var openingWindow; //holds the opener of popup window

/*	start mobile FlashDemo */ 
function gotoAndPlay()
{
	var o = document.getElementById("mobileDemo")
	if (o != null && o != "undefined")
	{
		o.TGotoLabel("_level0/_root", "startdemo");
		o.TPlay("_level0/_root");				
	}
}

/* check wether on PreWin or not */
function IsPreWin()
{
	try
	{					
		if (top.frames[0] != null && top.frames[0].name == "PRD_BAW_header")			
			return true
	}
	catch (err)
	{
	}
	return false;
}

// monnt fake function!!
function checkForm(){
	return true;
}

// this function opens a popup !!!
function redirect(url)
{
	window.open(url, 'popup', 'hotkeys=no, resizable=no, toolbar=no, status=yes, dependent=no, scrollbars=0, width=550, height=370');
}

function open_popup (url, params)
{
	window.open(url, 'popup', params);
}

function open_parent(url)
{
	window.opener.location= url;
	window.close();
}

function open_mobiledemo()
{
    window.open('epage.aspx?view=showmovie', 'demo', 'hotkeys=no, resizable=no, toolbar=no, status=no, dependent=yes, scrollbars=0, width=980, height=527');
}

function openVeriSign()
{
 	window.open('https://seal.verisign.com/splash?form_file=fdf/splash.fdf&type=GOLD&sealid=2&dn='+ location.host,'','scrollbars=1,width=700,height=550');
}

function submitBetFinder(BetFinderSearchString) 
{
	var isEmpty = true;
	regex	= /^\s*$/;
	isEmpty = regex.test(BetFinderSearchString);
	if (!isEmpty && BetFinderSearchString.length >1) 
	{
		frm = document.getElementById('_betfinder');
		frm.betfinder.value = BetFinderSearchString;		
		frm.submit();
	} 
}

function GetUserSettings()
{
	//detect persistant cookies
	document.cookie = "cookieName=cookiealue";
	var cookiesenable = document.cookie.indexOf("cookieName") ;
	var cookies = cookiesenable != -1;

	var useragent = navigator.userAgent;
	var bName = (useragent.indexOf('Opera') > -1) ? 'Opera' : navigator.appName;
	var bVer = "-1";
	var pos = useragent.indexOf('MSIE');
	if (pos > -1) {
		bVer = useragent.substring(pos + 5);
		pos = bVer.indexOf(';');
		bVer = bVer.substring(0,pos);
	}
	pos = useragent.indexOf('Opera');
	if (pos > -1) {
		bVer = useragent.substring(pos + 6);
		pos = bVer.indexOf(' ');
		bVer = bVer.substring(0, pos);
	}
	if (bName == "Netscape") {
		bVer = useragent.substring(8);
		pos = bVer.indexOf(' ');
		bVer = bVer.substring(0, pos);
	}
	if (bName == "Netscape" && parseInt(navigator.appVersion) >= 5) 
	{
		pos = useragent.lastIndexOf('/');
		bVer = useragent.substring(pos + 1);
	}

	if(useragent.indexOf('Firefox') > -1)
		bName = 'Firefox';

	var browser = bName;
	var ver = bVer;
	
	var data = "<UserAgent><![CDATA[" + navigator.userAgent + "]]></UserAgent>";
	data += "<Browser><![CDATA[" + browser + "]]></Browser>";
	data += "<Browserversion><![CDATA[" + ver + "]]></Browserversion>";
	data += "<ScreenWidth><![CDATA[" + window.screen.width + "]]></ScreenWidth>";
	data += "<ScreenHeigth><![CDATA[" + window.screen.height + "]]></ScreenHeigth>";
	data += "<ColorDepth><![CDATA[" + window.screen.colorDepth + "]]></ColorDepth>";
	data += "<Cookies><![CDATA[" + cookies + "]]></Cookies>";

	return data;
}

function ShowHelp(strPage)
{
	var target=location.host.toLowerCase();
	if(target.indexOf("dev.") == 0 && (target.indexOf("poker") > 0 || target.indexOf("casino") > 0 || target.indexOf("games") > 0))
		target = target.substr(4);
	if(target.indexOf("test.") == 0 && (target.indexOf("poker") > 0 || target.indexOf("casino") > 0 || target.indexOf("games") > 0))
		target = target.substr(5);
	if(target.indexOf("beta.") == 0 && (target.indexOf("poker") > 0 || target.indexOf("casino") > 0 || target.indexOf("games") > 0))
		target = target.substr(5);
	var doti = target.indexOf('.');
	target = "help" + target.substr(doti);

	target = location.protocol + "//" + target + "/" + strPage;
	if(typeof LanguageTLC != "undefined" && LanguageTLC != "" && target.indexOf("sc_lang") == -1)
		target += (target.indexOf("?") == -1 ? '?' : '&') + 'sc_lang=' + LanguageTLC;

	window.open(target, 'help', 'hotkeys=no, resizable=yes, toolbar=yes, status=yes, dependent=yes, scrollbars=1, width=720, height=550');
}

function open_help(strPage)
{
	window.open('help.aspx?mode=content&page=' + strPage, 'help', 'hotkeys=no, resizable=yes, toolbar=yes, status=yes, dependent=yes, scrollbars=1, width=720, height=550');
}

function open_livescore(strPage)
{
	window.open(strPage, 'livescore', 'hotkeys=no, resizable=no, toolbar=yes, status=yes, dependent=yes, scrollbars=1, width=1024, height=768');
}

function open_epage(aID)
{
	window.open('epage.aspx?aid=' + aID, 'help', 'hotkeys=no, resizable=yes, toolbar=yes, status=yes, dependent=yes, scrollbars=1, width=720, height=550');
}


function open_statistics(strPage)
{
	window.open(strPage, 'help', 'hotkeys=no, resizable=yes, toolbar=yes, status=yes, dependent=yes, scrollbars=1, width=720, height=550');
}

function open_glossary(strPage, oWin)
{
	if (oWin) this.openingWindow = oWin;
	window.open('help.aspx?mode=glossary&page=' + strPage, 'help', 'hotkeys=no, resizable=yes, toolbar=yes, status=yes, dependent=yes, scrollbars=1, width=720, height=550');
}

function open_glossaryinternal(strPage)
{
	window.open('help.aspx?mode=glossaryinternal&page=' + strPage, 'help', 'hotkeys=no, resizable=yes, toolbar=yes, status=yes, dependent=yes, scrollbars=1, width=720, height=550');
}

function open_stats(betradarMatchID, LanguageID, url)
{
	if (url!='')
	{ 
		var strLanguageString='en';
		if (LanguageID==2) {strLanguageString='de'};
		window.open('http://www.stats.betradar.com/' + url + '/?matchid=' + betradarMatchID + '&language=' + strLanguageString, 'statistics', 'toolbar=yes, resizable=yes, scrollbars=1, width=720, height=550');
	}
}

function open_listofodds()
{
	window.open('ListOfOdds.aspx?view=print', 'listofodds', 'hotkeys=no, resizable=yes, toolbar=yes, status=yes, dependent=yes, scrollbars=1, width=720, height=550');
}

// this func is used for simulates the focus to the login-button if the user clicks on one input field
// used in login control
function setBtnBorder(strElementName, strClassName){
	
	if (navigator.appVersion.indexOf("MSIE") != -1 && document.getElementById)
	{
		var obj = findObj(strElementName)
		if (obj != null)
		{
			obj.className = strClassName
		}
	}	
}

function findObj(n, d)
{ //v4.0
	var p,i,x;
	if(!d) d=document;
	if((p=n.indexOf('?'))>0&&parent.frames.length)
	{
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all)
		x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++)
		x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++)
		x=findObj(n,d.layers[i].document);
	if(!x && document.getElementById)
		x=document.getElementById(n);
	return x;
}

function swapImgRestore()
{ //v3.0
	var i,x,a=document.sr;
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
		x.src=x.oSrc;
}

function preloadImages()
{ //v3.0
	var d=document;
	if(d.images)
	{
		if(!d.p)
			d.p=new Array();
		var i,j=d.p.length,a=preloadImages.arguments;
		for(i=0; i<a.length; i++)
			if (a[i].indexOf('#')!=0)
			{
				d.p[j]=new Image;
				d.p[j++].src=a[i];
			}
	}
}

function swapImage()
{ //v3.0
	var i,j=0,x,a=swapImage.arguments;
	document.sr=new Array;
	for(i=0;i<(a.length-2);i+=3)
		if ((x=findObj(a[i]))!=null)
		{
			document.sr[j++]=x;
			if(!x.oSrc)
				x.oSrc=x.src;
				x.src=a[i+2];
		}
}

function changetextParent(fieldname,whichcontent)
{
	var e = document.getElementById(fieldname);	
	if (e == null) e = parent.document.getElementById(fieldname);
	
	if (e != null) e.innerHTML=whichcontent;
}

/*clock*/
var my12_hour = 0;
var dn = ""; var old = "";
function show_clock() 
{
	//show clock in NS 4
	if (document.layers)
		document.ClockPosNS.visibility="show"
	if (old == "die") { return; }

	seconds++;
	
	if (seconds >= 60) {
		seconds = "0";
		minutes++;
		if (minutes <= 9) { minutes = "0"+minutes; }
	}
	if (minutes >= 60) {
		minutes = "0";
		hours++;
		if (hours <= 9) { hours = "0"+hours; }
	}
	if (hours >= 24) {
		hours = "00";
	}
	
	if (my12_hour) {
		dn = "AM";
		if (hours > 12) { dn = "PM"; hours = hours - 12; }
		if (hours == 0) { hours = 12; }
	} else {
		dn = "";
	}
	
	if (seconds <= 9) { seconds = "0"+seconds; }
	if (minutes == "0") { minutes = "00"; }

	myclock = '';
	myclock += hours+':'+minutes+':'+seconds+' '+dn + ' ' + gmtDisplay;

	if (old == "true") {
		document.write(myclock);
		old = "die"; return;
	}

	if (document.layers) {
		clockpos = document.ClockPosNS;
		liveclock = clockpos.document.LiveClockNS;
		liveclock.document.write(myclock);
		liveclock.document.close();
	} else if (document.getElementById) {
		if (document.getElementById("LiveClockIE") != null)
			document.getElementById("LiveClockIE").innerHTML = myclock;
	} else if (document.all) {
		LiveClockIE.innerHTML = myclock;
	}
	setTimeout("show_clock()",1000);
}
	
// helper funktion returns MultiDimensionalArray
function MultiDimensionalArray(iRows,iCols) 
{ 
	var i; 
	var j; 
	var a = new Array(iRows); 
	for (i=0; i < iRows; i++) 
	{ 
		a[i] = new Array(iCols); 
		for (j=0; j < iCols; j++) 
			a[i][j] = ""; 
	} 
	return(a); 
} 
	
/* 
returns difference of leftPos of to objects 
used to get width
*/
function GetPosXDiff(leftElemID, rightElemID)
{
	var e1, e2;
	var retVal = null;
	e1 = document.getElementById(leftElemID);
	e2 = document.getElementById(rightElemID);
	if (e1 != null && e2 != null )
	{
		retVal = DL_GetElementLeft(e2) - DL_GetElementLeft(e1);	
	}
	return retVal;
}

/* 
returns difference of topPos of to objects 
used to get height
*/
function GetPosYDiff(topElemID, bottomElemID)
{	
	var e1, e2;
	var retVal = null;
	e1 = document.getElementById(topElemID);
	e2 = document.getElementById(bottomElemID);
	if (e1 != null && e2 != null )
	{
		retVal = DL_GetElementTop(e2) - DL_GetElementTop(e1);
	}
	return retVal;
}

/* returns true leftPos */
function DL_GetElementLeft(eElement)
{
	if (!eElement && this)	eElement = this;

	var DL_bIE = document.all ? true : false;
	var nLeftPos = eElement.offsetLeft;
	var eParElement = eElement.offsetParent;

	while (eParElement != null)
	{
		if(DL_bIE)
		{
			if( (eParElement.tagName != "TABLE") && (eParElement.tagName != "BODY") )
			{
				nLeftPos += eParElement.clientLeft;
			}
		}
		else
		{
			if(eParElement.tagName == "TABLE")
			{
				var nParBorder = parseInt(eParElement.border);
				if(isNaN(nParBorder))
				{
					var nParFrame = eParElement.getAttribute('frame');
					if(nParFrame != null)
					{
						nLeftPos += 1;
					}
				}
				else if(nParBorder > 0)
				{
					nLeftPos += nParBorder;
				}
			}
		}
		nLeftPos += eParElement.offsetLeft;
		eParElement = eParElement.offsetParent;
	}
	return nLeftPos;
}

/* returns true topPos */
function DL_GetElementTop(eElement)
{
	if (!eElement && this) eElement = this;

	var DL_bIE = document.all ? true : false;
	var nTopPos = eElement.offsetTop;
	var eParElement = eElement.offsetParent;

	while (eParElement != null)
	{
		if(DL_bIE)
		{
			if( (eParElement.tagName != "TABLE") && (eParElement.tagName != "BODY") )
			{
				nTopPos += eParElement.clientTop;
			}
		}
		else
		{
			if(eParElement.tagName == "TABLE")
			{
				var nParBorder = parseInt(eParElement.border);
				if(isNaN(nParBorder))
				{
					var nParFrame = eParElement.getAttribute('frame');
					if(nParFrame != null)
					{
						nTopPos += 1;
					}
				}
				else if(nParBorder > 0)
				{
					nTopPos += nParBorder;
				}
			}
		}

		nTopPos += eParElement.offsetTop;
		eParElement = eParElement.offsetParent;
	}
	return nTopPos;
}
	
/* COOKIE Helper Functions */
function GetCookie(name) 
{
	var sCookieData = null;
	var aCookie = document.cookie.split("; ");
	
	for (var i=0; i < aCookie.length; i++)
	{			
		var aCrumb = aCookie[i].split("=");
		if (aCrumb[0].replace(/^\s*/, '').replace(/\s*$/, '') == name)
		{
			sCookieData = unescape(aCrumb[1]);
		}
	}
	return sCookieData;
}

function DeleteCookie(name, path, domain)
{
	if (GetCookie(name))
	{
		document.cookie = name + "=" + ( (path) ? ";path=" + path :	"") + ( (domain) ? ";domain=" + domain : "") + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}
}

function SetCookie(name, value, expires, path, domain, secure)
{
	document.cookie = name + '=' + escape(value) +	( (expires) ? ';expires='	+ expires.toGMTString() : '') + ( (path) ? ';path=' + path : '') + ((domain) ? ';domain=' + domain : '') + ( (secure) ? ';secure' : '');
}

function Flash(movie, id, width, height, ver, bg, fv)
{
	this.movie = movie;
	this.id = id;
	this.width = width;
	this.height = height;
	this.ver = ver ? ver : "8,0,0,0";

	this.align ="middle";

	this.attributes = new Array();
	this.params = new Object();

	if(bg)
		this.setParam("bgcolor", bg);
	if(fv)
		this.setParam("FlashVars", fv);

    this.setParam("menu", "false");

	this.setParam("allowScriptAccess", "sameDomain");
	this.setParam("quality", "high");
}

function FlashWithMenu(movie, id, width, height, ver, bg, fv)
{
	this.movie = movie;
	this.id = id;
	this.width = width;
	this.height = height;
	this.ver = ver ? ver : "8,0,0,0";

	this.align ="middle";

	this.attributes = new Array();
	this.params = new Object();

	if(bg)
		this.setParam("bgcolor", bg);
	if(fv)
		this.setParam("FlashVars", fv);


	this.setParam("allowScriptAccess", "sameDomain");
	this.setParam("quality", "high");
}


Flash.prototype.addAttribute = function(n, v)
{
	if(v)
		this.attributes[this.attributes.length] = n + '="' + v + '"';
	else
		this.attributes[this.attributes.length] = n;
}

FlashWithMenu.prototype.addAttribute = function(n, v)
{
	if(v)
		this.attributes[this.attributes.length] = n + '="' + v + '"';
	else
		this.attributes[this.attributes.length] = n;
}

Flash.prototype.setParam = function(n, v)
{
	this.params[n] = v;
}

FlashWithMenu.prototype.setParam = function(n, v)
{
	this.params[n] = v;
}

Flash.prototype.toString = function()
{
	if(this.ver.length < 2)
		this.ver += ",0,0,0";

	var s = '<object id="' + this.id + '" width="' + this.width + '" height="' + this.height + '" align="' + this.align + '" ';
	s += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + this.ver + '" ';
	for(var i=0; i<this.attributes.length; i++)
		s += this.attributes[i] + " ";
	s += '>';

	s += '<param name="movie" value="' + this.movie + '" />';
	var k;
	for(k in this.params)
		s += '<param name="' + k + '" value="' + this.params[k] + '" />';

	s += '<embed menu="false" src="' + this.movie + '" ';
	s += 'width="' + this.width + '" height="' + this.height + '" name="' + this.id + '" align="' + this.align + '" ';
	for(k in this.params)
		s += k + '="' + this.params[k] + '" ';

	s += 'swLiveConnect="true" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" />';

	s += '</object>';
	return s;
}

FlashWithMenu.prototype.toString = function()
{
	if(this.ver.length < 2)
		this.ver += ",0,0,0";

	var s = '<object id="' + this.id + '" width="' + this.width + '" height="' + this.height + '" align="' + this.align + '" ';
	s += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + this.ver + '" ';
	for(var i=0; i<this.attributes.length; i++)
		s += this.attributes[i] + " ";
	s += '>';

	s += '<param name="movie" value="' + this.movie + '" />';
	for(var k in this.params)
		s += '<param name="' + k + '" value="' + this.params[k] + '" />';

	s += '<embed src="' + this.movie + '" ';
	s += 'width="' + this.width + '" height="' + this.height + '" name="' + this.id + '" align="' + this.align + '" ';
	for(var k in this.params)
		s += k + '="' + this.params[k] + '" ';

	s += 'swLiveConnect="true" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" />';

	s += '</object>';
	return s;
}

Flash.prototype.render = function()
{
	document.write(this.toString());

	// fix for flashplayer 9.0.16 bug with ExternalInterface
	if (!Flash.unloadSet) {
		if(window.attachEvent)	// only in IE
			window.attachEvent("onbeforeunload", function() { __flash_unloadHandler = function(){}; __flash_savedUnloadHandler = function(){};});
		Flash.unloadSet = true;
	}

	// fix for flashplayer 9.0.16 bug with ExternalInterface
	if (!Flash.unloadSet) {
		if(window.attachEvent)	// only in IE
			window.attachEvent("onbeforeunload", function() { __flash_unloadHandler = function(){}; __flash_savedUnloadHandler = function(){};});
		Flash.unloadSet = true;
	}
}

Flash.prototype.renderToString = function()
{
	// fix for flashplayer 9.0.16 bug with ExternalInterface
	if (!Flash.unloadSet) {
		if(window.attachEvent)	// only in IE
			window.attachEvent("onbeforeunload", function() { __flash_unloadHandler = function(){}; __flash_savedUnloadHandler = function(){};});
		Flash.unloadSet = true;
	}

	// fix for flashplayer 9.0.16 bug with ExternalInterface
	if (!Flash.unloadSet) {
		if(window.attachEvent)	// only in IE
			window.attachEvent("onbeforeunload", function() { __flash_unloadHandler = function(){}; __flash_savedUnloadHandler = function(){};});
		Flash.unloadSet = true;
	}

	return this.toString();
}

FlashWithMenu.prototype.render = function()
{
	document.write(this.toString());

	// fix for flashplayer 9.0.16 bug with ExternalInterface
	if (!Flash.unloadSet) {
		if(window.attachEvent)	// only in IE
			window.attachEvent("onbeforeunload", function() { __flash_unloadHandler = function(){}; __flash_savedUnloadHandler = function(){};});
		Flash.unloadSet = true;
	}

	// fix for flashplayer 9.0.16 bug with ExternalInterface
	if (!Flash.unloadSet) {
		if(window.attachEvent)	// only in IE
			window.attachEvent("onbeforeunload", function() { __flash_unloadHandler = function(){}; __flash_savedUnloadHandler = function(){};});
		Flash.unloadSet = true;
	}
}

FlashWithMenu.prototype.renderToString = function()
{
	// fix for flashplayer 9.0.16 bug with ExternalInterface
	if (!Flash.unloadSet) {
		if(window.attachEvent)	// only in IE
			window.attachEvent("onbeforeunload", function() { __flash_unloadHandler = function(){}; __flash_savedUnloadHandler = function(){};});
		Flash.unloadSet = true;
	}

	// fix for flashplayer 9.0.16 bug with ExternalInterface
	if (!Flash.unloadSet) {
		if(window.attachEvent)	// only in IE
			window.attachEvent("onbeforeunload", function() { __flash_unloadHandler = function(){}; __flash_savedUnloadHandler = function(){};});
		Flash.unloadSet = true;
	}

	return this.toString();
}

	
function Toggle(id, display)
{
	if(typeof display == "undefined")
		display = "block";
	
	var o = document.getElementById(id);
	if(o)
	{
		if(o.style.display == "none")
		{
			o.style.display = display;
		}
		else
		{
			o.style.display = "none";
		}
	}
}

function SwitchImageAndDiv(idDiv, idImage, image1, image2)
{
	// Togle div tag
	Toggle (idDiv);
	
	// Swap image src
	var oImage = document.getElementById(idImage);
	if(oImage)
	{
		var oImage_fileName = extractFileName (new String(oImage.src));
		
		if (oImage_fileName == extractFileName (new String(image1)))
		{
			oImage.src = image2;
		}
		else
		{
			oImage.src = image1;
		}
	}
}

function EnableElement(idElem, enable)
{
	var oElement = document.getElementById(idElem);
	if(oElement)
	{
		if (enable)
		{
			oElement.style.visibility = "visible";
			oElement.style.lineHeight = "normal";
			oElement.style.display = "block";
		}
		else 
		{
			oElement.style.visibility = "hidden";
			oElement.style.display = "none";
		}
	}
}

function extractFileName(url)
{
	if (url.lastIndexOf("/") != 0)
	{
		return url.substring(url.lastIndexOf("/")+1);
	}
	else
		return url;
}
function addLoadEvent(func)
{
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		var oldonload = window.onload;
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

//Inserts an additional omniture tag to the page, if pagename/channel/server are left null,
//the already set values are used
function InsertOmnitureTag(pagename, channel, defaultPageName)
{
	if (typeof cat != "undefined")
	{
		if (channel != null)
			cat.v1 = channel;

		if (pagename != null)
			cat.v2 = pagename;

		if (defaultPageName != null)
			cat.v22 = defaultPageName;

		cat.SetVars();
		var s_code = s_ocatalyst.t();				 
		if (s_code)
			document.write(s_code);
	}
}

function onBalanceChange(fieldname,whichcontent)
{
	if(typeof whichcontent == "undefined")	// fieldname is not used anymore, so in the future this should work with only one parameter
		whichcontent = fieldname;			// make it work with both one and two parameters.

	CurrencyBalanceSubject.SetState(whichcontent);
}

// returns the flash version.
// major version before comma
// minor version as first digit after comma
// revision as the next three digits.
// i.e. "9.0 r28"	--> 9.0028
// i.e. "9.0 r103" --> 9.0103
function FlashVersion()
{
	if(navigator.plugins && navigator.plugins.length)		// Navigator-based browsers
	{
		for (var i=0;i<navigator.plugins.length;i++)
		{
			if (navigator.plugins[i].name.indexOf('Shockwave Flash') != -1)
			{
				var d, darr, revarr, version;
				d = navigator.plugins[i].description;		// d = "Shockwave Flash 9.0 r103"
				darr = d.split(" ");

				version = darr[2];
				if ( darr[3] != "" ) {
					revarr = darr[3].split("r");
				} else {
					revarr = darr[4].split("r");
				}
				version += revarr[1] > 0 ? ("000" + revarr[1]).substr(revarr[1].length) : "000";
				return parseFloat(version);
			}
		}
	}
	else if (window.ActiveXObject)		// IE
	{
		for (var i=15;i>=2;i--)
		{
			try
			{
				var f = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
				if (f)
				{
					var v = f.GetVariable("$version");		// v = "WIN 9,0,47,0"
					v = v.substr(4);
					var varr = v.split(",");
					var version = varr[0]+'.'+(varr[1].length==1 ? varr[1] : '9');
					version += ("000" + varr[2]).substr(varr[2].length);
					return parseFloat(version);
				}
			}
			catch(e)
			{}
		}
	}
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1)
		return 4;	// WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1)
		return 3;	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1)
		return 2;	// older WebTV supports Flash 2

	return -1.0;	// can't detect
}

// PIB

// BUTTON STYLE BETBROWSER
function highlight(obj, isHover)
{
	var cssClass = obj.className;
	if(cssClass == "" || cssClass == "MouseOver")
	{	// RotatingTeaser
		obj.className = isHover ? "MouseOver" : "";
		return;
    }

    var color = "#000000";

	if (typeof (BetListHighlightColorOverride) != "undefined") {
	    color = BetListHighlightColorOverride
	}
	
	if(isHover)
	{
		obj.style.backgroundColor = "#FFCC00";
		obj.style.borderColor = "#ffe066 #907608 #907608 #ffe066";
	}
	else
	{
		color = "";
		obj.style.backgroundColor = "";
		obj.style.borderColor = "";
	}

	obj.style.color = color;					// set color of this element
	var tds = obj.getElementsByTagName("TD");	// and all child TDs
	for(var i=0; i<tds.length; i++)
		tds[i].style.color = color;
}


// CREATE DROPSHADOW AND STRETCHED BACKGROUND AND TRANSPARENCY
document.getElementsByClassName = function(clsName){
	var retVal = new Array();
	var elements = document.getElementsByTagName("*");
	for(var i = 0;i < elements.length;i++){
		if(elements[i].className.indexOf(" ") >= 0){
			var classes = elements[i].className.split(" ");
			for(var j = 0;j < classes.length;j++){
				if(classes[j] == clsName)
					retVal.push(elements[i]);
			}
		}
		else if(elements[i].className == clsName)
			retVal.push(elements[i]);
	}
	return retVal;
}

function ShadowBoxFactory(className)
{
	this.targetClassName = className;
	this.boxes = new Array();
	this.backgroundimage = null;
	this.tag = 0x000001;
	this.getBoxes = function(){
		var elements = document.getElementsByClassName(this.targetClassName);
		for(var n=0;n<elements.length;n++)
			this.boxes.push(elements[n]);
	}
	
	this.render = function (content){
		var x = new Array();
		x['dsBodyLeft'] = this.cr('div','dsBodyLeft');
		x['dsTop'] = this.cr('div','dsTop');
		x['dsTopLeft'] = this.cr('div','dsTopLeft');
		x['dsBodyRight'] = this.cr('div','dsBodyRight');
		x['dsBody'] = this.cr('div','dsBody');
		x['dsBodyBg'] = this.cr('div','dsBodyBg');
		if(this.backgroundimage != null)
			x['bgimg'] = this.cr('img',this.backgroundimage.className);
		x['dsBodyContent'] = this.cr('div','dsBodyContent');
									
		x['dsBottom'] = this.cr('div','dsBottom');
		x['dsBottomLeft'] = this.cr('div','dsBottomLeft');
		if(this.backgroundimage != null)
			x['bgimg'].src = this.backgroundimage.src;
		x['dsBodyLeft'].appendChild(x['dsTop']);
		x['dsTop'].appendChild(x['dsTopLeft']);
		x['dsBodyLeft'].appendChild(x['dsBodyRight']);

		x['dsBodyRight'].appendChild(x['dsBody']);
		x['dsBodyRight'].appendChild(x['dsBottom']);
		x['dsBody'].appendChild(x['dsBodyBg']);
		x['dsBottom'].appendChild(x['dsBottomLeft']);
		if(this.backgroundimage != null){
			x['dsBodyBg'].appendChild(x['bgimg']);
			x['dsBodyBg'].appendChild(x['dsBodyContent']).innerHTML = content;
		}
		else
			x['dsBodyBg'].innerHTML = content;
		this.backgroundimage = null;
		return x['dsBodyLeft'];
	}
	this.getBoxes();

	this.cr = function(name,classname,innerHTML){
		var e = document.createElement(name);
		if(classname)
			e.className = classname;
		if(innerHTML)
			e.innerHTML = innerHTML;
		return e;
	}
	
	this.tagthis = function (obj){
		obj.tag = this.tag;
	}
	this.tagged = function (obj){
		return obj.tag == this.tag;
	}
}

ShadowBoxFactory.prototype.CreateShadow = function(targetid,backgroundimage)
{
	if(backgroundimage)
		this.backgroundimage = backgroundimage;
	if(!targetid){
		for(n=0;n<this.boxes.length;n++){
			if(!this.tagged(this.boxes[n])){
				var ofcourse = this.render(this.boxes[n].innerHTML);
				this.boxes[n].innerHTML = '';
				this.boxes[n].appendChild(ofcourse);
				if(this.boxes[n].parentNode.offsetWidth && this.boxes[n].parentNode.offsetWidth != 'undefined')
					this.boxes[n].style.width = (this.boxes[n].parentNode.offsetWidth+'px');
				this.tagthis(this.boxes[n]);
			}
		}
	}
	else{
		var target = document.getElementById(targetid);
		if(!target || this.tagged(target))
			return;
		var ofcourse = this.render(target.innerHTML);
		target.innerHTML = '';
		target.appendChild(ofcourse);
		if(target.parentNode.offsetWidth && target.parentNode.offsetWidth != 'undefined')
			target.style.width = (target.parentNode.offsetWidth+'px');
		this.tagthis(target);
	}
}
ShadowBoxFactory.prototype.CreateBgImage = function(src,classname)
{
	var img = new Image();
	img.src = src;
	img.className = classname;
	return img;
}
