function collapseItContent(list){

//alert('Collapse: ' + list);

	var listElementStyle=document.getElementById(list).style;

	listElementStyle.display="none";

}

function expandItContent(list){

	//alert('Expand: ' + list);

	var listElementStyle=document.getElementById(list).style;

	if (listElementStyle.display!="block"){
		listElementStyle.display="block";
	} else {
		listElementStyle.display="none";
	}
}

function expandIt(list,change){
	var listElementStyle=document.getElementById(list).style;
	var arrowElementStyle=document.getElementById(change).style;

	if (listElementStyle.display!="block"){
		listElementStyle.display="block";
	} else {
		listElementStyle.display="none";
	}

	if (listElementStyle.display!="block"){
		arrowElementStyle.background="url(Assets/Images/NavArrowSmall.png) no-repeat";
	} else {
		arrowElementStyle.background="url(Assets/Images/NavArrowSmallDown.png) no-repeat";
	}

}


function popUp(path, width, height) {

    window.open( path, "", "height = " + height + ", width = " + width + ",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes" )

}


function ExtranetSupportPopUp(box){
	var BoxAppearStyle=document.getElementById(box).style;

	if (BoxAppearStyle.display="block"){
		BoxAppearStyle.display="block";
	} else {
		BoxAppearStyle.display="none";
	}	
}

function ExtranetSupportPopUpClose(box){
	var BoxAppearStyle=document.getElementById(box).style;
		
	BoxAppearStyle.display="none";
}



function CheckForBrowserCompatability() {

    sCurrentBrowserCompatabilityVersion = '1.04';

    sLastBrowserCompatabilityVersion = readCookie("LK_BrowserCompatability_Version");
    // Read the last browser compataility check's version
    
    //alert(sLastBrowserCompatabilityVersion);
    
    if (sCurrentBrowserCompatabilityVersion != sLastBrowserCompatabilityVersion) {
    	// If the version numbers are different we need to refresh the browser
    	window.setTimeout('window.location.reload()',1000);
    	// Refresh the page after 1 second
    }

    bHasSilverlight = CheckForSilverlight();
    
    if (!bHasSilverlight) {
    	bHasSilverlight = CheckForDirtyFirefoxSilverlight();
    }
    
    bHasOldBrowser = CheckForOldBrowser();
    
    // Write out Cookies for Server Side Processing
    createCookie("LK_BrowserCompatability_Version",sCurrentBrowserCompatabilityVersion,28)
    createCookie("LK_Old_Browser_Version",bHasOldBrowser,28)
    createCookie("LK_Silverlight_Available",bHasSilverlight,28)
    
    if (sCurrentBrowserCompatabilityVersion == sLastBrowserCompatabilityVersion) {
        // If the verion is up-to-date
        if (bHasOldBrowser) {
            // If this is an old browser
            sDontDisplayWarning = readCookie("LK_BrowserCompatability_VersionWarning");
            // Check if a previous warning has been shown
            if (sDontDisplayWarning != 'true') {
	    	OpenBrowserCompatabilityWarning('BrowserCompatabilityOldBrowser');
		// Produce a popup warning
		createCookie('LK_BrowserCompatability_VersionWarning','true',1);
	    	// Write a cookie to disable further warnings for 24 hours
	    }
    	} else {
    	    // 
	    if (!bHasSilverlight) {
	    	// If we don't have Silverlight
	    	
	    	sDontDisplayWarning = readCookie("LK_BrowserCompatability_SilverlightWarning");
		// Check if a previous warning has been shown
		
		if (sDontDisplayWarning != 'true') {
		    OpenBrowserCompatabilityWarning('BrowserCompatabilityNoSilverlight');
		    // Produce a popup warning
		    createCookie('LK_BrowserCompatability_SilverlightWarning','true',1);
	    	    // Write a cookie to disable further warnings for 24 hours
		}                
	    }
	}
    }
    
}

function CloseBrowserCompatabilityWarning(PopupName) {
	
	oPopupMessage = document.getElementById(PopupName);
	// Locate the hidden span for no Silverlight
	oTransparency = document.getElementById('PopupTransparencyFilter');
	// Locate the hidden span for no Silverlight
	
	oTransparency.style.display = 'none';
	oPopupMessage.style.display = 'none';
	// Make the warning invisible
	
}

function CheckForDirtyFirefoxSilverlight() {

	if(navigator != null) {
		if(navigator.plugins != null) {
			if(navigator.plugins.length) {
				var plugin = navigator.plugins["Silverlight Plug-In"];
				// Check for the plugin
				if(plugin != null) {
					// Silverlight is installed
					return true
					// Return SUCCESS
				}
			}
		}
	}
	return false;
	// Return FAILURE
}

function CheckForOldBrowser() {
	if (window.XMLHttpRequest) {
		return false;
	} else {
		return true;
	}
}

function CheckForSilverlight() {

	if ( typeof CheckForSilverlight.counter == 'undefined' ) {
		// It has not... perform the initilization
		CheckForSilverlight.counter = 0;
	}
	
	var isSLInstalled = Silverlight.isInstalled();
	// Check if Silverlight is installed

	return isSLInstalled;
	
}

function OpenBrowserCompatabilityWarning(PopupName) {

	oPopupMessage = document.getElementById(PopupName);
	// Locate the hidden span for no Silverlight
	oTransparency = document.getElementById('PopupTransparencyFilter');
	// Locate the hidden span for no Silverlight
	
	oTransparency.style.height = GetPageHeight();
	oTransparency.style.width = GetPageWidth();
	oTransparency.style.display = 'block';
	oTransparency.style.position = 'absolute';
	oTransparency.style.right = 0;
	oTransparency.style.top = 0;
	// Hide the body of the page
	oPopupMessage.style.display = 'inline-block';
	oPopupMessage.style.position = 'absolute';
	oPopupMessage.style.right = (GetPageWidth() - 600) / 2;
	oPopupMessage.style.top = 100;
	// Make the warning visible
	
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function GetPageWidth() {

    var aPageSize = GetPageSize();
    // Calculate the size of the screen
    return aPageSize[2];

}

function GetPageHeight() {

    var aPageSize = GetPageSize();
    // Calculate the size of the screen
    return aPageSize[1];

}

function GetPageSize() {

    var xScroll, yScroll;

    if (window.innerHeight && window.scrollMaxY) {
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }

    var windowWidth, windowHeight;
    if (self.innerHeight) {	// all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }

    // for small pages with total height less then height of the viewport
    if (yScroll < windowHeight) {
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }

    // for small pages with total width less then width of the viewport
    if (xScroll < windowWidth) {
        pageWidth = windowWidth;
    } else {
        pageWidth = xScroll;
    }

    arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight)
    return arrayPageSize;
}
