function VisualizarFecha(IdIdioma)
{
	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 (hours >= 6) { time_of_day = 'Buenos Días'; message='Morning Message';}
	if ((hours >= 14) && (hours < 21)) { time_of_day = 'Buenas Tardes'; message='Afternoon Message'}
	if (hours >= 21) { time_of_day = 'Buenas Noches'; message='Evening Message';}
	if ((hours >= 0) && (hours < 6)){ time_of_day = 'Buenas Noches'; message='Night Message';}

 

    if (IdIdioma == 1)    {
 		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';} 
	}
	else if (IdIdioma == 2)    {
 		if(month_number == 0){month = 'Janeiro';}
		if(month_number == 1){month = 'Fevereiro';}
		if(month_number == 2){month = 'Março';}
		if(month_number == 3){month = 'Abril';}
		if(month_number == 4){month = 'Maio';}
		if(month_number == 5){month = 'Junho';}
		if(month_number == 6){month = 'Julho';}
		if(month_number == 7){month = 'Agosto';}
		if(month_number == 8){month = 'Setembro';}
		if(month_number == 9){month = 'Outubro';}
		if(month_number == 10){month = 'Novembro';}
		if(month_number == 11){month ='Dezembro';}
		
		if(day_of_week_number == 0){day_of_week = 'Domingo';}
		if(day_of_week_number == 1){day_of_week = 'Segunda-feira';}
		if(day_of_week_number == 2){day_of_week = 'Terça-feira';}
		if(day_of_week_number == 3){day_of_week = 'Quarta-feira';}
		if(day_of_week_number == 4){day_of_week = 'Quinta-feira';}
		if(day_of_week_number == 5){day_of_week = 'Sexta-feira';}
		if(day_of_week_number == 6){day_of_week = 'Sábado';} 
	}


	var date_to_show='&nbsp;<b>'+day_of_week+', '+day_of_month+' de '+month+' de '+year+'</b>';
	document.write(date_to_show);
}




function EsNif (inputval)
{
inputStr= "" + inputval

if (inputStr.length!=8) return false

return EsPositiu(inputval)

}

function LongitudNula (inputval)
{
var oneChar
inputStr= "" + inputval
if (inputStr.length==0) return true
for(var i=0; i<inputStr.length; i++) 
{
	oneChar=inputval.charAt(i)
	if (oneChar!=" ") 
	{
	// Aqui tenemos un símbolo 
    return false
	}
}
return true
}

function Trim(inputval)
{
var oneChar
var i
var cadena
inputStr= "" + inputval
if (inputStr.length==0) return ("")
i=0
oneChar=inputval.charAt(i)
while ((i<inputStr.length) && (oneChar==" ")) 
{
 i++
 oneChar=inputval.charAt(i)
}
cadena=inputStr.substring(i,inputval.length)
return (cadena)
}

function EsPositiu(inputval)
{
inputStr= "" + inputval

if (inputStr.length==0) return true


for (var i=0; i < inputStr.length; i++ )

	{

	 var oneChar=inputStr.charAt(i)

		if ((oneChar < "0") || (oneChar > "9"))  return false 

	}


return true
}

// BrowserCheck Object
// provides most commonly needed browser checking variables
// 19990326

// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynapi/

function BrowserCheck() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.v = parseInt(navigator.appVersion)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
	if (this.ie5) this.v = 5
	this.min = (this.ns||this.ie)
}

function EnviaPlana(document)
{
// automatically create the "is" object
is = new BrowserCheck()


if (is.ie4) document.submit.click()
if (is.ie5) document.submit()

}


function ValidarFormEnviarMail(document)
{      	
		if (EsMail(document.EnviarEmail.value)==false)
		{
			alert ("E-mail obligatorio");
			document.EnviarEmail.focus();
			return false
		}
		
return true	
}

// VALIDAR TIPUS.js
texte=1
codipostal=2
email=3
numeric=4
nif=5
lletra=6
textarea=7
codi1=8
codi2=9
codi3=10
codi4=11
data=12


function validar_tipus(camp,tipus,longitudMax){


if (tipus==texte && !Valido(camp)) {alert("Campo contiene carácteres no válidos (')"); return false}
if (tipus==codipostal && !EsCodiPostal(camp)) {alert("Campo código postal incorrecto. Formato (XXXXX) donde X ha de ser numérico."); return false}
if (tipus==email && (!EsMail(camp) || !Valido(camp))) {alert("Campo email con formato incorrecto o contiene carácteres no válidos.Formato (XXXX@XXXX.XXXX.XXXX)"); return false}
if (tipus==numeric && !EsPositiu(camp)) {alert("Campo no numérico"); return false}
//if (tipus==nif && !EsNif(camp)) { alert("Campo no tiene formato de nif");return false}
if (tipus==lletra && (!EsLletra(camp) || !Valido(camp))) { alert("Campo ha de ser un carácter o contiene carácteres no válidos");return false}
if (tipus==textarea && !Valido(camp)) {alert("Campo contiene carácteres no válidos (')"); return false}
if (tipus==textarea && !mira_longitud(camp,"",longitudMax)) {alert("Campo supera la longitud máxima"); return false}
if (tipus==data && !EsData(camp)) {alert("Campo no tiene formato de fecha"); return false}


if (tipus==codi1 && camp.length!=4) { alert("1er campo código cuenta cliente tiene que tener 4 dígitos");return false}
if (tipus==codi2 && camp.length!=4) { alert("2undo. campo código cuenta cliente tiene que tener 4 dígitos");return false}
if (tipus==codi3 && camp.length!=2) { alert("3er. campo código cuenta cliente tiene que tener 2 dígitos");return false}
if (tipus==codi4 && camp.length!=10) { alert("4to. campo código cuenta cliente tiene que tener 10 dígitos");return false}

if (tipus==codi1 && !EsPositiu(camp)) { alert("1er campo código cuenta cliente no és numerico");return false}
if (tipus==codi2 && !EsPositiu(camp)) { alert("2undo. campo código cuenta cliente no és numerico");return false}
if (tipus==codi3 && !EsPositiu(camp)) { alert("3er. campo código cuenta cliente no és numerico");return false}
if (tipus==codi4 && !EsPositiu(camp)) { alert("4to. campo código cuenta cliente no és numerico");return false}


return true

}




function EsMail(inputVal){
	inputStr = "" + inputVal
	oneArroba = false
	oneDecimal = false
	for (var i = 0; i < inputStr.length; i++) {
		var oneChar = inputStr.charAt(i)
		if (oneChar == "@" && !oneArroba && i!=0) {
			oneArroba =true
			continue
		}
		if (oneChar == "." && !oneDecimal && oneArroba && i!=(inputStr.length-1)) {
			oneDecimal = true
			return true
		}
	}

	return false
}



function precisio(inputval,precisio)

{

inputStr= inputval + ""

cadena=inputval + ""

cadena2=""

index=0


var onechar=inputStr.charAt(index);

while ((onechar!=".") && (index<cadena.length))

{

onechar=inputStr.charAt(index);
if (onechar!=".") index=index+1

}

if (onechar==".") 

		{

		index2=0

		if (index+precisio<cadena.length) tope=index+precisio

		if (index+precisio>=cadena.length) tope=cadena.length
		
		while (index2<tope)

		{

		cadena2=cadena2+inputStr.charAt(index2)

		index2=index2+1
		

		}
		
		return cadena2

	
}

return cadena

}



function mira_longitud(inputval,nom,longitudMax) 

{


cadena=inputval + ""

if (cadena.length>longitudMax)  { 



					longitud_sobre_pasa=cadena.length-longitudMax
		
		
	
					alert("Campo " + nom + " sobrepasa longitud máxima de "+longitud_sobre_pasa + " carácteres.")

		

					return false

			         }


if (cadena.length<=longitudMax) {	

				return true

			}

}

function mira_longitud_password(inputval) 

{


cadena=inputval + ""

if (cadena.length<7)  { alert("La longitud del password debe ser de 7 dígitos como mínimo");return;}

return true;


}


			

function evalua (inputval)

{

inputStr= "" + inputval

 var oneChar=inputStr.charAt(0);

if (oneChar=="-") { return (-Math.abs(inputval)) }
	
if (oneChar!="-") { return (Math.abs(inputval)) }

}

function EsNif (inputval)

{


inputStr= "" + inputval

if (inputStr.length!=8) return false

return EsPositiu(inputval)



}




function EsPercentatge (inputval)

{

inputStr= "" + inputval

if (inputStr.length==3) return (inputval=='100')


for (var i=0; i < inputStr.length; i++ )

	{

	 var oneChar=inputStr.charAt(i)

		if ((oneChar < "0") || (oneChar > "9"))  return false 

	}


return true


}



function EsData (inputval)

{

var oneChar

inputStr= "" + inputval;

if (inputStr.length!=10) return false;

oneChar=inputStr.charAt(0);

if ((oneChar < "0") || (oneChar > "3"))  return false ;


if (oneChar=="3") 

	{

	oneChar=inputStr.charAt(1);

	if ((oneChar < "0") || (oneChar > "1"))  return false ;

	}

if (oneChar!="3") 

	{

	oneChar=inputStr.charAt(1);

	if ((oneChar < "0") || (oneChar > "9"))  return false ;

	}

oneChar=inputStr.charAt(2);

if (oneChar!="-") return false;

oneChar=inputStr.charAt(3);

if ((oneChar < "0") || (oneChar > "1"))  return false ;


if (oneChar=="1")

	{

	oneChar=inputStr.charAt(4);

	if ((oneChar < "0") || (oneChar > "2"))  return false ;

	}

if (oneChar=="0")

	{

	oneChar=inputStr.charAt(4);

	if ((oneChar < "0") || (oneChar > "9"))  return false ;

	}



oneChar=inputStr.charAt(5);

if (oneChar!="-") return false;

oneChar=inputStr.charAt(6);

if ((oneChar < "0") || (oneChar > "9"))  return false ;

oneChar=inputStr.charAt(7);

if ((oneChar < "0") || (oneChar > "9"))  return false ;

oneChar=inputStr.charAt(8);

if ((oneChar < "0") || (oneChar > "9"))  return false ;

oneChar=inputStr.charAt(9);

if ((oneChar < "0") || (oneChar > "9"))  return false ;

return true;

}




function LongitudNula (inputval)

{

inputStr= "" + inputval

if (inputStr.length==0) return true

return false

}

function EsData (inputval)

{

var oneChar

inputStr= "" + inputval;

if (inputStr.length!=10) return false;

oneChar=inputStr.charAt(0);

if ((oneChar < "0") || (oneChar > "9"))  return false ;

oneChar=inputStr.charAt(1);

if ((oneChar < "0") || (oneChar > "9"))  return false ;

oneChar=inputStr.charAt(2);

if (oneChar!="-") return false;

oneChar=inputStr.charAt(3);

if ((oneChar < "0") || (oneChar > "9"))  return false ;

oneChar=inputStr.charAt(4);

if ((oneChar < "0") || (oneChar > "9"))  return false ;

oneChar=inputStr.charAt(5);

if (oneChar!="-") return false;

oneChar=inputStr.charAt(6);

if ((oneChar < "0") || (oneChar > "9"))  return false ;

oneChar=inputStr.charAt(7);

if ((oneChar < "0") || (oneChar > "9"))  return false ;

oneChar=inputStr.charAt(8);

if ((oneChar < "0") || (oneChar > "9"))  return false ;

oneChar=inputStr.charAt(9);

if ((oneChar < "0") || (oneChar > "9"))  return false ;

return true;

}


function EsCodiPostal(inputval)

{


inputStr= "" + inputval

if (inputStr.length!=5) return false


for (var i=0; i < inputStr.length; i++ )

	{

	 var oneChar=inputStr.charAt(i)

		if ((oneChar < "0") || (oneChar > "9"))  return false 

	}


return true


}


function EsPositiu(inputval)

{


inputStr= "" + inputval

if (inputStr.length==0) return true


for (var i=0; i < inputStr.length; i++ )

	{

	 var oneChar=inputStr.charAt(i)

		if ((oneChar < "0") || (oneChar > "9"))  return false 

	}


return true


}

function EsFloat(inputval)

{


inputStr= "" + inputval

punt=false

if (inputStr.length==0) return true


for (var i=0; i < inputStr.length; i++ )

	{

	 var oneChar=inputStr.charAt(i)

		if ((oneChar==".") && (punt==true)) return false

		punt=(oneChar==".")

		if (((oneChar < "0") || (oneChar > "9")) && (oneChar!=".")) return false 

	}


return true


}



function Valido (inputval)

{

inputStr= "" + inputval

if (inputStr.length==0) return true


for (var i=0; i < inputStr.length; i++ )

	{

	 var oneChar=inputStr.charAt(i)


	}



return true


}


function EsLletra(inputval)

{

inputStr= "" + inputval

if (inputStr.length!=1) return false

var oneChar=inputStr.charAt(0)


if (((oneChar >= "a") && (oneChar <= "z"))  || ((oneChar >= "A") && (oneChar <= "Z"))) return true


return false


}


//ENVIAR.JS
// BrowserCheck Object
// provides most commonly needed browser checking variables
// 19990326

// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynapi/

function BrowserCheck() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.v = parseInt(navigator.appVersion)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
	if (this.ie5) this.v = 5
	this.min = (this.ns||this.ie)
}

function envia_plana(document)

{



// automatically create the "is" object
is = new BrowserCheck()

if (is.ns4) document.submit()

if (is.ie4) document.submit.click()
if (is.ie5) document.submit()

}




