(function() { // Localize jQuery variable var jQuery; /******** Load jQuery if not present *********/ if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.4.2') { var script_tag = document.createElement('script'); script_tag.setAttribute("type","text/javascript"); script_tag.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"); if (script_tag.readyState) { script_tag.onreadystatechange = function () { // For old versions of IE if (this.readyState == 'complete' || this.readyState == 'loaded') { scriptLoadHandler(); } }; } else { script_tag.onload = scriptLoadHandler; } // Try to find the head, otherwise default to the documentElement (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag); } else { // The jQuery version on the window is the one we want to use jQuery = window.jQuery; main(); } /******** Called once jQuery has loaded ******/ function scriptLoadHandler() { // Restore $ and window.jQuery to their previous values and store the // new jQuery in our local jQuery variable jQuery = window.jQuery.noConflict(true); // Call our main function main(); } /******** main function ********/ function main() { var autoscroll; jQuery(document).ready(function($) { /******* Load CSS *******/ var cssLink = $(""); $("head").append(cssLink); var cssLink = $(""); $("head").append(cssLink); var wid = 1; $("div.gp-widget").each(function(){ var gp_widget = $( this ); var gp_type = $( this ).attr("data-type"); var gp_category = $( this ).attr("data-category"); gp_widget.attr("id", "gp-widget-"+wid); if( !gp_category ){ gp_category = 0; /* Default Category */ } gp_widget.addClass( "widget-" + gp_type ); gp_widget.click(function(){ __gpga('widgetTracker.send', 'event', { eventCategory: 'Widget', eventAction: 'Click', eventLabel: window.location.hostname}); }); /******* Load HTML *******/ var jsonp_url = "http://www.gewinnspielpony.de/widget/data/" + gp_type + "_" + gp_category + "?callback=?"; $.getJSON(jsonp_url, function(data) { gp_widget.html(data.html); }); autoscroll = window.setInterval( function(){ $( gp_widget ).find('ul.gp-widget-scrollist li:first').before($(gp_widget).find('ul.gp-widget-scrollist li:last').hide().delay( 500 ).slideDown('slow')); } , 8000); }); }); // setup google analytics if (!window.__gpga){ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','__gpga'); } __gpga('create', 'UA-55449398-2', 'auto', {'name': 'widgetTracker'}); __gpga('widgetTracker.send', { 'hitType': 'pageview', 'page': window.location.hostname, 'title': window.document.title }); } })();