// namespace
var bigvars = {};

function getBigVar($str)
{
	return bigvars[$str];
};

function setBigVar($str,$value)
{
	bigvars[$str] = $value;
	return $value;
};

// flashvars
setBigVar("id",xLocation.Search['id']);
setBigVar("s",xLocation.Search['s']);
setBigVar("l",xLocation.Search['l']);
setBigVar("shellType",xLocation.Search['shellType']);
setBigVar("fv","l="+getBigVar("l")+"&s="+getBigVar("s")+"&id="+getBigVar("id")+"&shellType="+getBigVar("shellType"));

// js vars
setBigVar("window_count",0);
setBigVar("testPopUpBlocker",true);

setBigVar("stageheight",610);
setBigVar("flashcontent");
setBigVar("wholepage");

function track($obj)
{
	var code = $obj.sectionCode+"~"+$obj.sectionName+"~"+   (($obj.pageCode != "") ? $obj.pageCode+"~"+$obj.pageName : "");
	code = code.split("~null").join("");
	if (window.changestate) { changestate (code) }
//	alert("tracking: " + code);
};

function popWindow($obj)
{
	if(isBlocked() == false) xWindow.openCenterScroll($obj.url,"new_win_"+getBigVar("window_count"),$obj.w,$obj.h);
	setBigVar("window_count",getBigVar("window_count")++);
};

function popWindowFull($obj)
{
	if(isBlocked() == false) xWindow.openCenterFull($obj.url,"new_win_"+getBigVar("window_count"),xScreen.getWidth(),xScreen.getHeight());
	setBigVar("window_count",getBigVar("window_count")++);
};	

function popWallpaper($obj)
{
	if(isBlocked() == false) xWindow.openCenterScroll("html/popWallpaper.html?img="+$obj.file+"&w="+$obj.w+"&h="+$obj.h,"new_win_"+getBigVar("window_count"),$obj.w,$obj.h);
	setBigVar("window_count",getBigVar("window_count")++);
};

function isBlocked()
{
	if(getBigVar("testPopUpBlocker") == false) return false;
	test_window = window.open('popTest.html','test_window','width=1,height=1,left=0,top=0,scrollbars=no');
	var blocked = new Boolean(test_window == null);
	if(blocked == true) alert("Please Enable Popup Windows.");
	return blocked;
};	

function init()
{
	setBigVar("flashcontent",new xElementObject("flash"));
	setBigVar("wholepage",new xElementObject("wholepage"));

	xWindow.addEvent("resize");
	xWindow.addListener("resize", "onWindowResize");
	onWindowResize();
};

function setHeight(h)
{
	var setH = Math.max(h, xWindow.getHeight()-1);
	getBigVar("flashcontent").setHeight(setH);
	setBigVar("stageheight",h);
//	alert("setHeight: " + h + " vs. " + xWindow.getHeight());
};

function onWindowResize()
{
	setHeight(getBigVar("stageheight"));
};