//This is for POST LOGIN files. In case you want to see PRE LOGIN files just replace "1234' with "null"
var temp = "no";
function clrForm()
{
	if(temp == 'no' )
	{
		document.loginform.username.value="";
		document.getElementById("pass").innerHTML= '<input class="textbox" name="password" type="password"  onclick="javascript:clrForm()"/>';
	}
	temp = "yes";
}
function commonHeader()
{
	try
	{
		//alert(session_id);
		if(session_id == 'null' || session_id == '')
		{	
			document.write('<div class="blpromo"><div class="brpromo"><div class="tlpromo"><div class="trpromo">');
			document.write('<div id="login">');
			document.write('<div id="loginbt">');
			document.write('<div class="lbluebt"><div class="rbluebt"><a class="bluebt" href="../registration/login.html" onfocus="this.blur();">Login</a></div></div>');
			document.write('</div>');
			document.write('<div id="register">New User? <a class="registerlink" href="../registration/registration_step1.html" onfocus="this.blur();">Register</a></div>');
			document.write('</div>');
			document.write('</div></div></div></div>');
			/*if (location.search.indexOf("confirm=invalid")==-1)
			{
				document.loginform.username.value="username";
				document.loginform.password.value="password";
			}*/
		}
		else
		{
			document.write('<div class="blpromo"><div class="brpromo"><div class="tlpromo"><div class="trpromo">');
			document.write('<div id="login">');
			document.write('<div id="username"><span id="the_usernameright"></span></div>');
			document.write('<div id="logoutbt">');
			document.write('<div class="lbluebt"><div class="rbluebt"><a class="bluebt" href="/pokersys/login/logout.do" onfocus="this.blur();">Logout</a></div></div>');
			document.write('</div>');
			document.write('</div>');
			document.write('</div></div></div></div>');
			document.getElementById("the_usernameright").innerHTML=htmlusername;
		}
	}
	catch(e)
	{
		alert(e);
		//		location.href="../maintenance/maintenance.html";
	}
}

var validuser;
function Validate()
{
	if(document.loginlocal.password.type == 'text')
	{
		alert('Please enter a valid username and password');
		return false;
	}
	var username = document.loginlocal.username.value;
	var password = document.loginlocal.password.value
	if((username==null) || (username==""))
    {  
        alert("Enter the Username");
        document.loginlocal.username.focus();
        return false;
    }
    else if((password==null) || (password==""))
    {
        alert("Enter the Password");
        document.loginlocal.password.focus();
        return false;
    }
    else if(isValidPasswd(password,username)==-1)
    {
        document.loginlocal.password.focus();
        return false;
    }
    else
    {
		var val = isValidPasswd(document.loginlocal.password.value, document.loginlocal.password.value);
		if(val != 0)
			return 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.loginlocal.action = action_url + "/newsys/home/loginAction.do";	
		//document.loginlocal.method="POST";
		return true;
    }
}

function ImageURL()
{	
	if(session_id != 'null')
	{
		//document.location="../../login/BingoLogin.do";
		document.location="../../poker/lobby/index.html"; // by madhava Monday, March 06, 2006
	}
	else
	{
		document.location = "../registration/login.html";
	}
}

function PlayNowURL()
{	
		
		if(session_id != 'null')
		{ 
				if(document.getElementById("dynaplaynow"))
				{
					//location.href="../../login/BingoLogin.do";
					location.href="../../poker/lobby/index.html"; // by madhava Monday, March 06, 2006
						
				}
		}else
		{
				if(document.getElementById("dynaplaynow"))
				location.href="../registration/registration_step1.html";
		}
}
 
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='Yahoo! Poker Online';

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 Validate1()
{
	location.href="../registration/registration_step1.html";
	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 = "/poker/";
		var urlToSend = parentUrl.split(splitString)[0]+splitString
		//alert(urlToSend);
		var img = new Image();
		img.src = "/pokersys/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 = "/newsys/details.jsp?url="+urlToSend;
	}*/
}
catch(e){}


function idVerificationNav()
{
    try
    {
		if(session_id != 'null')
        {      
            if(isDocsUpload!='Y' && isUploadApp=='Y')
                document.write('<li><a class="lftnavbt01" href="../account/uploadbankdetails.html" onfocus="this.blur();">ID Document Upload</a></li>');
		}
    }
    catch(e)
    {
            //do nothing
    }
}