jQuery(function()
{
	var img = new Array(); 
	var i = 0;
	$('.gallery img').each(function(){
		var sr = $(this).attr("src"); 
		img[i] = new Image(); 
		img[i].src = sr;
		sr = '';
		i++;
	});
	
	var img1 = new Array(); 
	var i = 0;
	
	$('#inside_gallery2 li a').each(function(){
		var sr = $(this).attr("rel");
		img1[i] = new Image(); 
		img1[i].src = sr;
		sr = '';
		i++;
	});
	
	

	
	
	//onclick="$('.captcha').src='/captcha/index.php?'+time; return false;"
	$("#upload_code").click(function(){
	//	alert('aaa');
		var now = new Date();
		res ='/captcha/index.php?' +  now.getTime();
		$("#captcha_img").attr({ src: res });   	
   	}

   	)
	
	
	if($('.111photos a')){
		$('.111photos a').click(function(event){
			event.preventDefault();
			obj = this;
			$('.photos a').load(this.href);
			//alert(this.href);
			//$('.pager a').removeClass('current');
			//$(this).addClass('current');
		})
		
	}
	
	
		
	
	if($('.pager a')){
		$('.pager a').click(function(event){
			event.preventDefault();
			obj = this;
			$('#faq-list').load(this.href);
			//alert(this.href);
			$('.pager a').removeClass('current');
			$(this).addClass('current');
		})
		
	}
			var id = 0;
			$('.gallery img').fadeOut();
			$('.gallery img.'+$('.gallery li.current').attr('id')).addClass('current').fadeIn();			
			
	$('.gallery li').mouseenter(function(event){
		obj = $(this);
		id = setTimeout(function(){
			$('.gallery img.current').fadeOut('200');
			
			$('.gallery img.'+obj.attr('id')).addClass('current').fadeIn('200');
			$('.gallery li.current').removeClass('current');
			obj.addClass('current');		
		},800);				
	}).mouseleave(function(event){
		clearTimeout(id);	
	});
	    			  /* var tout = 800;
						$("#first").hover(function(){
							obj = this;	
							clearTimeout(id);
							id = setTimeout(function(){pict1(obj)}, tout);
							}
                       )
						
                       function pict1(obj) {
							$(".gallery").find(".current").removeClass("current");
							$(".first").css("display","block");
							$(".second").css("display","none");
							$(".third").css("display","none");
							$(obj).addClass("current");
							$(".first").hide();
							$(".first").fadeIn("normal");
						}
					 
						$("#second").hover(function(){
							obj = this;	
							clearTimeout(id);
							id = setTimeout(function(){pict2(obj)}, tout);
                       }
                       )
					   
					   function pict2(obj) {
							$(".gallery").find(".current").removeClass("current");
							//$(".first").fadeOut("fast");
							//$(".second").fadeOut("fast");
							$(".first").css("display","none");
							$(".second").css("display","block");
							$(".third").css("display","none");
							$(".second").hide();
							$(".second").fadeIn("normal");
							$(obj).addClass("current");
						}	

                       $("#third").hover(function(){
							obj = this;	
							clearTimeout(id);
							id = setTimeout(function(){pict3(obj)}, tout);
                       }
                       ) 
					   function pict3(obj) {
							$(".gallery").find(".current").removeClass("current");
							$(".first").css("display","none");
							$(".second").css("display","none");
							$(".third").css("display","block");
							
							$(".third").hide();
							$(".third").fadeIn("normal");
							$(obj).addClass("current");
							
						}*/
						
                      /*
                 	    $("#front_pict").click(function(){
                 	    	$('#inside_gallery li:has(a.current)').next().find('a').addClass("current").parent().prev().find('a').removeClass('current');
                 	    	var res = '/phpThumb/phpThumb.php?w=530&h=354&iar=1&src=' + $('#inside_gallery li a.current').attr("rel");
                 	    	alert(res);
                 	    	$("#front_pict").attr({ src: res });
                       	}
                       	) 
                       	*/
                       
                            /*
                       //$('#inside_gallery li a.current').css('color','red' );
                       $("#active_anons").mouseover(
                    		function  () {
                    			// $(this).css({"text-decoration": "underline", "color": "red"});
                    			$(this).css({color: "red"})
                    		},
                    		function  () {
                    		   var color = $(this).css("color");
                    		   var cssObj = {color: silver};
                    		    $(this).css(cssObj);
                    		}
                    	   );
                    	   
                    	 */
                       	
                       	$("#active_anons p").hover(
                       	function () {
                       		$(this).css({color: "#444"});
                       	},
                       	function () {
                       		$(this).css({color: "#787878"});
                       	}
                       	);
                       	/*
                       	$("#active_anons").hover(
                       	function () {
                       		$(this).css({text-decoration: "underline"});
                       	},
                       	function () {
                       		$(this).css({text-decoration: "none"});
                       	}
                       	);
                       	*/
                  /*     $('#inside_gallery li a.current').hover(function  () {
	  $(this).css({
	    text-decoration: underline;
	  });
	}, function () {
	  var cssObj = {
			  text-decoration: none;
	  }
	  $(this).css(cssObj);
	});		*/
                       
                       /*   $("#right_slide2").click(function(e){
    var clicked = $(e.target); 
    $('.current').removeClass("current"); 
    clicked.addClass("current");
   }
)  */
                       	$("#right_slide2").click(function(){
                       		$('#inside_gallery2 li:has(a.current)').next().find('a').addClass("current").parent().prev().find('a').removeClass('current');
                       		var res = "/phpThumb/phpThumb.php?w=213&h=131&zc=1&src=" + $('#inside_gallery2 li a.current').attr("rel");
                       		//	alert (res);
                       		$("#img123").attr({ src: res });
                       	}
   
                       	)
                       	if (document.getElementById('inside_gallery2'))
      {
        position2 = parseInt($('#inside_gallery2').css('left').replace('px',''));
        number2 = $("#inside_gallery2").find('li').length;
        if (number2>1) {$('#left_slide2').css('display','block');$('#right_slide2').css('display','block')}
        different2 = number2-1;
        if (different2 <= 0) {} else
        $('#right_slide2').removeClass();
        different_flag2 = different2;
        $('#right_slide2').click(function(){
                                if (different2>0)
                                  {$('#left_slide2').removeClass();
                                   position2 = position2 - 177;
                                   $('#inside_gallery2').animate({left:position2}, "fast");
                                   different2 = different2 - 1;
                                   if (different2 == 0){$(this).addClass('no_active');}
                                   return false;}
                                   else return false;
                                             })
        $('#left_slide2').click(function(){
                                if (different2 < different_flag2)
                                  {$('#right_slide2').removeClass();
                                   position2 = position2 + 177;
                                   $('#inside_gallery2').animate({left:position2}, "fast");
                                   different2 = different2 + 1;
                                   if (different2 == different_flag2){$(this).addClass('no_active');}
                                   return false;}
                                   else return false;
      })}

/*                    
                       $("#right_slide2").click(function(){
                    	  
                    	   $('#inside_gallery2 li a.current').next('#inside_gallery2 li a').addClass("current");
                    	   $('#inside_gallery2 li a.current').prev('#inside_gallery2 li a').removeClass("current");
                    	 //  var ob = $('#inside_gallery2 li a.current').next();
                    	//   alert (ob);
                    	    var res = "/phpThumb/phpThumb.php?w=213&h=131&zc=1&src=" + $('#inside_gallery2 li a.current').attr("rel");
                    	   alert (res);
                      	   $("#img123").attr({ src: res });
                        
                       }
                       
                       )  */
                        $("#left_slide2").click(function(){
                        	
                    		$('#inside_gallery2 li:has(a.current)').prev().find('a').addClass("current").parent().next().find('a').removeClass('current');
                       		var res = "/phpThumb/phpThumb.php?w=213&h=131&zc=1&src=" + $('#inside_gallery2 li a.current').attr("rel");
                       		//	alert (res);
                       		$("#img123").attr({ src: res });	
                       }
                       )
                      // $('li.third-item').next().css('background-color', 'red');
                       $("li.third-item").click(function(){
                    		
                       	$('li.third-item').next().css('background-color', 'red');
                    	   $('li.third-item').next().addClass("third-item");
                    	   $('li.third-item').prev().removeClass("third-item");
                    	   $('li.third-item').prev().css('background-color', 'white');
                    	  
                    	  //$('#img123').src = $('li.third-item a').rel;
                    	  var relpict = $('li.third-item').attr("rel");
                    	  res = "http://misha/phpThumb/phpThumb.php?w=213&h=131&zc=1&src=" + relpict;
                    	 //alert(rel);
                    	 $("#img123").attr({ src: res });

                    	  //$('#img123').attr("src") = rel;
                    	   
                       }
                       )

});
