/* ----------------------------------------------------------------
   © Copyright 2004 Joseph Balderson & Joseph Balderson Design
   :: http://www.memoriesofsilence.com ::
   Please share this code, but always give credit where it's due.
   loadFlash v.2.0
------------------------------------------------------------------- */
function initAssertFrames() {
	// ASSERT FRAMESET
	if (top.frames.length != 3) parent.location = "http://www.memoriesofsilence.com/index_main.html"+topParseData();
	//alert("top.frames.length = "+top.frames.length);
}

// parses variable data from top location URL for passing to Assert Frameset code
function topParseData() {
	varLocate = "";
	varLocate += document.location;
	// checks for '?' & '='; if both not present, then return nul string
	if (varLocate.indexOf("?") != -1 && varLocate.indexOf("=") != -1) { // checking for '?' & '='
		// don't need '+1' after 'indexOf("?")' cause we want to include the '?'
		varLocate = varLocate.substr(varLocate.indexOf("?"),varLocate.length); 
		//varLocate = "?pageid=020405"; // sample string
		//alert("varLocate = "+varLocate);
		return varLocate;
	} else {
		//alert("varLocate nul");
		return "";
	}
	
}

// parses variable data from parent location URL ready for passing to flash tags
function parseData() {
	varLocate = "";
	varLocate += parent.document.location;
	// checks for '?' & '='; if both not present, then return nul string
	if (varLocate.indexOf("?") != -1 && varLocate.indexOf("=") != -1) { // checking for '?' & '='
		// don't need '+1' after 'indexOf("?")' cause we want to include the '?'
		varLocate = varLocate.substr(varLocate.indexOf("?"),varLocate.length); 
		//varLocate = "?pageid=020405"; // sample string
		//alert("varLocate = "+varLocate);
		return varLocate;
	} else {
		//alert("varLocate nul");
		return "";
	}
	
}

function loadFlash(movieName, movieWidth, movieHeight, backColour, majorVersion, minorVersion, data, quality) {
	// devNotes: Left out 'menu=false' param cause I'll leave it up to
	// the flash movie to set this with the stage() object.
	// Note we can't use 'if(quality == undefined)' because undefined as a property of the global object does not exist until javascript 1.3, which will crash the function in lower browser versions
	if(typeof(quality) == "undefined"){
		swfquality = "high";
	} else {
		swfquality = quality;
	}
	//alert("quality = "+quality+" | "+ typeof(quality));
	//alert("swfquality = "+swfquality);
	if(data=='passvar') {
		// variable passing, no cache buster
		document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + majorVersion + ",0," + minorVersion + ",0\" width=\"" + movieWidth + "\" height=\"" + movieHeight + "\">");
		document.write("<param name=movie value=\"" + movieName + parseData() + "\">");
		document.write("<param name=quality value=" + swfquality + ">");
		document.write("<PARAM NAME=bgcolor VALUE=#" + backColour + ">");
		document.write("<embed src=\"" + movieName + parseData() + "\" quality=" + swfquality + "  bgcolor=#" + backColour + " pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"" + movieWidth + "\" height=\"" + movieHeight + "\">");
		document.write("</embed></object>");
		//alert("passvar received " + parseData() );
	} else if(data=='nocache') {
		// no variable passing, cache buster
		document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + majorVersion + ",0," + minorVersion + ",0\" width=\"" + movieWidth + "\" height=\"" + movieHeight + "\">");
		document.write("<param name=movie value=\"" + movieName + "?" + (new Date()).getTime() + "\">");
		document.write("<param name=quality value=" + swfquality + ">");
		document.write("<PARAM NAME=bgcolor VALUE=#" + backColour + ">");
		document.write("<embed src=\"" + movieName + "?" +  (new Date()).getTime() + "\" quality=" + swfquality + "  bgcolor=#" + backColour + " pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"" + movieWidth + "\" height=\"" + movieHeight + "\">");
		document.write("</embed></object>");
		//alert("nocache received " + (new Date()).getTime() );
	} else if(data=='passvar-nocache') {
		// no variable passing, cache buster
		document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + majorVersion + ",0," + minorVersion + ",0\" width=\"" + movieWidth + "\" height=\"" + movieHeight + "\">");
		document.write("<param name=movie value=\"" + movieName + "&cb=" + (new Date()).getTime() + "\">");
		document.write("<param name=quality value=" + swfquality + ">");
		document.write("<PARAM NAME=bgcolor VALUE=#" + backColour + ">");
		document.write("<embed src=\"" + movieName + "&cb=" +  (new Date()).getTime() + "\" quality=" + swfquality + "  bgcolor=#" + backColour + " pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"" + movieWidth + "\" height=\"" + movieHeight + "\">");
		document.write("</embed></object>");
		//alert("nocache received " + (new Date()).getTime() );
	} else {
		// no variable passing, no cache buster
		document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + majorVersion + ",0," + minorVersion + ",0\" width=\"" + movieWidth + "\" height=\"" + movieHeight + "\">");
		document.write("<param name=movie value=\"" + movieName + "\">");
		document.write("<param name=quality value=" + swfquality + ">");
		document.write("<PARAM NAME=bgcolor VALUE=#" + backColour + ">");
		document.write("<embed src=\"" + movieName + "\" quality=" + swfquality + "  bgcolor=#" + backColour + " pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"" + movieWidth + "\" height=\"" + movieHeight + "\">");
		document.write("</embed></object>");
		//alert("[other] received");
	}
}