// FLASH HELPER SCRIPTS
function writeTitle()
{
	var file = "/promostores/arcadia/gr/flash/titlebar.swf";

	// gather extra page information
	var flashVars = "loc=" + getFilename();
	
	// output flash tag
	writeFlashTag(file, "/promostores/arcadia/gr/flash/", 770, 54, "#1DBBB0", flashVars);
}

function writeTitleNoLogo()
{
	var file = "/promostores/arcadia/gr/flash/titlebar_nologo.swf";

	// gather extra page information
	var flashVars = "loc=" + getFilename();
	
	// output flash tag
	writeFlashTag(file, "/promostores/arcadia/gr/flash/", 770, 54, "#1DBBB0", flashVars);
}

function writeMenu()
{
	var file = "/promostores/arcadia/gr/flash/mainmenu.swf";

	// gather extra page information
	var flashVars = "loc=" + getFilename();
	
	// output flash tag
	writeFlashTag(file, "/promostores/arcadia/gr/flash/", 201, 540, "#1DBBB0", flashVars);
}

// get filename relative to /promostores/arcadia/gr/
function getFilename ()
{
	// split path into elements
	var pieces = location.pathname.split("/");

	// remove first few bits - empty entry, promostores, arcadia, gr (or gr_dev)
	pieces = pieces.slice(4);

	// if first entry is 'pages', discard this also
	if(pieces[0] == "pages")
		pieces = pieces.slice(1);

	// join everything together again
	var idString = pieces.join("/");

	// and return
	return idString;
}

// write intro flash tag
// uses cookies so intro only plays once per session
function writeIntro()
{
	var file="flash/intro.swf";

	// sort out cookies stuff
	/*var flashVars = "";

	if(getCookie("cogrintro") == null)
		setCookie("cogrintro","skip");
	else
		flashVars = "skipintro=yes";*/
		
	var flashVars = "skipintro=yes";

	// output flash tag
	writeFlashTag(file, "/promostores/arcadia/gr/flash/", 568, 700, "#FFFFFF", flashVars);
}

// write flash tag
function writeFlashTag (file, base, width, height, bgColor, flashvars)
{
	if(base == "")
		base = ".";

	if(flashvars == null)
		flashvars = "";

	var tagStr = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"';
	tagStr += 'WIDTH="' + width + '" HEIGHT="' + height + '">';
	tagStr += '<PARAM NAME="movie" VALUE="' + file + '">';
	tagStr += '<PARAM NAME="bgcolor" VALUE="' + bgColor + '">';
	tagStr += '<PARAM NAME="base" VALUE="' + base + '">';
	tagStr += '<PARAM NAME="flashvars" VALUE="' + flashvars + '">';
	tagStr += '<EMBED src="' + file + '" base="' + base + '" bgcolor="' + bgColor + '" flashvars="' + flashvars + '" WIDTH="' + width + '" HEIGHT="' + height + '" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>';
	tagStr += '</OBJECT>';

	document.write(tagStr);
}

// generic popup
function popUp (url, w, h, centre,scroll)
{
	var x = -1, y = -1;
	if(centre)
	{
		x = (screen.availWidth - w)/2;
		y = (screen.availHeight - h)/2;
	}

	var attrib = "width=" + w + ",height=" + h;
	if(x != -1)
		attrib += ",left=" + x;
	if(y != -1)
		attrib += ",top=" + y;
	if(scroll)
		attrib += ",scrollbars=yes";

	// generate random name so poups aren't reused
	var d = new Date();
	var name = 'cogrPopup' + d.getTime();

	cogrWin = window.open(url, name, attrib);
	
	// if statement in case popup blocker blocked the popup
	if(cogrWin)
		cogrWin.focus();
}