function detectFlash(){
	var agent = navigator.userAgent.toLowerCase(); 
	var flashVersion_DONTKNOW = -1;
	if (navigator.plugins != null && navigator.plugins.length > 0){
		var flashPlugin = navigator.plugins['Shockwave Flash'];
		if (typeof flashPlugin == 'object') { 
			if (flashPlugin.description.indexOf('9.') != -1) flashVersion = 9;
			else if (flashPlugin.description.indexOf('8.') != -1) flashVersion = 8;
			else if (flashPlugin.description.indexOf('7.') != -1) flashVersion = 7;
			else if (flashPlugin.description.indexOf('6.') != -1) flashVersion = 6;
			else if (flashPlugin.description.indexOf('5.') != -1) flashVersion = 5;
			else if (flashPlugin.description.indexOf('4.') != -1) flashVersion = 4;
			else if (flashPlugin.description.indexOf('3.') != -1) flashVersion = 3;
		}
	}
	else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
	  document.write('<scr' + 'ipt language="VBScript"\> \n');
		document.write('on error resume next \n');
		document.write('dim obFlash \n');
		document.write('set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.7") \n');
		document.write('if IsObject(obFlash) then \n');
		document.write('flashVersion = 9 \n');
		document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.8") end if \n');
		document.write('if flashVersion < 9 and IsObject(obFlash) then \n');
		document.write('flashVersion = 8 \n');
		document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.7") end if \n');
		document.write('if flashVersion < 8 and IsObject(obFlash) then \n');
		document.write('flashVersion = 7 \n');
		document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.6") end if \n');
		document.write('if flashVersion < 7 and IsObject(obFlash) then \n');
		document.write('flashVersion = 6 \n');
		document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.5") end if \n');
		document.write('if flashVersion < 6 and IsObject(obFlash) then \n');
		document.write('flashVersion = 5 \n');
		document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.4") end if \n');
		document.write('if flashVersion < 5 and IsObject(obFlash) then \n');
		document.write('flashVersion = 4 \n');
		document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.3") end if \n');
		document.write('if flashVersion < 4 and IsObject(obFlash) then \n');
		document.write('flashVersion = 3 \n');
		document.write('end if');
		document.write('</scr' + 'ipt\> \n');
  	}
	else{
		flashVersion = flashVersion_DONTKNOW;
	}
	if (flashVersion >= 6){
		return true;
	}
	else{
		return false;
	}
}

function doPopupUrl(mainid,url,width,height){
	var checkCookie = 0;
	var name = "adppu" + mainid;
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++){
		var aCrumb = aCookie[i].split("=");
		if (aCrumb[0] == name && aCrumb[1] == "1") checkCookie = 1;
	}
	if (checkCookie == 0){
		var size = "width=" + width + ",height=" + height;
		setaCookie(name,3);
		window.open(url,name,size);
	}
}

function setaCookie (name,hours){
	var not_NN2 = (navigator && navigator.appName && (navigator.appName == 'Netscape') && navigator.appVersion && (parseInt(navigator.appVersion) == 2))?false:true;
	if(hours && not_NN2){
		var exp = (new Date((new Date()).getTime() + hours*3600000)).toGMTString();
	}
	document.cookie = name + '=1' + ((exp)?(';expires=' + exp):'');
}

function swfWrite(swfURL, imgURL, width, height, targetURL){
  if(detectFlash()){
  		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0" width="' + width + '" height="' + height + '"><param name="movie" value="' + swfURL + '"><embed src="' + swfURL + '" width="' + width + '" height="' + height + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></object>');
  }
	else{
		if(imgURL != '' && targetURL != ''){
			document.write('<a href="' + targetURL + '" target="_blank"><img src="' + imgURL + '" width="' + width + '" height="' + height + '" border="0"></a>');
		}
	}
}

function xtendxWrite(swfURL, width, height, quality){
  if(detectFlash()){
  		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + width + '" height="' + height + '" id="player" align="middle"><param name="movie" value="http://ringier.simplex.tv/xbend/simplex/6/' + swfURL + '/player.swf"/><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="FlashVars" value="autostart=0&qId=' + quality + '" /><embed src="http://ringier.simplex.tv/xbend/simplex/6/' + swfURL + '/player.swf" FlashVars="autostart=0&qId=' + quality + '" quality="high" bgcolor="#ffffff" width="' + width + '" height="' + height + '" name="player" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></object>');
  }
}

