
//Cambio del zoom
function changeZoom(zoom) {
	document.getElementsByTagName("body")[0].style.fontSize=zoom;	
}

// Cambia de direccion
function nav(value, flag) {
	if (flag == 0)
		return false;
	
	if (value != "") { 
		document.location.href = value; 
	}
} 

jQuery.noConflict();
jQuery(document).ready(function(){
	  // Para pintar las 3 A para aumentar el tam. del texto 	
	  var ulzoom="";
		try {
			ulzoom = '<ul class="Zoom"><li><a href="#" title="'+b+'" onclick="changeZoom(\'62.5%\'); return false;">A<span class="oculta">'+txtDesc+b+'</span></a> </li> '+
			'<li class="aa"><a href="#" title="'+aa+'" onclick="changeZoom(\'75%\'); return false;">A<span class="oculta">'+txtDesc+aa+'</span></a> </li> '+
			'<li class="aaa"><a href="#" title="'+aaa+'" onclick="changeZoom(\'100%\'); return false;">A<span class="oculta">'+txtDesc+aaa+'</span></a> </li></ul>';	
			}
		catch(e){
			ulzoom = '<ul class="Zoom"><li><a href="#" title="Normal" onclick="changeZoom(\'62.5%\'); return false;">A<span class="oculta"> > 62.5%</span></a> </li> '+
			'<li class="aa"><a href="#" title="> 75%" onclick="changeZoom(\'75%\'); return false;">A<span class="oculta"> > 75%</span></a> </li> '+
			'<li class="aaa"><a href="#" title="> 100%" onclick="changeZoom(\'100%\'); return false;">A<span class="oculta"> > 100%</span></a> </li></ul>';
		}
	
		jQuery(ulzoom).insertAfter('.Idiomas');

		//Focus al campo Usuario del bloque Entra y Opera
		try {
			jQuery('#txfUser').focus();
		}
		catch(e){}
		
		//Ajustar el min-height de los h3 de lista Prod en Segmentos
		var lgH3 = jQuery(".Segment .lProd h3").length;
		if(lgH3>0) {
			var maxH3 = 0;
			for(var i=0; i<lgH3; i++) {
				var minH3 = jQuery(".Segment .lProd h3").eq(i).height();
				var txt = jQuery(".Segment .lProd h3").eq(i).text();
				//alert('height '+i+' : '+minH3+' - text: '+txt);
				if(i==0)
					maxH3 = minH3;
				
				if(minH3 > maxH3)
					maxH3 = minH3;				
			}
			//alert(maxH3);
			if(maxH3 > 0) {
				maxH3 = (maxH3-6) / 10;
				if(jQuery.browser.msie && jQuery.browser.version == '6.0')
					jQuery(".Segment .lProd h3").height(maxH3+"em");
				else
					jQuery(".Segment .lProd h3").css("min-height", maxH3+"em");				
			}
		}
		
		//Ajustar el min-height de los bloques de lista Prod en Productos Gen.
		var claseGen = ".prodGen1";
		var lgGen = jQuery(claseGen).length;
		var lgGen2 = jQuery(".prodGen2").length;
		//alert('lgGen:'+lgGen+' lgGen2:'+lgGen2);
		if(lgGen2>0) { 
			lgGen=lgGen2;
			claseGen= ".prodGen2";
		}
		
		if(lgGen>0) {
			for(var j=0; j<lgGen; j++) {
				//Porque no se puede recuperar la altura de la lista UL, se tiene que recuperar el max de los LI de la lista UL
				var objUL = jQuery(claseGen).eq(j);
				var lgLI = jQuery(claseGen).eq(j).find("li").length;

				if(lgLI>0) {
					var maxLI = 0;
					for(var i=0; i<lgLI; i++) {
						var minLI = jQuery(claseGen).eq(j).find("li").eq(i).height();
						//alert('height '+i+' : '+minLI+' - text: '+txt);
						if(i==0)
							maxLI = minLI;
						
						if(minLI > maxLI)
							maxLI = minLI;				
					}
					//alert('maxLI final:'+maxLI);
					if(maxLI > 0) {
						maxLI = (maxLI) / 10;
						if(jQuery.browser.msie && jQuery.browser.version == '6.0') {
							jQuery(claseGen).eq(j).find("li").height(maxLI+"em");
							jQuery(claseGen).eq(j).find("li li").height("auto");				
						}
						else {
							jQuery(claseGen).eq(j).find("li").css("min-height", maxLI+"em");				
							jQuery(claseGen).eq(j).find("li li").css("min-height", "0em");				
						}
					}
				}
				
			}
		}

		//Ajustar el height de los bloques de lista Prod en Necesidades/Fam. Prod para IE6
		var claseProd = ".lProductos";
		var lgProd = jQuery(claseProd).length;
		
		if(lgProd>0) {
			for(var j=0; j<lgProd; j++) {
				//Porque no se puede recuperar la altura de la lista UL, se tiene que recuperar el max de los LI de la lista UL
				var objUL = jQuery(claseProd).eq(j);
				var lgLI = jQuery(claseProd).eq(j).find("li").length;

				if(lgLI>0) {
					var maxLI = 0;
					for(var i=0; i<lgLI; i++) {
						var minLI = jQuery(claseProd).eq(j).find("li").eq(i).height();
						if(i==0)
							maxLI = minLI;
						
						if(minLI > maxLI)
							maxLI = minLI;				
					}

					if(maxLI > 0) {
						maxLI = (maxLI) / 10;
						if(jQuery.browser.msie && jQuery.browser.version == '6.0') {
							jQuery(claseProd).eq(j).find("li").height(maxLI+1+"em");
							jQuery(claseProd).eq(j).find("li li").height("auto");
							jQuery(claseProd).eq(j).css("height", maxLI+2+"em");		
						}
					}
				}
			}
		}
		
		// Algunos retoques para Opera
		if(jQuery.browser.opera) {
			jQuery(".MainCol").css("width", "72.5%");
			jQuery(".MainCol").css("margin-right", "3px");
			jQuery(".SecondCol li img").css("width", "100%");
			jQuery(".Segment .MainCol").css("width", "71%");
			jQuery(".Segment .MainCol").css("margin-right", "2px");
			jQuery(".Segment .SecondCol li img").css("width", "98.5%");
			jQuery(".ProdGen .MainCol").css("width", "29%");
			jQuery(".ProdGen .MainCol").css("margin-right", "20px");
			jQuery(".ProdGen .SecondCol li img").css("width", "68%");

			jQuery(".MidColumn").css("width", "79.8%");
			jQuery(".parchedIE6").css("width", "61% !important");
			jQuery(".LeftColumn").css("margin-right", "2px !important");
			jQuery(".banPeque").css("width", "97%");
			jQuery(".banPeque").css("min-height", "22em");
			jQuery(".RightColumn .Prensa").css("padding", "2% 2% 1px 22px");
			jQuery(".EntraOpera").css("min-height", "20.7em");
			jQuery(".NavHorizontalComodin li a").css("min-height", "3.1em");
			jQuery(".LeftColumn .Boxes").css("min-height", "27.7em");
			jQuery(".SecondCol .Entrada").css("width", "100% !important");
			jQuery(".SecondCol .Entrada").css("margin-right", "0px !important");
			jQuery(".chat").css("width", "95% !important");
			jQuery(".chat").css("min-height", "48.5em");
			jQuery(".menuchat").css("width", "40% !important;");
			jQuery(".FormEntraOpera").css("padding", "1% 0 9px 3.5%");
		}

		// Algunos retoques para Safari/Chrome
		if(jQuery.browser.safari) {
			jQuery(".MainCol").css("margin-right", "3px");
			jQuery(".ProdGen .MainCol").css("width", "29%");
			jQuery(".ProdGen .MainCol").css("margin-right", "20px");
			jQuery(".ProdGen .SecondCol li img").css("width", "68%");
			jQuery(".RightColumn .Prensa").css("padding", "2% 2% 1px 22px");
			jQuery(".RightColumn .EntraOpera").css("padding-bottom", "9px");
			jQuery(".banPeque").css("min-height", "22.3em");
			jQuery(".EntraOpera").css("min-height", "20.5em");
			jQuery(".SecondCol li img").css("margin-bottom", "1px");
			jQuery(".NavHorizontalComodin li a").css("min-height", "3.1em");
			jQuery(".RightColumn li.HomeC").css("padding", "13px 0");
			jQuery(".LeftColumn .Boxes").css("min-height", "27.6em");
			jQuery(".chat").css("min-height", "48.7em");
			jQuery(".FormEntraOpera").css("padding", "0% 0 1px 3.5%");

		}
		// Chrome
		if(navigator.userAgent.toLowerCase().indexOf('chrome') > -1){
			jQuery(".EntraOpera").css("min-height", "20.5em");
			jQuery(".RightColumn li.HomeC").css("padding", "13.1px 0");
			jQuery(".SecondCol li.first").css("padding", "0");
		}
		
		// Ajustar el alto del bloque central con el bloque derecho
		var hR = jQuery(".RightColumn").height();
		var hM = jQuery(".MidColumn").height();
		var hN = jQuery(".NavHorizontalComodin").height();
		var hL = jQuery(".SecondCol ul").height();
		var hP = jQuery(".Producto").height();
		var ifr = document.getElementById("ifrm");
		var convEm;
		//alert('height RightColumn: '+hR + ' y MidColumn: '+hM+' NavHorizontalComodin: '+hN+' .SecondCol ul: '+ hL+' document.getElementById("ifrm"):'+ ifr + ' Producto: ' + hP);
		if( hR > hM || ifr || (hN>0 && hM-hN<hR)) {
			convEm = hR-16;
			if(hN>0) {
					convEm = convEm-hN-6;
			}

			if(hP>0) {
				convEm = convEm+3;

				// Para la pagina de Comparador no es necesario
				if(jQuery(".Comparador").length>0)
					convEm = convEm-3;

				if(jQuery.browser.msie){
					if(jQuery.browser.version == '6.0'){
						convEm = convEm+5;
						jQuery(".Entrada").css("margin-bottom", "0px");
					}
					else if(jQuery.browser.version == '7.0')
						convEm = convEm+2;
				}				
				
				// Chrome/Safari
				if(jQuery.browser.safari){
					convEm =convEm+62;
				}				
			}

			if(jQuery.browser.msie){
				if(jQuery.browser.version == '6.0')
					convEm = convEm+3;
				else if(jQuery.browser.version == '7.0')
					convEm = convEm+7;
				else if(jQuery.browser.version == '8.0')
					convEm = convEm+4;
			}				

			if(hL>0 && hP == null) {
				convEm = hR-258;
				if(jQuery.browser.msie){
					if(jQuery.browser.version == '6.0')
						convEm = hR-262;
					else if(jQuery.browser.version == '7.0')
						convEm = hR-253;
					else if(jQuery.browser.version == '8.0')
						convEm = hR-258;
				}

				// Chrome/Safari
				if(jQuery.browser.safari){
					convEm =convEm - 258;
				}
				
				//Opera
				if(jQuery.browser.opera) {
					convEm =convEm - 254;
				}
			}
			
			convEm = convEm / 10;
			if(jQuery.browser.msie && jQuery.browser.version == '6.0') {
				if(hL>0 && hP == null || hP>0 && ifr)
					jQuery(".Entrada").height("100%");
				else
					jQuery(".Entrada").height(convEm+"em");
			}
			else
				jQuery(".Entrada").css("min-height", convEm+"em");
		}
		else {
			if(hL>0 && hP == null) {
				convEm = hR-258;
				if(jQuery.browser.msie){
					if(jQuery.browser.version == '6.0')
						convEm = hR-262;
					else if(jQuery.browser.version == '7.0')
						convEm = hR-253;
					else if(jQuery.browser.version == '8.0')
						convEm = hR-258; 
				}

				// Chrome/Safari
				if(jQuery.browser.safari){
					convEm =hR - 258;
				}

				//Opera
				if(jQuery.browser.opera) {
					convEm =convEm - 254;
				}

				convEm = convEm / 10;
				if(jQuery.browser.msie && jQuery.browser.version == '6.0')
					jQuery(".Entrada").height(convEm+"em");
				else
					jQuery(".Entrada").css("min-height", convEm+"em");
			}
		}
		
});

