function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }  
return xmlHttp;
}

/* Trim Function */
function trim(value)
 {
  var temp = value;
  return temp.replace(/^\s*(\b.*\b|)\s*$/, "$1");
 }

/* validContactForm Function */
function validContactForm(form_id, div_id)
 {
  tmp="passForm=document.forms['"+form_id+"'];";
  eval(tmp);

  // Beginning of Regular Expressions Creating
  regular_email_address=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  // End of Regular Expressions Creating

  // Beginning of Full Name Checking
  temp=trim(passForm.full_name.value);
  passForm.full_name.value=temp;
  if (temp=="")
     {
      alert("אנא רשמו שם.");
      passForm.full_name.focus();
      return false;
     }
  // End of Full Name Checking

  // Beginning of E-mail Address Checking
  temp=trim(passForm.email_address.value);
  passForm.email_address.value=temp;
  if (!(regular_email_address.test(temp)))
     {
      alert("אנא רשמו כתובת E-mail תקינה.");
      passForm.email_address.focus();
      return false;
     }
  // End of E-mail Address Checking
  
  // Beginning of Contact Purpose Checking
  temp=trim(passForm.contact_purpose.value);
  passForm.contact_purpose.value=temp;
  if (temp=="")
     {
      alert("אנא בחרו בסוג הפנייה.");
      passForm.contact_purpose.focus();
      return false;
     }
  // End of Contact Purpose Checking

  // Beginning of Message Content Checking
  temp=trim(passForm.message_content.value);
  passForm.message_content.value=temp;
  if ((temp=="") && (passForm.contact_purpose.value!="1"))
     {
      alert("אנא רשמו תוכן.");
      passForm.message_content.focus();
      return false;
     }
  // End of Message Content Checking
  
  // Beginning of Terms Checking
   o1=document.getElementById('terms').checked;
   if (o1==false)
      {
       alert("עליך לאשר את תנאי השימוש באתר.");
	return false;
      }
   // End of Terms Checking

  send_mail_procedure(form_id, div_id);
  return false;
 }
 
function stateChange() 
  { 
   if (xmlHttp.readyState==4)
      {
	//document.getElementById('field2_links').innerHTML=xmlHttp.responseText;
      }
  }

function send_mail_procedure(form_id, div_id)
  {
   tmp="passForm=document.forms['"+form_id+"'];";
   eval(tmp);

   full_name=passForm.full_name.value;
   contact_purpose=passForm.contact_purpose.value;
   email_address=passForm.email_address.value;
   message_content=passForm.message_content.value;
   
   xmlHttp=GetXmlHttpObject();
   if (xmlHttp==null)
      {
       alert("Your browser does not support AJAX!");
       return;
      }
  
   var url="send_mail_procedure.php";
   var params="full_name="+full_name+"&contact_purpose="+contact_purpose+"&email_address="+email_address+"&message_content="+message_content;
  
   xmlHttp.open("POST", url, true);
   //Send the proper header information along with the request
   xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   xmlHttp.setRequestHeader("Content-length", params.length);
   xmlHttp.setRequestHeader("Connection", "close");
   xmlHttp.onreadystatechange = stateChange;
   xmlHttp.send(params);

   str ="document.getElementById('"+div_id+"').innerHTML='<div style=\"font-size: 13px\">פנייתך נשלחה בהצלחה.<br />המשך גלישה נעימה.";
   if (div_id=="contact_form_popup") { str+="<p /><a href=\"javascript:parent.parent.GB_hide();\" class=\"greybox_links\">חזרה לאתר</a>"; }
   str+="</div>';";
   eval(str);
  }

/* validForumReplyForm Function */
function validForumReplyForm(form_id)
  {
   tmp="passForm=document.forms['"+form_id+"'];";
   eval(tmp);
   
   // Beginning of Regular Expressions Creating
  regular_email_address=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  // End of Regular Expressions Creating

   // Beginning of Nickname Checking
   temp=trim(passForm.nickname.value);
   passForm.nickname.value=temp;
   if (temp=="")
      {
	alert("אנא בחרו כינוי לזיהוי בפורום.");
	passForm.nickname.focus();
	return false;
      }
   // End of Nickname Checking
   
   // Beginning of E-mail Checking
   temp=trim(passForm.email_address.value);
   passForm.email_address.value=temp;
   if (!(regular_email_address.test(temp)))
      {
       alert("אנא רשמו כתובת דואר אלקטרוני בצורה תקינה.");
	passForm.email_address.focus();
	return false;
      }
   // End of E-mail Checking

   // Beginning of Subject Checking
   temp=trim(passForm.subject.value);
   passForm.subject.value=temp;
   if (temp=="")
      {
	alert("אנא רשמו את כותרת ההודעה.");
	passForm.subject.focus();
	return false;
      }
   // End of Subject Checking
   
   // Beginning of Captcha Checking
   temp=trim(passForm.captcha_code.value);
   passForm.captcha_code.value=temp;
   if (temp=="")
      {
	alert("אנא רשמו את רצף התווים המופיע בתמונה.");
	passForm.captcha_code.focus();
	return false;
      }
   // End of Captcha Checking
   
   // Beginning of Terms Checking
   o1=document.getElementById('terms').checked;
   if (o1==false)
      {
       alert("עליך לאשר את תנאי השימוש באתר.");
	return false;
      }
   // End of Terms Checking
   return true;
  }
  
/* validTestForm Function */
function validTestForm(form_id)
 {
  tmp="passForm=document.forms['"+form_id+"'];";
  eval(tmp);
  
  options_sum=passForm.total_options.value;
  one_selection=false;
  
  for (i=1; i<=options_sum; i++)
      {
       exp="sel=passForm.selection"+i+".checked;";
	eval(exp);
	
	if (sel==true) { one_selection=true; }
      }
      
  if (one_selection==false)
     {
      alert("אנא בחרו באפשרות אחת בלבד.");
      return false;
     }

  return true;
 }
 
function send_test_result(form_id, option_id)
 {
  tmp="passForm=document.forms['"+form_id+"'];";
  eval(tmp);

  test_type=passForm.test_type.value;
  symbol_id=passForm.symbol_id.value;
  
   xmlHttp=GetXmlHttpObject();
   if (xmlHttp==null)
      {
       alert("Your browser does not support AJAX!");
       return;
      }
  
   var url="add_test_result.php";
   var params="test_type="+test_type+"&symbol_id="+symbol_id+"&option_id="+option_id;
  
   xmlHttp.open("POST", url, true);
   //Send the proper header information along with the request
   xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   xmlHttp.setRequestHeader("Content-length", params.length);
   xmlHttp.setRequestHeader("Connection", "close");
   xmlHttp.onreadystatechange = stateChange;
   xmlHttp.send(params);
 }
 
function change_preview_img(option_img)
 {
  if (option_img!="0")
     { document.getElementById('preview_img').innerHTML="<img src='"+option_img+"' alt='' />"; }
  else
     { document.getElementById('preview_img').innerHTML=""; }
 }
 
/* validRegistrationForm Function */
function validRegistrationForm(form_id)
 {
  tmp="passForm=document.forms['"+form_id+"'];";
  eval(tmp);

  // Beginning of Regular Expressions Creating
  regular_email_address=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  // End of Regular Expressions Creating

  // Beginning of E-mail Address Checking
  temp=trim(passForm.email_address.value);
  passForm.email_address.value=temp;
  if (!(regular_email_address.test(temp)))
     {
      alert("אנא רשמו כתובת E-mail תקינה.");
      passForm.email_address.focus();
      return false;
     }
  // End of E-mail Address Checking
  
  // Beginning of Password Checking
  temp=trim(passForm.password.value);
  passForm.password.value=temp;
  if (temp=="")
     {
      alert("אנא בחרו סיסמה.");
      passForm.password.focus();
      return false;
     }
  // End of Password Checking

  // Beginning of First Name Checking
  temp=trim(passForm.first_name.value);
  passForm.first_name.value=temp;
  if (temp=="")
     {
      alert("אנא מלאו שם פרטי.");
      passForm.first_name.focus();
      return false;
     }
  // End of First Name Checking
  
  // Beginning of Last Name Checking
  temp=trim(passForm.last_name.value);
  passForm.last_name.value=temp;
  if (temp=="")
     {
      alert("אנא מלאו שם משפחה.");
      passForm.last_name.focus();
      return false;
     }
  // End of Last Name Checking
  
  // Beginning of License Agree Checking
   o=document.getElementById('license_agree').checked;
   if (o==false)
      {
       alert("עליך לאשר את תנאי השימוש באתר.");
	return false;
      }
   // End of License Agree Checking
   return true;
  }

/* validLoginForm Function */
function validLoginForm(form_id)
 {
  tmp="passForm=document.forms['"+form_id+"'];";
  eval(tmp);

  // Beginning of Regular Expressions Creating
  regular_email_address=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  // End of Regular Expressions Creating

  // Beginning of E-mail Address Checking
  temp=trim(passForm.email_address.value);
  passForm.email_address.value=temp;
  if (!(regular_email_address.test(temp)))
     {
      alert("אנא רשמו כתובת E-mail תקינה.");
      passForm.email_address.focus();
      return false;
     }
  // End of E-mail Address Checking
  
  // Beginning of Password Checking
  temp=trim(passForm.password.value);
  passForm.password.value=temp;
  if (temp=="")
     {
      alert("אנא בחרו סיסמה.");
      passForm.password.focus();
      return false;
     }
  // End of Password Checking
   return true;
  }
  
/* validPasswordRestoreForm Function */
function validPasswordRestoreForm(form_id)
 {
  tmp="passForm=document.forms['"+form_id+"'];";
  eval(tmp);

  // Beginning of Regular Expressions Creating
  regular_email_address=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  // End of Regular Expressions Creating

  // Beginning of E-mail Address Checking
  temp=trim(passForm.email_address.value);
  passForm.email_address.value=temp;
  if (!(regular_email_address.test(temp)))
     {
      alert("אנא רשמו כתובת E-mail תקינה.");
      passForm.email_address.focus();
      return false;
     }
  // End of E-mail Address Checking
   return true;
  }
  
/* validSendFriendForm Function */
function validSendFriendForm(form_id)
 {
  tmp="passForm=document.forms['"+form_id+"'];";
  eval(tmp);

  // Beginning of Regular Expressions Creating
  regular_email_address=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  // End of Regular Expressions Creating

  // Beginning of My Name Checking
  temp=trim(passForm.my_name.value);
  passForm.my_name.value=temp;
  if (temp=="")
     {
      alert("אנא רשמו את שמכם.");
      passForm.my_name.focus();
      return false;
     }
  // End of My Name Checking
  
  // Beginning of Friend Name Checking
  temp=trim(passForm.friend_name.value);
  passForm.friend_name.value=temp;
  if (temp=="")
     {
      alert("אנא רשמו את שם חברכם.");
      passForm.friend_name.focus();
      return false;
     }
  // End of Friend Name Checking

  // Beginning of My E-mail Address Checking
  temp=trim(passForm.my_email_address.value);
  passForm.my_email_address.value=temp;
  if (!(regular_email_address.test(temp)))
     {
      alert("אנא רשמו את כתובת המייל שלכם בצורה תקינה.");
      passForm.my_email_address.focus();
      return false;
     }
  // End of My E-mail Address Checking
  
  // Beginning of Friend E-mail Address Checking
  temp=trim(passForm.friend_email_address.value);
  passForm.friend_email_address.value=temp;
  if (!(regular_email_address.test(temp)))
     {
      alert("אנא רשמו את כתובת המייל של חברכם בצורה תקינה.");
      passForm.friend_email_address.focus();
      return false;
     }
  // End of Friend E-mail Address Checking
  
  // Beginning of Terms Checking
   o1=document.getElementById('terms').checked;
   if (o1==false)
      {
       alert("עליך לאשר את תנאי השימוש באתר.");
	return false;
      }
   // End of Terms Checking
  return true;
 }
 
// Graphologia
function graphologia()
 {
  window.open('http://גרפולוגיה.net');
 }
