function SwapImg(obj) {
  if (obj.src.indexOf("_On") != -1) obj.src = obj.src.replace("_On","_Off");
  else obj.src = obj.src.replace("_Off","_On");
}

function changecss(theClass,element,value) {
	//Last Updated on June 23, 2009
	//documentation for this script at
	//http://www.shawnolson.net/a/503/altering-css-class-attributes-with-javascript.html
	 var cssRules;

	 var added = false;
	 for (var S = 0; S < document.styleSheets.length; S++){

    if (document.styleSheets[S]['rules']) {
	  cssRules = 'rules';
	 } else if (document.styleSheets[S]['cssRules']) {
	  cssRules = 'cssRules';
	 } else {
	  //no rules found... browser unknown
	 }

	  for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
	   if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
	    if(document.styleSheets[S][cssRules][R].style[element]){
	    document.styleSheets[S][cssRules][R].style[element] = value;
	    added=true;
		break;
	    }
	   }
	  }
	  if(!added){
	  if(document.styleSheets[S].insertRule){
			  document.styleSheets[S].insertRule(theClass+' { '+element+': '+value+'; }',document.styleSheets[S][cssRules].length);
			} else if (document.styleSheets[S].addRule) {
				document.styleSheets[S].addRule(theClass,element+': '+value+';');
			}
	  }
	 }
	}
	
function changeSize(size) {
    cookieEmpty();
	cookieSave(size);
	changecss("#BodyDiv","font-size",size+"px");
	changecss("#BodyDiv table","font-size",size+"px");
	changecss("#BodyDiv a","font-size",size+"px");
	changecss(".text_blue","font-size",size+"px");
	changecss(".text_blue a","font-size",size+"px");
	changecss(".text_blue2","font-size",size+"px");
	changecss(".text_blue2 a","font-size",size+"px");
}

function cookieLoad() {
  var nameEQ = "size=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return "";
}

function cookieSave(value) {
  var date = new Date();
  date.setTime(date.getTime()+(7*24*60*60*1000));
  var expires = "; expires="+date.toGMTString();
  document.cookie = "size="+value+expires+"; path=/";
}

function cookieEmpty() {
  var date = new Date();
  date.setTime(date.getTime()+(-1*24*60*60*1000));
  var expires = "; expires="+date.toGMTString();
  document.cookie = "size="+expires+"; path=/";
}

function CheckForm(TheForm) {
  TheForm.Fullname.value=Trim(TheForm.Fullname.value);
  if (TheForm.Fullname.value == "") return RetFalse(TheForm.Fullname, "שגיאה: את חייבת להכניס שם מלא.");
  if (!(/^[A-Za-zא-ת\'\-\'_ ]+$/.test(TheForm.Fullname.value))) return RetFalse(TheForm.Fullname, "שגיאה: שם מלא אינו תקין.");
  TheForm.FriendFullname.value=Trim(TheForm.FriendFullname.value);
  if (TheForm.FriendFullname.value == "") return RetFalse(TheForm.FriendFullname, "שגיאה: את חייבת להכניס שם מלא של חברתך.");
  if (!(/^[A-Za-zא-ת\'\-\'_ ]+$/.test(TheForm.FriendFullname.value))) return RetFalse(TheForm.FriendFullname, "שגיאה: שם מלא של החברה אינו תקין.");
  TheForm.Email.value=Trim(TheForm.Email.value);
  if (TheForm.Email.value == "") return RetFalse(TheForm.Email, "שגיאה: את חייבת להכניס דואל.");
  if (TheForm.Email.value.indexOf("@") == -1) return RetFalse(TheForm.Email, "שגיאה: דואל אינו תקין.");
  TheForm.FriendEmail.value=Trim(TheForm.FriendEmail.value);
  if (TheForm.FriendEmail.value == "") return RetFalse(TheForm.FriendEmail, "שגיאה: את חייבת להכניס דואל של חברתך.");
  if (TheForm.FriendEmail.value.indexOf("@") == -1) return RetFalse(TheForm.FriendEmail, "שגיאה: דואל של חברתך אינו תקין.");
  return true;
}
function CheckQuery() {
	theForm = document.getElementById("QueryForm");
	if ((!document.getElementById("Q1T").checked && !document.getElementById("Q1F").checked) ||
		(!document.getElementById("Q2T").checked && !document.getElementById("Q2F").checked) ||
		(!document.getElementById("Q3T").checked && !document.getElementById("Q3F").checked) ||
		(!document.getElementById("Q4T").checked && !document.getElementById("Q4F").checked) ||
		(!document.getElementById("Q5T").checked && !document.getElementById("Q5F").checked) ||
		(!document.getElementById("Q6T").checked && !document.getElementById("Q6F").checked) ||
		(!document.getElementById("Q7T").checked && !document.getElementById("Q7F").checked) ||
		(!document.getElementById("Q8T").checked && !document.getElementById("Q8F").checked) ||
		(!document.getElementById("Q9T").checked && !document.getElementById("Q9F").checked)
		) {
			alert("שגיאה: לא מילאת אחת מהתשובות. אנא נסה שנית.");
			return;
		}
		ResCount = 0;
		if (document.getElementById("Q1T").checked) ResCount++;
		if (document.getElementById("Q2T").checked) ResCount++;
		if (document.getElementById("Q3T").checked) ResCount++;
		if (document.getElementById("Q4T").checked) ResCount++;
		if (document.getElementById("Q5T").checked) ResCount++;
		if (document.getElementById("Q6F").checked) ResCount++;
		if (document.getElementById("Q7F").checked) ResCount++;
		if (document.getElementById("Q8T").checked) ResCount++;
		if (document.getElementById("Q9T").checked) ResCount++;
		document.getElementById("ResNum").innerText = ResCount;
	document.getElementById("BodyDiv").style.display = "none";
	document.getElementById("QueryTable").style.display = "none";
	document.getElementById("QueryResultsTable").style.display = "block";
	document.getElementById("Q1Res").style.display = (document.getElementById("Q1F").checked?"none":"block");
	document.getElementById("Q2Res").style.display = (document.getElementById("Q2F").checked?"none":"block");
	document.getElementById("Q3Res").style.display = (document.getElementById("Q3F").checked?"none":"block");
	document.getElementById("Q4Res").style.display = (document.getElementById("Q4F").checked?"none":"block");
	document.getElementById("Q5Res").style.display = (document.getElementById("Q5F").checked?"none":"block");
	document.getElementById("Q6Res").style.display = (document.getElementById("Q6T").checked?"none":"block");
	document.getElementById("Q7Res").style.display = (document.getElementById("Q7T").checked?"none":"block");
	document.getElementById("Q8Res").style.display = (document.getElementById("Q8F").checked?"none":"block");
	document.getElementById("Q9Res").style.display = (document.getElementById("Q9F").checked?"none":"block");
}

function ShowLayer(layerID) {
  if (layerID=="") return;
  if (document.getElementById(layerID).style.display == "" || document.getElementById(layerID).style.display == "none")
	document.getElementById(layerID).style.display = "block";
  else document.getElementById(layerID).style.display = "none";
}

function Trim(str) { if(str) return( str.replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') ); else return ""; }
function RetFalse(obj,msg) { alert(msg);obj.focus();/*obj.select();*/return false; }

function CheckContactUs(TheForm) {
  TheForm.Fullname.value=Trim(TheForm.Fullname.value);
  if (TheForm.Fullname.value == "") return RetFalse(TheForm.Fullname, "שגיאה: אתה חייב להכניס שם מלא.");
  if (!(/^[A-Za-zא-ת\'\-\'_ ]+$/.test(TheForm.Fullname.value))) return RetFalse(TheForm.Fullname, "שגיאה: שם מלא אינו תקין.");
  TheForm.EMail.value=Trim(TheForm.EMail.value);
  if (TheForm.EMail.value == "") return RetFalse(TheForm.EMail, "שגיאה: אתה חייב להכניס דואל.");
  if (TheForm.EMail.value.indexOf("@") == -1) return RetFalse(TheForm.EMail, "שגיאה: דואל אינו תקין.");
  return true;
}

function grayOut(vis, options) {
// Pass true to gray out screen, false to ungray
// options are optional. This is a JSON object with the following (optional) properties
// opacity:0-100 // Lower number = less grayout higher = more of a blackout 
// zindex: # // HTML elements with a higher zindex appear on top of the gray out
// bgcolor: (#xxxxxx) // Standard RGB Hex color code
// grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
// Because options is JSON opacity/zindex/bgcolor are all optional and can appear
// in any order. Pass only the properties you need to set.
var options = options || {}; 
var zindex = options.zindex || 50;
var opacity = options.opacity || 95;
var opaque = (opacity / 100);
var bgcolor = options.bgcolor || '#ffffff';
var dark=document.getElementById('darkenScreenObject');
if (!dark) {
// The dark layer doesn't exist, it's never been created. So we'll
// create it here and apply some basic styles.
// If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
var tbody = document.getElementsByTagName("body")[0];
var tnode = document.createElement('div'); // Create the layer.
tnode.style.position='absolute'; // Position absolutely
tnode.style.top='0px'; // In the top
tnode.style.left='0px'; // Left corner of the page
tnode.style.overflow='hidden'; // Try to avoid making scroll bars 
tnode.style.display='none'; // Start out Hidden
tnode.id='darkenScreenObject'; // Name it so we can find it later
tbody.appendChild(tnode); // Add it to the web page
dark=document.getElementById('darkenScreenObject'); // Get the object.
}
if (vis) {
// Calculate the page width and height 
if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
var pageWidth = document.body.scrollWidth+'px';
var pageHeight = document.body.scrollHeight+'px';
} else if( document.body.offsetWidth ) {
var pageWidth = document.body.offsetWidth+'px';
var pageHeight = document.body.offsetHeight+'px';
} else {
var pageWidth='100%';
var pageHeight='100%';
} 
//set the shader to cover the entire page and make it visible.
dark.style.opacity=opaque; 
dark.style.MozOpacity=opaque; 
dark.style.filter='alpha(opacity='+opacity+')'; 
dark.style.zIndex=zindex; 
dark.style.backgroundColor=bgcolor; 
dark.style.width= pageWidth;
dark.style.height= pageHeight;
dark.style.display='block'; 
} else {
dark.style.display='none';
}
}

function GrayIt() {
  grayOut(true);
  document.getElementById("disclaimer").style.display="block";
}
function GrayOK() {
  grayOut(false);
  document.getElementById("disclaimer").style.display="block";
  document.getElementById("disclaimer").style.display="none";
    document.getElementById("MainDiv").style.display="block";
}

var isNeedShowCats=false;
var checkShowCatsVar=null
function CheckNeedClose() {
  if (!isNeedShowCats) {
    document.getElementById("SearchCats").style.display = "none";
    document.getElementById("SearchCats").style.visibility = "hidden";
    clearInterval(checkShowCatsVar);
    checkShowCatsVar=null;
  } else checkShowCatsVar=setInterval("CheckNeedClose()",2000);
}

function MainSearchSubmit() {
  //if (Trim(document.getElementById('MainSearch').value) == "") return RetFalse(document.getElementById('MainSearch'), "שגיאה: לא הוזן ביטוי חיפוש.");
  //if (!(/^[A-Za-zא-ת\-_ ]+$/.test(document.getElementById('MainSearch').value))) return RetFalse(document.getElementById('MainSearch'), "שגיאה: הוזנן ביטוי שגוי.");
  document.getElementById('MainSearchForm').submit();
}
function ProductSearchSubmit() {
  //if (Trim(document.getElementById('ProductSearch').value) == "") return RetFalse(document.getElementById('ProductSearch'), "שגיאה: לא הוזן ביטוי חיפוש.");
  //if (!(/^[A-Za-zא-ת\-_ ]+$/.test(document.getElementById('ProductSearch').value))) return RetFalse(document.getElementById('ProductSearch'), "שגיאה: הוזנן ביטוי שגוי.");
  document.getElementById('SearchProduct').submit();
}
function ProductSearchSubmitE() {
  //if (Trim(document.getElementById('ProductSearch').value) == "") return RetFalse(document.getElementById('ProductSearch'), "Error: search query is invalid.");
  //if (!(/^[A-Za-zא-ת\-_ ]+$/.test(document.getElementById('ProductSearch').value))) return RetFalse(document.getElementById('ProductSearch'), "Error: search query is invalid.");
  document.getElementById('SearchProduct').submit();
}

var curUrl;
function ShowOutDis(address,todo) {
  todo = false;
  if (todo) {
	  grayOut(true);
	  objobj = document.getElementsByTagName("object");
	  for (i=0;i<objobj.length;i++) {
		objobj[i].style.display = "none";
	  }
	  document.getElementById("outDisclaimer").style.display="block";
	  document.getElementById("outDisclaimer").style.top = tempY-350;
	  curUrl = address;
  } else {
	  window.open("http://"+address,"newWin","");
  }
}
function HideOutDis() {
  grayOut(false);
  document.getElementById("outDisclaimer").style.display="block";
  document.getElementById("outDisclaimer").style.display="none";
  window.open("http://"+curUrl,"newWin","");
  objobj = document.getElementsByTagName("object");
  for (i=0;i<objobj.length;i++) {
	objobj[i].style.display = "block";
  }
}

var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  return true
}
