function openwin(strs,Id,w,h)
{
var mynewwind=window.open(strs+"?Id="+Id,'mynewwind','width='+w+',height='+h+',top=200,left=300,resizable=no scrollbars=no toolbar=no channelmode=no fullscreen=no');return false;}

function IfNotSelected(items,radio,msg) {
var bReturn = false;
for (var i = 0;i < items; i++)
{
if (document.getElementById(radio+"_"+i).checked == true)
{bReturn = true;}
}
if (!bReturn){alert(msg);}
return bReturn;
}
function IfNotSelectedProd(msg) {
var bReturn = false;
for (var i = 0;i < document.getElementById("counter").value; i++)
{
if (document.getElementById('check'+i).checked == true)
    {bReturn = true;}
}
if (!bReturn){alert(msg);}
return bReturn;
}
function CheckSearchBox(srch,msg){
    if(document.getElementById(srch).value.trim()==""){
    alert(msg);document.getElementById(srch).focus();return false;}
}    
function CheckClick(e)
{
    var key;

     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox

    if (key == 13)
        return false;
    else
        return true;
}
startday = new Date();
clockStart = startday.getTime();
function initStopwatch() 
{ 
		var myTime = new Date(); 
        var timeNow = myTime.getTime();  
        var timeDiff = timeNow - clockStart; 
        this.diffSecs = timeDiff/2000;
        return(this.diffSecs); 
}    
function getSecs() 
{ 
        var mySecs = initStopwatch(); 
        var mySecs1 = ""+mySecs; 
        mySecs1= mySecs1.substring(0,mySecs1.indexOf("."));
        myMinutes=0.1

        mySecs1=myMinutes - mySecs1
        window.setTimeout('getSecs()',4000);
				
        if (mySecs1<=0) 
        {window.close();}
}    
function TextScroll(scrollname, div_name, up_name, down_name)
{
    this.div_name = div_name;
    this.name = scrollname;
    this.scrollCursor = 0;
    this.speed = 5;
    this.timeoutID = 0;
    this.div_obj = null;
    this.up_name = up_name;
    this.dn_name = down_name;

{
        if (document.getElementById) {
            div_obj = document.getElementById(this.div_name);
            if (div_obj) {
                this.div_obj = div_obj;
                this.div_obj.style.overflow = 'hidden';
            }
            div_up_obj = document.getElementById(this.up_name);
            div_dn_obj = document.getElementById(this.dn_name);
            if (div_up_obj && div_dn_obj) {
               div_up_obj.onmouseover = function() { eval(scrollname + ".scrollUp();") };
				div_up_obj.onmouseout = function() { eval(scrollname + ".stopScroll();") };

				div_dn_obj.onmouseover = function() { eval(scrollname + ".scrollDown();") };
				div_dn_obj.onmouseout = function() { eval(scrollname + ".stopScroll();") };
				//window.onload = function() { eval(scrollname + ".ScrollUpLitle();") };
            }
        }
    }

this.stopScroll = function() {
        clearTimeout(this.timeoutID);
    }

this.scrollUp = function() {
        if (this.div_obj) {
            this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
            this.div_obj.scrollTop = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + ".scrollUp()", 60);
        }
    }
    
this.scrollDown = function() {
		if (this.div_obj) {
			this.scrollCursor += this.speed;
			this.div_obj.scrollTop = this.scrollCursor;
			if (this.div_obj.scrollTop == this.scrollCursor) {
				this.timeoutID = setTimeout(this.name + ".scrollDown()", 60);
			} else {
			this.scrollCursor = this.div_obj.scrollTop;
			}
		}
	}

this.resetScroll = function() {
        if (this.div_obj) {
            this.div_obj.scrollTop = 0;
            this.scrollCursor = 0;
        }
    }

this.ScrollUpLitle = function() {
        if (this.div_obj) {
			this.scrollCursor += this.speed;
			this.div_obj.scrollTop = 500;
			if (this.div_obj.scrollTop == this.scrollCursor) {
				this.timeoutID = setTimeout(this.name + ".ScrollUpLitle()", 60);
			}
		}
    }        
    
}


//Load different banner as default for different pages
function InitializeFadingManager()
{
    var path = window.location.pathname;
    var pageNameIndex = path.lastIndexOf('/');
    var pageName = '';
    
//    if (pageNameIndex > 0)
//    {
        pageName = path.substring(pageNameIndex+1);
        pageName = pageName.toLowerCase();
//    }

    switch (pageName)
    {
        case 'index.aspx': defaultBannerPrefix = 'entrance';
            break;
        case 'financeshomepage.aspx': defaultBannerPrefix = 'finansim';
            break;
        case 'laborhomepage.aspx': defaultBannerPrefix = 'avoda';
            break;
        case 'taxationhomepage.aspx': defaultBannerPrefix = 'misui';
            break;
        case 'lawhomepage.aspx': defaultBannerPrefix = 'mishpat';
            break;
        case 'fundshomepage.aspx': defaultBannerPrefix = 'pensia';
            break;
        case 'instructionhomepage.aspx': defaultBannerPrefix = 'hadracha';
            break;
        case 'article.aspx': 
            var worldId = GetQueryStringItem('Wrld');
            defaultBannerPrefix = GetBannerPrefixFromWorldId(worldId);
            
            break;            
        case 'products.aspx':
            var worldId = GetQueryStringItem('Id');
            defaultBannerPrefix = GetBannerPrefixFromWorldId(worldId);
            break;
        default:  defaultBannerPrefix = 'entrance';
            break;          
    }
    
    fadingManager.Init(defaultBannerPrefix, 'fadingImage');
}

// utility function to find a specific querystring value
function GetQueryStringItem(itemName) 
{
    var queryString = window.location.search.substring(1);
    var itemArray= queryString.split("&");
    for (i=0;i<itemArray.length;i++) 
    {
        var nameValueItem = itemArray[i].split("=");
        if (nameValueItem[0].toLowerCase() == itemName.toLowerCase()) 
        {
            return nameValueItem[1];
        }
  
  
    }
 }	
 
 //Gets the banner prefix from the worldID	
function  GetBannerPrefixFromWorldId(worldId)
{
    var result;
    switch(worldId)
    {
        case '1': result = 'avoda';
            break;
        case '2': result = 'misui';
            break;
        case '3': result = 'finansim';
            break;
        case '4': result = 'pensia';
            break;
        case '5': result = 'hadracha';
            break;
        case '8': result = 'mishpat';
            break;                    
        default:  result = 'entrance';
            break;                 
    }
    return result;
}