try
{
	var cur_symbol="&#163;";
	if(cur == "978")
	cur_symbol="&#8364;";
	if(cur == "752")
	cur_symbol="kr";
	ChangeState("the_usernameright",username);
	ChangeState("uname",username);
	ChangeState("realbal",formatted_bal);
	ChangeState("bonbal",formatted_bonus);
	ChangeState("loyalty",loyalty);
	ChangeState("tollypoints",points);
	ChangeState("cno",cno);
}catch(ignore){}
function checkdeposit()
{
	if(levelId == 1)
	{
		location.href=built_url+"/bingo/registration/registration_step2.thtml";
	}
	else
	{
		location.href=built_url+"/deposit/depositView.do";
	}
}
function checkwithdraw()
{
	
	if(levelId == 1)
	{
		location.href=built_url+"/bingo/registration/registration_step2.thtml";
	}
	else if((levelId == 2)&&(bal < 10))
	{
		alert("Insufficient funds available");
	}
	else
	{
		location.href=built_url+"/withdraw/WithdrawView.do";
	}
	
}
function checkredeem()
{
	if(loyalty <= 0 )
	{
		alert("Insufficient loyalty points available");
	}
	else
	{
		location.href=built_url+"/bingo/account/redeem.thtml";
	}
}
function cardverify()
{
	if(bal>minChangeCardDepAmt)
	{
		location.href=built_url+"/bingo/account/card_accessdenied.thtml";
	}
	else
	{
		location.href=built_url+"/bingo/account/change_card.thtml";
	}

}
function allTransactions(transType)
{
	if(levelId == 1)
	{
		location.href=built_url+"/bingo/registration/registration_step2.thtml";
	}
	else
	{

		document.getElementById(transType).href=built_url+"/deposit/common_transactions.html?type="+transType;
		NewWindow(document.getElementById(transType).href,'mywin','600','550','yes','center');
		return false;
	}
}

function checkredeemBonus()
{
	location.href=built_url+"/bingo/account/redeembonus.thtml";
}
function checklink()
{
	if(levelId == 1)
	{
		location.href=built_url+"/bingo/registration/registration_step2.thtml";
	}
	else
	{
		location.href=built_url+"/deposit/depositView.do";
	}
}

function limitWithdraw()
{
	
	if(levelId == 1)
	{
		location.href=built_url+"/bingo/registration/registration_step2.thtml";
	}
	else
	{
		location.href=built_url+"/withdraw/WithdrawView.do";
	}
}
function createRequestObject() {
    var httprReqobj;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
	try{
			httprReqobj = new ActiveXObject("Microsoft.XMLHTTP");        
	}catch(recreate){
	        httprReqobj = new XMLHttpRequest();		
	}
    }else{
        httprReqobj = new XMLHttpRequest();
    }
    return httprReqobj;
}
function CheckNumber(variable,fieldname)
{
	var nos = "0123456789";
	for(var i=0; i<variable.length ;i++)
	{
		if(nos.indexOf(variable.charAt(i)) == -1 )
		{   		
			alert(fieldname+" får bara innehålla siffror");
			return false;
		}
	}
}
var balhttp_request = createRequestObject();
function getBalance()
{
        balhttp_request.open("POST",context+"/account/balance_retriver.jsp",true);
        balhttp_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        balhttp_request.setRequestHeader("Content-length", 0);
        balhttp_request.setRequestHeader("Connection", "close");
        balhttp_request.send(null);
        balhttp_request.onreadystatechange = handleBalResponse;
}
function handleBalResponse() 
{
	if(balhttp_request.readyState == 4)
	{
		response = balhttp_request.responseText;
		if(balhttp_request.status == 200)
		{
			 var account_res = response.split('&');
			 formatted_bal = account_res[0].split("=")[1];
			 formatted_bonus = account_res[1].split("=")[1];
			try
			{
				ChangeState("realbal",formatted_bal);
				ChangeState("bonbal",formatted_bonus);
				ChangeState("midbal",formatted_bal);
			}catch(e) 
			{}
		}
	}
}
setInterval("getBalance()", 60000);   //This is to call the function for every 60 seconds.
function createParameters(varFormName)
{
	var formlength = varFormName.length;
	var formobj	   = varFormName;
	var querystring= "";
 	for(var i=0;i<=formlength -1;i++)
	{
		try
		{
			if(isFirefox3Above)
				querystring = querystring+formobj[i].name+"="+formobj[i].value+"&";
			else
				querystring = querystring+formobj[i].name+"="+escape(formobj[i].value)+"&";
		}
		catch(e){}
	}
	return querystring;
}