		var last_div="";
		function CheckMailing(Where) 
		{
			if (document.mailinglist.name.value == "")
				alert("אנא הכנס/י שם")
			else
			{	
				if (document.mailinglist.email.value == "")
					alert("אנא הכנס/י  כתובת דואר אלקטרוני")
				else
				MySubmitMail(Where);																								
			}	
		}
		function CheckLogin()
		{
			if (document.Login.email.value == "")
				alert("אנא הכנס/י דואר אלקטרוני")
			else
			{	
				if (document.Login.password.value == "")
					alert("אנא הכנס/י סיסמא")
				else
					document.Login.submit();																								
			}	
		}
		function OpenWindow(site_url,the_width,the_height)
		{
			new_window=eval("window.open(site_url,'new_window', 'location=0, toolbar=0,status=0,menubar=0,resizable=1,location=0,scrollbars=0,left=200, top=100, width=" + the_width + ", height=" + the_height + "')");
			new_window.focus();
		}
		function EnlargePicture(imagefile, title) 
		{
			var testwin;	
			if (testwin==null)
				testwin = window.open('Enlargement.asp?image=' + imagefile + '&title=' + title ,'new','location=0, toolbar=0,status=0,menubar=0,resizable=1,scrollbars=1');
			else
				testwin = window.location('Enlargement.asp?image=' +imagefile + '&title=' + title ,'new','location=0, toolbar=0,status=0,menubar=0,resizable=1,scrollbars=1');
		    testwin.moveTo(0,0) ;
		    testwin.resizeTo(300,300);
			testwin.focus	
		}
		function SubmitSearch()
		{
			if(document.TheSearch.search_words.value=="")
			{
				alert("Please insert a search word");
				return;
			}
			else
			{	
				var sale_type;
				if (TheSearch.sale_type[0].checked==true)
					document.TheSearch.action="SearchResultsPast.asp";
				if (TheSearch.sale_type[1].checked==true)
					document.TheSearch.action="SearchResultsNext.asp";
				document.TheSearch.submit();
			}	
		}
		function ShowDiv(obj,div_id) 
		{  
		  var oRcts;
		  var the_left;
		  var current_left;
		  var current_bottom;
		  // alert("I am here");
		 // oRcts = obj.getClientRects();
		//  current_left = eval("document.img_" + div_id + ".clientLeft");
		//  alert("current_left:" + current_left);
		//  the_left = (oRcts(0).left+idBody.scrollLeft)-50;
  	     // alert("the_left:" + the_left);
		//  bottom = (oRcts(0).bottom+idBody.scrollTop)-3;
		//  eval("top_nav_" + div_id + ".style.left=" + the_left);
		//  eval("top_nav_" + div_id + ".style.top=" + bottom);
		  eval("top_nav_" + div_id + ".style.display='block'");
		  last_div=div_id;
		}
		function HideDiv(div_id) 
		{      
			window.setTimeout("top_nav_" + div_id + ".style.display='none'", 10);
		}
		
		function HideAll() 
		{  
			//window.setTimeout("top_nav_1.style.display='none'", 10);   
			//alert(last_div)
			if (last_div!="")
				eval("top_nav_" + last_div + ".style.display='none'");
		}
		
		function containsDOM (container, containee) {
		  var isParent = false;
		  do {
		    if ((isParent = container == containee))
		      break;
		    containee = containee.parentNode;
		  }
		  while (containee != null);
		  return isParent;
		}
		
		function checkMouseEnter (element, evt) {
		  if (element.contains && evt.fromElement) {
		    return !element.contains(evt.fromElement);
		  }
		  else if (evt.relatedTarget) {
		    return !containsDOM(element, evt.relatedTarget);
		  }
		}
		
		function checkMouseLeave (element, evt) {
		  if (element.contains && evt.toElement) {
		    return !element.contains(evt.toElement);
		  }
		  else if (evt.relatedTarget) {
		    return !containsDOM(element, evt.relatedTarget);
		  }
		}
		function CheckSearch()
		{
			if(document.SearchForm.search_word.value=="")
				alert("נא להכניס מילת חיפוש")
			else
				document.SearchForm.submit();
		}		
		function validEmail(email)
		{
			invalidChars = " /:,;'"
					
			if (email == "") {
				return false
			}
			for (i=0; i<invalidChars.length; i++) {
				badChar = invalidChars.charAt(i)
				if (email.indexOf(badChar,0) > -1) {
					return false
				}
			}
			atPos = email.indexOf("@",1)
			if (atPos == -1) {
				return false
			}
			if (email.indexOf("@",atPos+1) != -1) {
				return false
			}
			periodPos = email.indexOf(".",atPos)
			if (periodPos == -1) {
				return false
			}
			if (periodPos+3 > email.length)	{
				return false
			}
			
			if (noHeb(email)== false) {
				return false
			}
		//	for (i=0; i<email.length; i++) {
		//		if (email.charAt(i) >="א" && email.charAt(i)<="ת" )  {
		//			return false
		//		}
		//	}
			return true
		}
		function noHeb(str) 
		{
			invalidChars = "אבגדהוזחטיכלמנסעפצקרשתםןךףץ"
		    for (var i=0; i<invalidChars.length; i++)
			{
				badChar = invalidChars.charAt(i)
				if (str.indexOf(badChar,0) > -1) {
					return false
				}
			}
			return true
		}
		function getProject(pid,the_source,the_div_name)
		{
			source = new ActiveXObject("Microsoft.XMLDOM");
			source.async = false;
			source.load(the_source + "?pid=" + pid);
			root = source.documentElement;
			var Cont;
			Cont="";
			Cont = root.childNodes.item(0).childNodes.item(0).childNodes.item(0).text;
			status = "Done";
			Cont = replaceSubstring(Cont,"&lt;","<");
			Cont = replaceSubstring(Cont,"&gt;",">");
			Cont = replaceSubstring(Cont,"&amp;","&");
			Cont = replaceSubstring(Cont,"&rsquo;","'");
			Cont = replaceSubstring(Cont,"&quot;",'"');
			eval(the_div_name + ".outerHTML=Cont");
		}
		function replaceSubstring(inputString, fromString, toString) {
	   // Goes through the inputString and replaces every occurrence of fromString with toString
	   var temp = inputString;
	   if (fromString == "") {
	      return inputString;
	   }
	   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
	      while (temp.indexOf(fromString) != -1) {
	         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
	         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
	         temp = toTheLeft + toString + toTheRight;
	      }
	   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
	      var midStrings = new Array("~", "`", "_", "^", "#");
	      var midStringLen = 1;
	      var midString = "";
	      // Find a string that doesn't exist in the inputString to be used
	      // as an "inbetween" string
	      while (midString == "") {
	         for (var i=0; i < midStrings.length; i++) {
	            var tempMidString = "";
	            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
	            if (fromString.indexOf(tempMidString) == -1) {
	               midString = tempMidString;
	               i = midStrings.length + 1;
	            }
	         }
	      } // Keep on going until we build an "inbetween" string that doesn't exist
	      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
	      while (temp.indexOf(fromString) != -1) {
	         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
	         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
	         temp = toTheLeft + midString + toTheRight;
	      }
	      // Next, replace the "inbetween" string with the "toString"
	      while (temp.indexOf(midString) != -1) {
	         var toTheLeft = temp.substring(0, temp.indexOf(midString));
	         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
	         temp = toTheLeft + toString + toTheRight;
	      }
	   } // Ends the check to see if the string being replaced is part of the replacement string or not
	   return temp; // Send the updated string back to the user
	} // Ends the "replaceSubstring
	
	function OpenWindow(site_url,the_width,the_height)
	{
		new_window=eval("window.open(site_url,'new_window', 'location=0, toolbar=0,status=0,menubar=0,resizable=1,location=0,scrollbars=1,left=200, top=100, width=" + the_width + ", height=" + the_height + "')");
		new_window.focus();
	}	

