var tab_index=0;
var tab_count=6;
var tab_anim="++";
var tab_interval=6000;

$(document).ready(function() {
	//dropdown menu support for ie6
	$("li").hover(function(){$(this).addClass("hover");},function(){$(this).removeClass("hover");});
	
	
	//colorbox initialize
	$('a.colorbox').colorbox();
	
	//initialize homepage tabs
	setTimeout("setTab('++');",tab_interval);
	
	var pathname = window.location.pathname;

	if (pathname !== "/") {
		
		//if ltie7
		if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		
		} else {
			
			//header navigation logo background animation
			$('#header ul.navigation li.logo a')
			.css( {backgroundPosition: "0 0"} )
			.mouseover(function(){
				$(this)
				.stop().stop().stop()
				.animate({backgroundPosition:"(0 -186px)"}, {duration:200})
				.animate({backgroundPosition:"(-200px -186px)"}, {duration:0})
				.animate({backgroundPosition:"(-200px 0)"}, {duration:200})
			})
			.mouseout(function(){
				$(this)
				.stop().stop().stop()
				.animate({backgroundPosition:"(-200px -186px)"}, {duration:200})
				.animate({backgroundPosition:"(0 -186px)"}, {duration:0})
				.animate({backgroundPosition:"(0 0)"}, {duration:200});
			});
			
		};
		
	} else {
		$('#header ul.navigation li.logo a').css({"cursor":"default"});
	}
	
});

function setTab(index) {
	var $drawers=$("ul.drawers");
	if($drawers.length){
		if(((index=="++")&&(tab_anim==null))==false){
			if(index=="++"){index=tab_index+1;}else{tab_anim=null;};
			if(index>=tab_count){index=0;}
			var $new=$($drawers.children("li")[index]);
			if($new.hasClass("active")==false){
				tab_index=index;
				$drawers.children(".active").animate({'width':'39px'},500,function(){
					$(this).removeClass("active");
					$new.animate({'width':'560px'},500,function(){
						$(this).addClass("active");
						if(tab_anim=="++"){
							setTimeout("setTab('++');",tab_interval);
						};
					});
				});
			};
		};
	};
	return false;
	
}