var activomenu
var desplegado
var menuvisto
DHTML_IE = false
DHTML_NS = false
DHTML_W3C = false
if (document.all) { DHTML_IE = true }
else {
	if (document.layers) { DHTML_NS = true }
	else {
		if (document.getElementById) { DHTML_W3C = true }
	}
}
menuvisto = false
flechaon = new Image()
flechaon.src = "/img/fa.gif"
flechaoff = new Image()
flechaoff.src = "/img/pa.gif"
desplegado = false


function nosel() {
	if (DHTML_IE) {		
		document.onselectstart = new Function ("return false;");
		setTimeout("nosel()",200);
	}
	if (DHTML_NS||DHTML_W3C) {
		if (DHTML_NS) { var t = document.getSelection(); }
		else { var t = window.getSelection(); }
		if (t !="") {
			if (t !=" ") {
				window.find (" ");
			}
		}
		setTimeout("nosel()",20);
	}	
}

//nosel()	

function Muestra(fila,y_relativa_i,y_relativa_n,y_absoluta) {
	OcultarTodo();	
	if (DHTML_W3C)  {
		eval("document.getElementById('f" + fila + "').style.backgroundColor='#D68418'"); 
		eval("posicion = (y_relativa_n-pageYOffset) + pageYOffset - (((y_absoluta-85-pageYOffset)/(screen.availHeight - 85))*14*lineas[" + fila + "])");
		eval("document.getElementById('m" + fila + "').style.top = posicion + 'px'");	
		eval("document.getElementById('m" + fila + "').style.left = screen.availWidth * 0.1443 + 'px'")
		eval("document.getElementById('m" + fila + "').style.visibility = 'visible'");
		eval("document.getElementById('fl" + fila + "').src=flechaon.src");
		activomenu = fila
	}
	if (DHTML_IE) {
		eval("document.all.f" + fila + ".bgColor='#D68418'");		
		eval("posicion = y_relativa_i + document.body.scrollTop - (((y_absoluta-85)/(screen.availHeight - 85))*14*lineas[" + fila + "])");
		eval("document.all['m" + fila + "'].style.pixelTop = posicion");		
		eval("document.all['m" + fila + "'].style.pixelLeft = screen.availWidth * 0.1468")
		eval("document.all['m" + fila + "'].style.visibility = 'visible'");
		eval("document.fl" + fila + ".src=flechaon.src");
		activomenu = fila
	}
	if (DHTML_NS) {		
		eval("posicion = (y_relativa_n-pageYOffset) + pageYOffset - (((y_absoluta-85-pageYOffset)/(screen.availHeight - 85))*14*lineas[" + fila + "])");
		eval("document.layers['m" + fila + "'].top = posicion");	
		eval("document.layers['m" + fila + "'].left = screen.availWidth * 0.1443")
		eval("document.layers['m" + fila + "'].visibility = 'show'");
		eval("document.fl" + fila + ".src=flechaon.src");
		activomenu = fila
	}
}

function OcultarTodo() {
	menuvisto = false
	if (activomenu !=null) {
		if (DHTML_W3C) {
			eval("document.getElementById('f" + activomenu + "').style.backgroundColor='#2172BD'");
			eval("document.getElementById('m" + activomenu + "').style.visibility = 'hidden'");
			eval("document.getElementById('fl" + activomenu + "').src=flechaoff.src");
		}
		if (DHTML_IE) {
			eval("document.all.f" + activomenu + ".bgColor='#2172BD'");
			eval("document.all['m" + activomenu + "'].style.visibility = 'hidden'");
			eval("document.fl" + activomenu + ".src=flechaoff.src");
			activomenu = null
		}
		if (DHTML_NS) {
			eval("document.layers['m" + activomenu + "'].visibility = 'hide'");
			eval("document.fl" + activomenu + ".src=flechaoff.src");
			activomenu = null		
		}
	}
}

function cliqui(e) {
	if (DHTML_W3C) {
	 	id = e.target.id
	 	if (id) {
			if (id.charAt(0) == "m") {
				menuvisto = true
			}
			else {
				if (menuvisto) {
					OcultarTodo();				
				}	
			}
		}
   }
	if (DHTML_IE) {
	 	id = event.srcElement.id	 	
	 	if (id != "[object]") {
			if (id.charAt(0) == "m") {
				menuvisto = true
			}
			else {
				if (menuvisto) {
					OcultarTodo();				
				}	
			}
   	}
   }
  if (DHTML_NS) {
   	if (e.x == e.pageX) {
   		if (desplegado) { 
   			OcultarTodo();
   			desplegado = false
   		 }
   	}
   	else {
   		desplegado = true
   	}
   }
}

function inicio() {
    //if (document.layers) {
    //   document.captureEvents(Event.MOUSEMOVE); 
    //}
    //	document.onmousemove = cliqui;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
	 document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function Favoritos() {
	window.external.AddFavorite("http://www.www.latiendadelnavegante.com/","La Tienda del Navegante - Tu tienda náutica");
}	

function abrirdocumento(nombre) {
	window.open(nombre,"documento","scrollbars=no,status=no,toolbar=no,menubar=no,resizable=yes,width=630, height=500,left=10,top=10");
}

function abrirarchivo(nombre) {
	window.open(nombre,"documento","scrollbars=no,status=no,toolbar=no,menubar=no,resizable=no,width=300, height=110,left=100,top=100");
}

function abrirventana(dir,width,height,scrollbars,resizable) {
	window.open(dir,"popup","width=" + width + ",height=" + height + ",scrollbars=" + scrollbars + ",status=no,toolbar=no,menubar=no,resizable=" + resizable + ",left=30,top=20");
}

function GoTo(dir) {
	location.href = dir;	
}

function MostrarFecha()
	{
	var nombres_dias = new Array("Domingo", "Lunes", "Martes", "Mi&eacute;rcoles", "Jueves", "Viernes", "Sábado")
	var nombres_meses = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre")

	var fecha_actual = new Date()

	dia_mes = fecha_actual.getDate()		//dia del mes
	dia_semana = fecha_actual.getDay()		//dia de la semana
	mes = fecha_actual.getMonth() + 1
	anio = fecha_actual.getYear()

	if (anio < 100)							//pasa el año a 4 digitos
		anio = '19' + anio
	else {
		var cadena_anio = new String(anio)
		anio = '20' + cadena_anio.substring(2,4)
	}

	//escribe en pagina
	return(nombres_dias[dia_semana] + ", " + dia_mes + " de " + nombres_meses[mes - 1] + " de " + anio)
}

function PopUpAyuda (pagina,sesion) {
	ayuda = window.open('','ayuda','scrollbars=no,status=no,toolbar=no,menubar=no,resizable=yes,width=600,height=500,top=10,left=10');
	ayuda.document.open('text/html', 'replace');
	ayuda.document.write('<HTML><HEAD><TITLE>Ayuda en línea</TITLE>');
	ayuda.document.write("<frameset rows='50,*,80' frameborder='NO' border='0'  framespacing='0'>");
	ayuda.document.write("<frame name='top' src='/ayuda_online_top.html' scrolling='no'>");
	ayuda.document.write("<frame name='middle' src='/ayuda_online_middle.asp?pagina=" + pagina + "&sesion=" + sesion + "' scrolling='auto'>");
	ayuda.document.write("<frame name='bottom' src='/ayuda_online_bottom.asp?pagina=" + pagina + "&sesion=" + sesion + "' scrolling='auto'>");
	ayuda.document.write('</frameset></html>');
	ayuda.document.close();
}

function Recomendar(nombre,sesion,pagina,cod) {
	dir = "/recomendar.asp?cod=" + cod + "&nombre=" + nombre + "&pagina=" + pagina + "&sesion=" + sesion
	abrirventana(dir,300,400,'no','yes')	
}

function DeCrypt (texto) {
	var cadena
	cadena = ""
	for(i=0;i<=texto.length;i++){
		cadena = cadena + String.fromCharCode(texto.charCodeAt(i)-1);				
	}
	document.write (cadena);
	
}

function ProductoStock(tipo) {
   if (tipo == 2) {
		titulo = "Artículo bajo pedido";
   	}
   else {
  		titulo = "Artículo en stock";
   }	
	infostock = window.open('','infostock','scrollbars=no,status=no,toolbar=no,menubar=no,resizable=no,width=300,height=160,top=30,left=30');
 	infostock.document.open('text/html', 'replace');
	infostock.document.write("<HTML><HEAD><TITLE>" + titulo + "</TITLE></head>");
	infostock.document.write("<body bgcolor=#D3E8FF leftmargin=0 rightmargin=0 topmargin=0 marginwidth=0 marginheight=0>");
	infostock.document.write("<table width='100%' height='100%' border=0 cellpadding=10 cellspacing=0>");
	infostock.document.write("<tr height=45 bgcolor=#1878D1><td align='center' valign='middle'><font face='tahoma' size=2 color=white><b>" + titulo + "</b></td></tr>");
	infostock.document.write("<tr><td valign='middle'><font face='tahoma' size=2 color=#1878D1>");
   if (tipo == 2) {
		infostock.document.write("Este producto no está disponible en nuestro almacen por lo que su tiempo de entrega se <b>incrementará en un mínimo de 2 o 3 días</b> dependiendo de nuestros proveedores.")
   	}
   else {
  		infostock.document.write("Este producto habitualmente está en nuestro almacen por lo que su envío es inmediato con un tiempo de <b>entrega de 4 a 6 días</b>.")
   }	
	infostock.document.write("</font></td></tr></table></body></html>");
	infostock.document.close();
}

function PopUp(cod) {
	window.open("/popup.asp?c=" + cod,"popup","width=350, height=300,scrollbars=yes,status=no,toolbar=no,menubar=no,resizable=yes");
}


  
function AgregaFormato(control) {
  var Texto = "" + control;
  if (Texto.indexOf('.') > -1){
		var Entero = String(Texto.substring(0,Texto.indexOf('.')));
		var Decimal = String(Texto.substring(Texto.indexOf('.')+1,Texto.length))
	}
	else{
		var Entero = Texto;
		var Decimal = String("00")
	}
	if (Decimal.length == 1) {
		Decimal = Decimal + "0"
	}
	Decimal = Decimal.substring(0,2);
	if (Entero.indexOf('-') > -1){
		Entero = Entero.substring(1,Entero.length);
	}
	if (Entero == ""){
		Entero = "0";
	}
	var Max = Entero.length / 3;
	for (var i=0; i < Max - 1; i++){
		if (Entero.indexOf('.') > -1) {
			Entero = Entero.substring(0,Entero.indexOf(',') - 3) + '.' + Entero.substring(Entero.indexOf('.') - 3,Entero.length);
		}
		else{
			Entero = Entero.substring(0,Entero.length - 3) + '.' + Entero.substring(Entero.length - 3,Entero.length);
		}
	}
	if (Texto.indexOf('-')> -1){
		resultado = "-" + Entero + "," + Decimal
	}
	else{
		resultado = Entero + "," + Decimal
	}
	
	return resultado;
}

function MostrarCapa(nombrecapa,pi_show) {
	var display;
	var use_del_to_inv;
	if(pi_show){
		document.getElementById(nombrecapa).style.display='block';
	}
	else {
		document.getElementById(nombrecapa).style.display='none';
	}
	return 1;

}
