function backButtonVisibility (elem) {
	if(elem) {
		if(document.location.href.indexOf('?popup=1') == -1) elem.style.display='block';
		else elem.style.display='none';

		//disable for Mozilla 3.0
		if(BrowserDetect.browser == "Firefox" && BrowserDetect.version == 3 && window.history.length == 2)
			elem.style.display='none';
		if(window.history.length == 1) elem.style.display='none';

	}
}
function showPopup (url) {
	var t, l;
	var w, h;
	var address;
	address = url.toString() + getGuidFromQueryString(url);

	w = 500;
	h = 550;

	t = window.screen.height/2 - h/2;
	l = window.screen.width/2 - w/2;

	var p = window.open(address, "marketing",  "scrollbars=yes,resizable=yes,width="+w+",height="+h+",top=" +t+ ",left=" +l);
	p.focus();
}
function showPopupWH (url,w,h) {
	var t, l;
	//var w, h;
	var address;
	address = url.toString() + getGuidFromQueryString(url);

	t = window.screen.height/2 - h/2;
	l = window.screen.width/2 - w/2;

	var p = window.open(address, "marketing", "scrollbars=yes,resizable=yes,width=" +w + ",height=" +h+ ",top=" +t+ ",left=" +l);
	p.focus();
}
function getQueryString(variable) {
	var query = window.location.search.substring(1);
	var variables = query.split("&");
	for (var i = 0; i < variables.length; i++) {
		var pair = variables[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	}
	return "";
}
function getGuidFromQueryString(url) {
	var GUIDQuerystring;
	if (url.toString().indexOf("?") == -1) GUIDQuerystring = "?";
	else GUIDQuerystring = "&";
	GUIDQuerystring += "GUID=" + getQueryString("GUID");

	return GUIDQuerystring;
}

var imgFolder = '/images/new/';
var imgArray = new Array();
var redirectionStartedSoDoNotSwapImages = false;
var preloadingDone = false;
setTimeout("preloadingDone=true;", 8000); 
    
function SwapImages(imgelm, action) {
    if (redirectionStartedSoDoNotSwapImages || !preloadingDone) return;

    var suffix = '';
    var imgpath = '';
    suffix = action;
    var product = '';
    
    if (imgelm==null) return;

    product = imgelm.id;

    imgpath = GetImagePath(product,suffix);

    imgelm.src = imgpath;  // load the up/down image
}

function GetImagePath(product,suffix) { 
    var fileformat = '.jpg';
    if(product.indexOf("PageStart") != -1) fileformat = '.gif';
    return (imgFolder+product+'-'+suffix+fileformat); }
function PreloadImages() {
try {
    var currentImage = '';
    var suffix = '';
    var c = 0;
    var ps='';
    
    imgArray[c] = new Image;
    var navigation = ['PageStartBack','PageStartHome','PageStartSupport','PageStartLogOut'];
    for (var i=0; i<navigation.length; i++) {
        currentImage = navigation[i];
        suffix = 'down';
        imgArray[c] = new Image;
        ps+='<br/>';
        ps+=imgArray[c++].src = GetImagePath(currentImage,'up'); // preload up image
        imgArray[c] = new Image;
        ps+='<br/>';
        ps+=imgArray[c++].src = GetImagePath(currentImage,suffix); // preload down image
    }
    // Get out if its not productselection
    if(location.pathname.indexOf("productselection.aspx") == -1) {
        preloadingDone = true;
        return;
    }
    var products = ['NonProfits','NPAudits','Snapshot','Counselor','IndustryData','Analytics','AnalyticsUK','ExtremeUK','AnalystUK'];
    // loop thru all the products
    for (var i=0; i<products.length; i++) {
        currentImage = products[i];
        suffix = 'down';
        imgArray[c] = new Image;
        ps+='<br/>';
        ps+=imgArray[c++].src = GetImagePath(currentImage,'up'); // preload up image
        imgArray[c] = new Image;
        ps+='<br/>';
        ps+=imgArray[c++].src = GetImagePath(currentImage,suffix); // preload down/locked image
    }

    preloadingDone = true;
}catch (e) {}
}