

function loadMailingList(value, IDEE,checkedCheckboxes,page) //loadMailingList(this.value,'mailList','checkedCheckboxes','email')
{
	  jQuery.ajax({
              type: "GET",
			  url: "includes/Ajax/mailingList.php?email="+value+"&page="+page+"&checked="+checkedCheckboxes,
			  
            success: function(str)
			{
              if( trim(str).charAt(0) == 1)
			  {
				
				if(page =="rsvp" && document.getElementById("ss_account_pane")  != null )
					{
						writeHTML("ss_account_pane","<p></p>");
					}
					if( document.getElementById("ss_password_pane")  != null  )
					{
						document.getElementById("ss_password_pane").style.display ="none"; 
					
					}
					if( document.getElementById("show")  != null  )
					{
						document.getElementById("show").value ="0"; 
					
					}
					
				writeHTML("emailNotes"," Please proceed, we found your record <br>&nbsp;");
			   	
				var result = str.split("##########");
				if(result.length >=3)
				{
					var top = result[1].split("|");
					
					for(i =0; i < top.length; i++)
					{
						var pair = top[i].split("=");
						var id = pair[0];
						var value = pair[1];
                        if(id.indexOf("addr1")>=0 && id.indexOf("location")>=0 )
                        {
                            id = "street1_"+value;
                            value = value.toLowerCase();
                            
                        }
                        else if(id.indexOf("phone")>=0 && id.indexOf("location")>=0)
                        {
                            id = "phonet_"+value;
                             value = value.toLowerCase();
                        }
						if( jQuery("#"+id) != null)
						{
							 fillIt(id,value);
							 
						}
					}
					
					if(result[2] != null)
					{
						writeHTML(IDEE,result[2]);
					}
				}
				
				// fill itin 
				// give a success msg
			  }
			  else
			  {
				 writeHTML("emailNotes","Sorry, we did not find any record matching that email address ");
				if( document.getElementById("ss_password_pane")  != null  )
				{
					document.getElementById("ss_password_pane").style.display ="none"; 
					
				}
				if( document.getElementById("show")  != null  )
					{
						document.getElementById("show").value ="1"; 
					
					}	
				if(page =="rsvp" && document.getElementById("ss_account_pane")  != null )
				{
					writeHTML("ss_account_pane","<p><strong>Would you like to create an Atlas Signature Select account?</strong><input type=\"radio\" onclick='checkCreatePass(\"ss_account_yes\")'   value=\"yes\" name=\"ss_account\" id=\"ss_account_yes\"/>Yes <input type=\"radio\" onclick='checkCreatePass(\"ss_account_no\")' value=\"no\" name=\"ss_account\" id=\"ss_account_no\"/>No </p>");
				}
				
				  
			  }
            }
        });
	
	
}

function fillIt(id,value)
{
	 var dom = document.getElementById(id);
	 
	 if(dom != null)
	 {
		
		var type = dom.type.toUpperCase();
		
		if( type != "RADIO")
		{
			try
			{
				jQuery("#"+id).val(value);
				if(type =="SELECT-ONE")
				{
					
					if(dom.value != value)
					{
						var tryOther = id+"_other";
						
						if(document.getElementById(tryOther) != null )
						{
							jQuery("#"+id).val("Other");
							if(id == "best_describes")
							{
								checkBestDescribes();
							}
							jQuery("#"+tryOther).val(value);
							 
						
						}
						else if( id == "state")
						{
							
							
							jQuery("#otherregion").val(value);
						}
					}
				}
			}
			catch(error)
			{
				
			}
		}
		else 
		{
			
			dom.checked = "checked";	
		}
	
	 }
	 
	 
	
}

function trim(str) {
	return ltrim(rtrim(str));
}
 
function ltrim(str ) {
	chars =  "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str ) {
	chars =   "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}


function writeHTML(id, msg)
{
	if(jQuery("#"+id) != null)
	{
		jQuery("#"+id).html(msg);
	}
	
}
				   