var overlays={overlayenabled:false,t:null,init:function(){$('#navigation li.overlay a').bind('mouseover',function(){overlays.overlayenabled=true;overlays.showOverlay(this);}).bind('mouseout',function(){overlays.overlayenabled=false;overlays.hideOverlay();});$('#pagephoto').bind('mouseover',function(){overlays.overlayenabled=true;}).bind('mouseout',function(){overlays.overlayenabled=false;overlays.hideOverlay();});},resetOverlay:function(){clearTimeout(this.t);$('#photooverlay').css('position','absolute');$('#photooverlay').css('display','none');$('#photooverlay').stop(true);$('#photooverlay').css('top',0);},showOverlay:function(el){this.resetOverlay();var overlay=$('#'+$(el).attr('rel')).html();$('#photooverlaycontent').html(overlay);$('#photooverlaycontent ul li:nth-child(3n)').css('clear','right');this.t=setTimeout(function(){$('#photooverlay').show("slide",{direction:"up"},800);},400);},hideOverlay:function(){setTimeout(function(){if(overlays.overlayenabled==false){$('#photooverlay').fadeOut(150);}},500);}};function validateForm(form){var valid=true;$('label').removeClass('red');$('input.required',form).each(function(){if($(this).val()==''){var id=$(this).attr('id');$('label[for='+id+']').addClass('red');valid=false;}});$('select.required',form).each(function(){if($(this).val()==''){var id=$(this).attr('id');$('label[for='+id+']').addClass('red');valid=false;}});if(!valid){alert('Please complete all required fields.');return false;}
return true;}
$(document).ready(function(){$("#s").bind('focus',function(){$(this).removeClass('search');}).bind('blur',function(){if($(this).val()==""){$(this).addClass('search');}});$('a[rel=webchat]').bind('click',function(event){event.preventDefault();this.newWindow=window.open('http://webim.beachcombertours.co.uk/client.php?locale=en&amp;url='+escape(document.location.href)+'&amp;referrer='+escape(document.referrer),'webim','toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1');this.newWindow.focus();this.newWindow.opener=window;return false;});$('#s').addClass('search').val('');});;var count=0;var init=false;var map=false;var hotel_id=0;var imageheight=false;var hotels={getcoords:function(hotelid){switch(parseInt(hotelid)){case 7:return hotels.royalpalm();case 8:return hotels.paradis();case 12:return hotels.sainteanne();case 26:return hotels.dinarobin();case 36:return hotels.shandrani();case 37:return hotels.trouxauxbiches();case 38:return hotels.victoria();case 39:return hotels.canonnier();case 40:return hotels.mauricia();default:return[0,0];}},getcoordsbyregion:function(region){output=new Array();if(region=='mauritius'){output.push(hotels.royalpalm());output.push(hotels.paradis());output.push(hotels.dinarobin());output.push(hotels.shandrani());output.push(hotels.trouxauxbiches());output.push(hotels.victoria());output.push(hotels.canonnier());output.push(hotels.mauricia());}else{output.push(hotels.sainteanne());}
return output;},royalpalm:function(){return[-20.005708,57.579233,'Royal Palm Mauritius','Exceptional service at the best address in Mauritius'];},shandrani:function(){return[-20.445583,57.704525,'Shandrani Resort & Spa','The finest fully all-inclusive resort in Mauritius'];},canonnier:function(){return[-20.001622,57.553564,'Le Canonnier Hotel Mauritius','An idyllic setting on a historical peninsula'];},dinarobin:function(){return[-20.449894,57.315039,'Dinarobin Hotel Golf & Spa','An all-suite experience with a world class spa'];},paradis:function(){return[-20.436489,57.320625,'Paradis Hotel & Golf Club','The perfect blend of luxury and leisure'];},trouxauxbiches:function(){return[-20.030834,57.547255,'Trou Aux Biches','Pool suites set on a fantastic beach'];},victoria:function(){return[-20.075703,57.512833,'Le Victoria Hotel Mauritius','Spacious rooms and spectacular sunsets'];},mauricia:function(){return[-20.009297,57.580594,'Le Mauricia Hotel Mauritius','Right in the heart of lively Grand Baie'];},sainteanne:function(){return[-4.611883,55.498233,'Sainte Anne Resort & Spa','Private island experience with pool villas'];}};function initEarth(instance){init=true;var coords=hotels.getcoords(hotel_id);ge=instance;ge.getWindow().setVisibility(true);ge.getNavigationControl().setVisibility(false);ge.getOptions().setMouseNavigationEnabled(false);ge.getOptions().setFlyToSpeed(0.3);var la=ge.createLookAt('');la.set(coords[0],coords[1],0,ge.ALTITUDE_RELATIVE_TO_GROUND,107.7434445643967,48.94847219437366,939.7150181713223);ge.getView().setAbstractView(la);var placemark=ge.createPlacemark('');placemark.setName(coords[2]);google.earth.addEventListener(placemark,"click",function(event){event.preventDefault();});ge.getFeatures().appendChild(placemark);var icon=ge.createIcon('');icon.setHref('http://maps.google.com/mapfiles/kml/shapes/target.png');var style=ge.createStyle('');style.getIconStyle().setIcon(icon);placemark.setStyleSelector(style);var point=ge.createPoint('');point.setLatitude(coords[0]);point.setLongitude(coords[1]);placemark.setGeometry(point);google.earth.addEventListener(ge.getView(),'viewchangeend',viewCB);}
function moveCamera(){window.console.log('moving camera');var lookAt=ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);ge.getOptions().setFlyToSpeed(0.7);lookAt.setHeading(lookAt.getHeading()-180.1);ge.getView().setAbstractView(lookAt);}
function viewCB(){window.console.log('ended'+count);count++
if(count>2){google.earth.removeEventListener(ge.getView(),'viewchangeend',viewCB);ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);ge.getOptions().setMouseNavigationEnabled(true);}else{moveCamera();}}
function failureCB(errorCode){}
function createMap(hotel_id){var coords=hotels.getcoords(hotel_id);var centerCoord=new google.maps.LatLng(coords[0],coords[1]);var mapOptions={zoom:15,center:centerCoord,mapTypeId:google.maps.MapTypeId.SATELLITE};gmap=new google.maps.Map(document.getElementById("resortmap-map"),mapOptions);var marker=new google.maps.Marker({position:new google.maps.LatLng(coords[0],coords[1]),map:gmap,title:coords[2]});var infowindow=new google.maps.InfoWindow({content:"<h3 style=\"margin-bottom: 0\">"+coords[2]+"</h3><p style=\"margin-top: 0\">"+coords[3]+"</p>"});google.maps.event.addListener(marker,'click',function(){infowindow.open(gmap,marker);});map=true;}
function setupHotelMap(){if(!google.earth.isSupported()){$('#resortmapcontrols button.earth').remove();}else{$('#resortmapcontrols button.earth').bind('click',function(){$('#resortmapcontrols button').removeClass('active');$(this).addClass('active');hotel_id=$(this).attr('data-hotel');$('#resortmap>div').hide();$('#resortmap').animate({height:425},'fast');$('#resortmap-earth').show();if(!init){google.earth.createInstance('resortmap-earth',initEarth,failureCB);}});}
$('#resortmapcontrols button.plan').bind('click',function(){$('#resortmapcontrols button').removeClass('active');$(this).addClass('active');$('#resortmap>div').hide();$('#resortmap').animate({height:imageheight},'fast');$('#resortmap-plan').show();});$('#resortmapcontrols button.map').bind('click',function(){$('#resortmapcontrols button').removeClass('active');$(this).addClass('active');hotel_id=$(this).attr('data-hotel');$('#resortmap>div').hide();$('#resortmap').animate({height:425},'fast');$('#resortmap-map').show();if(!map){createMap(hotel_id);}});imageheight=$('#resortmap-plan img').height();$('#resortmap').animate({height:imageheight},'fast');}
function createRegionMap(region){if(region=='mauritius'){coords=[-20.25,57.55,9];}else{coords=[-4.67,55.47,11];}
var centerCoord=new google.maps.LatLng(coords[0],coords[1]);var mapOptions={zoom:coords[2],center:centerCoord,mapTypeId:google.maps.MapTypeId.ROADMAP,styles:[{featureType:'administrative.locality',elementType:'labels',stylers:[{visibility:'off'}]},{featureType:'roads',elementType:'labels',stylers:[{visibility:'off'}]},]};gmap=new google.maps.Map(document.getElementById("resortmap-map"),mapOptions);var points=hotels.getcoordsbyregion(region);for(var i=0;i<points.length;i++){var marker=new google.maps.Marker({position:new google.maps.LatLng(points[i][0],points[i][1]),map:gmap,title:points[i][2]});marker.infowindow=new google.maps.InfoWindow({content:"<h3 style=\"margin-bottom: 0\">"+points[i][2]+"</h3><p style=\"margin-top: 0\">"+points[i][3]+"</p>"});google.maps.event.addListener(marker,'click',function(){this.infowindow.open(gmap,this);});}
map=true;}
function initRegionMap(region){$('#resortmap-map').show();createRegionMap(region);};;(function($){$.fn.OfferScroller=function(settings){settings=jQuery.extend({pause:5000,duration:'slow',offerurl:'',url:''},settings);this.each(function(){function addControls(){var control=$("<div id=\"offer-control\" />").css({'width':w,'height':h});var previous=$("<a class=\"previous\"><span class=\"hidden\">&lt;</span></a>").css({'height':h,'cursor':'pointer'}).bind('click',function(){previousSlide();this.blur();return false;});control.append(previous);var next=$("<a class=\"next\"><span class=\"hidden\">&gt;</span></a>").css({'height':h,'cursor':'pointer'}).bind('click',function(){nextSlide();this.blur();return false;});control.append(next);obj.append(control).bind('mouseenter',enableControls).bind('mouseleave',disableControls);}
function enableControls(){clearTimeout(timeout);$('#offer-control').fadeIn("slow");}
function disableControls(){$('#offer-control').hide();timeout=setTimeout(function(){animate();},settings.pause);}
function nextSlide(){if((current+1)>count){showSlide(1);}else{showSlide(current+1);}}
function previousSlide(){if((current-1)<1){showSlide(count);}else{showSlide(current-1);}}
function showSlide(slide){if((!transition)&&(slide!=current)){transition=true;$("div.offer:nth-child("+current+")",obj).fadeOut(settings.duration,function(){$("div.offer:nth-child("+slide+")",obj).fadeIn(settings.duration,function(){current=slide;transition=false;});});}}
function animate(){nextSlide();timeout=setTimeout(function(){animate();},settings.pause);}
var obj=$(this);obj.width($('div.offer',obj).width());obj.height($('div.offer',obj).height());var w=$('div.offer img',obj).width();var h=$('div.offer img',obj).height();var count=0;var current=1;var transition=false;var timeout=false;if((settings.url!='')&&(settings.offerurl!='')){$.getJSON(settings.url,function(data){if(data.length>1){count=data.length;obj.empty();$.each(data,function(i,item){$("<div class=\"offer\" style=\"display: none;\"><img src=\"/images/offers/"+item.offer_id+"/offer-small.jpg\" width=\""+parseInt(w)+"\" height=\""+parseInt(h)+"\" alt=\""+item.offer_title+"\"><p><a href=\""+settings.offerurl+"#offer-"+item.offer_id+"\" class=\"arrow\">"+item.offer_title+"</a></p></div>").appendTo(obj);});$('div.offer:first',obj).show();addControls();timeout=setTimeout(function(){animate();},settings.pause);}});}});};})(jQuery);;;(function($){$.fn.PhotoScroller=function(settings){settings=jQuery.extend({pause:5000,duration:1500,easing:'easeOutCubic',url:''},settings);this.each(function(){var s=null;var w=null;var h=null;var ts=null;var t=0;function loopcheck(){if(t>ts)t=0;$("ul.photoscroller",obj).css("margin-left",(t*w*-1));timeout=setTimeout(function(){animate();},settings.pause);};function animate(){t++;p=(t*w*-1);$("ul.photoscroller",obj).animate({marginLeft:p},{queue:false,duration:settings.duration,easing:settings.easing,complete:loopcheck});};var obj=$(this);if(settings.url!=''){$.getJSON(settings.url,function(data){if(data.length>1){var ul=$("<ul class=\"photoscroller\"/>").prependTo(obj);$('img',obj).remove();$.each(data,function(i,item){if((typeof item.href=='undefined')||(item.href=='')){var src="<li><img src=\""+item.filename+"\"></li>";}else{var src="<li><a href=\""+item.href+"\"><img src=\""+item.filename+"\"></a></li>";}
$(src).appendTo(ul);});s=$("li",obj).length;w=$("li",obj).width();h=$("li",obj).height();ts=s-1;$("ul.photoscroller",obj).append($("ul.photoscroller li:first-child",obj).clone());$("ul.photoscroller",obj).css('width',(s+1)*w);$("ul.photoscroller li",obj).css('float','left');var timeout=setTimeout(function(){animate();},settings.pause);}});}});};})(jQuery);
