﻿function objOver(obj){obj.className=obj.className.replace('out','over');}
function objOut(obj){obj.className=obj.className.replace('over','out');}

function MM_openBrWindow(theURL,winName,features) {window.open(theURL,winName,features);}
function checkEmail(checkThisEmail){
//  return (strEmail.indexOf(".") > 2) && (strEmail.indexOf("@") > 0);
   //return /^\w+@([\w\-]+\.)+\w{2,3}$/.test(strEmail);
var myEMailIsValid = true;
var myAtSymbolAt = checkThisEmail.indexOf('@');
var myLastDotAt = checkThisEmail.lastIndexOf('.');
var mySpaceAt = checkThisEmail.indexOf(' ');
var myLength = checkThisEmail.length;
// at least one @ must be present and not before position 2
// @yellow.com : NOT valid
// x@yellow.com : VALID
if (myAtSymbolAt < 1 ){myEMailIsValid = false}
// at least one . (dot) afer the @ is required
// x@yellow : NOT valid
// x.y@yellow : NOT valid
// x@yellow.org : VALID
if (myLastDotAt < myAtSymbolAt){myEMailIsValid = false}
// at least two characters [com, uk, fr, ...] must occur after the last . (dot)
// x.y@yellow. : NOT valid
// x.y@yellow.a : NOT valid
// x.y@yellow.ca : VALID
if (myLength - myLastDotAt <= 2){myEMailIsValid = false}
// no empty space " " is permitted (one may trim the email)
// x.y@yell ow.com : NOT valid
if (mySpaceAt != -1){myEMailIsValid = false}
   return myEMailIsValid
}

String.prototype.trim = function(){
    // Use a regular expression to replace leading and trailing 
    // spaces with the empty string
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

function CheckFields_contact(obj,site_url){
	var doc=window.document;
	if (obj.FirstName.value==''){alert("אנא מלא/י שם פרטי "); obj.FirstName.focus(); return false;}
	if (obj.LastName.value==''){ alert("אנא מלא/י שדה שם משפחה "); obj.LastName.focus();return false;}
	if (obj.email.value==''){alert("אנא מלא/י שדה אימייל ");obj.email.focus();return false;}
    if (obj.email.value!=''  && !checkEmail(obj.email.value)){alert("כתובת דואר אלקטרוני לא חוקית");obj.email.select();return false;}
    return true;
}

function check_fields_subscription(site_url) {		
	if (document.getElementById('subscription_email').value == "" ){
	   alert("אנא מלא/י כתובת דואר אלקטרוני");
	   document.getElementById('subscription_email').focus();
	return false;}
    if (!checkEmail(document.getElementById('subscription_email').value)){
	   alert("כתובת דואר אלקטרוני לא חוקית");
	   document.getElementById('subscription_email').focus();
	return false;}
	window.document.subscriptionForm.action=site_url+"subscription/subscription_thanks.asp";
	window.document.subscriptionForm.submit();
	return false;					
}

function check_fields_unSubscription(site_url) {		
	if (document.getElementById('subscription_email').value == "" ){
	   alert("אנא מלא/י כתובת דואר אלקטרוני");
	   document.getElementById('subscription_email').focus();
	return false;}
    if (!checkEmail(document.getElementById('subscription_email').value)){
	   alert("כתובת דואר אלקטרוני לא חוקית")
	   document.getElementById('subscription_email').focus();
	return false;}
	if (confirm("?האם ברצונך להסיר את האימייל ")){
	    window.document.subscriptionForm.action=site_url+"subscription/unSubscription.asp";
	    window.document.subscriptionForm.submit();
	}
	return false;					
}