function log_err(a,b,c){var d=a.callee.toString().match(/function (.+?)\(/);jQuery.post('/ajax/error_logger.php',{err_name:b.name,err_msg:b.message,err_loc:document.URL,err_scpt:c,err_fn:d?jQuery.trim(d[1]):'UNKNOWN'})}function handle_focus(a){var b=jQuery.trim($(this).val());if(b==a.data.dfval||b.length==0){$(this).val('');$(this).css('color','red')}return false}function handle_blur(a){var b=jQuery.trim($(this).val());if(b==a.data.dfval||b.length==0){$(this).val(a.data.dfval);$(this).css('color','gray')}return false}function kill_keys(a){if(48<=a.which&&a.which<=57){return true}else if(96<=a.which&&a.which<=105){return true}else if(jQuery.inArray(a.which,[8,9,16,20,27,37,38,39,40,45,46,144])!==-1){return true}else{a.preventDefault()}return false}function update_total(a){$(this).change();return true}function handle_numeric_blur(a){var b=jQuery.trim($(this).val());if(b==a.data.dfval||b.length==0){$(this).val(a.data.dfval);$(this).css('color','gray')}else{var c=parseInt(b,10);if(isNaN(c)||c<1){alert('Please enter a positive whole number for this field');$(this).css('color','red');$(this).val('')}else{$(this).val(c);$(this).css('color','black');return true}}return false}function handle_keypress(a){var b=jQuery.trim($(this).val());if(a.keyCode==13){if(b==a.data.dfval||b.length==0){return false}}return true}function handle_plant_order_form(a){var b,amnt,ok,num_ok,cb_ok,num_str;amnt=parseInt($('#amount').val(),10);num_ok=false;cb_ok=false;ok=false;if(!isNaN(amnt)&&amnt>0){num_ok=true}cb_ok=$(a.data.me).find('input:radio:checked').length==1;ok=num_ok&&cb_ok;if(!ok){$('#error_messages').empty();if(!num_ok){$('#error_messages').append('<p>Please enter a positive whole number in the quantity field.</p>')}if(!cb_ok){$('#error_messages').append('<p>Please select a size for your order.</p>')}}return ok}function handle_radio(a){var b=$(this).attr('id');var c=b.split('id');var d=$('#price_rate').val();var e,price;if(c[0]=='p'){$("input:radio[name='seedPrice']").attr('checked','');e=$(d).val().split(';');price='Price: $'+parseFloat(e[c[1]]).toFixed(2)+' ('+(d=='#priceW'?'wholesale':'retail')+')'}else if(c[0]=='s'){$("input:radio[name='priceID']").attr('checked','');price='Price: $'+parseFloat($('#'+b).val()).toFixed(2)}else{throw new Exception('Invalid id passed: '+b);}$('#price_str').text(price);$('#potsize').val($('#'+b).parent().text())}function handle_comment(c){var d=$('#odf5').find('.error_messages');$(d).empty();var e=jQuery.trim($('#user_comment').val());var f=$(this).val()==='Add';if(e.length==0&&f){$(d).text('Please enter your comment in the text field above.')}else{if(f){$('#submit_comment').val('Sending...');pdata={insert_comment:1,comment_text:$('#user_comment').serialize()}}else{$('#delete_comment').val('Deleting...');pdata={insert_comment:2}}$('#delete_comment, #submit_comment').attr('disabled','disabled');$('#user_comment').attr('readonly','readonly');$.post('/ajax/orders.php',pdata,function(a,b){if(b=='success'&&a.ok==1){$('#submit_comment').removeAttr('disabled');$('#submit_comment').attr('enabled','enabled');$('#submit_comment').val('Add');$('#delete_comment').val('Delete');$('#user_comment').removeAttr('readonly');if(f){$('#delete_comment').removeAttr('disabled');$('#delete_comment').attr('enabled','enabled')}else{$('#user_comment').val('')}}else{$(d).html('<b>A mistake has occured:</b><br />'+a.err)}},"json")}return false}function tabfade(a,b){try{$('.disp_form:visible').hide();$(a).fadeIn('fast');$(".disp_ths").addClass('disp_th');$(".disp_ths").removeClass('disp_ths');$(b).removeClass('disp_th');$(b).addClass('disp_ths')}catch(e){log_err(arguments,e,'searches.js')}}function ensureSelection(a,b){var c,cbs,err_msgs;err_msgs=$(a).find('.error_messages');$(err_msgs).empty();cbs=$(a).find('input.cb:checkbox:checked');c=cbs.length;if(c>0){var d='Are you sure you want to remove ';d+=(c>1)?'these '+c+' items?':'this item?';if(confirm(d)){$(b).val(1);return true}else{return false}}else{$(err_msgs).text('Please make a selection from the checkboxes to indicate which items you would like to remove.')}return false}$(document).ready(function(){var i={me:'#search_input',dfval:'Search'};var j=window.location.pathname;$('#search_input').bind('focus',i,handle_focus);$('#search_input').bind('blur',i,handle_blur);$('#search_input').bind('keypress',i,handle_keypress);$('#page_header').click(function(){document.location.href='/index.php'});$('.boxtop').click(function(){var a=$(this).next();$(a).is(':visible')?$(a).slideUp('fast'):$(a).slideDown('fast')});$('.pl').click(function(){var a='#'+$(this).attr('id').substring(1);$(a).is(':visible')?$(a).slideUp('fast'):$(a).slideDown('fast')});$('#current').click(function(){window.location.href='/misc/orders.php'});$('#help, #info').click(function(){if($('#helptxt').is(':hidden')){var p=$('#the_stuff').position();$('#helptxt').css({top:'0px',left:'50px'});$('#helptxt').fadeIn('fast')}else{$('#helptxt').fadeOut('fast')}});$('#helptxt').click(function(){$(this).hide()});if(j==='/plants/plant.php'){$(".btnbrd").live('click',function(){this.form.submit()});var k={me:'#amount',dfval:'Quantity'};$('#amount').bind('focus',k,handle_focus);$('#amount').bind('blur',k,handle_numeric_blur);$('#amount').bind('keypress',k,handle_keypress);$("input:radio[name='priceID'],input:radio[name='seedPrice']").bind('click',handle_radio);$('#plant_order_form').bind('submit',{me:'#plant_order_form'},handle_plant_order_form)}else if(j==='/plants/plants.php'){$('.disp_th').live('click',function(){var a=$(this).attr('id').substring(3);tabfade('#pdf'+a,'#pdt'+a)});$(".btnbrd").click(function(){this.form.submit()})}else if(j==='/misc/orders.php'){$('.disp_th').live('click',function(){$('.error_messages').empty();var a=$(this).attr('id').substring(3);tabfade('#odf'+a,'#odt'+a)});$('.iptm').live('click',function(){var a=$(this).is(':checked')?'checked':'';var b=$(this.form).find('input.cb:checkbox').attr('checked',a)});$('#odf1').bind('submit',function(){return ensureSelection('#odf1','#remove_plantsID')});$('#odf2').bind('submit',function(){return ensureSelection('#odf2','#remove_seedsID')});$('#odf3').bind('submit',function(){return ensureSelection('#odf3','#remove_giftsID')});$('#odf7').bind('submit',function(){return confirm('Are you sure you want to delete this session?')});$('#odf6').bind('submit',function(){if($('input:checkbox.cb').length==0){alert('You have no items in your order at the moment!')}else{$('#order_tabs,.order_div').hide();$('#confirm_div').fadeIn('fast')}return false});$('#paypal_submit_btn').click(function(){try{var c,h,m,d=new Date();m=d.getTime();h=m.toString(16).toUpperCase();c=$('#ppsbmt').find("input:hidden[name='invoice']");$(c).val(h);$('#paypal_submit_btn').attr('disabled','disabled');$('#gb2').unbind();$('#gb2').css({color:'gray',cursor:'default'});$('#gb2').html('Processing&hellip;');$('#feedback').html('Please wait a few moments while we transfer you to the Paypal website to complete this transaction&hellip; Please <b>don&rsquo;t</b> click the &lsquo;Back&rsquo; button in your browser while this is taking place.');var f=$('#confirm_div').find('input:radio:checked').val();var g='';if(f=='replace'){g=jQuery.trim($('#tarepl').val())}jQuery.post('/ajax/paypal.php',{cart_upload:1,rmode:f,rtext:g,ivn:h},function(a,b){if(b=='success'&&a.ok){try{$('#ppsbmt').submit()}catch(e){log_err(arguments,e,'searches.js')}}else{$('#feedback').text('Unfortunately an error has occured while trying to process your transaction. '+'You may wish to try again in case the problem is temporary? '+'An error will be logged and we will try to fix the problem as soon as possible.');e=new Error('Paypal submission returned with text status: '+b+' and data.ok: '+a.ok);log_err(arguments,e,'searches.js')}},'json')}catch(e){log_err(arguments,e,'searches.js')}});$("input:radio[name='custom']").click(function(a){if($(this).attr('id')=='iptr'){$('#tarepl').val($('#repl_txt').val());$('#tarepl').removeAttr('disabled');$('#tarepl').focus()}else if($('#tarepl').val().length){$('#repl_txt').val($('#tarepl').val());$('#tarepl').val('');$('#tarepl').attr('disabled','disabled')}});$('#refund_mode').bind('submit',function(){return false});$('#proceed').click(function(){try{var a=$('#confirm_div').find('input:radio:checked').val();if(a!=undefined){$('#paypal_form').find("input:hidden[name='custom']").val(a);$('#confirm_div').hide();$('#paypal_form').fadeIn('fast')}else{$('#js_errs').text('Please make a selection from the options above to let us know how you want to handle this situation?')}}catch(e){log_err(arguments,e,'searches.js')}});$('#gb1').click(function(){$('#confirm_div').hide();$('#order_tabs,.order_div').fadeIn('fast');$('#js_errs').empty()});$('#gb2').click(function(){$('#js_errs').empty();$('#paypal_form').hide();$('#confirm_div').fadeIn('fast')});$('#submit_comment').bind('click',handle_comment);$('#delete_comment').bind('click',handle_comment);if($('#user_comment').val().length>0){$('#delete_comment').removeAttr('disabled')}$('.disp_form:first').show();if(!$('#odf1').length){$('#tarepl, #iptr_txt').hide()}}else if(j==='/misc/thanks.php'){$('.disp_form:first').show();if($('#user_comment').text().length){$('#comment_container').show()}if($('#pcell').text().length>0){$('#prow').show()}if($('#scell').text().length>0){$('#srow').show()}if($('#gcell').text().length>0){$('#grow').show()}$('.disp_th').live('click',function(){var a=$(this).attr('id').substring(3);tabfade('#odf'+a,'#odt'+a)})}else if(j==='/misc/person_data.php'){$('#enable_business').bind('click',function(){var a=$(this).is(':checked')?'':'disabled';$('#business').attr('disabled',a);$('#abn').attr('disabled',a)});$('#state').change(function(){$('#cust_errs').empty();if($(this).val()!=='Tasmania'){$('#cust_errs').html('We only ship plants in 2 inch and 140mm pot sizes to addresses outside of Tasmania at the moment.<br />'+'If you have previously selected some plants in other sizes they will be automatically removed from your order.')}});$('#customer_form').bind('submit',function(){return validate_customer(this)})}else if(j==='/food/foods.php'){$('#bubble').data('the_foods',new TWFoodOrder());$('.gfcbx').click(cb_click);$('.gfcbx').mouseover(cb_mouseover);$('.disp_th').click(function(){$('#bubble').hide();var a=$(this).attr('id').substring(3);tabfade('#pdf'+a,'#pdt'+a)});$('#bubble').dblclick(function(){$('#bubble').fadeOut('fast')});$('.disp_form:first').show();$('#food_input').bind('focus',{dfval:'Quantity'},handle_focus);$('#food_input').bind('blur',{dfval:'Quantity'},handle_blur);$('#food_input').change(handle_food);$('#food_input').keydown(kill_keys);$('#food_input').keyup(update_total);$('#confirm').live('click',jQuery.proxy($('#bubble').data('the_foods'),'showConfirmation'));$('#cancelP').live('click',jQuery.proxy($('#bubble').data('the_foods'),'resumeOrder'));$('#food_form').bind('submit',jQuery.proxy($('#bubble').data('the_foods'),'submitOrder'))}else if(j==='/gardens/gardens.php'){if(window.location.search.length==0){$('#leftnav_container').slideUp('slow')}else{$('#leftnav_container').hide()}}else if(j==='/seeds/seeds.php'){$('#bubble').data('the_seeds',new TWSeedOrder());$('#bubble').dblclick(function(a){$(this).fadeOut('fast')});$('input.cb').click(cb_click);$('input.cb').mouseover(cb_mouseover);$('#seed_count').bind('focus',{dfval:'Quantity'},handle_focus);$('#seed_count').bind('blur',{dfval:'Quantity'},handle_blur);$('#seed_count').change(handle_seed);$('#seed_count').keydown(kill_keys);$('#seed_count').keyup(update_total);$('#price_w, #price_h').click(price_click);$('#confirm').live('click',jQuery.proxy($('#bubble').data('the_seeds'),'showConfirmation'));$('#cancelP').live('click',jQuery.proxy($('#bubble').data('the_seeds'),'resumeOrder'));$('#seed_form').bind('submit',jQuery.proxy($('#bubble').data('the_seeds'),'submitOrder'))}});
