﻿/* 2008-02-27 Erik Lidälv,
This code is used to open the Temporary start page and the customized Popups
that are used in the system. */

//Remove this function when the intro-flash is removed! After that, use the CloseTemporaryStartPage() function!
function closeIF(obj)
{
    //parent.document.forms[0].submit();
    window.location.reload(); 
}

//Closes the temporay start-page
function CloseStartPage()
{
    parent.document.forms[0].submit(); 
}


//Init the popup function
function InitPopupPage()
{
    // Add the HTML to the body
    theBody = document.getElementsByTagName('BODY')[0];
    popmask = document.createElement('div');
    popmask.id = 'DivPopupPageMask';
    popmask.innerHTML = '' +
        '<div id="popupInner2" style="margin-top: 0px; margin-left: 0px; width:100%; height:100%;">' +
            '<div id="popupTitleBar2">' +
				'<div id="popupTitle2"></div>' +
				'<div id="popupControls2">' +
					'<img src="/templates/Oriflame/Styles/Images/Icons/close.gif" alt="Close this window" onclick="ClosePopupPage();" id="popCloseBox" />' +
				'</div>' +
			'</div>' +
            '<iframe src="/Templates/Oriflame/Pages/loading.html" style="width:100%;height:100%;background-color:transparent;" scrolling="no" frameborder="0" allowtransparency="true" id="popupFrame2" name="popupFrame2" width="100%" height="100%"></iframe>' +
        '</div>';
    theBody.appendChild(popmask);
    
    gPopupMask2 = document.getElementById("DivPopupPageMask");
    gPopupContainer2 = document.getElementById("popupInner2");
    gPopFrame2 = document.getElementById("popupFrame2");
    
    gPopupMask2.style.display = "none";
    gPopupContainer2.style.display = "none";
    gPopFrame2.src = "Templates/Oriflame/Pages/loading.html";
    
}
//addEvent(window, "load", InitPopupPage);


// Open a popup window
function OpenPopupPage(url, width, height, left, top)
{
    gPopupMask2 = document.getElementById("DivPopupPageMask");
    gPopupContainer2 = document.getElementById("popupInner2");
    gPopFrame2 = document.getElementById("popupFrame2");
    
    gPopupContainer2.style.marginLeft = left;
    gPopupContainer2.style.marginTop = top;
    gPopupContainer2.style.width = width;
    gPopupContainer2.style.height = height;
    setMaskSize2();
    gPopupMask2.style.display = "block";
    gPopupContainer2.style.display = "block";
    gPopFrame2.src = url;
}
        
// Close the popup window
function ClosePopupPage()
{
    var theBody = document.getElementsByTagName("BODY")[0];
    theBody.style.overflow = "";
    
    gPopupMask2 = parent.document.getElementById("DivPopupPageMask");
    gPopupContainer2 = parent.document.getElementById("popupInner2");
    gPopFrame2 = parent.document.getElementById("popupFrame2");

    gPopupMask2.style.display = "none";
    gPopupContainer2.style.display = "none";
    gPopFrame2.src = "Templates/Oriflame/Pages/loading.html";

}

function setMaskSize2() {
	var theBody = document.getElementsByTagName("BODY")[0];
	gPopupMask2 = document.getElementById("DivPopupPageMask");
			
	var fullHeight = getViewportHeight();
	var fullWidth = getViewportWidth();
	
	// Determine what's bigger, scrollHeight or fullHeight / width
	if (fullHeight > theBody.scrollHeight) {
		popHeight = fullHeight;
	} else {
		popHeight = theBody.scrollHeight;
	}
	
	if (fullWidth > theBody.scrollWidth) {
		popWidth = fullWidth;
	} else {
		popWidth = theBody.scrollWidth;
	}
	
	gPopupMask2.style.height = popHeight + "px";
	gPopupMask2.style.width = popWidth + "px";
}