$j(document).ready(function()
{
	// Картинки в модальном окне
	$j(".jquery_img").fancybox({ 
							   'zoomSpeedIn': 300, 
							   'zoomSpeedOut': 600, 
							   'overlayShow': true,
							   'hideOnContentClick': false,
							   'overlayOpacity': 0.85,
							   'imageScale': false,
							   'centerOnScroll': false
							   }); 
	
	// Слайдовый эффект подменю
	slide("#sliding-navigation", 20, 0, 150, .8);
	
	// Портфолио на главной
	if (document.getElementById("id_type_web"))
	{
		function nextWork() 
		{
			var type=$j("#id_type").val();
			var num=$j("#id_num").val();
			var num_next=num*1+1;
			var id_block=$j("#id_block").val();
			if (id_block==0)
			{
				if (document.getElementById(type+"_"+num_next))
				{
					$j("#id_block").val(1);
					$j("#id_num").val(num_next);
					$j("#"+type+"_"+num).hide("slow");
					$j("#"+type+"_"+num_next).show("slow", elementUnblock);
				}
				else if (num!=0) 
				{
					$j("#id_block").val(1);
					num_next=0;
					$j("#id_num").val(num_next);
					$j("#"+type+"_"+num).hide("slow");
					$j("#"+type+"_"+num_next).show("slow", elementUnblock);						
				}
			}
			return false;
		}
		
		function elementUnblock()
		{
			$j("#id_block").val(0);
		}
		
		$j("#id_type_web").addClass("menu_portfolio_type_web_hover");
		var intervalID=setInterval(nextWork, 5000);
		
		$j("#portfolio_next").click(
		 function (e)
		 {
			 clearInterval(intervalID);
			 var type=$j("#id_type").val();
			 var num=$j("#id_num").val();
			 var num_next=num*1+1;
			 var id_block=$j("#id_block").val();
			 if (id_block==0)
			 {
				 if (document.getElementById(type+"_"+num_next))
				 {
					 $j("#id_block").val(1);
					 $j("#id_num").val(num_next);
					 $j("#"+type+"_"+num).hide("slow");
					 $j("#"+type+"_"+num_next).show("slow", elementUnblock);
				 }
				 else if (num!=0) 
				 {
					 $j("#id_block").val(1);
					 num_next=0;
					 $j("#id_num").val(num_next);
					 $j("#"+type+"_"+num).hide("slow");
					 $j("#"+type+"_"+num_next).show("slow", elementUnblock);						
				 }
			 }
			 return false;
		 }
		);
		
		$j("#portfolio_back").click(
		 function ()
		 {
			 clearInterval(intervalID);
			 var type=$j("#id_type").val();
			 var num=$j("#id_num").val();
			 var num_next=num*1-1;
			 var id_block=$j("#id_block").val();
			 if (id_block==0)
			 {
				 if (document.getElementById(type+"_"+num_next))
				 {
					 $j("#id_block").val(1);
					 $j("#id_num").val(num_next);
					 $j("#"+type+"_"+num).hide("slow");
					 $j("#"+type+"_"+num_next).show("slow", elementUnblock);
				 }
			 }
			 return false;
		 }
		);
		
		$j("#id_type_web").click(
	     function () 
		 {
			 var new_type="web";
			 var type=$j("#id_type").val();
			 var id_block=$j("#id_block").val();
			 if ((type!=new_type) && (document.getElementById(new_type+"_0")) && (id_block==0))
			 {
				 $j("#id_block").val(1);
				 var num=$j("#id_num").val();
				 $j("#id_num").val(0);
				 $j("#id_type").val(new_type);
				 $j("#id_type_"+type).removeClass("menu_portfolio_type_"+type+"_hover");
				 $j("#id_type_"+new_type).addClass("menu_portfolio_type_"+new_type+"_hover");
				 $j("#"+type+"_"+num).hide("slow");
				 $j("#"+new_type+"_0").show("slow", elementUnblock);
			 }
			 return false;
		 }
		);	
		
		$j("#id_type_inter").click(
		 function () 
		 {
			 var new_type="inter";
			 var type=$j("#id_type").val();
			 var id_block=$j("#id_block").val();
			 if ((type!=new_type) && (document.getElementById(new_type+"_0")) && (id_block==0))
			 {
				 $j("#id_block").val(1);
				 var num=$j("#id_num").val();
				 $j("#id_num").val(0);
				 $j("#id_type").val(new_type);
				 $j("#id_type_"+type).removeClass("menu_portfolio_type_"+type+"_hover");
				 $j("#id_type_"+new_type).addClass("menu_portfolio_type_"+new_type+"_hover");
				 $j("#"+type+"_"+num).hide("slow");
				 $j("#"+new_type+"_0").show("slow", elementUnblock);
			 }
			 return false;
		 }
		);
		
		$j("#id_type_design").click(
         function () 
		 {
			 var new_type="design";
			 var type=$j("#id_type").val();
			 var id_block=$j("#id_block").val();
			 if ((type!=new_type) && (document.getElementById(new_type+"_0")) && (id_block==0))
			 {
				 $j("#id_block").val(1);
				 var num=$j("#id_num").val();
				 $j("#id_num").val(0);
				 $j("#id_type").val(new_type);
				 $j("#id_type_"+type).removeClass("menu_portfolio_type_"+type+"_hover");
				 $j("#id_type_"+new_type).addClass("menu_portfolio_type_"+new_type+"_hover");
				 $j("#"+type+"_"+num).hide("slow");
				 $j("#"+new_type+"_0").show("slow", elementUnblock);
			 }
			 return false;
		 }
		);	
		
	}
	// /Портфолио на главной
	
	// Анимация подарка 
	$j("#ind_b_prize").mouseover(
	function () 
	{
		$j("img:first",this).attr({
								  src: "/templates/artpoints_main/images/content2_b5_prize2.jpg"
								  });	
	}
	).mouseout(
	function()
	{
		$j("img:first",this).attr({
								  src: "/templates/artpoints_main/images/content2_b5_prize1.jpg"
								  });
    });
	
	// ИНФ в модальном окне
	$j("#feedback_question a").fancybox({
    	hideOnContentClick: false,
    	overlayShow: true,
    	overlayOpacity: 0.85,
    	zoomSpeedIn: 300,
    	zoomSpeedOut:600,
		imageScale:false,
		//centerOnScroll:false,
		frameWidth: 532,
		frameHeight: 282
		});
	
	// Красивые Titl'ы	
	$j(".b-portfolio-img a").easyTooltip();
	
	// Раздвижные новости
	$j.fn.news = function()
	{
		$j(".news_block", this).each(function() {			
		var news = this;		
		
		$j(".news_anonce", news).css("display", "block");
			var h = $j(".news_anonce", news).get(0).offsetHeight;	
		$j(".news_anonce", news).data("height", h);
		$j(".news_anonce", news).css("height", "0px");
		
		function myclick()
		{
			if($j(".news_anonce", news).css("height")== "0px")
			{
				//$j(".news_anonce").animate( { height: "0px"}, 100);	
				$j(".news_anonce").css("height", "0px");
				h = $j(".news_anonce", news).data("height");
				$j(".news_anonce", news).animate( { height: h + "px"}, 1000);	
			}
			else
			{
				$j(".news_anonce", news).animate( { height: "0px"}, 1000);	
				//$j(".news_anonce").css("height", "0px");
			}
			return false;

		}
		
		$j("._news_name", this).click(myclick);
											  });
	};	
	
	$j(function() {$j('.news_list').news()});
	$j(function() {$j('.animate_list').news()});
	
	/*
	 Центр обратной связи
	*/
	mod_feedbackcenter();
	
});
