//**************************************************************************************
function fAbreOpcion(iintCual)
{	switch(iintCual)
	{	case 1:
			window.open('../contenido.asp','neurtek_contenido');
			window.open('../menu/index.asp?modulo=0','neurtek_menu');
			fActualizaFrame(fM("BienvenidoaNeurtek"),'neurtek_titulo_cabecera');
			break;
		case 3:
			window.open('../menu/index.asp?modulo=14','neurtek_menu');
			fActualizaFrame(fM("Favoritos"),'neurtek_titulo_cabecera');
			break;
		case 6:
			window.open('../menu/index.asp?modulo=6','neurtek_menu');
			fActualizaFrame(fM("AgendaEventos"),'neurtek_titulo_cabecera');
			break;
		case 7:
			window.open('../otros/foro/index.asp','neurtek_contenido');
			window.open('../menu/index.asp?modulo=2','neurtek_menu');
			break;
		case 8:
			window.open('../otros/noticias/index.asp','neurtek_contenido');
			window.open('../menu/index.asp?modulo=1','neurtek_menu');
			fActualizaFrame('Neurtek Magazine','neurtek_titulo_cabecera');
			break;
		case 9:
			window.open('../otros/noticias/index.asp?pg=13&id=0','neurtek_contenido');
			window.open('../menu/index.asp?modulo=8','neurtek_menu');
			fActualizaFrame('Boletines Neurtek','neurtek_titulo_cabecera');
			break;
		case 12:
			window.open('../gestordocumentos/index.asp?opcion=listaweb','neurtek_contenido');
			window.open('../menu/index.asp?modulo=7','neurtek_menu');
			break;
		case 13:
			window.open('../faq/index.asp?pg=4','neurtek_contenido');
			window.open('../menu/index.asp?modulo=3','neurtek_menu');
			break;
		case 14:
		case 16:
			window.open('../faq/index.asp?pg=3','neurtek_contenido');
			window.open('../menu/index.asp?modulo=4','neurtek_menu');
			break;
		case 15:
			window.open('../pedidos/index.asp?pg=1','neurtek_contenido');
			window.open('../menu/index.asp?modulo=11','neurtek_menu');
			fActualizaFrame(fM('PedidoEnCurso'),'neurtek_titulo_cabecera');
			break;
		case 17:
			window.open('../otros/usuarios/index.asp?pg=regi','neurtek_contenido');
			window.open('../menu/index.asp?modulo=5','neurtek_menu');
			break;
		case 18:
			fValidarFormulario();
			break;
		case 19:
			window.open('../menu/index.asp?modulo=9','neurtek_menu');
			fActualizaFrame(fM('CatalogoProductos'),'neurtek_titulo_cabecera');
			break;
		case 20:
			window.open('../menu/index.asp?modulo=10','neurtek_menu');
			fActualizaFrame(fM('CatalogoSectorial'),'neurtek_titulo_cabecera');
			break;
		case 21:
			window.open('../menu/index.asp?modulo=12','neurtek_menu');
			window.open('../catalogo/index.asp?pg=4','neurtek_contenido');
			fActualizaFrame(fM('Novedades'),'neurtek_titulo_cabecera');
			break;
		case 22:
			window.open('../menu/index.asp?modulo=13','neurtek_menu');
			window.open('../catalogo/index.asp?pg=5','neurtek_contenido');
			fActualizaFrame(fM('Ofertas'),'neurtek_titulo_cabecera');
			break;
		default:
			break;
	}
}
//**************************************************************************************
	function fCargarDias(intDia,intMes,intAnho,nombre_campo,nombre_contenedor){
		//alert("DIA: "+intDia);
		//alert("MES: "+intMes);
		contenido='<select name='+nombre_campo+' class=textoinput>';
				
		if (intMes==2){
			finnal=28;
		}
		else{
			if (intMes==1 || intMes==3 || intMes==5 || intMes==7 || intMes==8 || intMes==10 || intMes==12){finnal=31;}
			else{finnal==30;}
		}
		
		//alert ("FINAL: "+finnal);
		for(i=1;i<=finnal;i++)
		  {
			if(i==intDia)
		  		contenido=contenido+'<option value='+i+' class=opcion'+(Math.abs(1-(i%2)))+' selected>'+i+'</option>';
		  	else
		  		contenido=contenido+'<option value='+i+' class=opcion'+(Math.abs(1-(i%2)))+'>'+i+'</option>';
		  }
		  contenido=contenido+'</select>';
		  		  	  
		  //if(navigator.appName.indexOf("Microsoft")!=-1)
			//{
			//alert(nombre_contenedor);
			document.getElementsByName(nombre_contenedor).item(0).innerHTML = contenido;
		//	}
		  //else
		  	//if(navigator.appName.indexOf("Netscape")!=-1)
			//	{document.write(contenido);}
		  	//else
		  	//	if(navigator.appName.indexOf("Opera")!=-1)
		  		//	{document.write(contenido);}
	}
	
//**************************************************************************************
//	funcion que recibiendo el nombre del mes (nombre_mes), coje su valor del formulario (que es un numero), llama a la funcion
//	finMes para que le devuelva el numero de dias que contiene ese mes, y crea un <select> de nombre nombre_campo que tenga
//	como valores los dias de ese mes. Tambien se le pasa a esta funcion el nombre del lugar donde se quiere que se escriba dinamicamente
//	este select creado (nombre_contenedor)
//**************************************************************************************
	 function cambia_dias(nombre_campo,nombre_contenedor,mes,nombre_mes,anho,dia_sel)
	 {	  if (mes)
			mes = '1';
		  else
		  	mes = document.getElementsByName(nombre_mes).item(0).value;
		  	
		  var contenido='<select name='+nombre_campo+' class=textoinput>';
		  finnal = finMes(mes);
		  if(mes == 2 && ((document.getElementsByName(anho).item(0)) ? document.getElementsByName(anho).item(0).value : null ) %4==0 && !(document.getElementsByName(anho).item(0).value%100==0 && document.getElementsByName(anho).item(0).value%400!=0) )
				finnal = 29;
		  
		  for(i=1;i<=finnal;i++)
		  {
			if(i==dia_sel)
		  		contenido=contenido+'<option value='+i+' class='+(Math.abs(1-(i%2)))+' selected>'+i+'</option>';
		  	else
		  		contenido=contenido+'<option value='+i+' class='+(Math.abs(1-(i%2)))+'>'+i+'</option>';
		  }
		  contenido=contenido+'</select>';
		  
		  if(navigator.appName.indexOf("Microsoft")!=-1)
			{document.getElementsByName(nombre_contenedor).item(0).innerHTML = contenido;}
		  else
		  	if(navigator.appName.indexOf("Netscape")!=-1)
				{document.write(contenido);}
		  	else
		  		if(navigator.appName.indexOf("Opera")!=-1)
		  			{document.write(contenido);}
	 }
//****************************************************
function ventana(vurl,valto,vancho)
{
  var str = "height=" + valto + ",innerHeight=" + valto;
  str += ",width=" + vancho + ",innerWidth=" + vancho;
  var nombre;
  nombre="_blank";
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - vancho) / 2;
    var yc = (ah - valto) / 2;

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
    
  }
	window.open(vurl,'external',str,'height='+valto+',innerHeight='+valto+',width='+vancho+',innerWidth='+vancho).focus();
}
//*****************************************************
function ventana2(vurl,valto,vancho)
{
  var str = "height=" + valto;
  str += ",width=" + vancho;
  
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - vancho) / 2;
    var yc = (ah - valto) / 2;

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
    
  }
	window.open(vurl,'external','left=' + xc + ',screenX='+xc+',height='+valto+',width='+vancho+',scrollbars=yes').focus();
}
//*****************************************************
function fValidarLetras(checkStr,Donde,Foco,Acentos) { 
	if (Acentos == 1){var checkOK = fM("ControlCaracteresAcentos"); 
	}else{var checkOK = fM("ControlCaracteres"); }
	var allValid = true; 
	for (i = 0; i < checkStr.length; i++) { 
		ch = checkStr.charAt(i); 
		for (j = 0; j < checkOK.length; j++) 
			if (ch == checkOK.charAt(j)) 
			break; 
			if (j == checkOK.length) { 
				allValid = false; 
				break; 
			} 
		} 
	if (!allValid) { 
		if (Donde==""){
			alert(fM("HaIntroducidoLetrasRaras"));
			if (Foco != ""){ eval("document." + Foco + ".select()"); }
		}
		else{
			alert(fM("SeHanEncontradoCaracteresRaros") + Donde);
			if (Foco != ""){ eval("document." + Foco + ".select()"); }
		}
		return (false); 
	}
	else{return (true);}
}
//****************************************************
function fFormatoTexto (Tipo,Donde){
	strTexto = document.selection.createRange().text;
	if (strTexto ==""){alert (fM("SeleccionaTexto"));return;}
	if (Tipo == "b"){document.selection.createRange().text = "[b]" + document.selection.createRange().text + "[/b]";}
	if (Tipo == "a"){document.selection.createRange().text = "[a]" + document.selection.createRange().text + "[/a]";}
	if (Tipo == "k"){document.selection.createRange().text = "[k]" + document.selection.createRange().text + "[/k]";}
	if (Tipo == "-t"){document.selection.createRange().text = "[-t]" + document.selection.createRange().text + "[/-t]";}
	if (Tipo == "t"){document.selection.createRange().text = "[t]" + document.selection.createRange().text + "[/t]";}
	if (Tipo == "+t"){document.selection.createRange().text = "[+t]" + document.selection.createRange().text + "[/+t]";}
	return;
}
//*************************************************
function fLakuiaJarri (Non){
	//Non=document.frmCajitas.Foco.value;
	eval('document.'+Non+'.focus ()');
	document.selection.createRange().text = "[cuadro]" + document.selection.createRange().text;
}
//*************************************************
function fSeleccionarUno(url,cantidad,txtForm,txtChk)
{	sw=0;
	j=0;
	if (cantidad>1)
	{	for (i=0;i<cantidad;i++)
		{	if (eval("document."+txtForm+"."+txtChk+"["+i+"].checked"))
			{	sw++;
				j=i;
			}
		}
		if (sw==1)
		{	strAux=eval("document."+txtForm+"."+txtChk+"["+j+"].value");
			location.href=url+strAux;
		}else if (sw==0){	
			alert(fM("SeleccioneAlgunaCasilla"));
		}else{	
			alert(fM("SeleccioneUnaCasilla"));
		}
	}
	else
	{	if (cantidad==1)
		{	if (eval("document."+txtForm+"."+txtChk+".checked"))
			{	strAux=eval("document."+txtForm+"."+txtChk+".value");
				location.href=url+strAux;
			}
			else
			{	alert(fM("SeleccioneAlgunaCasilla"));
			}
		}
	}
}
//*************************************************
function fActualizaFrame(istrPagina,istrFrame)
{	
	if(istrFrame=='neurtek_titulo_cabecera')
	{	istrFrame='neurtek_cabecera.neurtek_titulo_cabecera';
	}
	istrPagina="&nbsp;"+istrPagina+"&nbsp;";
	if(document.layers)
	{   strString='top.'+istrFrame+'.document.tip.document.write("'+istrPagina+'")';
		eval(strString);
	    eval('top.'+istrFrame+'.document.tip.document.close()');
	    strString='top.'+istrFrame+'.document.tip.visibility="visible"';
	    eval(strString);
	}
	if(document.all)
	{   strString='top.'+istrFrame+'.document.all("tip").innerHTML="';
		strString=strString+istrPagina+'"';
		eval(strString);
		eval('top.'+istrFrame+'.document.all("tip").style.visibility="visible"');
	}
	if(document.getElementById)
	{   strString='top.'+istrFrame+'.document.getElementById("tip").innerHTML="'+istrPagina+'"';
		eval(strString);
	    strString='top.'+istrFrame+'.document.getElementById("tip").style.visibility="visible"';
	    eval(strString);
	}
	return;
	
	//window.open(istrPagina,istrFrame);
}
//****************************************************
function fValidarCorreo(valor){
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(valor)){return true;} 
	else { alert(fM("CorreoMal")); return false ;}
}
function finMes(oTxt)
{
	var nMes = parseInt(oTxt, 10);
	var nRes = 0;
	switch (nMes){
	case 1: nRes = 31; break;
	case 2: nRes = 28; break;
	case 3: nRes = 31; break;
	case 4: nRes = 30; break;
	case 5: nRes = 31; break;
	case 6: nRes = 30; break;
	case 7: nRes = 31; break;
	case 8: nRes = 31; break;
	case 9: nRes = 30; break;
	case 10: nRes = 31; break;
	case 11: nRes = 30; break;
	case 12: nRes = 31; break;
	}
	return nRes;
}
//*******************************************
function cambia_dias(nombre_campo,nombre_contenedor,mes,nombre_mes,anho,dia_sel)
{	  
	if (mes){mes = '1';}else{mes = document.getElementsByName(nombre_mes).item(0).value;}
		  	
     var contenido='<select name='+nombre_campo+' class=textoinput>';
     //finnal = finMes(mes);
     finnal=31;
     if(mes == 2 && ((document.getElementsByName(anho).item(0)) ? document.getElementsByName(anho).item(0).value : null ) %4==0 && !(document.getElementsByName(anho).item(0).value%100==0 && document.getElementsByName(anho).item(0).value%400!=0) ){finnal = 29;}
		  
     for(i=1;i<=finnal;i++)
     {
   		if(i==dia_sel){contenido=contenido+'<option value='+i+' class=textoinput selected>'+i+'</option>';}
     	else{contenido=contenido+'<option value='+i+' class=textoinput>'+i+'</option>';}
     }
     contenido=contenido+'</select>';
		  
     if(navigator.appName.indexOf("Microsoft")!=-1){document.getElementsByName(nombre_contenedor).item(0).innerHTML = contenido;}
     else{
     	if(navigator.appName.indexOf("Netscape")!=-1)
   			{document.write(contenido);}
     	else{
     		if(navigator.appName.indexOf("Opera")!=-1){document.write(contenido);}
     	}
     }
}
//******************************************
function muestrameses(mes_seleccionado,nombreMes,nombre_dias,nombre_contenedor,nombre_anho)
{   mes='<select class=textoinput name=\"'+nombreMes+'\" onchange=\"cambia_dias(\''+nombre_dias+'\',\''+nombre_contenedor+'\',false,\''+nombreMes+'\',\''+nombre_anho+'\',document.getElementsByName(\''+nombre_dias+'\').item(0).value)\">';
		
	meses =new Array('Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre');
	for(i=-1;++i<12;)
	{	if(i+1==mes_seleccionado)
			mes=mes+'<option value='+(i+1)+' class=textoinput selected>'+meses[i]+'</option>';
		else
			mes=mes+'<option value='+(i+1)+' class=textoinput>'+meses[i]+'</option>';
	}
	mes=mes+'</select>';
	document.write(mes);
}
//******************************************
function sVentanaEmergenteSinBarra(direccion,nombre,ancho,alto)
{	strAux="win2=window.open(direccion,nombre,'scrollbars=no,status=no,left="+(window.screen.width-ancho)/2+",top="+(window.screen.height-alto)/2+", directories=no, toolbar=no,width="+ancho+",height="+alto+"');";
	eval(strAux);
}
//******************************************
function muestraanhos(anho_nombre,anho_seleccionado,nombreMes,nombre_dias,nombre_contenedor)
{
	anhos ='<select class=textoinput name='+anho_nombre+' onchange=\"if(navigator.appName.indexOf(\'Microsoft\')!=-1)cambia_dias(\''+nombre_dias+'\',\''+nombre_contenedor+'\',false,\''+nombreMes+'\',\''+anho_nombre+'\',document.getElementsByName(\''+nombre_dias+'\').item(0).value)\">';
	fecha_actual = new Date();
	for(i=fecha_actual.getFullYear()-1;++i<=fecha_actual.getFullYear()+49;)
		if(i==anho_seleccionado)
			anhos+='<option value=\"'+i+'\" class=textoinput selected>'+i+'</option>';
		else
			anhos+='<option value=\"'+i+'\" class=textoinput>'+i+'</option>';
	anhos+='</select>';
	document.write(anhos);
}
//funcion igual pero que empieza desde el 2003 fijo
//******************************************
function muestraanhos2(anho_nombre,anho_seleccionado,nombreMes,nombre_dias,nombre_contenedor)
{
	anhos ='<select class=textoinput name='+anho_nombre+' onchange=\"if(navigator.appName.indexOf(\'Microsoft\')!=-1)cambia_dias(\''+nombre_dias+'\',\''+nombre_contenedor+'\',false,\''+nombreMes+'\',\''+anho_nombre+'\',document.getElementsByName(\''+nombre_dias+'\').item(0).value)\">';
	fecha_actual = new Date();
	for(i=2002;++i<=fecha_actual.getFullYear()+49;)
		if(i==anho_seleccionado)
			anhos+='<option value=\"'+i+'\" class=textoinput selected>'+i+'</option>';
		else
			anhos+='<option value=\"'+i+'\" class=textoinput>'+i+'</option>';
	anhos+='</select>';
	document.write(anhos);
}
//******************************************
function fPintaTip(istrTip,istrTexto)
{	if(document.layers)
	{   strString='top.neurtek_cabecera.document.'+istrTip+'.document.write("'+istrTexto+'")';
		eval(strString);
	    eval('top.neurtek_cabecera.document.'+istrTip+'.document.close()');
	    strString='top.neurtek_cabecera.document.tip.visibility="visible"';
	    eval(strString);
	}
	if(document.all)
	{   strString='top.neurtek_cabecera.document.all("'+istrTip+'").innerHTML="';
		strString=strString+istrTexto+'"';
		eval(strString);
		eval('top.neurtek_cabecera.document.all("'+istrTip+'").style.visibility="visible"');
	}
	if(document.getElementById)
	{   strString='top.neurtek_cabecera.document.getElementById("'+istrTip+'").innerHTML="'+istrTexto+'"';
		eval(strString);
	    strString='top.neurtek_cabecera.document.getElementById("'+istrTip+'").style.visibility="visible"';
	    eval(strString);
	}
	return;
}
//*********************************************
function fCambiarFilaColor (intCual,intCuantos,strColor){
	i=1;
	while (i<=intCuantos){
		eval("fila"+i+"_"+intCual+".bgColor='"+strColor+"'");
		i++;
	}
}
function fNoEscribir(intAlert) 
{
	if (((window.event.keyCode>=0) && (window.event.keyCode<=47))||((window.event.keyCode>=58)&& (window.event.keyCode<=64)) || ((window.event.keyCode>=91)&& (window.event.keyCode<95)) || (window.event.keyCode==96) || (window.event.keyCode>122) ) {  
		window.event.keyCode=""; 
		if (intAlert==1){alert("No puede introducir caracteres extraños");return false;}
		else{return false;}
	}
}
function fSoloNumero(intAlert) 
{
	if (((window.event.keyCode<48)||(window.event.keyCode>57))&& (window.event.keyCode!=8)) {  
		window.event.keyCode=""; 
		if (intAlert==1){alert("Solo puede introducir numeros");return false;}
		else{return false;}
	}
}
function fSoloDecimal(intAlert) 
{
	if (((window.event.keyCode<48)||(window.event.keyCode>57))&& (window.event.keyCode!=8)&& (window.event.keyCode!=46)) {  
		window.event.keyCode=""; 
		if (intAlert==1){alert("Solo puede introducir numeros con decimales '.'");return false;}
		else{return false;}
	}
}
//*************************************************
function fPonerSimbolo (Donde,Cual){
	eval('document.'+Donde+'.focus ()');
	if(Cual=="n1"){
		document.selection.createRange().text = "[n1]" + document.selection.createRange().text;
	}
}

