function mycarousel_initCallback(carousel,state) {

		jQuery('.ra, .scroll_right').bind('click', function() {
			if(isAnimate == false&&$("#3").attr("jcarouselindex")=="4"){
				isAnimate = true;
				$(".caption, .materials").animate({opacity:"0"},500);		
	
				$(".centralitemMy img").animate({width:"185px",height: "180px", marginTop: "0px"},500,"linear",function(){
					//	get ID from .central
					var currentid = $(".centralitemMy").attr("id");
										
					if($("#"+(parseInt(currentid)+1)).attr("last")=="last"){
						carousel.scroll(1);
					}
					
					//	move~
					$("#mycarousel li").removeClass("centralitemMy");
	
					carousel.next();
	
				});
	
				return false;
			}
		});

		

		jQuery('.la, .scroll_left').bind('click', function() {
				if(isAnimate == false&&$("#3").attr("jcarouselindex")=="4"){
					isAnimate = true;
						$(".caption, .materials").animate({opacity:"0"},500);
			
						$(".centralitemMy img").animate({width:"185px",height: "180px",marginTop: "0px"},500,"linear",function(){
			
							$("#mycarousel li").removeClass("centralitemMy");
			
							carousel.prev();
						
						});
			
						return false;
			}
		});

}; 


var notAllowed = false;
var firstmove = false;

function mycarousel_itemFirstInCallback(carousel, item, idx, state) {
    
	$("#mycarousel img").css("width","185px");
    $("#mycarousel img").css("height","180px");

	var myPlaceHolder = idx+1;

	$(".caption").html($("#x"+idx).html());

	$("#tablehere").html($("#tbl"+idx).html());

	$(".biginfo").html($("#b"+idx).html());

	$(".smallinfo").html($("#s"+idx).html());	

	$(".materials").html($("#m"+idx).html());

	$(".caption, .materials").animate({opacity:"1"},500);
 
 
	if(scrollto=="2"||firstmove==true){

		$(".jcarousel-item-"+myPlaceHolder+" img").animate({
	
			width: "350px",
	
			height: "350px",
	
			marginTop: "-185px"
	
		},500);
	}
  
	$(".jcarousel-item-"+myPlaceHolder).addClass("centralitemMy");
	isAnimate = false;	
	if(scrollto!="undefined"&&firstmove==false){
		ScrollTo(carousel,scrollto);
		
		firstmove=true;
	}

}; 


function ScrollTo(carousel,scrollto){
	carousel.scroll(scrollto);
}

var isAnimate = false;

$(document).ready(function(){

//	oborudovanie
$(".imagePreviewItem img").click(function(){
	$(".equip_pic").css("background-image","url("+$(this).attr("thumbpath")+")");
	$("a.equipImg").attr("href",$(this).attr("fullpath"));
});



if($("#3").attr("jcarouselindex")!="4"){
	
	jQuery('#mycarousel').jcarousel({

        	scroll: 1,

        	visible: 3,

        	start: 2,

        	wrap: "both",
            
           	initCallback: mycarousel_initCallback, 
            itemFirstInCallback: mycarousel_itemFirstInCallback,

	        // This tells jCarousel NOT to autobuild prev/next buttons

			buttonNextHTML: null,

			buttonPrevHTML: null

    });

} else {

		$("#2 img").css({
			width: "350px",
	
			height: "350px",
	
			marginTop: "-185px"
		});
}	

	//	colorize table
	$('tr:odd').addClass('odd');
	$('tr:even').addClass('even');

	var trArray = $("table tr");
	for (i=0;i<=trArray.length;i++)
	{	
		$(trArray[i]).find("td:first").css("border","0px");
		$(trArray[i]).find("th:first").css("border-left","0px");
	}
	var tableArray = $("table");
	for (i=0;i<=tableArray.length;i++)
	{	
		$(tableArray[i]).find("tr:first").removeClass("even");
	}


});
