﻿


var fv = new Object();
fv.documentLocation = window.document.location;

function createArchive(type, archivePath){
	fv.componentType= type; //default 756x258//small 538x300//smallext 559x300//large 756X556
	fv.archiveXML = archivePath; //"../xml/archive_first_column.xml";
	fv.window_width = 0;
	fv.window_height = 0;	
	fv.headerURL = "";
	fv.headerText = headerText;
	fv.headerTagline = headerTagline;
	fv.runAsDeveloper = runAsDeveloper;

	this.setHeight();
	this.archive_renderFlash(archive_buildQuery());
}

function archive_addConditional(strVar, queryVars){
	var strValue = "";
	if(!queryVars[strVar]){
		strValue = "&"+strVar+"="+escape(fv[strVar]);
	}
	return strValue;
}
		
function setHeight(){
	if(fv.componentType == "default"){
		fv.window_width = 756;
		fv.window_height = 258;
		fv.headerURL = defaultHeader;
	}else if(fv.componentType == "small"){
		fv.window_width = 559;
		fv.window_height = 300;
		fv.headerURL = smallHeader;
	}else if(fv.componentType == "smallext"){
		fv.window_width = 559;
		fv.window_height = 300;
		fv.headerURL = smallextHeader;
	}else{
		fv.window_width = 756;
		fv.window_height = 556;
		fv.headerURL = largeHeader;
	
	}
}

function archive_parseQuery(q_str){
  	 	var pairHalves;
  	 	var queryVars = {};
   		var N_V_pairs = q_str.split("&");
   		var l = N_V_pairs.length;
   		for(i=0; i<l; i++){
       		pairHalves = N_V_pairs[i].split("=");
       		queryVars[pairHalves[0]] = pairHalves[1];
   		}
   		return queryVars;
}

function archive_buildQuery(){
	var strQuery = "";
	var queryVars = "";
	strQuery = new String(parent.window.location.search);
	strQuery = strQuery.substr(1);
	queryVars = archive_parseQuery (strQuery);
	strQuery += "&archiveXML="+escape(fv.archiveXML);
	strQuery += "&componentType="+escape(fv.componentType);
	strQuery += "&window_width="+escape(fv.window_width);
	strQuery += "&window_height="+escape(fv.window_height);
	strQuery += "&headerURL="+escape(fv.headerURL);
	strQuery += "&documentLocation="+escape(fv.documentLocation);
	strQuery += "&headerText="+escape(fv.headerText);
	strQuery += "&headerTagline="+escape(fv.headerTagline);
	strQuery += archive_addConditional("deeplinkId_a", queryVars);
	strQuery += archive_addConditional("deeplinkId_b", queryVars);
	strQuery += archive_addConditional("deeplinkURL", queryVars);
	strQuery += "&runAsDeveloper="+escape(fv.runAsDeveloper);
	return strQuery;
}

function archive_renderFlash(strVars){
	var numFheight;
	var numFwidth;
	var strID = "archive";
	var strSwf = flashLocation;

	numFwidth = fv.window_width;
	numFheight = fv.window_height;
	
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+numFwidth+'" height="'+numFheight+'" id="'+strID+'" align="rigth">');
	document.write('<param name="allowScriptAccess" value="always" />');
	document.write('<param name="movie" value="'+strSwf+'" />');
	document.write('<param name="FlashVars" value="'+strVars+'"/>');
	document.write('<param name="quality" value="best" />');
	document.write('<param name="bgcolor" value="#FFFFFF" />');
	document.write('<param name="wmode" value="opaque" />');
	document.write('<param name="scale" value="noscale" />');
	document.write('<param name="salign" value = "tl" />');
	document.write('<embed src="'+strSwf+'" swLiveConnect="true" wmode="opaque" FlashVars="'+strVars+'"  scale="noscale" salign="tl"  quality="best" bgcolor="#FFFFFF" width="'+numFwidth+'" height="'+numFheight+'" name="browser" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}


