/*function bindImages(){
    var tag = "img";

    $('#p_sub-items > ul> li > a').each(function(){
        $(this).bind("click",function(){
            var id = $(this).attr("id");
            id = id.substr(6);

            //Make sure all elements are hidden
            $('#p_main-item > ' + tag + ':not(.hide)').addClass("hide");
            $('#p_main-item > div:not(.hide)').addClass("hide");

            //Make one visible.
            $('#image-'+id).removeClass("hide");
            $('#flash-'+id).removeClass("hide");

            //Sub items
            $('#p_sub-items > ul > li:.current').removeClass("current");
            $('#thumb-'+id).parent().addClass("current");
            return false;
        });
    });
}*/

function bindImages(){
	$('#p_main-item-slider').anythingSlider({
		easing: 'easeInOutExpo',
		autoPlay: false,
		resizeContents      : false,
		buildArrows         : false,
		buildNavigation     : false,
		toggleControls	: false
	});
	
	//#p_main-item-slider > ul > li > img[id^="thumb-"]
	
	$('#p_main-item-slider > li > img[id^="image-"]').bind("click",function(){
		$('#p_main-item-slider').data('AnythingSlider').goForward();
		
		//Remove class on all thumb buttons
		$('#p_sub-items > ul > li').removeClass("current");
		
        var id = $(this).attr("id");
        id = parseInt(id.substr(6));
		//If next is available, goto it, otherwise don't add.
		if($('#thumb-'+(id+1)).length > 0){
			id += 1;
		}else{
			id = 1;
		}
		$('#thumb-'+id).parent().addClass("current");
	});
	
	$('#p_sub-items > ul > li > a[id^="thumb-"]').bind("click", function(){
		$('#p_sub-items > ul > li').removeClass("current");
		$(this).parent().addClass("current");
        var id = $(this).attr("id");
        id = id.substr(6);
		$('#p_main-item-slider').anythingSlider(id);
		
		return false;
	});
}
