//promo start/end date
var startDate = isDateBeforeToday(new Date("Fri Feb 16 2023"));
var endDate = isDateAfterToday(new Date("Thu Feb 29 2023"));
//get url to check language
var url = location.href;
var id = '<%= product.mpn %>';
var repo = document.getElementById("repo").getAttribute("flag");
//mpn cashback $300
var prod0 = "4147C002";
var prod1 = "4147C002R";
var prod2 = "5077C002";
//mpn cashback $500
var prod3 = "4895C002";
//mpn free course
var prod4 = "3380C132";
var prod5 = "3380C002";
var prod6 = "5803C002";
var prod7 = "5803C012";
var prod8 = "5137C002";
var prod9 = "5137C002B";
var prod10 = "5137C009";
var prod11 = "5137C009B";
var prod12 = "5331C002";
var prod13 = "5331C009";
var prod14 = "5811C012";
var prod15 = "6052C012";
//mpn free battery
var prod16 = "5666C002";
var prod17 = "5666C002S";
var prod18 = "5666C018";
var prod19 = "5666C018S";
function isDateBeforeToday(date) {
return new Date(date.toDateString()) < new Date(new Date().toDateString());
}
function isDateAfterToday(date) {
return new Date(date.toDateString()) > new Date(new Date().toDateString());
}
if (startDate && endDate) {
if (repo == "on") {
if (id == prod0 || id == prod1 || id == prod2) {
canonCashback300();
}
else if (id == prod3) {
canonCashback500();
}
else if (id == prod4 || id == prod5 || id == prod6 || id == prod7 || id == prod8 || id == prod9 || id == prod10 || id == prod11 || id == prod12 || id == prod13 || id == prod14 || id == prod15) {
canonFreeClass();
}
else if (id == prod16 || id == prod17 || id == prod18 || id == prod19) {
canonFreeBattery();
}
}
}
//create image element
function canonCashback300 () {
var elem = document.createElement("img");
if (url.toString().includes("magasin")) {
elem.setAttribute("src", "https://irp.cdn-website.com/14aefc77/dms3rep/multi/canon-cashback-badge-300.png");
}
else {
elem.setAttribute("src", "https://irp.cdn-website.com/14aefc77/dms3rep/multi/canon-cashback-badge-300.png");
}
elem.setAttribute("height", "188");
elem.setAttribute("width", "200");
elem.setAttribute("alt", "Canon Promo Badge");
elem.setAttribute("class", "canonPromoBadge");
document.getElementsByClassName("dakis-product-images")[0].appendChild(elem);
document.getElementById("demo").setAttribute("repo", "off");
}
function canonCashback500 () {
var elem = document.createElement("img");
if (url.toString().includes("magasin")) {
elem.setAttribute("src", "https://irp.cdn-website.com/14aefc77/dms3rep/multi/canon-cashback-badge-500.png");
}
else {
elem.setAttribute("src", "https://irp.cdn-website.com/14aefc77/dms3rep/multi/canon-cashback-badge-500.png");
}
elem.setAttribute("height", "188");
elem.setAttribute("width", "200");
elem.setAttribute("alt", "Canon Promo Badge");
elem.setAttribute("class", "canonPromoBadge");
document.getElementsByClassName("dakis-product-images")[0].appendChild(elem);
document.getElementById("demo").setAttribute("repo", "off");
}
function canonFreeClass () {
var elem = document.createElement("img");
if (url.toString().includes("magasin")) {
elem.setAttribute("src", "https://irp.cdn-website.com/14aefc77/dms3rep/multi/canon-course-badge-fr.png");
}
else {
elem.setAttribute("src", "https://irp.cdn-website.com/14aefc77/dms3rep/multi/canon-course-badge-fr.png");
}
elem.setAttribute("height", "200");
elem.setAttribute("width", "250");
elem.setAttribute("alt", "Canon Promo Badge");
elem.setAttribute("class", "canonPromoBadge");
document.getElementsByClassName("dakis-product-images")[0].appendChild(elem);
document.getElementById("demo").setAttribute("repo", "off");
}
function canonFreeBattery () {
var elem = document.createElement("img");
if (url.toString().includes("magasin")) {
elem.setAttribute("src", "https://irp.cdn-website.com/14aefc77/dms3rep/multi/canon-battery-badge-fr.png");
}
else {
elem.setAttribute("src", "https://irp.cdn-website.com/14aefc77/dms3rep/multi/canon-battery-badge-fr.png");
}
elem.setAttribute("height", "200");
elem.setAttribute("width", "250");
elem.setAttribute("alt", "Canon Promo Badge");
elem.setAttribute("class", "canonPromoBadge");
document.getElementsByClassName("dakis-product-images")[0].appendChild(elem);
document.getElementById("demo").setAttribute("repo", "off");
}