/********* Slideshow Javascript Functions *******/

/** Custom function for building a slideshow pager using thumbnails **/
function pagerImageBuilder(idx, slide) 
{ 
	var imgSrc = jQuery(slide).find("a").eq(0).attr("thmbsrc");
	return '<li><img src="' + imgSrc +'" width="43" height="27" /></li>';
}

function pagerImageBuilderTipsAndTricks(idx, slide) {
    var imgSrc = jQuery(slide).find("img").eq(0).attr("src");
    return '<li><img src="' + imgSrc + '" width="44" height="38" /></li>';
}

/** Custom function for building a slideshow numeric pager **/
function pagerTextBuilder(idx, slide) 
{ 
	return '<li id="index-' + idx + '" index='+ idx +'>'+ idx +'</li>';
}


/** Sets up click event for paging elements **/
function setupPager(pagerId, mainImageId, width, height)
{
	$(pagerId + ' li').each(function(index) { 
		var elem = $(this);
		var slideIndex = elem.attr("index");
		if (slideIndex >= 0)
		{
			elem.click(function() {
				$(mainImageId).cycle(slideIndex); 
				return false; 
			}).find("img").attr("width",width).attr("height", height);
		}
	});
	
	$(pagerId + ' .pager-next').detach().appendTo(pagerId + ' ul');
}
