// Generic onload function where all other onload functions should be added to
function onLoadFunctions() {
	if (document.forms['COUPON']) {
		updateCoupon(document.forms['COUPON']);
	}
	placeMoreSports();
	if (document.getElementById("priceTypeSelect")) {
		selectPriceType();
	}
	uniqueSession();

        // Added by Dan for winter season - delete in New Year!
        i = document.getElementById('headerLogo');
        if(     (location.host.indexOf('.vcbet.com')>-1) &&
                (langID!='21') &&
                (i) ) {
                if(i.src.indexOf('vcbet_logo.gif')>-1) {
                        i.src='/images/vcbet_logo.seasonal.gif';
                } else if(i.src.indexOf('vcgames_logo.gif')>-1) {
                        i.src='/images/vcgames_logo.seasonal.gif';
                } else if(i.src.indexOf('vcmobile_logo.gif')>-1) {
                        i.src='/images/vcmobile_logo.seasonal.gif';
                }
        }
        // End Dan seasonal addition
}

function onLoadForecasts() {
	if (document.forms['COUPON']) {
		updateForecast(document.forms['COUPON']);
	}
	placeMoreSports();
	if (document.getElementById("priceTypeSelect")) {
		selectPriceType();
	}
}

function placeMoreSports() {
	if (document.getElementById("moreSports")) {
		var ss = document.getElementById('sportsSelector');
		var ht = document.getElementById('headerTable');
		var ms = document.getElementById('moreSports');
		var sn = document.getElementById('sidenav');
		
		if ((ss) && (ht) && (ms) && (sn)) {
			var x = ss.offsetLeft + ss.offsetWidth;
			var y = ht.offsetHeight + ss.offsetTop + ss.offsetHeight;
			var browserName=navigator.appName;
	
			if (sn.offsetParent) {
				while (sn.offsetParent) {
					x += sn.offsetLeft
					sn = sn.offsetParent;
				}
			} else {
				var x = ss.offsetLeft + ss.offsetWidth;
			}
			if (document.body.offsetHeight < 500) {
				y -= ms.offsetHeight;
			} else {
				y -= 28;
			}
	
			if(langID=="21"){
				ms.style.pixelRight = x-633;
			} else {
				ms.style.pixelLeft = x;
			}
			ms.style.pixelTop = y;
			if (browserName=="Netscape"){
				ms.style.left = x;
				ms.style.top = y;
			}
		}
	}
}

function getmpos() {
	var ss = document.getElementById('sportsSelector');
		var ht = document.getElementById('headerTable');
		var ms = document.getElementById('moreSports');
		var t=document.getElementById("moreSports").style.pixelTop-document.body.scrollTop
	if (t <=0) {
		var y =ht.offsetHeight + ss.offsetTop + ss.offsetHeight;
		ms.style.pixelTop = y -28;
	}
}

// Extend more sports menu (left navigation)
function extendSports(state) {
	if (state=="show") {
		document.getElementById("moreSports").style.visibility="visible";
	} else {
		document.getElementById("moreSports").style.visibility="hidden";
	}
}

function extendTimer(state) {
	extendID=setTimeout("extendSports('"+state+"')",250);
}
function clearExtendTimer() {
	if (extendID) {
		clearTimeout(extendID);
	}
}

// Switches between divs on the page - used for maincontent/betslip divs
function switchDiv(toHide, toShow) {
	document.getElementById(toHide).style.display='none';
	document.getElementById(toShow).style.display='block';
}

// Function for left nav
function leftNav(sportId, time) {
	var date = new Date(parseInt(time));
	hrefVal = "";
	if (sportId == "100") {
		hrefVal = "football_index.jsp";
	} else if ((sportId == "200")) {
		hrefVal = "horseracing_index.jsp?ot=2000&sport="+sportId;
	} else if ((sportId == "967800")){ //football24/7
		 hrefVal = "chandler_park_intro.jsp";
	} else if ((sportId == "967900")){ //virtual racing
		 hrefVal = "chandler_park_intro.jsp";
	} else if ((sportId == "967600")){ //hilo
		 hrefVal = "games.jsp";
	} else if ((sportId == "966500")) {
		hrefVal = "horseracing_us_index.jsp?ot=20000&sport="+sportId+"&when=all";
	}else if (sportId == "400") {
		hrefVal = "golf_index.jsp";
	} else if (sportId == "433200") {
    	hrefVal = "dogs_index.jsp?sport="+sportId;
	} else if (sportId == "967900") {
		hrefVal = "chandler_park.jsp";
	} else if (sportId == "968300") {
		hrefVal = "trotting_index.jsp?sport="+sportId;
	} else if (sportId == "968900") {
		hrefVal = "horseracing_hk_index.jsp?sport="+sportId;
	} else if (sportId == "969900") {
		hrefVal = "vr_horseracing_index.jsp?ot=192800&sport="+sportId;
	} else if (sportId == "970000") {
		hrefVal = "vr_dogs_index.jsp?&sport="+sportId;
	} else if (sportId == "364600" || sportId == "964500") {
		hrefVal = "rugby_index.jsp?sportID="+sportId;
	} else {
		hrefVal = "coupon_index.jsp?sport="+sportId;
	}
	document.location.href="/"+hrefVal;
}

// Get coupon type to centralise this code
function getGenericCouponStyle(oppTypeId) {
	var ot = parseInt(oppTypeId);
	switch (ot) {
			case 15000:
			case 169400:
			case 12000:
			case 100800:
			case 101000:
			case 101300:
			case 101200:
			case 101100:
			case 182000:
			case 14000:
			case 23300:
			case 182100:
			case 11000:
			case 11200:
			case 11100:
			case 169700:
			case 170000:
			case 6000:
			case 25800:
			case 25900:
			case 6100:
			case 6200:
			case 26000:
			case 26100:
			case 26200:
			case 26300:
			case 26400:
			case 26500:
			case 26600:
			case 26700:
			case 27100:
			case 170400:
			case 25300:
			case 170500:
			case 170600:
			case 170700:
			case 170800:
			case 18000:
			case 171500:
			case 171200:
			case 171300:
			case 171400:
			case 300:
			case 3000:
			case 172200:
			case 172300:
			case 172400:
			case 172500:
			case 172800:
			case 172600:
			case 16000:
			case 182500:
			case 19800:
			case 181400:
			case 182600:
			case 7000:
			case 182700:
			case 8000:
			case 8200:
			case 8400:
			case 8500:
			case 176200:
			case 182800:
			case 25400:
			case 25500:
			case 182900:
			case 100:
			case 183000:
			case 200:
			case 183100:
			case 20400:
			case 183200:
			case 9000:
			case 9200:
			case 9300:
			case 9400:
			case 9500:
			case 9600:
			case 177700:
			case 17000:
			case 17200:
			case 17300:
			case 17400:
			case 17500:
			case 17600:
			case 178500:
			case 10000:
			case 10100:
			case 178700:
			case 19700:
			case 183300:
			case 20300:
			case 183300:
			case 20300:
			case 183400:
			case 20900:
			case 179100:
			case 179300:
			case 179600:
			case 179500:
			case 179400:
			case 183500:
			case 20100:
			case 24300:
			case 183600:
			case 5000:
			case 5100:
			case 180700:
			case 180300:
			case 20000:
			case 181000:
			case 181100:
			case 27500:
			case 183700:
			case 4000:
			case 172900:
			case 173000:
			case 173300:
			case 173400:
			case 173700:
			case 174100:
			case 174200:
			case 174300:
			case 174400:
			case 174500:
			case 174600:
			case 174900:
			case 175100:
			case 175200:
			case 175300:
			case 177800:
			case 177900:
			case 178000:
			case 178100:
			case 178200:
			case 178300:
			case 182400:
			case 177000:
			case 177100:
			case 177200:
			case 177300:
			case 177400:
				return 1;
				break;
			case 169500:
			case 100900:
			case 169900:
			case 25700:
			case 26900:
			case 201900:
				return 4;
				break;
			case 27000:
			case 170900:
			case 171000:
			case 171100:
			case 172700:
			case 175900:
			case 181800:
			case 176300:
			case 176500:
			case 176700:
			case 176900:
			case 25600:
			case 181900:
			case 23400:
			case 179200:
			case 180400:
			case 20500:
			case 180800:
			case 180900:
			case 181700:
			case 30100:
				return 2;
				break;
			case 23000:
			case 23200:
			case 101400:
			case 23500:
			case 24800:
			case 24900:
			case 25200:
			case 175700:
			case 175800:
			case 8100:
			case 8300:
			case 8600:
			case 8800:
			case 176100:
			case 21000:
			case 22800:
			case 179700:
			case 23900:
			case 179800:
			case 179900:
			case 180200:
			case 203800:
			case 203900:
			case 204000:
			case 204100:
			case 203000:
			case 203100:
			case 203200:
			case 203300:
				return 3;
				break;
			case 174000:
			case 174700:
			case 174800:
			case 173900:
			case 173800:
				return 4;
				break;
			case 9100:
			case 177600:
			case 17100:
			case 178400:
			case 201700:
			case 201800:
				return 5;
				break;
			case 170100:
				return 10;
				break;
			case 23500:
			case 169600:
			case 176800:
			case 178800:
			case 203400:
			case 203500:
			case 203600:
			case 203700:
				return 7;
				break;
			case 23100:
			case 14100:
			case 23700:
			case 23600:
			case 23800:
			case 25000:
			case 25100:
			case 169800:
			case 26800:
			case 176000:
			case 8700:
			case 8900:
			case 176400:
			case 177500:
			case 22900:
			case 20200:
			case 24100:
			case 24000:
			case 24200:
			case 180000:
			case 180100:
			case 102600:
				return 8;
				break;
			case 101500:
				return 12;
				break;
			case 101600:
				return 13;
				break;
			case 101700:
				return 11;
				break;
			case 102700:
				return 14;
				break;
			case 101900:
			case 102000:
				return 19;
				break;
			case 102100:
				return 18;
				break;
			case 101800:
			case 102200:
			case 102300:
				return 15;
				break;
			case 102400:
				return 21;
				break;
			//new opptypes for inrunning:
			case 201100:
			case 201200:
			case 197100:
			case 197800:
			case 198000:
			case 198800:
			case 194400:
			case 201000:
			case 200000:
			case 199400:
			case 200800:
			case 198500:
			case 197300:
			case 196600:
			case 195000:
			case 200300:
			case 198400:
			case 199300:
			case 194900:
			case 201300:
			case 200200:
			case 199900:
			case 200900:
			case 198700:
			case 197900:
			case 197200:
			case 195500:
			case 200700:
			case 197700:
			case 197000:
			case 199700:
			case 196800:
			case 196900:
			case 197500:
			case 197600:
			    return 1;
			    break;
			case 195200:
			case 199000:
			case 195100:
			case 198100:
			case 198900:
			case 199500:
			case 199600:
			case 198200:
			case 200100:
			case 195300:
			case 200400:
			case 195400:
			case 199800:
			case 198600:
			case 198300:
			    return 2;
			    break;
			case 194600:
			case 194700:
			case 194800:
			case 200500:
			case 200600:
			case 194500:
			    return 4;
			    break;
			case 197400:
			case 196700:
			    return 5;
			    break;
			case 199200:
			case 199100:
			    return 8;
			default:
				return 0;
				break;
		}
}

// Do the right nav stuff like next5 and top5
function rightNav(sportId, meetingId, eventId, oppId) {
	hrefVal = "";
	var sid = parseInt(sportId);
	var oid = parseInt(oppId);
	if (oid == 1001){
		hrefVal = "coupon_outright.jsp?eid="+eventId + "&ot=-1";
		}
	else{
		if (eventId == null) {
			switch (sid) {
				case 100: // football					
					hrefVal = "football_byo.jsp?&matches="+meetingId+"&outrights="+meetingId;
					break;
				case 200: // horses					
					hrefVal = "horseracing_simple.jsp?ot=2000&sport="+ sportId +"&mid="+meetingId;
					break;
				case 966500: // horses					
					hrefVal = "horseracing_simple.jsp?ot=20000&sport="+ sportId +"&mid="+meetingId;
					break;
				case 433200: // dogs					
					hrefVal = "dogs_simple.jsp?mid="+meetingId;
					break;
				case 967800: //football 24/7					
					hrefVal = "chandler_park_intro.jsp";
					break;
				case 967900: //virtual racing					
					hrefVal = "chandler_park_intro.jsp";
					break;
				case 967600: //games					
					hrefVal = "games.jsp";
					break;
				case 968900: 					
					hrefVal = "horseracing_hk_quick.jsp?mid="+meetingId;
					break;
				default:
					hrefVal = "coupon_outright.jsp?mid="+meetingId + "&ot=-1";
					break;
			}
		} else {
			switch (sid) {
				case 100: // football					
					hrefVal = "football_90.jsp?eid="+eventId;
					break;
				case 200: // horses					
					hrefVal = "horseracing_simple.jsp?ot=2000&sport="+ sportId +"&eid="+eventId;
					break;
				case 966500: // horses					
					hrefVal = "horseracing_simple.jsp?ot=20000&sport="+ sportId +"&eid="+eventId;
					break;
				case 433200: // dogs					
					hrefVal = "dogs_simple.jsp?eid="+eventId;
					break;
				case 968900: // horses					
					hrefVal = "horseracing_hk_quick.jsp?eid="+eventId;
					break;
				default:
					hrefVal = "coupon_outright.jsp?eid="+eventId + "&ot=-1";
					break;
			}
		}
	}
	document.location.href="/"+hrefVal;
}

// Do the right nav stuff like next5 and top5 (Antepost)
function rightNavAP(sportId, meetingId, eventId) {
	hrefVal = "";
	var sid = parseInt(sportId);
	if (eventId == null) {
		switch (sid) {
			case 200: // horses
				hrefVal = "horseracing_simple_antepost.jsp?ot=2000&sport="+ sportId +"&mid="+meetingId;
				break;
			case 966500: // horses
				hrefVal = "horseracing_simple.jsp?ot=20000&sport="+ sportId +"&mid="+meetingId;
				break;
			case 433200: // dogs
				hrefVal = "dogs_simple_antepost.jsp?mid="+meetingId;
				break;
			case 968900: // horses HK
				hrefVal = "horseracing_hk_quick.jsp?mid="+meetingId;
				break;
			default:
				hrefVal = "coupon_outright.jsp?mid="+meetingId + "&ot=-1";
				break;
		}
	} else {
		switch (sid) {
			case 200:
				// horses
				hrefVal = "horseracing_simple_antepost.jsp?ot=2000&sport="+ sportId +"&eid="+eventId;
				break;
			case 966500:
				// horses
				hrefVal = "horseracing_simple.jsp?ot=20000&sport="+ sportId +"&eid="+eventId;
				break;
			case 433200:
				// dogs
				hrefVal = "dogs_simple_antepost.jsp?eid="+eventId;
				break;
			case 968900:
				// horses HK
				hrefVal = "horseracing_hk_quick.jsp?eid="+eventId;
				break;
			default:
				hrefVal = "coupon_outright.jsp?eid="+eventId + "&ot=-1";
				break;
		}
	}
	document.location.href="/"+hrefVal;
}

function betfinder(selected) {
	sport = selected[selected.selectedIndex].value;
	meeting = selected[selected.selectedIndex].id;
	if (meeting == 506800) {
		location.href="/coupon_outright.jsp?ot=1001&mid=506800";
	} else {
		if (meeting == "-1") {
			leftNav(sport);
		} else {
			rightNav(sport, meeting, null);
		}
	}
}

/* ============================================================================
		Registration Help popup function.
		Pass Registration stage only as parameter (ie all other attirbutes are fixed)
		Don't use for anything but Registration help.
   ============================================================================ */
function regHelpPopup(regStage) {
	var regHelp = window.open("/help_pop.jsp","victor","width=297,height=345");
}

/* ============================================================================
		Alert Dialog Box - replaces normal alert()
		call by showDialog (message to display, form field width error, name of form)
   ============================================================================ */
nn6=(navigator.appName=="Netscape" && document.getElementById)?true:false;
dWindow=null;
o_alert = false;

function showDialog(message,errorField,rForm,invalid) {
	if (rForm != null && rForm.elements == null) {
	  	rForm=document.forms[rForm];
	}
	dialogText="";
	// Heading text for alert dialog
	if (errorField || rForm) {
		// don't pass in text anymore. it all comes from the properties now.
		// if there is a form or errorfield, send a formerror parameter into the jsp.
		jsp_param = "?formerror=1";
	} else {
		jsp_param = "";
	}
	dialogWidth=300; dialogHeight=150;

		// Text for invalid character dialog
	if (invalid) {
		// don't pass in text anymore. it all comes from the properties now.
		// if there is a form or errorfield, send a formerror parameter into the jsp.
		jsp_param = "?invalid=2";
	}

	if (document.all) {
		dialogFeatures="dialogWidth:"+dialogWidth+"px;dialogHeight:"+dialogHeight+"px;resizable:no;status:no;help:no;center:yes;"
		try {
			dialogWindow=window.showModalDialog("/alert_dialog.jsp"+jsp_param,message,dialogFeatures);
		} catch (e) {
			alert (message);
		}
	} else if (nn6) {
		alert(message);
	}
	// Return focus to error field (if it exists) after the dialog has closed
	if (errorField && rForm) {
        if (errorField.name!=null) {
			if (errorField.type != 'radio' && errorField.type != 'hidden' && rForm[errorField.name].disabled==false) {
				rForm[errorField.name].focus();
			}
        } else {
			if (errorField.type != 'radio' && errorField.type != 'hidden' && rForm[errorField].disabled==false) {
    			rForm[errorField].focus();
			}
        }
	}
}

// Netscape 6,7 bits
function checkExist() {
	if (dialogWindow) dWindow.focus();
}

function doWrite() {
	to_write = dialogWindow.document.forms["mess"].nnHeader.value;
	to_write+= dialogWindow.document.forms["mess"].nnBody1.value;
	to_write+= dialogWindow.document.forms["mess"].nnBody2.value;
	dialogWindow.document.forms["mess"].nnError.value=message;
}

// Refresh Page Function
function refreshPage() {
    var url = document.location.href;
    if(url.indexOf("refresh") == -1) {
      if(url.indexOf("?") == -1) {
        url += "?refresh=true";
      } else {
        url += "&refresh=true";
      }
    }
    document.location.href = url;
}

// Login focus
function loginFocus() {
	window.scrollTo(0,0);
	if (document.forms.login != null && document.forms.login.username != null){
    	document.forms.login.username.focus();
	}
}

// Returns The Value of An Element
function getElText(elementName) {
	return document.getElementById(elementName).innerHTML;
}

// Quick Deposit Validation
function validateQuickPayment(minAmount, maxAmount) {
	isNumeric = true;
	theForm = document.forms['bank_details'];

	if (isNaN(theForm.amount.value)){
		isNumeric = false;
	}
	for(x=0; x < theForm.elements.length; x++) {
		if ((theForm.elements[x].checked)&&(theForm.elements[x].value=='yes')) {
			performPayment = true;
		} else if ((theForm.elements[x].checked)&&(theForm.elements[x].value=='no')) {
			performPayment = false;
		}
	}
	if (performPayment) {
		if (!isNumeric) {
			showDialog(getElText('isNumeric'));
			theForm.amount.value = minAmount;
		} else
			if (theForm.amount.value < minAmount){
				showDialog(getElText('minDeposit'));
				theForm.amount.value = minAmount;
			} else
				if (theForm.amount.value > maxAmount){
					showDialog(getElText('maxDeposit'));
					theForm.amount.value = maxAmount;
				} else {
					if(document.getElementById('pressedbut')){
						document.getElementById('pressedbut').disabled = true;
					}
					setCookie("_BSGOCONF","true");
					theForm.submit();
				}
	} else if (!performPayment) {
		history.back();
	}
}

// Sets default racecard view using a cookie
function setRacecardView(setView) {
	var days = 360;
	var today = new Date();
	var defaultExp = new Date();
	defaultExp.setTime(today.getTime() + 1000*60*60*24*days);
	setCookie("_myview", setView, defaultExp, null, null, null);
}

// Gets cookie and goes to specific view (advanced / simple)
function defaultView(coupon, ids) {
	x = getCookie("_myview");

	if ((x!=null)&&(x!='')&&(x=='advanced')) {
		hrefStr = "/" + coupon + "_advanced.jsp?" + ids;
	} else if ((x!=null)&&(x!='')&&(x=='quick')) {
		hrefStr = "/" + coupon + "_quick.jsp?" + ids;
	} else {
		hrefStr = "/" + coupon + "_simple.jsp?" + ids;
	}
	document.location=hrefStr;
}

// Generic launch for help popups
function genericPopUpHelp(page, val) {
	var popHelp = window.open("/help_" + page + "_pop.jsp?sel=" + val, "HELPPOPUP", "width=317,height=345,toolbar=0,scrollbars=1");
	popHelp.focus();
}

//Set up Game Windows
var GAMEWINDOW = '';
for (w=1; w < 11; w++) {
	eval("var GAMEWINDOW"+w+" = ''");
}

// Generic pop-up window function
function openBrWindow(theurl, winname, features){
	if (theurl.indexOf("rt_radio") > -1) {
		GAMEWINDOW = window.open('http://vchandler.teamtalk.com/Victor_Chandler/Audio_Centre/Index','VC','Height=465,Width=450,statusbar=no,left=25,top=25');
	} else if (theurl.indexOf("tt_radio") > -1) {
		GAMEWINDOW = window.open('http://vchandler.teamtalk.com/Victor_Chandler/Audio_Centre/Index','VC','Height=465,Width=450,statusbar=no,left=25,top=25');
	} else if (theurl.indexOf("radio") > -1) {
		GAMEWINDOW = window.open('http://vchandler.teamtalk.com/Victor_Chandler/Audio_Centre/Index','VC','Height=465,Width=450,statusbar=no,left=25,top=25');
	}  else if (winname.indexOf("GAMEWINDOW") > -1){
		eval(winname + " = window.open(theurl, winname, features)");
	} else {
		window.open(theurl, winname, features);
	}
}

function getRadioSite() {
	var host = document.location.hostname;
	if (host.indexOf("victor.com") > -1) {
		return 141;
	} else if (host.indexOf("victorchandler.com") > -1) {
		return 140;
	} else if (host.indexOf("victorchandler.co.uk") > -1) {
		return 135;
	} else if (host.indexOf("victorchandler.co.il") > -1) {
		return 289;
	} else if (host.indexOf("bet.fhmbet.com") > -1) {
		return 194;
	} else if (host.indexOf("vikingbet.com") > -1) {
		return 290;
	} else if (host.indexOf("victor888.com") > -1) {
		return 296;
	} else if (host.indexOf("victorchandler.ie") > -1) {
		return 298;
	} else {
		return 28;
	}
}

//function for redirecting page when choosing a language.
function langFunc(pageLinker){
	if (pageLinker.indexOf("#")!= -1) {
		document.location.href = pageLinker.substring(0,pageLinker.indexOf("#"));
	} else if (pageLinker.indexOf("lang=")!= -1) {
		//Replaces the lang= so that it keeps all other parameters, eg. OID.
		location.href = location.href.replace("lang=","");
	} else {
		document.location.href = pageLinker;
	}
}

// function for where games pages link to when have error an client send email (email page link)
function gameproblem(){
	opener.location.href='/contact_us.jsp?gameproblem';
}

//hit a tracking pixel
function hitTrackingPixel(page) {
 var imageUrl = "https://ee.connextra.com/VictorChandler/pc.gif?page="+page;
 var imageObject = new Image();
 imageObject.src = imageUrl;
}

function writeActionTags(page, accbalance, country, age, accnumber) {
	var tagcalc = 0;
	var el = document.getElementById("actiontags");
	if (el) { // if element exists (id: 100, 200, 7000)
		tagcalc = (10000000-(accbalance*100)); // Atlas tags encoding*
		switch (page) {
			case 1: // shell_homepage		 		
				el.innerHTML = '<img height="1" width="1" src="http://switch.atdmt.com/action/mvi_VICH_Home_Page_Bet"/>';
				break;
			case 2: //vc_games				
				el.innerHTML = '<img height="1" width="1" src="http://switch.atdmt.com/action/mvi_VICH_Home_Page_Games"/>';
				break;
			case 3: //mobile_home				
				el.innerHTML = '<img height="1" width="1" src="http://switch.atdmt.com/action/mvi_VICH_Home_Page_Mobile"/>';
				break;
			case 4: //reg_your_details.jsp				
				el.innerHTML = '<img height="1" width="1" src="https://switch.atdmt.com/action/mvi_VICH_Open_Account_Page_1"/>';
				break;
			case 5: //reg_(asian)contact_details.jsp
				el.innerHTML = '<img height="1" width="1" src="https://switch.atdmt.com/action/mvi_VICH_Open_Account_Page_2"/>';
				break;
			case 9: //reg_success.jsp
				el.innerHTML = '<img height="1" width="1" src="https://switch.atdmt.com/action/mvi_VICH_Open_Account_Page_2/v3/ato.'+accnumber+'"/>';
				if (parseFloat(accbalance) > 0) {
					el.innerHTML += '<img height="1" width="1" src="https://switch.atdmt.com/action/mvi_VICH_Deposit_with_funds/v3/ato.'+accnumber+'/atc1.'+country+'/atc2.'+age+'/atm1.'+ tagcalc +'"/>';
				}
				break;
			case 10: //am_payment_success.jsp
				el.innerHTML = '<img height="1" width="1" src="https://switch.atdmt.com/action/mvi_VICH_Deposit_Confirmation/v3/ato.'+accnumber+'/atm1.'+ tagcalc +'"/>';
				break;
			case 12:
				//betslip_success.jsp
				el.innerHTML = '<img height="1" width="1" src="http://switch.atdmt.com/action/mvi_VICH_Bet_Confirmation/v3/ato.'+accnumber+'/atm1.'+ tagcalc +'" />';
				break;
			default:
				break;
		}
	}
}

function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	
	if(TRIM_VALUE==""){
		return "";
	}
	else{
		return TRIM_VALUE;
	}
} 

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	
	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		
		}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

	} 

	return strTemp;	
}

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
	if(VALUE.charAt(iTemp) == w_space){
	}
	else{
		strTemp = VALUE.substring(iTemp,v_length);
		break;
	}
		iTemp = iTemp + 1;
	} 
	return strTemp;
}

//reloads page with an added attribute in the url so that use can use the Back button to return to previous page (coupon)
function goBetSlip() {
	b = getCookie('betslip');
	if (b != null) {
		if (window.bsViewBetSlip){
			location.href=bsViewBetSlip;
		} else {
			location.href="/betslip.jsp";
		}
	} else {
		showDialog (getElText('bsmsg1'));
	}
}
