<!--

function ValidEncuesta(e){
	var s = new Array(5);
	s[0] = "no"; 
	s[1] = "no"; 
	s[2] = "no"; 
	s[3] = "no"; 
	s[4] = "no"; 
	var f = "";
	
	with (document.FormEncuesta){ 
		for(var a = 0; a < 5; a++){
			var fq = "fqs"+a;
			for ( var i = 0; i < eval(fq).length; i++ ) { 
				if ( eval(fq)[i].checked ) { 
					s[a]= "si"; 
				} 
			} 
			if ( s[a] == "no" ){ 
				document.getElementById('cl_fqs'+a).style.color="red";
				f = 1;
			}else{
				if(a==0){
					document.getElementById('cl_fqs'+a).style.color="#000000";
				}else{
					document.getElementById('cl_fqs'+a).style.color="#BC8C10";
				}
				f = 0;
			}
		}
	}
	if(f){
		document.getElementById('msncomentrario').innerHTML = "<font color=#ff0000>Data Required</font>";
	}else{
		document.getElementById(e).action = "comentario.php";
  		document.getElementById(e).method = "POST";
  		document.getElementById(e).submit();
	}
	
}


function checkFuel(e,f){
	if(e=="0.00"){
		document.getElementById('idfuel_shipping').checked = false;
		document.getElementById('idfuel').value = '0.00';
	}else{
		document.getElementById('idfuel_shipping').checked = true;
		document.getElementById('idfuel').value = f;
	}
}

function confirmSubmit(i,t)
{
	var agree=confirm("Are you sure you wish to continue?");
	if (agree){
		if(t!="jobs"){
			xajax_processDeleteFile(xajax.getFormValues(i),t);
		}else{
				return true;
		}
	}else{
		return false ;
	}
}
function DirChecked(i,d){ 
	var num = document.getElementById(i).elements.length;
	var tip ="";
	for (a = 0; a < num;a++){
		var nmt = document.getElementById(i).elements[a].name;
		tip = document.getElementById('id'+nmt);
		//document.getElementById('IdMensaje').innerHTML = tip.type;
		if(tip){
			if(tip.type == "checkbox" && tip.value != d){
				document.getElementById('id'+nmt).checked = false;
				document.getElementById('idalb').value = "";
			}
		}
	}
	if(document.getElementById('idalbum'+d).checked == true){
		document.getElementById('idalb').value = d;
		document.getElementById('IdMensaje').innerHTML = d;
	}
}


function gotoPage(varItem){
	window.location="cpanel.php?mn="+varItem;
}

function validArchivo(i,t) {
	if(t=="adicionar"){
		ProcessForm(i,'archivos');
	}
}
function validAlbumfotos(i,t) {
	var album1 = document.getElementById('idexisting')
	var album2 = document.getElementById('idnew')
	var error = "";
	
	if(album1.checked){
		var  s = document.getElementById('idalbumselect').value;
		if(!s){
			document.getElementById('IdMensaje').innerHTML = "<font color=#ff0000>Data Required</font>";
			document.getElementById('cl_asettings').style.color = "#FF0000";
			error = 1;
		}else{
			document.getElementById('IdMensaje').innerHTML = "";
			document.getElementById('cl_asettings').style.color = "#000000";
			error = "";
		}
		document.getElementById('cl_dirname').style.color = "#000000";
	}
	if(album2.checked){
		var  s = document.getElementById('iddirname').value;
		if(!s){
			document.getElementById('IdMensaje').innerHTML = "<font color=#ff0000>Data Required</font>";
			document.getElementById('cl_dirname').style.color = "#FF0000";
			error = 1;
		}else{
			document.getElementById('IdMensaje').innerHTML = "";
			document.getElementById('cl_dirname').style.color = "#000000";
			error = "";
		}
		document.getElementById('cl_asettings').style.color = "#000000";
	}
	if(!error){
		if(t=="adicionar"){
			ProcessForm(i,'album_fotos');
		}
		if((t=="Move")||(t=="Copy")){
			xajax_processMoverFoto(xajax.getFormValues(i),t);
		}
		
	}
}
function LengNumPhone(i,n,m) {
	var num = document.getElementById('id'+i).value.length;
	if(num < n){
		document.getElementById(m).style.color = "#FF0000";
		document.getElementById('IdMensaje').innerHTML = "<font color=#ff0000>Error in number of characters</font>";
		document.getElementById('id'+i).focus();
	}else{
		document.getElementById(m).style.color = "#000000";
		document.getElementById('IdMensaje').innerHTML = "";
	}
	return true
}

function LengNum(i) {
	var num = document.getElementById('id'+i).value.length;
	if(num < 4){
		document.getElementById('cl_'+i).style.color = "#FF0000";
		document.getElementById('IdMensaje').innerHTML = "<font color=#ff0000>Error in number of characters</font>";
		document.getElementById('id'+i).focus();
	}else{
		document.getElementById('cl_'+i).style.color = "#000000";
		document.getElementById('IdMensaje').innerHTML = "";
	}
	return true
}

function esCantMini(c,i,p){
	var cn = document.getElementById(i).value;
	if(eval(cn) < eval(c)){
		document.getElementById('msnqty'+p).innerHTML = "<font color='red'>Quantity not allowed...</font>";
		document.getElementById(i).focus();
	}else{
		document.getElementById('msnqty'+p).innerHTML = "";
	}
}

function esNum(e) {
var charCode
if (navigator.appName == "Netscape") // Veo si es Netscape o Explorer (mas adelante lo explicamos)
charCode = e.which // leo la tecla que ingreso
else
charCode = e.keyCode // leo la tecla que ingreso
status = charCode
if (charCode > 31 && (charCode < 48 || charCode > 57)) { // Chequeamos que sea un numero comparandolo con los valores ASCII
  alert("Character not allowed...")
  return false
}

return true
}


function esNumDe(e) {
var charCode
if (navigator.appName == "Netscape") // Veo si es Netscape o Explorer (mas adelante lo explicamos)
charCode = e.which // leo la tecla que ingreso
else
charCode = e.keyCode // leo la tecla que ingreso
status = charCode
if (charCode > 31 && (charCode < 48 || charCode > 57)) { // Chequeamos que sea un numero comparandolo con los valores ASCII
  if (charCode == 46){
    return true
  }else{
	  alert("Character not allowed...")
     return false
  }
}

return true
}

function IsChecked(i){ 
	var num = document.getElementById(i).elements.length;
	var val = document.getElementById('Idmontoapagar').value; 
	if(!val || val=="0.00" ){
		for (a = 0; a < num;a++){
			var nmt = document.getElementById(i).elements[a].name;
			var tip = document.getElementById('id'+nmt);
			if(tip){
			//document.getElementById('IdMensaje').innerHTML = tip.type;
			 	if(tip.type == "checkbox"){
				 	document.getElementById('Id'+nmt).checked = false;
			 	}
			}
		}
		document.getElementById('IdSerMensaje').innerHTML = "";
	}
}

function IsNumeric(valor) 
{ 
var log=valor.length; var sw="S"; 
for (x=0; x<log; x++) 
{ v1=valor.substr(x,1); 
v2 = parseInt(v1); 
//Compruebo si es un valor numérico 
if (isNaN(v2)) { sw= "N";} 
} 
if (sw=="S") {return true;} else {return false; } 
} 

var primerslap=false; 
var segundoslap=false; 
function formateafecha(fecha) 
{ 
var long = fecha.length; 
var dia; 
var mes; 
var ano; 

if ((long>=2) && (primerslap==false)) { dia=fecha.substr(0,2); 
if ((IsNumeric(dia)==true) && (dia<=31) && (dia!="00")) { fecha=fecha.substr(0,2)+"/"+fecha.substr(3,7); primerslap=true; } 
else { fecha=""; primerslap=false;} 
} 
else 
{ dia=fecha.substr(0,1); 
if (IsNumeric(dia)==false) 
{fecha="";} 
if ((long<=2) && (primerslap=true)) {fecha=fecha.substr(0,1); primerslap=false; } 
} 
if ((long>=5) && (segundoslap==false)) 
{ mes=fecha.substr(3,2); 
if ((IsNumeric(mes)==true) &&(mes<=12) && (mes!="00")) { fecha=fecha.substr(0,5)+"/"+fecha.substr(6,4); segundoslap=true; } 
else { fecha=fecha.substr(0,3);; segundoslap=false;} 
} 
else { if ((long<=5) && (segundoslap=true)) { fecha=fecha.substr(0,4); segundoslap=false; } } 
if (long>=7) 
{ ano=fecha.substr(6,4); 
if (IsNumeric(ano)==false) { fecha=fecha.substr(0,6); } 
else { if (long==10){ if ((ano==0) || (ano<1900) || (ano>2100)) { fecha=fecha.substr(0,6); } } } 
} 

if (long>=10) 
{ 
fecha=fecha.substr(0,10); 
dia=fecha.substr(0,2); 
mes=fecha.substr(3,2); 
ano=fecha.substr(6,4); 
// Año no viciesto y es febrero y el dia es mayor a 28 
if ( (ano%4 != 0) && (mes ==02) && (dia > 28) ) { fecha=fecha.substr(0,2)+"/"; } 
} 
return (fecha); 
} 

function ordentag(d,t,i){
	if (document.getElementById){
	  obj = document.getElementById(d); 
	  if (obj.style.display == "none"){ 
		 obj.style.display = "block"; 
		 if(t=="productos"){
			// xajax_processImagenProducto(t,i);
		 }
	   }else { 
		 obj.style.display = "none"; 
		 
	   }
   	}	
}
function closetag(d,f){
  if (document.getElementById){
	  obj = document.getElementById(d); 
	  
	  if(f){
		objc = document.getElementById(f); 
	  }
	  var dimga = "./images/arrow_1_down.gif";
	  var dimgb = "./images/arrow_1.gif";
	  if (obj.style.display == "none"){ 
		 obj.style.display = ""; 
		
		 if(f){
			if(objc.style.display != "none"){
			closetag(f,d);
			}
		 }
	   }else { 
		 obj.style.display = "none"; 
		
	   }
   }
}

function seleccionarOpcion(combo, valorIni) {

var x;

if(!combo.multiple)
{ 
  for (x = 0; x < combo.length; x++)
    if (combo[x].value == valorIni) {
      combo.selectedIndex = x;
      break;
    }
}else {
  var opciones = valorIni.split('-');
  for (var i = 0; i < opciones.length; i++)
    for (x = 0; x < combo.length; x++)
      if (combo.options[x].value == opciones[i]) {
        combo.options[x].selected = true;
        break;
      }
}    
}


function checkNumero(){

  if (event.keyCode >= 48 && event.keyCode <= 57){
    event.returnValue = true;
  }
  else{
    event.returnValue = false;
  }
}


function validarComillaSimple(){
	if (event.keyCode != 39){
		event.returnValue = true;
  }
  else{
    event.returnValue = false;
  }
}	

function checkValidos(){
  if ((event.keyCode >= 65 && event.keyCode <= 90)||(event.keyCode >= 97 && event.keyCode <= 122)||(event.keyCode >=40 && event.keyCode<=41 ) ){
    event.returnValue = true;
  }
  else{
    event.returnValue = false;
  }
}

function checkFechas(v1,v2)
{

 if (v1!="" &&  v2!="")
 {
   var fecha1 = new Date(v1.substr(6,4),v1.substr(3,2) - 1,v1.substr(0,2));
   var fecha2 = new Date(v2.substr(6,4),v2.substr(3,2) - 1,v2.substr(0,2));

    if (fecha1 <= fecha2)
      return true;
    else
      {  alert('La primera fecha es mayor\n que la segunda fecha.');
         return false;
      }
  }
  else
  { alert('Alguna de las fechas no fue indicada. Por favor introdúzcala e intente nuevamente');
    return false;
  }
}

function ponerColorFoco(objeto) {

if (objeto.tagName == 'INPUT') {
  objeto.style.backgroundColor='navy';
  objeto.style.color='white';
}  
}

function quitarColorFoco(objeto) {

if (objeto.tagName == 'INPUT') {
  objeto.style.backgroundColor='transparent';
  objeto.style.color='transparent';
}  
}

function quitarCaracteres (inputString, removeChar)
{
  var returnString = inputString;
  if (removeChar.length)
  {
    while('' + returnString.charAt(0) == removeChar)
    {
      returnString = returnString.substring(1,returnString.length);
    }
    while('' + returnString.charAt(returnString.length - 1) == removeChar)
    {
      returnString = returnString.substring(0,returnString.length - 1);
    }
  }
  return returnString;
}

//set todays date
Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();
if (NowYear < 2000) NowYear += 1900; //for Netscape

//function for returning how many days there are in a month including leap years
function DaysInMonth(WhichMonth, WhichYear)
{
  var DaysInMonth = 31;
  if (WhichMonth == "Abr" || WhichMonth == "Jun" || WhichMonth == "Sep" || WhichMonth == "Nov") DaysInMonth = 30;
  if (WhichMonth == "Feb" && (WhichYear/4) != Math.floor(WhichYear/4))	DaysInMonth = 28;
  if (WhichMonth == "Feb" && (WhichYear/4) == Math.floor(WhichYear/4))	DaysInMonth = 29;
  return DaysInMonth;
}

//function to change the available days in a months
function ChangeOptionDays(Which)
{
  DaysObject = eval(Which + "Dia");
  MonthObject = eval(Which + "Mes");
  YearObject = eval(Which + "Ano");

  Month = MonthObject[MonthObject.selectedIndex].text;
  Year = YearObject[YearObject.selectedIndex].text;

  DaysForThisSelection = DaysInMonth(Month, Year);
  CurrentDaysInSelection = DaysObject.length;
  if (CurrentDaysInSelection > DaysForThisSelection)
  {
    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
    {
      DaysObject.options[DaysObject.options.length - 1] = null
    }
  }
  if (DaysForThisSelection > CurrentDaysInSelection)
  {
    for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
    {
      NewOption = new Option(DaysObject.options.length + 1);
      DaysObject.add(NewOption);
    }
  }
    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
}

//function to write option years before x
function WriteYearOptions(YearsBefore)
{
  line = "";
  for (i=NowYear-YearsBefore; i <= NowYear; i++)
  {
    line += "<option value='" + i + "'>";
    line += i;
  }
  return line;
}

<!-- V1.1.3: Sandeep V. Tamhankar (stamhankar@hotmail.com) -->
<!-- Original:  Sandeep V. Tamhankar (stamhankar@hotmail.com) -->
<!-- Changes:
/* 1.1.4: Fixed a bug where upper ASCII characters (i.e. accented letters
international characters) were allowed.

1.1.3: Added the restriction to only accept addresses ending in two
letters (interpreted to be a country code) or one of the known
TLDs (com, net, org, edu, int, mil, gov, arpa), including the
new ones (biz, aero, name, coop, info, pro, museum).  One can
easily update the list (if ICANN adds even more TLDs in the
future) by updating the knownDomsPat variable near the
top of the function.  Also, I added a variable at the top
of the function that determines whether or not TLDs should be
checked at all.  This is good if you are using this function
internally (i.e. intranet site) where hostnames don't have to 
conform to W3C standards and thus internal organization e-mail
addresses don't have to either.
Changed some of the logic so that the function will work properly
with Netscape 6.

1.1.2: Fixed a bug where trailing . in e-mail address was passing
(the bug is actually in the weak regexp engine of the browser; I
simplified the regexps to make it work).

1.1.1: Removed restriction that countries must be preceded by a domain,
so abc@host.uk is now legal.  However, there's still the 
restriction that an address must end in a two or three letter
word.

1.1: Rewrote most of the function to conform more closely to RFC 822.

1.0: Original  */
// -->
function emailCheck (emailStr) {

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

alert("La dirección Email parece incorrecta (chequee arrobas (@) y puntos (.) )");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("El nombre de usuario contiene caracteres invalidos.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("El nombre de dominio contiene caracteres invalidos.");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

alert("El nombre de usuario no parece ser valido.");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Dirección IP destino es invalida!");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("El nombre de dominio no parece ser valido.");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("La dirección debe terminar en un dominio bien conocido o codigo de pais de dos letras.");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
alert("La dirección carece de un nombre de host!");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}

//-->
//Funcion para validar caracteres - Lo pones en el evento onKeyPress
function checkValidos(){
  if ((event.keyCode >= 65 && event.keyCode <= 90)||(event.keyCode >= 97 && event.keyCode <= 122)|| (event.keyCode >= 48 && event.keyCode <= 57)){   
    event.returnValue = true;
  }
  else{
    event.returnValue = false;
  }
}

//otras funciones

function validarForm(i,t) {
	var msn = "";
	var vemensaje = 0;
	var rd = "";
	var num = document.getElementById(i).elements.length;
	for (a = 0; a < num;a++){
	  var nmt = document.getElementById(i).elements[a].name;	
	  if (document.getElementById('ast_'+nmt)){
	    var djb = document.getElementById('ast_'+nmt).innerHTML;
	  }else{
		var djb = ""; 
	  }

       if (djb=="*"){
		 if(nmt != "date"){
		 	var vlt = document.getElementById('id'+nmt).value; 
		 }else{
			var dmes  = document.getElementById('idf_date_mes').value;
			var ddia  = document.getElementById('idf_date_dia').value;
			var dyear = document.getElementById('idf_date_year').value;
			
			if(!dmes || !ddia || !dyear){
				document.getElementById('f_date_b').value = "";
			}else{
				var vdate = dmes+"/"+ddia+"/"+dyear;
				document.getElementById('f_date_b').value = vdate;
			} 	
			var vlt = document.getElementById('f_date_b').value; 
		 }
		 vlt = vlt.replace(/(^\s*)|(\s*$)/g,""); 
		 if (nmt=="terminos"){
			 if (document.getElementById('id'+nmt).checked == false){
				 vlt = "";
			 }
		 }
		 if (nmt=="montoapagar"){
			 if (document.getElementById('id'+nmt).value == '0.00'){
				 vlt = "";
			 }
		 }
		  if (vlt==""){
			  var error = 1;
			 document.getElementById('cl_'+nmt).style.color = "#FF0000";
			 
			 
		 }else{
			 var ps = 1;
			 document.getElementById('cl_'+nmt).style.color = "#999999";
			 if(nmt=="email_address"){
				var vemail = document.getElementById('idemail_address').value;
	 			var ev = emailCheck(vemail);
	 			if (ev){
	   				msn += "<font color=#FF0000>"+ev+"</font><br>";
	   				document.getElementById('cl_email_address').style.color = "#FF0000";
	  			}
			 }
			 
			 if(nmt=="confirm_email_address"){
				var vemail = document.getElementById('idconfirm_email_address').value;
	 			var ev = emailCheck(vemail);
				if (ev){
	   				msn += "<font color=#FF0000>"+ev+"</font><br>";
	   				document.getElementById('cl_confirm_email_address').style.color = "#FF0000";
	  			}
			 }
			 
			 if(nmt=="confirm_email_address"){
				 var vemail = document.getElementById('idemail_address').value;
				 var vemail2 = document.getElementById('idconfirm_email_address').value;
				 if(vemail != vemail2){
					msn += "<font color=#FF0000>Emails must be equal</font><br>";
	   				document.getElementById('cl_email_address').style.color = "#FF0000";
					document.getElementById('cl_confirm_email_address').style.color = "#FF0000";
				 }
			 }
			 if(nmt=="username"){
				var txmsn = document.getElementById('idusername').value;
				txmsn = txmsn.replace(/(^\s*)|(\s*$)/g,""); 
				vemensaje = txmsn.length;
				 if(vemensaje < 6 || vemensaje > 12){
					 msn += "<font color=#FF0000>Username (6-12 characters)</font><br>";
	   				document.getElementById('cl_username').style.color = "#FF0000";
				 }
			 }
			 if(nmt=="password"){
				var txmsn = document.getElementById('idpassword').value;
				txmsn = txmsn.replace(/(^\s*)|(\s*$)/g,""); 
				vemensaje = txmsn.length;
				 if(vemensaje < 6 || vemensaje > 12){
					 msn += "<font color=#FF0000>Password (6-12 characters)</font><br>";
	   				document.getElementById('cl_password').style.color = "#FF0000";
				 }
			 }
			 if(nmt=="confirm_password"){
				var txmsn = document.getElementById('idconfirm_password').value;
				txmsn = txmsn.replace(/(^\s*)|(\s*$)/g,""); 
				vemensaje = txmsn.length;
				 if(vemensaje < 6 || vemensaje > 12){
					 msn += "<font color=#FF0000>Confirm password (6-12 characters)</font><br>";
	   				document.getElementById('cl_confirm_password').style.color = "#FF0000";
				 }else{
					 ps = "";
				 }
				
			 }
			 
		 }
	  }
	  
	}
	
	if(t=="usuarios_shipping_method"){
		var tmm1 = document.getElementById('idtime_between_hour').value;
		var tmm2 = document.getElementById('idtime_between_minute').value;
		var tmm3 = document.getElementById('idtime_between_tipo').value;
		var tmm4 = document.getElementById('idtime_and_hour').value;
		var tmm5 = document.getElementById('idtime_and_minute').value;
		var tmm6 = document.getElementById('idtime_and_tipo').value;
		if(!tmm1 || !tmm2 || !tmm3 || !tmm4 || !tmm5 || !tmm6 ){
			var error = 1;
			document.getElementById('cl_time').style.color = "#FF0000";
		}else{
			document.getElementById('cl_time').style.color = "#000000";
		}
	}
	if(error){
		 msn += "<font color=#FF0000>Data Required</font>";
	}
	if((t!="usuarios_billing") && (t!="usuarios_shipping") && (t!="usuarios_shipping_method") && (t!="usuarios_payment_method")&& (t!="orden_compras")){
		document.getElementById('IdMensaje').innerHTML = msn;
	}else{
		document.getElementById('Msn'+i).innerHTML = msn;
	}
	if (!msn){
		if( (t!='houses') && (t!='houses_images') && (t!='houses_editar') && (t!='houses_images_editar') && (t!='suggestions') && (t!='jobs') && (t!='jobs_aspirants')){
			if(t=='login'){
				xajax_processFormLogin(xajax.getFormValues(i),'usuarios');
			}
			
			if(t=='usuarios'){
				xajax_processFormRegistro(xajax.getFormValues(i),'1');
			}
			if(t=='aliados'){
				xajax_processFormAliados(xajax.getFormValues(i),'1');
			}
			
			if(t=='usuarios_perfil'){
				xajax_processFormRegistro(xajax.getFormValues(i),'2');
			}
			if(t=='usuarios_password'){
				xajax_processOlvidoPassword(xajax.getFormValues(i),'2');
			}
			
			if(t=='usuarios_billing'){
				document.getElementById('img_loading_2').src = "./images/loading.gif";
				xajax_processFormBilling(xajax.getFormValues(i),'_billing','2','3');
			}
			
			if(t=='usuarios_shipping'){
				document.getElementById('img_loading_3').src = "./images/loading.gif";
				xajax_processFormShipping(xajax.getFormValues(i),'_shipping','3','4');
			}
			if(t=='usuarios_shipping_method'){
				document.getElementById('img_loading_1').src = "./images/loading.gif";
				xajax_processFormShippingMethod(xajax.getFormValues(i),'_shipping_method','1','2');
			}
			if(t=='usuarios_payment_method'){
				document.getElementById('img_loading_4').src = "./images/loading.gif";
				xajax_processFormPaymentMethod(xajax.getFormValues(i),'_payment_method','4','5');
			}
			if(t=='orden_compras'){
				document.getElementById('img_loading_5').src = "./images/loading.gif";
				xajax_processConfirmarOrden(xajax.getFormValues(i),'5','6');
			}
			
			if((t=='contact')||(t=='contact_club')){
					xajax_processForm(xajax.getFormValues(i),t);
				
			}
			
			if(t=='houses_pago_deposito'){
				xajax_processPagoAgencia(xajax.getFormValues(i));
			}
			if((t=='houses_pago_tarjeta')||(t=='houses_pago_paypal')){
				xajax_processPagosCredito(xajax.getFormValues(i));
			}
			
			
			if(t=='houses_pagos'){
				xajax_processTipoPagos(xajax.getFormValues(i),'');
			}
			
			if(t=='album_fotos_reportados'){
				var ar = i.split("ag");
				if(ar[1]){
					var tb = document.getElementById('tabla'+ar[1]).value;
					xajax_processFotoReportada(xajax.getFormValues(i),ar[1],tb);
				}
			}
			
			if(t=='album_fotos_amigos'){
				for(a=0;a<7;a++){
					var vemail = document.getElementById('idemail'+a).value;
	 				var ev = emailCheck(vemail);
	 				if (ev){
						if(vemail){
	   						msn += "<font color=#FF0000>"+ev+" - email "+a+"</font><br>";
	   						document.getElementById('cl_email'+a).style.color = "#FF0000";
						}
	  				}
					
				}
				if(!msn){
					var ar = i.split("ag");
					if(ar[1]){
						var tb = document.getElementById('tabla'+ar[1]).value;
						xajax_processEnviarAmigo(xajax.getFormValues(i),ar[1],t);
					}
				}else{
					document.getElementById('Msn'+i).innerHTML = msn;
				}
			}
		}else{
	  			ProcessForm(i,t);  	
		}
		
		
	}else{
		return false;
	}
	
}
function FormAprove(t,i){
	xajax_processFormAprove(xajax.getFormValues(i),'');
}

function ProcessForm(f,t){
  document.getElementById(f).action = "cargar_"+t+".php";
  document.getElementById(f).target = "iform";
  document.getElementById(f).method = "POST";
  document.getElementById(f).enctype = "multipart/form-data";
  document.getElementById(f).submit();
  //xajax.$('IdImagenMsn').innerHTML="Imagen Cargada";
}

function emailCheck(emailStr) {
/* Verificar si el email tiene el formato user@dominio. */
var emailPat=/^(.+)@(.+)$/;

/* Verificar la existencia de caracteres. ( ) < > @ , ; : \ " . [ ] */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";

/* Verifica los caracteres que son válidos en una dirección de email */
var validChars="\[^\\s" + specialChars + "\]";

var quotedUser="(\"[^\"]*\")" ;

/* Verifica si la dirección de email está representada con una dirección IP Válida */ 


var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;


/* Verificar caracteres inválidos */ 

var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");


var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
var msn = "The email is wrong (and check @.)";
return msn;
}
var user=matchArray[1];
var domain=matchArray[2];

// Si el user "user" es valido 
if (user.match(userPat)==null) {
// Si no
msn = "The username is invalid.";
return msn;
}

/* Si la dirección IP es válida */
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
var msn = "Destination IP invalid";
return msn;
}
}
return true;
}

var domainArray=domain.match(domainPat);
if (domainArray==null) {
var msn = "The domain appears to be invalid.";
return msn;
}

var atomPat=new RegExp(atom,"g");
var domArr=domain.match(atomPat);
var len=domArr.length;
if (domArr[domArr.length-1].length<2 || 
domArr[domArr.length-1].length>3) { 

var msn = "The dicrección must have 3 points if. 'Com' or if 2 of any country.";
return msn;
}

if(len<2){
var msn="The email is wrong";
return msn;
}

// La dirección de email ingresada es Válida
return;
}

function CCInfo()
	{
		var isVisa = 1;
		var isMast = 1;
		var isAmex = 1;
		var isDisc = 1;
		var isDine = 0;

		

		document.write(
			'<tr>',
			'	<td align="right">Credit card type:</td>',
			'	<td>'
		);

		if(isVisa)
			document.write('<input type="radio" size="35" name="cctype" value="Visa" checked>',
				'<img border="0"  src="./images/visa.gif" > ');

		if(isMast)
			document.write('<input type="radio" size="35" name="cctype" value="MasterCard">',
				'<img border="0"  src="./images/mastercard.gif" > ');

		if(isAmex)
			document.write('<input type="radio" size="35" name="cctype" value="Amex">',
				'<img border="0"  src="./images/amex.gif" > ');

		if(isDisc)
			document.write('<input type="radio" size="35" name="cctype" value="Discover">',
				'<img border="0"  src="./images/discover.gif" > ');

		if(isDine)
			document.write('<input type="radio" size="35" name="cctype" value="Diners">',
				'<img border="0"  src="./images/diners.gif" > ');


		document.write(
			'	</td>',
			'</tr><tr>',
			'	<td align="right">Credit Card Number:&nbsp;</td>',
			'	<td>',
			'		<input name="ccnum" size="20" maxlength="16" value="">',
			'	</td>',
			'</tr><tr>',
			'	<td>&nbsp;</td>',
			'	<td class="small">1234123412341234</td>',
			'</tr>',
			'<tr>',
			'	<td align="right">Expiration Date:&nbsp;</td>',
			'	<td>',
			'		<select name="expMonth" size="1">',
			'			<option value="" selected>Month</option>',
			'   		<option value="1">January</option>',
			'			<option value="2">February</option>',
			'			<option value="3">March</option>',
			'			<option value="4">April</option>',
			'			<option value="5">May</option>',
			'			<option value="6">June</option>',
			'			 <option value="7">July</option>',
			'			<option value="8">August</option>',
			'			<option value="9">September</option>',
			'			<option value="10">October</option>',
			'			<option value="11">November</option>',
			'			<option value="12">December</option>',
			'		</select>',
			'		<select name="expYear" title="year" size="1">',
			'			<option value="" selected>Year</option>'
		) ;

		for(var i = 0 ; i < 16 ; i++)
		{
			document.write('<option value="', today.year+i, '">', today.year+i, '</option>');
		}
		document.write(
			'		</select>',
			'	</td>',
			'</tr>'
		) ;
	}
	
	function makeDate() {
		this.month = 4 ;
		this.day   = 10 ;	
		this.year  = 2008 ;
	}
	today = new makeDate() ;
	
	function OpenWindow(f,name,dim)
	{
		window.open(f, name, dim);
	}
	
	function onDireccion(f)
	{ 	
		xajax_processFormDireccion(f);
	}
	function vLogin()
	{ 	
		var lg = document.getElementById('idlogin').value;
		if(lg=="email"){
			document.getElementById('idlogin').value = "";
		}
		if(lg==""){
			document.getElementById('idlogin').value = "email";
		}
	}

	function vPass()
	{ 	
		var pw = document.getElementById('idpassword').value;
		if(pw=="****"){
			document.getElementById('idpassword').value = "";
		}
		if(pw==""){
			document.getElementById('idpassword').value = "****";
		}
	}
	
function submitLogin(f,t,x)
	{ 	
		var ms = "Estos datos son requeridos";
	 	var lg = document.getElementById('id'+x+'login').value;
		var pw = document.getElementById('id'+x+'password').value;
		if(lg && pw && lg!="email" && pw!="****"){
			xajax_processFormLogin(xajax.getFormValues(f),t,x);
		}else{
			alert(ms);
		}
		
	}
function validarFormEncuesta()
	{ 	
		var en ="";
	  	var cs = document.getElementById("idformencuesta").elements.length;
		var c = 0;
		var id = 0;
		var td = document.getElementById("idTabla").value;
		for (var i = 0; i < cs; i++) {
	       if (document.getElementById("idformencuesta").elements[i].checked==true){
		     id = document.getElementById("idformencuesta").elements[i].value;
			 c = 1; 
		   }
         }
		if (c == 0){
		  en = "<font color=red>Debe seleccionar una respuesta</font>";
		}else{
 		  xajax_processFormEncuesta(td,id);
		}
		document.getElementById('msnencuesta').innerHTML = en;
	}
function viewImagen(i,d,t,n){ 
		document.getElementById('idimagen'+d).src = "redimensionar.php?imagen="+i+"&cap="+t+"&tmn=400";
		document.getElementById('idnameimagen'+d).innerHTML = n;
		//document.getElementById('idHimagen'+d).style.height = '390px';
}

function validateDate(fld) {
    var RegExPattern = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;
    var errorMessage = 'Please enter valid date as month, day, and four digit year.\nYou may use a slash, hyphen or period to separate the values.\nThe date must be a real date. 2-30-2000 would not be accepted.\nFormay mm/dd/yyyy.';
    if ((fld.value.match(RegExPattern)) && (fld.value!='')) {
        return true; 
    } else {
        alert(errorMessage);
        fld.focus();
    } 
}
