var currentImageCounter=0;var timer;var won_bid;function showMain(a,b){var c=$("#LotImage"+currentImageCounter);if(c!=null){c.parent("a").removeClass("act")}currentImageCounter=a;if(currentImageCounter<0){currentImageCounter=imageList.length-1}else{if(currentImageCounter>imageList.length-1){currentImageCounter=0}}if(b){$("#LargeImage").attr("src",imageList[currentImageCounter])}$("#LotImage"+currentImageCounter).parent("a").addClass("act")}function changeImage(b,c){imageListCurrent=parseInt(currentImageCounter);imageListCurrent+=b;if(imageListCurrent<0){imageListCurrent=imageList.length-1}else{if(imageListCurrent==imageList.length){imageListCurrent=0}}var a=MagicMagnify.getFlashMovieObject("mObj"+c);if(a&&a.changeImage){a.changeImage(imageList[imageListCurrent],imageList[imageListCurrent],parseInt(a.parentNode.style.width),parseInt(a.parentNode.style.height));var d=$("#LotImage"+currentImageCounter);if(d!=null){d.parent("a").removeClass("act")}currentImageCounter=imageListCurrent;$("#LotImage"+currentImageCounter).parent("a").addClass("act")}return false}function changeImage0(b,c){currentImageCounter+=b;if(currentImageCounter==0){currentImageCounter=imageList.length-1}else{if(currentImageCounter==imageList.length){currentImageCounter=0}}var a=MagicMagnify.getFlashMovieObject("mObj"+c);if(a&&a.changeImage){a.changeImage(imageList[currentImageCounter],imageList[currentImageCounter],parseInt(a.parentNode.style.width),parseInt(a.parentNode.style.height))}return false}function showMainPrev(){showMain(currentImageCounter-1)}function showMainNext(){showMain(currentImageCounter+1)}function showLargeImage(b,c,a){$.ajax({url:global.url+"divs/largeimages/",data:"selectedImage="+b+"&lotId="+c+"&isOnSale="+a,dataType:"json",success:function(d){if(d.error){alert(d.error)}else{$("#btnLargeImage").fancybox({titleShow:false,overlayColor:"#000",padding:0,hideOnOverlayClick:false});$("#fancybox2").html(d.html);$("#btnLargeImage").trigger("click")}}})}function setLargeImage(a){addr=$("#image"+a+" img").attr("src").replace(".JPG","X.JPG");$("#mainImage").attr("src",addr);$(".images_set li").removeClass("active");$("#image"+a).addClass("active")}function bidIncDo(b,c){var e=parseInt($("#maxBid").val());var f=e;var a=parseInt($("#currentBid").val())+get_bid_inc(parseInt($("#currentBid").val()));var d=0;if(f<=1||isNaN(e)||(e<a&&b==1)||((e-get_bid_inc(e))<a&&b==2)){e=parseInt($("#currentBid").val())+get_bid_inc(parseInt($("#currentBid").val()));f=e;$("#maxBid").val(f);validateBid(true);if(c){calculate()}return}if(!validateBid(true)){return}if(b==1){d=parseInt(e+get_bid_inc(e));$("#maxBid").val(d)}else{if(b==2){d=parseInt(e-get_bid_inc(e-1));$("#maxBid").val(d)}}e=$("#maxBid").val();if(!validateBid(true)){return}if(f==e&&b>0){return}if(c){calculate()}}function get_bid_inc(a){var b=0;if(a<5){b=1}else{if(a<40){b=5}else{if(a<100){b=10}else{if(a<1000){b=25}else{if(a<5000){b=50}else{if(a<25000){b=100}else{if(a<50000){b=250}else{if(a<100000){b=500}else{b=1000}}}}}}}}return b}function current_bid(a,b){$.ajax({url:global.url+"carfinder-online-auto-auctions/ajax/current-bid/"+a+"/"+b+"/",dataType:"json",success:function(c){if(c.current_bid_str){if($("#current-bid")!=null&&$("#current-bid")!==undefined){$("#current-bid").html(c.current_bid_str)}if($("#currentBid")!=null&&$("#currentBid")!==undefined){$("#currentBid").val(c.bid_now)}if($("#maxBid")!=null&&$("#maxBid")!==undefined){$("#maxBid").val(c.bid_now_bid);$("#bidInc").val(c.bid_inc);$("#bidInc_str").html(c.bid_inc_str)}if(c.sold==1){window.location.reload()}}},error:function(){}})}function validateBid(b){var a=validateBidAmt($("#maxBid").val(),$("#maxBid"));if($("#shipping_type").attr("name")){$("#r-finalBid").html($("#maxBid").val()).format_numbers()}if(b){return a}else{if(a){$("#submitBidForm").submit()}}return true}function validateBidAmt(c,f){var b=parseInt($("#currentBid").val());var e=parseInt(get_bid_inc(b));var d=parseInt(b+e);if(c.indexOf(".")>=0){var a=c.split(".");if(a.length>2){$("#advice-common-before").html("<p>"+message.invalidBidAmt);$("#advice-common-before").show();$("#maxBid").focus();return false}else{if(a[1]!==null&&a[1]!==""){if(a[1]=="0"||a[1]=="00"){$(f).val(a[0]);if((($(f).val()-b)%e)>0){$("#advice-common-before").html("<p>"+message.invalidBidInc+" $"+parseInt($("#bidInc").val())+" "+$("#currency").html()+".");$("#advice-common-before").show();$("#maxBid").focus();return false}return true}else{$("#advice-common-before").html("<p>"+message.invalidBidAmt);$("#advice-common-before").show();$("#maxBid").focus()}}else{$(f).val(a[0]);if((($(f).val()-b)%e)>0){$("#advice-common-before").html("<p>"+message.invalidBidInc+" $"+parseInt($("#bidInc").val())+" "+$("#currency").html()+".");$("#advice-common-before").show();$("#maxBid").focus();return false}return true}}}else{if(c.indexOf(",")>=0){$("#advice-common-before").html("<p>"+message.invalidBidAmt);$("#advice-common-before").show();$("#maxBid").focus();return false}else{if(c<=0||isNaN(c)){$("#advice-common-before").html("<p>"+message.invalidBidAmt);$("#advice-common-before").show();$("#maxBid").focus();return false}else{if(((c-b)%e)>0){$("#advice-common-before").html("<p>"+message.invalidBidInc+" $"+parseInt($("#bidInc").val())+" "+$("#currency").html()+".");$("#advice-common-before").show();$("#maxBid").focus();return false}else{if(c<d){$("#advice-common-before").html("<p>"+message.lowBidAmtError+" $"+(parseInt($("#bidInc").val())+parseInt($("#currentBid").val()))+" "+$("#currency").html()+".");$("#advice-common-before").show();$("#maxBid").focus();return false}}}}}$("#advice-common-before").html("<p>");$("#advice-common-before").hide();$("#bidInc").val(get_bid_inc(c));$("#bidInc_str").html(get_bid_inc(c));return true}function calculate(){var i=$("#lot").val();var a=parseInt($("#maxBid").val());var e=$("#h").val();var f=$("#vehicle_type").val();var c=$("#condition").val();if($("#shipping_type").attr("name")){var l=$("#shipping_type").val();var b=$("#origination_zip").val();var k=$("#destination_zip").val();var m=$("#origination_port").val();var n=$("#destination_country").val();var d=$("#destination_port").val();var j=$("#origination_facility").val();var g=$("#border_crossing").val();if(l=="D"){if(!isZipValid(k)){$("#destination_zip").focus();return false}}else{if(l=="B"){if(g===""){return false}}else{if(l=="I"){if(n==0||d==0||m==0){return false}}}}parameters={lot:i,condition:c,maxBid:a,destination_zip:k,origination_zip:b,vehicle_type:f,h:e,shipping_type:l,origination_port:m,destination_country:n,destination_port:d,origination_facility:j,border_crossing:g}}else{parameters={lot:i,condition:c,maxBid:a,vehicle_type:f,h:e,shipping_type:l}}if(a<1){$("#maxBid").focus();return false}clearTimeout(timer);timer=setTimeout(function(){$.ajax({url:global.url+"carfinder-online-auto-auctions/ajax/calculate/",dataType:"json",data:parameters,success:function(h){if(h.total){if(!won_bid){$("#r-copartFee").html(h.copart_fee);$("#r-transactionFee").html(h.transaction_fee);$("#r-total").html(h.total)}if($("#enable_shipping").val()==1){if(h.shipping_type!="N"){$("#r-shippingRate").html("$"+h.shipping_rate+" <a class=\"btn_order_shipping\" href=\"javascript:void(0);\" onclick=\"$('#calcForm').attr('action', '/shipping-salvage-vehicles/order/');$('#calcForm').submit();\">"+message.order_shipping_now+"</a>");$("#shippingCost-container").show();if(h.shipping_type=="D"){if(h.place_domestic){$("#r-destinationLocation").html(h.place_domestic);$("#r-destinationLocation").show()}}if(h.shipping_type=="I"){$("#I-domesticCost-container").show();$("#I-internationalCost-container").show();$("#r-domesticCost").html("$"+h.shipping_domestic);$("#r-internationalCost").html("$"+h.shipping_international);$("#r-domesticPlace").html("&nbsp;&nbsp;&nbsp;- "+h.place_domestic);$("#r-internationalPlace").html("&nbsp;&nbsp;&nbsp;- "+h.place_international)}else{$("#I-domesticCost-container").hide();$("#I-internationalCost-container").hide()}}}}},error:function(){}})},300);return true}function subsc_change_type(a){$("#subsc_email").hide();$("#subsc_phone").hide();$("#subsc_"+a).show();$("#subsc_type").val(a)}function subscribe(){var c=$("#lot").val();var e=$("#h").val();var d=$("#subsc_type").val();var b=$("#subsc_email").val();var a=$("#subsc_phone").val();if(d=="email"){}$("#notification_msg").hide();$.ajax({url:global.url+"carfinder-online-auto-auctions/ajax/subscribe/",dataType:"json",data:{lot:c,type:d,h:e,email:b,phone:a},success:function(f){if(f.error){$("#notification_msg").html(f.error);$("#notification_msg").show()}else{$("#notification_content").html(f.text)}},error:function(){}});return true}function do_subscribe(){var b=$("#hash").val();var a=$("#code").val();$("#notification_msg").hide();$.ajax({url:global.url+"carfinder-online-auto-auctions/ajax/do-subscribe/",dataType:"json",data:{hash:b,code:a},success:function(c){if(c.error){$("#notification_msg").html(c.error);$("#notification_msg").show()}else{$("#notification_content").html(c.text)}},error:function(){}});return true}function unsubscribe(){var b=$("#hash").val();var a=$("#code").val();$("#notification_msg").hide();$.ajax({url:global.url+"carfinder-online-auto-auctions/ajax/unsubscribe/",dataType:"json",data:{hash:b,code:a},success:function(c){if(c.error){$("#notification_msg").html(c.error);$("#notification_msg").show()}else{$("#notification_content").html(c.text)}},error:function(){}});return true}function runVB(c,b,a){$("#advice-common-before").hide();$("#bid_wait").show();$("#join_vb").hide();$.ajax({url:global.url+"virtualsales-copart-auto-auctions/ajax/lot-vb/"+c+"/"+b+"/"+a+"/",dataType:"json",data:{hash:$("#hash").val()},success:function(e){if(e.error){$("#bid_wait").hide();$("#join_vb").show();$("#advice-vb").html("<p>"+e.error);$("#advice-vb").show()}else{$("#vsform").html("");e.fields.codebase="com.copart.vb2.applets.buyer.BuyerApplet.class";e.fields.height=540;e.fields.width=705;e.fields.jar=e.fields.jarF;e.fields.buyerFinalBidsURL="http://"+e.fields.serverName+"/cgi-bin/buyer/bid/final.dtw/disp";e.fields.minBidURL="http://"+e.fields.serverName+"/cgi-bin/buyer/bid/virtual/minbid.dtw/disp?lot=";e.fields.buyerHomeURL="http://"+e.fields.serverName+"/cgi-bin/buyer/index.dtw/fetch";e.fields.repeat=e.fields.repeatCount;e.fields.host=e.fields.domainName;for(var d in e.fields){$("<input>").attr({type:"hidden",id:d,name:d,value:e.fields[d]}).appendTo("#vsform")}popUpWindow=window.open("http://www.copart.com/loading.htm","AppletWindowQ"+e.fields.rowIndex,"resizable=no,scrollbars=no,width=713,height=550,screenX=0,screenY=0,status=yes");$("#vsform").attr("target","AppletWindowQ"+e.fields.rowIndex);$("#vsform").attr("action","http://"+e.fields.domainName+"/cgi-bin/public/virtual/bid.dtw/disp");$("#vsform").submit();$("#bid_wait").hide();$("#join_vb").show()}},error:function(){}})};
