var theInt 	= null;
var j$crosslink, j$navthumb;
var curclicked 	= 0;

theInterval = function(cur){
	clearInterval(theInt);
	
	if(typeof cur != "undefined") curclicked = cur;
	
	j$crosslink.removeClass("active-thumb");
	j$navthumb.eq(curclicked).parent().addClass("active-thumb");
	j$(".stripNav ul li a").eq(curclicked).trigger("click");
	
	theInt = setInterval(function(){
		j$crosslink.removeClass("active-thumb");
		j$navthumb.eq(curclicked).parent().addClass("active-thumb");
		j$(".stripNav ul li a").eq(curclicked).trigger("click");
		curclicked++;
		if(curclicked == 5) curclicked = 0;
	}, 6000);
};


j$(function() {

	j$("div#slider").codaSlider({
		autoSlide: true,
		autoSlideInterval: 3000,
		slideEaseDuration: 800,
		slideEaseFunction: "easeOutQuad"
	});
	
	j$navthumb = j$(".nav-thumb");
	j$crosslink = j$(".cross-link");
	
	j$navthumb.click(function() {
		var j$this = j$(this);
		theInterval(j$this.parent().attr('href').slice(1) - 1);
		return false;
	});
	
	theInterval();
	
	j$("div.loading").show();
	j$("div.slides").hide();
	
	j$("div.loading").delay(1500).fadeOut(function() {
		j$("div.loading").fadeOut();
		j$("div.slides").fadeIn();
		j$("div#slidesDummy").fadeIn();
	}).delay(500).fadeOut(function() {
		j$("ul#menu").animate({marginTop:"0px"},1000,"easeOutBounce");
		j$("div#slidesDummy").hide();
		j$("div#slider").loopedSlider({
			autoStart: 20000,
			restart: 20000
		});
	});
	
	j$("div#blockImg01").hover(function() {
		j$(this).find("p").stop().animate({marginTop:"0px"},500,"easeInOutQuad");
	},function() {
		j$(this).find("p").stop().animate({marginTop:"-125px"},500,"easeInOutQuad");
	});
	
	j$("div#blockImg02").hover(function() {
		//j$(this).find("p").stop().animate({marginLeft:"-240px"},500,"easeInOutQuad");
		j$(this).find("p").stop().animate({marginTop:"0px"},500,"easeInOutQuad");
	},function() {
		//j$(this).find("p").stop().animate({marginLeft:"0"},500,"easeInOutQuad");
		j$(this).find("p").stop().animate({marginTop:"-125px"},500,"easeInOutQuad");
	});
	
	j$("div.service03").hover(function() {
		j$(this).find(".service03Image").stop().animate({marginTop:"-110px"},500,"easeInOutQuad");
	},function() {
		j$(this).find(".service03Image").stop().animate({marginTop:"0px"},500,"easeInOutQuad");
	});
	
	j$("div.service06").hover(function() {
		j$(this).find(".service06Image").stop().animate({marginTop:"-110px"},500,"easeInOutQuad");
	},function() {
		j$(this).find(".service06Image").stop().animate({marginTop:"0px"},500,"easeInOutQuad");
	});
});

