/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	InsertElement.js - implements IE's insertAdjacentHTML and insertAdjacentText to DOM-based browsers
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	(c) Copyright Thor Larholm (thor@jscript.dk)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
if ( typeof(HTMLElement) != "undefined" ) {
	if ( !(HTMLElement.prototype.insertAdjacentElement) ) {
		HTMLElement.prototype.insertAdjacentElement = function(where,parsedNode) {
			switch (where) {
				case "beforeBegin":
					this.parentNode.insertBefore(parsedNode,this);
					break;
				case "afterBegin":
					this.insertBefore(parsedNode,this.firstChild);
					break;
				case "beforeEnd":
					this.appendChild(parsedNode);
					break;
				case "afterEnd":
					if (this.nextSibling) {
						this.parentNode.insertBefore(parsedNode, this.nextSibling);
					} else {
						this.parentNode.appendChild(parsedNode);
					}
					break;
			}
		};
		HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr) {
			var r = this.ownerDocument.createRange();
			r.setStartBefore(this);
			var parsedHTML = r.createContextualFragment(htmlStr);
			this.insertAdjacentElement(where,parsedHTML);
		};
		HTMLElement.prototype.insertAdjacentText = function(where,txtStr) {
			var parsedText = document.createTextNode(txtStr);
			this.insertAdjacentElement(where,parsedText);
		};
	}
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	AttachEventLib.js - AttachEvent Library v1.1 - allows multiple onEvent functions
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	(c) Copyright 2003, Aleksandar Vacic, aleck@sezampro.yu, www.aplus.co.yu
	## This work is licensed under the Creative Commons Attribution-ShareAlike License.
	## To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/1.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	v1.1 -	only for ONLOAD, ONRESIZE. add other events if you need them
			Load this script at the page begin.	
			Add your functions like this:
			- AE_AttachEvent("onload", "functionName");		//	DO NOT include brackets "()"
	12. 02. 03.	-	initial release, IE5+ uses it's own attachEvent method
	22. 04. 03.	-	IE doesn't start attached functions by the order they were attached. it seems it works randomly.
					hence this code is used in IE5+ too (with added benefit that browser-detection is removed)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

function AE_AttachEventSetup(oObj) {
	oObj.aeFN = new Array();
	oObj.attachEvent = AE_AttachEventFn;
	window.onload = AE_WindowOnload;
	window.onresize = AE_WindowOnresize;
}

function AE_AttachEventFn(sEvent, fpNotify) {
	if (this.aeFN[sEvent])
		this.aeFN[sEvent][this.aeFN[sEvent].length] = fpNotify;
	else {
		this.aeFN[sEvent] = new Array();
		this.aeFN[sEvent][this.aeFN[sEvent].length] = fpNotify;
	}
}

function AE_AttachEvent(sEvent, fpNotify) {
	if (!(sEvent == "onload" || sEvent == "onresize")) return;
	AE_oWindow.attachEvent(sEvent, fpNotify);
}

function AE_PlayEvent(sEvent) {
	eval("window." + sEvent);
	if (AE_oWindow.aeFN[sEvent])
		for (var i=0;i<AE_oWindow.aeFN[sEvent].length;i++)
			eval(AE_oWindow.aeFN[sEvent][i] + "()");
}

function AE_WindowOnload() {
	AE_PlayEvent("onload");
}

function AE_WindowOnresize() {
	AE_PlayEvent("onresize");
}

var AE_oWindow = new Object();
AE_AttachEventSetup(AE_oWindow);

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Browser Detect Lite  v2.1.4
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	http://www.dithered.com/javascript/browser_detect/index.html
	modified by Chris Nott (chris@NOSPAMdithered.com - remove NOSPAM)
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	stripped-down version.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function BrowserDetectLite() {
   var ua = navigator.userAgent.toLowerCase(); 
   this.isGecko     = (ua.indexOf('gecko') != -1 && ua.indexOf('like') == -1);
   this.isKHTML     = (ua.indexOf('khtml') != -1);
   this.isIE        = ( (ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) ); 
   this.isMac   = (ua.indexOf('mac') != -1);
}
var Browser = new BrowserDetectLite();
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	FormValidation.js - library contains code to validate HTML form-field data.
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	The bulk of this file was derived from Eric Krock's FormCheck.js at developer.netscape.com/docs/examples/javascript/formval/overview.html
	(Many thanks, Eric!) Enjoy ... and please maintain this header. Also thanks to Rick Scott who further developed this library
	(c) 1997 Netscape Communications Corporation
	(c) Copyright 2000, Rick Scott.
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	(c) Copyright 2002 Aleksandar Vacic, aleck@sezampro.yu, www.aplus.co.yu
	## This work is licensed under the Creative Commons Attribution-ShareAlike License.
	## To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/1.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	- added "namespace" FV for easier integration for other scripts
	- removed some string-munching functions from Rick's version
	- some functions renamed to shorter names (like FV_Trim to Trim)
	- removed all checks for letters since it works only with English language. Language independent functions needed. Time (for it) needed.
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	stripped-down version.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

var FV_sDigits = "0123456789";
var FV_sBlanks = " \t\n\r";	// aka whitespace chars
var FV_sDecimalPointDelimiter = "."; // decimal point character differs by language and culture

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Returns true if string s is empty
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function FV_IsEmpty(s){
	return ((s == null) || (s.length == 0));
}


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Returns true if string s is empty or all blank chars
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function FV_IsBlank(s){
	var i;
	var c;

	// Is s empty?
	if (FV_IsEmpty(s))
		return true;

	// Search through string's chars one by one until we find first non-blank char, then return false; if we don't, return true
	for (i=0; i<s.length; i++){	 
		// Check that current character isn't blank
		c = s.charAt(i);
		if (FV_sBlanks.indexOf(c) == -1) 
			return false;
	}

	// All characters are blank
	return true;
}


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Removes all characters which do NOT appear in string bag from string s
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function FV_StripCharsNotInBag(s, bag){
	var i;
	var c;
	var returnString = "";

	//	if bag is empty, no checks, just return input string
	if (bag == "") return s;

	// Search through string's characters one by one; if character is in bag, append to returnString
	for (i = 0; i < s.length; i++){	 
		// Check that current character isn't blank
		c = s.charAt(i);
		if (bag.indexOf(c) != -1) 
			returnString += c;
	}

	return returnString;
}


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Removes leading blank chars (as defined by FV_sBlanks) from s
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function FV_LTrim(s){ 
	var i = 0;
	while ((i < s.length) && (FV_sBlanks.indexOf(s.charAt(i)) != -1))
		 i++;
	return s.substring(i, s.length);
}


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Removes trailing blank chars (as defined by FV_sBlanks) from s
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function FV_RTrim(s){ 
	var i = s.length - 1;
	while ((i >= 0) && (FV_sBlanks.indexOf(s.charAt(i)) != -1))
		 i--;
	return s.substring(0, i+1);
}


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Removes leading+trailing blank chars (as defined by FV_sBlanks) from s
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function FV_Trim(s){ 
	s = FV_LTrim(s);
	s = FV_RTrim(s);
	return s;
}


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Returns true if character c is a digit (0 .. 9)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function FV_IsDigit(c){
	return ((c >= "0") && (c <= "9"));
}


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Returns true if all chars in string s are numbers;
	first character is allowed to be + or -; does not 
	accept floating point, exponential notation, etc.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function FV_IsInteger(s){
	if (FV_IsBlank(s))
		return false;

	// skip leading + or -
	if ((s.charAt(0) == "-") || (s.charAt(0) == "+"))
		var i = 1;
	else
		var i = 0;

	// Search through string's chars one by one until we find a non-numeric char, then return false; if we don't, return true
	var c;
	for (i; i<s.length; i++){	 
		// Check that current character is number
		c = s.charAt(i);
		if (!FV_IsDigit(c)) 
			return false;
	}

	// All characters are numbers
	return true;
}


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Returns true if string s is an integer such that a <= s <= b
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function FV_IsIntegerInRange(s, a, b){ 
	if (FV_IsBlank(s)) 
		return false;
	if (!FV_IsInteger(s)) 
		return false;
	var num = parseInt(s, 10);
	return ((num >= a) && (num <= b));
}


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	True if string s is an unsigned floating point (real) number; first character is allowed to be + or -; no exponential notation.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function FV_IsFloat(s){ 
	var seenDecimalPoint = false;

	if (FV_IsBlank(s)) 
		return false;
	if (s == FV_sDecimalPointDelimiter) 
		return false;

	// skip leading + or -
	if ((s.charAt(0) == "-") || (s.charAt(0) == "+"))
		var i = 1;
	else
		var i = 0;

	// Search through string's chars one by one until we find a non-numeric char, then return false; if we don't, return true
	var c;
	for (i; i<s.length; i++){	 
		// Check that current character is number
		c = s.charAt(i);

		if ((c == FV_sDecimalPointDelimiter) && !seenDecimalPoint) 
			seenDecimalPoint = true;
		else if (!FV_IsDigit(c)) 
			return false;
	}

	// All characters are numbers
	return seenDecimalPoint;
}


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Returns true if string is a valid email address: @ and . required, at least one char before @, at least one char before and after .
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function FV_IsEmail(strEmail) {
	if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		return true;
	else
		return false;
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Returns year in	4-digit format (e.g., 2000, not 0 or 100) 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function FV_GetYear2k(date){
	var year = date.getYear();
	if (year < 1000)
		year += 1900;
	return year;
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	check if this is a valid date (no Feb 31st and similar)	- argument nJan can mi omitted, when it defaults to 0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function FV_IsValidDate(sYear, sMonth, sDay, nJan) {
	if (nJan != 1) nJan = 0;
	var nDec = nJan + 11;
	if ( !FV_IsInteger(sYear) || !FV_IsIntegerInRange(sMonth, nJan, nDec) || !FV_IsIntegerInRange(sDay, 1, 31) )
		 return false;	

	var nDay = parseInt(sDay, 10);
	var nMonth = parseInt(sMonth, 10) - ((nJan == 1) ? 1 : 0);
	var nYear = parseInt(sYear, 10);
	var oDate = new Date(nYear, nMonth, nDay);

	if ( nDay == oDate.getDate() && nMonth == oDate.getMonth() && nYear == FV_GetYear2k(oDate) )
		return true;

	return false;
}


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	setup mandatory form elements for proper validation 
	XField = do not process
	sField = process as string
	nField = process as number
	bField = process as boolean (checkbox and radio state)

	mandatory fields have <label class="mandat">...
	<div class="badinput">... - indicates bad fields
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function FV_SetupForm(vForm){
	if (typeof(vForm) == "string")
		oForm = document.forms[vForm];
	else
		oForm = vForm;

	if (!oForm) return;

	//	ditch non-supporting browsers
	if (!oForm.parentNode) return;

	//	set onsubmit validation function
	oForm.onsubmit = function() {
		return FV_FormVal(this);
	};

	//	flag. if true, alert box will be shown on bad input 
	oForm.alertuser = false;

	//	flag to prevent multiple submits
	oForm.submitted = false; 

	var oElems = oForm.elements; 
	var nLen = oElems.length;
	var sTmp, oTmp, sTmp2;
	for (var i=0; i<nLen; i++) {
		oTmp = oElems[i];
		//	skip elements that don't have names (usually fieldset)
		if (typeof(oTmp.name) == "undefined") continue;

		sTmp2 = oTmp.name;
		sTmp = sTmp2.charAt(0).toLowerCase();
		//	process elements with names starting with b, s and n 
		if (sTmp != "b" && sTmp != "s" && sTmp != "n") continue;

		switch(oTmp.type) {
			case "text": case "select-one": case "password": case "textarea": 
				oLabels = oTmp.parentNode.getElementsByTagName("label");
				for (var j=0;j<oLabels.length;j++) {
					if (oLabels[j].className.indexOf("mandat") != -1 && oLabels[j].htmlFor == sTmp2) {
						oTmp.valme = function() {
							var oDiv = this.parentNode;

							if (this.type == "text")
								this.value = FV_Trim(this.value);

							bOk = FV_FieldVal(this);

							if (bOk)
								oDiv.className = oDiv.className.replace("badinput", "");
							else if (oDiv.className.indexOf("badinput") == -1) {
								oDiv.className += " badinput";
							}
							return bOk;
						};
						oTmp.onblur = oTmp.valme;
						break;			
					} 		
				}
				break; 		

			case "checkbox":				
				oLabel = oTmp.parentNode;
				if (oLabel.className.indexOf("mandat") != -1) {
	  				oTmp.valme = function(bShowMes) {
	  					var oDiv = this.parentNode.parentNode;
	
	  					var bOk = this.checked;
	
						if (!bOk) FV_FieldVal(this);

	  					if (bOk)
	  						oDiv.className = oDiv.className.replace("badinput", "");
	  					else if (oDiv.className.indexOf("badinput") == -1) {
	  						oDiv.className += " badinput";
	  						if (this.form.alertuser) FV_FieldVal(this);
	  					}
	  					return bOk;
	  				};
					oTmp.onblur = oTmp.valme;
				}
				break; 		

			case "radio":
				oLabel = oTmp.parentNode;
				if (oLabel.className.indexOf("mandat") != -1) {
					oTmp.valme = function(bShowMes) {
						var oDiv = this.parentNode.parentNode;

						var oRadios = this.form.elements[this.name];
						var bOk = false;
						for (var r=0;r<oRadios.length;r++) {
							if (oRadios[r].checked) {
								bOk = true; 
								break; 
							}
							FV_FieldVal(this);
						}

						if (bOk)
							oDiv.className = oDiv.className.replace("badinput", "");
						else if (oDiv.className.indexOf("badinput") == -1) {
							oDiv.className += " badinput";
	  						if (this.form.alertuser) FV_FieldVal(this);
						}
						return bOk;
					};
					oTmp.onblur = oTmp.valme;
				} 		
				break; 		
				
		}//switch oTmp.type
	}
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	handler function for specific fields		
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function FV_ShowMessage(sMes) {
	if (sMes != "")
		alert(sMes);
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	DropDownEngine.js - Library of functions to work with drop-down boxes (select lists)
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	(c) Copyright 2003, Aleksandar Vacic, aleck@sezampro.yu, www.aplus.co.yu
	## This work is licensed under the Creative Commons Attribution-ShareAlike License.
	## To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/1.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	stripped-down version.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
																							

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	returns pointer to form (or null).
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function DDB_Form(vF) {
	if (typeof(vF) != "string") return vF;
	if (document.forms[vF])
		vF = document.forms[vF];
	else
		vF = null;
	return vF;
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	returns pointer to form element (or null)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function DDB_Elem(vE, oForm) {
	if (typeof(vE) != "string") return vE;
	if (typeof(oForm) == "string") oForm = DDB_Form(oForm);
	if (oForm) {
		if (oForm.elements[vE])
			vE = oForm.elements[vE];
		else
			vE = null;
	} else {
		vE = null;
	}
	return vE;
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Add new option to select list
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function DDB_Add(sFormName, sSelectName, sText, sValue) {
	var oForm = DDB_Form(sFormName);
	var oSelect = DDB_Elem(sSelectName, oForm);
	
    var newoption = new Option(sText, sValue, true, true);
    oSelect.options[oSelect.length] = newoption;
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Removes all options
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function DDB_RemoveAll(sFormName, sSelectName) {
	var oForm = DDB_Form(sFormName);
	var oSelect = DDB_Elem(sSelectName, oForm);
	var i;

	for(i=0;i<oSelect.length;i++) {
        oSelect.options[i] = null;
		i--;
	}
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	takes the value of selected option which is an URL and loads it
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function DDB_Redirect(sFormName, sSelectName) {
	var oForm = DDB_Form(sFormName);
	var oSelect = DDB_Elem(sSelectName, oForm);
	var sValue = oSelect.options[oSelect.selectedIndex].value;
	if (sValue != "")
		location.href = sValue;
}


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	FiF.js - Floating IFrame v3.1
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	(c) Copyright 2003, Aleksandar Vacic, aleck@sezampro.yu, www.aplus.co.yu
	## This work is licensed under the Creative Commons Attribution License.
	## To view a copy of this license, visit http://creativecommons.org/licenses/by/2.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Works in:
	- IE5+ (Win and Mac)
	- Firefox 1.0+
	- Opera 7.5+
	- Safari 1+
	- OmniWeb 5.0+

	Dependencies: 
	- x.js
	- AttachEvent.js (only for IE5Mac)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

var FIF_Index = 0;
var FIF_IFrame = new Array();

function FIF_Frame( top, left, width, height, src, bIsStealth ) {
	//	deny all non-DOM browsers
	if (!document.getElementById && !document.documentElement && !document.getElementsByTagName) return null;
	
	var self = this;
	bIsStealth = (bIsStealth == true);

	//	some needed browser-detection
	var _sUA = navigator.userAgent.toLowerCase(); 
	var _bIsGecko = (_sUA.indexOf("gecko") != -1);	//	this works for KHTML-based too, since they have "like gecko" string in UAs (at least Safari and OmniWeb have)
	var _bIsMacIE = (_sUA.indexOf("mac") != -1 && _sUA.indexOf("msie") != -1);

	this.nTop = top;
	this.nLeft = left;
	this.nWidth = width;
	this.nHeight = height;
	this.sSrc = src;
	this.sID = FIF_Index;
	this.sName = "FIF_frame" + FIF_Index;
	this.bIsStealth = bIsStealth;
	this.oOpener = window;
	this.URLlimit = 1200;

	//	this loads passed URL in iFrame. has a bunch of browser tweaks, due to their inconsistency, bugs, and general lack of standard support.
	//	current time (FIFTime) is added to avoid page caching
	this.Load = function(sSrc) {
		sSrc = sSrc || self.sSrc;
		
		//	prepare cache hack
		var dTemp = new Date();
		var sTmp = "";
		if (sSrc.indexOf("?") != -1)
			sTmp += "&";
		else
			sTmp += "?";
		sTmp += "FIFTime=" + dTemp.getTime();

		if (sSrc.length < self.URLlimit-sTmp.length) {
			//	simple load of new document
			try {
				self.layer.src = sSrc + sTmp;
			} catch(exception) {
				if (self.layer) {
					if (self.layer.location)
						self.layer.location.href = sSrc + sTmp;
				} else if (document.frames && document.frames["FIF_frame" + self.sID]) {
					if (document.frames["FIF_frame" + self.sID].location)
						document.frames["FIF_frame" + self.sID].location.href = sSrc + sTmp;
				} else {
					setTimeout('FIF_IFrame[' + self.sID + '].Load("' + sSrc + '")', 500);
					return false;
				}
			}
		} else {
			//	must create form that will submit the data
			var oForm = null;
			try {
				var rform = null;
				if (rform = document.getElementById('form4fif'))
					document.body.removeChild(rform);

				var nUrl = sSrc.indexOf("?");
				var sAction = sSrc.substring(0, nUrl+1) + sTmp.substring(1);
				var aQS = sSrc.substring(nUrl+1).split("&");

				var tempForm = document.createElement('form');

				tempForm.setAttribute( 'action', sAction );
				tempForm.setAttribute( 'method', "post" );
				tempForm.setAttribute( 'name', "form4fif" );
				tempForm.setAttribute( 'id', "form4fif" );
				tempForm.setAttribute( 'target', 'FIF_frame' + self.sID );

				var aTmp;
				for (var cnt=0;cnt<aQS.length;cnt++) {
					aTmp = aQS[cnt].split( "=" );
					var tempFld = document.createElement( 'input' );
					tempFld.setAttribute( 'type', 'hidden' );
					tempFld.setAttribute( 'name', aTmp[0] );
					tempFld.setAttribute( 'id', aTmp[0] );
					tempFld.setAttribute( 'value', unescape(aTmp[1]) );
					tempForm.appendChild(tempFld);
				}

				oForm = document.body.appendChild(tempForm);
				tempForm = null;
				tempFld = null;

				if (!oForm && document.forms) {
					oForm = document.forms[document.forms.length];
				}
				if (!oForm) return false;
				oForm.submit();

			} catch(exception) {	//	only IE5.Mac gets here
				//	first get the document reference inside of iframe
				self.GetDocRef();
				//	clear it out
				self.doc.body.innerHTML = "";

				//	build the form HTML
				var nUrl = sSrc.indexOf("?");
				var sForm = '<form action="' + sSrc.substring(0, nUrl+1) + sTmp.substring(1) + '" method="post" id="form4fif" name="form4fif">';

				var aQS = sSrc.substring(nUrl+1).split("&");
				var aTmp;
				for (var cnt=0;cnt<aQS.length;cnt++) {
					aTmp = aQS[cnt].split("=");
					sForm += '<input type="hidden" name="' + aTmp[0] + '" id="' + aTmp[0] + '" value="' + unescape(aTmp[1]) + '" />\n';
				}

				sForm += '</form>';
				//	append to doc
				self.doc.body.innerHTML = sForm;
				//	submit
				oForm = self.doc.forms[0];
				oForm.submit();
			}	//	try-catch

		}//	if-else

		self.sSrc = sSrc;
		return true;
	};

	if (!bIsStealth) {
		this.bIsShown = true;
		this.bIsOn = true;
	}
	this.Show = function() { xShow(this.layer); this.bIsShown = true; };
	this.Hide = function() { xHide(this.layer); this.bIsShown = false; };
	this.On = function() { xOn(this.layer); this.bIsOn = true; };
	this.Off = function() { xOff(this.layer); this.bIsOn = false; };

	this.MoveTo = function(nL, nT) { if (typeof(nL) != "undefined") this.nLeft = nL; if (typeof(nT) != "undefined") this.nTop = nT; xMoveTo(this.layer, nL, nT); };
	this.Left = function(nL) { if (typeof(nL) != "undefined") this.nLeft = nL; return xLeft(this.layer, nL); };
	this.Top = function(nT) { if (typeof(nT) != "undefined") this.nTop = nT; return xTop(this.layer, nT); };

	this.ResizeTo = function(nW, nH) { if (typeof(nW) != "undefined") this.nWidth = nW; if (typeof(nH) != "undefined") this.nHeight = nH; xResizeTo(this.layer, nW, nH); };
	this.Width = function(nW) { if (typeof(nW) != "undefined") this.nWidth = nW; return xWidth(this.layer, nW); };
	this.Height = function(nH) { if (typeof(nH) != "undefined") this.nHeight = nH; return xHeight(this.layer, nH); };

	this.PageX = function() { return xPageX(this.layer) };
	this.PageY = function() { return xPageY(this.layer) };
/*
	if ( src.indexOf("://") != -1 ) {
		if ( src.indexOf(document.domain) == -1 ) {
			alert("FloatingIFrame: Sorry, the src you specified (" + src + ") is not in this domain. You can't load URLs outside " + document.domain);
			return;
		}
	}
*/
	//	write the iframe to the page
	if (bIsStealth) {
		var sVis = 'visibility:hidden;';
	} else {
		var sVis = '';
	}

	var sTmp = '<iframe' +
	' width="' + width + '" height="' + height + '"' +
	' scrolling="yes"' +
	' frameborder="0"' +
	' name="FIF_frame' + FIF_Index + '" ' +
	' id="FIF_frame' + FIF_Index + '" ' +
	' style="position:absolute;' + sVis + 'left:' + left + 'px;top:' + top + 'px;border:1px solid #000;"' + 
	' src="' + src + '">' + 
	'</iframe>\n';
	document.write(sTmp);
	document.close();

	//	fetch the reference to the iframe
	this.layer = null;
	this.GetLayerRef = function() {
		self.layer = document.getElementById("FIF_frame" + self.sID);
	};

	//	fetch the reference to the document object inside of the layer  
	this.doc = null;
	this.bIsDocSet = false;
	this.GetDocRef = function() {
		if (!self.layer) return;
		self.doc = null;
		try {
			if (_bIsMacIE) {
				self.doc = document.frames["FIF_frame" + self.sID].document;
			} else {
				self.doc = (self.layer.contentWindow || self.layer.contentDocument);
				if (self.doc && self.doc.document) self.doc = self.doc.document;
			}
			self.bIsDocSet = true;
		} catch(exception) {
			self.bIsDocSet = false;
			setTimeout('FIF_IFrame[' + self.sID + '].GetDocRef()', 100);
		}
	};

	//	enumerate
	FIF_Index++;
	FIF_IFrame[this.sID] = this;

	//	setup references...
	this.Setup = function() {
		self.GetLayerRef();
	};

	//	...on page load
	if (window.addEventListener) {	//	gecko, khtml
		window.addEventListener("load", FIF_IFrame[this.sID].Setup, false);
	} else if (window.attachEvent) {	//	IE5+ Win
		window.attachEvent("onload", FIF_IFrame[this.sID].Setup);
	} else if (typeof(AE_oWindow) != "undefined") {	//	IE5 Mac and all else
		AE_AttachEvent("onload", "FIF_IFrame[" + this.sID + "].Setup")
	}
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Flash.js - Flash handling library. For writing in-page Flash movies
	ver 2.3, Jul 12,2005
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	(c) Copyright 2005, Aleksandar Vacic, www.aplus.co.yu
	## This work is licensed under the Creative Commons BY-2.0 license
	## To view a copy of this license, visit http://creativecommons.org/licenses/by/2.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

<!--[if IE]>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
	codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"
	width="269" height="34">
<param name="movie" value="assets/countdown_greatbritain.swf" />
<param name="wmode" value="transparent" />
<param name="quality" value="high" />
<img src="assets/countdown_greatbritain.gif" 
	width="269" height="34"
	alt="Countdown to British GP - you need Flash to see it" border="0" />
</object>
<![endif]-->

<!--[if !IE]> <-->
<object data="assets/countdown_greatbritain.swf"
	type="application/x-shockwave-flash"
	width="269" height="34">
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
<param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer" />
<img src="assets/countdown_greatbritain.gif" 
	width="269" height="34" 
	alt="Countdown to British GP - you need Flash to see it" border="0" />
</object>
<!--> <![endif]-->

	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	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 SWF_bUseFlash = true;

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	VBScript function for IE ActiveX check
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
var SWF_IE = '<scr' + 'ipt language="VBScript"\> \n';
SWF_IE += 'Function SWF_Check4FlashVerIE(sVer) \n';
SWF_IE += 'On Error Resume Next \n';
SWF_IE += 'Dim obFlash, bRet \n';
SWF_IE += 'bRet = False \n';
SWF_IE += '   Set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash." & Left(sVer, 1)) \n';
SWF_IE += '   If IsObject(obFlash) Then bRet = True \n';
SWF_IE += 'SWF_Check4FlashVerIE = bRet \n';
SWF_IE += 'End Function \n';
SWF_IE += '</scr' + 'ipt\> \n';
document.write(SWF_IE);

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	this checks for specific version 	
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function SWF_Check4FlashVer(sVer) {
	var agent = navigator.userAgent.toLowerCase(); 
	
	// NS3 needs SWF_FlashVer to be a local variable
	if (agent.indexOf("mozilla/3") != -1 && agent.indexOf("msie") == -1) {
		return false;
	}
   
	// 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') { 
			var nTmp = parseFloat( flashPlugin.description.substring(16).replace(/\s+/gi, "").replace(/r/gi, "") );
			sVer = sVer.replace(/,/gi, "");
			sVer = sVer.charAt(0) + "." + sVer.substring(1); 
			var nVer = parseFloat(sVer);
            if (nTmp >= nVer)
				return true;
		}
	}

	// 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) {
		return SWF_Check4FlashVerIE(sVer);
	}
		
	// Can't detect in all other cases
	else {
		return false;
	}

	return false;
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	this tries to detect the version	
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function SWF_GetFlashVer() {
	var latestFlashVersion = 10;
	var agent = navigator.userAgent.toLowerCase(); 
	
	// NS3 needs SWF_FlashVer to be a local variable
	if (agent.indexOf("mozilla/3") != -1 && agent.indexOf("msie") == -1) {
		SWF_FlashVer = 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) {
               SWF_FlashVer = 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 += '      SWF_FlashVer = 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) SWF_FlashVer = 3;

	// older WebTV supports flash 2
	else if (agent.indexOf("webtv") != -1) SWF_FlashVer = 2;

	// Can't detect in all other cases
	else {
		SWF_FlashVer = -1;
	}

	return SWF_FlashVer;
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	function for Flash write
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function SWF_WriteFlashContent(sFileName, nWidth, nHeight, sAltExt, sLink, bNoAlt, sProtocol, sSiteAddr, sVer) {
	var sWriteContent = "";
	var sFlashContent = "";
	var sAlternateContent = "";
	
	if (typeof(sLink) == "undefined")
		sLink = "";

	if (typeof(bNoAlt) == "undefined")
		bNoAlt = false;

	if (typeof(sVer) == "undefined")
		sVer = "6,0,0,0";

	if (typeof(sProtocol) == "undefined")
		sProtocol = "http://";

	if (typeof(sSiteAddr) == "undefined" || sSiteAddr == "" || sSiteAddr == "/")
		sSiteAddr = sProtocol + location.host + "/";

	if (typeof(sAltExt) == "undefined")
		sAltExt += '.gif" ';

	if (!SWF_Check4FlashVer(sVer))
		SWF_bUseFlash = false;

	if (SWF_bUseFlash) {

		if (!bNoAlt) {
			sAlternateContent += '\n';
			if (sLink != "") {
				sAlternateContent += '<a href="' + sLink + '">';
			}
			sAlternateContent += '<img src="' + sFileName.replace(".swf", "") + sAltExt + '" ';
			if ( typeof(nWidth) != "undefined" )
				sAlternateContent += ' width="' + nWidth + '" ';
			if ( typeof(nHeight) != "undefined" )
				sAlternateContent += ' height="' + nHeight + '" ';
			sAlternateContent += ' border="0" />';
			if (sLink != "")
				sAlternateContent += '</a>';
		}

		//	fix the filename for data attribute of the object tag
		var sFixedFileName = sFileName;
		if (sFileName.charAt(0) == "/")
			sFixedFileName = sFileName.substring(1);
		else {
			sFixedFileName = location.pathname.substring(1, location.pathname.lastIndexOf("/") + 1) + sFileName; 
		}

		sFlashContent += '\n<!--[if IE]>';
		sFlashContent += '\n<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
		sFlashContent += ' codebase="' + sProtocol + 'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + sVer + '"';
		if ( typeof(nWidth) != "undefined" )
			sFlashContent += ' width="' + nWidth + '" ';
		if ( typeof(nHeight) != "undefined" )
			sFlashContent += ' height="' + nHeight + '" ';
		sFlashContent += '>';
		sFlashContent += '\n<param name="movie" value="' + sFileName;
		if (sLink != "")
			sFlashContent += '?blink=' + escape(sLink);
		sFlashContent += '" />';
		sFlashContent += '\n<param name="wmode" value="transparent" />';
		sFlashContent += '\n<param name="quality" value="high" />';
		sFlashContent += sAlternateContent;
		sFlashContent += '\n</object>';
		sFlashContent += '\n<![endif]-->';

		sFlashContent += '\n<!--[if !IE]> <-->';
		sFlashContent += '\n<object data="' + sSiteAddr + sFixedFileName;
		if (sLink != "")
			sFlashContent += '?blink=' + escape(sLink);
		sFlashContent += '" type="application/x-shockwave-flash"';
		if ( typeof(nWidth) != "undefined" )
			sFlashContent += ' width="' + nWidth + '" ';
		if ( typeof(nHeight) != "undefined" )
			sFlashContent += ' height="' + nHeight + '" ';
		sFlashContent += '>';
		sFlashContent += '\n<param name="quality" value="high" />';
		sFlashContent += '\n<param name="wmode" value="transparent" />';
		sFlashContent += '\n<param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer" />';
		sFlashContent += sAlternateContent;
		sFlashContent += '\n</object>';
		sFlashContent += '\n<!--> <![endif]-->';
	}

	if ( SWF_bUseFlash ) {
		sWriteContent = sFlashContent;
	} else {
		sWriteContent = sAlternateContent;
	}

	return sWriteContent;
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	x.js - X-DOM, modification of cross-browser DHTML Library from Cross-Browser.com
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Copyright (c) 2002, 2003 Michael Foster (mike@cross-browser.com)
	This library is distributed under the terms of the LGPL (gnu.org)
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	This DOM-only version by Aleksandar Vacic, www.aplus.co.yu
	- works only with DOM compatible browsers
	- Event part of the library removed
	- functions don't check for argument lengths, but whether arguments are defined (passed)
	- xPageX and xPageY don't call xParent, they directly use e.offset* (since calculation is solely based on .offset* properties)
	- added function xGetAnyCS which returns any computed style property
	- added xOn, xOff, which toggles display property. also xIsOn and xIsShown which checks if element is displayed, visible
	- added xStick and xStickScroll (based on code by Peter Paul Koch) - layer will follow user while he scrolls down
	- added xGetAnySP which return style property, either from DOM or CSS
	- added xContX and xContY which calculate offset up to first parent (container) which has position relative or absolute
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	stripped-down version.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Variables
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
var xOp7 = false, xIE = false, xUA = navigator.userAgent.toLowerCase();
if (window.opera) {
	xOp7 = ( xUA.indexOf("opera 7") != -1 || xUA.indexOf("opera/7") != -1 );
} else {
	xIE = ( xUA.indexOf("msie") != -1 );
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Appearance
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function xOn(e, sV) {
	if ( !(e = xGetElementById(e)) ) return;
	if ( xDef(sV) )
		e.style.display = sV;
	else
		e.style.display = "block";
}
function xOff(e) {
	if ( !(e = xGetElementById(e)) ) return;
	e.style.display = "none";
}
function xIsOn(e) {
	if ( !(e = xGetElementById(e)) ) return;
	var bRet = true;
	if (e.style.display == "") {
		bRet = !(xGetAnyCS(e, "display") == "none");
	} else {
		bRet = !(e.style.display == "none");
	}
	return bRet;
}
function xShow(e) {
	if ( !(e = xGetElementById(e)) ) return;
	e.style.visibility = "visible"; // v3.12, e.style.visibility='inherit';
}
function xHide(e) {
	if ( !(e = xGetElementById(e)) ) return;
	e.style.visibility = "hidden";
}
function xIsShown(e) {
	if ( !(e = xGetElementById(e)) ) return;
	var bRet = true;
	if (e.style.visibility == "")
		bRet = !(xGetAnyCS(e, "visibility") == "hidden");
	else
		bRet = !(e.style.visibility == "hidden");
	return bRet;
}
function xZIndex(e, uZ) {
	if ( !(e = xGetElementById(e)) ) return 0;
	if ( xDef(uZ) )
		e.style.zIndex = uZ;
    else
		uZ = e.style.zIndex;
	return uZ;
}
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Position
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function xMoveTo(e, iX, iY) {
	xLeft(e,iX);
	xTop(e,iY);
}
function xLeft(e, iX) {
	if ( !(e = xGetElementById(e)) ) return 0;
    if ( xDef(iX) )
		e.style.left = iX + "px";
	else {
    	if ( xDef(e.offsetLeft) )
			iX = e.offsetLeft; // v3.12
		else
			iX = parseInt(e.style.left);
    	if (isNaN(iX))
			iX = 0;
	}
	return iX;
}
function xTop(e, iY) {
	if ( !(e = xGetElementById(e)) ) return 0;
    if ( xDef(iY) )
		e.style.top = iY + "px";
	else {
		if ( xDef(e.offsetTop) )
			iY = e.offsetTop; // v3.12
		else
			iY = parseInt(e.style.top);
		if (isNaN(iY))
			iY = 0;
	}
	return iY;
}
function xPageX(e) {
	if ( !(e = xGetElementById(e)) ) return 0;
	var x = 0;
	while (e) {
		if ( xDef(e.offsetLeft) ) x += e.offsetLeft;
		else break;
		e = e.offsetParent;
	}
	return x;
}
function xPageY(e) {
	if ( !(e = xGetElementById(e)) ) return 0;
	var y = 0;
	while (e) {
		if ( xDef(e.offsetTop) ) y += e.offsetTop;
		else break;
		e = e.offsetParent;
	}
	return y;
}

function xStick(e) {
	if ( !(e = xGetElementById(e)) ) return;

	if ( !xDef(e.stick) ) {
		e.stick = false;
		e.stickOldPos = 0;
		e.stickStart = xTop(e);
		e.stickSub = xPageY(e) - e.stickStart;
		e.style.position = "absolute";
	}
	e.stick = (e.stick) ? false : true;
	if ( !e.stick ) {
		clearTimeout(e.stickTimer);
	}
}
function xStickScroll(e) {
	if ( !(e = xGetElementById(e)) ) return;

	var nPos;
	if (e.stick) {
		nPos = xScrollTop();
		if ( nPos < e.stickSub+e.stickStart )
			nPos = e.stickStart;
		else
			nPos -= e.stickSub;
		if ( nPos != e.stickOldPos )
			xTop( e, nPos );
		e.stickOldPos = nPos;
		e.stickTimer = setTimeout("xStickScroll('" + e.id + "')", 300);
	}
}
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Size
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function xResizeTo(e, uW, uH) {
	xWidth(e,uW);
	xHeight(e,uH);
}
function xWidth(e, uW) {
	if ( !e || (uW && uW<0) ) return 0;
	if ( xDef(uW) ) {
		uW = Math.round(uW);
		xSetCW(e, uW);
	}
	uW = e.offsetWidth;
	return uW;
}
function xHeight(e, uH) {
	if ( !e || (uH && uH<0) ) return 0;
	if ( xDef(uH) ) {
		uH = Math.round(uH);
		xSetCH(e, uH);
	}
	uH=e.offsetHeight;
	return uH;
}
function xGetCS(ele,sP){
	return parseInt(document.defaultView.getComputedStyle(ele,"").getPropertyValue(sP));
}
function xSetCW(ele,uW){
	if (uW < 0) return;

	var pl=0, pr=0, bl=0, br=0;
	if ( xDef(document.defaultView) && xDef(document.defaultView.getComputedStyle) ) {
		pl = xGetCS(ele, "padding-left");
		pr = xGetCS(ele, "padding-right");
		bl = xGetCS(ele, "border-left-width");
		br = xGetCS(ele, "border-right-width");
	} else if ( xDef(ele.currentStyle, document.compatMode) ) {
		if(document.compatMode == "CSS1Compat"){
			pl = parseInt(ele.currentStyle.paddingLeft);
			pr = parseInt(ele.currentStyle.paddingRight);
			bl = parseInt(ele.currentStyle.borderLeftWidth);
			br = parseInt(ele.currentStyle.borderRightWidth);
		}
	} else if ( xDef(ele.offsetWidth, ele.style.width) ) {
		ele.style.width = uW + "px";
		pl = ele.offsetWidth - uW;
	}
	if ( isNaN(pl) ) pl=0;
	if ( isNaN(pr) ) pr=0;
	if ( isNaN(bl) ) bl=0;
	if ( isNaN(br) ) br=0;
	var cssW = uW - (pl+pr+bl+br);
	if ( isNaN(cssW) || cssW<0 )
		return;
	else
		ele.style.width = cssW + "px";
}
function xSetCH(ele, uH){
	if (uH < 0) return;

	var pt=0, pb=0, bt=0, bb=0;
	if ( xDef(document.defaultView) && xDef(document.defaultView.getComputedStyle) ) {
		pt = xGetCS(ele,"padding-top");
		pb = xGetCS(ele,"padding-bottom");
		bt = xGetCS(ele,"border-top-width");
		bb = xGetCS(ele,"border-bottom-width");
	}
	else if (xDef(ele.currentStyle,document.compatMode)) {
		if (document.compatMode == "CSS1Compat"){
			pt=parseInt(ele.currentStyle.paddingTop);
			pb=parseInt(ele.currentStyle.paddingBottom);
			bt=parseInt(ele.currentStyle.borderTopWidth);
			bb=parseInt(ele.currentStyle.borderBottomWidth);
		}
	}
	else if ( xDef(ele.offsetHeight, ele.style.height) ) {
		ele.style.height = uH + "px";
		pt = ele.offsetHeight - uH;
	}
	if ( isNaN(pt) ) pt=0;
	if ( isNaN(pb) ) pb=0;
	if ( isNaN(bt) ) bt=0;
	if ( isNaN(bb) ) bb=0;
	var cssH = uH - (pt+pb+bt+bb);
	if ( isNaN(cssH) || cssH<0 )
		return;
	else
		ele.style.height = cssH + "px";
}
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Object
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function xGetElementById(e) {
	if (typeof(e) != "string") return e;
	if (document.getElementById)
		e = document.getElementById(e);
	else
		e = null;
	return e;
}
function xParent(e){
	if ( !(e = xGetElementById(e)) ) return null;

	var p = null;
	if ( xDef(e.parentNode) )
		p = e.parentNode;
	else if ( xDef(e.parentElement) )
		p = e.parentElement;
	else if ( xDef(e.offsetParent) )
		p = e.offsetParent;

	return p;
}
function xDef() {
	for (var i=0; i<arguments.length; ++i) {
		if ( typeof(arguments[i]) == "undefined" )
			return false;
	}
	return true;
}
function xGetAnyCS(oEle, sProp) {
	var p = "";
	if(document.defaultView && document.defaultView.getComputedStyle){
		p = document.defaultView.getComputedStyle(oEle,'').getPropertyValue(sProp)
	} else if(oEle.currentStyle) {
		// convert css property name to object property name for IE
		var a = sProp.split('-');
		sProp = a[0];
		for (var i=1; i<a.length; ++i) {
			c = a[i].charAt(0);
			sProp += a[i].replace(c, c.toUpperCase());
		}   
		p = oEle.currentStyle[sProp];
	}
	return p;
}
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Window
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function xScrollLeft() {
	var offset = 0;
	if ( xDef(window.pageXOffset) )
		offset = window.pageXOffset;
	else if ( document.documentElement && document.documentElement.scrollLeft )
		offset = document.documentElement.scrollLeft;
	else if ( document.body && xDef(document.body.scrollLeft ) )
		offset = document.body.scrollLeft;
	return offset;
}
function xScrollTop() {
	var offset = 0;
	if ( xDef(window.pageYOffset) )
		offset = window.pageYOffset;
	else if ( document.documentElement && document.documentElement.scrollTop )
		offset = document.documentElement.scrollTop;
	else if ( document.body && xDef(document.body.scrollTop ) )
		offset = document.body.scrollTop;
	return offset;
}
function xClientWidth() {
	var w=0;
	if ( !window.opera && document.documentElement && document.documentElement.clientWidth ) // v3.12
		w=document.documentElement.clientWidth;
	else if ( document.body && document.body.clientWidth )
		w = document.body.clientWidth;
	return w;
}
function xClientHeight() {
	var h=0;
	if ( !window.opera && document.documentElement && document.documentElement.clientHeight ) // v3.12
		h = document.documentElement.clientHeight;
	else if ( document.body && document.body.clientHeight )
		h = document.body.clientHeight;
	return h;
}

function xGetElementsByClassName(clsName, parentEle, tagName, fn)
{
  var found = new Array();
  var re = new RegExp('\\b'+clsName+'\\b', 'i');
  var list = xGetElementsByTagName(tagName, parentEle);
  for (var i = 0; i < list.length; ++i) {
    if (list[i].className.search(re) != -1) {
      found[found.length] = list[i];
      if (fn) fn(list[i]);
    }
  }
  return found;
}
function xGetElementsByTagName(tagName, parentEle)
{
  var list = null;
  tagName = tagName || '*';
  parentEle = parentEle || document;
  if (xIE) {
    if (tagName == '*') list = parentEle.all;
    else list = parentEle.all.tags(tagName);
  }
  else if (parentEle.getElementsByTagName) list = parentEle.getElementsByTagName(tagName);
  return list || new Array();
}
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	WCH.js - Windowed Controls Hider v3.10
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	(c) Copyright 2003, Aleksandar Vacic, aleck@sezampro.yu, www.aplus.co.yu
	## This work is licensed under the Creative Commons Attribution-ShareAlike License.
	## To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/1.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Credits: Mike Foster for x functions (cross-browser.com)
	Credits: Tim Connor for short and sweet way of dealing with IE5.0 - dynamic creation of style rule (www.infosauce.com)
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Based on idea presented by Joe King. Works with IE5.0+/Win
	IE 5.5+: place iFrame below the layer to hide windowed controls
	IE 5.0 : hide/show all elements that have "WCHhider" class
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
var WCH_Constructor = function() {
	//	exit point for anything but IE5.0+/Win
	if ( !(document.all && document.getElementById && !window.opera && navigator.userAgent.toLowerCase().indexOf("mac") == -1) ) {
		this.Apply = function() {};
		this.Discard = function() {};
		return;
	}

	//	private properties
	var _bIE55 = false;
	var _bIE6 = false;
	var _oRule = null;
	var _bSetup = true;
	var _oSelf = this;

	//	public: hides windowed controls
	this.Apply = function(vLayer, vContainer, bResize) {
		if (_bSetup) _Setup();

		if ( _bIE55 && (oIframe = _Hider(vLayer, vContainer, bResize)) ) {
			oIframe.style.visibility = "visible";
		} else if(_oRule != null) {
			_oRule.style.visibility = "hidden";
		}

	};

	//	public: shows windowed controls
	this.Discard = function(vLayer, vContainer) {
		if ( _bIE55 && (oIframe = _Hider(vLayer, vContainer, false)) ) {
			oIframe.style.visibility = "hidden";
		} else if(_oRule != null) {
			_oRule.style.visibility = "visible";
		}
	};

	//	private: returns iFrame reference for IE5.5+
	function _Hider(vLayer, vContainer, bResize) {
		var oLayer = _GetObj(vLayer);
		var oContainer = ( (oTmp = _GetObj(vContainer)) ? oTmp : document.getElementsByTagName("body")[0] );
		if (!oLayer || !oContainer) return;
		//	is it there already?
		var oIframe = document.getElementById("WCHhider" + oLayer.id);
		
		//	if not, create it
		if ( !oIframe ) {
			//	IE 6 has this property, IE 5 not. IE 5.5(even SP2) crashes when filter is applied, hence the check
			var sFilter = (_bIE6) ? "filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0);" : "";
			//	get z-index of the object
			var zIndex = oLayer.style.zIndex;
			if ( zIndex == "" ) zIndex = oLayer.currentStyle.zIndex;
			zIndex = parseInt(zIndex);
			//	if no z-index, do nothing
			if ( isNaN(zIndex) ) return null;
			//	if z-index is below 2, do nothing (no room for Hider)
			if (zIndex < 2) return null;
			//	go one step below for Hider
			zIndex--;
			var sHiderID = "WCHhider" + oLayer.id;
			oContainer.insertAdjacentHTML("afterBegin", '<iframe class="WCHiframe" src="javascript:false;" id="' + sHiderID + '" scroll="no" frameborder="0" style="position:absolute;visibility:hidden;' + sFilter + 'border:0;top:0;left;0;width:0;height:0;background-color:#ccc;z-index:' + zIndex + ';"></iframe>');
			oIframe = document.getElementById(sHiderID);
			//	then do calculation
			_SetPos(oIframe, oLayer);
		} else if (bResize) {
			//	resize the iFrame if asked
			_SetPos(oIframe, oLayer);
		}
		return oIframe;
	};

	//	private: set size and position of the Hider
	function _SetPos(oIframe, oLayer) {
		//	fetch and set size
		oIframe.style.width = oLayer.offsetWidth + "px";
		oIframe.style.height = oLayer.offsetHeight + "px";
		//	move to specified position
		oIframe.style.left = oLayer.offsetLeft + "px";
		oIframe.style.top = oLayer.offsetTop + "px";
	};

	//	private: returns object reference
	function _GetObj(vObj) {
		var oObj = null;
		switch( typeof(vObj) ) {
			case "object":
				oObj = vObj;
				break;
			case "string":
				oObj = document.getElementById(vObj);
				break;
		}
		return oObj;
	};

	//	private: setup properties on first call to Apply
	function _Setup() {
		_bIE55 = (typeof(document.body.contentEditable) != "undefined");
		_bIE6 = (typeof(document.compatMode) != "undefined");

		if (!_bIE55) {
			if (document.styleSheets.length == 0)
				document.createStyleSheet();
			var oSheet = document.styleSheets[0];
			oSheet.addRule(".WCHhider", "visibility:visible");
			_oRule = oSheet.rules(oSheet.rules.length-1);
		}

		_bSetup = false;
	};
};
var WCH = new WCH_Constructor();

/*
XHConn - Simple XMLHTTP Interface - bfults@gmail.com - 2005-04-08
Code licensed under Creative Commons Attribution-ShareAlike License
http://creativecommons.org/licenses/by-sa/2.0/

AjaxConn - Finsoft's upgrade of XHConn
ver 1.2 - Aug 15 2005
*/

function AjaxConn() {
	var self = this;

	var xmlhttp, bComplete = false;
	try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
	catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
	catch (e) { try { xmlhttp = new XMLHttpRequest(); }
	catch (e) { xmlhttp = false; }}}
	if (!xmlhttp) return null;

	//	is connection free to use?
	this.bIsFree = true;
	
	//	true = async request, false = sync request
	this.bIsAsync = true;
	
	//	result returned from server
	this.responseText = "";
	this.status = "";

	//	set that connection is free to be used again. save responseText
	function _Done() {
		self.bIsFree = true;
		self.responseText = xmlhttp.responseText;
		self.status = xmlhttp.status;
		self.Done();
	}
	//	allows executing specific actions after operation has completed
	this.Done = function() {};

	this.connect = function(sMethod, sURL, sVars) {
		if (!xmlhttp) return false;
		bComplete = false;
		sMethod = sMethod.toUpperCase();
		
		this.bIsFree = false;
		this.responseText = "";
		this.status = "";

		//	Finsoft's hack for stupid IE and its caching or URLs and responses
		if (sVars && sVars != "")
			sVars += "&";
		sVars += "fh4sie=" + (new Date()).getTime();

		try {
			if (sMethod == "GET") {
				sURL += "?" + sVars;
				xmlhttp.open(sMethod, sURL, this.bIsAsync);
			} else {
				xmlhttp.open(sMethod, sURL, this.bIsAsync);
				xmlhttp.setRequestHeader("Method", "POST " + sURL + " HTTP/1.1");
				xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			}
			xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4 && !bComplete) {
					bComplete = true;
					_Done();
				}
			};
			xmlhttp.send(sVars);
		} catch(z) { return false; }

		return true;
	};

	return self;
}


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	IEHover.js - simulates LI:hover for IE, v1.0
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	pass the ID of the UL. call on window.onload
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function IEHover(sID) {
	if (document.all && document.getElementById) {
		navRoot = document.getElementById(sID);
		if (! (navRoot && navRoot.childNodes && navRoot.childNodes.length) ) return;
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName.toUpperCase() == "LI") {
				node.onmouseover=function() {
					this.className+=" over";
				};
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				};
			}
		}
	}
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Global.js - Functions used all over the web site
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	(c) Copyright 2003, Finsoft Ltd
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

//	string of allowed characters for username and password
var SG_sInUserAllow = "0123456789abcdefghijklmnoprstquvwxyzABCDEFGHIJKLMNOPRSTQUVWXYZ_.@";
//	referer URL
var sURLRef = "";

var SG_sCurrency = "&pound;";

var BS = null;
var LU = null;
var BE = null;


//	hide Go! button in betting navigation
document.write( '<style "type="text/css" media="all">#BNGo{display:none !important}</style>' );


function InR_WriteHeader() {}
function ToggleRPTmpl() {}


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	rounds number to specified number of decimals
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function SG_Round(nNum, nNumOfDecimals) {
    var nRes1 = nNum * Math.pow(10, nNumOfDecimals);
    var nRes2 = Math.round(nRes1);
    var nRes3 = nRes2 / Math.pow(10, nNumOfDecimals);
	return nRes3;
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	returns STRING which has sChar repeated nNum times
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function SG_String(nNum, sChar) {
	var sRet = "";
	for (var i=0;i<nNum;i++)
		sRet += sChar;
	return sRet;
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	returns STRING with specified number of decimal figures
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function SG_GetNumWithDecimals(nAmount, nNumOfDecimals) {
	var sRet = "";

	if ( nAmount == null ) {
		sRet = "0." + SG_String(nNumOfDecimals,"0");
	} else {
		var nRet = SG_Round(nAmount, nNumOfDecimals);
		// Convert the number to a string
		var sRet = nRet.toString();
		// Locate the decimal point
		var decimal_location = sRet.indexOf(".");

		// Is there a decimal point?
		if (decimal_location == -1) {
			// If no, then all decimal places will be padded with 0s
			decimal_part_length = 0;
			// If decimal_places is greater than zero, tack on a decimal point
			sRet += nNumOfDecimals > 0 ? "." : "";
		} else {
			// If yes, then only the extra decimal places will be padded with 0s
			decimal_part_length = sRet.length - decimal_location - 1;
		}
		
		// Calculate the number of decimal places that need to be padded with 0s
		var pad_total = nNumOfDecimals - decimal_part_length;

		if (pad_total > 0) {
			// Pad the string with 0s
			for (var counter = 1; counter <= pad_total; counter++) 
				sRet += "0";
		}
	}

	return sRet;
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	visually toggles free class. toggles the other balance as well
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function SG_ToggleFreeClass(sFreeID, sID, bChecked) {
	if (!document.getElementById) return;

	var oFBtr = document.getElementById(sFreeID);
	var oBtr = document.getElementById(sID);
	var sClassName = "balance";
	var sFreeClassName = "balance";
	if (oFBtr && oBtr) {
		if (bChecked) {
			oFBtr.className = sFreeClassName + "on";
			oBtr.className = sClassName;
		} else {
			oFBtr.className = sFreeClassName;
			oBtr.className = sClassName + "on";
		}// bChecked
	}
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	check for Free balance
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function SG_IsFree() {
	var oForm = document.forms["login"];
	if (!oForm) return false;
	var oChk = oForm.elements["scfree"];
	if (!oChk) return false;
	var bChecked = oChk.checked;
	return bChecked;
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	open pop-up window
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function SG_ShowWin(sUrl, sName, xWidth, xHeight) {
	if (!xWidth) xWidth = 600;
	if (!xHeight) xHeight = 400;
	SG_ShowWnd(sUrl, sName, xWidth, xHeight, 1);
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	continue betting button, onClick handler
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function SG_ContinueBetting() {
	var aForms = document.forms;
	for (var i=0;i<aForms.length;i++) {
		if (!aForms[i]) continue;

		oContBet = aForms[i].elements["xContbet"];
		if (oContBet) {
			oContBet.onclick = function() {
				this.form.onsubmit = function() { return true; };
			};
		}  
		oCancel = aForms[i].elements["xCancel"];
		if (oCancel) {
			oCancel.onclick = function() {
				this.form.onsubmit = function() { return true; };
			};
		}  
	}
}
AE_AttachEvent("onload", "SG_ContinueBetting");

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	calls Flash function to write-out banner	
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function SG_WriteBanner(sFile, nW, nH, sLink) {
	//	needed to overcome mixed-content warning on SSL pages
	if (SG_bIsSSL) {
		sProtocol = "https://";
		sSiteAddress = SG_sSSLserver;
	} else {
		sProtocol = "http://";
		sSiteAddress = SG_sHTTPserver;
	}

	//	fix the link
	var sFixedLink = sLink;
	if (sLink != "") {
		if (sLink.substring(0, 6) != "http://") {
			if (sLink.charAt(0) == "/")
				sFixedLink = sLink.substring(1);
			sFixedLink = SG_sHTTPserver + sLink.substring(1);
		}
	}

	var nPos = sFile.lastIndexOf(".");
	var sFileExt = sFile.substring(nPos);

	document.write( '<div class="flashcenterer">' + SWF_WriteFlashContent(sFile, nW, nH, sFileExt, sFixedLink, false, sProtocol, sSiteAddress, "6,0,4,0") + '</div>' );
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	calls Flash function to write-out simple widgets (checkmark, exclaim, x)	
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function SG_WriteWidget(sFile, nW, nH) {
	//	needed to overcome mixed-content warning on SSL pages
	if (SG_bIsSSL) {
		sProtocol = "https://";
		sSiteAddress = SG_sSSLserver;
	} else {
		sProtocol = "http://";
		sSiteAddress = SG_sHTTPserver;
	}

	var sBaseWidgetPath = "/company/interface/images/widgets/";
	sFile = sBaseWidgetPath + sFile;
	
	sFile += ".swf";

	if (typeof(nW) == "undefined")
		nW = 50;
	if (typeof(nH) == "undefined")
		nH = 50;

	document.write( '<div class="flashcenterer">' + SWF_WriteFlashContent(sFile, nW, nH, ".gif", "", false, sProtocol, sSiteAddress, "6,0,0,0") + '</div>' );
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	FAL: get length of associative array
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function FS_AArrayLength(aTmp) {
	var nRet = 0;
	for (var i in aTmp)
		nRet++;
	return nRet;
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	setup TeamTalk and other popup windows
	
	Usage:
	use URL in href attribute, and expand class attribute with the following values:
	sN_STR			_STR = name for popup
	bS_NUM			_NUM = 1 or 0, scrolling on/off
	nW_NUM			_NUM = popup width in pixels
	nH_NUM			_NUM = popup height in pixels
	
	bR2W_NUM		_NUM = 1 or 0, is ratio to width used true/false
	nRW_NUM			_NUM = 0 to 1, number to multiply width
	nRH_NUM			_NUM = 0 to 1, number to mulitply height
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function SG_SetupWnd() {
	var aTmp = xGetElementsByClassName("Wnd", document, "a");
	for (var i=0;i<aTmp.length;i++) {
		aTmp[i].popupcnt = i;
		aTmp[i].onclick = function() {
			var sHref = this.href.replace("&amp;", "&");

			aClasses = this.className.split(" ");
			if (aClasses.length == 1) {
				//	if only Wnd is specified as class (no options) then replicate target="_blank"
				window.open(sHref);
			} else {
				var nW=0, nH=0;
				var nRW=1, nRH=1;
				var bHasScrollbars = 0, bIsR2W = 0;
				var sName = "";
	
				for (var j=0;j<aClasses.length;j++) {
					if ( aClasses[j].substring(0, 2) == "nW" )
						nW = parseInt( aClasses[j].substring(2), 10 );
					else if ( aClasses[j].substring(0, 2) == "nH" )
						nH = parseInt( aClasses[j].substring(2), 10 );
					else if ( aClasses[j].substring(0, 3) == "nRW" )
						nRW = parseFloat( aClasses[j].substring(3) );
					else if ( aClasses[j].substring(0, 3) == "nRH" )
						nRH = parseFloat( aClasses[j].substring(3) );
					else if ( aClasses[j].substring(0, 4) == "bR2W" ) {
						bIsR2W = parseInt( aClasses[j].substring(4) );
						if (isNaN(bIsR2W)) bIsR2W = 0;
					} else if ( aClasses[j].substring(0, 2) == "sN" )
						sName = aClasses[j].substring(2);
					else if ( aClasses[j].substring(0, 2) == "bS" ) {
						bHasScrollbars = parseInt( aClasses[j].substring(2) );
						if (isNaN(bHasScrollbars)) bHasScrollbars = 0;
					}
				}
				
				if (sName = "") sName = "FSpopwnd" + this.popupcnt;
				
				//	it's a popup, so add this identificator (used in betslip, placement)
				if (sHref.indexOf("?") == -1) sHref += "?";
				else sHref += "&";
				sHref += "p=1";

				SG_ShowWnd(sHref, sName, nW, nH, bHasScrollbars, nRW, nRH, bIsR2W);
			}
			return false;
		};
	}
}
AE_AttachEvent("onload", "SG_SetupWnd");

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	open popup windows
	sUrl is the URL to open in popup
	sName is the name of the popup wnd
	xWidth, xHeight are dimensions (optional)
	xRatioW, xRatioH are ratios (< 1, i.e. 0.8) to screen.width and screen.height
	bIsR2W = 1/true => xRatioH is ratio to xRatioW, not to xHeight
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function SG_ShowWnd(sUrl, sName, xWidth, xHeight, bHasScrollbars, xRatioW, xRatioH, bIsR2W) {
	var xMax = 770, yMax=600;

	if (screen) {
		var xMax = screen.width, yMax = screen.height;
	}

	if (!xWidth) {
		if (xRatioW) xWidth = xMax * xRatioW;
		xWidth = Math.round(xWidth);
	}
	//	tweak for scrollbars
	if (bHasScrollbars) xWidth += 22;
	if (xWidth > xMax) xWidth = xMax;

	if (!xHeight) {
		if (xRatioH) xHeight = ((bIsR2W) ? xWidth * xRatioH : yMax * xRatioH);
		xHeight = Math.round(xHeight);
	}

	var xOffset = (xMax - xWidth)/2;  // distance from left
	var yOffset = (yMax - xHeight)/2;  // distance from top
	if (xOffset < 1) xOffset = 0;
	if (yOffset < 1) yOffset = 0;

	winUpdate = window.open(sUrl, sName, "width="+ xWidth.toString() + ",height="+ xHeight.toString() +",screenX=" + xOffset + ",screenY=" + yOffset + ",top=" + yOffset + ",left=" + xOffset + ",status=no,resizable=yes" + (bHasScrollbars ? ",scrollbars=yes" : "") );
	if (winUpdate.opener == null) winUpdate.opener = self;
	winUpdate.focus();
	
	return winUpdate;
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	toggles classes in the group nav
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function SubClassToggle(sID) {
	//	no joy for IE5.0
	if (document.all && (typeof(document.body.contentEditable) == "undefined")) return false;

	var oID = document.getElementById(sID);
	if (!oID) return false;
	
	if (oID.off) {
		oID.style.display = "block";
		oID.off = false;
	} else {
		oID.style.display = "none";
		oID.off = true;
	}
	return false;
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	toggles classes in the group nav
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/


function FV_StripForbiddenCharsInBag(s, bag){
	var i;
	var c;
	var returnString = "";

	//	if bag is empty, no checks, just return input string
	if (bag == "") return s;

	// Search through string's characters one by one; if character is not in bag, append to returnString
	for (i = 0; i < s.length; i++){	 
		// Check that current character isn't blank
		c = s.charAt(i);
		if (bag.indexOf(c) == -1) 
			returnString += c;
	}

	return returnString;
}


var FBF_sAllowedChars = "0123456789abcdefghijklmnoprstquvwxyzABCDEFGHIJKLMNOPRSTQUVWXYZ'. ";
var FBF_sForbiddenChars = "=<>:;%!?()*";

function FBF_Setup() {
	var oF = document.forms["fbfform"];
	if (!oF) return;

	oF.onsubmit = function() {
		var oForm = this;
		var oKw = oForm.elements["sKeywords"];
		if (!oKw) return;
		
		var sKw = oKw.value;
		sKw = FV_StripForbiddenCharsInBag(sKw, FBF_sForbiddenChars);
		oKw.value = sKw;
	
		if (sKw.length < 3) {
			if (SG_MsgFBFInvalidKeywords != "") alert(SG_MsgFBFInvalidKeywords);
			return false;
		} else
			return true;
	};
}

AE_AttachEvent("onload", "FBF_Setup");

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	I18N support function
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
var aFS_I18N = new Array();

function FS_I18N(sPhrase) {
	var sKey = sPhrase.replace('"','\"');
	var sValue = aFS_I18N[sKey];
	if (sValue == null || sValue == '') sValue = sPhrase;
	return sValue;
}


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Login.js - client-side validation for login form
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	(c) Copyright 2003, Finsoft Ltd
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	shorted version of FV_SetupForm() from FAL
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function SetupLoginForm(vForm){
	if (typeof(vForm) == "string")
		oForm = document.forms[vForm];
	else
		oForm = vForm;

	if (!oForm) return;

	//	ditch non-supporting browsers
	if (!oForm.parentNode) return;

	//	set onsubmit validation function
	oForm.onsubmit = function() {
		return LoginVal(this);
	};

	//	flag. if true, alert box will be shown on bad input 
	oForm.alertuser = false;

	//	flag to prevent multiple submits
	oForm.submitted = false; 

	var oElems = oForm.elements; 
	var nLen = oElems.length;
	var sTmp, oTmp, sTmp2;
	for (var i=0; i<nLen; i++) {
		oTmp = oElems[i];
		//	skip elements that don't have names (usually fieldset)
		if (typeof(oTmp.name) == "undefined") continue;

		sTmp2 = oTmp.name;
		sTmp = sTmp2.charAt(0).toLowerCase();
		//	process elements with names starting with b, s and n 
		if (sTmp != "b" && sTmp != "s" && sTmp != "n") continue;

		switch(oTmp.type) {
			case "text": case "password": 
				oLabels = oTmp.parentNode.getElementsByTagName("label");
				for (var j=0;j<oLabels.length;j++) {
					if (oLabels[j].className.indexOf("mandat") != -1 && (oLabels[j].htmlFor == sTmp2 || oLabels[j].firstChild == oTmp)) {
						oTmp.valme = function() {
							var oDiv = this.parentNode;

							if (this.type == "text")
								this.value = FV_Trim(this.value);

							bOk = LoginFieldVal(this);

							if (bOk)
								oDiv.className = oDiv.className.replace("badinput", "");
							else if (oDiv.className.indexOf("badinput") == -1) {
								oDiv.className += " badinput";
							}
							return bOk;
						};
						oTmp.onblur = oTmp.valme;
						break;			
					} 		
				}
				break; 		

		}//switch oTmp.type
	}
}


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	onsubmit function		
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function LoginVal(oForm) {
	var sTmp, oTmp, bOk = true;

	//	prevent multiple clicks on submit
	if (oForm.submitted)
		return false;

	//	inform user about mistakes
	oForm.alertuser = true;

	var oElems = oForm.elements; 
	var nLen = oElems.length;

	for (var i=0; i<nLen; i++) {
		oTmp = oElems[i]; 
		if (typeof(oTmp.valme) == "undefined") continue;
		bOk = oTmp.valme();
		if (!bOk) break; 
	}

	if (bOk) {
		oForm.submitted = true;
	} 

	return bOk;
}


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	validation handler		
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function LoginFieldVal(oField) {
	var bOk = true;

	var sFldName = oField.name;
	var oForm = oField.form;
	var sValue = oField.value;

	switch(sFldName) {
		case "sLusername":
			bOk = (sValue.length >= nMinLenUsername && sValue.length <= nMaxLenUsername);
			if (!bOk) {
				if (oForm.alertuser) {
					FV_ShowMessage(SG_MsgLogEntUserLen);
					oForm.alertuser = false;
					oField.focus();
				}
				break;
			}
			bOk = ( FV_StripCharsNotInBag(sValue, SG_sInUserAllow) == sValue );
			if (!bOk) {
				if (oForm.alertuser) {
					FV_ShowMessage(SG_MsgLogEntUserChars + "\n" + SG_sInUserAllow);
					oForm.alertuser = false;
					oField.focus();
				}
			}
			break;

		case "sLpassword":
			bOk = (sValue.length >= nMinLenPassword && sValue.length <= nMaxLenPassword);
			if (!bOk) {
				if (oForm.alertuser) {
					FV_ShowMessage(SG_MsgLogEntPassLen);
					oForm.alertuser = false;
					oField.focus();
				}
				break;
			}
			bOk = ( FV_StripCharsNotInBag(sValue, SG_sInUserAllow) == sValue );
			if (!bOk) {
				if (oForm.alertuser) {
					FV_ShowMessage(SG_MsgLogEntPassChars + "\n" + SG_sInUserAllow);
					oForm.alertuser = false;
					oField.focus();
				}
			}
			break;
	}

	return bOk;
}

function SetupLoginFormOnLoad() {
	SetupLoginForm("login");
}
AE_AttachEvent("onload", "SetupLoginFormOnLoad");

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	logout confirm
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function LogoutConfirm() {
	return true;
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Based of Clock 2.0, by Andrew Shearer
See: http://www.shearersoftware.com/software/web-tools/clock/
Redistribution is permitted with the above notice intact.

Client-side clock, based on computed time differential between browser &
server. The server time is inserted by server-side JavaScript, and local
time is subtracted from it by client-side JavaScript while the page is
loading.

Cookies: The local and remote times are saved in cookies named
localClock and remoteClock, so that when the page is loaded from local
cache (e.g. by the Back button) the clock will know that the embedded
server time is stale compared to the local time, since it already
matches its cookie. It can then base the calculations on both cookies,
without reloading the page from the server. (IE 4 & 5 for Windows didn't
respect Response.Expires = 0, so if cookies weren't used, the clock
would be wrong after going to another page then clicking Back. Netscape
& Mac IE were OK.)

Every so often (by default, one hour) the clock will reload the page, to
make sure the clock is in sync (as well as to update the rest of the
page content).
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
var FS_oClock = null;
var localTime;
var clockOffset;
var clockExpirationLocal;
var clockTimerID = null;

//	use this is seconds are to be shown
var clockShowsSeconds = true;
var clockIncrementMillis = 1000;
//	use this if seconds are not shown
//var clockShowsSeconds = false;
//var clockIncrementMillis = 60000;

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
onload setup of objects
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function FS_ClockSetup() {
	FS_oClock = document.getElementById("lb_clock");
	if (!FS_oClock || (Browser.isIE && Browser.isMac)) return;
	clockInit(clockLocalStartTime, clockServerStartTime);
}
AE_AttachEvent("onload", "FS_ClockSetup");

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
actual time update
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function FS_ClockUpdate(sTime) {
	FS_oClock.innerHTML = sTime;
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function clockOnUnload() {
    clockClearTimeout();
}
window.onunload = clockOnUnload;

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function clockClearTimeout() {
    if (clockTimerID) {
        clearTimeout(clockTimerID);
        clockTimerID = null;
    }
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
on onload, initialize the clock properties
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function clockInit(localDateObject, serverDateObject)
{
    var origRemoteClock = parseInt(clockGetCookieData("remoteClock"));
    var origLocalClock = parseInt(clockGetCookieData("localClock"));
    var newRemoteClock = serverDateObject.getTime();
    // May be stale (WinIE); will check against cookie later
    // Can't use the millisec. ctor here because of client inconsistencies.
    var newLocalClock = localDateObject.getTime();
    var maxClockAge = 60 * 60 * 1000;   // get new time from server every 1hr

    if (newRemoteClock != origRemoteClock) {
        // new clocks are up-to-date (newer than any cookies)
        document.cookie = "remoteClock=" + newRemoteClock;
        document.cookie = "localClock=" + newLocalClock;
        clockOffset = newRemoteClock - newLocalClock;
        clockExpirationLocal = newLocalClock + maxClockAge;
        localTime = newLocalClock;  // to keep clockUpdate() happy
    }
    else if (origLocalClock != origLocalClock) {
        // error; localClock cookie is invalid (parsed as NaN)
        clockOffset = null;
        clockExpirationLocal = null;
    }
    else {
        // fall back to clocks in cookies
        clockOffset = origRemoteClock - origLocalClock;
        clockExpirationLocal = origLocalClock + maxClockAge;
        localTime = origLocalClock;
        // so clockUpdate() will reload if newLocalClock
        // is earlier (clock was reset)
    }
    /* Reload page at server midnight to display the new date, by expiring the clock then */
    var nextDayLocal = (new Date(serverDateObject.getFullYear(), serverDateObject.getMonth(), serverDateObject.getDate() + 1)).getTime() - clockOffset;
    if (nextDayLocal < clockExpirationLocal) {
        clockExpirationLocal = nextDayLocal;
    }
	
	clockUpdate();
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
find the value of the specified cookie in the document's
    semicolon-delimited collection. For IE Win98 compatibility, search
    from the end of the string (to find most specific host/path) and
    don't require "=" between cookie name & empty cookie values. Returns
    null if cookie not found. One remaining problem: Under IE 5 [Win98],
    setting a cookie with no equals sign creates a cookie with no name,
    just data, which is indistinguishable from a cookie with that name
    but no data but can't be overwritten by any cookie with an equals sign.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function clockGetCookieData(label) {
    var c = document.cookie;
    if (c) {
        var labelLen = label.length, cEnd = c.length;
        while (cEnd > 0) {
            var cStart = c.lastIndexOf(';',cEnd-1) + 1;
            // bug fix to Danny Goodman's code: calculate cEnd, to prevent walking the string char-by-char & finding cookie labels that contained the desired label as suffixes
            // skip leading spaces
            while (cStart < cEnd && c.charAt(cStart)==" ") cStart++;
            if (cStart + labelLen <= cEnd && c.substr(cStart,labelLen) == label) {
                if (cStart + labelLen == cEnd) {
                    return ""; // empty cookie value, no "="
                }
                else if (c.charAt(cStart+labelLen) == "=") {
                    // has "=" after label
                    return unescape(c.substring(cStart + labelLen + 1,cEnd));
                }
            }
            cEnd = cStart - 1;  // skip semicolon
        }
    }
    return null;
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function clockDisplayTime(inHours, inMinutes, inSeconds) {
    FS_ClockUpdate(clockTimeString(inHours, inMinutes, inSeconds));
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Called regularly to update the clock display as well as onLoad (user
	may have clicked the Back button to arrive here, so the clock would need
	an immediate update)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function clockUpdate()
{
    var lastLocalTime = localTime;
    localTime = (new Date()).getTime();

    /* Sanity-check the diff. in local time between successive calls;
       reload if user has reset system clock */
    if (clockOffset == null) {
        clockDisplayTime(null, null, null);
    }
    else if (localTime < lastLocalTime || clockExpirationLocal < localTime) {
        /* Clock expired, or time appeared to go backward (user reset the clock).
		Reset cookies to prevent infinite reload loop if server doesn't give a new time. */
        document.cookie = 'remoteClock=-';
        document.cookie = 'localClock=-';
        location.reload();      // will refresh time values in cookies
    }
    else {
        // Compute what time would be on server
        var serverTime = new Date(localTime + clockOffset);
        clockDisplayTime(serverTime.getHours(), serverTime.getMinutes(), serverTime.getSeconds());

        // Reschedule this func to run on next even clockIncrementMillis boundary
		var nIncr = clockIncrementMillis - (serverTime.getTime() % clockIncrementMillis);
        clockTimerID = setTimeout("clockUpdate()", nIncr);
    }
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function clockTimeString(inHours, inMinutes, inSeconds) {
    return (
			(inHours < 10 ? "0" : "") + inHours
	        + ((inMinutes < 10) ? ":0" : ":") + inMinutes
    	    + (clockShowsSeconds ? ((inSeconds < 10 ? ":0" : ":") + inSeconds) : "")
		);
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	client.js - client specific things
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	(c) Copyright 2003, Finsoft Ltd
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	calls Flash function to write-out in-running header	
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function InR_WriteHeader() {
	//	needed to overcome mixed-content warning on SSL pages
	if (SG_bIsSSL) {
		sProtocol = "https://";
		sSiteAddress = SG_sSSLserver;
	} else {
		sProtocol = "http://";
		sSiteAddress = SG_sHTTPserver;
	}

	var oReplace = null;
	oReplace = document.getElementById("inrunH2");
	if (oReplace) {
		oReplace.innerHTML = '<div class="flashcenterer">' + SWF_WriteFlashContent("/company/interface/css/images/headers/header_inrunning.swf", 379, 68, ".gif", "", false, sProtocol, sSiteAddress, "6,0,0,0") + '</div>';
	}
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	freephone betline functionality
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
var FPB_aDiv = new Array();
var FPB_aLI = new Array();
var FPB_x = null;
if (document.getElementsByTagName) {
	var FPB_x = document.getElementsByTagName("head")[0];
	if (FPB_x) FPB_x = FPB_x.parentNode;
	if (FPB_x) document.write('\n<style type="text/css" media="screen, tv, projection"> .freephone div{display:none;} </style>\n');
}

function FPB_Setup() {
	if (!FPB_x) return;
	
	var nCnt = 0;
	xGetElementsByClassName("freephone", null, "div", function(oDiv) {
		var aA = oDiv.getElementsByTagName("a");
		var aDiv = oDiv.getElementsByTagName("div");
		for (var i=0;i<aDiv.length;i++) {
			aA[i].oDiv = aDiv[i];
			aA[i].nCnt = nCnt;
			aA[i].onclick = function() {
				var nCnt = this.nCnt;
				if (FPB_aLI[nCnt])
					FPB_aLI[nCnt].className = FPB_aLI[nCnt].className.replace(/fpbcur/, "");
				if (FPB_aDiv[nCnt])
					FPB_aDiv[nCnt].style.display = "none";
				this.parentNode.className += " fpbcur";
				this.oDiv.style.display = "block";
				FPB_aLI[nCnt] = this.parentNode;
				FPB_aDiv[nCnt] = this.oDiv;
				return false;
			};
		}

		FPB_aLI[nCnt] = aA[0].parentNode;
		FPB_aLI[nCnt].className += " fpbcur";

		FPB_aDiv[nCnt] = aDiv[0];
		FPB_aDiv[nCnt].style.display = "block";
		
		nCnt++;
	});
}

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	IE setup for the ADxMenu
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function ADXM_IESetup() {
	var aTmp2, i, j, oLI, oUL;

	var aTmp = xGetElementsByClassName("adxm", document, "ul");
	for (i=0;i<aTmp.length;i++) {
		oUL = aTmp[i];
		
		aTmp2 = xGetElementsByClassName("submenu", oUL, "li");

		for (j=0;j<aTmp2.length;j++) {
			oLI = aTmp2[j];
			oLI.isV = (oUL.className.indexOf('adxmV') != -1);

			oLI.onmouseenter = function() {
				if (!this.UL)
					this.UL = this.getElementsByTagName("ul")[0];

				if (!this.A)
					this.A = this.getElementsByTagName("a")[0];
					
				if (this.A)
					this.A.className += " ieover";


				if (this.UL) {
					if (this.isV)
						this.UL.style.left = "100%";

					WCH.Apply(this.UL, this, true);	//	to overlap select boxes
					this.UL.style.visibility = "visible";
				}
			};

			oLI.onmouseleave = function() {
				if (this.A)
					this.A.className = this.A.className.replace(/ieover/, "");
				if (this.UL) {
					this.UL.style.visibility = "hidden";
					if (this.isV)
						this.UL.style.left = "0px";
					WCH.Discard(this.UL, this);
				}
			};
		}

	}
}

if (document.all && !window.opera && window.attachEvent)
	window.attachEvent("onload", ADXM_IESetup);

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	workaround for damn IE and it's a:hover span problem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
function FormHelp_Setup() {
	if (!document.all || window.opera) return;

	var aTmp, aFld = document.getElementsByTagName("fieldset");
	for (var i=0;i<aFld.length;i++) {
		xGetElementsByClassName("formhelp", aFld[i], "a", function(oA) {
			oA.onmouseenter = function() {
				if (!(x = this.getElementsByTagName('span')[0])) return;
				x.style.visibility = 'visible';
			};
			oA.onmouseleave = function() {
				if (!(x = this.getElementsByTagName('span')[0])) return;
				x.style.visibility = 'hidden';
			};
		});
	}
}

//	this will execute various client stuff on page load
function ClientSetup() {
	FPB_Setup();
	FormHelp_Setup();
}

if (window.addEventListener) {
	window.addEventListener("load", ClientSetup, false);
} else if (window.attachEvent) {
	window.attachEvent("onload", ClientSetup);
} else {
	AE_AttachEvent("onload", "ClientSetup");
}

