/**
* this function creates a slideshow inside element with specified selector
* Arguments:
* selector: selector of the container
* ids: an array contains ids of containers with slides
*/
function slideShow(selector,ids){
if(ids.length==0){
return;
}
jQuery(selector).html('
');
var f = {};
var t = [];
var callback = function(fname){
var tout = setTimeout(function(){
// hide
jQuery(selector+" .slideshowContent").hide("slide",{direction:"right"},"fast",f[fname]);
},7000);
t.push(tout)
};
var navHtml = ['
'];
for(var i=0;i');
}else{
navHtml.push('
');
}
//console.log("creating function with name: "+"f"+e +" and the next id="+fname);
f[fName] = function(){
//console.log("call function with name: "+"f"+e +" and the next id="+fname);
jQuery(selector+ " .slideshowNav a").removeClass("active");
jQuery(selector+ " .slideshowNav a.slideshow-id-"+e).addClass("active");
jQuery(selector +" .slideshowContent").empty().html(jQuery(id).html()).show("slide",{direction:"left"},"slow",callback(nextFName));
};
})(i);
// end of creating copy of i
}
navHtml.push('
')
f.f0();
// inject pager at the bottom
jQuery(selector +" nav").html(navHtml.join(""));
jQuery(selector+ " .slideshowNav a").click(function(e){
e.preventDefault();
jQuery(selector+ " .slideshowNav a").removeClass("active");
var c = jQuery(this).attr("class");
//extract the number
var index = c.lastIndexOf("-");
var fName = "f"+c.substring(index+1);
for(var i=0; i