var theInt = null;
var $crosslink, $navthumb;
var curclicked = 0;

theInterval = function(cur){
	clearInterval(theInt);
			
	if( typeof cur != 'undefined' )
		curclicked = cur;
		
	$crosslink.removeClass("active-thumb");
	$navthumb.eq(curclicked).parent().addClass("active-thumb");
		$(".stripNav ul li a").eq(curclicked).trigger('click');
	
	theInt = setInterval(function(){
		$crosslink.removeClass("active-thumb");
		$navthumb.eq(curclicked).parent().addClass("active-thumb");
		$(".stripNav ul li a").eq(curclicked).trigger('click');
		curclicked++;
		if( 6 == curclicked )
			curclicked = 0;
		
	}, 6000);
};
	
$(document).ready(function(){ 	
	$('ul.sf-menu').superfish();
	
	$(document).pngFix();
	
	$('.webform').validate({
		rules: {
			errorPlacement: function(error, element) {
				if(element.is(":radio"))
					error.appendTo(element.parent().next().next());
				else if(element.is(":checkbox"))
					error.appendTo (element.next());
				else
					error.appendTo(element.parent().next());
			},
			success: function(label) {
				label.html("&nbsp;").addClass("checked");
			}
		}
	});
	
	$("#main-photo-slider").codaSlider();
	$navthumb = $(".nav-thumb");
	$crosslink = $(".cross-link");
	
	$navthumb.click(function() {
		var $this = $(this);
		theInterval($this.parent().attr('href').slice(1) - 1);
		return false;
	});
	
	theInterval();
	
	$('#menu li').hover(
		function () { $(this).css('background-position','0 0'); }, 
		function () { $(this).css('background-position','0 -20px'); }
	);
	
	$('.tip').qtip({
	   content: { attr: 'title' },
	   style: { classes: 'ui-tooltip-dark ui-tooltip-rounded ui-tooltip-shadow' }, 
	   position: { at: 'right center',  my: 'left center'  }
	})
	
});
