var STTAFINTRO = {

	divStillInside: true,

    positionDiv : function(divObj)
    {
		if(STTAFINTRO.divStillInside)
		{
			// remove the div from the parent container and put it inside the body directly
			
			var divToBeRemoved = document.getElementById("widgetContainer");
			var htmlContent = '<div id = "widgetHeader"></div><div id = "contant"><div id = "conbox"><p>Please note that you are leaving Santa\'s List on the Family.com site. If you accept these terms and conditions, please press "continue" below to use this tool</p><ul><li><a href = "javascript: callTAFPopup()" style = "cursor:pointer">&nbsp;</a></li><li class = "nthanks"><a style = "cursor:pointer" onclick = "closeTAFIntro();">No thanks.</a></li></ul></div></div><div id = "widgetFooter"><a href = "http://tellafriend.socialtwist.com/privacy-policy" target = "_blank">Privacy Policy</a> | <a href = "http://tellafriend.socialtwist.com/terms-of-use" target = "_blank">Terms of Use</a></div>';

			divToBeRemoved.parentNode.removeChild(divToBeRemoved);
			
			var stIntroDiv = document.createElement('div');
			stIntroDiv.setAttribute('id', 'widgetContainer');
			
			var introDivHTML = htmlContent;
			
			stIntroDiv.innerHTML = introDivHTML;
			document.body.appendChild(stIntroDiv);
		
			STTAFINTRO.divStillInside = false;
		}	
	
	    var divObj = document.getElementById("widgetContainer");
        var scrollXY = STTAFFUNC.scrollXY();
        var h = (STTAFFUNC.GetHeight() / 2) - (546 / 2);
        var w = (STTAFFUNC.GetWidth() / 2) - (481 / 2);

        divObj.style.left = w + "px";
        divObj.style.top = h + "px";

        // lets create the overlay
        var overlay = document.createElement('div');
        overlay.setAttribute('id', 'st-overlay');
        var ocs = overlay.style;
        var isIE6 = (window.external && typeof window.XMLHttpRequest == "undefined");
        if (isIE6) {
            ocs.position = 'absolute';
            ocs.height = "2000px";
        } else {
            ocs.position = 'fixed';
            ocs.height = '100%';
        }
        ocs.zIndex = 9990;
        ocs.top = 0;
        ocs.left = 0;
        ocs.width = '100%';
        ocs.backgroundColor = 'black';
        ocs.filter = 'alpha(opacity: 75)';
        ocs.MozOpacity = 0.75;
        ocs.opacity = 0.75;
        document.body.insertBefore(overlay, document.body.firstChild);
		divObj.style.display = 'block';
	}	
}

function windowXY()
{
    var A = 0;
    var B = 0;
    if (typeof (window.innerWidth) == "number") {
        A = window.innerWidth;
        B = window.innerHeight;
    } else
    {
        if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
            A = document.documentElement.clientWidth;
            B = document.documentElement.clientHeight
        } else {
            if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
                A = document.body.clientWidth;
                B = document.body.clientHeight;
            }
        }
    }
    return[A,B];
}

function showDiv()
{
    var width = 479;
    var height = 546;
    var screenSize = windowXY();
    screenHeight = screenSize[1];
    screenWidth = screenSize[0];

    var divObj = document.getElementById("widgetContainer");
    divObj.style.left = ((screenWidth - width) / 2) + "px";
    divObj.style.top = ((screenHeight - height) / 2) + "px";
    divObj.style.display = "block";
}

function closeTAFIntro()
{
    document.getElementById('st-overlay').parentNode.removeChild(document.getElementById('st-overlay'));
    document.getElementById('widgetContainer').style.display = 'none';
}

STTAFFUNC.closeEventFunc = function()
{
	document.getElementById('st-overlay').parentNode.removeChild(document.getElementById('st-overlay'));
}
