var Constants = {
		isIE : navigator.appName.toLowerCase().indexOf("explorer") > -1,
		isMoz : !this.isIE,
		a: 1,
		ViewMode: {Target:0, Avg:1}
}

var content=null;

function onLoadFunction()
{

	for (i=0; i<document.forms.length; ++i)
	{
		actionURL=document.forms[i].action;
		currentURL=String(window.location);
		actionURL=currentURL.substr(0,currentURL.indexOf(actionURL))+actionURL;
		
		document.forms[i].action=actionURL;
	}
	
    if(typeof pageInit!="undefined")
        pageInit();
        
	return true;
}

function FormatDate(value) {
	if (value.replace(/ /, "") == "") return "01/01/05";
	return value.replace(/[\d]{2}([\d]{2})([\d]{2})([\d]{2})/, "$3/$2/$1");
}

function isNullOrUndefined(obj)
{
	return ((obj==null) || (obj==undefined) || (typeof(obj)=="undefined"));
}

function notNullOrUndefined(obj)
{
	return !isNullOrUndefined(obj)
}

function WindowOnKeyPressFunction()
{
    return true;
}


function AjaxUrl(urlToSet)
{
	var ajaxURL=(((idx=location.href.indexOf('#'))>-1) ? location.href.substr(idx+1) : null);
	
	if (urlToSet==null)
	{
		if (ajaxURL!=null && ajaxURL!="")
			ajaxURL+=((ajaxURL.indexOf('?')>-1) ? "&" : "?" ) + "contentOnly=true";
		else
			ajaxURL=null;
		
		return ajaxURL;
	}
	else
	{
		if (ajaxURL!=null)
			location.href=location.href.replace("#"+ajaxURL,"#"+urlToSet);
		else
			location.href+="#"+urlToSet;
		
		return ((urlToSet!="") ? urlToSet+((urlToSet.indexOf('?')>-1) ? "&" : "?" ) + "contentOnly=true" : null);
	}
	
}

function historyHandler(url)
{
	if (document.getElementById('fwrdBackHandler')==null)
		document.body.appendChild(document.createElement("<iframe id='fwrdBackHandler' src='"+siteRoot+"/Templates/NavStack.aspx' style='display:none'/>"));		
	
	document.getElementById('fwrdBackHandler').src=siteRoot+"/Templates/NavStack.aspx?"+url.split("#")[1];
}

function fetchContent(ajaxURL, doNotLog)
{
	URLtoFetch=AjaxUrl()
	if (ajaxURL!=null)
	{
		if (ajaxURL.toLowerCase()=="homepage.aspx")				// if need fetching of homepage, redirect
		{	
			AjaxUrl("");				
			document.getElementById('draggedDrop').setSelected(-1);
			setShowContents(false,true);
			return;
		}
		
		URLtoFetch=AjaxUrl(ajaxURL);
		
	}	
    
	tuneDropPointer((URLtoFetch!=null) ?  URLtoFetch : window.location.href);

	if (URLtoFetch==null)
		return;
	
	window.scrollTo(0,0);	
	httpRequest(siteRoot+"/Templates/"+URLtoFetch, "GET", false);
	placeContent('BodySection');

	if (ajaxURL!=null && doNotLog==null)
		historyHandler(window.location.href);
	
	if (typeof(setShowContents)!="undefined")
		setShowContents(true, (ajaxURL!=null));
}    

function tuneDropPointer(url)
{
	try
	{	
		menuItems=document.getElementById('hightLightModule').childNodes[0].childNodes[0].childNodes.length;
			
		for (i=0; i<menuItems; ++i)
		{
			if (url.indexOf(document.getElementById('hightLightModule').childNodes[0].childNodes[0].childNodes[i].childNodes[0].href.replace(siteRoot,'').split('/')[4])>-1)
			{
				document.getElementById('draggedDrop').setSelected(i);				
				break;
			}
		}
	}
	catch(e){}
}

function placeContent(Placeholder, filterLevel, delta)
{
	if (document.getElementById('draggedDrop').inMotion==true)	// wait till drop will stop
		window.setTimeout("placeContent('"+Placeholder+"')",200);
	else
	{
		var numberOfFadeLevels=3;					// change, if needed
		var fadePeriod=5;							// 
		
		if (delta==null)
			delta=Math.round(100/numberOfFadeLevels);
			
		var placeHolder=document.getElementById(Placeholder);
		
		if (filterLevel>=100)
		{  
		    //CALL GOOGLE
		    _uacct = "UA-340698-1";
            urchinTracker();
           
			return;
		}	
		if (filterLevel<=0)
		{
			if (ajaxResponse==null)
			{
				delta=0;
				fadePeriod=500;
			}
			else
			{
				if (placeHolder.style.display!="none")
				{
					placeHolder.innerHTML=ajaxResponse;
				  
				}	
				delta=-Math.round(100/numberOfFadeLevels);
				filterLevel=0;
				setPageProperties(document.getElementById('pageProperties'));
			}
		}
		
		placeHolder.style.filter ="progid:DXImageTransform.Microsoft.Alpha(opacity=" + (filterLevel!=null ? filterLevel-delta : 100-delta) + ");";
		
		window.setTimeout("placeContent('"+Placeholder+"',"+(filterLevel!=null ? filterLevel-delta : 100-delta)+", "+delta+")",fadePeriod);
	}
}

function setPageProperties(propertyObj)
{
	if (propertyObj==null)
		return;
		
	for(i=0; i<propertyObj.childNodes.length; ++i)
	{
		eval ("document."+propertyObj.childNodes[i].name+"='"+propertyObj.childNodes[i].value+"'");
	}
	
	//added by sharon & sigal 18.7.06
	FixToolsVisibility();
}
function FixToolsVisibility()
{
	var iScreenHe, iBodyCltHe, iLinkTop;
	var oTd = document.getElementById("Td2Top");
	var oDiv = document.getElementById("mainDiv");
	
	iScreenHe = window.screen.height; //גובה המסך כולו כולל כל הסרגלים
	
	//iBodyCltHe = window.document.body.clientHeight // גובה של המסך ללא סרגלים
	
	iBodyCltHe = window.document.body.offsetHeight // גובה של המסך ללא סרגלים וללא סטטוס בר
	
	iLinkTop = oDiv.offsetHeight - 140;
				
	//alert(iLinkTop  + " > " + iBodyCltHe);
	
	if(iLinkTop > iBodyCltHe)
		oTd.style.visibility='visible';
	else
		oTd.style.visibility='hidden';
	
}

/// Query string Handler /////////////////////////////////////
//////////////////////////////////////////////////////////////
// Usage Sample :                                           //
//    var QueryString = new QSObject(window.location.href); //
//    alert(QueryString["sharon"]);                         //
//////////////////////////////////////////////////////////////

function QSObject(querystring){
	var qsReg = new RegExp("[?][^#]*","i");
	hRef = unescape(querystring);
	var qsMatch = hRef.match(qsReg);
	//removes the question mark from the url
	qsMatch = new String(qsMatch);
	qsMatch = qsMatch.substr(1, qsMatch.length -1);
	//split it up
	var rootArr = qsMatch.split("&");
	for(i=0;i<rootArr.length;i++){
	var tempArr = rootArr[i].split("=");
	if(tempArr.length ==2){
	tempArr[0] = unescape(tempArr[0]);
	tempArr[1] = unescape(tempArr[1]);

	this[tempArr[0]]= tempArr[1];
	}
	}
} 

function Trim(str)
{
    return str.replace(/^\s+|\s+$/, '');
}
/*
function validateForm(form)
{
	if (!form)
		{form=window.document.forms[0].id}
	
	var rtn=true;
	
	var inputFields=window.document.forms[form].tags('input');
	for (i=inputFields.length-1; i>=0; --i)
	{
		if (inputFields[i].className.indexOf('IWInputField')>-1)
		{
			if (!inputFields[i].isValid())
				rtn=false;								
		}
	}
	
	return rtn;
}
*/
function chick(let,idTd)
{
 var d = document.getElementById("aaaa");
 var aa = d.getElementsByTagName("span");
 var TEST = document.getElementById(idTd);
 var abcx = document.getElementById('LinksTable');
 var list = abcx.getElementsByTagName('td');
 for (var k=0;k<list.length;k++)
 {
    //list[k].className = "ContentInnerLink";     
   if (list[k].getAttribute('type') == 'link')
   {
     list[k].className = "ContentInnerLink"; 
   }
 }
 
 var i=0;
    if (let == "ALL")
    {
        for ( i;i<aa.length;i++)
        { 
         aa[i].className = "innerWorkers2 ContentInnerText"; 
        }
    }
    else
    {
             for ( i;i<aa.length;i++)
             {   
                    if ( splitLetter(aa[i].getAttribute("cat"),let) < 0)
                    {
                       
                        
                        if   (aa[i].getAttribute("cat") == "Text")
                        {
                        
                        }
                        else
                        {
                             aa[i].className = "innerWorkersOff"; 
                        }      
                    }
                    else
                    {
                          if   (aa[i].getAttribute("cat") == "Text")
                        {
                           
                        }
                        else
                        {
                            aa[i].className = "innerWorkers2 ContentInnerText";
                        }  
                        
                               
                    } 
             }
     }
    
   TEST.parentNode.parentNode.className = "Customers";
}

function splitLetter(str,str2)
{
   return str.indexOf(str2);

}
function printPage()
	{
		var oPage = window.open();
		var TitleToPrint = document.getElementById("toPrintTitle");
		var contentToPrint = document.getElementById("toPrintBody");
		
		oPage.document.writeln('<html>');
		oPage.document.writeln('<head>');
		oPage.document.writeln('<LINK href="/Styles/Global.css" type="text/css" rel="stylesheet">');
		oPage.document.writeln('<style>.innerWorkers {width:150px;	float:right;	height:170px;	display:block;}.innerWorkersOff{	display:block;}</style>');		
		oPage.document.writeln('</head>');
		oPage.document.writeln('<body dir="rtl" onload="javascript:window.print();">');
		
		oPage.document.writeln('<table align="center" width="620px">');
		oPage.document.writeln('<tr><td align="left">');
		oPage.document.writeln('<img src="/Images/Logos/Logo_altN.gif">');		
		oPage.document.writeln('</td></tr>');
		oPage.document.writeln('<tr><td>');
	
	
	//	oPage.document.writeln(TitleToPrint.outerHTML + contentToPrint.outerHTML );
		oPage.document.writeln('<tr  id="toPrintTitle" class="imgTitleTD2 grayBackground">' + TitleToPrint.innerHTML + '</tr>');
		oPage.document.writeln('<tr id="toPrintBody">' + contentToPrint.innerHTML + '</tr>');
		oPage.document.writeln('</td></tr></table>');
		oPage.document.writeln('</body>');
		oPage.document.writeln('</html>');
		 
		//oPage.location.reload();
		oPage.document.close()
		
}
function printmap()
{   
//window.open("");
   // window.open("/Templates/About/WorkersTeam/Teams/MapAddwisePrintVersion.htm",'','left=0,top=1100,width=30');
    window.open("/Templates/About/WorkersTeam/Teams/MapAddwisePrintVersion.htm");
}
function printmapEng()
{   
    window.open("/Templates/About/WorkersTeam/Teams/MapAddwisePrintVersionEng.htm",'','left=0,top=1100,width=30');
    //window.open("/Templates/About/WorkersTeam/Teams/MapAddwisePrintVersion.htm");
}

function GetArticle()
{
	for(i=1;i<=3;i++)
	{
		var oCheBox= document.getElementById("chk_"+i)
		var oDiv= document.getElementById("div_"+i)
			
		
			if(oCheBox.checked)
			{
				oDiv.style.display="block";
			}
			else
			{
				oDiv.style.display="none";
			}
	}
}