$(document).ready(function(){

	$("div.howtobuy").click(function(){ $("div.howtobuy").css({ "background":"url(gfx/"+$("#top-menu-content").attr("site_lang")+"/how_to_buy.jpg)","height":"492px" }); });
	$("div.howtobuy").mouseout(function(){ $("div.howtobuy").css({ "background":"url(gfx/"+$("#top-menu-content").attr("site_lang")+"/box_btn_howtobuy.png)","height":"84px" }); });
	
		   how_imgs=$("#how-source > div.how-img").size();
		   $("#how-target").html("<div>"+$("#how-source > div.how-img:eq(1)").html()+"</div>");
		  var dv=1;
		  
		  image_timer=setTimeout(function(){ changeImg(dv,how_imgs);	},2000);
									
			function changeImg(num,max)
				{
				if(num==max || num>max)  num=0;
				
				$("#how-target > div").fadeOut(200);
				setTimeout(function(){ 
									$("#how-target").html("<div style=display:none>"
															+$("#how-source > div.how-img:eq("+num+")").html()
															+"</div>"); 
									$("#how-target > div").fadeIn(200); 
									},200);
				num++;
								
				if(num==max)  num=0;
				image_timer=setTimeout(function(){	changeImg(num,max);	},4000);
				}
			
			$("#how-target").mouseover(function(){ clearTimeout(image_timer); }).mouseout(function(){
													if($(this).find("img").attr("grupa")!="free")
														{
														numernow=$(this).find("img").attr("num");
														$("div.quick-preview").remove();
															image_timer=setTimeout(function(){ 
																							changeImg(numernow,how_imgs);	
																							$("#how_handle").css("height","250px");
																							$("#howdoesitwork-div").css("margin-top","10px");
																							},1000); 
														}
												});
												
												
});	
