/* 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":"7","title":"More Property articles...","values":[{"title":"Semi is deceptively spacious","link":"http:\/\/www.newsandstar.co.uk\/property\/Surprisingly-spacious-rural-home-dd44eba1-17b0-40dd-a923-fc6257f71d8a-ds","image":"4adb5e5d-e380-4207-ab77-5269f292c7bb","imageCrop":[]},{"title":"Stunning scenery all around","link":"http:\/\/www.newsandstar.co.uk\/property\/Charming-country-cottage-close-to-Hadrians-Wall-3c397d9a-5336-4db8-9756-0dd4bb067911-ds","image":"a18879cf-ab66-4a56-9a06-dccafe886988","imageCrop":[]},{"title":"Period style in conservation area","link":"http:\/\/www.newsandstar.co.uk\/property\/Revamped-three-storey-home-in-Penriths-New-Streets-area-87c841ec-9a4e-490f-8e76-3deb2bc22a48-ds","image":"b4682bb6-a0d1-45f6-afc1-1b2f0ab2ef0f","imageCrop":[]},{"title":"Views helped clinch sale","link":"http:\/\/www.newsandstar.co.uk\/property\/Bungalows-fell-views-and-acres-of-land-clinched-sale-8c148797-6341-4591-a557-f3f5514fe93e-ds","image":"f5120b00-bc81-487f-af23-6f2853b25d3e","imageCrop":[]},{"title":"Family space is highlight of home","link":"http:\/\/www.newsandstar.co.uk\/property\/Quality-as-standard-in-lovely-family-home-031c0dc1-73e4-449c-8a32-49a9460baef9-ds","image":"73f6c787-89dc-4829-855a-7714e380765f","imageCrop":[]},{"title":"\u00a3250,000 to spend?","link":"http:\/\/www.newsandstar.co.uk\/property\/3-homes-for-sale-at-250000-85aa07b6-749d-4ddf-a817-0514166979ef-ds","image":"86ebf1e4-159a-4a2d-854f-f89ab4c25350","imageCrop":[]}]}; 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"; }