/****************************************\
* Show Overlay and box
\****************************************/
function showBox(id){
    $('overlay').show();
	$(id).show();
    overlayReload();
    center(id, '500', 'auto');// Size of the box
    return false;
}

function showAbout(id){
    $('overlay').show();
	$('about').show();
    overlayReload();
    center('about', '500', 'auto');// Size of the box
    return false;
}

function showLinks(id){
    $('overlay').show();
	$('links').show();
    overlayReload();
    center('links', '500', 'auto');// Size of the box
    return false;
}

function showDailyDose(id){
    $('overlay').show();
	$('daily_dose').show();
    overlayReload();
    center('daily_dose', '500', 'auto');// Size of the box
    return false;
}

function showMamapop(id){
    $('overlay').show();
	$('mamapop').show();
    overlayReload();
    center('mamapop', '500', 'auto');// Size of the box
    return false;
}

function showAdvice(id){
    $('overlay').show();
	$('advice').show();
    overlayReload();
    center('advice', '500', 'auto');// Size of the box
    return false;
}

function hideBox(id){
    $(id).hide();
    $('overlay').hide();
    return false;
}

function hideLinks(id){
    $('overlay').hide();
    $('links').hide();
	return false;
}

function hideDailyDose(id){
    $('overlay').hide();
    $('daily_dose').hide();
	return false;
}

function hideMamapop(id){
    $('overlay').hide();
    $('mamapop').hide();
	return false;
}

function hideAdvice(id){
    $('overlay').hide();
    $('advice').hide();
	return false;
}


function hideAbout(id){
    $('about').hide();
    $('overlay').hide();
    return false;
}

function hideOverlay(id){
    $('overlay').hide();
    return false;
}

/****************************************\
* Adjust overlay to new window size
\****************************************/
function overlayReload()
{
    if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX) {    
        yScroll = window.innerHeight + window.scrollMaxY;
        xScroll = window.innerWidth + window.scrollMaxX;
        var deff = document.documentElement;
        var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;
        var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;
        xScroll -= (window.innerWidth - wff);
        yScroll -= (window.innerHeight - hff);
    } else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth){ // all but Explorer Mac
        yScroll = document.body.scrollHeight;
        xScroll = document.body.scrollWidth;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        yScroll = document.body.offsetHeight;
        xScroll = document.body.offsetWidth;
      }

    $('overlay').style.height = yScroll;
    $('overlay').style.width = xScroll;
}
/****************************************\
* Actually center box
\****************************************/
function center(window_name, _width, _height) {
    var successWin = $(window_name);
    var pagesize = getPageSize();    
    var arrayPageScroll = getPageScrollTop();
    successWin.style.left = (arrayPageScroll[0] + (pagesize[0] - _width)/2);
    successWin.style.top = (arrayPageScroll[1] + (pagesize[1] - _height)/3);
}
/****************************************\
*
\****************************************/
function getPageSize(){
    var de = document.documentElement;
    var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
    var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight
    arrayPageSize = new Array(w,h) 
    return arrayPageSize;
}
/****************************************\
*
\****************************************/
function getPageScrollTop(){
    var yScrolltop;
    var xScrollleft;
    if (self.pageYOffset || self.pageXOffset) {
        yScrolltop = self.pageYOffset;
        xScrollleft = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollTop || document.documentElement.scrollLeft ){     // Explorer 6 Strict
        yScrolltop = document.documentElement.scrollTop;
        xScrollleft = document.documentElement.scrollLeft;
    } else if (document.body) {// all other Explorers
        yScrolltop = document.body.scrollTop;
        xScrollleft = document.body.scrollLeft;
    }
    arrayPageScroll = new Array(xScrollleft,yScrolltop) 
    return arrayPageScroll;
}
 