
function newWindow(url,name,w,h) {	
	wi= "width=" + w + ",height=" + h
	sb = ",scrollbars=yes"
	wi = wi+sb
	win = window.open(url,"",wi,sb);
}

/**
 * 
 * @param url
 * @param name
 * @param w
 * @param h
 */
function newWindowPopup(url) {	
	options = "resizable=1,scrollbars=1,menubar=0,status=1,width=800,height=708";
	new2Win = window.open(url, '' ,options);
}


/* non-language game launch - deprecated
function launchGame(game, state) {
	game = escape(game);
	if (state == "real") {
		url = "/gamelaunch/gamewin?gameID="+game;
	}else{
		if (state == "choice") {
			url = "/gamelaunch/choice?gameID="+game;
		}else{
			url = demoplayurl+"&gameID="+game;
		}
	}
	window.open(url,'oneclick','width=800,height=588,resizable=yes,scrollbars=1');
}
*/

function launchGame(game, state, langversion, rb) {
	game = escape(game);
	if (state == "real") {
		url = "/gamelaunch/gamewin?gameID="+game+"&langversion="+langversion + "&reload=0";
	}else{
		if (state == "choice") {
			url = "/gamelaunch/choice?gameID="+game+"&langversion="+langversion;
		}else{
			if (langversion == "en") {
				url = demoplayurl+"&gameID="+game;
			}else{
				url = LANGdemoplayurl+"&gameID="+game+"&langversion="+langversion;
			}
		}
	}
	if(rb){
		var m =	rb.split(',');
		for(i = 0; i < m.length; i++){
			url = url+"&RB="+m[i];
		}
	}
	window.open(url,'oneclick','width=800,height=588,resizable=yes,scrollbars=1');
}

function launchFGGame(game, state) {
	game = escape(game);
	if (state == "real") {
		url = "/gamelaunch/gamewin?gameID="+game+"&type=FG";
	}else{
		if (state == "choice") {
			url = "/gamelaunch/choice?gameID="+game+"&type=FG";
		}else{
			url = FGdemoplayurl+"&GameId="+game;
		}
	}
	window.open(url,'oneclick','width=800,height=588,resizable=yes,scrollbars=1');
}

function newaccount() {
	var url;
		
			url = fromLobReg;
			reg_win = openWin(url,800,588,'regwindow');
		
}

function openWin(url, width, height,name) {
	options = "resizable=1,scrollbars=1,menubar=0,status=1,width="+width+",height="+height;
	new2Win = window.open(url, name ,options);
}

function account (start,mid,stat) {
		var ret_url = encode_url(document.location.href);
		var url = ssl2url+"?action=go_acct_main&casino_aff=default&ret_url="+ret_url;
		if (start != null) {
			url = url + "&start=" + start;
		}
		if (mid != null) {
			url += "&mid=" + mid;
		}
		if (stat != null) {
			url += "&static=" + stat;
		}
		if (start == "go_account_cashier" || start == "go_acct_dep") {
			url = url + "&ext_acct=CASINO";
		}
		acct_win = openWin(url,750,650,'acctwindow'); 
}

function go_unlock() {
	var ret_url = encode_url(document.location.href);
	var unlock_url = unlockUrl+'?action=GoUnlockCustAccount&retURL_good='+ret_url;
	unlockWindow = openWin(unlock_url,'560','400','Unlock');
}

function goBank(type) {
	if (type != '0') {
		if (type == "transfer") {
			account('go_acct_cashier');
		}else{
			account('go_acct_dep');
		}	
	}else{
		account("accounthelp_deposit.html","accounthelp",1);
	}
}

	function encode_url (u) {
		var url = "" + u;
		var l = url.length;
		var i;
		var ret = "";
		var c;
		for (i = 0; i < l; i++) {
			c = url.charAt(i);
			if (c == '&') {
				ret = ret + '~';
			} else {
				if (c == ':') {
					ret = ret + '^';
				} else {
					ret = ret + c;
				}
			}
		}
		return ret;
	}

	function encode_url2 (u) {
		var url = "" + u;
		var l = url.length;
		var i;
		var ret = "";
		var c;
		for (i = 0; i < l; i++) {
			c = url.charAt(i);
			if (c == '&') {
				ret = ret + '%26';
			} else {
				if (c == ':') {
					ret = ret + '%3a';
				} else {
					if (c == '+') {
						ret = ret + '%2B';
					}else{
						ret = ret + c;
					}
				}
			}
		}
		return ret;
	}
	

	function findPosY(obj)
	  {
	    var curtop = 0;
	    if(obj.offsetParent)
	        while(1)
	        {
	          curtop += obj.offsetTop;
	          if(!obj.offsetParent)
	            break;
	          obj = obj.offsetParent;
	        }
	    else if(obj.y)
	        curtop += obj.y;
	    return curtop;
	  }
	
	function calculate_widget_order() {
		var limit = findPosY(document.getElementById('promotions_widget'));
		window.alert(limit);
	}
// end absolutely positioned scrollable area object scripts 

function openImg (imgSrc,dir) {
	str = imgSrc.substring(imgSrc.lastIndexOf("/")+1,imgSrc.length);
	url = "/layout/default/images/paddington/large/"+str;
	if (dir == "v") {
		width = "334";
		height = "498";
	}else{
		width = "735";
		height = "498";
	}
	str = Math.floor(Math.random()*10000);
	window.open(url,str,"width="+width+",height="+height);
	return false;
}
function clearField(elem, matStr)
{
      if(elem.value==matStr || elem.value=='password') {
            elem.value ='';
      }
}

function setField(elem, matStr)
{
      if(elem.value==matStr || elem.value=='password' || elem.value=='') {
            elem.value = matStr;
      }
}

function setStartPage(startPage)
{
  document.getElementById('startPage').value = startPage;
  form = document.getElementById('startPageForm');
  form.submit();
}

// Function to launh the Live Dealer client. mypage = The client url,
// gameName = the game to launch, e.g. Blackjack, Roulette, Baccarat
// myname = The name of the pop up window,
// w, h, the width and height of the pop up window. scroll = Whether the pop up has scroll bars.
function launchLiveDealer(mypage,gameName,myname,w,h,scroll){
	var win = null;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable';
			
	//If url has action=go_live_dealer then it shows Casino Evolution Wallet Info Page
	if(mypage.indexOf('action=DoGameLaunch') != -1) {
		if (gameName != '') {	
		var url = '/gamelaunch/gamelogin?return=LiveDealerUrl'+ '&page=' + gameName;
		} else {
		var url = '/gamelaunch/gamelogin?return=LiveDealerUrl&page=Roulette';
		}
		var language = location.href.split('/')[3] ;
		win = window.open( '/' + language + '/gamelaunch/walletinfo?gameUrl='+encode_url2(url),myname,settings);
	} else {
		win = window.open(mypage,myname,settings);
	}
}
