IE = (navigator.appVersion).indexOf("MSIE") != -1; 
NS = (navigator.appName).indexOf("Netscape") != -1; 

function buscarCadena()
{
  	if (document.formSection.query.value == "" || document.formSection.query.value == "buscar ...") {
		alert ("Introduce la cadena a buscar");
		document.formSection.query.focus();
		return false;
	}
	else 
	{
	 	var palabras = document.formSection.query.value.split(" ");
		var texto = "";
		if (palabras.length == 1)
		{
			texto = palabras;
		}
		else
		{
			for (i = 0; i < palabras.length; i++)
			{
				texto = texto + "+" + palabras[i];
	   	}
	   }
		document.formSection.textobusqueda.value = texto;
		document.formSection.submit();  
  	}
  	
}

function irBuscador()
{
	if (document.formSection.cat.selectedIndex != 0)
	{
	    top.location = document.formSection.cat.options[document.formSection.cat.selectedIndex].value;
	}
}

function irUrl(url)
{
	if (url != "")
		top.location="/"+url;
}

function doAction(section,texto)
{
	document.formSection.section.value=section;
	if (section != "") 
		document.formSection.submit();
	else
		alert (texto);
}

function doActionNivel2(section,track,url)
{
  	if (section != "") {
    	document.formSection.section.value = section;
    	document.formSection.track.value = track;
    	document.formSection.url.value = url;    
    	document.formSection.submit();
	}
}

function ResetBuscador()
{
	if (document.formSection.query.value == "buscar ...")
		document.formSection.query.value = "";
}

function VisualizarFecha()
{
	date = new Date();
	var day_of_week_number = date.getDay();
	var day_of_month = date.getDate();
	var month_number = date.getMonth();
	var year = date.getYear();
	if (year<200) year+=1900;
	var day_of_week = '';
	var month = '' 

	var hours = date.getHours();
	var message = '';

	

	if(month_number == 0){month = 'Enero';}
	if(month_number == 1){month = 'Febrero';}
	if(month_number == 2){month = 'Marzo';}
	if(month_number == 3){month = 'Abril';}
	if(month_number == 4){month = 'Mayo';}
	if(month_number == 5){month = 'Junio';}
	if(month_number == 6){month = 'Julio';}
	if(month_number == 7){month = 'Agosto';}
	if(month_number == 8){month = 'Septiembre';}
	if(month_number == 9){month = 'Octubre';}
	if(month_number == 10){month = 'Noviembre';}
	if(month_number == 11){month ='Diciembre';}
	
	if(day_of_week_number == 0){day_of_week = 'Domingo';}
	if(day_of_week_number == 1){day_of_week = 'Lunes';}
	if(day_of_week_number == 2){day_of_week = 'Martes';}
	if(day_of_week_number == 3){day_of_week = 'Miercoles';}
	if(day_of_week_number == 4){day_of_week = 'Jueves';}
	if(day_of_week_number == 5){day_of_week = 'Viernes';}
	if(day_of_week_number == 6){day_of_week = 'Sábado';} 

	var date_to_show='&nbsp;'+day_of_week+', '+day_of_month+' '+month+' '+year+'.';
	document.write(date_to_show);
}

function WinOpen(url,ancho,alto,scroll)
{
	window.open (url,"Copyright","width="+ancho+",height="+alto+",scrollbars="+scroll+",location=no,status=no,directories=no,toolbar=no,resizable=no,maximizable=no,menubar=no");
}

function AbrirVentana(valor1,valor2,valor3)
{
	window.open (valor1,valor2,valor3);
}

// EuroCalculadora 

var lastChanged = "";
function formatnumber(num)	// 1.- It rounds the number up two decimals:  ( 1.234 ==> 1.23 ) and ( 1.456 ==> 1.46 )
{				// 2.- It adds a 0 before the point, if there is not any one:  ( .12 ==> 0.12 )
 var i = 0;			// 3.- It formats the two decimals: ( 1 ==> 1.00 ) and ( 1.2 ==> 1.20 )
 var result = "";
 var limit = 0;
 //window.alert(num);

 num = (Math.round(num*100))/100;	// ROUND THE NUMBER UP TWO DECIMALS
 num = num + "";

 var len = num.length;
 var posit = num.indexOf(".");

 if (num == "NaN")			// CONTROL OF THE MISTAKES
     result = "...";
 else{
     if (posit == "-1")
	result = num + ".00";
     else{
	if (posit == "0")		// ADD THE 0 BEFORE THE POINT
	   result = "0";
	
	limit = posit;

	if ((len-posit) >= 3)
	    result = result + num;
	else{
	    for (i=0; i<limit; i++)	  	 // ADD THE CHARS FROM THE 0 UNTIL THE CHAR BEFORE THE POINT
		result = result + num.charAt(i);
    
	    result = result + ".";
	    if ((len-posit) == 2)
		result = result + num.charAt(limit+1) + "0";
	    else
		if ((len-posit) == 1)
		    result = result + "00";
	   }
	}
     }
 
 return(result);
}

function Pesetas2Euros()
{
   document.form.E.value = formatnumber(document.form.P.value/166.386);
}

function Euros2Pesetas()
{
   document.form.P.value = formatnumber(document.form.E.value*166.386);
}

function PonerACero(){
	document.form.E.value = 0;
	document.form.P.value = 0;
}

function calcular(){
	
	if ((lastChanged==1) && (document.form.E.value !="NaN")) { 
		Euros2Pesetas();
		return false;
	}
	
	if ((lastChanged==0) && (document.form.P.value !="NaN")) { 
		Pesetas2Euros();
		return false;
	}
	alert ("introduce valores válidos");
	return false;
}

//Fin de Eurocalculadora