﻿//
//misc functions for the placement of floating flash content

// requires cookieCreator.js 
// requires a div with the id 'flashBox'

//start and end dates (format is yyyy, mm(-1), dd)
var flashSource = "/where/imap/ammap.swf";
var flashWidth = "900";
var flashHeight = "500";

//set devMode to false to hide all alerts and the cookie reset things.
var devMode = false;

function init(){
	loadInTheFlash();
	//load the additional CSS
	loadcssfile('flashOver.css');
}


//get rid of the flashContent
function hideDiv() {
	document.getElementById("flashBox").style.visable = "none";
	document.getElementById("flashBoxContainer").style.display = "none";
}


function loadInTheFlash() {
	var flashvars = {
	data_file: "/where/imap/ammap_data.xml",
   	settings_file: "/where/imap/ammap_settings.xml",
	path:		"/where/imap/"
	};
	var params = {};
	params.wmode = "transparent";
	var attributes = {
    	};
	swfobject.embedSWF(flashSource, "flashBox", flashWidth, flashHeight, "9.0.0", false, flashvars, params, attributes);
	//and position it in the middle...

	editCSSValues();
}

function loadcssfile(filename){
	var headID = document.getElementsByTagName("head")[0];
	var cssNode = document.createElement('link');
	cssNode.type = 'text/css';
	cssNode.rel = 'stylesheet';
	cssNode.href = filename;
	cssNode.media = 'screen';
	headID.appendChild(cssNode);
}

function editCSSValues(){
	var closetab= "<a href='#'><img src='/where/images/close-btn.jpg'/></a>";
	document.getElementById("flashBox").style.display = "block";
	document.getElementById("flashBoxContainer").style.display = "block";
	document.getElementById("closebox").innerHTML="<img src='/where/images/close-btn.jpg'/>";
	//adjust values in the loaded CSS to make it centered in the window:
	var leftMargin = (GetWidth()/2)-(document.getElementById("flashBoxContainer").width/2);
	var topMargin = (GetHeight()/2)-(document.getElementById("flashBoxContainer").height/2);
	//alert(topMargin + " <- top | left -> "+ leftMargin);
	document.getElementById("flashBoxContainer").style.left = leftMargin+"px";
	document.getElementById("flashBoxContainer").style.top = topMargin+"px";	
}

function GetWidth()
{
        var x = 0;
        if (self.innerHeight)
        {
                x = self.innerWidth;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
                x = document.documentElement.clientWidth;
        }
        else if (document.body)
        {
                x = document.body.clientWidth;
        }
        return x;
}
 
function GetHeight()
{
        var y = 0;
        if (self.innerHeight)
        {
                y = self.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
                y = document.documentElement.clientHeight;
        }
        else if (document.body)
        {
                y = document.body.clientHeight;
        }
        return y;
}


window.onload = function() {
	document.getElementById("flashBox").style.visable = "none";
	document.getElementById("flashBoxContainer").style.display = "none";
	}



