var img=1;
var img_all=(document.getElementById('img_big').childNodes.length)-1;
    $(document).ready(function(){
       $("#img_next").hover(
      	function () { 	
      		if(img!=img_all) $(this).addClass("img_next_hover");
		},
		function () { 	
       		$(this).removeClass("img_next_hover");
		}
		)
		
       $("#img_prev").hover(
      	function () { 	
       		if(img!=1) $(this).addClass("img_prev_hover");	
		},
		function () { 	
       		$(this).removeClass("img_prev_hover");
		}
		)

	 	$("#img_next").click(function () { 
			if(img!=img_all)
			{
			$("#img_"+(img)+"_img").css({'display' : 'none'});
		 	$("#img_"+(img)+"_ref").css({'display' : 'none'});
			$("#img_"+(img)+"_text").css({'display' : 'none'});
		 	$("#img_"+(img)+"_thumb").css({'border' : '1px solid #ffffff'});
		    img++;
		    $("#img_"+(img)+"_img").fadeIn("slow"); 
		    $("#img_"+(img)+"_ref").fadeIn("slow"); 
		    
		    $("#img_"+(img)+"_text").fadeIn("slow"); 
			$("#img_"+(img)+"_thumb").css({'border' : '1px solid #DA156F'});	
			}
			
	    })

	 	$("#img_prev").click(function () { 
	 		if(img!=1)
	 		{
		 	$("#img_"+(img)+"_img").css({'display' : 'none'});
		 	$("#img_"+(img)+"_ref").css({'display' : 'none'});
		 	$("#img_"+(img)+"_text").css({'display' : 'none'});
		 	$("#img_"+(img)+"_thumb").css({'border' : '1px solid #ffffff'});
		    img--;
		    $("#img_"+(img)+"_img").fadeIn("slow"); 
		    $("#img_"+(img)+"_ref").fadeIn("slow"); 
		    $("#img_"+(img)+"_text").fadeIn("slow"); 
		 	$("#img_"+(img)+"_thumb").css({'border' : '1px solid #DA156F'});	
	 		}
	    })
	    
	 	$(".case_img_thumb").hover(
      	function () { 	
       		$(this).css({'border' : '1px solid #DA156F'});	
		},
		function () { 	
       		$(this).css({'border' : '1px solid #ffffff'});	
		}
		)	    
		
	 	$(".case_img_thumb").click(function () { 
		var get_id=this.id.split("_");
		get_id=get_id[1];

		for (var j=1;j<=img_all;j++) 
		{
	    $("#img_"+(j)+"_img").css({'display' : 'none'});
	    $("#img_"+(j)+"_ref").css({'display' : 'none'});
	    $("#img_"+(j)+"_text").css({'display' : 'none'});
		$("#img_"+(j)+"_thumb").css({'border' : '1px solid #ffffff'});			    
		}
		img=get_id;
	    $("#img_"+(get_id)+"_img").fadeIn("slow"); 
	    $("#img_"+(get_id)+"_ref").fadeIn("slow"); 
	    $("#img_"+(get_id)+"_text").fadeIn("slow"); 
		$("#img_"+(get_id)+"_thumb").addClass("img_active_thumb");	
		$("#img_"+(get_id)+"_thumb").removeClass("img_inactive_thumb");
	    })		
	    
     });
