
function buyTicket(){
    window.location = "https://www.nhcqualify.com/buy_advanced.aspx?ID=" + readCookie('xyxrst').split("=")[1];
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function forgotpassword(){
    
     var winl = (screen.width - 300) / 2;     
     var wint = (screen.height - 100) / 2;
     
     winprops = 'height=100,width=300,top='+wint+',left='+winl+',resizable=0'     
     window.open("forgotpassword.aspx","Forgot_Password", winprops) 
}

function retrievePassword(){
 var frm = document.forms['password'];   
 var rc = forgotpassword.retrievePassword(frm.txtemail.value);    
 alert( rc.value );
}


function cc2help(){
		var href = "http://www.nhcqualify.com/CCV2.html";
		window.open(href, "Help", 'screenx=400, screeny=200,titlebar=no, location=no, width=175,height=95,scrollbars=no');
}
function registerMember(){
    verifyForm( document.forms['regForm']);    
}

function verifyForm(frm){
    //Agree with terms and conditions
	if ( frm.nhctour.value > 0 ){
		    if ( frm.authorize.checked){
		        //Verify form values
		        var rc = buy_advanced.verifyRegistration(frm.firstname.value,frm.lastname.value,frm.address.value,frm.city.value,frm.state.value,frm.zip.value,frm.email.value,frm.phone.value,frm.password.value, frm.passwordverify.value, frm.ssn.value, frm.nhctour.value);
		        //Display errors if any
		        if( rc.value.indexOf("Error") >= 0 ){            
		            alert( rc.value );
		        }
		        else{
		            //Set the cookie
		            setcookie("xyxrst", rc.value);
		            //Redirect to buy entries
		            window.location = "http://www.nhcqualify.com/buy.aspx";
		        }
		    }
		    else{
		        alert("You need to authorize ID verification.");
		    }
		}
		else{
			alert("You need to supply an NHC Tour ID");
		}
}
function changeItems(box){
  for ( var i = 0; i < box.length; i++ ){
    if ( box[i].selected )        
        window.location = "leaderboard.aspx?&m=" + box[i].value.split("-")[0] + "&lower=0&upper=" + box[i].value.split("-")[0] + "&cid=" + box[i].value.split("-")[1];
  }
    
}

function changeldate(box){
    for ( var i = 0; i < box.length; i++ ){
        if ( box[i].selected )
            window.location = "leaderboard.aspx?cid=" + box[i].value;
    }
}

function changeR2date(box){
    for ( var i = 0; i < box.length; i++ ){
        if ( box[i].selected )
            window.location = "winners.aspx?cid=" + box[i].value;
    }
}

function changerdate(box, ccid){
    for ( var i = 0; i < box.length; i++ ){
        if ( box[i].selected )
            window.location = "myresults.aspx?ticket=1&cid=" + box[i].value + "&ccid=" + ccid;
    }
}
function setcookie(name, value){
        var cookieName = name;      
        document.cookie = cookieName+"="+cookieName+"="+value;
        return true;
}
function selectChange(){
    var total = get('dynamount').innerHTML;
    var totalPurchase = document.forms['purchaseForm'];
    var idx = totalPurchase.numtickets.selectedIndex;
    if ( idx == 0 )
          get('dynamount').innerHTML = "$150";
    else
          get('dynamount').innerHTML = "$300";
    
}


function logmeout(){
    setcookie("xyxrst","clear");
    window.location = "http://www.nhcqualify.com";
}

function gohome(){
    window.location = "http://www.nhcqualify.com";
}

function purchaseEntry(){
    window.location = "http://www.nhcqualify.com/buy.aspx?ID=" + readCookie('xyxrst').split("=")[1];
}


function buyEntry(){
    var frm = document.forms['purchaseForm'];
    if ( frm.bolauthorize.checked ){
	if ( frm.bolNHCTagree.checked ){
		frm.submit();
		return true;
		}
	else{
		alert("You must be an NHC Tour member to participate.");
	}
        }
    else{
        alert("You need to authorize the transaction.");
    }
}

function login_form(){    
    var frm = document.forms['frmLoginPanel'];
    var email = frm.bolaccessid.value;
    var password = frm.bolpassword.value;
    var rc = _default.login(email, password); 
      
    if ( rc.value.indexOf("clear") >= 0 ){
        alert("Invalid login information.");
     
    }
    else{
        setcookie("xyxrst", rc.value);
        window.location = "http://www.nhcqualify.com/";
    }
}

	function get(eN)
	{
		  if(document.getElementById)
		    return document.getElementById(eN);
		  else if(document.all)
			    return document.all[eN];
		       else
			    return null;
	}
	
	function sendPick(){
	    var frm = document.forms['picks'];
	    var ticket1 = "";
	    var ticket2 = "";
	    var item1 = "";
	    var item2 = "";
	    
	       try{
	        for( var i = 0; i < frm.chk1.length; i++ )
	        {
	            if ( frm.chk1[i].checked ){
	                ticket1 = frm.chk1[i].value + "-" + readCookie('xyxrst').split("=")[1] + "-1"  ;
	                item1 = frm.chk1[i].value;
	            }
	        }
	        
	        for (var i = 0; i < frm.chk2.length; i++){
	           if ( frm.chk2[i].checked){
	                ticket2 = frm.chk2[i].value + "-" + readCookie('xyxrst').split("=")[1] +  "-2";
	                item2 = frm.chk1[i].value;
	            }
	        }
	        }
	        catch(e){
	        
	        
	        }
	        
	        var rc1 =""; 
	        var rc2 ="";
	        	        
	        if ( ticket1 != "" ){
	            rc1 = view.submitPick(ticket1);     
	        }
	        
	        if ( ticket2 != "" ){
	            rc2 = view.submitPick(ticket2);
	        }	        
	        window.location = "http://www.nhcqualify.com/view.aspx?rc1=" + rc1.value + "&rc2=" + rc2.value + "&E1=" + item1 + "&E2=" + item2;
	        
	    //alert( frm.chk1.selected );
	}
	

