// JavaScript Document
function validar(x){
  if(x == 'registro'){
    var email = document.form1.email.value;
	if(document.form1.nombre.value == ''){
	  alert('Nombre es un campo requerido.');
	}else if(document.form1.apellido.value == ''){
	  alert('Apellido es un campo requerido.');
	}else if(document.form1.estado.value == ''){
	  alert('Estado es un campo requerido.');
	}else if(document.form1.direccion1.value == ''){
	  alert('Direcci\ón 1 es un campo requerido.');
	}else if(document.form1.ciudad.value == ''){
	  alert('Ciudad es un campo requerido.');
	}else if(document.form1.zip.value == '' || isNaN(document.form1.zip.value)){
	  alert('Codigo Zip es un campo num\érico requerido.');
	}else if(email == "" || email.indexOf ('@') == -1 || email.indexOf ('.') == -1 || (email.indexOf('.') < email.indexOf('@')+3)){
	  alert('Email es un campo requerido.');
	}else{
	  document.form1.submit();
	}
  }else if(x == 'contacto'){
	var email = document.form1.email.value;
	if(document.form1.nombre.value == ''){
	  alert('Nombre es un campo requerido');
	}else if(document.form1.apellido.value == ''){
	  alert('Apellido es un campo requerido.');
	}else if(email == "" || email.indexOf ('@') == -1 || email.indexOf ('.') == -1 || (email.indexOf('.') < email.indexOf('@')+3)){
	  alert('Email es un campo requerido.');
	}else{
	  document.form1.submit();
	}
  }
}
function seleccionarDeseleccionar(accion,cantidad){
  if(accion == 'S'){
	for(i=1;i<=cantidad;i++){
	  eval("document.form1.elm_"+i+".checked = true");
	}
  }else if(accion == 'D'){
	 for(i=1;i<=cantidad;i++){
	  eval("document.form1.elm_"+i+".checked = false");
	} 
  }
}
function getRefToDiv(divID,oDoc) {
    if( !oDoc ) { oDoc = document; }
    if( document.layers ) {
        if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
            //repeatedly run through all child layers
            for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
                //on success, return that layer, else return nothing
                y = getRefToDiv(divID,oDoc.layers[x].document); }
            return y; } }
    if( document.getElementById ) {
        return document.getElementById(divID); }
    if( document.all ) {
        return document.all[divID]; }
    return false;
}
function showDiv(divID_as_a_string,x,y) {
   //get a reference as above ...
	myReference = getRefToDiv(divID_as_a_string);
    if( !myReference ) {
        return false; //don't go any further
        //return anything would work,
        //but I am using false to show failure
    }
    //now we have a reference to it
    if( myReference.style ) { //DOM & proprietary DOM
        myReference.style.visibility = 'visible';
		myReference.style.left = x;
		myReference.style.top = y-65;
    } else {
        if( myReference.visibility ) { //Netscape
            myReference.visibility = 'show';
			myReference.left = x;
			myReference.top = y-65;
        } else {
            return false; //don't go any further
        }
    }
    return true;
}
function hideDiv(divID_as_a_string) {
    //get a reference as above ...
    myReference = getRefToDiv(divID_as_a_string);
    if( !myReference ) {
        return false; //don't go any further
        //return anything would work,
        //but I am using false to show failure
    }
    //now we have a reference to it
    if( myReference.style ) { //DOM & proprietary DOM
        myReference.style.visibility = 'hidden';
    } else {
        if( myReference.visibility ) { //Netscape
            myReference.visibility = 'hide';
        } else {
            return false; //don't go any further
        }
    }
    return true;
}
function showLayer(actual,desde,hasta,x,y){
  for(i=desde;i<=hasta;i++){
	if (actual==i) {
	  showDiv('alerta_'+i,x,y);
	}else{
	  hideDiv('alerta_'+i);
	}
  }
}
function rdm(id,width,height){
  id=document.getElementById(id);
  id.style.width=width + "px";
  id.style.height=height + "px";
  id.style.clip= "rect(0px, "+width+"px, "+height+"px, 0px)"
  //alert("ancho="+width+" / "+"alto="+height);
}