// (c)2008 uShip, Inc.

var radioTrueFalse=function(rbList,ShowWhenTrue,ShowWhenFalse){var rbItems=$A(rbList.getElementsByTagName('input'));var change=function(e){var item=Event.element(e);if(item.value==1){Element.show(ShowWhenTrue);Element.hide(ShowWhenFalse);}
else{Element.hide(ShowWhenTrue);Element.show(ShowWhenFalse);}}
rbItems.each(function(item){if(item.value==1&&item.checked){Element.show(ShowWhenTrue);Element.hide(ShowWhenFalse);}
else if(item.value==0&&item.checked){Element.hide(ShowWhenTrue);Element.show(ShowWhenFalse);}
Event.observe(item,'click',change);});}
var CheckBoxSelectedShow=function(chkbox,ShowItemsList){var change=function(e){if(chkbox.checked==true){Element.show(ShowItemsList);}
else{Element.hide(ShowItemsList);}}
Event.observe(chkbox,'click',change);if(chkbox.checked==true){Element.show(ShowItemsList);}
else{Element.hide(ShowItemsList);}}
var ShowOtherOptionInDropDown=function(drpdown,ShowItemsdiv,val){var change=function(e){if(drpdown.selectedIndex==val){Element.show(ShowItemsdiv);}
else{Element.hide(ShowItemsdiv);}}
Event.observe(drpdown,'click',change);if(drpdown.selectedIndex==val){Element.show(ShowItemsdiv);}
else{Element.hide(ShowItemsdiv);}}
var radioOptions=function(details,rbList,val,invert){var rbItems=$A(rbList.getElementsByTagName('input'));var change=function(e){var item=Event.element(e);if(item.value==val){if(invert){Element.hide(details);}
else{Element.show(details);}}
else{if(invert){Element.show(details);}
else{Element.hide(details);}}}
rbItems.each(function(item){if(item.value==val&&item.checked){if(invert){Element.hide(details);}
else{Element.show(details);}}
Event.observe(item,'click',change);});}
var AuctionOptions_old=function(rbNotAuctionId,rbIsAuctionId,ddAuctionTypeId,ebayValue,conAuctionOptionsId,conEbayOptionsId){me={};me.rbNotAuction=$(rbNotAuctionId);me.rbIsAuction=$(rbIsAuctionId);me.ddAuctionType=$(ddAuctionTypeId);me.conAuctionOptions=$(conAuctionOptionsId);me.conEbayOptions=$(conEbayOptionsId);me.ebayValue=ebayValue;function init(){me.rbNotAuction.observe('click',me.run);me.rbIsAuction.observe('click',me.run);me.ddAuctionType.observe('change',handleAuctionTypeChange);me.run();}
me.run=function(){if(me.rbIsAuction.checked){me.conAuctionOptions.show();if(me.ddAuctionType.options[me.ddAuctionType.selectedIndex].value==me.ebayValue){me.conEbayOptions.show();}
else{me.conEbayOptions.hide();}}
else{me.conAuctionOptions.hide();me.conEbayOptions.hide();}}
function handleAuctionTypeChange(e){me.rbIsAuction.checked=true;me.run();}
init();return me;}
var AuctionOptions=function(rbNotAuctionId,rbIsAuctionId,rbLinkedAuctionId,rbNotLinkedAuctionId,ddAuctionTypeId,ebayValue,ritchieValue,conAuctionOptionsId,conEbayOptionsId,conLinkedEbayId,conNotLinkedEbayId,itemURL){me={};me.rbNotAuction=$(rbNotAuctionId);me.rbIsAuction=$(rbIsAuctionId);me.rbLinkedAuction=$(rbLinkedAuctionId);me.rbNotLinkedAuction=$(rbNotLinkedAuctionId);me.ddAuctionType=$(ddAuctionTypeId);me.conEbayOptions=$(conEbayOptionsId);me.conLinkedEbay=$(conLinkedEbayId);me.conNotLinkedEbay=$(conNotLinkedEbayId);me.ebayValue=ebayValue;me.ritchieValue=ritchieValue;me.conAuctionOptions=$(conAuctionOptionsId);me.itemURL=$(itemURL);function init(){if(me.rbNotAuction!=null){me.rbNotAuction.observe('click',me.run);me.rbIsAuction.observe('click',me.run);me.rbLinkedAuction.observe('click',me.run2);me.rbNotLinkedAuction.observe('click',me.run2);me.ddAuctionType.observe('change',handleAuctionTypeChange);me.run();me.run2();}
else{me.conAuctionOptions.show();}}
me.run=function(){var showLotNumber=document.getElementsByClassName("showLotNumber")
var lotNumbers=document.getElementsByClassName("lotnumber");var div_biddernumber=$('divBidderNumber');if(showLotNumber.length>0){if(me.rbIsAuction.checked&&me.ddAuctionType.options[me.ddAuctionType.selectedIndex].value==me.ritchieValue){showLotNumber[0].value='-1';for(var i=0;i<lotNumbers.length;i++){lotNumbers[i].show();}
div_biddernumber.show();}
else{showLotNumber[0].value='0';for(var i=0;i<lotNumbers.length;i++){lotNumbers[i].hide();}
div_biddernumber.hide();}}
if(me.rbIsAuction.checked){me.conAuctionOptions.show();if(me.ddAuctionType.options[me.ddAuctionType.selectedIndex].value==me.ebayValue){me.conEbayOptions.show();me.itemURL.hide();}
else{me.conEbayOptions.hide();me.itemURL.show();}}
else{me.conAuctionOptions.hide();me.conEbayOptions.hide();me.itemURL.hide();}}
me.run2=function(){if(me.rbLinkedAuction.checked){me.conLinkedEbay.show();me.conNotLinkedEbay.hide();}
else{me.conLinkedEbay.hide();me.conNotLinkedEbay.show();}}
function handleAuctionTypeChange(e){me.rbIsAuction.checked=true;me.run();}
init();return me;}
var EBayImporter=function(btnLaunchId,btnRefreshId,containerId,conLoadingId,importUrl){this.btnLaunch=$(btnLaunchId);this.btnRefresh=$(btnRefreshId);this.container=$(containerId);this.conLoading=$(conLoadingId);this.EBAY_IMPORT_URL=importUrl;}
EBayImporter.prototype={launch:function(){if(this._w){this._w.focus();}
else{this._w=window.open(this.EBAY_IMPORT_URL,'','toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=800,height=600');this._w.focus();}},complete:function(){if(this._w){this._w.close();}
Position.clone(this.container,this.conLoading);new Effect.Opacity(this.container,{duration:0,transition:Effect.Transitions.linear,from:1,to:.2});this.conLoading.show();this.btnLaunch.disabled=true;this.btnRefresh.click();}}
var YearInput=function(inputId){var elem=$(inputId);var TEXT='Year';function run(){if(elem.value==''){elem.value=TEXT;}
else if(elem.value==TEXT){elem.value='';}}
elem.observe('focus',run);elem.observe('blur',run);run();}
var TimeframeOptions=function(rbFlexibleId,rbSpecificId,conSpecificId){this.rbFlexible=$(rbFlexibleId);this.rbSpecific=$(rbSpecificId);this.conSpecific=$(conSpecificId);this.rbFlexible.observe('click',this.run.bind(this));this.rbSpecific.observe('click',this.run.bind(this));this.run();}
TimeframeOptions.prototype={run:function(){if(this.rbSpecific.checked){this.conSpecific.show();}
else{this.conSpecific.hide();}}}
var ExpirationOptions=function(containerId,pickupObj,deliveryObj){this.container=$(containerId);this.pickup=pickupObj;this.delivery=deliveryObj;this.run();}
ExpirationOptions.prototype={run:function(){if(this.isSet(this.pickup)||this.isSet(this.delivery)){this.container.hide();}
else{this.container.show();}
setTimeout(this.run.bind(this),500);},isSet:function(tf){return(tf.checkbox.checked&&tf.latest.value.length>0)}}
var Location=Class.create();Location.prototype={initialize:function(CountryName,CountryChangeLink,CountryDropDown,ZipcodeName,ProvinceGroup,ProvinceDropDown,ProvinceTextBox,ProvinceHiddenInput,StateLabel,FillStates,opZIPtxt,opCitytxt,conZipTextAll,conFreeTextAll,opFreetxt,lbl_FreeTextExample,conZipExample,FreeTextExample,FreeTextStreet,FreeTextList){this.countryName=$(CountryName);this.countryChangeLink=$(CountryChangeLink);this.countryDropDown=$(CountryDropDown);this.zipcodeName=$(ZipcodeName);this.provinceGroup=$(ProvinceGroup);this.provinceDropDown=$(ProvinceDropDown);this.provinceTextBox=$(ProvinceTextBox);this.provinceHiddenInput=$(ProvinceHiddenInput);this.stateLabel=$(StateLabel);this.opZIPtxt=$(opZIPtxt);this.opCitytxt=$(opCitytxt);this.ZipAll=$(conZipTextAll);this.FreeTextAll=$(conFreeTextAll);this.opFreetxt=$(opFreetxt);this.lbl_FreeTextExample=$(lbl_FreeTextExample);this.ZipExample=$(conZipExample);this.FreeTextExample=FreeTextExample;this.FreeTextStreet=FreeTextStreet;this.FreeTextList=$(FreeTextList);if(FillStates==undefined||FillStates==""||FillStates=="false"){this.fillStates=false;}
else{this.fillStates=true;}
this.populateCountries();},showCountryList:function(){Element.hide(this.countryName);Element.hide(this.countryChangeLink);Element.show(this.countryDropDown);},hideCountryList:function(){Element.show(this.countryName);Element.show(this.countryChangeLink);Element.hide(this.countryDropDown);},changeCountry:function(stateID){if(stateID){this.setSelectedProvince(stateID);}
else{this.setSelectedProvince(-1);}
this.provinceTextBox.value='';this.populateCountries();},changeProvince:function(){this.setSelectedProvince(this.getSelectedProvince());},setCountryName:function(country){this.countryName.innerHTML=country;},setZipcodeName:function(zipname){this.zipcodeName.innerHTML=zipname+':';},setZIPCode:function(zip){if(this.opZIPtxt){this.opZIPtxt.value=zip;}},setCity:function(city){if(this.opCitytxt){this.opCitytxt.value=city;}},setStateLabel:function(label){this.stateLabel.innerHTML=label+':';},setSelectedProvince:function(provinceID){this.provinceHiddenInput.value=provinceID},setSelectedCountry:function(countryID){for(i=0;i<this.countryDropDown.length;i++){if(this.countryDropDown[i].value==countryID){this.countryDropDown.selectedIndex=i;break;}}},getSelectedCountry:function(){return this.countryDropDown.options[this.countryDropDown.selectedIndex].value;},getSelectedProvince:function(){return this.provinceDropDown.options[this.provinceDropDown.selectedIndex].value;},getProvinces:function(countryID){id3Solutions.UShip.Web.PickupDropoff.GetStates(countryID,this.provinceDropDown.id,this.provinceHiddenInput.value,this.populateProvinces);},populateCountries:function(){var val=this.getSelectedCountry();this.setCountryName(this.countryDropDown.options[this.countryDropDown.selectedIndex].text);this.hideCountryList();if(this.FreeTextAll!=undefined){Element.hide(this.FreeTextAll);}
if(this.ZipAll!=undefined){Element.show(this.ZipAll);}
if(this.lbl_FreeTextExample!=undefined){Element.hide(this.lbl_FreeTextExample);}
if(this.ZipExample!=undefined){Element.hide(this.ZipExample);}
if(val==1){if(this.fillStates){Element.show(this.provinceDropDown);Element.hide(this.provinceTextBox);this.getProvinces(val);Element.show(this.provinceGroup);}
else{Element.hide(this.provinceGroup);}
this.setZipcodeName('ZIP code');this.setStateLabel('State');}
else if(val==2){Element.show(this.provinceDropDown);Element.hide(this.provinceTextBox);this.getProvinces(val);Element.show(this.provinceGroup);this.setZipcodeName('Postal code');this.setStateLabel('Province');}
else if(val==3){Element.hide(this.provinceGroup);this.setZipcodeName('Post code');this.setStateLabel('County');Element.show(this.ZipExample);}
else{if(val in this.FreeTextList){Element.hide(this.provinceTextBox);Element.hide(this.provinceDropDown);Element.hide(this.provinceGroup);Element.hide(this.ZipAll);uship.utils.text_input_default_text(this.opFreetxt,'Town, Region, or Postcode');uship.utils.text_input_default_text(this.FreeTextStreet,'Street Address');Element.show(this.FreeTextAll);}
else
{Element.show(this.provinceTextBox);Element.hide(this.provinceDropDown);Element.show(this.provinceGroup);this.setZipcodeName('Postal code');this.setStateLabel('Province/Region');}}},populateProvinces:function(response){var drop=$(response.value.target);drop.innerHTML='';response.value.values.each(function(val){var isSelected=(response.value.selected==val.k);drop.options[drop.options.length]=new Option(val.v,val.k,isSelected,isSelected);});}}
var AddressOptions=function(rbPreviousId,rbNewId,ddPreviousId,conNewId,addressID,overlayId){this.rbPrevious=$(rbPreviousId);this.rbNew=$(rbNewId);this.ddPrevious=$(ddPreviousId);this.conNew=$(conNewId);this.address=$(addressID);this.overlay=$(overlayId);Event.observe(this.rbPrevious,'click',this.handleRadioClick.bind(this));Event.observe(this.rbNew,'click',this.handleRadioClick.bind(this));Event.observe(this.ddPrevious,'click',this.handleDropdownClick.bind(this));Event.observe(this.ddPrevious,'change',this.handleDropdownChange.bind(this));Event.observe(this.conNew,'click',this.handleAreaClick.bind(this));Event.observe(this.conNew,'keypress',this.handleAreaKeyPress.bind(this));this.run();}
AddressOptions.prototype={run:function(){if(this.rbPrevious.checked){this.ddPrevious.removeClassName('deselected');this.conNew.addClassName('deselected');}
else if(this.rbNew.checked){this.ddPrevious.addClassName('deselected');this.conNew.removeClassName('deselected');}
else{this.ddPrevious.removeClassName('deselected');this.conNew.removeClassName('deselected');}},handleRadioClick:function(e){this.run();},handleDropdownClick:function(e){this.rbPrevious.checked=true;this.run();},handleDropdownChange:function(e){this.rbPrevious.checked=true;this.run();},handleAreaClick:function(e){this.rbNew.checked=true;this.run();},handleAreaKeyPress:function(e){this.ddPrevious.checked=true;this.run();},selectNewAddress:function(){this.rbNew.checked=true;},pseudo_disabled:function(val){if(this.overlay){var visibility;if(val){this.ddPrevious.addClassName('deselected');this.conNew.addClassName('deselected');this.overlay.style.display='block';this.overlay.style.height=(this.address.offsetHeight+10)+'px';visibility='hidden';}
else{this.ddPrevious.removeClassName('deselected');this.conNew.removeClassName('deselected');this.overlay.style.display='none';this.overlay.style.height='0px';visibility='visible';this.run();}
if(uship.browser.msie&&parseFloat(uship.browser.version)<=6){this.ddPrevious.style.visibility=visibility;var inputs=this.conNew.select('select');for(var i=0;i<inputs.length;i++){inputs[i].style.visibility=visibility;}}}}}
var PricingSelect=function(options){this.options=options;var noneSelected=false;for(var i=0,len=this.options.length;i<len;i++){this.options[i].radio.observe('click',this.handleRadioClick.bind(this));if(this.options[i].textbox){this.options[i].textbox.observe('click',this.handleTextboxClick.bind(this));}
if(!noneSelected){noneSelected=!this.options[i].radio.checked;}}
this.run(undefined,noneSelected);}
PricingSelect.prototype={run:function(click,noneSelected){for(var i=0,len=this.options.length;i<len;i++){if(!this.options[i].radio.checked&&this.options[i].textbox&&!noneSelected){this.options[i].textbox.addClassName('deselected');}
else if(this.options[i].textbox){this.options[i].textbox.removeClassName('deselected');if(click){this.options[i].textbox.focus();}}}},handleRadioClick:function(e){this.run(true);},handleTextboxClick:function(e){var elem=Event.element(e);for(var i=0,len=this.options.length;i<len;i++){var textbox=this.options[i].textbox;if(textbox&&textbox==elem){this.options[i].radio.checked=true;break;}}
this.run();}}
var PricingOption=function(radioId,textboxId){return{radio:$(radioId),textbox:$(textboxId)}}
var SelectOnType=function(chkNotifyId,txtMobileId){this.chkNotify=$(chkNotifyId);this.txtMobile=$(txtMobileId);this.length=this.txtMobile.value.length
Event.observe(this.txtMobile,'keyup',this.handleKeyPress.bind(this));}
SelectOnType.prototype={handleKeyPress:function(e){var len=this.txtMobile.value.length;if(this.txtMobile.value.length>0&&len>this.length&&!this.chkNotify.checked){this.chkNotify.click();}
this.length=len;}}
var MoneyHelper=function(txtAmountId){this.txtAmount=$(txtAmountId);Event.observe(this.txtAmount,'blur',this.handleBlur.bind(this));}
MoneyHelper.prototype={handleBlur:function(e){if(this.txtAmount.value.length>0){this.txtAmount.value=this.txtAmount.value.replace('$','');}}}
function AlertForm(checkbox,inputs){this.checkbox=$(checkbox);this.length=0;this.check_css();Event.observe(this.checkbox,'click',this.handle_checkbox_click.bind(this));for(var i=0,len=inputs.length;i<len;i++){var elem=$(inputs[i]);var tag=elem.tagName.toUpperCase();if(tag=='SELECT'){Event.observe(elem,'change',this.handle_change_state.bind(this));}
else if(tag=='INPUT'){var type=elem.type.toUpperCase();if(type=='TEXT'){this.length=elem.value.length;Event.observe(elem,'keyup',this.handle_text_type.bind(this));}
else if(type=='RADIO'){Event.observe(elem,'click',this.handle_change_state.bind(this));}}}}
AlertForm.prototype={check_css:function(){if(this.checkbox.checked){Element.removeClassName(this.checkbox.parentNode,'disabled');}
else{Element.addClassName(this.checkbox.parentNode,'disabled');}},handle_checkbox_click:function(e){this.check_css();},handle_change_state:function(e){this.checkbox.checked=true;this.check_css();},handle_text_type:function(e){var elem=Event.element(e);if(this.length<elem.value.length){this.checkbox.checked=true;this.check_css();}
this.length=elem.value.length;}};var HomeAddressOptions=function(rbPickupId,rbDeliveryId,rbNewId,conNewId){this.rbPickup=$(rbPickupId);this.rbDelivery=$(rbDeliveryId);this.rbNew=$(rbNewId);this.conNew=$(conNewId);Event.observe(this.rbPickup,'click',this.handleRadioClick.bind(this));Event.observe(this.rbDelivery,'click',this.handleRadioClick.bind(this));Event.observe(this.rbNew,'click',this.handleRadioClick.bind(this));Event.observe(window,'load',this.run.bind(this));this.run();}
HomeAddressOptions.prototype={run:function(){if(this.rbNew.checked){this.conNew.show();}
else{this.conNew.hide();}},handleRadioClick:function(e){Event.element(e).checked=true;this.run();}}
var MeasureControl=function(container_id){this.elem_container=$(container_id);var inputs=this.elem_container.getElementsByTagName('input');this.rb_english=inputs[0];this.rb_metric=inputs[1];this.check_radio_state();Event.observe(this.rb_english,'click',this.handle_radio_click.bind(this));Event.observe(this.rb_metric,'click',this.handle_radio_click.bind(this));for(var i=2,len=inputs.length;i<len;i++){Event.observe(inputs[i],'blur',this.handle_input_blur.bind(this));}};MeasureControl.prototype={regx:/[^\d.-]*/g,check_radio_state:function(){if(!this.rb_english.checked&&!this.rb_metric.checked){this.rb_english.checked=true;}
if(this.rb_metric.checked){this.elem_container.addClassName('dimensions-plus-metric');}
else{this.elem_container.removeClassName('dimensions-plus-metric');}},strip_elem:function(elem){elem.value=elem.value.replace(this.regx,'');},handle_radio_click:function handle_radio_click(e){this.check_radio_state();},handle_input_blur:function(e){this.strip_elem(Event.element(e));}};var uShipDefaultButton;var SetFocus=function(formId){var inputs=$$('td.form-nav input');if(inputs&&inputs.length>0){uShipDefaultButton=inputs[inputs.length-1];}
if(uShipDefaultButton!=undefined){Event.observe($('form1'),'keypress',function(e){if(e.keyCode==Event.KEY_RETURN){Event.stop(e);uShipDefaultButton.click();}});}}
function callback_inclisting(){return true;}
function SaveTitle(txtTitle){id3Solutions.UShip.Web.listing2a.SaveTitle(txtTitle.value,callback_inclisting);}
function SaveAutoTitle(dropdown){var model=dropdown.options[dropdown.selectedIndex].text;var year_make=$('phControlToLoad_pnlHost__ctl0_txtTitle').value;id3Solutions.UShip.Web.listing2a.SaveTitle((year_make+" "+model),callback_inclisting);}
function SaveEmail(txtEmail){id3Solutions.UShip.Web.listing2a.SaveEmail(txtEmail.value,callback_inclisting);}