//
//  THIS FILE IS SERVED FROM COMMONAPACHE SERVER.
//
try
{
	var cur_symbol="&#163;";
	if(cur == "978")
		cur_symbol="&#8364;";

	ChangeState("uname",username);
	ChangeState("the_usernameright",username);
	ChangeState("realbal",cur_symbol+bal);
	ChangeState("bonbal",cur_symbol+bonus);
	ChangeState("tollypoints",points);
	ChangeState("loyalty",loyalty);
	
	//Added for Common Header
	ChangeState("header_realbal",cur_symbol+bal);
	ChangeState("header_bonbal",cur_symbol+bonus);
	ChangeState("header_loyalty",loyalty);


}
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;
}


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){
		var balResponse = balhttp_request.responseText;
		if(balhttp_request.status == 200){
			var account_res = balResponse.split('&');
			formatted_bal = account_res[0].split("=")[1];
			formatted_bonus = account_res[1].split("=")[1];
			ChangeState("realbal",formatted_bal);
			ChangeState("bonbal",formatted_bonus);	
		}
	}
}