$(document).ready(function(){$("#summary-container").show();function d(){var h=$("#amount_of_citation").val();var g=parseInt(h);return h!=""&&!isNaN(g)&&g>0}function e(){if($("#faxRadio").is(":checked")){$("#uploadOption").hide();$("#emailOption").hide();$("#faxOption").show()}if($("#uploadRadio").is(":checked")){$("#faxOption").hide();$("#emailOption").hide();$("#uploadOption").show()}if($("#emailRadio").is(":checked")){$("#uploadOption").hide();$("#faxOption").hide();$("#emailOption").show()}if($("#noneRadio").is(":checked")){$("#uploadOption").hide();$("#faxOption").hide();$("#emailOption").hide()}}e();$("#uploadRadio").click(e);$("#faxRadio").click(e);$("#noneRadio").click(e);$("#emailRadio").click(e);function b(){var j=$("#amount_of_words").val();if(j.length>0){j=j.replace(",","")}var h=$("#amount_by_words").is(":checked");var i=$("#amount_by_pages").is(":checked");if(j==""||(!h&&!i)){return -1}var g=parseInt(j);if(isNaN(g)){return -1}if(i){return g}if(h){return Math.ceil(g/WCPP_CUSTOM_ORDER)}}function a(){var h=0;var o=$("input[name=plan_id]:checked");var l=0;var n=0;var j="";var t="";var p=new Array();if(o.length>0){l=o.val();n=o.attr("cost");j=$("#plan-time-"+l).text();t=o.attr("days")}if(j==""){$("#summary-rate").html("Not specified");$("#summary-time").html("Not specified")}else{$("#summary-rate").html("$"+n+" ("+t+")");$("#summary-time").html(j)}var i=b();var g="Not specified";if(i!=-1){if(i<MIN_NUM_PAGES_CUSTOM_ORDER){g="Warning: less "+MIN_NUM_PAGES_CUSTOM_ORDER+" pages"}else{g=i+" Page(s)"}}$("#summary-pages").html(g);var k=0;var m=false;if(d()&&$("#copies_yes").is(":checked")){m=true;var s=$("#amount_of_citation").val();var r=parseInt(s);if(!isNaN(r)){k=r*3.95}$("#summary-citations-container").show()}else{$("#summary-citations-container").hide()}$("#summary-citations").html(k==0?"Unavailable":"$"+k.toFixed(2));var q=0;g="";if(j!=""&&i>=MIN_NUM_PAGES_CUSTOM_ORDER){q=i*n+k;$("#total_cost_store").val(q.toFixed(2));g="$"+q.toFixed(2)}else{g="Unavailable"}if(m&&k==0){$("#total-help-container").show()}else{$("#total-help-container").hide()}$("#summary-total").html(g)}function f(g){var m=$("#amount_of_words").val();m=m.replace(",","");var k=$("#amount_by_words").is(":checked");var p=$("#amount_by_pages").is(":checked");var j="Enter the number of pages or words";var l=0;var i=0;var h="";if(m!=""){var n=parseInt(m);if(isNaN(n)){h="Please enter a number of pages or words."}else{if(!k&&!p){h="Please choose  would you like pages or words?"}}}if(h==""&&m!=""){var o=words2=parseInt(m);if(p){words2=o*WCPP_CUSTOM_ORDER;i=o;l=words2}if(k){words2=Math.ceil(o/WCPP_CUSTOM_ORDER);i=words2;l=o}h="";if(p&&o>100){h="Whoa! Did you mean <strong>"+o+" pages</strong> or did you mean <strong>"+o+" words</strong>? If you meant <strong>"+o+"</strong> pages, don't change anything. If you meant <strong>"+o+"</strong> words, please select &laquo;Words&raquo; instead of &laquo;Pages&raquo;."}if(p&&o<MIN_NUM_PAGES_CUSTOM_ORDER){h="Please enter a minimum of "+MIN_NUM_PAGES_CUSTOM_ORDER+" pages.  Each page has approximately "+WCPP_CUSTOM_ORDER+" words."}if(k&&o<WCPP_CUSTOM_ORDER*MIN_NUM_PAGES_CUSTOM_ORDER){h="Please enter a minimum of "+(WCPP_CUSTOM_ORDER*MIN_NUM_PAGES_CUSTOM_ORDER)+" words ("+MIN_NUM_PAGES_CUSTOM_ORDER+" pages). Each page has approximately "+WCPP_CUSTOM_ORDER+" words."}$("#amount_pages_description").html(i+" Pages ~ "+l+" Words")}else{$("#summary-pages").html("0 Pages ~ 0 Words")}if(h!=""){$("#amount_pages_help span").html(h);$("#amount_pages_help").show()}else{$("#amount_pages_help").hide();$("#amount_pages_help span").html(j)}a()}function c(g){if(d()){$("#citation-style-container").show();$("#citation-copies-container").show()}else{$("#citation-style-container").hide();$("#citation-copies-container").hide()}a()}if($.browser.msie){$("#copies_yes").click(a);$("#copies_no").click(a);$("#amount_by_words").click(f);$("#amount_by_pages").click(f);$("input[name=plan_id]").click(a)}else{$("#copies_yes").change(a);$("#copies_no").change(a);$("#amount_by_words").change(f);$("#amount_by_pages").change(f);$("input[name=plan_id]").change(a)}$("#amount_of_words").keyup(f);$("#amount_of_citation").keyup(c);$("#amount_of_words").keyup(a);c();$("#amount_of_citation").keyup();$("#amount_of_words").keyup();$("#add-material-none-label").click(function(){$("#noneRadio").attr("checked","checked");e()});$("#add-material-upload-label").click(function(){$("#uploadRadio").attr("checked","checked");e()});$("#add-material-fax-label").click(function(){$("#faxRadio").attr("checked","checked");e()});$("#add-material-email-label").click(function(){$("#emailRadio").attr("checked","checked");e()});$("#proceed-button").click(function(){var g=new Array();if($("#description").val().length==0){g.push("Please enter an essay description.")}if($("#amount_of_words").val().length==0){g.push("Please specify the number of pages or words for your order.")}if($("#amount_of_citation").val().length==0){g.push("Please enter the number of sources you would like us to cite. If it's zero, please enter '0'. If you enter '0' than no sources will be used in your paper and you will not get a bibliography page.")}if(d()&&$("#amount_of_citation").val()!=""){if($("#citation_style").val()==""){g.push("Please select the citation style from list.")}}if($("input[name=plan_id]:checked").length==0){g.push("Please specify when you would like the essay delivered.")}if(g.length!=0){alert(g.join("\n"));return false}return true})});
