var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
                parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.")) >= 0 ? 1 : 0;

//breakFrames();

//var strBrowser = getBrowser();

function LoadImages( ) {
  if( isMinNS4 || isMinIE4 ) {
    img1  = new Image( );
    img2  = new Image( );

    img1.src  = "images/icon-logon-on.gif";
    img2.src  = "images/icon-logoff-on.gif";
  }
}

LoadImages( );

function PopupPic(sPicURL) { 
    var wd = 150;
    var ht = 150;
    var d = ((screen.width-wd)/2);
	var h = ((screen.height-ht)/2);
    window.open('popup-pic.html?pic='+sPicURL,'popupImage','top='+h+',left='+d+',width='+wd+',height='+ht+',toolbar=no,location=no,directories=no,menubar=no,status=no,scrollbars=no,resizable=no');
}

function IconRollOver( img ) {
  if( isMinNS4 || isMinIE4 ) {
	//alert(img);
    document.images[img.name].src = document.images[img.name].src.replace(".gif","-on.gif");
  }
}

function IconRollOut( img ) {
  if( isMinNS4 || isMinIE4 ) {
	//imageName = document.images[ img ].name;
    document.images[img.name].src = document.images[img.name].src.replace("-on.gif",".gif");
  }
}

function pLayer(layerName,IntCO) {
	if (IntCO==1) {
		document.getElementById(layerName).style.display = "block";
	}
	else {
		document.getElementById(layerName).style.display = "none";
	} 
}

function confirmAction(StrUrl) {
	if (confirm('האם אתה בטוח שברצונך לבצע פעולה זו?')) {
		Redir(StrUrl);
	}
}

function getURL(StrUrl) {
	window.location.href = StrUrl;
}

function Redir(StrUrl) {
	window.location.href = StrUrl;
}


// =========== Functions that gets the value of a key (strKey) from the GET query string. ==========

function jsGet(strKey) {
    var strUrl, strOut, strKey;
    var strUrlArray, strRecArray;
	var startPos, endPos, x;
	strOut = "";
    strUrl = window.location.href;
    startPos = strUrl.indexOf("?")+1;
    endPos = strUrl.length;
    strUrl = strUrl.substring(startPos, endPos);
    strUrlArray = strUrl.split("&");
    for (x=0; x < strUrlArray.length; x++) {
        strRecArray = strUrlArray[x].split("=");
        if (strKey==strRecArray[0]){
            strOut = strRecArray[1];
			break;
        }
    }
    return strOut;
}


/********************************************************
variable getResolution();
Gets the clients available screen width and returns the 
width in "a,b,c,d or e" depending on the resolution. 
Will return "z" on unsupported resolutions.
Possible future modifications could be if both are null,
open a new browser window "full screen" write an image
100% x 100% get the image size and return the values.
********************************************************/

function getResolution(){
	var iWidth, iHeight, sRes;

	if (window.innerWidth != null) {
		iWidth = window.innerWidth;
		iHeight = window.innerHeight; 
	}


		else if (document.body.clientWidth != null) {
			iWidth = document.body.clientWidth;
			iHeight=document.body.clientHeight;
		}
		else { iWidth = 640; }
		if(iWidth <= 640) 
			{sRes = 1;}		// 640 x 480 Resolution
		else if(iWidth <= 800)
			{sRes = 2;}		// 800 x 600 Resolution
		else if(iWidth <= 1024)
			{sRes = 3;}		// 1024 x 800 Resolution
		else if(iWidth <= 1280)
			{sRes = 4;}		// 1280 x 1024 Resolution
		else if(iWidth <= 1600)
			{sRes = 5;}		// 1600 x 1200 Resolution
		else {sRes = 6}
		return (sRes);
}


/********************************************************
getBrowser();
Gets the users browser type and returns "ie5, ie4, ie3, 
ns6, ns4, ns3". Will return "other" on any other browser.
********************************************************/

function getBrowser() {
	var vBrowser=navigator.appName;			
	var vVersion=navigator.appVersion;
	var sBrowser;
	if (vBrowser.indexOf("Microsoft")>=0 && vVersion.indexOf("6")>=0)
		{sBrowser="ie5";} 	// Microsoft Internet Explorer 5.x
	else if (vBrowser.indexOf("Microsoft")>=0 && vVersion.indexOf("5")>=0)
		{sBrowser="ie5";} 	// Microsoft Internet Explorer 5.x
	else if (vBrowser.indexOf("Microsoft")>=0 && vVersion.indexOf("4")>=0)
		{sBrowser="ie4";}		// Microsoft Internet Explorer 4.x
	else if (vBrowser.indexOf("Microsoft")>=0 && vVersion.indexOf("3")>=0)
		{sBrowser="ie3";}	// Microsoft Internet Explorer 3.x
	else if (vBrowser.indexOf("Netscape")>=0 && vVersion.indexOf("6")>=0)
		{sBrowser="ns6";}	// Netscape Navigator 6.x
	else if (vBrowser.indexOf("Netscape")>=0 && vVersion.indexOf("4")>=0)
		{sBrowser="ns4";}	// Netscape Navigator 4.x
	else if (vBrowser.indexOf("Netscape")>=0 && vVersion.indexOf("3")>=0)
		{sBrowser="ns3";}	// Netscape Navigator 3.x
	else
		{sBrowser="other";}	// All Others 	
	return(sBrowser);
}	


/********************************************************
breakFrames();
breakFrames() Tests if user was linked to here within
a frame. If true then will reopen current location
in the parent window.
********************************************************/

function breakFrames(){
	if(self.parent.frames.length != 0)
		{self.parent.location = document.location;}
}
