/*
Function Index:
	
	PopupWindow(URL, Height, Width)    * This function will do a popup window to the URL with No Headers
	toggle(IDofDiv)					   * This function will reverse the visable property of the Div
	getObj(name)					   * A replacement for getElementById which is cross browser supported
	getObjNN4(obj, name)			   * Used internally to the getObj method
	getObjStyle(name)				   * get the Style property of a Object.  
	parseHTML(HTMLwithJavascript)	   * this method will return the HTML and run the javascript
	isNumeric(someValue)			   * returns false if the string contains anything other then 0-9
	isFileNameValid(filename)		   * Returns true or false if the filename is a valid filename or not
	isValidEmail(emailAddress)		   * Returns true or false if the email address is valid or not
	maxLengthHandler(TextArea, length) * This is a keydown event that will take the text area and trim it to the length
	replaceSubstring(inputString, fromString, toString)  * this will replace like in VB Script
	hideRow(rowToHide)				   * Hides a row in a table
	showRow(row,displayString)
	showCell(cell,displayString)
	hideCell(cell)
	ButtonMouseOver
	ButtonMouseOut
	
ControlVersion
GetSwfVer
DetectFlashVer
AC_AddExtension
AC_Generateobj
AC_FL_RunContent
AC_GetArgs

swfobject

*/

	function isDate(aDate){
		var tmpDate, result;
		var tmpDate = new Date(aDate);
		isNaN(tmpDate)? result=false : result=true ;
		return result ;
	}
// ---------------------------------------------------------------
//  This function will take a URL a Height and Width and
//  Will do a Window.Open to that window with no Options.
//  The height/Width of the window will be what is passed in
//  Name is not manditory.
// ---------------------------------------------------------------
	function PopupWindow(URL, height, width, name)
	{
		if (URL==""){  
			alert("The URL for the popup function cannot be blank"); 
			return;
		}
		//If the height and width are null then default them to 500
		if (height==null)  height=500;
		if (width==null)   width=500;
		if (name==null)    name = "CommonPopupWindow";
		var returnWindow
		returnWindow=window.open(URL,name,'width=' + width + ',height=' + height +',menubar=no,scrollbars=no,toolbar=no,location=no,directories=no,resizable=yes,top=0,left=0');
		return returnWindow;
	}
	function popup(URL, height, width, name)
	{
		if (URL==""){  
			alert("The URL for the popup function cannot be blank"); 
			return;
		}
		var returnWindow
		if ((height==null)||width==null) {
			returnWindow=window.open(URL,name);
			
		}else{
			returnWindow=window.open(URL,name,'width=' + width + ',height=' + height +',resizable=yes,top=0,left=0');
			
		}
		
		
		
	}


// ---------------------------------------------------------------
//toggle(ID)
//	-  This method will hide or show the div
//  -  If it is visable thus style.display="" it will make it style.display="none"
//  -  if the visabliity is style.display="none"  it will make it style.display=""
// ---------------------------------------------------------------
	function toggle(ID){
		var element = getObj(ID);
		if (element!=null){
			if (element.style.display=="")
				element.style.display="none";
			else
				element.style.display="";
		}
	}
	
	
// ---------------------------------------------------------------
//  getObj(name)
//	-  This method is a replacement for GetElementById.  It is
///    cross browser and will return a pointer to the instance of the object
// ---------------------------------------------------------------
	function getObj(name){
		if(document.getElementById){
			return document.getElementById(name);
		}else if(document.all){
			return document.all[name];
		}else if(document.layers && document.layers[name] != null){
			return getObjNN4(document, name);
		}else{
			return false;
		}
	}

// ---------------------------------------------------------------
//getObjNN4(obj, name)
//	- This method should not be called directly.  it is used
//    internally to all the other GetObj methods.  And is used for netscape
// ---------------------------------------------------------------
	function getObjNN4(obj, name)
	{
		var x = obj.layers;
		var foundLayer;
		for(var i=0;i<x.length;i++)
		{
			if(x[i].id == name)
			{
				foundLayer = x[i];
			}
			else if (x[i].layers.length)
			{
				var tmp = getObjNN4(x[i],name);
			}
			if(tmp)
			{
				foundLayer = tmp;
			}
		}
		if(foundLayer)
		{
			return foundLayer;
		}
		else
		{
			return false;
		}
	}

// ---------------------------------------------------------------
// getObjStyle(name)
//	- This method will get the Style property of the object in question
//  -  This is cross browser supported
// ---------------------------------------------------------------
	function getObjStyle(name)
	{
		if(document.getElementById)  
		{
			return document.getElementById(name).style;
		}
		else if(document.all)
		{
			return document.all[name].style;
		}
		else if(document.layers)
		{
			return getObjNN4(document, name);
		}
	}

// ---------------------------------------------------------------
//  showRow(rowToShow, optional DisplayString block or inline)
//  -  This method takes in a javascript row object and makes it
//		visible using the display property.  This should work
//		on all platforms and most browsers including firefox,
//		ie6, ie7, and safari
// ---------------------------------------------------------------
	function showRow(row,displayString){
		try{
			row.style.display="table-row";
		} catch (e) {
			if (displayString == null){
				displayString = "block";
			}
			row.style.display = displayString;
		}
	}

// ---------------------------------------------------------------
//  hideRow(rowToHide)
//  -  This method takes in a javascript row object and makes it
//		invisible using the display property. 
// ---------------------------------------------------------------
	function hideRow(row){
		row.style.display="none";
	}

// ---------------------------------------------------------------
//  showCell(cellToShow, optional DisplayString block or inline)
//  -  This method takes in a javascript cell object and makes it
//		visible using the display property.  This should work
//		on all platforms and most browsers including firefox,
//		ie6, ie7, and safari
// ---------------------------------------------------------------
	function showCell(cell,displayString){
		try{
			cell.style.display="table-cell";
		} catch (e) {
			if (displayString == null){
				displayString = "block";
			}
			cell.style.display = displayString;
		}
	}

// ---------------------------------------------------------------
//  hideCell(cellToHide)
//  -  This method takes in a javascript Cell object and makes it
//		invisible using the display property. 
// ---------------------------------------------------------------
	function hideCell(cell){
		cell.style.display="none";
	}


// ---------------------------------------------------------------
//  parseHTML(HTMLwithJavascript)
//  -  This method will take in some HTML that is typically returned from an Ajax Call
//    and then it will look for Javascript in the string and run it.  parse out the javascript
//   then just return the HTML
// ---------------------------------------------------------------
	function parseHTML(result){
		//var re = new RegExp('\<scr'+'ipt\\b\[\^\>\]\*\>(.*)<\/sc'+'ript\>', "g");
		var re =new RegExp('<scr'+'ipt [\\S+].*>([^<]+|.*?)?</scr'+'ipt>', "g");
		var Javascript = re.exec(result);
		
		//<(\S+).*>(.*)<

		var HTML	   = result.replace(re, "")
		if (Javascript!=null){
			for (var i=1;i<Javascript.length;i++){
			//alert(Javascript[i]);
				eval(Javascript[i]);
			}
		}
		
		return HTML;
	}
// ---------------------------------------------------------------
//  This method takes a script tag as a string like
// <scr ipt>  someJavascriptHere() </scr ipt>  and then
//  executes the code between the script tags
// ---------------------------------------------------------------
	function parseJavascript(result){

		var re = new RegExp('\<scr'+'ipt\\b\[\^\>\]\*\>\(\.\*\?\)\<\/sc'+'ript\>', "g");
		var Javascript = re.exec(result)[1];
		
		return Javascript;
		
	}
 
// ---------------------------------------------------------------
//  This method insures that its only a number either whole
//  number or a floating point number.  Thus the string must
//  contain 0 to 9 or a .
// ---------------------------------------------------------------
	function isNumeric(sText)
		{
		var ValidChars =	"0123456789.";
		var IsNumber=true;
		var Char;  
		for (i =	0; i < sText.length	&& IsNumber	== true; i++)
			{
			Char = sText.charAt(i);
			if (ValidChars.indexOf(Char) == -1)
				{
				IsNumber =	false;
				}
			}
		return IsNumber;
		}  

// ---------------------------------------------------------------
//   This method tells us if a file name is in a valid format or not
//  It cannot contain spaces, or some special charactesr.  so we
//  are only allowing a-z 0-9 . and a .htm extention
// ---------------------------------------------------------------
	function isFileNameValid(valin){
				// \W - any non ASCII word character (not a-z, 0-9)
			var strCompare = /\W*\s/;
			var result = valin.match(strCompare);
			
			var strCompareII = /((\?)|(\))|(\()|(\*)|(\&)|(\^)|(\%)|(\$)|(\#)|(\@)|(\!))/;
			var resultII = valin.match(strCompareII);
			
			var strCompareIII = /^(.*(\.)htm)/;
			var resultIII = valin.match(strCompareIII);
			
			var strCompareIIII = /[^m|^l]$/;
			var resultIIII = valin.match(strCompareIIII);
			
			var strResult = "";
			 
			if ((valin == null) || (valin == '')) {
				strResult = "bad";
			}
			if ((result != null) && (result != '/')) {
				strResult = "bad";
			}
			if (resultII != null) {
				strResult = "bad";
			}
			if (resultIII == null) {
				strResult = "bad";
			}
			if (resultIIII != null) {
				strResult = "bad";
			}
			if (strResult != "") {
				//alert ('The value entered is not of the correct format');
				return false;
			}
			else {
				//alert ('The value entered is of the correct format');
				return true;
			}
		}


// ---------------------------------------------------------------
//  This method will return true if the email is in a valid format
//  and will return false if it is not.
// ---------------------------------------------------------------
	function isValidEmail(emailAddress){
		//var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
		//if(emailAddress.search(/^([0-9a-zA-Z]+([_&\.-]?[0-9a-zA-Z]+[_]?)*@[0-9a-zA-Z]+[0-9,a-z,A-Z,\.,-]*(\.){1}[a-zA-Z]{2,4})$/i) == -1){
		if(emailAddress.search(/^[a-zA-Z0-9\._%\+\-]+@[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/i) == -1){
			return false;
		}
		return true;
		//var regex = new RegExp(emailReg);
		//return regex.test(emailAddress);
	}

// ---------------------------------------------------------------
// THis function is a Handler for the max length.  you can put it on the onchange
// event of some text area and it will ensure that the length isn't longer then that.
// ---------------------------------------------------------------
	function maxLengthHandler(textarea, length, showmessage){
		if (!showmessage) showmessage=false;
		var x = new String();
		
		if (textarea.value.length>length){
			textarea.value = textarea.value.substr(0, length);
			if (showmessage){
				alert("The number of characters was too long.  \nIt has been trimmed to " + length + " characters")
			}
		}
	}
	
	/***********************************************************************************/
function replaceSubstring(inputString, fromString, toString) {
   // Goes through the inputString and replaces every occurrence of fromString with toString
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function

function ButtonMouseOver(obj){
	obj.style.backgroundColor='#1B334E'
	 
}
function ButtonMouseOut(obj){
	obj.style.backgroundColor='#7194BA'
}


/* FLASH DETECTION */

// Flash Player Version Detection - Rev 1.6
// Detect Client Browser type
// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			//version = -1;
		}
	}
	
	if (!version){
		for (i=25;i>0;i--){
			document.write('<script language=VBScript>\n' + 
			'on error resume next\n' + 
			'Dim swControl, swVersion\n' + 
			'swVersion = 0\n' + 
			'set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))\n' + 
			'if (IsObject(swControl)) then\n' + 
			'	swVersion = swControl.GetVariable("$version")\n' + 
			'end if\n' + 
			'</script>\n');
			try {
				if(swVersion != 0){
					version = swVersion;
					break;
				}else{
					version = -1;
				}
			} catch (e) {
				version = -1;
			}
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
		//alert(navigator.plugins.length);
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	//alert("flashVer="+flashVer);
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
    var str = '';
    if (isIE && isWin && !isOpera)
    {
  		str += '<object ';
  		for (var i in objAttrs)
  			str += i + '="' + objAttrs[i] + '" ';
  		for (var i in params)
  			str += '><param name="' + i + '" value="' + params[i] + '" /> ';
  		str += '></object>';
    } else {
  		str += '<embed ';
  		for (var i in embedAttrs)
  			str += i + '="' + embedAttrs[i] + '" ';
  		str += '> </embed>';
    }

    document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "id":
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

if(typeof swfobject === 'undefined'){
	var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();
}

/* FLASH DETECTION */

/* MEDIA PLAYER DETECTION */

// TODO: compile to format similar to swfobject
// set some globals so the detection only happens once per page load
var MEDIAALREADYDETECTED = false;
var FLIPDETECTED = false;
var MEDIAPLAYERDETECTED = false;
var QUICKTIMEDETECTED = false;
var VBDETECTIONWRITTEN = false;

function DetectPlayer(id, ftype, width, height, error, params, istest){
	
	// browser detection
	this.UserAgent = navigator.userAgent.toLowerCase();
	this.IsInternetExplorer  = (this.UserAgent.indexOf("msie") != -1);
	this.IsNetscape  = (navigator.appName.indexOf("Netscape") != -1);
	this.IsWindows = ((this.UserAgent.indexOf("win")!=-1) || (this.UserAgent.indexOf("32bit")!=-1));
	this.IsVista = (this.UserAgent.indexOf("windows nt 6")!=-1);
	
	// set defaults for plugin detection
	this.HasFlip = false;
	this.HasMediaPlayer = false;
	this.HasQuickTime = false;

	try{
		
		if(MEDIAALREADYDETECTED == true){
			this.HasFlip = FLIPDETECTED;
			this.HasMediaPlayer = MEDIAPLAYERDETECTED;
			this.HasQuickTime = QUICKTIMEDETECTED;
		
			// display details of test
			if(istest){
				alert("Already detected:\n\nFlip - " + this.HasFlip + "\nMedia Player - " + this.HasMediaPlayer + "\nQuick Time - " + this.HasQuickTime);
			}
			
		}else{

			if(this.IsInternetExplorer && this.IsWindows){
				this.setupVbScript(id, istest);
				if(this.IsVista){
					this.HasMediaPlayer = this.detectWindowsMedia();
					this.HasQuickTime = this.detectQuickTime();
				}
				if(!this.HasMediaPlayer){
					this.HasMediaPlayer = this.detectIE("MediaPlayer.MediaPlayer.1", "Windows Media Player");
				}
				if(!this.HasQuickTime){
					this.HasQuickTime = this.detectIE("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime");
				}
			}else{
				this.HasMediaPlayer = this.detectNS("application/x-mplayer2", "Windows Media Player");
				this.HasQuickTime = this.detectNS("video/quicktime", "QuickTime");
			}
			QUICKTIMEDETECTED = this.HasQuickTime;
			MEDIAPLAYERDETECTED = this.HasMediaPlayer;
			
			this.HasFlip = this.detectFlip();
			FLIPDETECTED = this.HasFlip;
			
			MEDIAALREADYDETECTED = true;
		
			// display details of test
			if(istest){
				alert("Player detected:\n\nFlip - " + this.HasFlip + "\nMedia Player - " + this.HasMediaPlayer + "\nQuick Time - " + this.HasQuickTime);
			}
		
		}
		
		this.LoadPlayer(id, ftype, width, height, error, params, istest);
		
	}catch(ex){
		
		// display details of test
		if(istest){
			alert("DETECTPLAYER ERROR: " + ex + "\n\n" + ex.description + "\n\n" + ex.linenumber);
		}

		// an error occurred so don't load players
		this.HasFlip = false;
		FLIPDETECTED = false;
		this.HasMediaPlayer = false;
		MEDIAPLAYERDETECTED = false;
		this.HasQuickTime = false;
		QUICKTIMEDETECTED = false;
		
		MEDIAALREADYDETECTED = true;
		
	}
	
}

DetectPlayer.prototype.LoadPlayer = function(id, ftype, width, height, error, params, istest){

	var canLoadPlayer = false;
		
	try {
	
		// check if a player was found
		if(this.HasMediaPlayer || this.HasQuickTime){
		
			// determine if its a WMA or WMV file
			var isWmvOrWma = this.isWmvWmaFile(ftype);
			
			// determine if its a MOV or MP4 file
			var isMovOrMp4 = this.isMovOrMp4File(ftype)
			
			// check for windows media specific files
			if(isWmvOrWma){
				// check for media player or quicktime with flip plugin
				if(this.HasMediaPlayer || (this.HasQuickTime && this.HasFlip)){
	
					// display details of test
					if(istest){
						alert("This is a MediaPlayer file.\nLoaded: I either have MediaPlayer or QuickTime with Flip.");
					}
					
					//return true;
					//this.HasPlayer = true;
					canLoadPlayer = true;
				}
				// neither player was detected
				else{
	
					// display details of test
					if(istest){
						alert("This is a MediaPlayer file, but couldn't load.\nReasons: I don't have MediaPlayer or QuickTime with Flip.");
					}
					
					//return false;
					//this.HasPlayer = false;
					canLoadPlayer = false;
				}
			}else{
			
				// check for quicktime specific files
				if(isMovOrMp4){
	
					// display details of test
					if(istest){
						alert("This is a QuickTime file.\nLoaded: I have QuickTime.");
					}
					
					//return this.HasQuickTime;
					//this.HasPlayer = this.HasQuickTime;
					canLoadPlayer = this.HasQuickTime;
				}
				
				// no player specific file detected, lets just see if a player is detected (media player is the dominate player)
				else{
	
					// display details of test
					if(istest){
						alert("Attempting to load media file.\nCan I load it? " + (this.HasMediaPlayer || this.HasQuickTime));
					}
					
					//return (this.HasMediaPlayer || this.HasQuickTime);
					//this.HasPlayer = (this.HasMediaPlayer || this.HasQuickTime);
					canLoadPlayer = (this.HasMediaPlayer || this.HasQuickTime);
				}
				
			}
			
		}else{
		
			// display details of test
			if(istest){
				alert("I don't have MediaPlayer or QuickTime installed.");
			}
			
			//return false;
			//this.HasPlayer = false;
			canLoadPlayer = false;
		}
		
	}catch(ex){
		
		// display details of test
		if(istest){
			alert("LOADPLAYER ERROR: " + ex + "\n\n" + ex.description);
		}
		
		//return false;
		//this.HasPlayer = false;
		canLoadPlayer = false;
	}
	
	if(canLoadPlayer){
		this.buildPlayerCode(id, ftype, width, height, params, istest);
	}else{
		var strPlayer = "";
		if(error){
			if(typeof CustomMediaError !== 'undefined'){
				strPlayer = '<div class="Media_Error Player_Not_Supported Custom_Error">' + CustomMediaError + '</div>' + "\n";
			}else{
				strPlayer = '<div class="Media_Error Player_Not_Supported">' + "\n";
				strPlayer += '<table cellpadding="2" cellspacing="0" border="0" width="' + width + '">' + "\n";
				strPlayer += '<tr>' + "\n";
				strPlayer += '<td colspan="3" align="center"><h3>Player Not Found:</h3></td>' + "\n";
				strPlayer += '</tr>' + "\n";
				if(this.isWmvWmaFile(ftype)){
					if(this.HasQuickTime && !this.HasFlip){
						strPlayer += '<tr>' + "\n";
						strPlayer += '<td><img src="/SiteCM3/i/flip4mac_icon.jpg" alt="Flip4Mac" width="34" height="34" border="0" align="left" hspace="2" vspace="2" /></td>' + "\n";
						strPlayer += '<td nowrap="true">Flip4Mac (QuickTime plug-in):</td>' + "\n";
						strPlayer += '<td><a href="http://www.apple.com/downloads/macosx/video/flip4macwindowsmediacomponentsforquicktime.html" target="_blank">download</a></td>' + "\n";
						strPlayer += '</tr>' + "\n";
					}else{
						strPlayer += '<tr>' + "\n";
						strPlayer += '<td rowspan="4" align="center">Windows<br />Media Player<br /><img src="/SiteCM3/i/mediaplayer_icon.jpg" alt="Windows Media Player" width="34" height="34" border="0" hspace="2" vspace="2" /></td>' + "\n";
						strPlayer += '<td nowrap="true">Microsoft Windows:</td>' + "\n";
						strPlayer += '<td><a href="http://www.microsoft.com/windows/windowsmedia/default.mspx" target="_blank">download</a></td>' + "\n";
						strPlayer += '</tr>' + "\n";
						strPlayer += '<tr>' + "\n";
						strPlayer += '<td nowrap="true">Mac OS X:</td>' + "\n";
						strPlayer += '<td><a href="http://www.microsoft.com/windows/windowsmedia/player/mac/mp9/default.aspx" target="_blank">download</a></td>' + "\n";
						strPlayer += '</tr>' + "\n";
						strPlayer += '<tr>' + "\n";
						strPlayer += '<td nowrap="true">Mac OS 8.1 to 9.x:</td>' + "\n";
						strPlayer += '<td><a href="http://www.microsoft.com/windows/windowsmedia/player/mac/mp71/default.aspx" target="_blank">download</a></td>' + "\n";
						strPlayer += '</tr>' + "\n";
						strPlayer += '<tr>' + "\n";
						strPlayer += '<td nowrap="true">Mozilla Firefox:</td>' + "\n";
						strPlayer += '<td><a href="http://port25.technet.com/pages/windows-media-player-firefox-plugin-download.aspx">download</a></td>' + "\n";
						strPlayer += '</tr>' + "\n";
					}
				}else{
					if(!this.HasMediaPlayer){
						strPlayer += '<tr>' + "\n";
						strPlayer += '<td rowspan="4" align="center">Windows<br />Media Player<br /><img src="/SiteCM3/i/mediaplayer_icon.jpg" alt="Windows Media Player" width="34" height="34" border="0" hspace="2" vspace="2" /></td>' + "\n";
						strPlayer += '<td nowrap="true">Microsoft Windows:</td>' + "\n";
						strPlayer += '<td><a href="http://www.microsoft.com/windows/windowsmedia/default.mspx" target="_blank">download</a></td>' + "\n";
						strPlayer += '</tr>' + "\n";
						strPlayer += '<tr>' + "\n";
						strPlayer += '<td nowrap="true">Mac OS X:</td>' + "\n";
						strPlayer += '<td><a href="http://www.microsoft.com/windows/windowsmedia/player/mac/mp9/default.aspx" target="_blank">download</a></td>' + "\n";
						strPlayer += '</tr>' + "\n";
						strPlayer += '<tr>' + "\n";
						strPlayer += '<td nowrap="true">Mac OS 8.1 to 9.x:</td>' + "\n";
						strPlayer += '<td><a href="http://www.microsoft.com/windows/windowsmedia/player/mac/mp71/default.aspx" target="_blank">download</a></td>' + "\n";
						strPlayer += '</tr>' + "\n";
						strPlayer += '<tr>' + "\n";
						strPlayer += '<td nowrap="true">Mozilla Firefox:</td>' + "\n";
						strPlayer += '<td><a href="http://port25.technet.com/pages/windows-media-player-firefox-plugin-download.aspx">download</a></td>' + "\n";
						strPlayer += '</tr>' + "\n";
					}
					if(!this.HasQuickTime){
						strPlayer += '<tr>' + "\n";
						strPlayer += '<td><img src="/SiteCM3/i/quicktime_icon.jpg" alt="QuickTime" width="34" height="34" border="0" align="left" hspace="2" vspace="2" /></td>' + "\n";
						strPlayer += '<td nowrap="true">Apple QuickTime:</td>' + "\n";
						strPlayer += '<td><a href="http://www.apple.com/quicktime/download" target="_blank">download</a></td>' + "\n";
						strPlayer += '</tr>' + "\n";
					}
				}
				strPlayer += '<tr>' + "\n";
				strPlayer += '<td colspan="3"><p align="center">Please install a supported media player and reload the page.</p></td>' + "\n";
				strPlayer += '</tr>' + "\n";
				strPlayer += '</table>' + "\n";
				strPlayer += '</div>' + "\n";
			}
		}
		getObj("SiteCM_Media_" + id + "_Container").innerHTML = strPlayer;
	}
	
}

DetectPlayer.prototype.detectIE = function(ClassID, name){
    document.writeln('<scr' + 'ipt language="vbscript">');
    document.writeln('on error resume next');
    document.writeln('result = IsObject(CreateObject("' + ClassID + '"))');
    document.writeln('</scr' + 'ipt>');
	if(result){
		return true;
	}
	return false;
}

DetectPlayer.prototype.detectNS = function(ClassID, name){
	var nse = "";
	for (var i=0;i<navigator.mimeTypes.length;i++){
		nse += navigator.mimeTypes[i].type.toLowerCase();
	}
	if(nse.indexOf(ClassID) != -1){
		if(navigator.mimeTypes[ClassID].enabledPlugin != null){
			return true;
		}
	}
	return false;
}

DetectPlayer.prototype.detectQuickTime = function() {
    var foundPlugin = this.detectPlugin('QuickTime');
    // if not found, try to detect with VisualBasic
    if(!foundPlugin && isDetectableWithVB){
		foundPlugin = this.detectQuickTimeActiveXControl();
    }
    return foundPlugin;
}

DetectPlayer.prototype.detectFlip = function(){
    return this.detectPlugin('Flip4Mac');
}

DetectPlayer.prototype.detectWindowsMedia = function(){
    var foundPlugin = this.detectPlugin('Windows Media', 'Pl');
    // if not found, try to detect with VisualBasic
    if(!foundPlugin && isDetectableWithVB){
		foundPlugin = this.detectActiveXControl('MediaPlayer.MediaPlayer.1');
    }
    return foundPlugin;
}

DetectPlayer.prototype.detectPlugin = function(){
    // allow for multiple checks in a single pass
    var daPlugins = this.detectPlugin.arguments;
    // consider foundPlugin to be false until proven true
    var foundPlugin = false;
    // if plugins array is there and not fake
    if(navigator.plugins && navigator.plugins.length > 0){
		var pluginsArrayLength = navigator.plugins.length;
		// for each plugin...
		for(pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ){
		    // loop through all desired names and check each against the current plugin name
		    var numFound = 0;
		    for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++){
				// if desired plugin name is found in either plugin name or description
				if((navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0)){
				    // this name was found
				    numFound++;
				}   
		    }
		    // now that we have checked all the required names against this one plugin,
		    // if the number we found matches the total number provided then we were successful
		    if(numFound == daPlugins.length){
				foundPlugin = true;
				// if we've found the plugin, we can stop looking through at the rest of the plugins
				break;
		    }
		}
    }
    return foundPlugin;
}

DetectPlayer.prototype.isWmvWmaFile = function(filetype){
	if(filetype == 'wma' || filetype == 'wmv'){
		return true;
	}
	return false;
}

DetectPlayer.prototype.isMovOrMp4File = function(filetype){
	if(filetype == 'mov' || filetype == 'm3u' || filetype == 'mp4' || filetype == 'm4a'){
		return true;
	}
	return false;
}

var isDetectableWithVB = false;

DetectPlayer.prototype.setupVbScript = function(id, istest){
	if(!VBDETECTIONWRITTEN){
		var vbScript = "";

		vbScript = '<scr' + 'ipt language="vbscript">' + "\n";

		vbScript += '\'do a one-time test for a version of VBScript that can handle this code' + "\n";
		vbScript += 'isDetectableWithVB = False' + "\n";
		vbScript += 'If ScriptEngineMajorVersion >= 2 Then' + "\n";
		vbScript += '  isDetectableWithVB = True' + "\n";
		vbScript += 'End If' + "\n";

		vbScript += '\'this next function will detect most plugins' + "\n";
		vbScript += 'Function detectActiveXControl(activeXControlName)' + "\n";
		vbScript += '  on error resume next' + "\n";
		vbScript += '  detectActiveXControl = False' + "\n";
		vbScript += '  If isDetectableWithVB Then' + "\n";
		vbScript += '     detectActiveXControl = IsObject(CreateObject(activeXControlName))' + "\n";
		vbScript += '  End If' + "\n";
		vbScript += 'End Function' + "\n";

		vbScript += '\'and the following function handles QuickTime' + "\n";
		vbScript += 'Function detectQuickTimeActiveXControl()' + "\n";
		vbScript += '  on error resume next' + "\n";
		vbScript += '  detectQuickTimeActiveXControl = False' + "\n";
		vbScript += '  If isDetectableWithVB Then' + "\n";
		vbScript += '    detectQuickTimeActiveXControl = False' + "\n";
		vbScript += '    hasQuickTimeChecker = False' + "\n";
		vbScript += '    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")' + "\n";
		vbScript += '    If IsObject(hasQuickTimeChecker) Then' + "\n";
		vbScript += '      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then' + "\n";
		vbScript += '        detectQuickTimeActiveXControl = True' + "\n";
		vbScript += '      End If' + "\n";
		vbScript += '    End If' + "\n";
		vbScript += '  End If' + "\n";
		vbScript += 'End Function' + "\n";

		vbScript += '</scr' + 'ipt>' + "\n";

		getObj("SiteCM_Media_" + id + "_VB_Detection").innerHTML = vbScript;
		
		VBDETECTIONWRITTEN = true;
		
		// display details of test
		if(istest){
			alert("VB detection script written.");
		}
	}
}

DetectPlayer.prototype.buildPlayerCode = function(id, ftype, width, height, params, istest){
	var strPlayer = "";
	
	try {
		
		// determine if its a WMA or WMV file
		var isWmvOrWma = this.isWmvWmaFile(ftype);
		
		// determine if its a MOV or MP4 file
		var isMovOrMp4 = this.isMovOrMp4File(ftype)

		strPlayer = '<object' + "\n";
		strPlayer += ' id="SiteCM_Media_' + id + '"' + "\n";
		strPlayer += ' width="' + width + '"' + "\n";
		if(this.HasMediaPlayer && !isMovOrMp4){
			// Media Player parameters
			strPlayer += ' classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"' + "\n";
			strPlayer += ' codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902"' + "\n";
			strPlayer += ' type="application/x-oleobject"' + "\n";
			if(this.IsInternetExplorer){
				strPlayer += ' height="' + (height+40) + '' + "\n";
			}else{
				if(this.HasQuickTime && this.HasFlip){
					// Quicktime parameters
					strPlayer += ' height="' + (height+15) + '"' + "\n";
				}else{
					strPlayer += ' height="' + (height+65) + '"' + "\n";
				}
			}
		}else{
			// Quicktime parameters
			strPlayer += ' height="' + (height+15) + '"' + "\n";
			strPlayer += ' classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"' + "\n";
			strPlayer += ' codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0"' + "\n";
		}
		strPlayer += '>' + "\n";
		strPlayer += '<param name="volume" value="' + params.volume + '" />' + "\n";
		if(this.HasMediaPlayer && !isMovOrMp4){
			// Media Player parameters
			strPlayer += '<param name="filename" value="' + params.filename + '" />' + "\n";
			if(this.IsInternetExplorer){
				strPlayer += '<param name="autostart" value="' + params.autostart + '" />' + "\n";
			}else{
				strPlayer += '<param name="src" value="' + params.filename + '" />' + "\n";
				strPlayer += '<param name="autostart" value="';
				if(params.autostart == "true"){
					strPlayer += '1';
				}else{
					strPlayer += '0';
				}
				strPlayer += '" />' + "\n";
			}
		}else{
			// Quicktime parameters
			strPlayer += '<param name="src" value="' + params.filename + '" />' + "\n";
			strPlayer += '<param name="autoplay" value="' + params.autostart + '" />' + "\n";
		}
		strPlayer += '<embed' + "\n";
		strPlayer += ' src="' + params.filename + '"' + "\n";
		strPlayer += ' name="SiteCM_Media_' + id + '"' + "\n";
		strPlayer += ' volume="' + params.volume + '"' + "\n";
		strPlayer += ' width="' + width + '"' + "\n";
		if(this.HasMediaPlayer && !isMovOrMp4){
			// Media Player parameters
			strPlayer += ' type="application/x-mplayer2"' + "\n";
			strPlayer += ' pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"' + "\n";
			if(this.IsInternetExplorer){
				strPlayer += ' height="' + (height+40) + '"' + "\n";
				strPlayer += ' autostart="' + params.autostart + '"' + "\n";
			}else{
				if(this.HasQuickTime && this.HasFlip){
					// Quicktime parameters
					strPlayer += ' height="' + (height+15) + '"' + "\n";
				}else{
					strPlayer += ' height="' + (height+65) + '"' + "\n";
				}
				strPlayer += ' autostart="';
				if(params.autostart == "true"){
					strPlayer += '1';
				}else{
					strPlayer += '0';
				}
				strPlayer += '"' + "\n";
			}
		}else{
			// Quicktime parameters
			strPlayer += ' pluginspage="http://www.apple.com/quicktime/download/"' + "\n";
			strPlayer += ' height="' + (height+15) + '"' + "\n";
			strPlayer += ' autoplay="' + params.autostart + '"' + "\n";
		}
		strPlayer += ' />' + "\n";
		strPlayer += '</object>' + "\n";
	
		if(istest){
			alert(strPlayer);
		}
		getObj("SiteCM_Media_" + id + "_Container").innerHTML = strPlayer;
	
	}catch(ex){
		
		// display details of test
		if(istest){
			alert("BUILDPLAYERCODE ERROR: " + ex + "\n\n" + ex.description);
		}
		
		return null;
	
	}
	
}