
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.loginform.password.value="";
//	document.getElementById("pass").innerHTML= '<input class="inputLogin" name="password" type="password"  onclick="javascript:clrForm()"/>';
	}
	temp = "yes";
}

function commonHeader()
{
	try
	{
		if(session_id == 'null')
		{	
			document.write('<div class="grid_1">');
        	document.write('<div id="customer">');
           	document.write('<h1>New Player?</h1>');
            document.write('<a href="/jackpotslots/casino/registration/registration_step1.thtml?hide=true">Register now to play JackpotSlots!</a>');
            document.write('</div>');
        	document.write('</div>');
        	document.write('<div class="grid_2">');
        	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>Welcome</h1>');
			document.write('<a href="'+built_url+'/casino/registration/forgotten.thtml">Forgotten details?</a></div>');
			document.write('<div id="login">');
			document.write('<div class="loginUser">username</div>');
			document.write('<div class="loginPassword">password</div>');
			document.write('<div class="loginUserField"><input class="inputLogin" name="username" type="text" autocomplete="off" onclick="javascript:clrForm()"/></div>');
			document.write('<div class="logiPasswordField"><span id="pass"><input class="inputLogin" name="password" type="password" onclick="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>');
        	document.write('</div>');
			
			if (location.search.indexOf("confirm=invalid")==-1)
			{
				document.loginform.username.value="username";
				document.loginform.password.value="password";
			}
		}
		else
		{
			document.write('<div class="grid_3">');
			document.write('<div id="accountArea">');
			document.write('<div class="accountTitleLrg"><span id="the_usernameright"></span>&nbsp;balance:</div>');
			document.write('<div class="accountTitle">Free play points:</div>');
			document.write('<div class="accountTitle">Bonus money:</div>');
			document.write('<div class="accountTitle">Loyalty points:</div>');
			document.write('<div class="accountButtons">');
			document.write('<div class="accountBut"><a class="button" href="javascript:checkredeem();"><span>Redeem Pts</span></a></div>');
			document.write('<div class="accountBut"><a class="button" href="javascript:checkwithdraw();"><span>Withdrawal</span></a></div>');
			document.write('<div class="accountBut"><a class="button" href="javascript:checkdeposit();"><span>Deposit</span></a></div>');
			document.write('</div>');
			document.write('<div class="accountAmountLrg"><span id="realbal"></span></div>');
			document.write('<div class="accountAmount"><span id="tollypoints"></span></div>');
			document.write('<div class="accountAmount"><span id="bonbal"></span></div>');
			document.write('<div class="accountAmount"><span id="loyalty"></span></div>');
			document.write('</div>');
			document.write('</div>');
		}
		
	}
	catch(e)
	{
		location.href="../maintenance/index.html";
	}
}

function ImageURL()
{	
	if(session_id != 'null')
	{
		document.location=built_url+"/home/loginAction.do";
	}
	else
	{
		document.location = built_url+"/casino/registration/registration_step1.thtml";
	}
}


function PlayNowURL()
{	
		
		if(session_id != 'null')
		{ 
				 if(document.getElementById("dynaplaynow"))
				 location.href=built_url+"/home/loginAction.do";
		}else
		{
				if(document.getElementById("dynaplaynow"))
				location.href=built_url+"/casino/registration/registration_step1.thtml";
		}
}
function AccountURL()
{
		if(session_id != 'null')
		{
				if(document.getElementById("account"))
						document.getElementById("account").href="../../deposit/Account.do";
		}else
		{
			if(document.getElementById("account"))
				 document.getElementById("account").href="../../casino/registration/login.thtml";
		}

}


/*
* The below method effects to all the static pages

 document.title = "VIPCASINO CLUB"; */


/***

**/
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  }
  return null;
}

var validuser;
function Validate()
{
	if(document.loginform.password.type == 'text')
	{
		alert('Please enter a valid username and password');
		return false;
	}
	var username = document.loginform.username.value;
	var password = document.loginform.password.value
	if((username==null) || (username==""))
    {  
        alert("User Name should not be empty");
        document.loginform.username.focus();
        return false;
    }
    else if((password==null) || (password==""))
    {
        alert("Password should not be empty");
        document.loginform.password.focus();
        return false;
    }
    else if(isValidPasswd(password,username)==-1)
    {
        document.loginform.password.focus();
        return false;
    }
    else
    {
		var val = isValidPasswd(document.loginform.password.value, document.loginform.password.value);
		if(val != 0)
			return false;
		var hardCodedURL = location.host; 
		var strPathname = location.pathname;
		var action_path = strPathname.split("/");
		var action_url="https://"+hardCodedURL+"/"+action_path[1];

		if((hardCodedURL.indexOf("demo") != -1 ) || (hardCodedURL.indexOf("casino-v2") != -1 ))
		{
			hardCodedURL = "casino-v2.st-minver.com";	
			action_url="https://"+hardCodedURL;
		} else
		{
			hardCodedURL = "gaming.st-minver.com";	 
			action_url="https://"+hardCodedURL;
		}
		
		document.loginform.action = action_url + "/commonsys/home/loginAction.do";
		document.loginform.method="POST";
		document.loginform.submit();
		return false;
    }
}
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 putValues()
{
	var errorObj = document.getElementById("error");
	var errorMsg = getQueryVariable("error");
	if (errorMsg){ errorObj.innerText = errorMsg;}
	var userObj = document.all["username"];
	var userVal = getQueryVariable("user");
	if (userVal) {userObj.value=userVal;}
	userObj.focus();userObj.select();
}

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 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("", "slotgames", winProps);
	win_ref.close();
	window.event.returnValue = true;
	return true;
}


function createRequestObject1() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject1();
function LoginReq(username,password) {

	http.open('get', '../../shared/login_check.jsp?username='+username+'&password='+password+'&platform=RIGHTRESULT');
    http.onreadystatechange = handleResponse1;
    http.send(null);
}

function handleResponse1() {
    if(http.readyState == 4){
        var response = http.responseText;
		validuser =	response;
    }
}


   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 openNewWindow(test,temp)
	{
		location.href="../registration/registration_step1.thtml"
	}
	
var registration_validity = getQueryVariable("confirm");
if(registration_validity == "true")
{
	alert("Your registration has been successfully confirmed. Please login with your username and password.");
}
else if(registration_validity == "false")
{
	alert("Your session has been expired or your are not logged in ,Please login again.");
}
function goURL(gimmie)
{
	if (document.myform[gimmie].selectedIndex != -1) {
		document.location.href =
		document.myform[gimmie].options[document.myform[gimmie].selectedIndex].value;
	}
}


  function Test(id,message)
	{
		if(document.getElementById(id))
			document.getElementById(id).innerHTML = message;
	}

try
{
	//alert(currentContext);
	var parentUrl = location.href;
	//alert(parentUrl.indexOf("/home/index.html"));
		var splitString = "/casino/";
		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){}


document.write('<script language="JavaScript" type="text/javascript" src="/commonjs_english/js_includes/openGameWindow.js"></script>');


function accountBut()
{
	try
	{
		if(session_id == 'null')
		{		
			document.write('');
		}
		else
		{
			document.write('<li><a onFocus="if(this.blur)this.blur()" href="/jackpotslots/casino/account/edit_account.thtml"><span>Edit Account</span></a></li>');
		}
	}
	catch(e)
	{
			document.write('');
		
	}
}

function logOut()
{
	try
	{
		if(session_id == 'null')
		{		
			document.write('<a href="/jackpotslots/casino/registration/registration_step1.thtml">Sign up here!</a>');
		}
		else
		{
			document.write('<a href="/jackpotslots/login/logout.do">Log out</a>');
		}
	}
	catch(e)
	{
			document.write('<a href="/jackpotslots/casino/registration/registration_step1.thtml">Sign up here!</a>');
		
	}
}

 
 function idVerificationNav()
{
	try
	{
		if(session_id == 'null')
		{		
			document.write('');
		}
		else if(isDocsUpload!='Y' && isUploadApp=='Y')
		{
			document.write(' | <a onFocus="if(this.blur)this.blur()" href="'+built_url+'/casino/account/uploadbankdetails.thtml"><span>ID Document Upload</span></a>');
		}
	}catch(e){ }
}

function myAccountNav()
{
    try
    {
        if(session_id != 'null')
        {        
            if(isMyAccountCheckEnabled == 'Y' && isPlayerSegmentMatched=='true')

               document.write(' | <a href="'+built_url+'/casino/account/edit_account.thtml">Edit Account</a>');
		  }
    }
    catch(e)
    {
    }
}