
var temp = "no";
	var path= location.pathname;
	var built_url = location.protocol+"//"+location.host+"/"+path.split("/")[1];
function clrForm()
{
	
	if(temp == 'no' )
	{
		document.loginform.username.value="";
		//document.getElementById("pass").innerHTML= '<input class="inputLogin" name="password" type="password" onfocus="javascript:clrForm()"/>';
		document.loginform.password.value="";
		document.loginform.username.focus();
	}
	temp = "yes";
}

function pageOnload ()
{
	if (location.search.indexOf("confirm=invalid")==-1)
	{
	if(temp == 'no')
		{
		document.loginform.username.value="Login name";
		document.loginform.password.value="password";		
		}
		
	}

}
if(session_id == 'null')
{

	if (location.href.indexOf("bingo/home/")!=-1)
		window.onload = pageOnload;
}


//function commonHeader()
//{
//	try
//	{
//		if(session_id == 'null')
//		{	
//			
//			
//			document.write('<div id="loginpanel">');
//			document.write('<form action="/commonsys/home/loginAction.do" method="POST" autocomplete="off" name="loginform" tabindex="2">');
//			document.write('<span class="login_txt">Login</span><input class="textboxLog" name="username" type="text" autocomplete="off" onfocus="javascript:clrForm();" />');
//			document.write('<br /><span class="password_txt">Password</span><span id="pass"><input class="textboxLog" name="password" type="text" onfocus="javascript:clrForm();"/></span>');
//			document.write('<div id="loginforgotten"><a href="'+built_url+'/bingo/registration/forgotten.thtml" class="header" onfocus="this.blur();" title="Forgotten Password?">Forgotten Password?</a></div>');
//			document.write('<div id="loginenter"><a href="javascript:Validate()"  onmouseover="MM_showHideLayers(\'logininfo\',\'\',\'show\')" onmouseout="MM_showHideLayers(\'logininfo\',\'\',\'logininfo\')"  value="Login"  onclick="javascript:test();"/><img name="enter"  tabindex="4" src="/yahoonew/bingo/images/login.gif" border="0" alt="Enter" /></a></div>');
//			document.write('</form>');
//			document.write('</div>'); 
//			
//			if (location.search.indexOf("confirm=invalid")==-1)
//			{
//				document.loginform.username.value="";
//				document.loginform.password.value="";
//			}
//		}
//		else
//		{
//			document.write('<div><br><br><br><a href="'+built_url+'/bingo/account/edit_account.thtml" onfocus="this.blur();"><img src="/yahoonew/bingo/images/bt_editaccount.gif" border="0" alt="Edit Account" /></a></div>');
//			document.write('<a href="/commonsys/login/logout.do" onfocus="this.blur();" onclick="javascript:return CloseGameWindow();"><img name="logout" src="/yahoonew/bingo/images/bt_logout.gif" border="0" alt="Logout" vspace="5" /></a>');
//				
//		}
//	}
//	catch(e)
//	{
//		alert(e);
//		//location.href="../maintenance/maintenance.html";
//	}
//}

function commonHeader1()
{
	try
	{
		if(session_id == 'null')
		{	
	        document.write('<div id="loginBox">');
			document.write('<div id="loginLeft">');
			document.write('<form action="/commonsys/home/loginAction.do" method="POST" autocomplete="off" name="loginform">');
			document.write('<h1 style="text-transform: none">Welcome</h1>');
			document.write('<a href="'+built_url+'/bingo/registration/forgotten.thtml">Forgotten details?</a></div>');
			document.write('<div id="login">');
			document.write('<div class="loginUser">Login name</div>');
			document.write('<div class="loginPassword">password</div>');
			document.write('<div class="loginUserField"><input class="inputLogin" name="username" type="text" autocomplete="off" onfocus="javascript:clrForm()"/></div>');
			document.write('<div class="logiPasswordField"><span id="pass"><input class="inputLogin" name="password" type="password" onfocus="javascript:clrForm()"/></span></div>');
			document.write('<div class="loginsubmit"><input name="" type="submit" class="loginBut" onclick="javascript: return Validate()" value="Login"  onclick="javascript:test();" /></div>');
			document.write('</form>');
			document.write('</div>');
			document.write('</div>');
        
			
			/*if (location.search.indexOf("confirm=invalid")==-1)
			{
				document.loginform.username.value="username";
				document.loginform.password.value="password";
			}*/
		}
		else
		{
			
			document.write('<div id="accountArea">');
			document.write('<div><a href="'+built_url+'/bingo/account/edit_account.thtml" onfocus="this.blur();" class="editacct"><img src="/yahoonew/bingo/images/bt_editaccount.gif" border="0" alt="Edit Account" /></a></div>');
			document.write('<a href="/commonsys/login/logout.do" onfocus="this.blur();" onclick="javascript:return CloseGameWindow();" class="logout"><img name="logout" src="/yahoonew/bingo/images/bt_logout.gif" border="0" alt="Logout" vspace="5" /></a>');
			document.write('</div>');
			
		}
		
	}
	catch(e)
	{
		location.href="../maintenance/index.html";
	}
}

var validuser;
var request_flag = true;
function Validate()
{
				
	//alert(document.loginform.password.value);
	if(request_flag)
	{
	
			if(document.loginform.password.type == 'text')
			{
				alert('Please enter a valid Login name and password');
				return false;
			}
			var username = document.loginform.username.value;
			var password = document.loginform.password.value;
			if((username==null) || (username==""))
			{  
		
				alert("Enter the Login name");
				document.loginform.username.focus();
				return false;
			}
			else if((password==null) || (password==""))
			{
				alert("Enter the Password");
				document.loginform.password.focus();
				return false;
			}
			else if(isValidPasswd(password,username)==-1)
			{
				document.loginform.password.focus();
				return;
			}
			else
			{
				var val = isValidPasswd(document.loginform.password.value, document.loginform.password.value);
				if(val != 0)
					return;
				request_flag = false;
				var hardCodedURL = location.host; 
				var strPathname = location.pathname;
				var action_path = strPathname.split("/");
				var action_url="http://"+hardCodedURL+"/"+action_path[1];
				if((hardCodedURL.indexOf("demo") != -1 ) || (hardCodedURL.indexOf("test") != -1 ))
				{
					hardCodedURL = "testgaming.st-minver.com";	
					action_url="https://"+hardCodedURL;
					
				}else
				{
					hardCodedURL = "bingo.st-minver.com";	
					action_url="https://"+hardCodedURL;
				}				
				document.loginform.action = action_url + "/commonsys/home/loginAction.do";	
				document.loginform.method="POST";
				document.loginform.submit();
				return;
			}
		}
		else
		{
			alert("Request is in progress");
			//return false;
		}
}

function ImageURL()
{	
	if(session_id != 'null')
	{
		if(isDynamicLobby == "true")
		{
			document.location=built_url+"/bingo/lobby/index.thtml";
		}
		else
		{
			//document.location="../../login/BingoLogin.do";
			document.location=built_url+"/bingo/lobby/top-games/"; // by madhava Monday, March 06, 2006
		}
	}
	else
	{
		document.location = built_url+"/bingo/registration/login.thtml";
	}
}

function PlayNowURL()
{	
		
		if(session_id != 'null')
		{ 
				if(document.getElementById("dynaplaynow"))
				{
					if(isDynamicLobby == "true")
					{
						document.location=built_url+"/bingo/lobby/index.thtml";
					}
					else
					{
						//location.href="../../login/BingoLogin.do";
						location.href=built_url+"/bingo/lobby/top-games/"; // by madhava Monday, March 06, 2006
					}
				}
		}else
		{
				if(document.getElementById("dynaplaynow"))
				location.href=built_url+"/bingo/registration/registration_step1.thtml";
		}
}
 
function ChangeState(id,message)
{
		if(document.getElementById(id))
			document.getElementById(id).innerHTML = message;
}

function ChangeVisibility(tagid,thevisiblity)
	{
		if(document.getElementById(tagid))
			document.getElementById(tagid).style.visibility = thevisiblity;
	}

function CloseGameWindow()
{
			allowResize = "no";
			// Start at top left
			LeftPosition = 0;
			TopPosition = 0;
			// Go almost full-screen for Flash Bingo
			myHeight = (screen.height) ? (screen.height-145) : 0;
			myWidth = myHeight * 1.375;

			// Set the left and top window position to zero if logic above has produced a value less than zero
			if (LeftPosition < 0) {	LeftPosition = 0;}
			if (TopPosition < 0) {	TopPosition = 0;}
			// Configure other window properties
			winProps = "left="+LeftPosition+",top="+TopPosition+",width="+myWidth+",height="+myHeight+",location=0,scrollbars=0,menubar=0,toolbar=0,resizable=" + allowResize;
	var win_ref = window.open("../../pre_refresh.jsp", "Logout", winProps);
	win_ref.close();
	window.event.returnValue = true;
	return true;
}
//title for the 
 //document.title='Littlewoods Bingo';

function isValidPasswd(pw, username){
  if(pw.length == 0){
    alert("Please enter a valid password.");
    return -1;
  } else if (pw.length > 30) {
    alert("Please enter a valid password");
    return -1;
  }else if (pw.length < 6) {
    alert("Please enter a valid password");
    return  -1;
  }/* else if ((username.length > 2) && (pw.indexOf(username) >= 0) ){
    alert("Please enter a valid password");
    return -1;
  } */else {
    return 0;
  }
}

function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}
function openSlots()
{
	if(session_id == 'null')
	{
		location.href=built_url+"/bingo/registration/login.thtml";
	}else
	{
		//location.href="/commonsys/home/loginAction.do";
		openGamePage('Grow Me The Money');
	}
}

function openVideoPoker()
{
	if(session_id == 'null')
	{
		location.href=built_url+"/bingo/registration/login.thtml";
	}else
	{
		//location.href="../login/Login.do#slotgames";
		openGamePage('Video Poker!');
	}
}

function openBingoWin()
{
	if(session_id == 'null')
	{
		location.href=built_url+"/bingo/registration/login.thtml";
	}else
	{
		if(isDynamicLobby == "true")
		{
			location.href=currentContext+"/bingo/lobby/index.thtml?bingogames";
		}
		else
		{
			location.href=currentContext+"/bingo/lobby/top-games/index.thtml?bingogames";
		}
	}
}
function OpenKeno()
{

	//alert('under construction');
	if(session_id == 'null')
	{
		location.href=built_url+"/bingo/registration/login.thtml";
	}else
	{
		//location.href="../login/Login.do?kenogames";	
		openGamePage('Roulette');
	}
}

function openGames(gamename)
{
	//alert(gamename);
	if(session_id == 'null')
	{
		location.href=built_url+"/bingo/registration/login.thtml";
	}else
	{
		openGamePage(gamename);
	}
}

function gamepagelink()
{
	if(session_id != 'null')
	{
		document.location="/commonsys/home/loginAction.do";

	}
	else
	{
		document.location = "../games/index.thtml";
	}
}
function addTrackTag(){
	var request_protocol	= location.protocol;
	var request_pathname	= location.pathname;
	var request_querString  = location.search;
	if(request_pathname.indexOf("/deposit/bonushistory.html") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_bonushistory_10"/>');
	}
	if(request_pathname.indexOf("/community/index.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_community_10"/>');
	}
	if(request_pathname.indexOf("/account/edit_account.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_editaccount_10"/>');
	}
	if(request_pathname.indexOf("/info/index.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_gettingstarted_10"/>');
	}
	if(request_pathname.indexOf("/info/help.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_help_10"/>');
	}
	if(request_pathname.indexOf("info/help_banking.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_helpbanking_10"/>');
	}
	if(request_pathname.indexOf("/info/help_bonus.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_helpbonus_10"/>');
	}
	if(request_pathname.indexOf("/info/help_gameplay.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_helpgameplay_10"/>');
	}
	if(request_pathname.indexOf("/info/help_gettingstarted.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_helpgettingstarted_10"/>');
	}
	if(request_pathname.indexOf("/info/help_privacy.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_helpsecurity_10"/>');
	}
	if(request_pathname.indexOf("/home/index.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_indexpage_10" />');
	}
	if(request_pathname.indexOf("/registration/login.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_loginpage_10"/>');
	}
	if(request_pathname.indexOf("/promotions/index.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_promotions_10"/>');
	}
	if(request_pathname.indexOf("/registration/step1FinishedView.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_regcomplete_10"/>');
	}	
	if(request_pathname.indexOf("/registration/registration_step1.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_regpage1_10"/>');
	}	
	if(request_pathname.indexOf("/info/sitemap.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_sitemap_10"/>');
	}	
	if(request_pathname.indexOf("/timetable/index.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_timetable_10"/>');
	}
	
	if(request_querString.indexOf("Deposit") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_deposithistory_10"/>');
	}
	if(request_querString.indexOf("Withdraw") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_withdrawal_10"/>');
	}
	if(request_querString.indexOf("Transaction") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_transactions_10"/>');
	}
	if(request_pathname.indexOf("/account/deposit.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_opencheckdeposit_10"/>');
	}
	if(request_pathname.indexOf("/account/edit_account.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_editaccount_10"/>');
	}
	if(request_pathname.indexOf("/account/withdrawal_cheque.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_opencheckwithdrawal_10"/>');
	}
	if(request_pathname.indexOf("/account/withdrawal.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_opencheckwithdrawal_10"/>');
	}
	if(request_pathname.indexOf("/lobby/index.thtml") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_openbingogamescreen_10"/>');
	}
	if(request_pathname.indexOf("/login/Login.do") != -1)
	{
		document.write('<img height="1" width="1" src="'+request_protocol+'//switch.atdmt.com/action/cdkcht_opengamescreen_10"/>');
	}
}
addTrackTag();

function Validate1()
{
	location.href=built_url+"/bingo/registration/registration_step1.thtml";
	return false;
}
function getCookie()
{
	 var dc = document.cookie;
	 var c = dc.split(';');
	 var value='';
	 if(c.length > 0)
		{
			for(var i =0; i< c.length;i++)
			{
				var key = trim(c[i].split('=')[0]);
				if(key == 'TRADEDOUBLER')
				{
					//alert(c[i].split('=')[0]);
					//alert(c[i].split('=')[1]);
					value = c[i].split('=')[1];
				}
			}
		}
	return  value;
}

if(location.search == "?cookie")
{
	alert(document.cookie);
	//getCookie()
}

try
{
	//alert(currentContext);
	var parentUrl = location.href;
	//alert(parentUrl.indexOf("/home/index.html"));
		var splitString = "/bingo/";
		var urlToSend = parentUrl.split(splitString)[0]+splitString
		//alert(urlToSend);
		var img = new Image();
		img.src = "/commonsys/details.jsp?url="+urlToSend;
		//alert(img.src) ;
	 
	/*if(parentUrl.indexOf(currentContext) == -1)
	{
		var splitString = "/bingo/";
		var urlToSend = parentUrl.split(splitString)[0]+splitString
		//alert(urlToSend);
		var img = new Image();
		img.src = "/commonsys/details.jsp?url="+urlToSend;
	}*/
}
catch(e){}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=550,height=600,left = 365,top = 180');");
}
function popUp2(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=550,height=600,left = 365,top = 180');");
}
//Peters New Lobby Button ;

//copy image;
function playButton()
{
	try
	{
		if(session_id == 'null')
		{				
		   document.write('<a href="'+built_url+'/bingo/registration/registration_step1.thtml"><img src="'+built_url+'/bingo/images/bt_sign_up.gif" width="150" height="66" border="0" alt="Online Bingo &#8250; Play now" style="cursor:hand"/></a>');
		}
		else
		{
			if(isDynamicLobby == "true")
			{
				 document.write('<a href="'+built_url+'/bingo/lobby/index.thtml"><img src="'+built_url+'/bingo/images/bt_play_bingo.gif" width="150" height="66" border="0" alt="Online Bingo &#8250; Play now" style="cursor:hand"/></a>');
			}
			else
			{
				 document.write('<a href="'+built_url+'/bingo/lobby/top-games/"><img src="'+built_url+'/bingo/images/bt_play_bingo.gif" width="150" height="66" border="0" alt="Online Bingo &#8250; Play now" style="cursor:hand"/></a>');
			}
			
		}
	}
	catch(e)
	{
			document.write('<a href="'+built_url+'/bingo/registration/registration_step1.thtml"><img src="'+built_url+'/bingo/images/bt_sign_up.gif" width="150" height="66" border="0" alt="Online Bingo &#8250; Play now" style="cursor:hand"/></a>');
			//alert(e);
		//location.href="../maintenance/maintenance.html";
	}
}

function bingoNav()
{
	try
	{
		if(session_id == 'null')
		{	if(isDynamicLobby == "true"){	
				document.write('<a href="'+built_url+'/bingo/lobby/index1.thtml" onfocus="this.blur();"><img class="lftnavbttp" src="'+built_url+'/bingo/images/bt_bingo_games.gif" border="0" alt="Learn to play Online Bingo" /></a>');
			}else{
				document.write('<a href="'+built_url+'/bingo/lobby/top-games/index1.thtml" onfocus="this.blur();"><img class="lftnavbttp" src="'+built_url+'/bingo/images/bt_bingo_games.gif" border="0" alt="Learn to play Online Bingo" /></a>');
			}
		}
		else
		{
			if(isDynamicLobby == "true"){	
				document.write('<a href="'+built_url+'/bingo/lobby/index.thtml" onfocus="this.blur();"><img class="lftnavbttp" src="'+built_url+'/bingo/images/bt_bingo_games.gif" border="0" alt="Learn to play Online Bingo" /></a>');
			}else{
				document.write('<a href="'+built_url+'/bingo/lobby/top-games/" onfocus="this.blur();"><img class="lftnavbttp" src="'+built_url+'/bingo/images/bt_bingo_games.gif" border="0" alt="Learn to play Online Bingo" /></a>');

			}

		}
	}
	catch(e)
	{
			if(isDynamicLobby == "true"){	
				document.write('<a href="'+built_url+'/bingo/lobby/index1.thtml" onfocus="this.blur();"><img class="lftnavbttp" src="'+built_url+'/bingo/images/bt_bingo_games.gif" border="0" alt="Learn to play Online Bingo" /></a>');
			}else{
				document.write('<a href="'+built_url+'/bingo/lobby/top-games/index1.thtml" onfocus="this.blur();"><img class="lftnavbttp" src="'+built_url+'/bingo/images/bt_bingo_games.gif" border="0" alt="Learn to play Online Bingo" /></a>');
			}
			//alert(e);
		//location.href="../maintenance/maintenance.html";
	}
}

//copy end;

function myAccountNav()
{
    try
    {
        if(session_id != 'null')
        {        
            if(isMyAccountCheckEnabled == 'Y' && isPlayerSegmentMatched=='true')
			{
				if(isDynamicLobby == "true"){	
					//document.write('<div class="navbutton" id="navbg"><a href="'+built_url+'/bingo/lobby/index.thtml?popup" title="My Account">My Account</a></div>');
					document.write('<div class="navbutton"><a href="'+built_url+'/bingo/lobby/index.thtml?popup" title="My Account" class="NavTxt">My Account</a></div>');
				}else{
					//document.write('<div class="navbutton" id="navbg"><a href="'+built_url+'/bingo/lobby/top-games/?popup" title="My Account">My Account</a></div>');
					document.write('<div class="navbutton"><a href="'+built_url+'/bingo/lobby/top-games/?popup" title="My Account" class="NavTxt">My Account</a></div>');
				}                
			}
        }
    }
    catch(e)
    {
            //do nothing
    }
}

function idVerificationNav()
{
    try
    {
		if(session_id != 'null')
        {        
            if(isDocsUpload!='Y' && isUploadApp=='Y')
                document.write('<div class="navbutton"><a href="'+built_url+'/bingo/account/uploadbankdetails.thtml" class="NavTxt" title="ID Verification">ID Document Upload</a></div>');
        }
    }
    catch(e)
    {
            //do nothing
    }
}

