// SLIDER VARS
var moving = false;
var pWidth = 600;
var transTime = 500;

// FADER VARS
var timeout = 5000;
var inc = 0;
var total = 0;
var obj;

$(document).ready(function(){	

	var numPanels = $('div.col-left div.content').children("div.panel").size();

	/*
	$("div.arrow_buttons a.next").click(function(){
		if ( moving==false ) {
			moving=true;
			var obj1 = $(this).parents("div.col-left");
			var obj2 = $(this).parents("div.content");
			var offset = obj2.offset().left - obj1.offset().left;
			$("div.tabs a").each(function(){ $(this).removeClass("active") });
			$("a#tab"+(Math.abs(offset/pWidth)+2)).addClass("active");
			obj2.animate({ left:(offset-pWidth) },transTime,function(){ moving=false; });
		}
		return false;
	});

	$("div.arrow_buttons a.prev").click(function(){
		if ( moving==false ) {
			moving=true;
			var obj1 = $(this).parents("div.col-left");
			var obj2 = $(this).parents("div.content");
			var offset = obj2.offset().left - obj1.offset().left;
			$("div.tabs a").each(function(){ $(this).removeClass("active") });
			$("a#tab"+(Math.abs(offset/pWidth))).addClass("active");
			obj2.animate({ left:(offset+pWidth) },transTime,function(){ moving=false; });
		}
		return false;
	});
	
	$("div.arrow_buttons a.prev-disabled").click(function(){ return false; });
	$("div.arrow_buttons a.next-disabled").click(function(){ return false; });
	*/

	// IE6 wont redraw the nav so add a second class to break it
	$("ul#nav li a").hover( function () { $(this).children("span").removeClass("ie6hide"); }, function () { $(this).children("span").addClass("ie6hide"); });

	// Fader Setup
	obj = $("div.fader img");
	total = obj.size();
	inc = total;
	setTimeout("fade()",timeout);


});

function fade() {
	if (inc<2) {
		inc = total;
		obj.show();
	}
	obj.eq(inc-1).fadeOut(2000);
	setTimeout("fade()",timeout);
	inc --;
}

function tabClick(tabid) {
	if ( moving==false ) {
		moving=true;
		
		$("div.tabs a").each(function(){ $(this).removeClass("active") });
		$("a#tab"+tabid).addClass("active");
		$("div.col-left div.content").animate({ left:-(tabid*pWidth)+pWidth },transTime,function(){ moving=false; });
	}
}
