var angle = 0;



jQuery.preloadImages = function()

{

	for(var i = 0; i<arguments.length; i++)

	{

		jQuery("<img>").attr("src", arguments[i]);

	}

}



$.preloadImages("/i/pattern-grey-a.png", "/i/pattern-green-a.png");

$.preloadImages("/i/inactive.png");



$(document).ready(function(){

	

	$(".equipImg").fancybox({
		'overlayShow' : true,
		'zoomSpeedIn' : 300,
 		'zoomSpeedOut' : 300
	}); 

	

//	mainpage



	//	colorize!

		$("img.size2").hover(function(){

			//	over

			$("li.size2 img").attr("src","/i/pattern-grey-a.png");	

		}, function(){

			//	out

			$("li.size2 img").attr("src","/i/pattern-grey.png");		

		});

		

		$("img.size3").hover(function(){

			//	over

			$("li.size3 img").attr("src","/i/pattern-blue-a.png");	

		}, function(){

			//	out

			$("li.size3 img").attr("src","/i/pattern-blue.png");		

		});

		

		$("img.size4").hover(function(){

			//	over

			$("li.size4 div img").attr("src","/i/pattern-yellow-a.png");	

		}, function(){

			//	out

			$("li.size4 div img").attr("src","/i/pattern-yellow.png");		

		});

		

		

		

	$(".top-corners .tl, .top-corners .tr, .bottom-corners .br, .bottom-corners .bl").hide();

	$(".current-cat .down-arrow").css("background","transparent url(/i/inactive.png) no-repeat scroll 100% 0");

	$(".drop-down-menu .center").css("borderLeft","1px solid white").css("borderRight","1px solid white");
	
	$(".container-inner-2 .drop-down-menu .center").css("borderLeft","1px solid #D5002D").css("borderRight","1px solid #D5002D").css("background-image","none");

	$(".current-cat div div").parent().css("background","#FFFFFF url(/i/dropdown-bg.png) no-repeat scroll 0 0");

	

//	catalog

	//	dropdown	

	var isClosed = true;

	$(".down-arrow").click(function(){

		if(isClosed==true){

			$(".menu-list ul").slideToggle("fast");

			$(".top-corners .tl, .top-corners .tr, .bottom-corners .br, .bottom-corners .bl").show();

			$(".current-cat .down-arrow").css("background","transparent url(/i/active.png) no-repeat scroll 100% 0");

			$(".drop-down-menu .center").css("borderLeft","1px solid #A5A5A5").css("borderRight","1px solid #A5A5A5");

			$(".current-cat div div").parent().css("background","#FFFFFF url(/i/dropdown-bg-off.png) no-repeat scroll 0 0");
			
			$(".container-inner-2 .drop-down-menu .center").css("background","transparent url(/i/center-bg.png) no-repeat scroll 100% 0");

			isClosed = false;

		} else {

			$(".menu-list ul").slideToggle("fast");

			$(".top-corners .tl, .top-corners .tr, .bottom-corners .br, .bottom-corners .bl").hide();

			$(".current-cat .down-arrow").css("background","transparent url(/i/inactive.png) no-repeat scroll 100% 0");

			$(".drop-down-menu .center").css("borderLeft","1px solid white").css("borderRight","1px solid white");
			
			$(".container-inner-2 .drop-down-menu .center").css("borderLeft","1px solid #D5002D").css("borderRight","1px solid #D5002D").css("background-image","none");

			$(".current-cat div div").parent().css("background","#FFFFFF url(/i/dropdown-bg.png) no-repeat scroll 0 0");

			isClosed = true;

		}

	});

	//	dropdown select

	$(".menu-list ul li a").click(function(){

		$(".current-cat div div").html($(this).html());

		$(".menu-list ul").slideToggle("fast");

		$(".top-corners .tl, .top-corners .tr, .bottom-corners .br, .bottom-corners .bl").hide();

			$(".current-cat .down-arrow").css("background","transparent url(/i/inactive.png) no-repeat scroll 100% 0");

			$(".drop-down-menu .center").css("borderLeft","1px solid white").css("borderRight","1px solid white");
			
			$(".container-inner-2 .drop-down-menu .center").css("borderLeft","1px solid #D5002D").css("borderRight","1px solid #D5002D").css("background-image","none");

			isClosed = true;

			//	redirect

	});

	

	
	$("#la").click(function(){
		$.post("/products/stone/lipuchki/",{obj:$(this).attr('objid')},
			function(data)
			{
				var afterBodyArray = data.split("<body>");
				var afterBody = afterBodyArray[1];
				var beforBodyArray = afterBody.split("</body>");
				$("body").html(beforBodyArray[0]);
				redeclaration();
			
			});
	});
	
	$(".nextLipEl").click(function(){
		$.post("/products/stone/lipuchki/",{obj:$(".left-disk").attr('objid')},
			function(data)
			{
				nextLip(data);
				redeclaration();
			});
	});
	
	function nextLip(data)
	{
		var afterBodyArray = data.split("<body>");
		var afterBody = afterBodyArray[1];
		var beforBodyArray = afterBody.split("</body>");
		$("body").html(beforBodyArray[0]);
	}
	
	function redeclaration()
	{
		$(".nextLipEl").click(function(){
		$.post("/products/stone/lipuchki/",{obj:$(".left-disk").attr('objid')},
			function(data)
			{
				nextLip(data);
				redeclaration();
			
			});
		});
		
		$("#la").click(function(){
		$.post("/products/stone/lipuchki/",{obj:$(this).attr('objid')},
			function(data)
			{
				nextLip(data);
				redeclaration();
			
			});
		});
	} 
	
	

	

	

});
