var flash_replace = new Array();

//this function adds flash "objects" to an array which will be parsed into the page
//it is called near the top of the page, once for each flash piece that will be parsed into the page
//example function call:		add_flash_replace("body_text","780","409","swf.swf","high","","opaque","#5A4666","6")
//Note:  flashVars MUST BE URLENCODED!
function add_flash_replace(ID,WIDTH,HEIGHT,MOVIE,QUALITY,FLASHVARS,WMODE,BGCOLOR,MIN_FLASH_VERSION) {
	i = flash_replace.length;
	flash_replace[i] = new Array();
	flash_replace[i]['id'] = ID;
	flash_replace[i]['width'] = WIDTH;
	flash_replace[i]['height'] = HEIGHT;
	flash_replace[i]['movie'] = MOVIE;
	flash_replace[i]['quality'] = QUALITY;
	flash_replace[i]['flashVars'] = FLASHVARS;
	flash_replace[i]['wmode'] = WMODE;
	flash_replace[i]['bgcolor'] = BGCOLOR;
	flash_replace[i]['min_flash_version'] = MIN_FLASH_VERSION;
}


//this is where the replace actually happens
//call it once at the bottom of the page
function replace_flash() {
	
	cookies = document.cookie;
	start = cookies.indexOf("FlashVersion=");
	start = start + 13;
	end = cookies.indexOf(";", start);
	if (end == -1) {
		end = cookies.length;
	}
	
	cFlashVersion = (cookies.substring(start, end));

		var flash_obj = new Array();
	
		for (i=0;i<flash_replace.length;i++) {
			if (cFlashVersion >= parseInt(flash_replace[i]['min_flash_version'])) {
				flash_obj[i] = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + flash_replace[i]['width'] + '" height="' + flash_replace[i]['height'] + '">' + "\n";
				flash_obj[i] = flash_obj[i] + '<param name="movie" value="' + flash_replace[i]['movie'] + '">' + "\n";
				flash_obj[i] = flash_obj[i] + '<param name="quality" value="' + flash_replace[i]['quality'] + '">' + "\n";
				flash_obj[i] = flash_obj[i] + '<param name="flashVars" value="' + flash_replace[i]['flashVars'] + '">' + "\n";
				flash_obj[i] = flash_obj[i] + '<param name="wmode" value="' + flash_replace[i]['wmode'] + '">' + "\n";
				flash_obj[i] = flash_obj[i] + '<param name="bgcolor" value="' + flash_replace[i]['bgcolor'] + '">' + "\n";
				flash_obj[i] = flash_obj[i] + '<embed type="application/x-shockwave-flash" width="' + flash_replace[i]['width'] + '" height="' + flash_replace[i]['height']	+ '" ';
				flash_obj[i] = flash_obj[i] + 'src="' + flash_replace[i]['movie'] + '" quality="' + flash_replace[i]['quality'] + '" wmode="' + flash_replace[i]['wmode'] + '" flashVars="' + flash_replace[i]['flashVars'] + '" bgcolor="' + flash_replace[i]['bgcolor'] + '" />' + "\n"; 
				flash_obj[i] = flash_obj[i] + '</object>' + "\n";
			
				document.getElementById(flash_replace[i]['id']).innerHTML=flash_obj[i];
			
			}
		}
}
