//si el dom esta listo cargamos menu
$(document).ready(function(){
 cargarmenu();
});

function cargarmenu(){

// modified to work on click of top item
$(document).ready(function(){

$("ul.topnav").parent().append(""); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)

$("ul.topnav li").mouseover(function() { //When trigger is clicked…

//Following events are applied to the subnav itself (moving subnav up and down)
// $(this).parent().find(”ul.subnav”).slideDown(’fast’).show(); //Drop down the subnav on click

$(this).find("ul.subnav").stop().slideDown('fast').show('slow', function(){
$(this).height("auto");
});

$(this).hover(function() {
}, function(){
$(this).find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
});

//Following events are applied to the trigger (Hover events for the trigger)
}).hover(function() {
$(this).addClass("subhover"); //On hover over, add class “subhover”
}, function(){ //On Hover Out
$(this).removeClass("subhover"); //On hover out, remove class “subhover”
});
});



	$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)
        //$("ul.topnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)
	$("ul.topnav li span").mouseover(function() { //When trigger is clicked...

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
}


function fancy(){
      $("a.example6").fancybox();
}

var videoAct=0;
function fancyVideosPosActual(element){
    videoAct=element;
}


function fancyVideos(){
var x=$("a#videos");
$("a#videos").click(function() {
                $.fancybox({
                
                        'padding'               : 0,
                        'autoScale'     : false,
                        'transitionIn'  : 'none',
                        'transitionOut' : 'none',
                        'title'                 : x[videoAct].title,
                        'titlePosition'	: 'inside',
                        'width'         : 680,
                        'height'                : 495,
                        'zIndex'               : 300,
                        'href'                  : x[videoAct].href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
                        'type'          : 'swf'
                });
                return false;
                }); 
}


function paginacion(){ 
$("#resultado").pagination(); }


function offSimulateClick(elementId) {
var event;
 var element = document.getElementById(elementId);
 if (document.createEvent) {
 event = document.createEvent("MouseEvents");
 if (event.initMouseEvent) {
 event.initMouseEvent("click", true, true, window,
 0, 0, 0, 0, 0, false, false, false, false, 0, null);
 } else {
 event = false;
 }
 }
 (event) ? element.dispatchEvent(event) : (element.click && element.click());
}

function disabledNode()
{
   //se busca el arbol con hijos
   var div= $("div#table4").find("div");
   
   //se recorren todos los divs del arbol
   for(var i=0; i<div.length;i++)
   {
        var hijo = div[i].children;
        //en el caso que tenga hijos, significa que es un  nodo desplegable
        if(hijo.length!=0)
        {
            //se obtiene la id del desplegable para ponersela al input
           var id = hijo[0].id; 
           div[i].style.fontStyle="italic";
           var cadena = id.split(':');
           var input = document.getElementById("table4:"+cadena[1]);
           //input.disabled = true;
           input.style.display="none";
        }
   }
}

function asignarIdHistorico (p_ident){
var ident = document.getElementById("f:ident");
ident.value=p_ident;
}


