﻿//*************************************************************************************
// trim - this function deletes spaces around the string.
//*************************************************************************************
String.prototype.trim = function()
{
    // Use a regular expression to replace leading and trailing 
    // spaces with the empty string
    return this.replace(/(^\s*)|(\s*$)/g, "");
}


//return false if email is not valid ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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

}

function emptyField(textObj){
	if (textObj.value.length == 0) return true;
	for (var i=0; i<textObj.value.length; i++) {
		var ch = textObj.value.charAt(i);
		if (ch != ' ' && ch != '\t') return false;	
	}
	return true;	
}

function LoadIMG(siteUrl){
    document.getElementById('captcha_numchar').src=siteUrl+'global/captcha.asp?'+Date();
}

function addbookmark(){
var url="http://www.zimerdeal.co.il";
var title="zimerdeal -  צימר דיל - דילים ומבצעים יחודיים לפורטל צימר דיל";
if (window.sidebar) { // firefox
   //alert('firefox');
   window.sidebar.addPanel(title, url,"");
}else if(window.opera && window.print){ // opera
   var elem = document.createElement('a');
   elem.setAttribute('href',url);
   elem.setAttribute('title',title);
   elem.setAttribute('rel','sidebar');
   elem.click();
}else if(document.all)// ie
   window.external.AddFavorite(url, title);
}
var contactUs_toCustomer
function onclick_contactUs_toCustomer(strFile){contactUs_toCustomer=window.open(strFile,'contactUs_toCustomer','width=780,height=591, left=100,top=0,screenX=0,screenY=0,outerwidth=500,outerheight=230,resizable=0,status=0,toolbar=0,scrollbars=0');return false;}
var window_vacants
function onclick_vacants(strFile){window_vacants=window.open(strFile,'window_vacants','width=780,height=290, left=100,top=0,screenX=0,screenY=0,outerwidth=500,outerheight=230,resizable=0,status=0,toolbar=0,scrollbars=0');return false;}
function MM_openBrWindow(theURL,winName,features){window.open(theURL,winName,features);}
function checkSearch(obj){
  if(obj.keySearch.value.trim() == ""){
 	 alert('חובה למלא שדה לחיפוש');
 	 obj.keySearch.focus();
 	 return false;
  } 	
}