﻿function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}
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.name.value==''){alert("אנא מלא/י שם פרטי "); obj.name.focus(); return false;}
	//if (obj.last_name.value==''){ alert("אנא מלא/י שדה שם משפחה "); obj.last_name.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;}
    if (obj.content.value==''){alert("אנא מלא/י  הערות "); obj.content.focus(); return false;}
    if (obj.captchacode.value==''){alert("אנא מלא/י  אימות מילה ");obj.captchacode.focus();return false;}
    return true;
}

function CheckFields_press(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.city.value==''){ alert("אנא מלא/י אזור בארץ "); obj.city.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;					
}

function SetFontSize(elm, size)
{
    document.getElementById(elm).style.fontSize = size;
    return ;
}


function printContent(site_url,printTitle){
	var thisdoc=document;
	var txt="";
	var strdoc=new String("");
	document.body.style.cursor = "wait";
	win = window.open("","_blank","height=650,width=500,top=100,left=50,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes");
	var doc = win.document;
	doc.open();
	strdoc="<html><title>למען - "+printTitle+"</title>"
	strdoc= strdoc + "<head><link href='"+site_url+"include/style.css' type='text/css' rel='stylesheet'></head>"
	strdoc= strdoc + "<body onload=\"window.print();window.close();\" style=\"background-color:#ffffff\">"
	strdoc= strdoc + "<table width=\"519\"><tr><td><img src='"+site_url+"images/top_print.gif' width=\"519\" height=\"100\" border=\"0\"></td></tr><tr><td>"
	strdoc= strdoc + "<font size=\""+eval(fontSize+1)+"\">"+contentText.innerHTML+"</font>";
	strdoc= strdoc + "</td></tr>" 
	strdoc= strdoc + "</body></html>" 
	doc.write(strdoc);
	doc.close();
	document.body.style.cursor = "default";
	return false;
}
