window.onclick = function (e) { window.onclick = null; hideCoupon(e); } var tc=window.setTimeout(dealerOnCouponLunch, 500); function dealerOnCouponLunch(){ var launcherTop = '25%'; if(DlronGlobal_TemplateVersion==4){ launcherTop = '5%'; } $('
', {'id': 'dealerOnCoupon'}).appendTo('body'); $("#dealerOnCoupon").css({ 'position':'absolute', 'top':launcherTop, 'left':'25%', 'backgroundColor':'#fff', 'fontFamily':'Frutiger,Verdana,Arial', 'z-index':'99999', 'cursor':'move' }); $('#dealerOnCoupon').draggable(); updateCouponBox(); document.querySelector("body").dispatchEvent(new CustomEvent("couponLoaded")); } function updateCouponBox() { var urlPrefix = (typeof DealeronDealerGenericUrl === 'undefined' ? '' : DealeronDealerGenericUrl); var url = urlPrefix + '/coupon/eas/launcher.aspx'; try { $.get(url, function (data) { if (data.length > 0) { $('#dealerOnCoupon').html(data); addCouponBoxEvents(); } else { $('#dealerOnCoupon').remove(); } }); } catch (err) { $('#dealerOnCoupon').remove(); } } function addCouponBoxEvents() { $('#couponOfferButton').bind('click', function() { $('#couponOfferButton').unbind('click'); window.onclick = null; openCoupon(); }); $('#couponOfferButtonNissan').bind('click', function() { $('#couponOfferButtonNissan').unbind('click'); window.onclick = null; openCoupon(); }); $('#couponClose').bind('click', function(event) { $('#couponClose').unbind('click'); hideCoupon(event); }); $('#couponCloseButton').bind('click', function(event) { $('#couponCloseButton').unbind('click'); hideCoupon(event); }); var tmpElm= $('#couponOffers h1'); var charLength = tmpElm.html().length; if ( (charLength >= 15 && charLength < 20 )) tmpElm.css('fontSize','28px'); else if ( (charLength >= 20 && charLength < 35 )) tmpElm.css('fontSize','26px'); else if ( (charLength >= 35)) tmpElm.css('fontSize','20px'); tmpElm= $('#couponOffers h3'); charLength = tmpElm.html().length; if ( (charLength >= 18 && charLength < 40 )) tmpElm.css({'fontSize':'12px','fontWeight':'bold'}); else if ( (charLength >= 40)) tmpElm.css({'fontSize':'16px','fontWeight':'bold'}); tmpElm= $('#couponOffers .couponOfferExp'); charLength = tmpElm.html().length; if ( (charLength >= 101 && charLength < 160 )) tmpElm.css('fontSize','12px'); else if ( (charLength >= 160)) tmpElm.css('fontSize','10px'); tmpElm= $('#couponOffers .couponCertificate'); charLength = tmpElm.html().length; if ( (charLength >= 30 && charLength < 100 )) tmpElm.css('fontSize','16px'); else if ( (charLength >= 100 && charLength < 130 )) tmpElm.css('fontSize','14px'); else if ( (charLength >= 130 && charLength < 160 )) tmpElm.css('fontSize','12px'); else if ( (charLength >= 160)) tmpElm.css('fontSize','10px'); } function openCoupon(){ var screen_width = window.screen.availWidth; var screen_height = window.screen.availHeight; var left_point = parseInt(screen_width/2)-(445); var top_point = parseInt(screen_height / 2) - (320); if (window.chrome) { var generatorC = window.open('/coupon/eas/', 'EAS', 'toolbar=no,location=no,directories=no,status=1,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,height=700,width=840'); } else { var generator = window.open('/coupon/eas/', 'EAS', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,height=700,width=840'); generator.moveTo(left_point, top_point); } $('#dealerOnCoupon').remove(); } function hideCoupon(e) { e.preventDefault(); var href = e.target.getAttribute("href"); var targetPage = href || document.location; if(nothxid==2){ $('#dealerOnCoupon').remove(); } else if(nothxid==3){ $('#dealerOnCoupon').remove(); easStatus = 1; createCouponFloater(); } else { var is_safari = /safari/.test(navigator.userAgent.toLowerCase()); var browser_version = navigator.userAgent.substr(navigator.userAgent.lastIndexOf('Version/') + 8, 3); if(is_safari && browser_version > 6.0){ if(!window.isCouponOpened){ var a = document.createElement("a"); a.href = targetPage; document.location.href = '/coupon/eas' var evt = document.createEvent("MouseEvents"); if(navigator.userAgent.indexOf('Mac OS X') != -1) { // Simulate meta btn (between leftctrl and alt) + click evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0,false, false, false, true, 0, null); } else { // Simulate ctrl+click evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0,true, false, false, false, 0, null); } a.dispatchEvent(evt); $('#dealerOnCoupon').remove(); window.isCouponOpened = true; } } else{ var screen_width = window.screen.availWidth; var screen_height = window.screen.availHeight; var left_point = parseInt(screen_width/2)-(445); var top_point = parseInt(screen_height / 2) - (320); if (window.chrome) { var generatorC = window.open('/coupon/eas/', 'EAS', 'toolbar=no,location=no,directories=no,status=1,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,height=700,width=840'); window.setTimeout(window.focus, 500); generatorC.blur(); window.open("", "_self", ""); $('#dealerOnCoupon').remove(); $('#back_overlay').remove(); } else { var generator = window.open('/coupon/eas/', 'EAS', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,height=700,width=840'); if (window.opera) { $('#dealerOnCoupon').remove(); $('#back_overlay').remove(); generator.moveTo(left_point, top_point); window.focus(); } else { window.setTimeout(window.focus, 500); generator.blur(); window.open("", "_self", ""); $('#dealerOnCoupon').remove(); $('#back_overlay').remove(); } } } } }