// JavaScript Document

g_o_comun='toolbar=no,location=no,directories=no,menubar=no,scrollbar=yes,scrollbars=1,resizable=1,copyhistory=no';
if(g_debug)
	g_o_popup1='status=1,width='+580+',height='+500+'toolbar=1,location=no,directories=no,status=1,menubar=1,scrollbar=yes,scrollbars=1,resizable=1,copyhistory=yes';
else	
	g_o_popup1='status=1,width='+580+',height='+500+g_o_comun;
g_o_popup2='status=1,width='+700+',height='+600+g_o_comun;	
g_o_popup3=g_o_comun;
g_o_popup4='status=1,width='+720+',height='+600+g_o_comun;	
g_o_popup5='status=0,width='+580+',height='+300+g_o_comun;
g_o_popup6='status=1,width='+765+',height='+600+g_o_comun;
g_o_popup7='status=1,width='+616+',height='+530+g_o_comun;
g_o_popup8='width='+450+',height='+200;
g_o_popup9='status=1,width='+780+',height='+600+g_o_comun;	
g_o_popup10='status=1,width='+616+',height='+440+g_o_comun;	

///////////////////////////////////////////////////////////////////////////
//// debugging
g_debug=0
function f_false() { return false; }

///////////////////////////////////////////////////////////////////////////
//// mensajes
function msj(s){
	window.status=s;
	return true;
}

///////////////////////////////////////////////////////////////////////////
//// objetos
function d_obj(id){
	var o;
	if (document.all) o = document.all(id);
	else if (document.getElementById) o = document.getElementById(id); 
	else if (document.layers) o = document.layers[id];
	if (o) return(o);
	return(null);
}

///////////////////////////////////////////////////////////////////////////
// precargar imágenes
function precargar() {
	if(document.images) {
		var s=precargar.arguments;
		if(document.precargadas==null) document.precargadas = new Array();
		var i=document.precargadas.length;
		with(document){
	 		for(var j=0;j<s.length;j++,i++){
	   			precargadas[i] = new Image; precargadas[i].src = s[j];
	  		}
		}
	}
}

///////////////////////////////////////////////////////////////////////////
//// ventanas
function popup(u,v,o){
	var w=window.open(u,v,o);
	w.focus();
	//return false;
}

function popup_foto(i,t){
	var s,n,pat1,pat2,colorbg;
	pat1='<br><i>';
	pat2='</i>';
	s=t;
	n=s.indexOf(pat1);
	if(n>-1){
		t=s.substr(0,n);
		s=s.substring(n+pat1.length,s.length);
		n=s.indexOf(pat2);
		if(n>-1){
			s=s.substr(0,n);
		}
	}
	if (t.indexOf('Olympia Viajes')>-1){
		colorbg='#385389'
	} else {
		if (t.indexOf('BRONZE')>-1){
			colorbg='#FF6600';
		}else{
			colorbg='#247DA8';
		}
	}
	var w=window.open('','foto','height=200,width=200,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=yes,scrollbars=1,resizable=1,copyhistory=no');
	w.focus();
	var d=w.document.open();
	d.write('<html><head><title>');
	d.write(t);
	if(s>'') d.write(s);
	d.write('</title>');
	d.write('<script>function redimensionar(){');
	d.write('resizeTo(document.images.foto.width+12+32,document.images.foto.height+32+36+32);');
	d.write('}</script>');
	d.write('</head>');
	d.write('<body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0" onLoad="redimensionar()" scroll="no" style="overflow:auto;">');
	d.write('<table bgcolor="'+colorbg+'" width="100%" height="100%" cellpadding=0 cellspacing=0 border=0><tr><td width="100%" height="100%" align=center valign=middle><img name=foto src="'+i+'" alt="'+t+'" title="'+s+'" hspace=0 vspace=0 border=0 style="border:1px solid #ffffff;">');
	if(s>'') d.write('</td></tr><tr><td height="20" align="center"><font size=1 color=#ffffff face=Tahoma style="font-family:Tahoma;font-size:10px;"></font>');
	d.write('</td></tr><tr><td height="20" align="right" style="padding-bottom:5px;padding-right:15px;"><a href="#" onClick="window.close();" style="font-family:Tahoma;font-size:11px;color:#ffffff;text-decoration: none;">'+m_[646]+'</a>');
	d.write('</td></tr></table>');
	d.write('</body></html>');
	d.close();
	w.location.reload();
}

function colapsar_popup(){
	//
}

///////////////////////////////////////////////////////////////////////////
//// gestión menús y títulos
function gestion_titulo(n){
	if(n>0 && t_[n] && t_[n]>'') {
		document.title=g_TituloPortal // + ' - ' + t_[n];
	}
}

///////////////////////////////////////////////////////////////////////////
//// ZONAS Y LOCALIDADES
function flash_sel_zona_nopopup(id,nom){
	if((document.location.href.indexOf('es/')!=-1) || (document.location.href.indexOf('en/')!=-1) || (document.location.href.indexOf('fr/')!=-1) || (document.location.href.indexOf('de/')!=-1) || (document.location.href.indexOf('pt/')!=-1) ){
		//Estamos en topcosta con rewiter
		document.location.href='/web/establecimientos.asp?idz='+id;
	}else{
		//Estamos en bronze, olympia o topcosta sin rewriter
		document.location.href='?idz='+id;
	}
}
function flash_sel_localidad_nopopup1(id,nom,idz){
	if(document.location.href.indexOf('es/')!=-1 || document.location.href.indexOf('en/')!=-1 || document.location.href.indexOf('fr/')!=-1 || document.location.href.indexOf('de/')!=-1 || document.location.href.indexOf('pt/')!=-1){
		//Estamos en topcosta con rewiter
		document.location.href='/web/establecimientos.asp?idz='+idz+'&idl='+id;
	}else{
		//Estamos en bronze, olympia o topcosta sin rewriter
		document.location.href='?idz='+idz+'&idl='+id;
	}
	//seleccionar_localidad('buscador','localidad',id,idz);
}
function flash_sel_localidad_nopopup(id,nom,idz){
	//document.location.href='?idz='+idz+'&idl='+id;
	seleccionar_localidad('buscador','localidad',id,idz);
}
function flash_sel_zona(id,nom){
	location='/obs/selector_localidad.asp?accion=mostrar_zona&id_zona='+id+'&nom_zona='+nom;
}
function flash_sel_localidad(id,nom,idz){
	seleccionar_localidad('buscador','localidad',id,idz);
	window.close();
}
function seleccionar_localidad(frm,ctl,idl,idz){
	var s;
	s=opener.document.location+'';
	if(s.indexOf('/web/localidades')>0){
		opener.document.location='/web/localidades.asp?idz='+idz+'&idl='+idl; 
	}else{
		if(s.indexOf('/web/establecimientos')>0){
			opener.document.location='/web/establecimientos.asp?idz='+idz+'&idl='+idl; 
		}else{
			var o;
			o=eval('opener.document.'+frm+'.'+ctl);
			o.value=idz+';'+idl;
		}
	}
	//window.close();
}

///////////////////////////////////////////////////////////////////////////
function selecciona_establecimiento(caso,ide,ido,idh,idf,ne,idz,idl){
//1. caso=1	pop-up ficha_establecimiento.asp desde selector_estab_localidad.asp desde nueva_reserva.asp
//	selector_establecimiento,ficha_establecimiento,'' 
//2. caso=2	pop-up selector_estab_localidad.asp desde nueva_reserva.asp
//	desde 2 pop-up selector_establecimiento,ficha_establecimiento,object
//	desde 1 pop-up '',ficha_establecimiento,undefined
	//alert('opener.name='+opener.name);	// '' | selector_establecimiento | ''
	//alert('top.name='+top.name); 		//selector_establecimiento | ficha_establecimiento | ficha_establecimiento
	//alert(opener.opener);
	//alert('opener.opener.name='+opener.opener.name);	//
//
	//2,-2147472034,2,1195,2,'APTOS. AVENIDA'
	var f,caso;
	switch(caso){
			case 1:
				//alert('1111')
				f=opener.document.buscador;
				f.id_establecimiento.value=ide;
				f.id_oficina.value=ido;
				f.patron_establecimiento.value=ne;
				window.close();
				break;
			case 2:
				if(opener.name=='selector_establecimiento'){
					//alert('caso 2 a');
					f=opener.opener.document.buscador;
					f.id_establecimiento.value=ide;
					f.id_oficina.value=ido;
					f.patron_establecimiento.value=ne;
					opener.close();
					window.close();
				} else {
					//alert('caso 2 b');
					opener.location='/obs/nueva_reserva.asp?tipo_buscador=por_oferta&idEstablecimiento='+ide+'&idOficina='+ido+'&idHotelGlobal='+idh+'&idOficinaFicha='+idf
					//opener.location='http://www.olympia-viajes.com/obs/nueva_reserva.asp?tipo_buscador=por_oferta&idEstablecimiento='+ide+'&idOficina='+ido+'&idHotelGlobal='+idh+'&idOficinaFicha='+idf
					
					window.close();
				}
				break;
			case 3:
				//alert('3333')
				window.location='/obs/nueva_reserva.asp?tipo_buscador=por_establecimiento&idEstablecimiento='+ide+'&idOficina='+ido+'&idHotelGlobal='+idh+'&idOficinaFicha='+idf;
				break;
			case 4:
				//alert('4444')
				f=opener.document.buscador;
				f.id_establecimiento.value=ide;
				f.id_oficina.value=ido;
				f.patron_establecimiento.value=ne;
				f.localidad.value=idz+';'+idl;
				window.close();
				break;
			
			case 5:
				//opener.location='http://www.olympia-viajes.com/obs/nueva_reserva.asp?tipo_buscador=por_oferta&idEstablecimiento='+ide+'&idOficina='+ido+'&idHotelGlobal='+idh+'&idOficinaFicha='+idf
				window.open('http://www.olympia-viajes.com/obs/nueva_reserva.asp?tipo_buscador=por_oferta&idEstablecimiento='+ide+'&idOficina='+ido+'&idHotelGlobal='+idh+'&idOficinaFicha='+idf)
				break;
	}
}

///////////////////////////////////////////////////////////////////////////
//// IDIOMAS
function seleccionar_idioma(n){
		location='/web/inicio.asp?idIdioma='+n;
}

///////////////////////////////////////////////////////////////////////////
//// FECHAS

//------------------------------------------------------------------------------
// ajusta días a partir de las fechas de entrada y salida
// los parámetros son los objetos input
function ajustar_fechas_y_dias(ofe,ofs,ond) {
	var fecha_entrada,fecha_salida,fecha1,hoy,fecha2,dias,diff;
	var Ano1,Mes1,Dia1,dte_entrada;
	var Ano2,Mes2,Dia2,dte_salida;

	fecha_entrada=ofe.value;
	if(fecha_entrada=='') return;
	fecha_entrada=es_fecha(fecha_entrada);
	if(!fecha_entrada) return;
	ofe.value=fecha_entrada;
	Ano1 = fecha_entrada.substring(6,10);
	Mes1 = fecha_entrada.substring(3,5);
	Dia1 = fecha_entrada.substring(0,2);
	dte_entrada = Ano1+'/'+Mes1+'/'+Dia1
	
	fecha1 = new Date(dte_entrada);
	hoy = new Date();
	if(fecha1<hoy){
		alert(s_[15]);
		ond.value=0;
		ofe.focus();
		return;
	}
	
	fecha_salida=ofs.value;
	if(fecha_salida=='') return;
	fecha_salida=es_fecha(fecha_salida);
	if(!fecha_salida) return;
	ofs.value=fecha_salida;
	Ano2 = fecha_salida.substring(6,10);
	Mes2 = fecha_salida.substring(3,5);
	Dia2 = fecha_salida.substring(0,2);
	dte_salida = Ano2+'/'+Mes2+'/'+Dia2;

	fecha2 = new Date(dte_salida);
	diff = fecha2.getTime() - fecha1.getTime();
	dias = Math.floor(diff / (1000 * 60 * 60 * 24));
	
	if(dias<1) {
		alert(s_[13]);
		ond.value=0;
		ofs.focus();
		return;
	}
	if(dias>g_maxDiasReserva) {
		alert(s_[14]);
		ond.value=0;
		ofs.focus();
		return;
	}
	ond.value=dias;
}

// ajusta fecha de salidaa partir de la fechas de entrada y del nº de días
// los parámetros son los objetos input
function ajustar_dias_y_fecha(ofe,ofs,ond) {
	var mse,mss;
	var dte_salida;
	fecha_entrada=ofe.value
	days=ond.value;
	if(fecha_entrada=='') return;
	if(!es_fecha(fecha_entrada)) return;
	
	if(days>g_maxDiasReserva) {
		alert(s_[14]);
		ond.value=0;
		ond.focus();
		return;
	}
	fecha_entrada=es_fecha(fecha_entrada);

	//var Ano1 = fecha_entrada.substring(6,10);
	//var Mes1 = fecha_entrada.substring(3,5);
	//var Dia1 = fecha_entrada.substring(0,2);
	//var dte_entrada = Ano1+'/'+Mes1+'/'+Dia1
	
	//var f = new Date(dte_entrada);
	//mse=f.getTime();
	//mss=mse+((parseInt(days))*(1000 * 60 * 60 * 24));
	//alert(mse+' -- '+mss);
	//var dte_salida = new Date();
	//dte_salida.setTime(mss);
	//alert(dte_salida);
		
	//var fecha_salida = dte_salida.getDate()+'/'+(dte_salida.getMonth()+1)+'/'+anyo_(dte_salida);
	fecha_salida=addToDate(fecha_entrada, days);
	
	ofs.value=es_fecha(fecha_salida);
}

function ajusta_dia_es(fecha_){
	var d=new Date(fecha_.substr(3,2)+'/'+fecha_.substr(0,2)+'/'+fecha_.substr(6,4));
	var weekday=new Array("Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado");
	return weekday[d.getDay()];
}

function ajusta_dia_gr(fecha_){
	var d=new Date(fecha_.substr(3,2)+'/'+fecha_.substr(0,2)+'/'+fecha_.substr(6,4));
	var weekday=new Array("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag");
	return weekday[d.getDay()];
}

function ajusta_dia_en(fecha_){
	var d=new Date(fecha_.substr(3,2)+'/'+fecha_.substr(0,2)+'/'+fecha_.substr(6,4));
	var weekday=new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
	return weekday[d.getDay()];
}

function ajusta_dia_pt(fecha_){
	var d=new Date(fecha_.substr(3,2)+'/'+fecha_.substr(0,2)+'/'+fecha_.substr(6,4));
	var weekday=new Array("Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sábado");
	return weekday[d.getDay()];
}

function ajusta_dia_fr(fecha_){
	var d=new Date(fecha_.substr(3,2)+'/'+fecha_.substr(0,2)+'/'+fecha_.substr(6,4));
	var weekday=new Array("Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi");
	return weekday[d.getDay()];
}

//------------------------------------------------------------------------------
function comprobar_fecha(val){
	if(val==0 || val=="") return false;
	if(!es_fecha(val)) return false;
	return true;
}
function comprobar_fechas(valent,valsal){
	var fecha_entrada,fecha_salida;
	var Ano1,Mes1,Dia1;
	var Ano2,Mes2,Dia2;
	var dte_entrada,dte_salida;
	var fecha1,fecha2;
	var diff;
	fecha_entrada=es_fecha(valent);
	if(!fecha_entrada) return false;
	fecha_salida=es_fecha(valsal);
	if(!fecha_salida) return false;
	Ano1 = fecha_entrada.substring(6,10);
	Mes1 = fecha_entrada.substring(3,5);
	Dia1 = fecha_entrada.substring(0,2);
	dte_entrada = Ano1+'/'+Mes1+'/'+Dia1
	fecha1 = new Date(dte_entrada);
	Ano2 = fecha_salida.substring(6,10);
	Mes2 = fecha_salida.substring(3,5);
	Dia2 = fecha_salida.substring(0,2);
	dte_salida = Ano2+'/'+Mes2+'/'+Dia2;
	fecha2 = new Date(dte_salida);
	diff = fecha2.getTime() - fecha1.getTime();
	if(diff<=0) return false;
	return true;
}

function anyoBisiesto(anyo){
 var fin;
  if (anyo < 100) fin = anyo + 1900;
  else fin = anyo ;
  if (fin % 4 != 0) return false;
  else {
     if (fin % 100 == 0) {
         if (fin % 400 == 0) return true;
         else return false;
     }
     else return true;
  }
}

function es_fecha(a){
  var mes, dia, anyo, febrero,fecha;
 if (a.indexOf("/")==-1) {
     alert(s_[8]);
	 return false;
  }
  dia = parseInt(a.split("/")[0],10);
  mes = parseInt(a.split("/")[1],10);
  anyo = parseInt(a.split("/")[2],10);
  if(anyoBisiesto(anyo)) febrero=29;
  else febrero=28;
  if (isNaN(mes) || (mes<1) || (mes>12)) {
     alert(s_[9]);
     return false;       
  }
  if ((isNaN(mes) || (mes==2)) && (isNaN(dia) || (dia<1) || (dia>febrero))) {
     alert(s_[10]);
     return false;       
  }
  if ((isNaN(mes) || (mes==1) || (mes==3) || (mes==5) || (mes==7) || (mes==8) || (mes==10) || (mes==12)) && (isNaN(dia) || (dia<1) || (dia>31))) {
     alert(s_[10]);
     return false;       
  }
  if ((isNaN(mes) || (mes==4) || (mes==6) || (mes==9) || (mes==11)) && (isNaN(dia) || (dia<1) || (dia>30))) {
     alert(s_[10]);
     return false;       
  }
  if (isNaN(anyo) || anyo<0 ) {
     alert(s_[11]);
     return false;       	 
  }
  if(anyo<99){
	  	anyo+=2000;
  }
  if ( anyo<1900  || anyo>3000 ) {
     alert(s_[11]);
     return false;       	 
  } 
  dia='0'+dia+'/';
  dia=dia.substr(dia.length-3, 3);
  mes='0'+mes+'/';
  mes=mes.substr(mes.length-3, 3);
  fecha=dia+mes+anyo;
  //alert(fecha);
  return fecha; 
}

function validar_fecha_valida(nm_campo_, formulario_) {
  var a = eval("formulario_."+nm_campo_+".value");
  return es_fecha(a);
}    

function anyo_actual(){
	var f,a;
	var f = new Date();
	var a = f.getYear();
	
	if ((navigator.appName == "Microsoft Internet Explorer") && (a < 2000))		
		a="19" + a;
	if (navigator.appName == "Netscape")
		a=1900 + a;
	return a;
}

function anyo_(f){
	var a = f.getYear();
	
	if ((navigator.appName == "Microsoft Internet Explorer") && (a < 2000))		
		a="19" + a;
	if (navigator.appName == "Netscape")
		a=1900 + a;
	return a;
}

function ajustar_fecha_salida_1d(){
	var f=document.buscador;
	if(f.fechaent.value!='' && f.fechasal.value==''){
		f.numdias.value=1;
		ajustar_dias_y_fecha(f.fechaent,f.fechasal,f.numdias);
	}
}



  var aFinMes = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); 

  function finMes(nMes, nAno){ 
   return aFinMes[nMes - 1] + (((nMes == 2) && (nAno % 4) == 0)? 1: 0); 
  } 

   function padNmb(nStr, nLen, sChr){ 
    var sRes = String(nStr); 
    for (var i = 0; i < nLen - String(nStr).length; i++) 
     sRes = sChr + sRes; 
    return sRes; 
   } 

   function makeDateFormat(nDay, nMonth, nYear){ 
    var sRes; 
    sRes = padNmb(nDay, 2, "0") + "/" + padNmb(nMonth, 2, "0") + "/" + padNmb(nYear, 4, "0"); 
    return sRes; 
   } 
    
  function incDate(sFec0){ 
   var nDia = parseInt(sFec0.substr(0, 2), 10); 
   var nMes = parseInt(sFec0.substr(3, 2), 10); 
   var nAno = parseInt(sFec0.substr(6, 4), 10); 
   nDia += 1; 
   if (nDia > finMes(nMes, nAno)){ 
    nDia = 1; 
    nMes += 1; 
    if (nMes == 13){ 
     nMes = 1; 
     nAno += 1; 
    } 
   } 
   return makeDateFormat(nDia, nMes, nAno); 
  } 

  function decDate(sFec0){ 
   var nDia = Number(sFec0.substr(0, 2)); 
   var nMes = Number(sFec0.substr(3, 2)); 
   var nAno = Number(sFec0.substr(6, 4)); 
   nDia -= 1; 
   if (nDia == 0){ 
    nMes -= 1; 
    if (nMes == 0){ 
     nMes = 12; 
     nAno -= 1; 
    } 
    nDia = finMes(nMes, nAno); 
   } 
   return makeDateFormat(nDia, nMes, nAno); 
  } 

  function addToDate(sFec0, sInc){ 
   var nInc = Math.abs(parseInt(sInc)); 
   var sRes = sFec0; 
   if (parseInt(sInc) >= 0) 
    for (var i = 0; i < nInc; i++) sRes = incDate(sRes); 
   else 
    for (var i = 0; i < nInc; i++) sRes = decDate(sRes); 
   return sRes; 
  } 

  function recalcF1(){ 
   with (document.formulario){ 
    fecha1.value = addToDate(fecha0.value, increm.value); 
   } 
  } 


//////////////////////////////////////////////////////////////////////////////
// Cookies
function getCookieVal (offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
		endstr = document.cookie.length;  
		return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg){
			return getCookieVal (j);    
			}
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	} 
	return null;
}

function SetCookie (name, value) {  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {  
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

//////////////////////////////////////////////////////////////////////////////
// Formularios
function limitar_longitud_textarea(field, maxlimit) {
  if (field.value.length > maxlimit) // if too long...trim it!
      field.value = field.value.substring(0, maxlimit);
}

function validar_campos_formulario(formulario) {
	for (i=0;i<formulario.length;i++) {
		var tempobj=formulario.elements[i]; 
        var valor = tempobj.value;		
        var tipo = tempobj.id.substring(0,3); 
        var nombre_campo = tempobj.id.substring(4,30).toUpperCase();
		if(nombre_campo.substring(0,2).toUpperCase()=='S_'){
			nombre_campo=s_[parseInt(nombre_campo.substring(2,30))];
		} else {
		}
		//alert(nombre_campo);
         if (tempobj.id.length > 0) {  
            if (((tempobj.type=="text")||(tempobj.type=="textarea")||(tempobj.type=="password")||(tempobj.type=="file"))&&(valor.length==0)&&(nombre_campo.length >0)){
               alert(s_[1]+'\n'+nombre_campo);	 
	           //tempobj.style.background = "#CCCCCC";  //permitir cambiar el color de fondo del campo
               tempobj.focus();
			   return false;
            }  
			if ((tipo.length > 0)&&(valor.length > 0)) {
 		       switch (tipo){
		          case "num": 
		               if (isNaN(valor)) {
				          alert(s_[2]+nombre_campo); 
                          tempobj.select();
			              return false;						  						  
				       }
                       break;					
		          case "dts": 
			           if (!validar_fecha_valida(tempobj.name, formulario)) {
                          tempobj.select();
			              return false;						  
				       }
                       break;
			      case "@@@": 
			           var inicio = valor.indexOf("@"); 
					   var fin = valor.lastIndexOf("@"); 
                       if ((inicio != fin) || ((inicio == -1) && (fin == -1)) || ((inicio == 0) && (fin == 0))|| ((inicio == valor.length-1) && (fin == valor.length-1))){
					      alert(s_[3]+nombre_campo);
                          tempobj.select();
			              return false;						  
                       }
					   if(!isEmail(valor)){
					      alert(s_[3]+nombre_campo);
                          tempobj.select();
			              return false;						  
					   }
			           break; 
				  case "hhh": 
                       var horas=valor.split(":")[0];
                       var minutos=valor.split(":")[1];
                       var segundos=valor.split(":")[2];
                       if (valor.indexOf("/")==-1) {
                          alert(s_[4]);
                          tempobj.select();						  
                     	  return false;
                       }					   
					   if ((horas > "23")||(horas < "0")) {
					      alert(s_[5]);
                          tempobj.select();
                          return false;						  
					   }
					   if ((minutos > "59")||(minutos < "0")) {
					      alert(s_[6]);
                          tempobj.select();
                          return false;						  
					   }
					   if ((segundos > "59")||(segundos < "0")) {
					      alert(s_[7]);
                          tempobj.select();
                          return false;						  
					   }
				       break;
		          case "txt": break;
		          case "bit": break; 
		          case "ids": break; 
		       } 
            }  
         } 
	 } 
  return true;  
} 

///////////////////////////////////////////////////////////////////////////
/// TEXTOS

function ctl_mayusculas(oc){
	var s;
	s=oc.value;
	oc.value=s.toUpperCase();
	return true;
}

function cambia_puntuacion_es_en(s){
	var i,c,r;
	r='';
	for(i=0;i<s.length;i++){
		c=s.charAt(i);
		if(c=='.') r=r+'';
		else if(c==',') r=r+'.';
		else r=r+c;
	}
	return r;
}

function cambia_puntuacion_en_es(s){
		return formatCurrency(s);
}

function formatCurrency(num){
  num = num.toString().replace(/\ |\,/g,'');
  if(isNaN(num)) 
	num = "0";
  cents = Math.floor((num*100+0.5)%100);
  num = Math.floor((num*100+0.5)/100).toString();
  if(cents < 10) 
	cents = "0" + cents;
  for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+'.'+num.substring(num.length-(4*i+3));
  return (' ' + num + ',' + cents);
}

///////////////////////////////////////////////////////////////////////////
//// E-MAIL
function isEmail(strEmail) {
	if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		return true;
	else
		return false;
}

///////////////////////////////////////////////////////////////////////////
//// favoritos/inicio
function addbookmark(){
 	if(document.all) 
  		window.external.AddFavorite(g_urlPortal,g_TituloPortal);
}
function makeHomePage(o){
 	if(document.all) {
		o.style.behavior='url(#default#homepage)';
		o.setHomePage(g_urlPortal); 
 	}
	return false;
}
//  <TR>
//  <TD align=center>
//  <P><A OnMouseOver="return msj('Añade esta página a tus favoritos')" OnMouseOut="return msj('')" HREF="JavaScript:addbookmark()">Añade esta página<br>a tus favoritos</A></P>
//  </TD>
//  </TR>
// <TR><TD height=4><HR></TD></TR>
//  <TR>
//  <TD align=center>
//  <P><a  OnMouseOver="return msj('Haz esta página tu página de inicio')" OnMouseOut="return msj('')"
//  href="#"
// onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.terra.es/personal6/alanceta/principal.html'); return false;">Haz esta página<br>tu página de inicio</a></P>
//  </TD>
//  </TR>

///////////////////////////////////////////////////////////////////////////
// login usuario
function validar_formulario_login(o){
	if(o.usuario.value==""){
		alert(m_[290]); //Por favor, introduce tu nombre de usuario (e-mail).
		o.usuario.focus();
		return false;
	}
	if(o.clave.value==""){
		alert(m_[291]); //Por favor, introduce tu clave.
		o.clave.focus();
		return false;
	}
	return true;
}

function validar_login(){
	var f=document.login;
	if(validar_formulario_login(f)) {
		f.submit();
	} else {
		//alert('problemas en el login');
	}
}

function comprobar_login_enter(evt){
	evt = (evt) ? evt : event;
	var charCode = (evt.which) ? evt.which : evt.keyCode;
	if (charCode == 13) {
		var f=document.login;
		if(f.usuario.value==''){
			alert(s_[1]+'login');
			f.usuario.focus();
			return true;
		}
		if(f.clave.value==''){
			alert(s_[1]+'password');
			f.clave.focus();
			return true;
		}
		//f.submit();
		validar_login();
		return false;
	}
	return true;
}
////////////////////////
function checkEntero(evt){
	evt=(evt)?evt:event;
	if (evt.keyCode < 48 || evt.keyCode > 57){
		evt.returnValue = false;
		return false;
	}
	return true;
}

////////////////////////
function inicializar_pagina(){ return true; }

