var whitespace = " \t\n\r";
var defaultEmptyOK = false;
var NS4 = (document.layers) ? true : false;

function isEmpty(s)
{   
	return ((s == null) || (s.length == 0))
}


function isWhitespace (s)

{   
	var i;

    if (isEmpty(s)) return true;

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }
    return true;
}

function isEmail (s)
{   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);

    if (isWhitespace(s)) return false;

    var i = 1;
    var sLength = s.length;

    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }
	if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

function isDigit (c)
{  
	return ((c >= "0") && (c <= "9"))
}

function isInteger (s)

{  
	var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }
    return true;
}

function goToPage(url)
{
	window.location.href=url;
}

function openPage(url)
{
	window.open(url,"_blank","width=700,height=600,scrollbars=1,resizable=1");
}

function checkForEnter(event, Str)
{     
    var code = 0;
    
    if (NS4)
        code = event.which;
    else
        code = event.keyCode;
    if (code==13)
        eval(Str);
}

function DoEnigmaSearch()
{
	if (isEmpty(demoForm.MaagarTypeID.value))
	{
		alert(".(אנא בחר היכן לחפש (חקיקה/פסיקה");
		demoForm.MaagarTypeID.focus();
	}
	else
	{
		//frmSearch.searchForm.username.value = demoForm.username.value;
		frmSearch.searchForm.user.value = demoForm.username.value;
		frmSearch.searchForm.searchedText.value = encodeURIComponent(demoForm.KeyWord.value);
		frmSearch.searchForm.MaagarTypeID.value = demoForm.MaagarTypeID(demoForm.MaagarTypeID.selectedIndex).value
		LoadSession.location.reload();
		frmSearch.getSearch();		
	}
}

function DoEnigma()
{
	frmSearch.searchForm.user.value = demoForm.username.value;
	//frmSearch.searchForm.searchedText.value = encodeURIComponent(demoForm.KeyWord.value);
	frmSearch.searchForm.action.value = "StartV8";
	LoadSession.location.reload();
	frmSearch.getSearch();
}

function DoEnigmaNew()
{
	if (!(isWhitespace(NameFrm.usname.value)))
	{
		frmSearch.searchForm.user.value = NameFrm.usname.value;//demoForm.username.value;
		//frmSearch.searchForm.searchedText.value = encodeURIComponent(demoForm.KeyWord.value);
		frmSearch.searchForm.action.value = "StartV8";
		LoadSession.location.reload();
		frmSearch.getSearch();
	}
	else
	{
		alert("יש לרשום את שם המשתמש בשדה המתאים וללחוץ על כניסה למאגר");
	}
}

function openFullSite(url)
{
	oHeight=screen.availHeight-45;
	oWidth=screen.availWidth-10;
	var atts='width='+oWidth+',height='+oHeight+',toolbars=0,top=0,left=0,status=1,scrollbars=1';
	var winName ='HalachotProduct'
	window.open(url,winName,atts);
}

/***********************************************
* Sticky Note script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
* Go to http://www.dynamicdrive.com/ for full source code
***********************************************/

//Specify display mode. 3 possible values are:
//1) "always"- This makes the fade-in box load each time the page is displayed
//2) "oncepersession"- This uses cookies to display the fade-in box only once per browser session
//3) integer (ie: 5)- Finally, you can specify an integer to display the box randomly via a frequency of 1/integer...
// For example, 2 would display the box about (1/2) 50% of the time the page loads.

var displaymode="oncepersession"

//var enablefade="yes" //("yes" to enable fade in effect, "no" to disable)
var enablefade="no"
//var autohidebox=["yes", 60] //Automatically hide box after x seconds? [yes/no, if_yes_hide_after_seconds]
var autohidebox=["yes",10]
var showonscroll="yes" //Should box remain visible even when user scrolls page? ("yes"/"no)
var IEfadelength=1 //fade in duration for IE, in seconds
var Mozfadedegree=0.05 //fade in degree for NS6+ (number between 0 and 1. Recommended max: 0.2)

////////No need to edit beyond here///////////

if (parseInt(displaymode)!=NaN)
var random_num=Math.floor(Math.random()*displaymode)

function displayfadeinbox(){
var ie=document.all && !window.opera
var dom=document.getElementById
iebody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
objref=(dom)? document.getElementById("fadeinbox") : document.all.fadeinbox
var scroll_top=(ie)? iebody.scrollTop : window.pageYOffset
var docwidth=(ie)? iebody.clientWidth : window.innerWidth
docheight=(ie)? iebody.clientHeight: window.innerHeight
var objwidth=objref.offsetWidth
objheight=objref.offsetHeight
objref.style.left=docwidth/2-objwidth/2+130+"px"
objref.style.top="50px";//scroll_top+docheight/2-objheight/2+"px"

if (showonscroll=="yes")
showonscrollvar=setInterval("staticfadebox()", 50)

if (enablefade=="yes" && objref.filters){
objref.filters[0].duration=IEfadelength
objref.filters[0].Apply()
objref.filters[0].Play()
}
objref.style.visibility="visible"
if (objref.style.MozOpacity){
if (enablefade=="yes")
mozfadevar=setInterval("mozfadefx()", 90)
else{
objref.style.MozOpacity=1
controlledhidebox()
}
}
else
controlledhidebox()
}

function mozfadefx(){
if (parseFloat(objref.style.MozOpacity)<1)
objref.style.MozOpacity=parseFloat(objref.style.MozOpacity)+Mozfadedegree
else{
clearInterval(mozfadevar)
controlledhidebox()
}
}

function staticfadebox(){
var ie=document.all && !window.opera
var scroll_top=(ie)? iebody.scrollTop : window.pageYOffset
objref.style.top="50px";//scroll_top+docheight/2-objheight/2+"px"
}

function hidefadebox(){
objref.style.visibility="hidden"
if (typeof showonscrollvar!="undefined")
clearInterval(showonscrollvar)
}

function controlledhidebox(){
if (autohidebox[0]=="yes"){
var delayvar=(enablefade=="yes" && objref.filters)? (autohidebox[1]+objref.filters[0].duration)*1000 : autohidebox[1]*1000
setTimeout("hidefadebox()", delayvar)
}
}

function initfunction(){
//if (get_cookie("fadedin")=="")
	setTimeout("displayfadeinbox()", 100);
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = ""
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset)
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

var date=new Date();

if (displaymode=="oncepersession" && get_cookie("fadedin")=="" || displaymode=="always" || parseInt(displaymode)!=NaN && random_num==0){
document.cookie="fadedin=yes;"
}

//DHTML Window script- Copyright Dynamic Drive (http://www.dynamicdrive.com)
//For full source code, documentation, and terms of usage,
//Visit http://www.dynamicdrive.com/dynamicindex9/dhtmlwindow.htm

var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function drag_drop(e){
if (ie5&&dragapproved&&event.button==1){
document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
}
}

function initializedrag(e){
offsetx=ie5? event.clientX : e.clientX
offsety=ie5? event.clientY : e.clientY
document.getElementById("dwindowcontent").style.display="none" //extra
tempx=parseInt(document.getElementById("dwindow").style.left)
tempy=parseInt(document.getElementById("dwindow").style.top)

dragapproved=true
document.getElementById("dwindow").onmousemove=drag_drop
}

function loadwindow(url,width,height){
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
document.getElementById("dwindow").style.display=''
document.getElementById("dwindow").style.width=initialwidth=width+"px"
document.getElementById("dwindow").style.height=initialheight=height+"px"
document.getElementById("dwindow").style.left="300px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
document.getElementById("cframe").src=url
}
}

function maximize(){
if (minrestore==0){
minrestore=1 //maximize window
document.getElementById("maxname").setAttribute("src","img/restore.gif")
document.getElementById("dwindow").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
document.getElementById("dwindow").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
}
else{
minrestore=0 //restore window
document.getElementById("maxname").setAttribute("src","img/max.gif")
document.getElementById("dwindow").style.width=initialwidth
document.getElementById("dwindow").style.height=initialheight
}
document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}

function closeit(){
document.getElementById("dwindow").style.display="none"
}

function stopdrag(){
dragapproved=false;
document.getElementById("dwindow").onmousemove=null;
document.getElementById("dwindowcontent").style.display="" //extra
}

function SearchCourt()
{
	if(frm10.city.value == "")
		alert("נא בחר/י עיר/ישוב בבקשה")
	else
	{
		frm10.city.blur();
		frm10.submit();
	}
}

function SwitchUser()
{
	document.getElementById("HiddenForm10").style.display = "none";
	document.getElementById("HiddenForm11").style.display = "none";
	
	document.getElementById("HiddenForm").style.display = "";
	document.getElementById("HiddenForm1").style.display = "";
	//document.getElementById("HiddenForm2").style.display = ""
}

function SwitchUser1()
{
	document.getElementById("HiddenForm").style.display = "none";
	document.getElementById("HiddenForm1").style.display = "none";
	//document.getElementById("HiddenForm2").style.display = "none"
	
	document.getElementById("HiddenForm10").style.display = "";
	document.getElementById("HiddenForm11").style.display = "";
}