var thisURL=window.location.href;var error_messages=new Array;var system_messages=new Array;var propertyId=1;$.fn.validatePin=function(card_number,pin_number,propery_id,form){$("#verify_progressbar").html("<img src=\""+loadingGif.src+"\">").css('height','12px').show();card_number.attr('disabled',true);pin_number.attr('disabled',true);$("#pin_verify").attr('disabled',true);var property_id=propery_id.val().replace(/[^0-9]/g,'');$.ajax({type:'POST',url:ajax_url+'Ajax/Validate/',data:'property_id='+property_id+'&card_number='+card_number.val()+'&pin_number='+pin_number.val(),dataType:'json',success:function(response){if(response){if(response.responseCode==10){window.location.href='/profile-register/';}else{showError(response.message);$("#verify_progressbar").html('').hide();$("#button_create-account").show();}}else{showError("The server couldn't process this request.");$("#verify_progressbar").html('').hide();$("#button_create-account").show();}}});card_number.removeAttr('disabled');pin_number.removeAttr('disabled');$("#pin_verify").removeAttr('disabled');};$.fn.addNewCard=function(card_number,pin_number,property_id){$("#add_new_card_submit").hide();$("#add_new_card_progress").html("<img src=\""+loadingGif.src+"\"><br>Please wait while we verify your pin.");$.ajax({type:'POST',url:ajax_url+'Ajax/Validate/',data:'property_id='+property_id+'&card_number='+card_number+'&pin_number='+pin_number,dataType:'json',success:function(response){if(response){if(response.responseCode==10){$("#add_new_card_progress").html(response.message);$.ajax({type:'POST',url:ajax_url+'Ajax/AddNewCard/',data:'property_id='+property_id+'&card_number='+card_number+'&pin_number='+pin_number,dataType:'json',success:function(response2){if(response2.responseCode==10){$("#ModalAddCardForm").html("You have successfully added a new card.<br><br><a href=\"/myprofile/\" class=\"close_modal_reload\">Close</a>");}else{showError(response2.message);$("#add_new_card_submit").show();$("#add_new_card_progress").html('');}}});}else{showError(response.message);$("#add_new_card_submit").show();$("#add_new_card_progress").html('');}}else{showError("The server couldn't process this request.");$("#add_new_card_submit").show();$("#add_new_card_progress").html('');}}});$("#pin_verify").removeAttr('disabled');};$.fn.signup=function(form,url){if($('#register_terms:checked').length==0){showError("You must agree to the Terms and Conditions");$('.Terms').addClass('errorInput');return false;}
$("#profile_submit").hide();$("#profile_submitted").html("<img src=\""+loadingGif.src+"\"><br>Please wait...");var login_email=$("#signup_login_email").val();var email=$("#signup_email").val();var password=$("#signup_password").val();var phone=$("#signup_phone").val();var card_number=$("#patron_cardnumber").val();var property_id=$("#patron_property_id").val();var update_account_email=$("#update_account_email").val();var preferences=new Array;var preference_args='';$(".signup_preference").each(function(){if($(this).attr('checked'))preferences.push('preference[]='+$(this).val());});if(preferences.length)preference_args=preferences.join('&');$.ajax({type:'POST',url:ajax_url+'Ajax/Register/',data:'email='+login_email+'&password='+password+'&phone='+phone+'&property_id='+property_id+'&card_number='+card_number+'&'+preference_args+'&update_account_email='+update_account_email,dataType:'json',success:function(response){if(response.responseCode==10)
{$.ajax({type:'GET',url:'/home/Modal_RegisterVerify?height=280&width=354&modal=true',success:function(modal){showSystemMessage(modal);}});$("#profile_submitted").html('').hide();}else{showError(response.message);$("#profile_submit").show();$("#profile_submitted").html('');}}});};$.fn.editprofile=function(form,url){$("#profile_submit").hide();$("#profile_submitted").html("<img src=\""+loadingGif.src+"\"><br>Please wait...");var login_email=$("#signup_login_email").val();var email=$("#signup_email").val();var password=$("#signup_password").val();var phone=$("#signup_phone").val();var card_number=$("#patron_cardnumber").val();var property_id=$("#patron_property_id").val();var editfields=new Array;var preferences=new Array;var preference_args='';$(".edit_profile_field").each(function(){var key=$(this).attr('id').substr(5);var value=$(this).val();editfields.push(key+'='+escape(value));});$(".signup_preference").each(function(){if($(this).attr('checked'))preferences.push('preference[]='+$(this).val());});if(preferences.length)preference_args=preferences.join('&');$.ajax({type:'POST',url:ajax_url+'Ajax/EditProfile/',data:'email='+email+'&login_email='+login_email+'&password='+password+'&phone='+phone+'&property_id='+property_id+'&card_number='+card_number+'&'+preference_args+'&'+editfields.join('&'),dataType:'json',success:function(response){if(response.responseCode==10){$("#profile_submitted").html('').hide();showSystemMessage("Your profile updates have been sent to Pinnacle Entertainment for review.<br>Please allow up to 72 hours for changes to be completed.");$(".systemmsgclose").attr('href','/myprofile/');}else{showError(response.message);$("#profile_submit").show();$("#profile_submitted").html('');}}});};$.fn.patron_login=function(email,password,suffix){if(!suffix)var suffix='';$.getJSON(api_url,'email='+email+'&password='+password,function(response){if(response.responseCode=='SUCCESS'){$.getJSON(ajax_url+"Ajax/Authenticate/",'hash='+response.result.hash,function(response2){if(response2.message){$("#redirect_url").val(response2.result);$("#redirect_name").val($("#select_property").text());if($("#remember_me"+suffix).attr('checked')==true){$.cookie('email_address',email,{expires:90,path:'/'});}else{$.cookie('email_address',false,{expires:-100,path:'/'});}
$("#login_loading"+suffix).css('display','none');$("#member_login"+suffix).css('display','none');$("#login_loading_message"+suffix).show().html('<p class="title">Successfully logged in!<br />Loading your profile...</p>');window.location.href="/myprofile/";}else{showError('<p class="title">There was a problem verifying your login credentials. Please check the following:</p>Did you enter your login email address properly?<br />Did you enter your password properly?');$("#login_loading"+suffix).hide().html('');$("#member_login"+suffix).show();}});}else{showError(response.message);$("#login_loading"+suffix).hide().html('');$("#member_login"+suffix).show();$('#member_login_popup').show();}});};$.fn.patron_login_enquiry=function(){$.getJSON(api_url+"/authenticate/Logged/?propertyId="+propertyId+"&callback=?",'',function(response){if(response.hash){$.getJSON(ajax_url+"Ajax/Authenticate/",'hash='+response.hash+'&property_id='+propertyId,function(response2){if(response2.message){showSystemMessage("Please wait while we log you in...");window.location.href=window.location.href;}else{showError('We could not log you in. Please try again.');}});}else{}});};function loginFormSubmit(suffix){if(!suffix)var suffix='';var errors=[];validate=$("#login_userid"+suffix).validate_input_data();if(validate.value===false){errors.push(validate.message);}else{var email=validate.value;}
validate=$("#login_password"+suffix).validate_input_data();if(validate.value===false){errors.push(validate.message);}else{var password=validate.value;}
if(errors.length>0){showError('<b>The following errors occured:</b><br>'+errors.join('<br>'));return false;}else{$("#member_login"+suffix).css('visibility','hidden');$("#login_loading"+suffix).show().html('<img src="'+loadingGif.src+'"');}
$.fn.patron_login(email,password,suffix);return false;}
function signUpFormSubmit(){$(".mandatory").removeClass('error_input');var card_number=$("#card_number2");var pin_number=$("#pin_number");var property_id=$("#card_number1");var errors=[];validate=$("#card_number2").validate_input_data();if(validate.value===false){errors.push(validate.message);}else{var card_number=$("#card_number2");}
validate=$("#card_number1").validate_input_data();if(validate.value===false){errors.push(validate.message);}else{var property_id=$("#card_number1");}
validate=$("#pin_number").validate_input_data();if(validate.value===false){errors.push(validate.message);}else{var pin_number=$("#pin_number");}
if(errors.length>0){$("#errormsg_body").html(errors.join('<br>'));$(".errormsg").center().show();showError('<b>The following errors occured:</b><br>'+errors.join('<br>'));return false;}
$("#button_create-account").hide();$.fn.validatePin(card_number,pin_number,property_id,document.getElementById("signUpForm"));return false;}
function memberSignupForm(){$.fn.signup(document.getElementById("signUpForm"),'$URLSegment/Modal_Preferences?height=600&width=500&modal=true');return false;}
