function show(id) {
    document.getElementById(id).style.display = '';
}
function hide(id) {
    document.getElementById(id).style.display = 'none';
}

function clickButton(e, buttonid) {
    var bt = document.getElementById(buttonid);
    if (typeof bt == 'object') {
        if (navigator.appName.indexOf("Netscape") > (-1)) {
            if (e.keyCode == 13) {
                bt.click();
                return false;
            }
        }
        if (navigator.appName.indexOf("Microsoft Internet Explorer") > (-1)) {
            if (event.keyCode == 13) {
                bt.click();
                return false;
            }
        }
    }
}

var popupdivname;
function closeAnimation(divname) {
    if (divname == 'undefined') {
        divname = popupdivname;
    }
    document.getElementById(divname).style.display = 'none';
    hideDiv(divname);
}

//Etienne 2008-02-26
var popupDivcontent;
//Show a div
//backGroundColor and backGroundOpacity are optional set to gray and 70% by default
function showDiv(PopupDivName, backGroundColor, backGroundOpacity) {
    if (gup('BlockJavascript') != 'true') {
        popupdivname = PopupDivName;

        //Set Up Some Variable by default
        var PopupBackgroundDivName = PopupDivName + 'BackGround'
        if (!backGroundColor) { backGroundColor = 'gray'; }
        if (!backGroundOpacity) { backGroundOpacity = 70; }

        //Get the modalPopup div
        var popupDiv = document.getElementById(PopupDivName);

        if (popupDivcontent != null){
            popupDiv.innerHTML = popupDivcontent;
        }

        //Crate a grey background for the popup to be modal
        if (!document.getElementById(PopupBackgroundDivName)) {
            var theDiv = document.createElement('div');
            theDiv.setAttribute('id', PopupBackgroundDivName);
            theDiv.style.top = '-10px';
            theDiv.style.left = '0';
            theDiv.style.opacity = backGroundOpacity / 100; //IE
            theDiv.style.filter = 'alpha(opacity=' + backGroundOpacity + ')'; //Non-IE
            theDiv.style.position = 'absolute';
            theDiv.style.backgroundColor = backGroundColor;
            document.body.appendChild(theDiv);
            resizeDivModal(PopupDivName);
        }
        //Or get it if the background already exist
        else {
            var theDiv = document.getElementById(PopupBackgroundDivName);
            theDiv.style.display = 'block';
            theDiv.style.visibility = 'visible';
        }
        //set the background size to fill the page


        //show the popup
        popupDiv.style.display = 'block';
        popupDiv.style.visibility = 'visible';
        //Order Z-depht of the page elements            
        theDiv.style.zIndex = 110;
        popupDiv.style.zIndex = 120;
    }
}

//Hide a div
function hideDiv(PopupDivName) {
    //Set Up Some Variable by default
    var PopupBackgroundDivName = PopupDivName + 'BackGround'
    //Get the modalPopup div
    var theDiv = document.getElementById(PopupBackgroundDivName);
    var popupDiv = document.getElementById(PopupDivName);
    //Hide all
    popupDivcontent = popupDiv.innerHTML;
    popupDiv.innerHTML = null;
    
    popupDiv.style.display = 'none';
    popupDiv.style.visibility = 'hidden';
    theDiv.style.display = 'none';
    theDiv.style.visibility = 'hidden';
}

//Resize a Div to the document size (hiden scroll part include)
function resizeDivModal(PopupDivName) {
    //Set Up Some Variable by default
    var PopupBackgroundDivName = PopupDivName + 'BackGround'
    //Get the modalPopup div
    var theDiv = document.getElementById(PopupBackgroundDivName);
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        theDiv.style.width = document.body.scrollWidth + 'px';
        theDiv.style.height = document.body.scrollHeight + 'px';
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
    //IE 6+ in 'standards compliant mode'
        theDiv.style.width = (document.documentElement.scrollWidth + 10) + 'px';
        theDiv.style.height = (document.documentElement.scrollHeight + 10) + 'px';
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        theDiv.style.width = document.body.scrollWidth + 'px';
        theDiv.style.height = document.body.scrollHeight + 'px';
    }
}

function gup(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null) return "";
    else return results[1]; 
}
