mediaList = new Array();

function Media(type){
	this.type = type;
}

Media.prototype.showMedia = function(type){
	if (this.type.toLowerCase() == "mov") this.showMov();
	if (this.type.toLowerCase() == "swf") this.detectFlash();
}


Media.prototype.detectFlash = function(){
	if (this.exists(flashVersion)){
				
		if (this.isLayer && useLayer){
			flashPresent=1;
			document.write("<div"+" id=\"flashLayer\" class=\"flashLayerClass\">")
		}
		if (flashVersion >= this.minVersion){
			this.addMedia();
			this.showSwf();
		}
		else this.showAlt();
		if (this.isLayer && useLayer) document.write("</div>");
		if ( (isMac && isIE) || (isN6) ) dhtml = 0;
	}
}


Media.prototype.showSwf = function(type){
	
	this.setMovieLoc();	
	this.setFlashVars();
	
	if (this.name == "false"){
		this.name = "swf"+mediaList.length;
	}

	document.writeln("<" + "OBJECT CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" id=\"" + this.name + "\" ");
	document.writeln(" CODEBASE=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" "); 
	document.writeln(" WIDTH=" + this.width + " HEIGHT=" + this.height);
	
	if (this.usePopup) document.writeln(" onMouseUp=\"Media.prototype.doAction()\" ");
	
	document.writeln(" > ");	
	document.writeln(" <"+"PARAM NAME=MOVIE VALUE=" + this.movieLoc + "> ");
	document.writeln(" <"+"PARAM NAME=PLAY VALUE=true> ");
	document.writeln(" <"+"PARAM NAME=LOOP VALUE=true> ");
	if (this.bgcolor != "nobg") document.writeln(" <"+"PARAM NAME=bgcolor VALUE=#" + this.bgcolor + "> ");
	document.writeln(" <"+"PARAM NAME=QUALITY VALUE=best> ");
	
	// Flash Vars 
	document.writeln(" <"+"PARAM NAME=FlashVars VALUE="+this.flashVars+"> ");
		
	document.writeln(" <"+"PARAM NAME=MENU VALUE=" + this.menu + "> ");

	// Revisit
	if ((this.wmode7 && (flashVersion >= 7)) || !this.wmode7){
		document.writeln(" <"+"PARAM NAME=WMODE VALUE=" + this.wmode + ">");
	}
	document.writeln("<EMB"+"ED NAME=\"" + this.name + "\" SRC=" + this.movieLoc + " ");
	
	// Init
	document.writeln("FlashVars=" + this.flashVars + " ");
	document.writeln(" WIDTH=" + this.width + " HEIGHT=" + this.height + " play=true ");
	document.writeln(" loop=true QUALITY=best ALIGN=TOP ");
	if (this.bgcolor != "nobg") document.writeln(" BGCOLOR=#" + this.bgcolor + " ");
	document.writeln(" TYPE=application/x-shockwave-flash ");
	if ((this.wmode7 && (flashVersion >= 7)) || !this.wmode7){
		document.writeln(" wmode=" + this.wmode );
	}
	document.writeln(" PLUGINSPAGE=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\">");
	document.writeln("</EMBED>");
	document.writeln("</OBJECT>");
}


Media.prototype.setFlashVars = function(){

	// AOL Platform.
	this.flashVars = "?plat=" + plat;

	if (this.userName != "null") {
		this.flashVars += "&userName=" + this.userName;
	}
	if (this.vars.length >= 1) {
		this.flashVars += "&"+this.vars;
	}
	
	// flashAdvars
	if (this.useAdvals){
		this.flashVars += "&flashAdvars="+flashAdVars;
	}
	
	// check for custom vars
	if (this.useCustom){
		this.flashVars += "&customVars="+flashCustomVars;
	}
}
Media.prototype.setMovieLoc = function(){
	return this.movieLoc;
}
Media.prototype.showAlt = function(){
	if (this.altPage.length > 1){
		this.showAltPage();
	}
	else if (this.textAlt){
		this.showAltText();
	}
	else {
		this.showAltImage();
	}
}
Media.prototype.showAltPage = function(){
	document.write("<"+"iframe src=\""+this.altPage+"\" width="+this.width+" height="+this.height+" frameborder=0 scrolling="+this.altPageScroll+"></iframe>");
}
Media.prototype.showAltImage = function(){
	var aInn = "";
	var aOut = "";
	var map = (this.usemap != "false")? "usemap=#"+this.usemap+" ": "";
	
	if(this.usemap == "false"){
		aInn = (this.altHref.length > 1)? "<"+"a href=\""+this.altHref+"\">" : "";
		aOut = (this.altHref.length > 1)? "</A>" : "";
	}
	document.write(aInn+"<"+"img src=\""+this.altImage+"\" " + map + " width="+this.width+" height="+this.height+" border=0>"+aOut);
}
Media.prototype.showAltText = function(){
	var aInn = (this.altHref.length >= 1)? "<"+"div style=\"text-align:left;padding:5px;background-color:#EEEEEE;width:"+this.width+"px;height:"+this.height+"px\"><"+"a href=\""+this.altHref+"\" target=\"_blank\">" : "";
	var aOut = (this.altHref.length >= 1)? "</A></div>" : "";
	document.write(aInn+this.altText+aOut);
};
Media.prototype.exists = function(obj){
	return (typeof obj != "undefined")? true: false;
};
Media.prototype.addMedia = function(){
	mediaList[mediaList.length] = this.movieLoc;
};
Media.prototype.debug = function(){
	document.write("<br clear=all>");
	for (var prop in this){
		var obj =  typeof this[prop];
		if (obj =="function")  {
			document.write("");
		}
		else {
			document.write("<B>"+prop+"</B> = " + this[prop] + "\<BR>");
		}
	}
};

function commandObj() {}
argObject = new Object();
action = new commandObj;

Media.prototype.doAction = function() {
	if (commandObj != null) {
		action = new commandObj(argObject.args);
		commandObj = null;
		action = null;
	}
}

