var PageSize = {

    getPageSize: function () {
        var xScroll, yScroll;

        if (window.innerHeight && window.scrollMaxY) {
            xScroll = document.body.scrollWidth;
            yScroll = window.innerHeight + window.scrollMaxY;
        } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
            xScroll = document.body.scrollWidth;
            yScroll = document.body.scrollHeight;
        } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
            xScroll = document.body.offsetWidth;
            yScroll = document.body.offsetHeight;
        }

        var windowWidth, windowHeight;
        if (self.innerHeight) {	// all except Explorer
            windowWidth = self.innerWidth;
            windowHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
            windowWidth = document.documentElement.clientWidth;
            windowHeight = document.documentElement.clientHeight;
        } else if (document.body) { // other Explorers
            windowWidth = document.body.clientWidth;
            windowHeight = document.body.clientHeight;
        }

        // for small pages with total height less then height of the viewport
        if(yScroll < windowHeight){
            pageHeight = windowHeight;
        } else {
            pageHeight = yScroll;
        }

        // for small pages with total width less then width of the viewport
        if(xScroll < windowWidth){
            pageWidth = windowWidth;
        } else {
            pageWidth = xScroll;
        }


        arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
        return arrayPageSize;


    },

    getPageScroll : function () {
        var yScroll;

        if (self.pageYOffset) {
            yScroll = self.pageYOffset;
        } else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
            yScroll = document.documentElement.scrollTop;
        } else if (document.body) {// all other Explorers
            yScroll = document.body.scrollTop;
        }
        arrayPageScroll = new Array('',yScroll)
        return arrayPageScroll;

    }

};

 /*
  * Begin cover page 
  */

function CoverBody(id , page)
{
	var pages = new Array();
    pages['send'] = "quick-s.php?id=";
	pages['print'] = "quick-p.php?id=";
	pages['contact'] = "quick-comment.php?id=";
	
    this.div_color      = '#5C758E';
    this.page_size      = PageSize.getPageSize();
    this.page_scrool    = PageSize.getPageScroll();
    this.objBody        = document.getElementsByTagName("body").item(0);
    this.objOverId      = "over";
    this.objCloseId     = "close";
    this.objInnerId     = "inner";
    this.objInnerWidth  = 640;
    this.objInnerHeight = 480;
    this.objCloseHeight = 100;
    this.objInnerSrc = pages[page]+ id;
}

CoverBody.prototype.CreateOver = function ()
{
    this.objOver                    = document.createElement("div");
    this.objOver.id                 = this.objOverId;
    this.objOver.name               = this.objOverId;
    this.objOver.style.position     = 'absolute';
    this.objOver.style.top          = '0';
    this.objOver.style.left         = '0';
    this.objOver.style.zIndex       = '99';
    this.objOver.style.width        = '100%';
    this.objBody.insertBefore(this.objOver, this.objBody.firstChild);
    this.objOver.style.height       = (this.page_size[1] + 'px');
    this.objOver.style.display      = 'block';
    this.objOver.style.border       = '0px;';
    this.objOver.style.background   = this.div_color;
    this.objOver.style.opacity      = '0.25';
    this.objOver.style.filter       = 'alpha(opacity=25 )';

}

CoverBody.prototype.CreateInner = function()
{
    this.objInner                   = document.createElement("div");
    this.objInner.id                = this.objInnerId;
    this.objInner.style.position    = 'absolute';
    this.objInner.style.zIndex      = '100';
    this.objInner.style.background  = '#ffffff';
    this.objInner.style.border      = "none";
    this.objBody.appendChild(this.objInner);
    this.objInner.style.top         = (this.page_scrool[1] + ((this.page_size[3]  - this.objInnerHeight) / 2) + 'px');
    this.objInner.style.left        = (((this.page_size[0] -  this.objInnerWidth) / 2) + 'px');


    this.objInnerFrame                  = document.createElement("iframe");
    this.objInnerFrame.style.width      = this.objInnerWidth+ "px";
    this.objInnerFrame.style.height     = this.objInnerHeight + "px";
    this.objInnerFrame.frameBorder      = "0";
    this.objInnerFrame.border           = "0";
    this.objInnerFrame.scrolling        = "no";
    this.objInnerFrame.name        	    = "rec";
    this.objInnerFrame.id        	    = "rec";
    this.objInnerFrame.src              = this.InnerSrc();
    this.objInner.appendChild(this.objInnerFrame);
}

CoverBody.prototype.CreateClose = function ()
{
    this.objClose                   = document.createElement("div");
    this.objClose.id                = this.objCloseId;
    this.objClose.style.position    = 'absolute';
    this.objClose.style.right       = '5px';
    this.objClose.style.top         = '8px';
    this.objClose.style.zIndex      = '200';
    this.objClose.style.background  = '';
    this.objClose.onclick           = "remov()";
    this.objClose.innerHTML         ="<div style='margin:4px 10px 0 0;'><a href='#' onclick='remov(); showgames(); return false;'><img src='/images/template/quick-close.gif' /></a></div>";
    this.objInner.appendChild(this.objClose);
}

CoverBody.prototype.CreateRefresh = function ()
{
    this.objRefresh                   = document.createElement("div");
    this.objRefresh.id                = this.objCloseId;
    this.objRefresh.style.position    = 'absolute';
    this.objRefresh.style.right       = '40px';
    this.objRefresh.style.top         = '8px';
    this.objRefresh.style.zIndex      = '200';
    this.objRefresh.style.background  = '#ffffff';
    this.objRefresh.onclick           = "remov()";
    this.objRefresh.innerHTML         ="<div ><a href='#' onclick='refresh();return false;'>Refresh</a></div>";
    this.objInner.appendChild(this.objRefresh);


}

CoverBody.prototype.Create = function () {
    this.CreateOver();
    this.CreateInner();
    this.CreateClose();
}

CoverBody.prototype.InnerSrc = function ()
{
    return this.objInnerSrc;
}

CoverBody.prototype.Remove = function()
{
   var objOver = document.getElementById(this.objOverId)
   var objInner= document.getElementById(this.objInnerId);
    try {
        this.objBody.removeChild(objOver);
        this.objBody.removeChild(objInner);
    } catch(e) {

    }
}

function comment( id , page) {
    cvr = new CoverBody( id , page);
    cvr.Create();
    return false;
}

function showgames() {
    window.parent.document.getElementById('gameswf').style.display = '';
	return false;
}

function remov()
{
    cvr.Remove();
}
