
 
 Module = function(id,ter,nm,bg) {
	 this.contentId = id;
	 this.territory = ter;
	 this.contentName = nm;
	 this.bgcolor = bg;
 }
 

 Module.prototype.dimensions = [[300,300],[400,400]]
 Module.prototype.territory = "";
 Module.prototype.contentId = 0;
 Module.prototype.contentRoot = "";
 Module.prototype.contentName = "300content";
 Module.prototype.contentFolder = "";
 
 Module.prototype.getContentObject = function() {
	 var w=this.dimensions[this.contentId][0];
	var  h=this.dimensions[this.contentId][1];
	 //var url = this.contentRoot + this.territory + "/" + this.contentFolder + "/";
	 var url = this.territory;
	 var fname = "400x400.swf";
	 var fo = new FlashObject(url + fname, this.contentName,w,h,6,this.bgcolor);
	 fo.addVariable("territory", this.territory);
	 fo.addVariable("jsObject", this.objName);
	 fo.addVariable("dim", w+"x"+h); 
	 fo.addParam("allowScriptAccess","always");
	 fo.addParam("scaleMode","noscale");
	 fo.addParam("salign","TL");
	 return fo;
 }
 
  Module.prototype.write = function() {
	this.getContentObject().write(); 
 }

  
//Banner = function(bannerid,ter,objName,bgcolor,xloc,yloc) {
Banner = function(bannerid,ter,objName,bgcolor,xloc,yloc) {
  
	 this.territory = ter
	 this.bannerId = bannerid;
	 this.objName = objName;
	 this.bgcolor = bgcolor;
	 this.xloc = xloc;
	 this.yloc = yloc;
 }

 Banner.prototype.banners = [[100,100],[234,60],[468,60],[120,90],[300,250]];
 Banner.prototype.bannerRoot = "";
 Banner.prototype.bannerFolder = "";
 Banner.prototype.territory = "";
 Banner.prototype.bannerName = "300banners";
 Banner.prototype.bannerId = 0;
 Banner.prototype.contentRoot = "";
 Banner.prototype.contentName = "300content";
 Banner.prototype.contentFolder = "";
 Banner.prototype.xloc = 0;
 Banner.prototype.yloc = 0;
 
 Banner.prototype.getBannerObject = function() {
	
	 var w =this.banners[this.bannerId][0];
	 var h =this.banners[this.bannerId][1];
	 //var url = this.bannerRoot + this.territory + "/" + this.bannerFolder + "/";
	 var url = this.territory;
	 var fname =  w + "x" + h +".swf";
	 var fo = new FlashObject(url + fname, this.bannerName, w, h,6,this.bgcolor);
	 fo.addVariable("territory", this.territory);
	 fo.addVariable("jsObject", this.objName);
	 fo.addParam("allowScriptAccess","always");
	 fo.addParam("scaleMode","noscale");
	 fo.addParam("salign","TL");
	 return fo;
 }
 

 
 Banner.prototype.getContentObject = function() {
	 var w=400;
	 var h=400;
	 //var url = this.contentRoot + this.territory + "/" + this.contentFolder + "/";
	 var url = this.territory;
	 var fname = "400x400.swf";
	 var fo = new FlashObject(url + fname, this.contentName,w,h,8,this.bgcolor);
	 fo.addVariable("territory", this.territory);
	 fo.addVariable("showClose","true");
	 fo.addVariable("jsObject", this.objName);
	 fo.addVariable("dim", "400x400"); 
	 fo.addParam("allowScriptAccess","always");
	  fo.addParam("scaleMode","noscale");
	  fo.addParam("salign","TL");
	 return fo;
 }
 
 Banner.prototype.write = function() {
	
	 this.getBannerObject().write();
	 document.write("<div id=\""+this.objName+"\" style=\"position:absolute; z-index: 100;visibility:hidden;left:" + this.xloc + "px;top:"+this.yloc+"px;width:400px;height:400px;background-color:"+this.bgcolor+"\">");
	 this.getContentObject().write();
	 document.write("</div>");
 }
 
 Banner.prototype.hide = function() {
 		document.getElementById(this.objName).style.visibility="hidden";
		//var ie=document.all;
		//var dom=document.getElementById;
		//var obj=(dom)?document.getElementById(this.objName).style : ie? //document.all.dropin : document.dropin
		//obj.visibility="hidden";
 }

 Banner.prototype.show = function() {
 	document.getElementById(this.objName).style.visibility="visible";
 /*
	 var ie=document.all;
	 var dom=document.getElementById;
	 var obj=(dom)?document.getElementById(this.objName).style : ie? document.all.dropin : document.dropin;
	 obj.visibility=(dom||ie)? "visible" : "show";
	 */
 }
 
 
 

FlashObject = function(swf, id, w, h, ver, c) {
	this.swf = swf;
	this.id = id;
	this.width = w;
	this.height = h;
	this.version = ver || 8; // default to 6
	this.align = "middle"; // default to middle
	this.codebase = this.version +",0,0,0"; // fix cab download
	this.redirect = "";
	this.sq = document.location.search.split("?")[1] || "";
	this.altTxt = "Please <a href='http://www.macromedia.com/go/getflashplayer'>upgrade your Flash Player</a>.";
	this.bypassTxt = "<p>Already have Flash Player? <a href='?detectflash=false&"+ this.sq +"'>Click here if you have Flash Player "+ this.version +" installed</a>.</p>";
	this.params = new Object();
	this.variables = new Object();
	if (c) this.color = this.addParam('bgcolor', c);
	this.addParam('quality', 'high'); // default to high
	this.doDetect = getQueryParamValue('detectflash');
}

FlashObject.prototype.addParam = function(name, value) {
	this.params[name] = value;
}

FlashObject.prototype.getParams = function() {
    return this.params;
}

FlashObject.prototype.getParam = function(name) {
    return this.params[name];
}

FlashObject.prototype.addVariable = function(name, value) {
	this.variables[name] = value;
}

FlashObject.prototype.getVariable = function(name) {
    return this.variables[name];
}

FlashObject.prototype.getVariables = function() {
    return this.variables;
}

FlashObject.prototype.getParamTags = function() {
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    if (paramTags == "") {
        paramTags = null;
    }
    return paramTags;
}

FlashObject.prototype.getHTML = function() {
    var flashHTML = "";
    if (window.ActiveXObject && navigator.userAgent.indexOf('Mac') == -1) { // PC IE
        flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+ this.codebase +'" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '">';
        flashHTML += '<param name="movie" value="' + this.swf + '" />';
        if (this.getParamTags() != null) {
            flashHTML += this.getParamTags();
        }
        if (this.getVariablePairs() != null) {
            flashHTML += '<param name="flashVars" value="' + this.getVariablePairs() + '" />';
        }
        flashHTML += '</object>';
    }
    else { // Everyone else
        flashHTML += '<embed type="application/x-shockwave-flash" src="' + this.swf + '" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '"';
        for (var param in this.getParams()) {
            flashHTML += ' ' + param + '="' + this.getParam(param) + '"';
        }
        if (this.getVariablePairs() != null) {
            flashHTML += ' flashVars="' + this.getVariablePairs() + '"';
        }
        flashHTML += '></embed>';
    }
    return flashHTML;	
}


FlashObject.prototype.getVariablePairs = function() {
    var variablePairs = new Array();
    for (var name in this.getVariables()) {
        variablePairs.push(name + "=" + escape(this.getVariable(name)));
    }
    if (variablePairs.length > 0) {
        return variablePairs.join("&");
    }
    else {
        return null;
    }
}

FlashObject.prototype.write = function(elementId) {
	if(detectFlash(this.version) || this.doDetect=='false') {
		if (elementId) {
			document.getElementById(elementId).innerHTML = this.getHTML();
		} else {
			document.write(this.getHTML());
		}
	} else {
		if (this.redirect != "") {
			document.location.replace(this.redirect);
		}
		document.write(this.altTxt +""+ this.bypassTxt);
	}		
}

function getFlashVersion() {
	var flashversion = 0;
	if (navigator.plugins && navigator.plugins.length) {
		var x = navigator.plugins["Shockwave Flash"];
		if(x){
			if (x.description) {
				var y = x.description;
	   			flashversion = y.charAt(y.indexOf('.')-1);
			}
		}
	} else {
		result = false;
	    for(var i = 15; i >= 3 && result != true; i--){
   			execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
   			flashversion = i;
   		}
	}
	return flashversion;
}

function detectFlash(ver) {	
	if (getFlashVersion() >= ver) {
		return true;
	} else {
		return false;
	}
}

// get value of querystring param
function getQueryParamValue(param) {
	var q = document.location.search;
	var detectIndex = q.indexOf(param);
	if(q.length > 1 && detectIndex != -1) {
		return q.substring(q.indexOf("=", detectIndex)+1, q.indexOf("&", detectIndex));
	} else {
		return true;
	}
}

