// (c)2008 uShip, Inc.

if(window.PE===undefined){window.PE={};}
var CommoditySelectModule=function(dd_parent_id,dd_child_id,hid_child_id,elem_weight_id,elem_length_id,elem_number_id,elem_is_running_id,fields){var selector=new PE.CommoditySelect(dd_parent_id,dd_child_id,hid_child_id),elem_weight=$(elem_weight_id),elem_length=$(elem_length_id),elem_number=$(elem_number_id),elem_is_running=$(elem_is_running_id),fields=fields||CommoditySelectModule.Fields;selector.onparentchange=function(commodity_id){elem_weight.style.display=(commodity_id==11||commodity_id==391)?'block':'none';elem_length.style.display='none';elem_number.style.display='none';if(!!elem_is_running){elem_is_running.style.display='none';}};selector.onchildchange=function(commodity_id,parent_id){elem_weight.style.display='none';elem_length.style.display='none';elem_number.style.display='none';if(commodity_id==0){return;}
if(!!elem_is_running){elem_is_running.style.display='none';}
if(array_contains(fields.weight,commodity_id)){elem_weight.style.display='block';}
else if(array_contains(fields.length,commodity_id)){elem_length.style.display='block';}
else if(array_contains(fields.number,commodity_id)){elem_number.style.display='block';}
else if(array_contains(fields.is_running,commodity_id)){if(!!elem_is_running){elem_is_running.style.display='block';}}
else if(!array_contains(fields.none,commodity_id)){elem_weight.style.display='block';}};var value=selector.get_child();if(value>0){selector.hid_child.value=value;if(selector.onchildchange!=undefined){selector.onchildchange(value,selector.get_parent());}}
return{selector:selector,fields:fields};};PE.CommoditySelect=function(parent_id,child_id,hidden_id){if(typeof parent_id=='number'){this.parent_value=parent_id;}
else{this.dd_parent=$(parent_id);}
this.dd_child=$(child_id);this.hid_child=$(hidden_id);this.change_children(this.get_parent());if(this.dd_parent!=undefined){this.dd_parent.onchange=this.handleParentChange.bind(this);}
this.dd_child.onchange=this.handleChildChange.bind(this);};PE.CommoditySelect.prototype={change_children:function(value){this.dd_child.innerHTML='';if(value>0){this.dd_child.disabled=false;this.dd_child.options[this.dd_child.length]=new Option('- Select One -',0,false,false);if(value==1){this._ae('Furniture','12');this._ae('Home Electronics','13');this._ae('Appliances','14');this._ae('Arcade Equipment','15');this._ae('Lawn & Outdoor Equipment','16');this._ae('Sporting Equipment','17');this._ae('Household Plants','18');this._ae('Other Household Goods','19');}
else if(value==2){this._ae('Wood & Paper Products','20');this._ae('Liquids, Gases & Chemicals','21');this._ae('Heavy Equipment','392');this._ae('Construction Material, Equipment & Machinery','22');this._ae('Stone, Metals & Minerals','23');this._ae('Commodities Dry Bulk','24');this._ae('General Freight','25');this._ae('Mixed Freight','26');this._ae('Utilities','27');this._ae('Pharmaceutical Products','28');this._ae('Fertilizers','29');this._ae('Plastics & Rubber','30');this._ae('Textiles, Leather','31');this._ae('Miscellaneous Manufactured Products','32');this._ae('Tradeshow Equipment','33');this._ae('Office Equipment','34');this._ae('Other Business & Industrial Goods','35');}
else if(value==3){this._ae('Small Studio','66');this._ae('Large Studio or 1 BR Apartment','67');this._ae('2 BR Apt','69');this._ae('3 BR Apt or 2 BR house','70');this._ae('3 BR house','71');this._ae('4 BR house','72');this._ae('5+ BR house','73');}
else if(value==4){this._ae('Cars & Light Trucks','79');this._ae('Recreational Vehicles (RVs)','81');this._ae('Trailers','82');this._ae('Trailer Homes','83');this._ae('Vehicle Parts','84');this._ae('Antique Vehicles','87');this._ae('Heavy Trucks & Construction Vehicles','88');this._ae('Tractors & Agricultural Equipment','91');}
else if(value==5){this._ae('Powerboats','93');this._ae('Sailboats','94');}
else if(value==6){this._ae('Fresh Produce','98');this._ae('Refrigerated Food','99');this._ae('Meat, Fish, Seafood','100');this._ae('Agricultural/Farm Supplies','101');this._ae('Grain, Feed, Hay','102');this._ae('Cereal Grains (including seed)','103');this._ae('Other Agricultural Products, except for Animal Feed','104');this._ae('Animal Feed & Products of Animal Origin','105');this._ae('Milled Grain Products & Preparations, and Bakery Products','106');this._ae('Beverages','107');this._ae('Alcoholic Beverages','108');this._ae('Other Prepared Foodstuffs, and Fats and Oils','109');this._ae('Tobacco Products','110');this._ae('Other Food & Agriculture','111');}
else if(value==7){this._ae('Antiques','112');this._ae('Art','113');this._ae('Glass/Breakables','114');this._ae('Pianos','115');this._ae('Pool Tables','116');this._ae('Other Special Care Items','117');}
else if(value==10){this._ae('Cats','124');this._ae('Dogs','125');this._ae('Cattle','126');this._ae('Horses','128');}
else if(value==11){this._ae('Less than Truckload','132');this._ae('Full Truckload','150');this._ae('Intermodal Container','137');}
else if(value==146){this._ae('Motorcycles & Mopeds','80');this._ae('Personal Watercraft','95');this._ae('Snowmobiles','90');this._ae('ATVs','86');}
else if(value==391){this.dd_child.disabled=true;}}
else{this.dd_child.options[this.dd_child.length]=new Option('- Any Sub Category -',0,false,false);}},handleParentChange:function(){var value=this.get_parent();this.hid_child.value=-1;this.change_children(value);if(this.onparentchange!=undefined){this.onparentchange(value);}},handleChildChange:function(){var value=this.get_child();this.hid_child.value=value;if(this.onchildchange!=undefined){this.onchildchange(value,this.get_parent());}},_ae:function(text,value){var is_selected=(this.hid_child.value==value);var i=this.dd_child.length;this.dd_child.options[i]=new Option(this._shorten_string(text,30),value,is_selected,is_selected);this.dd_child.childNodes[i].title=text;},_shorten_string:function(str,max_length){if(str.length>max_length){return str.substring(0,(max_length-3))+'...';}
else{return str;}},get_parent:function(){return(this.dd_parent!=undefined)?this.dd_parent.options[this.dd_parent.selectedIndex].value:this.parent_value;},get_child:function(){return this.dd_child.options[this.dd_child.selectedIndex].value;}};CommoditySelectModule.Fields={weight:[12,13,14,15,16,17,18,19,112,113,114,115,116,117,124,125,391],length:[93,94],number:[128],is_running:[79,87],none:[66,67,69,70,71,72,73,80,81,82,86,90,95]};array_contains=function(arr,value){var is_found=function(id){return(value==id);};return(arr.find(is_found)!=undefined);}