﻿function AddToShoppingCart(event_id,session_id,product_id,product_price_id,qty){_20MileReg.WSL.Register.AddToCart(event_id,session_id,product_id+"$"+product_price_id,qty,"false",GetCart);return false;}function GetCart(){var event_id=$get("_hid_event_id").value;var session_id=$get("_hid_session_id").value;GetSessionCart(event_id,session_id);}function GetSessionCart(event_id,session_id){ShowProcessing("shopping_cart","indicator_small.gif");_20MileReg.WSL.Register.GetSessionCart(event_id,session_id,DisplaySessionCart);}function DisplaySessionCart(results){var shopping_cart=$get("shopping_cart");var output_str="";var total=0;if(results!=""){output_str+="<table cellspacing=0; style='width:275px'>";for(i=0;i<results.length;i++){output_str+="<tr>";output_str+="<td style='width:200px'>"+results[i].Product+"</td>";output_str+="<td class='align_right'>"+formatAsMoney(results[i].ExtendedPrice)+"</td>";if(results[i].IsAutoPackage){output_str+="<td>&nbsp;</td>";}else{output_str+="<td class='align_right'><a  title='Remove "+results[i].Product+" from your shopping cart' class='cart_rem' href='javascript:RemoveFromCart(&#39;"+results[i].SessionId+"&#39;,"+results[i].CartSessionId+",&#39;"+results[i].Product+"&#39;)'>&nbsp;</a></td>";}output_str+="</tr>";total+=results[i].ExtendedPrice;}output_str+="<tr><td colspan='3'>&nbsp;</td></tr>";output_str+="<tr><td class='top_border'><b>Total</b></td><td class='top_border'><b>"+formatAsMoney(total)+"</b></td><td class='top_border'>&nbsp;</td></tr>";output_str+="</table><br /><br />";}else{output_str+="<p>Your shopping cart is empty</p><p>&nbsp;</p>";}shopping_cart.innerHTML=output_str;}function RemoveFromCart(session_id,cart_session_id,product){var sPath=window.location.pathname;var event_id=$get("_hid_event_id").value;var sPage=sPath.substring(sPath.lastIndexOf('/')+1);if(confirm("Are you sure you want to delete "+product+" from your shopping cart?")){if(sPage=="ExhibitorConference.aspx"){_20MileReg.WSL.Register.RemoveFromCart(event_id,session_id,cart_session_id,GetDiscountCart);}else{_20MileReg.WSL.Register.RemoveFromCart(event_id,session_id,cart_session_id,GetCart);}}}function ValidateCart(){var event_id=$get("_hid_event_id").value;var session_id=$get("_hid_session_id").value;_20MileReg.WSL.Register.ValidateShoppingCart(event_id,session_id,NextStepReview);}function NextStepReview(){var event_code=$get("_hid_event_code").value;var event_id=$get("_hid_event_id").value;var session_id=$get("_hid_session_id").value;window.location="/register/commerce/"+event_code+"/"+session_id+"/contact.aspx";}function GetReview(){GetAdminContact();GetShoppingCart();}function GetAdminContact(){var event_id_field=$get("_hid_event_id");event_id=event_id_field.value;var session_id_field=$get("_hid_session_id");session_id=session_id_field.value;_20MileReg.WSL.Register.GetSessionContact(event_id,session_id,DisplayAdminContact);}function GetShoppingCart(){var event_id_field=$get("_hid_event_id");event_id=event_id_field.value;var session_id_field=$get("_hid_session_id");session_id=session_id_field.value;_20MileReg.WSL.Register.GetSessionCart(event_id,session_id,DisplayAdminCart);}function DisplayAdminContact(results){var contact_display=$get("contact_display");var output_str="";if(results.length>0){output_str+="<table class='review_contact' cellspacing='0'>";result_array=results.split("|");for(var j=0;j<(result_array.length-1);j++){option_value=result_array[j].split("~");if(j%2==0){output_str+="<tr class='odd'>";}else{output_str+="<tr class='even'>";}output_str+="<td class='review_label'>"+option_value[0]+"</td><td>"+option_value[1]+"&nbsp;</td></tr>";}output_str+="</table>";}else{output_str+="<p>An error occurred retrieving your contact information from the database</p>";}contact_display.innerHTML=output_str;}function DisplayAdminCart(results){var item_display=$get("item_display");var output_str="";var total_due=0;var sPath=window.location.pathname;var sPage=sPath.substring(sPath.lastIndexOf('/')+1);if(results.length>0){output_str+=BuildSortableTable("admin_item","Item","Quantity","List Price","Extended Price","");for(i=0;i<results.length;i++){output_str+="<tr>";output_str+="<td>"+results[i].Product+"</td>";output_str+="<td>"+results[i].Qty+"</td>";output_str+="<td>"+formatAsMoney(results[i].ProductPrice)+"</td>";output_str+="<td>"+formatAsMoney(results[i].ExtendedPrice)+"</td>";if(sPage=="review.aspx"){if(!results[i].IsAutoPackage){output_str+="<td class='align_right'><a  title='Remove "+results[i].Product+" from your shopping cart' class='cart_rem' href='javascript:RemoveFromAdminCart(&#39;"+results[i].SessionId+"&#39;,"+results[i].CartSessionId+",&#39;"+results[i].Product+"&#39;)'>&nbsp;</a></td>";}else{output_str=="<td>&nbsp</td>";}}else{output_str=="<td>&nbsp</td>";}output_str+="</tr>";total_due=total_due+results[i].ExtendedPrice;}output_str+="<tfoot>";output_str+="<td colspan='3'>Total Due:</td>";output_str+="<td colspan='2'>"+formatAsMoney(total_due)+"</td>";output_str+="</tfoot>";output_str+="</table>";}else{output_str+="<p>There are no items selected.</p>";}item_display.innerHTML=output_str;}function CancelCommerceRegistration(){if(confirm("Are you sure you want to cancel your purchase?")){var event_id=$get("_hid_event_id").value;var session_id=$get("_hid_session_id").value;_20MileReg.WSL.Register.DeleteSession(event_id,session_id,CommerceCancelled);return false;}}function CommerceCancelled(results){var event_code_field=$get("_hid_event_code");event_code=event_code_field.value;window.location="/register/commerce/"+event_code+"/cart.aspx";}function EditContact(){var event_code=$get("_hid_event_code").value;var session_id_field=$get("_hid_session_id").value;window.location="/register/commerce/"+event_code+"/"+session_id+"/edit_contact.aspx";}function ApplyPromoCode(){var event_id=$get("_hid_event_id").value;var session_id=$get("_hid_session_id").value;var promo_code=$get("fld_promo_code").value;var web_form_id=$get("_hid_web_form_id").value;if(promo_code.length>0){_20MileReg.WSL.Register.ApplyPromoCode(event_id,session_id,promo_code,web_form_id,DisplayPromoResult);}else{alert("Please enter a promotional code before attempting to continue.");}}function DisplayPromoResult(results){var promo_display=$get("promo_display");var output_str="";if(results!=""){var contact_id="";contact_id=results.ContactId;if(contact_id>0){output_str+="<h4>Promotional Code Applied</h4>";output_str+="<p>Thank you. The promotional code has been applied.  Your item selections have been updated.</p>";GetShoppingCart();}else{output_str+="<h4>Promotional Code Applied</h4>";output_str+="<p>Thank you. The promotional code has been applied.</p>";promo_display.innerHTML=output_str;promo_display.style.display="block";}}else{output_str+="<h4>An Error Occurred</h4>";output_str+="<p>We're sorry. An error occurred and your promotional code was not applied.</p>";}promo_display.innerHTML=output_str;promo_display.style.display="block";}function ProceedToPayment(obj){var event_code=$get("_hid_event_code").value;var session_id=$get("_hid_session_id").value;window.location="/register/commerce/"+event_code+"/"+session_id+"/1/CheckTotalDue.aspx";}function GetContactAddress(){var event_id=$get("_hid_event_id").value;var contact_id=$get("_hid_contact_id").value;_20MileReg.WSL.Register.GetSessionContactAddress(event_id,contact_id,FillMailing);}function FillMailing(results){if(results.length>0){for(var i=0;i<results.length;i++){$get("txtFirstName").value=results[i].FirstName;$get("txtLastName").value=results[i].LastName;$get("txtAddress").value=results[i].Address1;$get("txtCity").value=results[i].City;$get("txtState").value=results[i].State;$get("txtPostalCode").value=results[i].PostalCode;$get("ddlCountry").value=results[i].CountryCode;$get("txtPhone").value=results[i].Phone;$get("txtEmail").value=results[i].Email;}}else{alert("A connection error occured and we weren\'t able to retrieve your address.  Please enter the information in the required fields.");}}function GetConfirm(){GetConfirmContact();GetConfirmItems();GetConfirmPayments();}function GetConfirmContact(){var event_id=$get("_hid_event_id").value;var session_id=$get("_hid_session_id").value;_20MileReg.WSL.Register.GetConfirmContact(event_id,session_id,DisplayAdminContact);}function GetConfirmItems(){var event_id=$get("_hid_event_id").value;var session_id=$get("_hid_session_id").value;_20MileReg.WSL.Register.GetConfirmItems(event_id,session_id,DisplayAdminCart);}function GetConfirmPayments(){var event_id=$get("_hid_event_id").value;var session_id=$get("_hid_session_id").value;_20MileReg.WSL.Register.GetConfirmPayments(event_id,session_id,DisplayConfirmPayment);}function DisplayConfirmPayment(results){var payment_display=$get("payment_display");var output_str="";var total_due=0;if(results.length>0){output_str+=BuildSortableTable("admin_payment","Payment Type","Account Number","Payment Date","Amount");for(i=0;i<results.length;i++){output_str+="<tr>";output_str+="<td>"+results[i].PaymentType+"</td>";output_str+="<td>"+results[i].AccountNumber+"</td>";output_str+="<td>"+results[i].PaymentDt+"</td>";output_str+="<td>"+formatAsMoney(results[i].TransactionAmount)+"</td>";output_str+="</tr>";}output_str+="</table>";}else{output_str+="<p>There have been no payments applied to this order.</p>";}payment_display.innerHTML=output_str;}function RemoveFromAdminCart(session_id,cart_session_id,product){var sPath=window.location.pathname;var event_id=$get("_hid_event_id").value;var sPage=sPath.substring(sPath.lastIndexOf('/')+1);_20MileReg.WSL.Register.RemoveFromCart(event_id,session_id,cart_session_id,GetShoppingCart);}
