var tclkTrackedClickthrough = "http://dd.connextra.com/servlet/redirect?target=http%3A%2F%2Fbetway.com%2Fpartner%3Ftrack%3D9652640e28d1e9ffc565899d40606cef4bdcc8c5%26asset_id%3D725&s=Eng_football_120x240&a=Betway%3AEng_football_120x240";

function getParameter(queryString, parameterName) {
    allParamSplits = queryString.split(parameterName+"=");
    paramToEnd = allParamSplits[1];
    if(paramToEnd==null) return null;
    paramSplits = paramToEnd.split("&");
    param = paramSplits[0];
    return unescape(param);
}
function getLocation(scriptUri){
  return scriptUri.split('/')[2];
}

function getProtocol(scriptUri){
//to handle both HTTP and HTTPS
  return scriptUri.split('/')[0];
}

allScript = document.getElementsByTagName("script");
scriptUri = allScript[allScript.length-1].src;
var tclk =  getParameter(scriptUri, "tclk");
var myProtocol = getProtocol(scriptUri);
var myLocation = getLocation(scriptUri);
if (tclk != null){
  tclkTrackedClickthrough += ("&tclk="+escape(tclk));  
}

	var MM_contentVersion = 6;
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	if ( plugin ) {

			var words = navigator.plugins["Shockwave Flash"].description.split(" ");
		    for (var i = 0; i < words.length; ++i)
		    {
			if (isNaN(parseInt(words[i])))
			continue;
			var MM_PluginVersion = words[i];
		    }
		var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
	}
	else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
	   && (navigator.appVersion.indexOf("Win") != -1)) {
			document.write('<SCR' + 'IPT LANGUAGE=VBScript> \n'); //FS hide this from IE4.5 Mac by splitting the tag
			document.write('on error resume next \n');
			document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
			document.write('</SCR' + 'IPT> \n');
	}

	if ( MM_FlashCanPlay ) {
	    	paramTransparent = "opaque";
    		embedTransparent = "";
		var swfUrl = myProtocol+"//"+myLocation+"/servlet/controller?client=Betway&placement=Eng_football_120x240&service=Eng_football_120x240&image=application%2Fx-shockwave-flash&template=%2Fservices%2FUltraEditor%2FUltraAdImage.xml&clickTAG="+escape(tclkTrackedClickthrough);
		document.write("<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='"+myProtocol+"//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' "
			+ "WIDTH='120' HEIGHT='240' id='theMovie' ALIGN=''><PARAM NAME=movie VALUE='"+swfUrl+"'><PARAM NAME=quality VALUE=high><PARAM NAME='wmode' VALUE='"+paramTransparent+"'><EMBED src='"+swfUrl+"' "+embedTransparent+" quality=high bgcolor=#DDDDDD  WIDTH='120' HEIGHT='240' NAME='theMovie' ALIGN='' TYPE='application/x-shockwave-flash' PLUGINSPAGE='"+myProtocol+"//www.macromedia.com/go/getflashplayer'></EMBED></OBJECT>");
	} else{
		document.write("<a href='"+tclkTrackedClickthrough+"' ><img src='"+myProtocol+"//"+myLocation+"/resources/Betway/Graphics/Backup_images/backup_image_120x240.jpg' border='0'/></a>");
	}

	function formClickthru(args) {
		Interstitial.load(args);
	}
	
	function theMovie_DoFSCommand(command, args) {
		if(command == "clickthru") {
			if(args) formClickthru(args);
			else formClickthru("http://dd.connextra.com/servlet/redirect?target=http%3A%2F%2Fbetway.com%2Fpartner%3Ftrack%3D9652640e28d1e9ffc565899d40606cef4bdcc8c5%26asset_id%3D725&s=Eng_football_120x240&a=Betway%3AEng_football_120x240");
		}
	}

	// Hook for Internet Explorer 
	if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
		  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
		document.writeln('<SCRIPT LANGUAGE=VBScript>');
		document.writeln('on error resume next');
		document.writeln('Sub theMovie_FSCommand(ByVal command, ByVal args)');
		document.writeln('  call theMovie_DoFSCommand(command, args)');
		document.writeln('end sub');
		document.writeln('</SCRIPT>');
	}