var slideIndex=0;
var slides;
var smooth = screen.fontSmoothingEnabled;
var ie6 = ((navigator.appVersion.indexOf("Win")!=-1) && (navigator.appVersion.indexOf("MSIE 6")!=-1));
var ie7 = ((navigator.appVersion.indexOf("Win")!=-1) && (navigator.appVersion.indexOf("MSIE 7")!=-1));
var t;
$(document).ready(function () {

		
//if ( $("body").addClass("win");
if(smooth) $("body").removeClass("win");


//### Slideshow

	if($("div#slides").length>0) {
		slides = $("div#slides ul li");
		//hide all but the first slide
		slides.css("opacity",0).eq(0).css("opacity",1);
		//start the animation
		s = setTimeout("$(slides).animateSlides()", slideSpeed);
	}
	
//### Fadey links

	if(!ie6 && !ie7) $("div#home-games li").fader();
	
//#### Tooltips

	$("ul.social li").tip();

});

jQuery.fn.extend ({
    animateSlides:function() {
        var t = $(this);
        $(t.eq(slideIndex)).animate({
			opacity: 0		
        }, transitionSpeed);
        slideIndex = ((slideIndex+1) > (slides.length-1)) ? 0 : (slideIndex+1);
        $(t.eq(slideIndex)).animate({
			opacity: 1		
        }, transitionSpeed, function() {
        	s = setTimeout("$(slides).animateSlides()", slideSpeed);	
        });
        
	},
	fader:function() {
		var t = $(this);
		t.hover(function() {
			$(this).animate({
				opacity: .6	
			}, 200)
		}, function() {
			$(this).animate({
				opacity: 1	
			}, 500)	
		});
	},
	tip:function() {
		var tt = $(this);
		tt.each(function() {
			t = $(this);
			var title = t.attr("title");
			t
				.removeAttr("title")
				.css("position","relative");
			t.hover(function() {
				$(this).append('<div class="tt"><span>' + title + '</span></div>');
				$(this).find(".tt").css("opacity",".8");
			}, function() {
				$(this).find(".tt").remove();	
			});		
		});

			
	}
});

