  function rot13(s) {
    var n = '';
    for (i = 0; i < s.length; i++) {
      ch = s.charCodeAt(i);
      if ( ((ch>64) && (ch<78)) || ((ch>96) && (ch<110)) ) {
        ch += 13;
      } else
      if ( ((ch>77) && (ch<91)) || ((ch>109) && (ch<123)) ) { 
        ch -= 13;
      }
      if (ch == 124) {
        n = n.concat ("\n");
      } else {
        n = n.concat (String.fromCharCode(ch));
      }
    }
    return (n);
  }


  function email(emailaddress, subject) {
    var realaddress = rot13(emailaddress);
    return("<a href='mailto:"+realaddress+"?subject="+subject+"'>"+realaddress+"</a>");
  }

  function process(cDiv, cUrl){
        var divId = cDiv; var url = cUrl; var loader = '<p>Cargando....</p>';  var effect = 'appear'; var ecache = false;     
        $ajaxload(cDiv, cUrl, loader, effect, ecache);
  }

  function CargarServicios() {
  	process('ListaServicios', 'apiajax.asp?op=CargaServicios&ref='+document.getElementById('CmbTipoServicio').value+'&ran=' + Math.random())
  }

  function ValCpn() {
  	process('InfoCupon', 'apiajax.asp?op=ValCpn&ref='+document.step2.Cupon.value+'&cServ=' +document.step2._i.value+'&ran=' + Math.random())
  }

  function GetDatosClientes() {
  	process('InfoDatosClientes', 'apiajax.asp?op=GetDatosClientes&eu='+document.getElementById('EmailUsuario').value+'&pu='+document.getElementById('PasswordUsuario').value+'&ran=' + Math.random())
  }

  function SetupPlan(cIdPlan) {
	process('Carrito', 'apiajax.asp?op=SetupPlan&ref='+cIdPlan+'&ran=' + Math.random())
  }
  
  function AddDomainToPlan() {
	var elementos = document.getElementsByName("domainoption");
	var cOpcionDominio = '';
 
	for(var i=0; i<elementos.length; i++) {	if (elementos[i].checked) {	cOpcionDominio = elementos[i].value; } }

    if (ValidaDominio()){
	  	process('Carrito', 'apiajax.asp?op=ShowOpcionProd&domain='+ document.getElementById('Dominio').value + '.'+ document.getElementById('DominioTld').value + '&OpcionDominio=' + cOpcionDominio + '&ran=' + Math.random())
  	}  		
  }
  
  
  function ValidarDatosCliente(){
  if (document.form1.Nombres.value=="") {
    alert("Usted debe ingresar su Nombre");
    document.form1.Nombres.focus(); }
   else
      if (document.form1.Apellidos.value=="") {
         alert("Usted debe ingresar sus Apellidos");
         document.form1.Apellidos.focus(); }
      else
        if (document.form1.Pais.value=="") {
		    alert("Usted debe ingresar el País");
		    document.form1.Pais.focus(); }
		else
			if (document.form1.Estado.value=="") {
	               alert("Usted debe ingresar el estado o región");
	              document.form1.Estado.focus();   }
	         else
	            if (document.form1.Ciudad.value=="") {
	               alert("Usted debe ingresar una Ciudad");
	               document.form1.Ciudad.focus(); }
		         else
			         if (document.form1.Direccion.value=="") {
			            alert("Usted debe ingresar la dirección");
			            document.form1.Direccion.focus(); }
			         else
  if (document.form1.Telefono.value=="") {
    alert("Usted debe ingresar un número telefonico");
    document.form1.Telefono.focus();  }
  else
  if (document.form1.EmailPrincipal.value=="") {
    alert("Usted debe ingresar un dirección de email");
    document.form1.EmailPrincipal.focus();   }
  else
    document.form1.submit();
}

  function Domain(){ 
   var cEmail = "email@" + document.step1.Dominio.value + "." + document.step1.DominioTld.value
   
   if(cEmail == "email@"){
	   alert("Debe ingresar el dominio");
	   document.paso1.Dominio.focus()}
   else
     if (cEmail.search(/^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$/) == -1){
		alert("El dominio digitado es invalido");
                document.step1.Dominio.focus()}	
    else 
    document.step1.submit()
 }
  
  
  function ValidaDominio(){ 
   var cEmail = "email@" + document.getElementById('Dominio').value + '.'+ document.getElementById('DominioTld').value;
   //alert(cEmail);
   
   if(cEmail == "email@"){
	   alert("Debe ingresar el nombre del dominio");
	      		return false }
   else
     if (cEmail.search(/^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$/) == -1){
		alert("El dominio digitado es invalido");
                return false}	
    else 
    	return true;
 }
  

function openWindow(url,w,h,tb,stb,l,mb,sb,rs,x,y){
var pos=(document.layers)? ',screenX='+x+',screenY='+y: ',left='+x+',top='+y;
tb=(tb)?'yes':'no';
stb=(stb)?'yes':'no';
l=(l)?'yes':'no';
mb=(mb)?'yes':'no';
sb=(sb)?'yes':'no';
rs=(rs)?'yes':'no';
var txt='';
txt+='scrollbars='+sb;
txt+=',width='+w;
txt+=',height='+h;
txt+=',toolbar='+tb;
txt+=',status='+stb;
txt+=',menubar='+mb;
txt+=',links='+l;
txt+=',resizable='+rs;
var x=window.open(url, 'newWin'+new Date().getTime(), txt+pos);
x.focus();
}



//# url - The URL of the page to open. Example: "http://scriptasylum.com".
//# w - The width of the window in pixels.
//# h - The height of the window in pixels (doesn't include menubars).
//# tb - Toolbar visible? 1 = yes, 0 = no.
//# stb - Status bar visible? 1 = yes, 0 = no.
//# L - Linkbar visible? 1 = yes, 0 = no.
//# mb - Menubar visible? 1 = yes, 0 = no.
//# sb - Scrollbars visible? 1 = yes, 0 = no.
//# rs - Resizable window? 1 = yes, 0 = no.
//# x - The horizontal position of the window from the left of the screen.
//# y - The vertical position of the window from the top of the screen.