﻿/*
    Graham Colmer : 11th March 2009

    common.js : Common utility javascript file. This file should contain common functions that all product
    sites can use, instead of duplicating the same logic in different places.
    
    This file should grow on demand and there should be an update log in Sharepoint so developers
    are aware of what logic it contains.

*/

/* Navigation dropdowns function */


sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
// comments since new menu has been implemented
//if (window.attachEvent) window.attachEvent("onload", sfHover);

/* centered popup window */

function centerPopup(url, default_left, default_top, width, height, scrollbars, winName) {
    var posX, posY;

    posX = default_left;
    posY = default_top;

    if (parseFloat(navigator.appVersion) >= 4.0) {
        posX = parseInt(screen.availWidth / 2.0) - (width / 2.0);
        posY = parseInt(screen.availHeight / 2.0) - (height / 2.0);
    }

    if (scrollbars) {
        var win = window.open(url, (winName == null ? "popupWin" : winName), "width=" + width + ",height=" + height + ",resizable=yes,scrollbars=1,location=no,status=yes,left=" + posX + ",top=" + posY);
    } else {
        var win = window.open(url, (winName == null ? "popupWin" : winName), "width=" + width + ",height=" + height + ",resizable=yes,scrollbars=0,left=" + posX + ",top=" + posY);
    }

    if (parseFloat(navigator.appVersion) >= 4.0) {
        win.moveTo(posX, posY);
        if (navigator.appName.indexOf("Netscape") != -1)
            win.focus();
    }
}

//functions for showing/hiding div for wwa language chooser div
    function setURL(ctr){
        var newURL = window.location.href.substring(0,window.location.href.lastIndexOf("/")+1);
        window.location = newURL + "?mc="+ctr;
    }
    var alphaInterval;
    function showDiv(){document.getElementById('subCountries').className = 'displayDiv';}
    function hideDiv(){clearTimeout(alphaInterval);document.getElementById('subCountries').className = 'hideDiv';}
    function setTimeOut(){if(alphaInterval){clearTimeout(alphaInterval);}alphaInterval = setInterval('hideDiv()',1000);}
    function clearTime(){clearTimeout(alphaInterval);}


