function toggleInternational() { $('ul#flaglist2, #fullOverlay').toggleClass('open'); } function setViewport() { if (document.querySelector) { var viewport = document.querySelector("meta[name=viewport]"); if (window.innerHeight >= window.innerWidth) { // portrait var w = screen.width; } else { // landscape var w = screen.height; } if (w > 1100) { contentWidth = 1100; } else { var contentWidth = (((w+50)/100)|0) * 100; if (contentWidth < 400) { contentWidth = 400; } } viewport.setAttribute('content', 'width='+contentWidth+', initial-scale='+(w/contentWidth)); // device width/content width document.body.style.backgroundColor = document.body.style.backgroundColor; // forces full screen redraw. (iOS has problems with clearing the frame buffer when changing content width on orientationchange) } } function addToCart(addURL, redirectURL) { $.ajax({ url:addURL, context:document.body }).done(function(data, textStatus, jqXHR) { window.location.href = redirectURL; }).fail(function( jqXHR, textStatus, errorThrown ) { window.location.href = redirectURL; // go to redirect url on fail anyway }); } function setupNavTrigger() { var trigger = document.getElementById('trigger'); var topnav = document.getElementById('topnav'); $(trigger).on('click', function() { $(topnav).toggleClass('open'); }); } $(function() { if (window.addEventListener) { setViewport(); window.addEventListener('orientationchange', setViewport); } setupNavTrigger(); });