/*
FRAMEWORK_VERSION:19.3.0
*/
registerNameSpace("Site.Offers");Site.Offers.SpecialOffersAllMap=function(k){k.productType=k.productType||"Flight";k.jsonOffers=k.jsonOffers||[];k.resources=k.resources||{};k.priceRanges=k.priceRanges||[];k.currentCurrency=k.currentCurrency||"NonLocalCurrency";k.zoom=k.zoom||2;k.mapType=k.mapType||google.maps.MapTypeId.ROADMAP;k.scrollwheel=k.scrollwheel||false;k.centerPosition=k.centerPosition||{};k.centerPosition.Latitude=k.centerPosition.Latitude||20.5;k.centerPosition.Longitude=k.centerPosition.Longitude||-20.5;k.markers=k.markers||{};k.markers.width=k.markers.width||17;k.markers.height=k.markers.height||17;k.polylinesColor=k.polylinesColor||"#C00000";k.spriteMarkersURL=k.spriteMarkersURL||"/images/despegar/offers/SpecialOffersAllMarkers.png";var c;var h=[];var l=[];var g;var b;var f=false;var i=function(){var n=new google.maps.LatLng(k.centerPosition.Latitude,k.centerPosition.Longitude);var m={zoom:k.zoom,center:n,mapTypeId:k.mapType,scrollwheel:k.scrollwheel};c=new google.maps.Map(document.getElementById("mapContainer"),m);if(k.jsonOffers.length>0){e()}};var e=function(){var o;var q;var v;var w=new google.maps.LatLng(k.jsonOffers[0].OriginCoordinates.Latitud,k.jsonOffers[0].OriginCoordinates.Longitud);var r=k.spriteMarkersURL;var n;if(f){r="/images/despegar/offers/IE6/SpecialOffersAllMarker0.png";n=new google.maps.MarkerImage(r,null,null,new google.maps.Point(k.markers.width/2,k.markers.height/2),new google.maps.Size(k.markers.width,k.markers.height))}else{n=new google.maps.MarkerImage(r,new google.maps.Size(k.markers.width,k.markers.height),null,new google.maps.Point(k.markers.width/2,k.markers.height/2),null)}g=new google.maps.Marker({position:w,map:c,icon:n});for(indexSpecialOffer in k.jsonOffers){o=k.jsonOffers[indexSpecialOffer];var p=new google.maps.LatLng(o.DestinationCoordinates.Latitud,o.DestinationCoordinates.Longitud);var s=0;var u=true;while(s<=k.priceRanges.length&&u){s++;var t;if(k.currentCurrency=="NonLocalCurrency"){t=o.NonLocalPrice}else{t=o.LocalPrice}if(k.priceRanges[s-1]>=t){u=false}}if(f){r="/images/despegar/offers/IE6/SpecialOffersAllMarker"+s+".png";n=new google.maps.MarkerImage(r,null,null,new google.maps.Point(k.markers.width/2,k.markers.height/2),new google.maps.Size(k.markers.width,k.markers.height))}else{n=new google.maps.MarkerImage(r,new google.maps.Size(k.markers.width,k.markers.height),new google.maps.Point((k.markers.width*s),0),new google.maps.Point(k.markers.width/2,k.markers.height/2),null)}q=new google.maps.Marker({position:p,icon:n,map:c});if(q){d(q,o);h[o.Destination]=q;var m=[w,p];v=new google.maps.Polyline({map:c,path:m,strokeWeight:1,strokeColor:k.polylinesColor});l[o.Destination]=v}}};var a=function(){for(specialOfferIndex in k.jsonOffers){destinationCode=k.jsonOffers[specialOfferIndex].Destination;h[destinationCode].setVisible(true);l[destinationCode].setOptions({strokeOpacity:1})}};var d=function(n,m){var p='		<div class="windowsGmap">			<h5>'+m.OriginDescription+"&nbsp;"+k.resources.To+"&nbsp;"+m.DestinationDescription+'</h5>			<div class="contentWindowsGmap">				<div class="priceText">					<span class="priceFrom">'+k.resources.OfferPriceFrom+'</span>					<span class="price">'+k.resources[(k.currentCurrency=="NonLocalCurrency"?"nonLocalCurrencyMask":"localCurrencyMask")]+'&nbsp;<em class="priceValue">'+(k.currentCurrency=="NonLocalCurrency"?m.NonLocalPrice:m.LocalPrice)+'</em></span>				</div>				<div class="buttonContainer">					<a class="button btnRed" href="'+m.Url+'">						<span><em>'+k.resources.SearchButtonText+'</em></span>					</a>					<span class="clearBox"></span>				</div>			</div>		</div>';var o=new google.maps.InfoWindow({content:p});google.maps.event.addListener(o,"closeclick",function(){b=null});google.maps.event.addListener(n,"click",function(){if(b!=o){if(b){b.close()}o.open(c,n);b=o}})};var j=function(m){if(b){b.close()}for(destinationCode in m){if(m[destinationCode]){h[destinationCode].setVisible(true);l[destinationCode].setOptions({strokeOpacity:1})}else{if(m[destinationCode]!=undefined){h[destinationCode].setVisible(false);l[destinationCode].setOptions({strokeOpacity:0})}}}};if($.browser.msie){if($.browser.version<"7"){f=true}}i();return{getOffers:function(){return k.jsonOffers},updateOffersToShow:j,showAll:a}};registerNameSpace("Site.Offers");Site.Offers.SpecialOffersAll=function(a){a=a||{};a.productType=a.productType||"Flight";a.jsonOffers=a.jsonOffers||[];a.resources=a.resources||{};a.priceRanges=a.priceRanges||[];a.currentCurrency=a.currentCurrency||"NonLocalCurrency";var b;$("#otherCitiesLink").click(function(){$("#otherCitiesLinksPopUp").css("left",$("#otherCitiesLink").position().left).fadeIn()});$(document).ready(function(){b=new Site.Offers.SpecialOffersAllMap({productType:a.productType,jsonOffers:a.jsonOffers,resources:a.resources,priceRanges:a.priceRanges,currentCurrency:a.currentCurrency});if(b){var c=$(".rangePriceFilterItem",$("#priceFilterContainer"));c.click(function(){var g=new Array();var f=$(this);var e=$(".priceRangeValue",f.next()).html();e=e.replace(".","").replace(",","");e=parseInt(e);for(var h in jsonOffers){var d=a.jsonOffers[h];var i;if(a.currentCurrency=="NonLocalCurrency"){i=d.NonLocalPrice}else{i=d.LocalPrice}if(e>=i){g[d.Destination]=true}else{g[d.Destination]=false}}b.updateOffersToShow(g);f.unbind("click").bind("click",function(){return(function(){b.updateOffersToShow(g)}())})});$("#priceFilterItemShowAll").click(b.showAll)}})};
