// JavaScript Document
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe contener una dirección de email válida.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- El '+nm+' debe contener un teléfono válido.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- El campo "'+nm+'" es obligatorio.\n'; }
  } if (errors) alert('Han surgido los siguientes errores:\n'+errors);
  document.MM_returnValue = (errors == '');
}
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
function tcn_writeCookie(name, defaultText){
  if(document.cookie==''){
    document.write(defaultText);
    return false;
  }
  if(document.cookie != ''){
    var actualValue, firstChar, lastChar;
    var theBigCookie = document.cookie;
    firstChar = theBigCookie.indexOf(name);
    if(firstChar==-1){
      document.write(defaultText);
      return false;
    }
    if(firstChar != -1) {
      firstChar += name.length + 1;
      lastChar = theBigCookie.indexOf(';', firstChar);
      if(lastChar == -1) lastChar = theBigCookie.length;
      actualValue = theBigCookie.substring(firstChar, lastChar);
    } else {actualValue = ""}
  }
  document.write(actualValue);
}
<!--
var foto = 'http://www.renovacar.com/upload/noimage.jpg';
function galeria(img,img_med,img_small){
foto = "/upload/"+img;
//definimos imagenes
image_med = new Image();
image_small = new Image();

//definimos las rutas
image_med.src = "http://www.renovacar.com/upload/"+img_med;
image_small.src = "http://www.renovacar.com/upload/"+img_small;
loader(img_med, img_small);
}
//precargamos
function loader(img, img_small){
	flagx=false;
	var tiempo = "";

	if (image_med.complete){flagx=true;}
	if (flagx) {
	clearTimeout(tiempo);
	document.images['large'].src=image_med.src;
	} else {
	document.images['large'].src="upload/cargando.gif";
	tiempo=setTimeout("loader('"+img+"', '"+img_small+"')",1000);
	}
}
function ampliaFoto(){
GP_AdvOpenWindow('verfoto.php?img='+foto,'form_ampli','fullscreen=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no',550,413,'center','ignoreLink','',0,'');return document.MM_returnValue
}
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = "";
}
function resetText(thefield){
if(thefield.value==""){
thefield.value=thefield.defaultValue;
}}

//Validar numero personas
var validInt = '0123456789';

function validateKeyPress(e, validSet){
var key;
var keychar;

if(window.event || !e.which) // IE
key = e.keyCode; // IE
else if(e) 
key = e.which; // Netscape
else
return true; // no validation

keychar = String.fromCharCode(key);
validSet += String.fromCharCode(8);

if (validSet.indexOf(keychar) < 0)
return false;

return true; 
}

