<!--

/*
Form field Limiter script- By Dynamic Drive
For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
This credit MUST stay intact for use
*/
var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}

function displaylimit(theform,thelimit){
var limit_text='<strong><span id="'+theform.toString()+'">'+thelimit+'</span></strong>'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
}
//////////////////////////////
function dothis(obj,anterior)
{
if(obj.value == ""){
obj.value = anterior;
}
}
//////////////////////////////

//////////////////////////////
function changeImage(filename)
{
   document.mainimage.src = filename;
}
//////////////////////////////
//////////////////////////////


function validar(theForm){

        if(theForm.empresa.value == "") {
        alert("Indique el nombre de la empresa (Hotel, hostal, etc).");
        theForm.empresa.focus();
        return(false);
        }
        if(theForm.name.value == "") {
        alert("Indiqueu el nombre y apellidos de la persona de contacto.");
        theForm.name.focus();
        return(false);
        }


        if(theForm.address.value == "") {
        alert("Indique la dirección.");
        theForm.address.focus();
        return(false);
        }

        if(theForm.pcode.value == "") {
        alert("Indique el código postal.");
        theForm.pcode.focus();
        return(false);
        }

        if(theForm.provincia.value == "") {
        alert("Indique la provincia.");
        theForm.provincia.focus();
        return(false);
        }

        if(theForm.pais.value == "") {
        alert("Indique el país.");
        theForm.pais.focus();
        return(false);
        }

if(theForm.wphone.value == ""  || theForm.wphone.value == "tu teléfono") {
                 alert("Por favor, indique un teléfono de contacto.");
                 theForm.wphone.focus();
                 return(false);
        }
  if(theForm.wphone.value != "") {
var parsed2 = true;
var largo2 = theForm.wphone.value;
if (largo2.length <9){alert("Es correcto el teléfono? \rEscriba sólo números.\rRecuerde escribir el prefijo.");theForm.wphone.focus();return(false);}
  var validchars2 = "0123456789 ";
  for (var z=0; z < largo2.length; z++) {
    var letter2 = largo2.charAt(z);
    if (validchars2.indexOf(letter2) != -1)
      continue;
    alert("Por favor, escriba sólo números en el campo Teléfono.");
    parsed2 = false;

    theForm.wphone.focus();
    return(false);
break;

  }
}


		if(theForm.e_mail.value == "" || theForm.e_mail.value == "tu email") {
		alert("Por favor, su email.");
		theForm.e_mail.focus();
		return(false);
		}
	
	
		if(theForm.e_mail.value != "") {
	
		var largoV = theForm.e_mail.value;
			if (largoV.length < 6){
			theForm.e_mail.focus();alert("Email incorrecto.");return (false);
	
			}else{
	
			var valor1v = "false";
			var valor2v = "false";
				for(x = 0;x<largoV.length;x++){
				var oneChar2v = largoV.charAt(x);
				if (oneChar2v == "@"){valor1v = "true";}
				if (oneChar2v == "."){valor2v = "true";}
				}
			if (valor1v == "true"){if(valor2v == "true"){}else{theForm.e_mail.focus();alert("Email incorrecto.");return (false);}} else {theForm.e_mail.focus();alert("Email incorrecto.");return (false);}
	
			}
	
		}

		if(theForm.strCAPTCHA.value == "" || theForm.strCAPTCHA.value == " ") {
		alert("Por favor, escribe los caracteres que se muestran en la imagen.");
		theForm.strCAPTCHA.focus();
		return(false);
		}

}// function validar



function cambio(valor, elemento){
//	alert(valor);
if (elemento == 0){

	if ( valor == "1")
	{
	document.file.visible.value = 0;
	}else{
	document.file.visible.value = 1;
	}
}
if (elemento == 1){

	if ( valor == "1")
	{
	document.file.visible1.value = 0;
	}else{
	document.file.visible1.value = 1;
	}
}

if (elemento == 2){

	if ( valor == "1")
	{
	document.file.visible2.value = 0;
	}else{
	document.file.visible2.value = 1;
	}
}


//	alert(document.file.visible.value);

}

//////////////////////////////
function validarPhone(theForm){
/************************************
archivo con la funciones y utilidades necesarias en javascript principalmente para validar formularios
*************************************/


	if(theForm.name.value == "" || theForm.name.value == "tu nombre") {
	alert("Por favor, rellene el campo nombre.");
	theForm.name.focus();
	return(false);
	}



//////////////////////////// comprobaciones para informacion y contactar /////////////////////////////////////
//	if (theForm.name == "informacion" || theForm.name == "contactar"){
///////////////////////////////////////////////////////////////////////////////////


} // final funcion validar



//-->




