$(document).ready(function(){ var theHost = window.location.host; var windowWidth = $(window).width(); var windowHeight = $(window).height(); var isiPad = false; var isTouch = is_touch_device(); var isPortrait = false; if (windowHeight>windowWidth){ isPortrait = true; } function is_touch_device() { return !!('ontouchstart' in window) || !!('onmsgesturechange' in window); }; if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i)) { var viewportmeta = document.querySelector('meta[name="viewport"]'); if (viewportmeta) { viewportmeta.content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0'; document.body.addEventListener('gesturestart', function () { viewportmeta.content = 'width=device-width, minimum-scale=0.25, maximum-scale=1.6'; }, false); } var supportsOrientationChange = "onorientationchange" in window, orientationEvent = supportsOrientationChange ? "orientationchange" : "resize"; window.addEventListener(orientationEvent, function() { window.location.reload() }, false); isiPad = true; } // Amends for small screens < 600px if(windowWidth<601){ if($(".mag_nav").length){ $(".mag_next p").html("Next"); $(".mag_prev p").html("Previous"); } if($(".subtext").length){ $moveText = $(".subtext").html(); $moveText = "

"+$moveText+"

"; $(".subtext").remove(); if($(".mag_article_content").length){ $(".mag_article_content").first().before($moveText); } } if($(".subtitle").length){ $moveText = $(".subtitle").html(); $moveText = "

"+$moveText+"

"; $(".subtitle").remove(); if($(".mag_article_content").length){ $(".mag_article_content").first().before($moveText); } } if($(".mobile-move").length){ $(".mobile-move").each(function(){ $moveImg = $(this).html(); $(this).remove(); $(".halfinner").closest().before($moveImg); }); } } // Rapide S if($("#rapide").length){ $("#mag_big_pic").click(function(){ $("#mag_big_pic").fadeOut("slow", function(){ $("#mag_draggable_pic").fadeIn("slow", function(){ whereHead = $("#mag_draggable_pic").position(); whereHead = whereHead.top; $('html:not(:animated),body:not(:animated)').animate({scrollTop: whereHead },'fast'); }); }); }); } // Set up image gallery captions if($(".hideme").length){ $(".hideme").each(function(){ $(this).closest('li').append("
"); $(this).parent().fadeOut(0, function() { $(".showme").click(function(){ $(this).parent('li').find('div').fadeIn('fast'); $(this).closest(".showme").remove(); }); }); }); $(".hideme").click(function(){ $(this).closest('li').append("
"); $(this).parent().fadeOut('fast', function(){ $(".showme").click(function(){ $(this).parent('li').find('div').fadeIn('fast'); $(this).remove(); }); }); }); } // Pages var pageArray=["index.html", "feature-news-intro.html","feature-happy-birthday.html","feature-special-delivery.html","feature-uk-news.html","feature-europe-news.html","feature-me-news.html","feature-americas-news.html","feature-asia-pacific-news.html","feature-racing-season.html","feature-hindmarch.html","feature-drive.html","feature-photo-story.html","feature-new-kid-on-the-block.html","feature-timeline.html","feature-design.html","feature-street-fighting-man.html","feature-a-knights-tale.html","feature-objects.html","feature-portfolio.html","feature-works.html","feature-big-question.html"]; // Current page var urlname = window.location.pathname; var index = urlname.lastIndexOf("/") + 1; var filename = urlname.substr(index); if(filename != ""){ whichPage = $.inArray(filename, pageArray); // Show Ads adServed = localStorage.getItem("adsServed"); }else{ whichPage = 0; } howManyPages = (pageArray.length)-1; $(".mag_next").click(function(){ if (whichPage < howManyPages){ newPage=pageArray[whichPage+1]; }else{ newPage=pageArray[0]; }  window.location.assign(newPage); }); $(".mag_prev").click(function(){ if (whichPage > 0){ newPage=pageArray[whichPage-1]; }else{ newPage=pageArray[howManyPages]; }  window.location.assign(newPage); }); $(".contents_button").click(function(){ if ($(".contentsMenu").is(':visible')) { $(".contentsMenu").fadeOut('slow'); }else{ $(".contentsMenu").fadeIn('slow'); } }); // Figs (Rapide feature) $(".figpoint").click(function () { var thisFig = ($(".figpoint").index(this))+1; if($('#fig'+thisFig).hasClass("clicked")){ $('#fig'+thisFig).fadeOut('slow', function() { $('#fig'+thisFig).removeClass("clicked"); }); }else{ $('#fig'+thisFig).fadeIn('slow', function() { $('#fig'+thisFig).addClass("clicked"); }); } }); // Accordion if($(".expandable").length){ $(".expandable").each(function() { $(this).css('background-image', 'url(images/accordian_plus.gif' + ')'); $(this).next().slideUp('normal'); }); } $(".expandable").click(function() { removeTab = $(".expandable").outerHeight(); $(".expandable").each(function() { $(this).css('background-image', 'url(images/accordian_plus.gif' + ')'); $(this).next().slideUp('normal'); if($("#timeline").length){ $(this).fadeIn('fast'); } }); if ($(this).next().is(':visible')) { $(this).css('background-image', 'url(images/accordian_plus.gif' + ')'); $(this).next().slideUp('normal'); }else { $(this).css('background-image', 'url(images/accordian_minus.gif' + ')'); if($("#timeline").length){ $(this).fadeOut('slow'); } // $(this).next().slideDown('normal'); $(this).next().slideDown('slow', function() { var whereHead = $(this).position(); whereHead = (whereHead.top)+(removeTab*1.2); $('html:not(:animated),body:not(:animated)').animate({scrollTop: whereHead },'fast'); }); } }); $("#mag_draggable_pic_img_container").draggable({ drag: function(event, ui) { if(ui.position.top>0) { ui.position.top = 0; } var maxtop = ui.helper.parent().height()-ui.helper.height(); if(ui.position.top0) { ui.position.left = 0; } var maxleft = ui.helper.parent().width()-ui.helper.width(); if(ui.position.left

Click here to continue to article

"); }else if(adFlip == "1"){ $("body").append("

Click here to continue to article

"); }else if(adFlip == "2"){ $("body").append("

Click here to continue to article

"); }else if(adFlip == "3"){ $("body").append("

Click here to continue to article

"); } fullHeight =$("body").outerHeight(); $("#adoverlay").css("height",fullHeight); if(!isiPad){ if(isPortrait){ $("#adoverlay img").css("width",windowWidth); $("#adoverlay img").css("height","auto"); }else{ $("#adoverlay img").css("height",windowHeight); $("#adoverlay img").css("width","auto"); } }else{ $("#adoverlay img").css("height",windowHeight); $("#adoverlay img").css("width","auto"); } var imageShowing = false; if(isPortrait){ if(adFlip == "0"){ $("#adoverlay img").attr("src","images/ads/perAquum_portrait.jpg"); $("#adoverlay, #adoverlay div").css("background-color","#000"); }else if(adFlip == "1"){ $("#adoverlay img").attr("src","images/ads/JLC_AstonMartin_PortraitAd.jpg"); $("#adoverlay, #adoverlay div").css("background-color","#000"); }else if(adFlip == "2"){ $("#adoverlay img").attr("src","images/ads/macallan_ad_portrait.jpg"); $("#adoverlay, #adoverlay div").css("background-color","#FFF"); }else if(adFlip == "3"){ $("#adoverlay img").attr("src","images/ads/johnlobb_ad_portrait.jpg"); $("#adoverlay, #adoverlay div").css("background-color","#000"); } }else{ if(adFlip == "0"){ $("#adoverlay img").attr("src","images/ads/perAquum_landscape.jpg"); $("#adoverlay, #adoverlay div").css("background-color","#000"); }else if(adFlip == "1"){ $("#adoverlay img").attr("src","images/ads/JLC_AstonMartin_LandscapeAd.jpg"); $("#adoverlay").css("background-color","#000"); }else if(adFlip == "2"){ $("#adoverlay img").attr("src","images/ads/macallan_ad_landscape.jpg"); $("#adoverlay").css("background-color","#FFF"); }else if(adFlip == "3"){ $("#adoverlay img").attr("src","images/ads/johnlobb_ad_landscape.jpg"); $("#adoverlay").css("background-color","#000"); } } $("#adoverlay").fadeIn('slow', function(){ imageShowing = true; // Timed ad fadeout setInterval(function(){$("#adoverlay div p").click()},4000); whereAd= $("html").scrollTop(); adHeight =$("#adoverlay div img").outerHeight(); var scrollAmount = 0; if(windowHeighttheDifference){ $('html:not(:animated),body:not(:animated)').animate({scrollTop: theDifference },0); } }); }else{ $("body").css("overflow", "hidden"); } }); $("#adoverlay div p").click(function(){ $("#adoverlay").fadeOut('slow'); imageShowing = false; theDifference = fullHeight; $("body").css("overflow", "auto"); }); } $(window).load(function() { // Set local storage for Ad serving if (Modernizr.localstorage) { function countVisits(){ // Set number of page views inbetween displaying ads clickThroughs = 7; str_count = localStorage.getItem("count"); adServe = localStorage.getItem("adsServed"); if (str_count == null || str_count == "null"){ count = 0; adServe = 0; localStorage.setItem("adsServed", adServe); } else { visited = true; count = parseInt(str_count); adFlip = localStorage.getItem("adsServed"); localStorage.setItem("adsServed", adFlip); } count++; pageView = count%clickThroughs; localStorage.setItem("count",count); if ((pageView == 0)&&(visited=true)){ count = 0; if(adFlip<3){ adFlip++; }else{ adFlip=0; } localStorage.setItem("adsServed", adFlip); launchAd(adFlip); } } countVisits(); } // Front Page var h = 1000; var w = 545; var ratio = h / w; var counter = 1; var howManyImages = $("#mag_article li").length; thisWidth = $("#mag_featured_articles").outerWidth(); frameWidth=thisWidth; totalWidth = thisWidth*howManyImages; proportionateHeight = (Math.round(thisWidth / ratio)); $("#mag_article").css("width",totalWidth); $("#mag_article li").css("width",thisWidth); $("#mag_featured_articles, #mag_article li").css("height",proportionateHeight); if(isiPad){ fixWidth = thisWidth*1.2; $("#mag_article li").css("background-size",fixWidth); }else{ $("#mag_article li").css("background-size",thisWidth); } $("#mag_nav_right").click(function(){ if(counter1){ thisWidth += frameWidth; } counter++; $("#mag_article").animate({ "left": -thisWidth }, 600); }else{ counter = 1; thisWidth = $("#mag_featured_articles").outerWidth(); $("#mag_article").animate({ "left": 0 }, 600); } }); $("#mag_nav_left").click(function(){ if(counter>1){ thisWidth -= frameWidth; counter --; $("#mag_article").animate({ "left": -thisWidth }, 600); }else{ counter = howManyImages; thisWidth = totalWidth - frameWidth; $("#mag_article").animate({ "left": -thisWidth }, 600); } }); if($("#mag_top_images_left").length){ theHeight = $("#mag_top_images_right img").first().outerHeight(); $("#mag_top_images_right").css("height",theHeight); $("#mag_top_images_left").css("height",theHeight); circleHeight = $("#mag_top_images_left div").outerHeight(); circleHeight = Math.round((circleHeight/100)*20); $("#mag_top_images_left div h2").css("padding-top",circleHeight); $("#mag_top_images_left").css("visibility","visible"); offSet = Math.round((theHeight/100)*10); } if($("#mag_top_images_left_alt").length){ theHeight = $("#mag_top_images_right img").first().outerHeight(); $("#mag_top_images_right").css("height",theHeight); $("#mag_top_images_left_alt").css("height",theHeight); circleHeight = $("#mag_top_images_left_alt div").outerHeight(); circleHeight = Math.round((circleHeight/100)*20); $("#mag_top_images_left_alt div h2").css("padding-top",circleHeight); $("#mag_top_images_left_alt").css("visibility","visible"); offSet = Math.round((theHeight/100)*10); } // Article Gallery if($("#mag_top_images_right_nav").length){ var counter = 1; var howManyImages = $("#mag_top_images_right li").length; thisHeight = $("#mag_top_images_right li").first().outerHeight(); originalHeight = thisHeight; $("#mag_top_images_right").click(function(){ if(counter1){ thisHeight += originalHeight; } counter++; $("#mag_top_images_right ul").animate({ "top": -thisHeight }, 600); }else{ counter = 1; thisHeight = originalHeight; $("#mag_top_images_right ul").animate({ "top": 0 }, 600); } }); } // Vertical Gallery if($("#vertical_gallery").length){ theHeight = $("#vertical_gallery_right img").first().outerHeight(); theWidth = $("#vertical_gallery_right img").first().outerWidth(); $("#vertical_gallery_left").css("height",theHeight); $("#vertical_gallery_left").css("width",theWidth); $("#vertical_gallery_left ul").css("width",theWidth); $("#vertical_gallery_left").css("visibility","visible"); offSet = Math.round((theHeight/100)*10); var counter = 1; var howManyImages = $("#vertical_gallery_left li").length; thisHeight = $("#vertical_gallery_left li").first().outerHeight(); originalHeight = thisHeight; if(windowWidth<601){ if($("#vertical_gallery").length){ theRightSide = $("#vertical_gallery_right").html(); theRightSide = ""; $("#vertical_gallery_right").remove(); $("#vertical_gallery").prepend(theRightSide); } } if($("#the_drive").length){ var theDriveArray=["a Paris landmark displays its evening magic", "Alessandro Sartori, creative director of Berluti’s new menswear range","classic bespoke cloth from Parisian tailor Lorenzo Citronelli","stylish Italian loafers from Milanese outfitter Rubinetti"]; } $("#dynamic_fig").html("Left: "+theDriveArray[0]); $("#vertical_gallery_left").click(function(){ if(counter1){ thisHeight += originalHeight; } counter++; $("#vertical_gallery_left ul").animate({ "top": -thisHeight }, 600); }else{ counter = 1; thisHeight = originalHeight; $("#vertical_gallery_left ul").animate({ "top": 0 }, 600); } if($("#dynamic_fig").length){ whichCaption = theDriveArray[counter-1]; $("#dynamic_fig").fadeOut("slow", function(){ $("#dynamic_fig").html("Left: "+whichCaption); $("#dynamic_fig").fadeIn("fast"); }); } }); } if($('#mag_nav_left, #mag_gallery_nav_left').length){ if(!isiPad){ $('#mag_featured_articles').hover( function() { $("#mag_nav_left, #mag_nav_right").animate({backgroundColor: 'rgba(255,255,255,0.7)'}); }, function () { $("#mag_nav_left, #mag_nav_right").animate({backgroundColor:'transparent'}, 100); }); $('#mag_gallery_items').hover( function() { $("#mag_gallery_nav_left, #mag_gallery_nav_right").animate({backgroundColor: 'rgba(255,255,255,0.7)'}); }, function () { $("#mag_gallery_nav_left, #mag_gallery_nav_right").animate({backgroundColor:'transparent'}, 100); }); } } // Photo Gallery if($("#mag_gallery_items").length){ var imgSrc = $("#mag_gallery li").first().css('background-image').replace('url(', '').replace(')', '').replace("'", '').replace('"', ''); imgSrc=imgSrc.replace('"',''); var imgHeight = 0; var imgWidth = 0; function getImgSize(imgSrc) { var newImg = new Image(); newImg.onload = function() { imgHeight = newImg.height; imgWidth = newImg.width; setGallery(imgHeight, imgWidth); } newImg.src = imgSrc; } getImgSize(imgSrc); function setGallery(h, w){ if(isiPad){ h = h*1.2; } var ratio = w / h; var counter = 1; var howManyPhotos = $("#mag_gallery li").length; var thisWidth = $("#mag_gallery_items").outerWidth(); frameWidth=thisWidth; totalWidth = thisWidth*howManyPhotos; proportionateHeight = (Math.round(thisWidth / ratio)); $("#mag_gallery li").css("width",thisWidth); if(windowWidth>600){ $("#mag_gallery").css("width",totalWidth); $("#mag_gallery_items").css("height",proportionateHeight); }else{ $("li div").each(function(){ divReplace = $(this).html(); $(this).closest('li').after("
  • "+divReplace+"
  • "); $(this).remove(); }); } $("#mag_gallery li.photoLi").css("height",proportionateHeight); if(isiPad){ fixWidth = thisWidth*1.2; $("#mag_gallery li.photoLi").css("background-size",fixWidth); }else{ $("#mag_gallery li.photoLi").css("background-size",thisWidth); } $("#mag_gallery_items").after("

    No. 1 of "+howManyPhotos+" Images

    "); $("#mag_gallery_nav_right").click(function(){ if(counter1){ thisWidth += frameWidth; } counter++; $("#mag_gallery").animate({ "left": -thisWidth }, 600); }else{ counter = 1; thisWidth = $("#mag_gallery_items").outerWidth(); $("#mag_gallery").animate({ "left": 0 }, 600); } $("#currentImage").text(counter); }); $("#mag_gallery_nav_left").click(function(){ if(counter>1){ thisWidth -= frameWidth; counter --; $("#mag_gallery").animate({ "left": -thisWidth }, 600); }else{ counter = howManyPhotos; thisWidth = totalWidth - frameWidth; $("#mag_gallery").animate({ "left": -thisWidth }, 600); } $("#currentImage").text(counter); }); } } // Set draggable initial position if($("#mag_draggable_pic_img_container").length){ bigPicPos = $("#mag_draggable_pic_img_container").position(); bigPicY = bigPicPos.top; bigPicH = $("#mag_draggable_pic_img_container").outerHeight(); bigPicW = $("#mag_draggable_pic_img_container").outerWidth(); bigPicParentH = $("#mag_draggable_pic_img_container").parent().outerHeight(); $("#mag_draggable_pic_img_container").css("top","-450px"); xPos = bigPicW/4; $("#mag_draggable_pic_img_container").offset({left: -xPos}); } //Reveal if($(".reveal").length){ var imgSrc = $(".sprev1").css('background-image').replace('url(', '').replace(')', '').replace("'", '').replace('"', ''); imgSrc=imgSrc.replace('"',''); var imgHeight = 0; var imgWidth = 0; function getRevSize(imgSrc) { var newImg = new Image(); newImg.onload = function() { imgHeight = newImg.height; imgWidth = newImg.width; setReveal(imgHeight, imgWidth); } newImg.src = imgSrc; } getRevSize(imgSrc); function setReveal(h,w){ // var h = 1000; // var w = 727; var ratio = w / h; thisWidth = $(".reveal").outerWidth(); proportionateHeight = (Math.round(thisWidth / ratio)); $(".reveal").css("height",proportionateHeight); $(".reveal div").css("height",proportionateHeight); var wrapper = $("div.reveal"); $("div.reveal").find('div').width("25%"); if(isTouch){ wrapper.bind('touchstart', function(e) { if ($("#tooltip").is(':visible')) { $("#tooltip").fadeOut("slow"); } var xPos = e.originalEvent.touches[0].pageX; $(this).data("sliding", true); var offs = xPos - $(this).offset().left; $(this).find('div').width(offs); }); $("div.reveal").bind('touchmove', function(jQueryEvent) { jQueryEvent.preventDefault(); var event = window.event; xPos = event.touches[0].pageX; var offs = xPos - $(this).offset().left $(this).find('div').width(offs); }); wrapper.bind('touchend', function(e) { wrapper.data("sliding", false); }); }else{ wrapper.mouseover(function(e) { $(this).data("sliding", true); var offs = e.pageX - $(this).offset().left; $(this).find('div').width(offs); }).mousemove(function(e) { if ($("#tooltip").is(':visible')) { $("#tooltip").fadeOut("slow"); } if ($(this).data("sliding")) { var offs = e.pageX - $(this).offset().left $(this).find('div').width(offs); } }); $(document).mouseout(function(e) { wrapper.data("sliding", false); }); } } } // Fix Widows if(windowWidth>600){ $("h2").widowFix(); $(".subtitle").widowFix(); $(".photo_fig").widowFix(); $(".contentsh3").widowFix(); } // Drive Map if($("#map_canvas").length){ var london = new google.maps.LatLng(47.398349,5.141602); var myOptions = { zoom: 5, center: london, mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); var geoXml = new geoXML3.parser({map: map, singleInfoWindow: true}); geoXml.parse('thedrive_map.kml'); } }); });