// (c)2008 uShip, Inc.

function bidEnlargement(zip1,zip2){window.open('/popups/showroute.aspx?zip1='+zip1+'&zip2='+zip2+'&height=750&width=500','BidWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700,height=450');}
function bidPopup(bidID){window.open('/popups/bid_details.aspx?ID='+bidID,'BidWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=778,height=725');}
function bookingPopup(bookingID){window.open('/popups/booking_details.aspx?ID='+bookingID,'DetailsWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700,height=250');}
var Gallery=function(imgId,numOfImgId,prevId,nextId,magnifyId,images){this.imgElem=$(imgId);this.numOfImg=$(numOfImgId);this.lnkPrev=$(prevId);this.lnkNext=$(nextId);this.lnkMagnify=$(magnifyId);if(images&&images.length>0){for(var i=0,len=images.length;i<len;i++){var imgSrc=images[i];var imgType=this._getType(images[i]);images[i]={src:imgSrc,type:imgType.type,path:imgType.path}}
this.images=images;this.current=0;}
if(images.length>0){this.lnkMagnify.parentNode.style.display='block';}
else{this.lnkMagnify.parentNode.style.display='none';this.imgElem.style.cursor='auto';}
if(images.length>1){this.lnkPrev.parentNode.style.display='block';}
else{this.lnkPrev.parentNode.style.display='none';}
Event.observe(this.lnkPrev,'click',this.handlePrevClick.bind(this));Event.observe(this.lnkNext,'click',this.handleNextClick.bind(this));Event.observe(this.lnkMagnify,'click',this.handleMagnifyClick.bind(this));if(this.images){Event.observe(this.imgElem,'click',this.handleMagnifyClick.bind(this));}}
Gallery.prototype={show:function(i){this.current=i;this.imgElem.src=this.images[i].path;if(document.all){this.numOfImg.innerText=(i+1)+' of '+this.images.length;}else{this.numOfImg.textContent=(i+1)+' of '+this.images.length;}},next:function(){if(this.current+1<this.images.length){this.show(this.current+1);}
else{this.show(0);}},prev:function(){if(this.current-1>=0){this.show(this.current-1);}
else{this.show(this.images.length-1);}},popup:function(){window.open('/Popups/profilePic.aspx?imagePath='+this.images[this.current].src.replace('.jpg',''),"window",'location=0,menubar=0,scrollbars=1,status=0,toolbar=0,resizable=1,width=200,height=200');},_getType:function(imageName){var type;var path;if(imageName.indexOf('http')>-1){type=3;path='/listing/show_listingImage.aspx?maxwidth=270&maxheight=210&filename='+imageName;}
else if(imageName.indexOf('/sticky/images/icons/category/')>-1){type=2;path='/'+imageName;}
else{type=1;path='/listing/show_listingImage.aspx?maxwidth=270&maxheight=210&filename=/static/'+imageName;}
return{type:type,path:path}},_preload:function(){var preload_image_object=[]
for(var i=0;i<this.images.length;i++){preload_image_object[i]=new Image();preload_image_object[i].src=this.images.path;}},handlePrevClick:function(e){Event.stop(e);this.prev();},handleNextClick:function(e){Event.stop(e);this.next();},handleMagnifyClick:function(e){Event.stop(e);this.popup();}}
var InteractiveMap=function(containerId,startLoc,endLoc,gid,currentmtype){this.containerId=containerId;this.startLoc=startLoc;this.endLoc=endLoc;this.gid=gid;this.currentmtype=currentmtype;this.request=uship.ns.ajaxpro.register('listing2','setmileagelisting',['mileage','type','gid','currenttype'])
this.map=new GMap2(document.getElementById(containerId));this.map.addControl(new GSmallMapControl());this.map.addControl(new GMapTypeControl());this.map.addControl(new GScaleControl());this.route=new GDirections();this.route.load(startLoc+' to '+endLoc,{getPolyline:true});Event.observe(window,'unload',this.handlePageUnload.bind(this));var d=new Date();this.timeloaded=d.getTime();this._callback();}
InteractiveMap.prototype={doGoto:function(LatLong){this.map.setCenter(LatLong,13);},showOriginalView:function(){if(this.route!=undefined){this.map.returnToSavedPosition();}else if(this.geoOriginal!=undefined){this.map.returnToSavedPosition();}},resize:function(width,height){this.map.checkResize();},handleViewStartClick:function(e){if(e){Event.stop(e);}
if(this.startMarker!=undefined){this.doGoto(this.startMarker.getPoint());}else if(this.geoStart!=undefined){this.doGoto(this.geoStart);}},handleViewEndClick:function(e){if(e){Event.stop(e);}
if(this.endMarker!=undefined){this.doGoto(this.endMarker.getPoint());}else if(this.geoEnd!=undefined){this.doGoto(this.geoEnd);}},handleViewOriginalClick:function(e){if(e){Event.stop(e);}
this.showOriginalView();},handlePageUnload:function(e){GUnload();},handleRouteCallback:function(){var poly=this.route.getPolyline();this.startMarker=this.route.getMarker(0);this.endMarker=this.route.getMarker(1);var startLatLng=this.startMarker.getPoint();var endLatLng=this.endMarker.getPoint();var bounds=poly.getBounds();var zoom=this.map.getBoundsZoomLevel(bounds);var center=bounds.getCenter();this.map.setCenter(center,zoom);this.map.savePosition();var icon=new GIcon();icon.image="/sticky/images/listing/pinpoint_green.png";icon.shadow="/sticky/images/pricingestimator/shadow.png";icon.iconSize=new GSize(24,37);icon.shadowSize=new GSize(27,37);icon.iconAnchor=new GPoint(6,30);this.map.addOverlay(poly);this.map.addOverlay(new GMarker(startLatLng,icon));this.map.addOverlay(new GMarker(endLatLng,new GIcon(icon,'/sticky/images/listing/pinpoint_red.png')));if(uship.prefs.i18n.inmiles){var it=(this.route.getDistance().meters*0.000621371192).toFixed(1)+' mi';}
else{var it=(this.route.getDistance().meters*0.001).toFixed(1)+' km';}
$('conEstimatedMiles').innerHTML=it+' | '+this.route.getDuration().html;this.request((this.route.getDistance().meters*0.000621371192).toFixed(1),2,this.gid,this.currentmtype);},_callback:function(){var s=this.route.getStatus();if(s&&s.code==200){this.handleRouteCallback();}
else{var d1=new Date();var timediff=d1.getTime()-this.timeloaded;if(timediff<=10000){setTimeout(this._callback.bind(this),50);}
else{this.handleNoRoute();}}},handleNoRoute:function(){var geocoder=new GClientGeocoder();geocoder.getLatLng(this.startLoc,this.addToMapStart.bind(this));},addToMapStart:function(point){this.geoStart=point
if(this.geoStart!=undefined){var geocoder=new GClientGeocoder();geocoder.getLatLng(this.endLoc,this.addToMapEnd.bind(this));}
else{$('vemap').style.backgroundImage='url(/sticky/images/listing/image_no_map.gif)';}},addToMapEnd:function(point){this.geoEnd=point
if(this.geoEnd!=undefined&&this.geoStart!=undefined){var icon2=new GIcon();icon2.image="/sticky/images/listing/pinpoint_green.png";icon2.shadow="/sticky/images/pricingestimator/shadow.png";icon2.iconSize=new GSize(24,37);icon2.shadowSize=new GSize(27,37);icon2.iconAnchor=new GPoint(6,30);this.map.addOverlay(new GMarker(this.geoStart,icon2));var icon=new GIcon();icon.image='/sticky/images/listing/pinpoint_red.png';icon.iconSize=new GSize(24,37);icon.shadowSize=new GSize(27,37);icon.iconAnchor=new GPoint(6,30);this.map.addOverlay(new GMarker(point,icon));this.doGetCenterForGeoCode();}
else{this.geoStart=undefined;this.geoEnd=undefined;$('vemap').style.backgroundImage='url(/sticky/images/listing/image_no_map.gif)';}},doGetCenterForGeoCode:function(){var glatlng1=new GLatLng(this.geoStart.y,this.geoStart.x);var glatlng2=new GLatLng(this.geoEnd.y,this.geoEnd.x);if($('hidShowMileage').value=="hide"){$('liEstimatedMiles').innerHTML="";}
else{var miledistance=glatlng1.distanceFrom(glatlng2,3959).toFixed(1);this.request(miledistance,3,this.gid,this.currentmtype);var kmdistance=(miledistance*1.609344).toFixed(1);if(uship.prefs.i18n.inmiles){$('conEstimatedMiles').innerHTML=""+miledistance+""+" mi";}
else{$('conEstimatedMiles').innerHTML=""+kmdistance+""+" km";}}
var latlng=[this.geoStart,this.geoEnd];var latlngbounds=new GLatLngBounds();for(var i=0;i<latlng.length;i++){latlngbounds.extend(latlng[i]);}
this.map.setCenter(latlngbounds.getCenter(),this.map.getBoundsZoomLevel(latlngbounds));this.map.savePosition();}}
var HoverZoom=function(elem,highlightColor){this.element=$(elem);this.highlightColor=highlightColor;this.fireEvent=false;this.isClicked=false;this.isBlocked=false;this.__t;this.__t2;Event.observe(this.element,'mouseover',this.handleMouseOver.bind(this));Event.observe(this.element,'mouseout',this.handleMouseOut.bind(this));Event.observe(this.element,'click',this.handleClick.bind(this));};HoverZoom.prototype={highlight:function(){this.element.style.backgroundColor=this.highlightColor;},ignore:function(){this.element.style.backgroundColor='#fff';},isWithin:function(){},handleDelayedHover:function(e){if(this.onhover){this.onhover(e);}},handleDelayedOut:function(e){if(this.ondelayedout){this.ondelayedout(e);}},handleMouseOver:function(e){clearTimeout(this.__t2);this.__t=setTimeout(this.handleDelayedHover.bind(this,e),1000);if(this.onmouseover){this.onmouseover(e);}},handleMouseOut:function(e){clearTimeout(this.__t);this.__t2=setTimeout(this.handleDelayedOut.bind(this,e),1000);if(this.onmouseout){this.onmouseout(e);}},handleClick:function(e){clearTimeout(this.__t);if(this.onclick){this.onclick(e);}}};function flagAlert(clientID){if(confirm('By clicking on the report flag at the end of a message that you feel is in violation, not only will you notify uShip of the offense, but you will also initiate an email that will be sent directly to the offender!  Please be sure a violation has occurred before you hit Ok. \n \nOnly genuine questions/answers from interested carriers are allowed – no other comments are appropriate in the Q&A.  It is a violation of uShip rules to post any of the following in Q&A: \n \n -Email Addresses \n -Phone Numbers \n -Web Addresses \n -Fax Numbers \n -Profanity or Hostile Language.\n -Any communication that references uShip fees, uShip commission or similar phrases (Price discussion should only reference All-inclusive Total Bids) \n -Any communication that attempts to direct a shipper offsite. \n -Any communication that is directed at another carrier (Q&A is for communicating with the shipper) \n -Any communication unrelated to the delivery of this shipment. \n\n Please note - It is NOT a violation to post Company Names or Personal Names.\n\n Click Ok if you feel this message is in violation, or Cancel to exit.')){__doPostBack(clientID,'');}
return false;}
function setDropdown(dropDown,value){var numOptions=dropDown.options.length;for(i=0;i<numOptions;i++){if(dropDown.options[i].value==value){dropDown.options[i].selected=true;}}}
var scroll_to_bid=function(){Element.scrollTo('ready');}
var bv=(function(){var rel={},is_alt_group=true,PARENT_HIDE_CLASS_NAME='bv-hide-parent',CHILD_HIDE_CLASS_NAME='bv-hide-child';return{add:function(parent_id,child_id,is_opened){is_opened=(is_opened!=undefined)?is_opened:false;if(rel[parent_id]==undefined){rel[parent_id]=[];is_alt_group=!is_alt_group;}
document.write('<input type="hidden" id="childbid'+child_id+'" />');var elem=document.getElementById('childbid'+child_id).parentNode.parentNode;if(is_alt_group){Element.addClassName(elem,'alt');}
else{Element.removeClassName(elem,'alt');}
var children=rel[parent_id];children.push(elem);if(!is_opened){Element.addClassName(elem,(children.length==1)?PARENT_HIDE_CLASS_NAME:CHILD_HIDE_CLASS_NAME);}},toggle:function(parent_id){if(rel[parent_id]!=undefined){var children=rel[parent_id];var elem=children[0];if(Element.hasClassName(elem,PARENT_HIDE_CLASS_NAME)){Element.removeClassName(elem,PARENT_HIDE_CLASS_NAME);}
else{Element.addClassName(elem,PARENT_HIDE_CLASS_NAME);}
for(var i=1,len=children.length;i<len;i++){elem=children[i];if(Element.hasClassName(elem,CHILD_HIDE_CLASS_NAME)){Element.removeClassName(elem,CHILD_HIDE_CLASS_NAME);}
else{Element.addClassName(elem,CHILD_HIDE_CLASS_NAME);}}}}};})();function show_popup(popupDivID){if(window.HideNumberToComplete!=undefined){HideNumberToComplete();}
new Effect.Appear(popupDivID,{duration:.2})}
function cancel_addgroup(groupDiv,txtID,drpdwnID,lblErrorID){new Effect.Fade(groupDiv,{duration:.2});if(window.ShowNumberToComplete!=undefined){ShowNumberToComplete();}
var name=$(txtID);name.value="";var number=$(drpdwnID);number.options.selectedIndex=0
var error=$(lblErrorID);error.innerHTML="";error.style.display='none';}
function Calculate_Price(totalPrice,lblPrice,divError,divDisplay){var price=$(totalPrice).value;var error=$(divError);var display=$(divDisplay);var t=id3Solutions.UShip.Web.BidCalcCtrl.AmountToMe(price,'1',freeShipment,myUserID,function(response){response=response.value;if(response!=''){$(lblPrice).innerHTML=response;error.style.display='none';display.style.display='block';}
else{display.style.display='none';error.style.display='block';}});}
function close_QuotePrice(groupDiv,TotalPriceID,DivError,ControlToSet){var name=$(TotalPriceID);var error=$(DivError);var SetControl=$($(ControlToSet).value);error.style.display='none';if(name!=null){var Price=name.innerHTML;var Adjustedprice=Price;if($('lblTotalBid').innerHTML.include('per')){Adjustedprice=parseFloat(Price/itemcount).toFixed(2);}
if(Price.replace('$','')!=''){SetControl.value=Adjustedprice.replace('$','');if(SetControl.id=='txtTotalBid'){UpdateBidButtonText(Adjustedprice);}}}
new Effect.Fade(groupDiv,{duration:.2});}
function validateGroupName(txtID,drpdwnID,lblErrorID){var name=$(txtID);var labelError=$(lblErrorID);var trimedName=name.value;trimedName=trimedName.replace(/^\s*/,"").replace(/\s*$/,"");if(trimedName=="")
{labelError.innerHTML="Please enter a group name";labelError.style.display='block';return false;}
var number=$(drpdwnID);if(number.options.selectedIndex==0)
{labelError.innerHTML="Please select number of matches";labelError.style.display='block';return false;}
return true;}