/* updated */ if (typeof hideInlineMPU == "undefined") { var cssId = 'storypromocss'; // you could encode the css path itself to generate id.. if (!document.getElementById(cssId)) { var head = document.getElementsByTagName('head')[0]; var link = document.createElement('link'); link.id = cssId; link.rel = 'stylesheet'; link.type = 'text/css'; link.href = 'http://www.cnnewmedia.co.uk/storypromo/css/storypromo.css'; link.media = 'all'; head.appendChild(link); } var jsonValues = {"par":"45","title":"More News & Star articles...","values":[{"title":"Man dies after falling from bridge on the M6 near Carlisle","link":"http:\/\/www.newsandstar.co.uk\/news\/Man-dies-after-falling-from-bridge-on-the-M6-near-Carlisle-d7c04fb5-f473-49a8-9abe-51b62e3bc0da-ds","image":"25023477-c7e2-4ee0-b389-185778006c99","imageCrop":[]},{"title":"Ex-Bradford City footballer jailed for attempted knifepoint robbery in Carlisle","link":"http:\/\/www.newsandstar.co.uk\/news\/Ex-Bradford-City-footballer-jailed-for-attempted-knifepoint-robbery-at-Sainsburys-in-Carlisle-162112fa-a5d9-4bb8-8a7e-eea35c9fc65f-ds","image":"63714d83-9166-4f9b-9dc6-39ba11c73b90","imageCrop":{"targetX0":"0","targetX1":"100","targetY0":"5.96","targetY1":"94.04"}},{"title":"Two arrested after five horses die in barn fire","link":"http:\/\/www.newsandstar.co.uk\/news\/Two-men-arrested-on-suspicion-of-arson-after-Distington-barn-fire-acee3bb8-14d2-4deb-a5ca-6d74959032d7-ds","image":"64ae1460-445c-4176-8b9a-41cffbbad9ee","imageCrop":[]},{"title":"Roadworks warning for motorists as closures affect A66 and A69 in Cumbria","link":"http:\/\/www.newsandstar.co.uk\/news\/Roadworks-warning-for-motorists-as-closures-affect-A66-and-A69-in-Cumbria-d1b92d1e-e506-4708-b371-c08c340dece8-ds","image":"9580b70a-a6b6-40ac-bc11-d8a8e8d22b8b","imageCrop":[]},{"title":"Man, 19, arrested after woman sexually assaulted in Carlisle","link":"http:\/\/www.newsandstar.co.uk\/news\/Man-19-arrested-after-woman-sexually-assaulted-in-Carlisle-ef14ee15-7fbd-4c87-b939-fa1611f2d0d4-ds","image":"e8d02bc6-ef51-446a-b2d0-875b8de61696","imageCrop":{"targetX0":"4.17","targetX1":"95.83","targetY0":"0","targetY1":"100"}},{"title":"Carlisle slimmer who has lost almost seven stones in 18 months tells her story","link":"http:\/\/www.newsandstar.co.uk\/news\/Carlisle-slimmer-who-has-lost-almost-seven-stones-in-18-months-tells-her-story-504941d3-cc18-4f75-9f9d-3e402075f99a-ds","image":"9f6dcda8-8395-4991-b5f3-ccbe32d0a1f0","imageCrop":{"targetX0":"11","targetX1":"81","targetY0":"12.75","targetY1":"37.38"}}]}; var insertAfter = jsonValues.par; var promotitlediv = document.getElementById("storypromotitle"); promotitlediv.innerHTML = jsonValues.title; var promodiv = document.getElementById("storypromo"); var promoarticleslist = document.getElementById("storypromoarticleslist"); var storyPromoSliderDiv = document.createElement("div"); storyPromoSliderDiv.setAttribute("id", "storypromo-slider"); promodiv.appendChild(storyPromoSliderDiv); storyPromoSliderDiv.setAttribute("class", "owl-carousel owl-theme"); if (jsonValues.values.length == 0) promodiv.style.display = "none"; else { for (x = 0; x < jsonValues.values.length; x++) { var listitem = document.createElement("div") listitem.setAttribute("class", "item storypromo"); var linkdiv = document.createElement("a"); linkdiv.setAttribute("href", jsonValues.values[x].link); linkdiv.setAttribute("title", jsonValues.values[x].title); var linkImageDiv = document.createElement("div"); linkImageDiv.setAttribute("class", "storypromoImage"); var linkImage = document.createElement("img"); if ("targetX0" in jsonValues.values[x].imageCrop) cropString = "targetX0=" + jsonValues.values[x].imageCrop["targetX0"] + "_targetX1=" + jsonValues.values[x].imageCrop["targetX1"] + "_targetY0=" + jsonValues.values[x].imageCrop["targetY0"] + "_targetY1=" + jsonValues.values[x].imageCrop["targetY1"] + "_"; else cropString = "" linkImage.setAttribute("data-src", "http://www.newsandstar.co.uk/portalsuite/image/" + jsonValues.values[x].image + "/mainMediaSize=226x169_" + cropString + "type=image_publish=true_role=1_image.jpg"); linkImage.setAttribute("class", "lazyOwl"); linkImageDiv.appendChild(linkImage); linkdiv.append(linkImageDiv); var linkTextNode = document.createTextNode(jsonValues.values[x].title) ; linkdiv.append(linkTextNode); listitem.appendChild(linkdiv); storyPromoSliderDiv.appendChild(listitem); } if (jsonValues.values.length > 0) { promodiv.style.display = "block"; promodiv.style.clear = "both"; var articleElement = document.getElementsByClassName("article_story"); var paragraphtags = articleElement[0].getElementsByTagName("p") if (paragraphtags.length > insertAfter) articleElement[0].insertBefore(promodiv, paragraphtags[insertAfter]); else articleElement[0].insertBefore(promodiv, paragraphtags[paragraphtags.length]); } } jQuery(document).ready(function() { var storypromoslider = jQuery("#storypromo-slider"); storypromoslider.owlCarousel({ navigation : false, autoPlay: 7000, lazyLoad: true, itemsTablet: [800, 3], itemsMobile: [600, 2], items: 4 }); // Custom Navigation Events jQuery(".next").click(function(){ owl.trigger('owl.next'); }) jQuery(".prev").click(function(){ owl.trigger('owl.prev'); }) jQuery(".play").click(function(){ owl.trigger('owl.play',1000); //owl.play event accept autoPlay speed as second parameter }) jQuery(".stop").click(function(){ owl.trigger('owl.stop'); }) }); var styleText = "#storypromo-slider .storypromo {margin: 0 10px}; " + "div.storypromoAddress {font-weight: bold; font-size:1rem} " + "div.storypromoPrice {font-weight: bold; font-size:0.9rem} " + ".storypromoImage img.lazyOwl {position: absolute;top: 0;left: 0;/* bottom: 0; *//* right: 0; */ height: 100%;/* display: block !important; */max-width: none;}" + ".storypromoImage {display: block; max-height: 100%; padding: 75% 0 0 0; height: 0; overflow: hidden; position: relative; width: auto; }"; var styleNode = document.createElement("style"); styleNode.type = "text/css"; styleNode.appendChild(document.createTextNode(styleText)); document.getElementsByTagName('head')[0].appendChild(styleNode); } else{ document.getElementById("storypromo").style.display = "none"; }