function getSlider(id) { if (window.ActiveXObject) { httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } else { httpRequest = new XMLHttpRequest(); } httpRequest.open("GET", 'http://www.oredo.cz/ajax/get_slider.php?id='+id, true); httpRequest.onreadystatechange= function () { if (httpRequest.readyState == 4) { if (httpRequest.status == 200) { init_slider(httpRequest.responseText); } } }; httpRequest.send(null); } function init_slider(text) { var a1 = new Array(); a1 = text.split("\n"); function mycarousel_initCallback(carousel) { jQuery('.slider-control a').bind('click', function() { carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text())); return false; }); carousel.remove(1); carousel.clip.hover(function() { carousel.stopAuto(); }, function() { carousel.startAuto(); }); carousel.scroll(1); }; function itemLoadCallbackFunction(carousel, state) { for (var i = carousel.first; i <= carousel.last; i++) { // Check if the item already exists if (!carousel.has(i)) { // Add the item carousel.add(i, a1[i-1]); } } }; function itemChangeFce(carousel, state) { for (var i = carousel.first; i <= carousel.last; i++) { // Check if the item already exists if (!carousel.has(i)) { // Add the item carousel.add(i, a1[i-1]); } } }; function highlight(carousel, obejctli,liindex,listate){ jQuery('.slider-control a:nth-child('+ liindex +')').attr("class","selected"); }; function removehighlight(carousel, obejctli,liindex,listate){ jQuery('.slider-control a:nth-child('+ liindex +')').removeAttr("class","selected"); }; jQuery("#M_slider").jcarousel({ scroll: 1, start:1, offset:1, auto: 6, wrap: 'last', initCallback: mycarousel_initCallback, itemLoadCallback: {onBeforeAnimation: itemLoadCallbackFunction}, itemVisibleInCallback: highlight, itemVisibleOutCallback: removehighlight, buttonNextHTML: null, size: slider_size, buttonPrevHTML: null }); }