// preloader
// layer Mask overlay to be display while loading the page
var pageLoaded=0;

function pageSize(scroll){
    if(document.body){
        // get the Height and Width of the page
        var pageWidth, pageHeight;
        if (self.innerHeight) {          // FF, Opera, Chrome, Safari
                    pageWidth = self.innerWidth;
                    pageHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) { // IE 6, IE 7 
                    pageWidth = document.documentElement.clientWidth;
                    pageHeight = document.documentElement.clientHeight;
        } else if (document.body) { // old browsers
                    pageWidth = document.body.clientWidth;
                    pageHeight = document.body.clientHeight;
        }
        // check for scroll 
        var scrollH, scrollV;
        if (window.innerHeight && window.scrollMaxY) {      // old browsers
                    scrollH = document.body.scrollWidth;
                    scrollV = window.innerHeight + window.scrollMaxY;
        } else if (document.body.scrollHeight > document.body.offsetHeight){ 
                    // Opera9, Safari 3/4  windows
                    scrollH = document.body.scrollWidth;
                    scrollV = document.body.scrollHeight;
        } else { //IE6, IE7, FF, Netscape 
                    scrollH = document.body.offsetWidth;
                    scrollV = document.body.offsetHeight;
        }   
        if(scrollV > pageHeight) {
                    pageHeight = scrollV;
                    if(/Internet Explorer/.test(navigator.appName)) pageHeight+=30;
        }
        if(scrollH > pageWidth) pageWidth = scrollH;
        values = new Array(pageWidth+"px",pageHeight+"px"); 
    } else values = new Array("100%","100%"); 
    return values;
}


function checkBody(){
    document.write("<div id='pageMaskId' style='position:absolute;background:#FFF;top:0;left:0;display:block;height:100%;width:100%;z-index:999;'></div>");
    resizeMaskOverlay();
}
function resizeMaskOverlay(){
    if(pageLoaded==0){
        ps = pageSize(true); 
        pHeight = ps[1]!=null ? ps[1] : "100%";       
        if(document.getElementById("pageMaskId")) document.getElementById("pageMaskId").style.height=pHeight;
        setTimeout(resizeMaskOverlay,100);
    } 
}
function showPage(){
   $("#pageMaskId").fadeOut(500, function(){
     $(this).remove();
    });
   pageLoaded=1;
}
checkBody();