

document.writeln('<div id="leadCaptureWidgetDisplayId" name="leadCaptureWidgetDisplayId" > </div>');
document.writeln('<script type="text/javascript" src="http://itrack.myshaklee.com/esuite/javascript/codec.js"></script>');
var language="en";
leadCapture=function() {  
      
    var action=arguments[0];           
	// setting parameters	
	
	var parameters='userid='+sponsors_user_id;	
	try{
	parameters+='&for_site='+for_site;	
	}catch(err){} 
	try{
	parameters+='&notification='+encodeBase64(sponsor_notification);	
	}catch(err){}
	parameters+='&action='+action;	
	parameters+='&remote_domain='+encodeBase64(document.domain);	
	parameters+='&user_choice_bg_color='+encodeBase64(user_choice_bg_color);
	parameters+='&user_choice_size='+encodeBase64(user_choice_size);	
	parameters+='&user_lead_type='+encodeBase64(user_lead_type);	
	parameters+='&user_choice_skin='+encodeBase64(user_choice_skin);
	try{
	parameters+='&user_choice_language='+encodeBase64(user_choice_language);
	language=user_choice_language;
	}catch(err){} 
	
	if('save'==action){	 
	
	
	
	    if(!validate()){
	    document.getElementById("ilcBtn").disabled=false;
	    return false;
	    }
	    parameters+='&ilcElement10='+document.getElementById("ilcElement10").value;
	    parameters+='&ilcElement11='+document.getElementById("ilcElement11").value;
		for(var i=1;i<=9;i++){
		var ilcElementId="ilcElement"+i;
	    var ilcElement=document.getElementById(ilcElementId);
		parameters+='&'+ilcElement.name+'='+encodeBase64(ilcElement.value);		
		}	
				
	} 
	
  
    scriptx=document.createElement("script");    
    scriptx.type= "text/javascript";
	var url='http://itrack.myshaklee.com/esuite/control/drb/servlet/leadCaptureWidget?'+parameters;
	scriptx.src= url;	
    document.getElementById("leadCaptureWidgetDisplayId").appendChild(scriptx);	
   
    	
}

 



displayTimeToCall=function(){
 if(document.getElementById("ilcElement7").selectedIndex==2){   
 document.getElementById("btc").style.display='';
 document.getElementById("btc1").style.display='';
 document.getElementById("btc2").style.display='inline';
 }
 else{
 document.getElementById("btc").style.display='none';
 document.getElementById("btc1").style.display='none';
 document.getElementById("btc2").style.display='none';
 document.getElementById("ilcElement8").selectedIndex=0;
 }
 }

validate=function(){      
        if("es"==language){
		        if(document.getElementById("ilcElement1").value==''){
			    alert('Debes ingresar tu nombre');
			    return false;
			    }
			    if(document.getElementById("ilcElement2").value==''){
			    alert('Debes ingresar tu apellido');
			    return false;
			    }
			    if(document.getElementById("ilcElement3").value==''){
			    alert('Debes ingresar tu correo electrónico');
			    return false;
			    }
			    else{	
			     if(!validEmail(document.getElementById("ilcElement3").value)){
			      alert('Tu correo electrónico contiene caracteres erróneos');      
			       return false;
			       }
			    }
			    if(document.getElementById("ilcElement7").selectedIndex==2 && document.getElementById("ilcElement5").value==''){
			    alert('Ingresa tu teléfono o elige otra manera de contactarte que no sea teléfono');
			    return false;
			    }
			    if(document.getElementById("ilcElement9").value.length>1000){
			    alert('Por favor no ingreses más de 1000 caracteres');	    
			    return false;
			    }
			    if(!document.getElementById("ilcElement4").value=='' && !validName(document.getElementById("ilcElement4").value)){
		        alert('Tu país contiene caracteres erróneos');	 
		        return false;	     
			    }
			    if(!document.getElementById("ilcElement5").value=='' && !validPhone(document.getElementById("ilcElement5").value)){
			     alert("El teléfono tiene caracteres erróneos");	     
			     return false;	    	   
			    }
			    
	    }
	    else{
	    
			     if(document.getElementById("ilcElement1").value==''){
			    alert('First Name cannot be empty');
			    return false;
			    }else if(!validName(document.getElementById("ilcElement1").value)){
			       alert('First Name contains illegal characters.');
			       return false;
			    }
			    if(document.getElementById("ilcElement2").value==''){
			    alert('Last Name cannot be empty');
			    return false;
			    }else if(!validName(document.getElementById("ilcElement2").value)){
			       alert('Last Name contains illegal characters.');
			       return false;
			    }
			    if(document.getElementById("ilcElement3").value==''){
			    alert('Your email cannot be empty');
			    return false;
			    }
			    else{	
			     if(!validEmail(document.getElementById("ilcElement3").value)){
			      alert('Your email contains illegal characters.');      
			       return false;
			       }
			    }
			    if(document.getElementById("ilcElement7").selectedIndex==2 && document.getElementById("ilcElement5").value==''){
			    alert('Daytime Phone cannot be empty \n                     (or) \n Deselect phone as Best way to Contact');
			    return false;
			    }
			    if(document.getElementById("ilcElement9").value.length>1000){
			    alert('Please do not enter more than 1000 characters.');	    
			    return false;
			    }
			    if(!document.getElementById("ilcElement4").value=='' && !validName(document.getElementById("ilcElement4").value)){
		        alert('Country contains illegal characters.');	 
		        return false;	     
			    }
			    if(!document.getElementById("ilcElement5").value=='' && !validPhone(document.getElementById("ilcElement5").value)){
			     alert("The Daytime Phone contains illegal characters.");	     
			     return false;	    	   
			    }
			     if(!document.getElementById("ilcElement6").value=='' && !validPhone(document.getElementById("ilcElement6").value)){
		        alert("The Evening Phone contains illegal characters.");
		        return false;
			    }
	    }
        return true;	  
}
function validPhone(phone){
	var stripped = phone.replace(/[\(\)\.\-\ ]/g, '');		
	if (isNaN(parseInt(stripped))) {		  
	   return false;
	}
    return true;
}
function validName(name){
	var regex=/[^a-zA-Z]/;
	if(regex.test(name)){
	return false;
	}
	return true;
}
function validEmail(strng){
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z0-9]{2,6}(?:\.[a-z0-9]{2})?)$/i;
		if (!filter.test(strng)){
		return false;
		}
	return true;
}

function temp(){
var loaded=true;
try{
encodeBase64("test");
}
catch(e){
loaded=false;
}
if(document.getElementById("leadCaptureWidgetDisplayId")!=null && loaded){
leadCapture('view');
return;
}
setTimeout("temp()",1000);
}
temp();


