function IsEmpty(str) 
{ 
	while (str.substring(0,1) == ' ') str = str.substring(1);
	
	if (str.length > 0) 
		 return false; 
	else 
		return true; 
}
function validate_email(str)
{
	l = str.length;
	at=str.indexOf("@");
	lastdot = str.lastIndexOf(".");
	if (at < 1 || (lastdot > l-3) || (lastdot-at < 2)) 
	return false;
	
	return true;
}

var xmlHttp;


function ajaxForm1()
{
// Validate fields

  if (IsEmpty(form1.Email.value) || (!validate_email(form1.Email.value)))
	{
		alert("Please write a valid Email!");
		form1.Email.focus();
		return false;
	}
	
  if ( IsEmpty(document.form1.Name.value))
	{
		alert("Please write your Name");
		form1.Name.focus();
		return false;
	}	
	
  if ( IsEmpty(document.form1.Zip.value))
	{
		alert("Please write your Zip");
		form1.Zip.focus();
		return false;
	}	
  if ( IsEmpty(document.form1.security_code.value))
	{
		alert("Please write Security code");
		form1.security_code.focus();
		return false;
	}			

	document.form1.Submit.disabled=true;
  
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
 	xmlHttp.onreadystatechange = alertContents;
    xmlHttp.open("GET","http://www.wendystkitts.com/contact.php?Form=EMAIL_LIST&Email="+form1.Email.value+"&Name="+form1.Name.value+"&Country="+form1.Country[form1.Country.options.selectedIndex].value+"&Zip="+form1.Zip.value+"&security_code="+form1.security_code.value,true);
    xmlHttp.send(null);


		
	return false;
  }

   function alertContents() {
      if (xmlHttp.readyState == 4) {
         if (xmlHttp.status == 200) {
            if(xmlHttp.responseText == '')
			{
			
			if (document.getElementById)
        	{
                document.getElementById('news').style.display = 'none';
				document.getElementById('thanks').style.display = 'block';
        	}
        	else if (document.all)
        	{
                document.all['news'].style.display = 'none';
				document.all['thanks'].style.display = 'block';
       		}
			
			}
			else
			{
				alert(xmlHttp.responseText);
				document.form1.Submit.disabled=false;
			}
			
         } else {
            alert('There was a problem with the request.');
         }
      }
   }  
   
   
   function ShowPage(ID)
   {
		$(""+'#content'+"").load("index.php?page_id="+ID+"");
   }
  
