/*
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
	
	* TODO: Define these functions better
	* TODO: add more
	disableEnter
	cleanTextField
	cleanTextFields
	displayFormError
	displayFormErrorAlert
	stripHtml
	trimString
	
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');
			
		}
		
		
		
	}
	
	var CUSTOMPOPUPWINPROPS;
	function openWin(URL, name, props){
	
		// check for URL
		if(URL == ""){
			alert("Error!\n\nThe URL for the link could not be determined.");
		}
		
		// if we have one then setup window
		else{
		
			var newwindow = null;
			var windowprops;
			
			if(typeof(props) !== 'undefined' && props && props != null && props != ""){
				windowprops = props;
			}else if(typeof(CUSTOMPOPUPWINPROPS) !== 'undefined' && CUSTOMPOPUPWINPROPS && CUSTOMPOPUPWINPROPS != null && CUSTOMPOPUPWINPROPS != ""){
				windowprops = CUSTOMPOPUPWINPROPS;
			}
			
			// doesn't have custom features
			if(!windowprops){
				newwindow = window.open(URL, name);
			}
			
			// has custom features
			else{
				
				// container for window features
				var features = "";
				
				// set width and height (needed if centered or fullscreen)
				var width = 0;
				if(typeof(windowprops.width) !== 'undefined' && windowprops.width && windowprops.width != null && windowprops.width != ""){
					width = (windowprops.width-0);
				}
				
				var height = 0;
				if(typeof(windowprops.height) !== 'undefined' && windowprops.height && windowprops.height != null && windowprops.height != ""){
					height = (windowprops.height-0);
				}
				
				// set top, update top to center vertically if necessary
				var top = 0;
				if(typeof(windowprops.top) !== 'undefined' && windowprops.top && windowprops.top != null && windowprops.top != ""){
					top = windowprops.top;
					if(height > 0 && windowprops.centerv == 'yes'){
						top = (window.screen.height/2) - ((height/2) + 58); // 58 = status bar(25px) and title bar(25px) and browser window borders(4px)
					}
				}
				
				// set left, update left to center horizontally if necessary
				var left = 0;
				if(typeof(windowprops.left) !== 'undefined' && windowprops.left && windowprops.left != null && windowprops.left != ""){
					left = windowprops.left;
					if(width > 0 && windowprops.centerh == 'yes'){
						left = (window.screen.width/2) - ((width/2) + 8); // 8 = 4px browser window borders
					}
				}
				
				// reset top, left and calculate new width, height for full screen
				if(windowprops.fullscreen == 'yes'){
					top = 0;
					left = 0;
					width = window.screen.width - 8; // 8 = 4px browser window borders
					height = window.screen.height - 58; // 58 = status bar(25px) and title bar(25px) and browser window borders(4px)
				}
				
				var directories = "yes";
				if(typeof(windowprops.directories) !== 'undefined' && windowprops.directories && windowprops.directories != null && windowprops.directories != "" && windowprops.directories.toLowerCase() == "no"){
					directories = "no";
				}
				
				var location = "yes";
				if(typeof(windowprops.location) !== 'undefined' && windowprops.location && windowprops.location != null && windowprops.location != "" && windowprops.location.toLowerCase() == "no"){
					location = "no";
				}
				
				var menubar = "yes";
				if(typeof(windowprops.menubar) !== 'undefined' && windowprops.menubar && windowprops.menubar != null && windowprops.menubar != "" && windowprops.menubar.toLowerCase() == "no"){
					menubar = "no";
				}
				
				var resizable = "yes";
				if(typeof(windowprops.resizable) !== 'undefined' && windowprops.resizable && windowprops.resizable != null && windowprops.resizable != "" && windowprops.resizable.toLowerCase() == "no"){
					resizable = "no";
				}
				
				var scrollbars = "yes";
				if(typeof(windowprops.scrollbars) !== 'undefined' && windowprops.scrollbars && windowprops.scrollbars != null && windowprops.scrollbars != "" && windowprops.scrollbars.toLowerCase() == "no"){
					scrollbars = "no";
				}
				
				var status = "yes";
				if(typeof(windowprops.status) !== 'undefined' && windowprops.status && windowprops.status != null && windowprops.status != "" && windowprops.status.toLowerCase() == "no"){
					status = "no";
				}
				
				var toolbar = "yes";
				if(typeof(windowprops.toolbar) !== 'undefined' && windowprops.toolbar && windowprops.toolbar != null && windowprops.toolbar != "" && windowprops.toolbar.toLowerCase() == "no"){
					toolbar = "no";
				}

				// build window feature settings
				features += "directories=" + directories;
				features += ",location=" + location;
				features += ",menubar=" + menubar;
				features += ",resizable=" + resizable;
				features += ",scrollbars=" + scrollbars;
				features += ",status=" + status;
				features += ",toolbar=" + toolbar;
				features += ",top=" + top;
				features += ",screenY=" + top;
				features += ",left=" + left;
				features += ",screenX=" + left;
				features += ",width=" + width;
				features += ",height=" + height;

				newwindow = window.open(URL, name, features);

			}
			
			// set focus to new window
			if(window.focus){
				try{
					newwindow.focus();
				}catch(x){
					// do nothing
				}
			}
		
		}
		
		// always stop the link (if necessary)
		return false;
		
	}


// ---------------------------------------------------------------
//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 -- had to update for ie8
// ---------------------------------------------------------------
	function showCell(cell,displayString){
		try{
			if (displayString == null){
				cell.style.display="table-cell";
			}else{
				cell.style.display = displayString;
			}
		} 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){
			
			// valin is empty, null or undefined
			if ((valin == null) || (valin == '') || (typeof valin === 'undefined')) {
				return false;
			}
			
			// \W - contains any non ASCII word character (not a-z, 0-9)
			var strCompare = /\W*\s/;
			var result = valin.match(strCompare);
			if ((result != null) && (result != '/')) {
				return false;
			}
			
			// does not end in .htm
			var strCompareIII = /^(.*)\.htm$/;
			var resultIII = valin.match(strCompareIII);
			if (resultIII == null) {
				return false;
			}else{
				// if it does remove it to look for invalid characters
				valin = replaceSubstring(valin, ".htm", "");
			}
			
			// invalid character exists
			var strCompareII = /((\.)|(\?)|(\))|(\()|(\*)|(\&)|(\^)|(\%)|(\$)|(\#)|(\@)|(\!)|(\+)|(\')|(\,)|(\\)|(\<)|(\>)|(\;)|(\:)|(\")|(\|)|(\])|(\[)|(\~)|(\`)|(\=)|(\})|(\{))/;
			var resultII = valin.match(strCompareII);
			if (resultII != null) {
				return false;
			}
			
			/*
			// does not end in m or l
			var strCompareIIII = /[^m|^l]$/;
			var resultIIII = valin.match(strCompareIIII);
			if (resultIIII != null) {
				return false;
			}
			*/

			// valid filename
			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'
}

/* EVENT HANDLING */

function addSafeEventListener(s_event, f_function){
	if(typeof(f_function) != 'function'){
		throw(new Error(000, 'Can not assign ' + typeof(f_function) + ' as the event handler.'));
	}
	if(document.addEventListener){
		window.addEventListener(s_event, f_function, false);
		return;
	}
	if(window.attachEvent){
		window.attachEvent('on' + s_event, f_function);
		return;
	}
	var f_oldHandler = window['on' + s_event];
	if(typeof(f_oldHandler) == 'function'){
		window['on' + s_event] = function(){
			f_oldHandler();
			f_function();
		}
		return;
	}
	window['on' + s_event] = f_function;
}

/* FORM HANDLING */

// Disable the Enter Key usage: onkeypress="return disableEnter(this, event)"
function disableEnter(field, event){
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if(keyCode == 13){
		var i;
		for(i = 0; i < field.form.elements.length; i++){
			if(field == field.form.elements[i]){
				break;
			}
		}
		if(field.form.elements[i+1].type != 'hidden' && field.form.elements[i+1].disabled != 1){
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		}else{
			return disableEnter(field.form.elements[i+1], event);
		}
	}else{
		return true;
	}
}

function cleanTextField(fieldid, strip){
	if(fieldid != ""){
		var what = getObj(fieldid);
		if(!what){
			return;
		}
	}else{
		return;
	}
	if(typeof strip == "undefined"){
		strip = true;
	}
	myType = what.type;
	if(myType == 'hidden' || myType == 'password' || myType == 'text' || myType == 'textarea'){
		if(what.value != ""){
			what.value = trimString(what.value);
			if(strip){
				what.value = stripHtml(what.value);
			}
			what.value = replaceSubstring(what.value, '’', "'");
			what.value = replaceSubstring(what.value, '“', '"');
			what.value = replaceSubstring(what.value, '”', '"');
			what.value = replaceSubstring(what.value, '–', '-');
			what.value = replaceSubstring(what.value, '…', '...');
			what.value = replaceSubstring(what.value, "", "'");
			what.value = replaceSubstring(what.value, "", "'");
			what.value = replaceSubstring(what.value, "`", "'");
			what.value = replaceSubstring(what.value, "", "'");
			what.value = replaceSubstring(what.value, "", "'");
			what.value = replaceSubstring(what.value, '', '"');
			what.value = replaceSubstring(what.value, '', '"');
			what.value = replaceSubstring(what.value, '', '-');
			what.value = replaceSubstring(what.value, '', '-');
		}
	}
}

// remove weird characters - from cut and paste from other programs
function cleanTextFields(formid, strip){
	if(typeof formid === "undefined"){
		what = document.forms[0];
		if(!what){
			return;
		}
	}else{
		if(formid != ""){
			what = getObj(formid);
			if(!what){
				what = document.forms[0];
				if(!what){
					return;
				}
			}
		}else{
			if(!what){
				what = document.forms[0];
				if(!what){
					return;
				}
			}
		}
	}
	if(typeof strip === "undefined"){
		strip = true;
	}
	for(var i=0, j=what.elements.length; i<j; i++) {
		cleanTextField(what.elements[i].id, strip);
	}
}

function displayFormError(validationsummaryid, errors, usebookmark){
	if(typeof validationsummaryid === "undefined" || validationsummaryid == "" || !validationsummaryid){
		displayFormErrorAlert(errors);
	}else{
		var objValidationSummary = getObj(validationsummaryid);
		if(objValidationSummary){
			objValidationSummary.innerHTML = "";
			var strErrors = "";
			if(usebookmark){
				strErrors += "<a name='ERR"+validationsummaryid+"'></a>";
			}
			strErrors += "<p style='color:red;font-weight:bold;'>Please correct the following errors to proceed:</p><ul>";
			for(var i=0; i<errors.length; i++){
				strErrors += "<li style='color:red;font-weight:bold;'>" + errors[i] + "</li>";
			}
			strErrors += "</ul>";
			objValidationSummary.innerHTML = strErrors;
			if(usebookmark){
				var url = document.location.href.split("#");
				document.location.href = url[0] + "#ERR"+validationsummaryid;
			}
		}else{
			displayFormErrorAlert(errors);
		}
	}
}

function displayFormErrorAlert(errors){
	var strErrors = "Please correct the following errors to proceed:\n\n";
	for(var i=0; i<errors.length; i++){
		strErrors += "- " + errors[i] + "\n";
	}
	alert(strErrors);
}

function stripHtml(str){
	var re = /<\S[^>]*>/gi;
	str = str.replace(re, "");
	return str;
}

function trimString(str){
	var	str = str.replace(/^\s\s*/, ''), 
	ws = /\s/, 
	i = str.length;
	while(ws.test(str.charAt(--i)));
	return str.slice(0, i + 1);
}


/* 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 */
