
function MoveraPagina(numeropagina) {
	document.formulario.vnpage.value = numeropagina;
	document.formulario.submit();
}

// JavaScript para hacer llamadas sin post back
function nuevoAjax(){
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");  		// Creación del objeto ajax para navegadores diferentes a Explorer
	} catch (e) {
		try {								// o bien
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");		// Creación del objet ajax para Explorer
		} catch (E) {
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
		if (xmlhttp.overrideMimeType) {
                xmlhttp.overrideMimeType('text/xml');
            }
	}
	
	return xmlhttp;
}


// manejar el carrito de publicaciones
function manejarcarrito(p, c, a)
{
	ajax = nuevoAjax();
	ajax.open("GET","includes/manejarcarrito.asp?producto="+p+"&cantidad="+c+"&accion="+a, false);
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4) {
			if (ajax.status == 200) { 
				alert(ajax.responseText); 
			}
			else { 
				alert('Error, al acceder a la compra'); 
			}
		}
	}
	ajax.send(null);
}


var allLinks = document.getElementsByTagName("div"); 	
	
/*abre el menu del segundo nivel */		
var nombremenu
function abrir(nextSib) {	


   var seleccionadoelmenu1 = 0;
   
   overPrimerNivel();

		if (document.getElementById('Menu1').nextSibling.className != 'accion noAccion') {
			document.getElementById('Menu1').onmouseover = function() {primerDtMenu();};
		   document.getElementById('Menu1').onmouseout = function() {primerDtMenu(true);};	
		}
		else {
			seleccionadoelmenu1 = 1;
		}

	for (var i = 0; i < allLinks.length; i++)
		  {
		   if (allLinks[i].className == 'primerNivel' )
		   {
			     	allLinks[i].style.backgroundColor = 'transparent';  
			     	allLinks[i].style.color = '#000000';
			     	allLinks[i].style.backgroundImage = 'url(img/flechita.gif)';
		 	}//fin if		
		   }// fin for	   


	primerDtMenu(true);	
	if (nextSib.id!='Menu1') {

		nextSib.style.backgroundColor='#C70C07';		
		nextSib.style.color='#ffffff';
		nextSib.style.backgroundImage='url(img/flechita_on.gif)';
		nextSib.onmouseover = function() {nextSib.style.backgroundColor='#C70C07'; nextSib.style.color='#ffffff';};
		nextSib.onmouseout = function() {nextSib.style.backgroundColor='#C70C07'; nextSib.style.color='#ffffff';};
	}
	else {
		
		primerDtMenuSelecc();
		nextSib.onmouseover = function() {primerDtMenuSelecc();};
		nextSib.onmouseout = function() {primerDtMenuSelecc();};		
	}
	
	while (nextSib.nextSibling.nodeType != 1) {nextSib = nextSib.nextSibling};
	estado = nextSib.nextSibling.style.display;
	closeNav();		
	nextSib.nextSibling.style.display=estado;
	nextSib.nextSibling.style.display=nextSib.nextSibling.style.display=='block'?'none':'block';

	// Lo siguiente es para que el pie se ajuste al menú
	var ajuste = document.getElementById('ajuste');
	var suma = 0;
	suma = nextSib.nextSibling.childNodes.length;
	if(nombremenu == nextSib.id) {
		nombremenu = '';
		suma = 1;
	} else {
		nombremenu = nextSib.id;
	}
	
	 for (var i=0; i<allLinks.length; i++) {
	   if (allLinks[i].className=='accion noAccion') {
		 suma = suma + allLinks[i].childNodes.length;
	   }
	 }
	
		
	 ajuste.height = (parseInt(suma)/2*20)+400;

	
	 if (seleccionadoelmenu1==1) {
		primerDtMenuSelecc();
	 }
	 
}
		
		function closeNav()
		{
			var x = document.getElementsByTagName('div');
			for (var i=0;i<x.length;i++)
			{		
				if (x[i].className == 'accion' && x[i].className != 'accion noAccion') {x[i].style.display = 'none';}					
			}
		}

	
function ajustarlatablamenu() {
	
	var ajuste = document.getElementById('ajuste');
	var suma = 0;
	for (var i = 0; i < allLinks.length; i++)
	  {
	   if (allLinks[i].className == 'accion noAccion')
	   {
			suma = suma + allLinks[i].childNodes.length;
	   }
	 }
	 ajuste.height = (parseInt(suma)/2*20)+400;
}

 // onmouseover
function overPrimerNivel() { 
	
	 for (var i = 0; i < allLinks.length; i++)
	  {
	   if (allLinks[i].className == 'primerNivel')
	   {
	    allLinks[i].onmouseover = function()
		    {
		  		this.style.backgroundColor = '#C70C07';
		  		this.style.color = '#ffffff';	
		  		this.style.backgroundImage = 'none';						
		    }
	    allLinks[i].onmouseout = function()
		    {			
		     	this.style.backgroundColor = 'transparent';
		     	this.style.color = '#000000';			
		  		this.style.backgroundImage = 'url(img/flechita.gif)';		
		    }
	 	}//fin if		
	   }// fin for	   
}   
	


function montre(id) {	

	var h = document.getElementById(id);
	


function addAnEvent( target, eventName, functionName )
	{    
		var ua = navigator.userAgent.toLowerCase();
	    if (ua.indexOf('msie') != -1) {eval('target.on'+eventName+'=functionName');}   
	    else {target.addEventListener( eventName , functionName , true );}
	} 
	 

	
	function show()
		{			
			this.getElementsByTagName('A')[0].style.backgroundColor='#000000'; 
			this.getElementsByTagName('A')[0].style.color='#ffffff'; 	
			this.getElementsByTagName('SPAN')[0].style.visibility='visible';	
		}
	function timeoutHide()
		{			
			this.getElementsByTagName('A')[0].style.backgroundColor='transparent'; 
			this.getElementsByTagName('A')[0].style.color='#9E0000'; 	
			this.getElementsByTagName('SPAN')[0].style.visibility='hidden';	
		}

			
	if (h) {
			h.style.display='block';
			h.style.visibility='visible';
			h.parentNode.getElementsByTagName('A')[0].style.backgroundColor='#000000'; 
			h.parentNode.getElementsByTagName('A')[0].style.color='#ffffff'; 	
			h.parentNode.getElementsByTagName('SPAN')[0].style.visibility='visible';			
			}
	
	var lis = document.getElementsByTagName('ul');  
	
	if (!h) {
				for ( var i=0; i<lis.length; i++ )
			     {              
					if (lis.item(i).className=='segundoNivel') {
						lis.item(i).style.display='none'; 
						lis.item(i).style.visibility='hidden';
						lis.item(i).parentNode.getElementsByTagName('A')[0].style.backgroundColor='transparent'; 
						lis.item(i).parentNode.getElementsByTagName('A')[0].style.color='#9E0000'; 	
						lis.item(i).parentNode.getElementsByTagName('SPAN')[0].style.visibility='hidden';						
							/*if (lis.item(i).parentNode.getElementsByTagName('A')[0].className=='mantener') {																lis.item(i).parentNode.getElementsByTagName('A')[0].style.color='#ffffff'; 											lis.item(i).parentNode.getElementsByTagName('A')[0].style.backgroundColor='black'; 										lis.item(i).parentNode.getElementsByTagName('SPAN')[0].style.visibility='visible';	
										}*/
						}				
					<!-- Nuevo: Para el tercer nivel -->
					else if (lis.item(i).className=='tercerNivel') {
					lis.item(i).style.display='none'; 
					lis.item(i).style.visibility='hidden';
					lis.item(i).parentNode.getElementsByTagName('A')[0].style.backgroundColor='transparent'; 
					lis.item(i).parentNode.getElementsByTagName('A')[0].style.color='#FFFFFF'; 	
					lis.item(i).parentNode.getElementsByTagName('SPAN')[0].style.visibility='hidden';						
					/*if (lis.item(i).parentNode.getElementsByTagName('A')[0].className=='mantener') {																lis.item(i).parentNode.getElementsByTagName('A')[0].style.color='#ffffff'; 											lis.item(i).parentNode.getElementsByTagName('A')[0].style.backgroundColor='black'; 										lis.item(i).parentNode.getElementsByTagName('SPAN')[0].style.visibility='visible';	
										}*/
					}				
					<!-- Fin nuevo-->
			     }	
			}
}


	function primerDtMenu(esOver) 
	{   
		a = document.getElementById('Menu1');	
		if (esOver==true) {
			a.style.backgroundImage='url(img/primerLiMenu.gif)';
			a.className='esOver';
		}
		else {
			a.style.backgroundImage='url(img/primerLiMenu_on.gif)';
			a.className='noEsOver';
		}
	}


	
	function primerDtMenuSelecc()
	{
			a = document.getElementById('Menu1');	
			a.style.backgroundImage='url(img/primerLiMenu_on_selecc.gif)';
			a.className='noEsOver';	
	} 	

/* Funcion para cortar strings */
function cortarString ( texto, len)
{
	var lenS = len;
	var numberN = -1;
	var lasS = '';
	
	if(texto.length < len)
		lenS = texto.length;
	if(texto.length > len)
		numberN = texto.substr(0,lenS+1).lastIndexOf(" ");
	if(numberN == -1)
		numberN = lenS;
	else
		lasS = ' ...'
		texto = texto.substr(0,numberN) + lasS;
	
	return texto;
}

function LanzarMenu(enlace) {
	if( (enlace.indexOf('http:') != -1) || (enlace.indexOf('www.') != -1) )
	{
		enlace = enlace.replace("?", "{lainterrogacion}");
		enlace = enlace.replace("&", "{elampersam}");
		var pagina = 'enlacesexternos.asp?page=' + enlace;
		window.open(pagina,'_blank');
	}
	else 
	{
		window.location.href = enlace
	}
}

		
/* funcion onload */		
window.onload = function() {overPrimerNivel();} 



//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}



