jQuery.noConflict();

jQuery(document).ready(function(){

//init gallerys
jQuery(".cycleGallerySmalls").each(function(index) {
	var bn=jQuery(this).find(".cycleNext");
	var bp=jQuery(this).find(".cyclePrev");
    jQuery(this).find(".jCarouselLite").jCarouselLite({
        btnNext: bn,
        btnPrev: bp,
		mouseWheel: true,
		circular: false
    });
	

});


jQuery(".cycleGallerySmalls img").click(function() {
	jQuery(this).parents(".jCarouselLite").find("li").removeClass("active");
	
	if (jQuery(this).attr("name")!="")
		jQuery(this).parents(".cycleGallery").find(".cycleBigPic img").attr("src", jQuery(this).attr("name"));
	else
		jQuery(this).parents(".cycleGallery").find(".cycleBigPic img").attr("src", jQuery(this).attr("src"));
	

	jQuery(this).parents("li").addClass("active");
})


//init popupgallery
jQuery(function() {
	jQuery(".cyclePopupGallery .jCarouselLite").jCarouselLite({
		btnNext: ".cyclePopupGallery .cycleNext",
		btnPrev: ".cyclePopupGallery .cyclePrev",
		vertical: true,
		mouseWheel: true,
		circular: false
	});
});
//init scroll
jQuery(".cycleScroll-pane").jScrollPane({scrollbarWidth:24, showArrows:true});	


jQuery(".cyclesPopup").css("display","none");
jQuery(".cyclesPopup").css("opacity","1");

// more click
jQuery(".cycleLeftColBox .cycleMore").click(function() {
	var el=jQuery(this).parents(".cycleLeftColBox").find(".cyclesPopup");

	el.css("display","none");
	el.css("width","451px");
	
	if(el.find("img").length) el.css("margin-left","-75px")
	else el.css("margin-left","-250px");
	
	el.find(".cyclePopupClose").css("display","none");
	el.find(".cyclePopupGallery span").css("display","none");
	el.find(".cyclePopupText").css("margin-left","15px");
	
	el.fadeIn("1000");
	if(el.find("img").length){
	timeoutID = setTimeout(function()
	{
		el.animate( { width:"750px", marginLeft:"-375px" } , 400 );
		el.find(".cyclePopupText").animate( { marginLeft:"312px" } , 400 );
		
	}, 400);
	}
	timeoutID = setTimeout(function()
	{
		el.find(".cyclePopupGallery li img").animate( { opacity:0.7 } , 400 );
		el.find(".cyclePopupClose").fadeIn();
		el.find(".cyclePopupGallery span").fadeIn();
	}, 1000);
	
	
});

// more click right
jQuery(".cycleRightColumn .cycleMore").click(function() {
	var el=jQuery(this).parent().find(".cyclesPopup");

	el.css("display","none");
	el.css("width","451px");
	if(el.find("img").length) el.css("margin-left","-75px")
	else el.css("margin-left","-250px");
	
	el.find(".cyclePopupClose").css("display","none");
	el.find(".cyclePopupGallery span").css("display","none");
	el.find(".cyclePopupText").css("margin-left","15px");
	
	el.fadeIn("1000");
	if(el.find("img").length){
	timeoutID = setTimeout(function()
	{
		el.animate( { width:"750px", marginLeft:"-375px" } , 400 );
		el.find(".cyclePopupText").animate( { marginLeft:"312px" } , 400 );
		
	}, 400);
	}
	timeoutID = setTimeout(function()
	{
		el.find(".cyclePopupGallery li img").animate( { opacity:0.7 } , 400 );
		el.find(".cyclePopupClose").fadeIn();
		el.find(".cyclePopupGallery span").fadeIn();
	}, 1000);
	
	
});

		
//close click
jQuery(".cyclePopupClose").click(function() {
	jQuery(this).parent().fadeOut();
});

//show big picture
jQuery(".cyclePopupGallery li").click(function() {

	var el=jQuery(this).find("img");
	
	jQuery(".cyclesPopupBigPhoto").fadeIn();
	jQuery("#BigPicture").css("display","none");
	jQuery("#cyclePreLoad").fadeIn();


	if (el.attr("name")!=""){
		jQuery("#BigPicture").attr("src", el.attr("name"));
		var hugeimage=new Image();
		hugeimage.src=el.attr("name");
		timeoutID = setTimeout(function()
		{		
		cc=hugeimage.width;
		dd=hugeimage.height;

		jQuery("#BigPicture").attr("width", cc).attr("height", dd);
		jQuery(".cyclesPopupBigPhoto").css("margin-left",-cc/2);
		jQuery("#BigPicture").css("display","block");
		jQuery("#cyclePreLoad").fadeOut();
		}, 500);
	}
	else{
		jQuery("#BigPicture").attr("src", el.attr("src"));
		jQuery("#BigPicture").attr("width", el.attr("width")).attr("height", el.attr("height"));
		jQuery(".cyclesPopupBigPhoto").css("margin-left",-el.width()/2);
		jQuery("#BigPicture").css("display","block");
		jQuery("#cyclePreLoad").fadeOut();
	}


	
		
});


//gallary effects
jQuery(".cycleGallerySmalls li").hover(
  function () {
    jQuery(this).css("background","#fff");
  }, 
  function () {
    jQuery(this).css("background","#939598");
	}
);

jQuery(".cyclePopupGallery li img").hover(
  function () {
    jQuery(this).animate( { opacity:1 } , 400 );
  }, 
  function () {
    jQuery(this).animate( { opacity:0.7 } , 400 );
	}
);




});
