     
function checkForRedirect()
{
	var message = "Hello";
	/* alert(message); */
}

function member_login()
{
	var user = document.memberLogin.myusername.value;
	var pass = document.memberLogin.mypassword.value;
	var site = document.memberLogin.csite.value;
	var passedstuff = user + ":" + pass + ":" + site;
	/* alert(passedstuff); */
	var url = "/pcart/LoginCheck.php";
	request.open("POST", url, true);
	request.onreadystatechange = LoginResults;
	request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	request.send("logincheck=" + escape(passedstuff));	
}

function LoginResults()
{
  if (request.readyState == 4) {
    if (request.status == 200) {
      
      /* Get the response from the server */
      var results = request.responseText;
	  	
	  	/* Get the row where the member info cell is and add member info*/
	  	var x=document.getElementById('memberInfoTable').rows[1].cells;
	  	x[0].innerHTML = results;

      /* alert(x[0].innerHTML); */
      
			/* look up any currently registered players */
			
			if (results != "Login Failure. Check your password and try again. If you did not reach the login page through the SSAA website, go there first to enter your Login ID and then things should work properly.") {	
			
				var xx = document.getElementById('memberInfoTable').rows[2].cells;
		  	xx[0].innerHTML = "";
			
				getCurrentPlayers(document.memberLogin.myusername.value);
				
      	var y=document.getElementById('accountLogin');
			  y.style.display = "none";
			  var z=document.getElementById('memberMain');
      	z.style.display = "block";
      	
      } else {
       
	      var y=document.getElementById('accountLogin');
	      y.style.display = "block";
        var z=document.getElementById('memberMain');
	      z.style.display = "block";
	      
				var xx = document.getElementById('memberInfoTable').rows[2].cells;
		  	xx[0].innerHTML = "Current Players -<hr />";
		  	var zz = document.memberLogin.myusername.value;
	      Set_Cookie( 'ssaareg', 'valid', '', '/', '', '' );
			}      
      
    } else {
      alert("Error! Request status is " + request.status);
	}
  }
}

function toggle_login_visibility(id, ppid) 
{
	var e = document.getElementById(id);
	var f = document.getElementById(ppid);
	e.style.display = 'block';
	f.style.display = 'none';
}

function make_visible(id) 
{
	var e = document.getElementById(id);
	e.style.display = 'block';
}

function hideAddPlayer() 
{
	var e = document.getElementById('addPlayer');
	e.style.display = 'none';
}


function exposeAddPlayer()
{
	var e=document.getElementById('addPlayer');
	e.style.display='block';
}


function getCurrentPlayers(parents)
{
	/* alert("This is what was passed by the LoginResults " + parents); */
	var url = "/pcart/playerLookup.php";
	request.open("POST", url, true);
	request.onreadystatechange = playerLookupResults;
	request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	request.send("playerlookup=" + escape(parents));	
}


function playerLookupResults()
{
  if (request.readyState == 4) {
    if (request.status == 200) {
      
      /* Get the response from the server */
      var results = request.responseText;
  	
	  	/* Get the row where the member info cell is and add member info*/
	  	var x=document.getElementById('memberInfoTable').rows[3].cells;
	  	x[0].innerHTML = results;

      var y=document.getElementById('accountLogin');
      y.style.display = "none";
      
      var z=document.getElementById('memberMain');
      z.style.display = "block";
      
    } else {
      alert("Error! Request status is " + request.status);
		}
  }
}

function checkout()
{
	var answer = confirm("You have chosen to pay for your current players in the amount shown. If you need to add another player, or are not ready to checkout, please click CANCEL. If you are ready to checkout, click OK and you will be forwarded to the Paypal Checkout page. Thank You!");
	
	if (answer==true)
	{
		var message = document.memberLogin.myusername.value;
		/* alert(message); */
		var url = "/pcart/txTried.php";
		request.open("POST", url, true);
		request.onreadystatechange = txTriedResults;
		request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		request.send("parent=" + escape(message));  
  }
	else
  {
	  alert("You chose to cancel for now. Please be sure to checkout later. Thank You!");
	  return false;
  }
}


function txTriedResults()
{
  if (request.readyState == 4) {
    if (request.status == 200) {
      
      /* Get the response from the server */
      var results = request.responseText;
  	
	  	/* Get the row after the paypal button*/
	  	var x=document.getElementById('memberInfoTable').rows[4].cells;
	  	x[0].innerHTML = results;    
    } else {
      alert("Error! Request status is " + request.status);
	}
  }
}


function duplicateCheck()
{
	var Afn = document.newRegistration.parentA_first.value;
	var Aln = document.newRegistration.parentA_last.value;
	var Bfn = document.newRegistration.parentB_first.value;
	var Bln = document.newRegistration.parentB_last.value;
	var Afullname = Afn + ":" + Aln;
	var Bfullname = Bfn + ":" + Bln;
	var message = Afullname + " " + Bfullname;
	alert(message);
}

function duplicateCheck2()
{
	var Afn = document.newRegistration.parentA_first.value;
	var Aln = document.newRegistration.parentA_last.value;
	var Bfn = document.newRegistration.parentB_first.value;
	var Bln = document.newRegistration.parentB_last.value;
	var Afullname = Afn + ":" + Aln;
	var Bfullname = Bfn + ":" + Bln;
	var url = "/pcart/duplicateMemberCheck.php";
	request.open("POST", url, true);
	request.onreadystatechange = dupCheckResults;
	request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	request.send("membercheck=" + escape(Afullname) + ":|:" + escape(Bfullname));
}



function debugPaynow() 
{
	var x=document.getElementById('memberInfoTable').rows[3].cells;	
	message = x[0].innerHTML;   
	alert(message);
}

var newwindow;

function popsizing(url)
{
	newwindow=window.open(url,'SizingChart','height=300,width=500,resizable=yes');
	if (window.focus) {newwindow.focus()}
}

function send_pass() 
{
	var user = document.memberLogin.myusername.value;
	var url = "/pcart/sendPass.php";
	request.open("POST", url, true);
	request.onreadystatechange = sendPassResults;
	request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	request.send("user=" + escape(user));	
}
function sendPassResults()
{
  if (request.readyState == 4) {
    if (request.status == 200) {
      
      /* Get the response from the server */
      var results = request.responseText;
  		message = "Your password has been sent to " + results + ".";
			alert(message);
    } else {
      alert("Error! Request status is " + request.status);
		}
  }
}

function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}	

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

