function mmLoadMenus() 
{
  window.mm_menu_empresa_0 = new Menu("root",116,17,"Verdana, Arial, Helvetica, sans-serif",11,"#333333","#ffffff","#ffffff","#cc9966","center","middle",3,0,500,-5,7,true,true,true,0,true,true);
  mm_menu_empresa_0.addMenuItem("Nosotros","location='../pages/nosotros.php'");
  mm_menu_empresa_0.addMenuItem("Dec&aacute;logo","location='../pages/decalogo.php'");
  mm_menu_empresa_0.addMenuItem("Historia","location='../pages/historia.php'");
  mm_menu_empresa_0.fontWeight="bold";
  mm_menu_empresa_0.hideOnMouseOut=true;
  mm_menu_empresa_0.bgColor='#cc9966';
  mm_menu_empresa_0.menuBorder=1;
  mm_menu_empresa_0.menuLiteBgColor='#cc9966';
  mm_menu_empresa_0.menuBorderBgColor='#cc9966';

  window.mm_menu_productos_0 = new Menu("root",200,17,"Verdana, Arial, Helvetica, sans-serif",11,"#333333","#ffffff","#ffffff","#cc9966","center","middle",3,0,500,-5,7,true,true,true,0,true,true);
	mm_menu_productos_0.addMenuItem("Cerrajer&iacute;a","location='../pages/productos_otros.php?id_cat=8'");
	mm_menu_productos_0.addMenuItem("Ferreter&iacute;a","location='../pages/productos_otros.php?id_cat=13'");
	mm_menu_productos_0.addMenuItem("Herramientas de Corte","location='../pages/productos_otros.php?id_cat=6'");
	mm_menu_productos_0.addMenuItem("Herramientas Manuales","location='../pages/productos_otros.php?id_cat=5'");
	mm_menu_productos_0.addMenuItem("Otras L&iacute;neas","location='../pages/productos_otros.php?id_cat=10'");
	mm_menu_productos_0.addMenuItem("Refrigeraci&oacute;n","location='../pages/productos_otros.php?id_cat=7'");		
	mm_menu_productos_0.addMenuItem("Reguladores y V&aacute;lvulas","location='../pages/productos_otros.php?id_cat=9'");
	mm_menu_productos_0.addMenuItem("Soldaduras","location='../pages/productos_otros.php?id_cat=4'");
	mm_menu_productos_0.fontWeight="bold";
	mm_menu_productos_0.hideOnMouseOut=true;
	mm_menu_productos_0.bgColor='#cc9966';
	mm_menu_productos_0.menuBorder=1;
	mm_menu_productos_0.menuLiteBgColor='#cc9966';
	mm_menu_productos_0.menuBorderBgColor='#cc9966';
  
  window.mm_menu_cobre_0 = new Menu("root",150,17,"Verdana, Arial, Helvetica, sans-serif",11,"#333333","#ffffff","#ffffff","#cc9966","center","middle",3,0,500,-5,7,true,true,true,0,true,true);

  

  
  mm_menu_cobre_0.addMenuItem("Tuber&iacute;a de Cobre","location='../pages/productos_cobre.php?id_cat=1'");
  mm_menu_cobre_0.addMenuItem("Barras de Cobre","location='../pages/productos_cobre.php?id_cat=12'");
  mm_menu_cobre_0.addMenuItem("Bobinas de Cobre","location='../pages/productos_cobre.php?id_cat=11'");
  mm_menu_cobre_0.addMenuItem("Conexiones","location='../pages/productos_cobre.php?id_cat=2'");
  mm_menu_cobre_0.addMenuItem("L&aacute;minas de Cobre","location='../pages/productos_cobre.php?id_cat=3'");
  mm_menu_cobre_0.fontWeight="bold";
  mm_menu_cobre_0.hideOnMouseOut=true;
  mm_menu_cobre_0.bgColor='#cc9966';
  mm_menu_cobre_0.menuBorder=1;
  mm_menu_cobre_0.menuLiteBgColor='#cc9966';
  mm_menu_cobre_0.menuBorderBgColor='#cc9966';
  
  window.mm_menu_recursos_0 = new Menu("root",100,17,"Verdana, Arial, Helvetica, sans-serif",11,"#333333","#ffffff","#ffffff","#cc9966","center","middle",3,0,500,-5,7,true,true,true,0,true,true);
  mm_menu_recursos_0.addMenuItem("Enlaces","location='../pages/enlaces.php'");
  mm_menu_recursos_0.addMenuItem("Descargas","location='../pages/descargas.php?des=1'");
  mm_menu_recursos_0.addMenuItem("Videos","location='../pages/videos.php'");
  mm_menu_recursos_0.fontWeight="bold";
  mm_menu_recursos_0.hideOnMouseOut=true;
  mm_menu_recursos_0.bgColor='#cc9966';
  mm_menu_recursos_0.menuBorder=1;
  mm_menu_recursos_0.menuLiteBgColor='#cc9966';
  mm_menu_recursos_0.menuBorderBgColor='#cc9966';

  mm_menu_empresa_0.writeMenus();
} 


function MM_showMenu(menu, x, y, child, imgname) {
	if (!window.mmWroteMenu) return;
	MM_clearTimeout();

	if (menu) {
		var obj = FIND(imgname) || document.images[imgname] || document.links[imgname] || document.anchors[imgname];
		x = moveXbySlicePos (x, obj);
		y = moveYbySlicePos (y, obj);
		showIframeShim(imgname, x);
	}
	if (document.layers) {
		if (menu) {
			var l = menu.menuLayer || menu;
			l.top = l.left = 1;
			hideActiveMenus();
			if (this.visibility) l = this;
			window.ActiveMenu = l;
		} else {
			var l = child;
		}
		if (!l) return;
		for (var i=0; i<l.layers.length; i++) {
			if (!l.layers[i].isHilite) l.layers[i].visibility = "inherit";
			if (l.layers[i].document.layers.length > 0) MM_showMenu(null, "relative", "relative", l.layers[i]);
		}
		if (l.parentLayer) {
			if (x != "relative") l.parentLayer.left = x || window.pageX || 0;
			if (l.parentLayer.left + l.clip.width > window.innerWidth) l.parentLayer.left -= (l.parentLayer.left + l.clip.width - window.innerWidth);
			if (y != "relative") l.parentLayer.top = y || window.pageY || 0;
			if (l.parentLayer.isContainer) {
				l.Menu.xOffset = window.pageXOffset;
				l.Menu.yOffset = window.pageYOffset;
				l.parentLayer.clip.width = window.ActiveMenu.clip.width +2;
				l.parentLayer.clip.height = window.ActiveMenu.clip.height +2;
				if (l.parentLayer.menuContainerBgColor && l.Menu.menuBgOpaque ) l.parentLayer.document.bgColor = l.parentLayer.menuContainerBgColor;
			}
		}
		l.visibility = "inherit";
		if (l.Menu) l.Menu.container.visibility = "inherit";
	} else if (FIND("menuItem0")) {
		var l = menu.menuLayer || menu;
		hideActiveMenus();
		if (typeof(l) == "string") l = FIND(l);
		window.ActiveMenu = l;
		var s = l.style;
		s.visibility = "inherit";
		if (x != "relative") {
			s.pixelLeft = x || (window.pageX + document.body.scrollLeft) || 0;
			s.left = s.pixelLeft + 'px';
		}
		if (y != "relative") {
			s.pixelTop = y || (window.pageY + document.body.scrollTop) || 0;
			s.top = s.pixelTop + 'px';
		}
		l.Menu.xOffset = document.body.scrollLeft;
		l.Menu.yOffset = document.body.scrollTop;
	}
	if (menu) window.activeMenus[window.activeMenus.length] = l;
	MM_clearTimeout();
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function exec_search()
{
	var txt = document.getElementById("txtSearch");
	var prm = trim(txt.value, " ");
	var prm2 = prm.replace(/ /g, "+");
	//alert(prm2);
	window.location="/pages/busqueda.php?sc=" + prm2;
}

function KeyPress(e)
{ 
	var tecla = (document.all) ? e.keyCode : e.which; // 2
	
	if (tecla == 13)
	 {
		 exec_search();
	 }
}

//--- AJAX LENGUAJE

function nuevoAjax()
{
/* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
lo que se puede copiar tal como esta aqui */
	var xmlhttp=false;
	try
	{
		// Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
		// Creacion del objet AJAX para IE
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(E) 
		{ 
			xmlhttp=false; 
		}
	}
	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') 
	{ 
		xmlhttp=new XMLHttpRequest(); 
	}
	return xmlhttp;
}

function changeLanguage(idLanguage)
{
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	var sPathPrm = window.location.href;
	var sPagePrm = sPathPrm.indexOf("?");	
	var refPage = "";
	
	if (sPagePrm != -1)
	{
		var sPara = window.location.href.split("?");
		rPage = sPara[1].substring(sPara[1].lastIndexOf('=') + 1);
		
		if(sPage == "productos_otros.php")
			refPage = "/pages_i/others_product.php?id_cat="+rPage;
		
		if(sPage == "others_product.php")
			refPage = "/pages/productos_otros.php?id_cat="+rPage;
			
		if(sPage == "productos_cobre.php")
			refPage = "/pages_i/copper_products.php?id_cat="+rPage;
		
		if(sPage == "copper_products.php")
			refPage = "/pages/productos_cobre.php?id_cat="+rPage;
			
		if(sPage == "descargas.php")
			refPage = "/pages_i/downloads.php?des="+rPage;
		
		if(sPage == "downloads.php")
			refPage = "/pages/descargas.php?des="+rPage;
	}
	
	if(sPath == "/")
		refPage = "/index_i.php";
	
	if(sPage == "index.php")
		refPage = "/index_i.php";
		
	if (sPage == "index_i.php")
		refPage = "/index.php";
	
	if(sPage == "nosotros.php")
		refPage = "/pages_i/about.php";
		
	if (sPage == "about.php")
		refPage = "/pages/nosotros.php";
		
	if (sPage == "decalogo.php")
		refPage = "/pages_i/decalogue.php";
		
	if (sPage == "decalogue.php")
		refPage = "/pages/decalogo.php";
		
	if(sPage == "historia.php")
		refPage = "/pages_i/history.php";
		
	if (sPage == "history.php")
		refPage = "/pages/historia.php";
	
	if (sPage == "novedades.php")
		refPage = "/pages_i/new_products.php";
		
	if (sPage == "new_products.php")
		refPage = "/pages/novedades.php";
		
	if (sPage == "productos_detalle.php")
	{
		var sParameters = window.location.href.split("?");
		refPage = "/pages_i/products_detail.php?"+ sParameters[1];
	}
	
	if (sPage == "products_detail.php")
	{
		var sParameters = window.location.href.split("?");
		refPage = "/pages/productos_detalle.php?"+ sParameters[1];
	}
	
	if (sPage == "cobre_detalle.php")
	{
		var sParameters = window.location.href.split("?");
		refPage = "/pages_i/copper_detail.php?"+ sParameters[1];
	}
	
	if (sPage == "copper_detail.php")
	{
		var sParameters = window.location.href.split("?");
		refPage = "/pages/cobre_detalle.php?"+ sParameters[1];
	}
	
	if (sPage == "enlaces.php")
		refPage = "/pages_i/links.php";
		
	if (sPage == "links.php")
		refPage = "/pages/enlaces.php";
			
	if (sPage == "videos.php")
		refPage = "/pages_i/video.php";
		
	if (sPage == "video.php")
		refPage = "/pages/videos.php";
	
	if (sPage == "contactos.php")
		refPage = "/pages_i/contact.php";
		
	if (sPage == "contact.php")
		refPage = "/pages/contactos.php";
		
	if (sPage == "busqueda.php")
	{
		var sParameters = window.location.href.split("?");
		refPage = "/pages_i/search.php?"+ sParameters[1];
	}
	
	if (sPage == "search.php")
	{
		var sParameters = window.location.href.split("?");
		refPage = "/pages/busqueda.php?"+ sParameters[1];
	}
	
	if (sPage == "sitemap.php")
		refPage = "/pages_i/sitemap_i.php";
		
	if (sPage == "sitemap_i.php")
		refPage = "/pages/sitemap.php";
	
	
	window.location = refPage;
}

function showIframeShim(typeMenu, L)
{
	var shimmer = document.createElement('iframe');
    shimmer.id='shimmer';
    shimmer.style.position='absolute';
	
	var posLeft = L+'px';
	
	// normally you would get the dimensions and
	// positions of the sub div dynamically. For demo
	// purposes this is hardcoded
	shimmer.style.height='20px';
	shimmer.style.top='225px';
	shimmer.style.zIndex='0';
	shimmer.setAttribute('frameborder','0');
	shimmer.setAttribute('scrolling', 'no');
	shimmer.setAttribute('src','');
	
	browserType = 0; // Default Internet Explorer
	
	if (navigator.appName == 'Netscape')
		browserType = 1;
	
	if (typeMenu == "empresa") {
		shimmer.style.left=posLeft;

		shimmer.style.width='121px';		
		if (browserType == 1)
			shimmer.style.width='121px';
	}
	else if (typeMenu == "productos") {
		//shimmer.style.left='297px';
		shimmer.style.left=posLeft;
		
		shimmer.style.width='204px';		
		if (browserType == 1)
			shimmer.style.width='205px';
	}
	else if (typeMenu == "cobre") {
		shimmer.style.left=posLeft;
		//shimmer.style.left='390px';

		shimmer.style.width='155px';		
		if (browserType == 1)
			shimmer.style.width='156px';
	}
	else if (typeMenu == "recursos") {
		shimmer.style.left=posLeft;
		//shimmer.style.left='456px';

		shimmer.style.width='105px';		
		if (browserType == 1)
			shimmer.style.width='106px';
	}

	document.body.appendChild(shimmer);
	// make sub div visible       
}
