var now = new Date();
 newgameWin=new Object();
//var prt_window=window;
w_id = "LadbrokesBackgammonHome";

	w_id += now.getYear();
	w_id += now.getDate();
	w_id += now.getMonth();
	w_id += now.getHours();
	w_id += now.getMinutes();
	w_id += now.getSeconds(); 



var current_tab  = "home";


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_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 showmenu() {
	var navitem = document.getElementById("idlang");
	navitem.style.zIndex=100;
	divpostop = navitem.offsetTop;
	divposleft = navitem.offsetLeft;
	divposwidth = navitem.offsetWidth;
	divposheight = navitem.offsetHeight;

	dropHi = document.getElementById("footer").offsetTop;
//	dropHi = document.getElementById("langselect").offsetTop;
	droptheight2 = document.getElementById("main").offsetHeight;


	if (document.documentElement && document.documentElement.scrollTop){
		theTop = document.documentElement.clientHeight;
	}else{
		if (document.body) {
			theTop = document.body.clientHeight;
		}
	}

	navitem.style.position = "absolute";

//	navitem.style.top = dropHi - divposheight+8;

	var IE = (document.all)
  if (IE) { // IE
    	navitem.style.top = droptheight2-divposheight+50;
  } else {  // FF
	navitem.style.top = droptheight2-divposheight+60;
  }  

	if (navitem.style.visibility != "visible") {
		navitem.style.display = "block";
		if(navitem.filters){
			navitem.filters[0].Apply();
			navitem.filters[0].Play();
		}
		navitem.style.visibility="visible";			
	}
}

//STEVES NEW FUNCTION
function getParent(obj,objThis){
	//obj is objDepartedNode
	while(obj){
		//alert("obj.id="+obj.id)
		if(obj == objThis){
			return obj;
		}		
		obj = obj.parentNode;
	}
	return null
}
function IsChildHovered(e,objThis){
	var isChildHovered = false;
	var objDepartedNode = (e.relatedTarget)?e.relatedTarget:e.toElement;
	/*
	var strAlert = ""
	for(var obj in e){
		strAlert+=obj + "="+eval("e."+obj) + "      ";
	}
	alert("strAlert:\n\n"+strAlert)
	*/
	var objParent = getParent(objDepartedNode,objThis);
	if(objParent){
		isChildHovered = true;
	}
	return isChildHovered;
}
function isMouseOutObjectArea(e,objThis){//,obj2,obj3
	//this is to detect if a user mouseout from one object to another object
	//for example, a user will mouseout from MORE to HIDEMELAYER or vice versa
	//in which case all further mouseout functionality will be void.
	var objDepartedNode = (e.relatedTarget)?e.relatedTarget:e.toElement;		
	for(var a = 1; a < isMouseOutObjectArea.arguments.length; ++a){
		if(objDepartedNode == isMouseOutObjectArea.arguments[a]){
			return false;
		}
	}
	//a mouseout will trigger even if a user does a mouseover onto a node inside the parent node
	//so this detects if the mouseout was triggered by mouseover onto the parents child nodes.
	//and if it does then all further mouseout functionality will be void.
	if(IsChildHovered(e,objThis)){return false}		
	return true;
}

function ID(strId){
	return document.getElementById('id'+strId);
}

function moreinfo(strId){
	return document.getElementById('moreinfo'+strId);
}
	
function hidemenu(e,objThis){
	var e=(e)?e:window.event;
	if(isMouseOutObjectArea(e,objThis)){
		objThis.style.visibility="hidden";
	}
}

function showInfo(objItem) { 

	navitem = document.getElementById("id"+objItem);

	parentitem = navitem.parentNode;
	divpostop = navitem.offsetTop;
	divposleft = navitem.offsetLeft;
	divposwidth = navitem.offsetWidth;
	divposheight = navitem.offsetHeight;

	dropHi = parentitem.offsetTop+parentitem.offsetParent.offsetTop+parentitem.parentNode.offsetParent.offsetTop+parentitem.offsetHeight+3;
	if (document.documentElement && document.documentElement.scrollTop){
		theTop = document.documentElement.clientHeight;
	}else{
		if (document.body) {
			theTop = document.body.clientHeight;
		}
	}
		navitem.style.position = "absolute";
		navitem.style.top = dropHi;


	if (navitem.style.visibility != "visible") {
		navitem.style.display = "block";
		navitem.style.visibility="visible";	
		if(navitem.filters){
			navitem.filters[0].Apply();
			navitem.filters[0].Play();
		}
	}
}

//_________________________
function hideInfo(e,objThis,strHideId,objAllowMouseout1,objAllowMouseout2){
	var e=(e)?e:window.event;	
		
	if(isMouseOutObjectArea(e,objThis,objAllowMouseout1,objAllowMouseout2)){
		
		//the reason i have put this line here is just to make the code look neater in the HTML
		var objHide = ID(strHideId)		
		
		objHide.style.visibility="hidden";
	}
}


// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
	e=(e)?e:window.event;
	/*e.stopPropagation();
	e.cancelBubble = true;*/
	
	var IE = (document.all)
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  mousepos=tempX+","+tempY;
	//document.title = mousepos
}
function getMouseXYIE(e){
		e=(e)?e:window.event;
	var IE = (document.all)
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  

alert(tempX + ","+tempY);
  return tempX+","+tempY;
}


function banner_DoFSCommand(command, args){
	alert(command + "  " + args)
	if(command=="click"){
		switch (args) {
			case "ff":
				alert(args);
				break;
			default:
		}
	}
}

function newWindow(url,name,w,h) {	
	wi= "width=" + w + ",height=" + h
	sb = ",scrollbars=yes"
	wi = wi+sb
	win = window.open(url,name,wi,sb);
}

/*function dolaunchKanaRealtime() {
	launchKanaRealtime( location.href,"https://livehelp.ladbrokes.com/KanaImail/ladbrokescasino_Imail/KanaRealtime/KanaRealtime.html","","test","Please complete your details below" );
}*/
var mousepos;
document.onmouseover = getMouseXY;
document.onmouseout = getMouseXY;



// begin absolutely positioned scrollable area object scripts 
function verifyCompatibleBrowser(){ 
	this.ver=navigator.appVersion 
	this.dom=document.getElementById?1:0 
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
	this.ie4=(document.all && !this.dom)?1:0; 
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0; 
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) 
	return this 
} 
bw=new verifyCompatibleBrowser() 
lstart = 15; 
incr = 16;
curr = lstart;
next = lstart+incr;
loop=true  
speed=25 
pr_step=1 
function ConstructObject(obj,nest){ 
    nest=(!nest) ? '':'document.'+nest+'.' 
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 
  	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight 
	this.newsScroll=newsScroll; 
	this.moveIt=b_moveIt; this.x; this.y; 
    this.obj = obj + "Object" 
    eval(this.obj + "=this") 
    return this 
} 
function b_moveIt(x,y){ 
	//this.x=x;
	this.y=y 
	//this.css.left=this.x 
	this.css.top=this.y 
} 
//Makes the object scroll up 
function newsScroll(speed){
	if (curr < next) {
		if(this.y>-this.scrollHeight){ 
			this.moveIt(0,this.y-pr_step) 
			setTimeout(this.obj+".newsScroll("+speed+")",speed) 
			curr = curr + 1;
		}else if(loop) { 
			curr = lstart;
			next = lstart+incr;
			this.moveIt(0,lstart)
			eval(this.obj+".newsScroll("+speed+")")
			//curr = curr + 1;
		} 
	}else{
		next = next + incr;
		setTimeout(this.obj+".newsScroll("+speed+")",7000)
	}
} 
//Makes the object 
function InitialiseAutoScrollArea(){ 
	objContainer=new ConstructObject('tickerContainer') 
	objContent=new ConstructObject('ticker','tickerContainer') 
	objContent.moveIt(0,lstart) 
	objContainer.css.visibility='visible' 
	objContent.newsScroll(speed) 
} 
// 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 getDetails() {
	window.open('http://casino-dev.ladbrokes.com/ssl/getdetail.php','getdetails','width=200,height=200');
}
function validate(form){
		
		var error = "";
		//for each form element
		for(var i=0; i<form.length; i++){
			var element = form[i];
			//if required
			if(element.getAttribute("required") == "yes"){
				//if form element if empty
				if(!valid(element.value,element.getAttribute("validate"),element))
					error += element.getAttribute("message") + "\r\n";	
			}
		}
		if(error != ""){
			alert(error);
			document.formSubmit = false;
		}
		else
			document.formSubmit = true;
	}	
	
	function valid(value,type,element){
		if(value == "")
			return false;
			
		switch(type){
			case "int":
				if(isNaN(parseInt(value)))
					return false;
				break;
			case "float":
				if(isNaN(parseFloat(value)))
					return false;
				break;
			case "email":
				var p = value.indexOf('@');
				if(p<1 || p==(value.length-1))
					return false;
				break;
			case "checked":
				if(!element.checked)
					return false;
				break;
			default://string
				break;
		}
		return true;
	}

function popupadClose() {
	tempobj = document.getElementById('popupad');
	tempobj.style.visibility = "hidden";
}

/* menu */

window.onload=montre;
function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}
