function getWindowWidth(){
    var ww = 0;
    if(self.innerWidth){
        ww = self.innerWidth;
    }else if(document.documentElement && document.documentElement.clientWidth){
        ww = document.documentElement.clientWidth;
    }else if(document.body){
        ww = document.body.clientWidth;
    }
    return ww;
}
function getWindowHeight(){
    var wh = 0;
    if (window.innerHeight && window.scrollMaxY){
        wh = window.innerHeight + window.scrollMaxY;
    }else if(document.body.scrollHeight > document.body.offsetHeight){
        wh = document.body.scrollHeight;
    }else{
        wh = document.body.offsetHeight;
    }
    return wh;
}
function disablePage(overRideIf){

    var MainDiv = document.getElementById("topLevelDiv");
    MainDiv.style.position = "absolute";
    MainDiv.style.top = "0px";
    MainDiv.style.left = "0px";
    if(document.getElementById("divLogIn").style.display=="block" || document.getElementById("divReg").style.display=="block" || document.getElementById("divPass").style.display=="block" || document.getElementById("divEmailPage").style.display=="block" || document.getElementById("divDLReg").style.display=="block" || overRideIf==1){
        
        var winW = getWindowWidth() + 'px';
        var winH = getWindowHeight() + 'px';                    
        
        MainDiv.style.width = winW;
        MainDiv.style.height = winH;
        MainDiv.style.display = "block";
        MainDiv.style.visibility = "visible";
        MainDiv.style.backgroundColor = "black";
        //MainDiv.style.zIndex = document.getElementById("divLogIn").style.zIndex - 1;
        
    }else{
        
        MainDiv.style.width = "0px";
        MainDiv.style.height = "0px";
        MainDiv.style.display = "none";
        MainDiv.style.visibility = "hidden";
        MainDiv.style.backgroundColor = "";
        MainDiv.style.color = "";
        MainDiv.style.zIndex = 999;
        
    }
}
function HideDiv(DivToHide){
    var x = document.getElementById(DivToHide);
    x.style.display = "none";
    x.style.visibility = "hidden";
}
function HideShow(DivShow,DivHide){
    if(DivHide!=''){
        HideDiv(DivHide);
    }
    if(DivShow!=''){
        var x = document.getElementById(DivShow);
        if(x.style.display == 'block' || x.style.visibility == "visible"){
            x.style.display = "none";
            x.style.zIndex = document.getElementById("topLevelDiv").style.zIndex - 1;
        }else{
            x.style.display = "block";
            x.style.visibility = "visible";
            x.style.zIndex = document.getElementById("topLevelDiv").style.zIndex + 1; 
        }
        switch(DivShow){
            case 'divLogIn':
                document.getElementById("ctl00$usrName").focus();
                break;
            case 'divReg':
                document.getElementById("ctl00$company").focus();
                break;
            case 'divEmailPage':
                document.getElementById("ctl00$epEmailTo").focus();
                break;
            case 'divPass':
                document.getElementById("ctl00$passEmail").focus();
                break;
        } 
    }
    disablePage(0);
}

function popper(windowURL,windowName,windowFeatures){
    return window.open(windowURL,windowName,windowFeatures); 
}
function OpenMap(divName){
    document.getElementById(divName).style.visibility = "visible";
    document.getElementById(divName).style.display = "block";
}
function CloseMap(divName){
    document.getElementById(divName).style.visibility = "hidden";
    document.getElementById(divName).style.display = "none";
}
function CVValidEmail(sender,args){
    var email = document.getElementById(sender.controltovalidate);
    if(isValidEmail(email.value)){
        args.IsValid = true;
    }else{
        args.IsValid = false;
    }
}
function isValidEmail(email){
    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (filter.test(email)){
        return true;
    }else{
        return false;
    }
}
