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");
 }

function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

/* Input Emphasis Function */
function input_emphasis(cell)
 {
  var emphasis="document.all."+cell+".style.backgroundColor='#ffffff'";
  eval(emphasis);
  return true;
 }

/* validContactForm Function */
function validContactForm(form_id, div_id)
 {
  tmp="passForm=document.forms['"+form_id+"'];";
  eval(tmp);

  // Beginning of Regular Expressions Creating
  regular_phones=/^([0-9\-\+]{9,})$/;
  regular_email_address=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  regular_url=/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
  // 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 Phone Number Checking
  temp=trim(passForm.phone_number.value);
  passForm.phone_number.value=temp;
  if (!(regular_phones.test(temp)))
     {
      alert("אנא מלאו את מספר הטלפון שלכם בספרות, קווים מפרידים וסימני + בלבד.");
      passForm.phone_number.focus();
      return false;
     }
  // End of Phone Number 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("אנא מלאו כתובת דואר אלקטרוני תקינה.");
      passForm.email_address.focus();
      return false;
     }
  */
  // End of E-mail Address Checking

  // Beginning of Company Name Checking
  temp=trim(passForm.company_name.value);
  passForm.company_name.value=temp;
  /*
  if (temp=="")
     {
      alert("אנא רשמו את שם החברה/הארגון שאליו אתם משתייכים.");
      passForm.company_name.focus();
      return false;
     }
  */
  // End of Company Name Checking

  // Beginning of Web URL Checking
  temp=trim(passForm.web_url.value);
  passForm.web_url.value=temp;
  if (temp!="")
     {
      if (!(regular_url.test(temp)))
	  {
	   alert("אנא מלאו את כתובת אתרכם הקיים בתבנית חוקית.");
	   passForm.web_url.focus();
	   return false;
	  }
     }
  // End of Web URL Checking

  // Beginning of Message Content Checking
  temp=trim(passForm.message_content.value);
  passForm.message_content.value=temp;
  /*
  if (temp=="")
     {
      alert("אנא רשמו את תוכן המסר.");
      passForm.message_content.focus();
      return false;
     }
  */
  // End of Message Content 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;
   phone_number=passForm.phone_number.value;
   email_address=passForm.email_address.value;
   company_name=passForm.company_name.value;
   web_url=passForm.web_url.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+"&phone_number="+phone_number+"&email_address="+email_address+"&company_name="+company_name+"&web_url="+web_url+"&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='<p style=\"margin-top: 50px; font-size: 13px\">פנייתך נשלחה בהצלחה.<br />נציגנו יצרו איתך קשר בתוך 24 שעות.<br />המשך גלישה נעימה.<br /><br /><a href=\"javascript: parent.parent.GB_hide()\">חזרה לאתר</a></p>';";
   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 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 Followup Checking
   o1=document.getElementById('followup').checked;
   if (o1==true)
      {
	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 Followup Checking
   return true;
  }
  
// ----------------------------------------------------------------------------------------------------

function ajaxFunction(form_id)
  {
   tmp="passForm=document.forms['"+form_id+"'];";
   eval(tmp);

   var fn = passForm.full_name.value;
   var pn = passForm.phone_number.value;
   var ad_id = passForm.ad_id.value;
   
   xmlHttp=GetXmlHttpObject();
   if (xmlHttp==null)
      {
       alert("Your browser does not support AJAX!");
       return;
      }
  
   var url="send_smart_application_procedure.php";
   var params="full_name="+fn+"&phone_number="+pn+"&ad_id="+ad_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 doSmartLoading(div_id)
  {
   if (BrowserDetect.browser=="Firefox")
      {
	exp1="document.getElementById('"+div_id+"').innerHTML='<div align=\"center\" style=\"margin-top: 13px; margin-bottom: 25px\"><img src=\"images/other/ajax-loader-bar.gif\" alt=\"\" width=\"128px\" height=\"15px\" /></div>';";
      }
   else if (BrowserDetect.browser=="Explorer")
      {
	exp1="document.getElementById('"+div_id+"').innerHTML='<div align=\"center\" style=\"margin-top: 14px; margin-bottom: 25px\"><img src=\"images/other/ajax-loader-bar.gif\" alt=\"\" width=\"128px\" height=\"15px\" /></div>';";
      }
   else
      {
	exp1="document.getElementById('"+div_id+"').innerHTML='<div align=\"center\" style=\"margin-top: 13px; margin-bottom: 25px\"><img src=\"images/other/ajax-loader-bar.gif\" alt=\"\" width=\"128px\" height=\"15px\" /></div>';";
      }

   eval(exp1);

   str ="intval=window.setInterval(\"updateTimer('"+div_id+"')\", 2000);";
   eval(str);
  }

function changeSmartForm(div_id)
  {
   if (BrowserDetect.browser=="Firefox")
      {
	html_code="<div align=\"center\" style=\"font-size: 17px; margin-top: 0px\">פרטיך נשלחו בהצלחה! נציגנו יצרו איתך קשר בהקדם.<br />האם כבר ראית את <a style=\"font-size: 17px\" href=\"תיק_עבודות\">תיק העבודות</a> שלנו?</div>";
      }
   else if (BrowserDetect.browser=="Explorer")
      {
       html_code="<div align=\"center\" style=\"font-size: 17px; margin-top: 0px\">פרטיך נשלחו בהצלחה! נציגנו יצרו איתך קשר בהקדם.<br />האם כבר ראית את <a style=\"font-size: 17px\" href=\"תיק_עבודות\">תיק העבודות</a> שלנו?</div>";
      }
   else
      {
       html_code="<div align=\"center\" style=\"font-size: 17px; margin-top: 0px\">פרטיך נשלחו בהצלחה! נציגנו יצרו איתך קשר בהקדם.<br />האם כבר ראית את <a style=\"font-size: 17px\" href=\"תיק_עבודות\">תיק העבודות</a> שלנו?</div>";
      }

   exp="document.getElementById('"+div_id+"').innerHTML='"+html_code+"';";
   eval(exp);
  }

sec=0;
function updateTimer(div_id)
  {
   sec++;

   if (sec==2)
      {
	sec=0;
	window.clearInterval(intval);
	changeSmartForm(div_id);
      }
  }
  
 /* validSmartContactForm Function */
function validSmartContactForm(form_id, button_id, div_id)
  {
   tmp="passForm=document.forms['"+form_id+"'];";
   eval(tmp);

   // Beginning of Regular Expressions Creating
   regular_hebrew=/^([^a-zA-Z0-9_]{1,})$/;
   regular_digits=/^([0-9]{1})$/;
   // 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;
      }

   exp ="Set_Cookie('web360_form[full_name]', '"+escape(temp)+"', 30, '/');";
   eval(exp);
   // End of Full Name Checking

   // Beginning of Phone Number Checking
   temp=trim(passForm.phone_number.value);
   passForm.phone_number.value=temp;

   if (temp.charAt(0)!="0")
	{
	 alert("הספרה הראשונה של מספר הטלפון מוכרחה להיות 0.");
	 passForm.phone_number.focus();
	 return false;
	}

   count_digits=0;
   for (i=0; i<=temp.length; i++)
	 {
	  if (regular_digits.test(temp.charAt(i)))
	     { count_digits++; }
	 }

   if (count_digits<9)
	{
	 alert("אנא רשמו את מספר הטלפון שלכם כולל קידומת ב-9 ספרות לפחות.");
	 passForm.phone_number.focus();
	 return false;
	}

   exp ="Set_Cookie('web360_form[phone_number]', '"+escape(temp)+"', 30, '/');";
   eval(exp);
   // End of Phone Number Checking

   ajaxFunction(form_id);
   doSmartLoading(div_id);
   return false;
  }
  
// ----------------------------------------------------------------------------------------------------

function ajaxFunctionRC(form_id)
  {
   tmp="passForm=document.forms['"+form_id+"'];";
   eval(tmp);

   var fn = passForm.full_name.value;
   var pn = passForm.phone_number.value;
   var email = passForm.email_address.value;
   var web_url = passForm.website.value;
   
   xmlHttp=GetXmlHttpObject();
   if (xmlHttp==null)
      {
       alert("Your browser does not support AJAX!");
       return;
      }
  
   var url="send_mail_procedure.php";
   var params="full_name="+fn+"&phone_number="+pn+"&email_address="+email+"&message_content="+web_url;
  
   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 doSmartLoadingRC(div_id)
  {
   if (BrowserDetect.browser=="Firefox")
      {
	exp1="document.getElementById('"+div_id+"').innerHTML='<div align=\"center\" style=\"margin-top: 13px; margin-bottom: 25px\"><img src=\"images/other/ajax-loader-bar.gif\" alt=\"\" width=\"128px\" height=\"15px\" /></div>';";
      }
   else if (BrowserDetect.browser=="Explorer")
      {
	exp1="document.getElementById('"+div_id+"').innerHTML='<div align=\"center\" style=\"margin-top: 14px; margin-bottom: 25px\"><img src=\"images/other/ajax-loader-bar.gif\" alt=\"\" width=\"128px\" height=\"15px\" /></div>';";
      }
   else
      {
	exp1="document.getElementById('"+div_id+"').innerHTML='<div align=\"center\" style=\"margin-top: 13px; margin-bottom: 25px\"><img src=\"images/other/ajax-loader-bar.gif\" alt=\"\" width=\"128px\" height=\"15px\" /></div>';";
      }

   eval(exp1);

   str ="intval=window.setInterval(\"updateTimerRC('"+div_id+"')\", 2000);";
   eval(str);
  }

function changeSmartFormRC(div_id)
  {
   if (BrowserDetect.browser=="Firefox")
      {
	html_code="<div align=\"center\" style=\"line-height: 150%; font-size: 13px; margin-top: 0px; color: #292828\">פרטיך נשלחו בהצלחה!<br />נציגנו יצרו איתך קשר בתוך 24 שעות.<br />האם כבר ראית את <a style=\"font-size: 13px\" href=\"תיק_עבודות\">תיק העבודות</a> שלנו?</div>";
      }
   else if (BrowserDetect.browser=="Explorer")
      {
       html_code="<div align=\"center\" style=\"line-height: 150%; font-size: 13px; margin-top: 0px; color: #292828\">פרטיך נשלחו בהצלחה!<br />נציגנו יצרו איתך קשר בתוך 24 שעות.<br />האם כבר ראית את <a style=\"font-size: 13px\" href=\"תיק_עבודות\">תיק העבודות</a> שלנו?</div>";
      }
   else
      {
       html_code="<div align=\"center\" style=\"line-height: 150%; font-size: 13px; margin-top: 0px; color: #292828\">פרטיך נשלחו בהצלחה!<br />נציגנו יצרו איתך קשר בתוך 24 שעות.<br />האם כבר ראית את <a style=\"font-size: 13px\" href=\"תיק_עבודות\">תיק העבודות</a> שלנו?</div>";
      }

   exp="document.getElementById('"+div_id+"').innerHTML='"+html_code+"';";
   eval(exp);
  }

sec=0;
function updateTimerRC(div_id)
  {
   sec++;

   if (sec==2)
      {
	sec=0;
	window.clearInterval(intval);
	changeSmartFormRC(div_id);
      }
  }
  
/* validRightContactForm Function */
function validRightContactForm(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})+$/;
   regular_digits=/^([0-9]{1})$/;
   // 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 Phone Number Checking
   temp=trim(passForm.phone_number.value);
   passForm.phone_number.value=temp;

   if (temp.charAt(0)!="0")
	{
	 alert("הספרה הראשונה של מספר הטלפון מוכרחה להיות 0.");
	 passForm.phone_number.focus();
	 return false;
	}

   count_digits=0;
   for (i=0; i<=temp.length; i++)
	 {
	  if (regular_digits.test(temp.charAt(i)))
	     { count_digits++; }
	 }

   if (count_digits<9)
	{
	 alert("אנא רשמו את מספר הטלפון שלכם כולל קידומת ב-9 ספרות לפחות.");
	 passForm.phone_number.focus();
	 return false;
	}
   // End of Phone Number Checking
   
   // Beginning of E-mail Address Checking
   temp=trim(passForm.email_address.value);
   passForm.email_address.value=temp;
   if (temp!="")
      {
	if (!(regular_email_address.test(temp)))
	   {
	    alert("אנא רשמו כתובת דואר אלקטרוני תקינה.");
	    passForm.email_address.focus();
	    return false;
          }
      }
   // End of E-mail Address Checking

   ajaxFunctionRC(form_id);
   doSmartLoadingRC(div_id);
   return false;
  }

/* website_redirect Function */
function website_redirect(link_url)
  {
   exp ="window.open('"+link_url+"');";
   eval(exp);
  }