$(function() {
	$('.homeSlideShow')
		.before('<div id="homeSlideShowNav"></div>')
		.cycle({
				fx: 'scrollLeft'
				,speed: 0 // speed of sliding
				,timeout: 5000 // time between slides
				,pause: 1 // 1=true - pause on hover
				,random: 0 // 1=true - show in random order (dosn't seem to work)
				,delay: 1000 // + time befoer first slide
				,next: '.homeSlideShow' // advance onclick
				,pager: '#homeSlideShowNav'
			});
	attachScrollable();
	$(".validateForm").validate();
});

/************************************************************/
var scrollableApi = null;
var startScroll = null;

function attachScrollable()
{
	scrollableApi = $("div.scrollable").scrollable({
		vertical:true
		, size: 5
		, api: true
	});	
	if ( startScroll ) {
		scrollableApi.seekTo(startScroll);
	}
}

/************************************************************/

function showProduct(language, productId)
{
	var categoryUrl, categoriesUrl, displayUrl;

	/*	alert("showProduct-" + language + "-" + productId);	*/

	categoriesUrl = "/hidur/index.php/ajax/" + language + "/productCategories/" + productId ;
	$("#productCategories").load(categoriesUrl);

	displayUrl = "/hidur/index.php/ajax/" + language + "/productDisplay/" + productId ;
	$("#productDisplay").load(displayUrl);

	showCategory(language, productId, -1);
}

/************************************************************/

// show a category section starting with startIndex
// if index is -1, start with an index that makes the productId visible

function showCategory(language, productId, startIndex)
{
	categoryUrl = "/hidur/index.php/ajax/" + language + "/productCategory/" + productId + "/" + startIndex ;
	$("#productCategory").load(categoryUrl, attachScrollable);
}

/************************************************************/

