// --------------------------------------------------
// scroll callback
// --------------------------------------------------
function mycarousel_itemFirstInCallback(carousel, item, idx, state) {
	document.scrolllist.scrollpos.value= idx;
	jQuery('#test1').html('Item #' + idx + ' is now the first item');
};
function mycarousel_itemLastInCallback(carousel, item, idx, state) {
    jQuery('#test2').html('Item #' + idx + ' is now the last item');
};


// --------------------------------------------------
// scroll helper
// --------------------------------------------------
function scroll_helper_link( pid )
{
    document.scrolllist.prodid.value= pid;
    document.scrolllist.submit();
}


// --------------------------------------------------
// bild_nav helper
// --------------------------------------------------
function imgNav()
{
	$( '.navblock' ).each( function () {
		// target elements
		var imgurl= $( this ).find( 'img' ).attr( 'src' );
		var imgTarget= $( this ).find( 'a' );
		var imgTargetURL= imgTarget.attr( 'href' );

		// styles to apply
		var cssObjOut= {
			'background' : 'url( ' + imgurl + ' ) top left no-repeat'
		};
		var cssObjOver= {
			'background' : 'url( /global/img/round_white.jpg ) top left no-repeat'
		};

		// mouse over
		$( this ).mouseover(function () {
			$( this ).children().css( {'cursor':'pointer'} );
			$( this ).toggleClass( "on" );
			imgTarget.css( cssObjOver );			
		});
			
		// mouse out
		$( this ).mouseout(function () {
			$( this ).toggleClass( "on" );
			imgTarget.css( cssObjOut );			
		});	
		
		// default style
		imgTarget.css( cssObjOut );
		
		// pass link to click for all children
		$( this ).children().click(function () {
			document.location.href= imgTargetURL;
		});	
	});
}


// --------------------------------------------------
// init
// --------------------------------------------------
$( document ).ready( function()
{
	// jcarousel scroller	
	jQuery('#mycarousel').jcarousel(
		{scroll: 1}
	);
	// jcarousel scroller	
	jQuery('#mycarousel3').jcarousel(
		{scroll: 1}
	);	

	// call helper for bild_nav
	imgNav();
});