﻿jQuery(document).ready(function()
{	
	var numeroElementos = 	jQuery("#menuSuperior > li").size();
	var anchoElemento = Math.floor((920 - ((numeroElementos-1)*4))/numeroElementos);
	jQuery("#menuSuperior > li").css({"width":anchoElemento + "px"});
	jQuery("#menuSuperior > li:last").css({"margin-right":"0px"});

	/* LLT: Scripts necesarios para que funcione el menú superior */
	jQuery("#menuSuperior ul, #menuSuperior ul li a").map(function () {if(!jQuery.browser.msie){jQuery(this).css({"width":"" + jQuery(this).parents("#menuSuperior > li").css("width") + ""});}else{jQuery(this).css({"width":"" + jQuery(this).parents("#menuSuperior > li").attr("offsetWidth") + ""});}});

	jQuery("#menuSuperior > li").hover(
		function () {
			jQuery(this).children("ul").show("75");
		}, 
		function () {
			jQuery(this).children("ul").hide("75");
		}
	);
	
	jQuery("#menuSuperior > li:not(#marcado)").hover(
	function () {
			jQuery(this).css({"background":"url('./IMG/FondoBotonPulsado.gif') top left repeat-x"});
		}, 
		function () {
			jQuery(this).css({"background":"url('./IMG/FondoBoton.gif') top left repeat-x"});
		}
	);
	
	jQuery("#menuSuperior ul li").hover(
		function () {
			jQuery(this).children("a").css({"background-color":"#DD6600"});
			jQuery(this).children("ul").show("75");
		},
		function () {
			jQuery(this).children("a").css({"background-color":"#FF6600"});
			jQuery(this).children("ul").hide("75");
		}
	);
	
	/*LLT: Hacer visible la familia seleccionada en el menú lateral */
	jQuery("#elementoSeleccionado").parents().children("ul").add("#elementoSeleccionado > ul").css({"display":"block"});
	
	/*LLT: Poner en negrita la familia seleccionada */
	jQuery("#elementoSeleccionado > a, #elementoSeleccionado > div").css({"font-weight":"bold","cursor":"pointer"});
	
	/*LLT: Alinear verticalmente el texto de todos los botones */
	jQuery("a.boton span, a.botonDerecha span, a.botonEliminar span").vAlign();
	
	
	/*LLT: Hacer que los paneles contengan los botones en Firefox */
	if(!jQuery.browser.msie)
	{
		jQuery("a.botonDerecha, a.botonEliminar").parents(".panel").css({"padding-bottom":"70px"})
	}
	
	jQuery("#elementoSeleccionado div").click(function() {
		jQuery("#elementoSeleccionado > ul").slideToggle('600', function() {
			// Animation complete.
		});
	});
});

function AbrirVentana(url,ancho,alto,funcionCallBack)
{
    showPopWin(url,ancho,alto,funcionCallBack);
}

function CapturarEnter(btnClientId,btnUniqueId,event)
{
    if (document.all)
    {
        if (event.keyCode==13)
        {
            event.returnValue=false;
            event.cancel=true;
            document.getElementById(btnClientId).click();
       
        }
    }
    else if (document.getElementById)
    {
        if (event.which==13)
        {
            event.returnValue=false;
            event.cancel=true;
            __doPostBack(btnUniqueId,'')
        }
    }
}

function ValidarCaracteres(textareaControl,maxlength,mensaje)
{    
    if (textareaControl.value.length > maxlength)
    {
        textareaControl.value = textareaControl.value.substring(0,maxlength);
        alert(mensaje);
    }
}
