// Flash Version Detector  v1.2.1
// documentation: http://www.dithered.com/javascript/flash_detect/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com) with VBScript code from Alastair Hamilton (now somewhat modified)
var flashVersion = 0;
var flashVersion_DONTKNOW = -1;
function isDefined(property) {  return (typeof property != 'undefined'); }
function getFlashVersion() {
	var latestFlashVersion = 10;
	var agent = navigator.userAgent.toLowerCase(); 
	// NS3 needs flashVersion to be a local variable
	if (agent.indexOf("mozilla/3") != -1 && agent.indexOf("msie") == -1) {	flashVersion = 0;	}
	// NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Flash plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		var flashPlugin = navigator.plugins['Shockwave Flash'];
		if (typeof flashPlugin == 'object') {  for (var i = latestFlashVersion; i >= 3; i--) { if (flashPlugin.description.indexOf(i + '.') != -1) { flashVersion = i; break; } } }
	}
	// IE4+ Win32:  attempt to create an ActiveX object using VBScript
	else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
	   var doc = '<scr' + 'ipt language="VBScript"\> \n';
      doc += 'On Error Resume Next \n';
      doc += 'Dim obFlash \n';
      doc += 'For i = ' + latestFlashVersion + ' To 3 Step -1 \n';
      doc += '   Set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n';
      doc += '   If IsObject(obFlash) Then \n';
      doc += '      flashVersion = i \n';
      doc += '      Exit For \n';
      doc += '   End If \n';
      doc += 'Next \n';
      doc += '</scr' + 'ipt\> \n';
      document.write(doc);
   }		
	// WebTV 2.5 supports flash 3
	else if (agent.indexOf("webtv/2.5") != -1) flashVersion = 3;
	// older WebTV supports flash 2
	else if (agent.indexOf("webtv") != -1) flashVersion = 2;
	// Can't detect in all other cases
	else { flashVersion = flashVersion_DONTKNOW; }
	return flashVersion;
}
// End Flash Version Detector by Chris Nott (chris[at]dithered[dot]com)

getFlashVersion();

function insertFlashMovie(movie, width, height, flashvars, requiredversion){

	if(flashVersion >= requiredversion){
		var cabversion = (requiredversion == 7) ? '7,0,14,0' : '6,0,65,0';
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + cabversion + '" width="' + width + '" height="' + height + '">');
		document.write('  <param name="movie" value="' + movie + '" />');
		document.write('  <param name="quality" value="high" />');
		document.write('  <param name="wmode" value="transparent" />');
		document.write('  <param name="FlashVars" value="' + flashvars + '">');
		document.write('  <embed src="' + movie + '"  FlashVars="' + flashvars + '" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>');
		document.write('</object>');
	} else {
		document.write('<div class="noflash"><div class="padding"><h2>MACROMEDIA FLASH PLAYER REQUIREMENTS</h2><p>You don\'t have required flash version on your computer.<br /> To ensure the best possible Internet Experience, please download the latest version of the free <a href="http://www.macromedia.com/go/getflashplayer">Macromedia Flash Player</a></p></div></div>');
	}
}

function getListMenu(id){
  var e = document.getElementById(id);
	if(e){
		var a = new Array();
		a.push('<UL>');
		a = a.concat(DOMToString(e));
		a.push('</UL>');
		e.style.display = 'none';
		return a.join('');
	}
}
 
function DOMToString(node){
 var ra = new Array('href','target');
 var a = new Array();
 var n = node.childNodes;
 var l = n.length;
 var nn, attr;
 for(var i=0; i<l; i++){
  if(n[i].nodeType == 1){
   nn = n[i].nodeName;
   a.push('<'); a.push(nn);
   if(nn == 'A'){
    j = ra.length;
    while(j--){
     if(n[i].getAttribute(ra[j])){
      a.push(' '); a.push(ra[j]); a.push('=^'); a.push(n[i].getAttribute(ra[j])); a.push('^');
     }
    }
   }
   a.push('>');
   if(n[i].hasChildNodes) a = a.concat(DOMToString(n[i]));
   a.push('</'); a.push(nn); a.push('>');
  }else
   a.push(n[i].nodeValue.trim().toOneLine());
 }
 return a;
}

function getInnerText(id){
	var obj = document.getElementById(id);
	if(obj){
		return obj.innerHTML.stripTags();
	} else
		return '';
}

String.prototype.stripTags = function() { return this.replace(/<\/?[^>]+>/gi, ''); }
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }
String.prototype.toOneLine = function() { return this.replace(/\n/g, ' '); }



/*
ObjectSwap - Bypasses the new ActiveX Activation requirement in Internet Explorer by swapping existing ActiveX objects on the page with the same objects. 
Flash version detection by adding the param:    <param name="flashVersion" value="8" /> to the object tag.
Author: Karina Steffens, www.neo-archaic.net

var ie = (document.defaultCharset && document.getElementById && !window.home);
if (ie){ document.write ("<style id='hideObject'> object{display:none;} </style>"); }

objectSwap = function(){
	if (!document.getElementsByTagName){ return; }
	var stripQueue = [];
	var objects = document.getElementsByTagName('object');
	for (var i=0; i<objects.length; i++){			
		var o = objects[i];
		var h = o.outerHTML;
		var params = "";
		var hasFlash = true;
		for (var j = 0; j<o.childNodes.length; j++) {
			var p = o.childNodes[j];
			if (p.tagName == "PARAM"){
				if (p.name == "flashVersion"){
					hasFlash = detectFlash(p.value);
					if (!hasFlash){
						o.id = (o.id == "") ? ("stripFlash"+i) : o.id;
						stripQueue.push(o.id);
						break;
					}
				} 
				params += p.outerHTML;		       
			}
		}	
		if (!hasFlash){ continue; }		
		if (!ie){ continue; }
		if (o.className.toLowerCase().indexOf ("noswap") != -1){ continue; }
		var tag = h.split(">")[0] + ">";			
		var newObject = tag + params + o.innerHTML + " </OBJECT>";		
		o.outerHTML = newObject;
	}
	if (stripQueue.length) { stripFlash(stripQueue) }
	if (ie){ document.getElementById("hideObject").disabled = true; }
}

detectFlash = function(version){
	if(navigator.plugins && navigator.plugins.length){
		var plugin = navigator.plugins["Shockwave Flash"];
		if (plugin == undefined){ return false; }
		var ver = navigator.plugins["Shockwave Flash"].description.split(" ")[2];
		return (Number(ver) >= Number(version))
	} else if (ie && typeof (ActiveXObject) == "function"){
		try{
			var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + version);
			return true;
		} catch(e){ return false; }
	}
	return true;
}

stripFlash = function (stripQueue){
	if (!document.createElement){ return; }
	for (var i=0; i<stripQueue.length; i++){
		var o = document.getElementById(stripQueue[i]);
		var newHTML = o.innerHTML;	
		newHTML = newHTML.replace(/<!--\s/g, "");
		newHTML = newHTML.replace(/\s-->/g, "");
		newHTML = newHTML.replace(/<embed/gi, "<span");		
		var d = document.createElement("div");
		d.innerHTML = newHTML;
		d.className = o.className;
		d.id = o.id;
		o.parentNode.replaceChild(d, o);
	}
}

var tempFunc = window.onload;
window.onload = function(){
	if (typeof (tempFunc) == "function"){
		try{ tempFunc(); } catch(e){}
	}
	objectSwap();
}
*/


















