﻿var tempi=1;
var obj;
var tout;

$(function(){
		tout= setInterval("showImg()",5000); 
	    jQuery(".smallimg").css("opacity","0.5");
		
		jQuery(".smallimg:eq(0)").css("opacity","1").css("border","solid 1px #69C");  
		jQuery(".smallimg").hover(function(){
										tempi=$(".smallimg").index(this)+1;
										clearInterval(tout);
										tout= setInterval("showImg()",5000);  
										jQuery(".smallimg").css("opacity","0.5").css("border","solid 1px #fff");   
										$(this).animate({"opacity":"1"},200).css("border","solid 1px #69C");  
										obj=$(this);
										
										jQuery(".bigimg").fadeOut("200",function(){
													$(".bigimg").attr("src",obj.attr("rel"));						
													$(".bigimg").fadeIn()							
																				});										
										   }	   
										   );
	$('a').bind('focus',function(){
			if(this.blur){
					this.blur();
			};
	});
	
	
	
})	


function showImg()
{
	if(tempi>=$(".smallimg").size())
	{
		tempi=0;
	}
	
	var martop;
	if(tempi>=3)
	{
		margtop=-(10+100+3+4)*(tempi-3);
		$("#small").css("margin-top",margtop+"px");
	}
	var img=$(".smallimg:eq("+tempi+")").attr("rel");
	$(".bigimg").css("opacity",0).css("top",0).attr("src",img);		
	$(".bigimg").stop().animate({top: 0, opacity: '1' }, { duration: 800});
	

	jQuery(".smallimg").css("opacity","0.5").css("border","solid 1px #fff");  
	$(".smallimg:eq("+tempi+")").css("opacity","0.5").css("border","solid 1px #69C");  
	$(".smallimg:eq("+tempi+")").animate({"opacity":"1"},200); 
	tempi++;
}

(function($){
	$.fn.infowuxiMarquee = function(o){
		o = $.extend({
			direction : "left",
			amount: 1,
			speed: 100
		}, o || {});
		
		return this.each(function(){
			var d = $(this), u = $("ul", d), l = $("li", u), s = 0, c = 0;
			//Css
			d.css({overflow: "hidden", position: "relative"});
			u.css({margin: "0", padding: "0", position: "relative", "list-style": "none"});
			l.css({overflow: "hidden"});
			if(o.direction == "left") l.css({float: "left"});
			//All
			for(var i=0; i<l.size(); i++){
				s += o.direction == "left" ? l.eq(i).outerWidth(true) : l.eq(i).outerHeight(true);
			}
			//u Css
			if(o.direction == "left") u.css({width: s*3});
			u.append(l.clone()).append(l.clone());
			//Go
			function go(){
				c += o.amount;
				if(c > s) c = 1;
               	//u.animate(o.direction == "left" ? { left : -c } : { top : -c }, 0);
				u.css(o.direction == "left" ? { left : -c } : { top : -c })
				//o.direction == "left" ? d.scrollLeft(c) : d.scrollTop(c);
			}
			//Start
			var move = setInterval(function(){ go(); }, o.speed);
			d.hover(function(){clearInterval(move);},function(){clearInterval(move);move = setInterval(function(){ go(); }, o.speed);});
		});
	}
})(jQuery);


$(function(){

	$('.scrollimg').infowuxiMarquee();

})	




