//Index:Tab
$.auto={
	init:function(){
		for (module in $.auto) {
			if($.auto[module].init)
			$.auto[module].init();
		}
	}
};

$(document).ready($.auto.init);
// Switches tabs on click
$.auto.tabs = {
	init: function() {
		$('.Tabchange').each(function(){
			var f = $.auto.tabs.click;
			var group = this;
			$('.ChoiceBtn li,', group).each(function(){
				$(this).css("cursor","pointer");
				this.group = group;
				$(this).click(f);
				$('#'+this.id+'Tabchange').hide();
			});
		});
	},
	click: function(){
		var tab = $('#'+this.id+'Tabchange').get(0);
		$('.ChoiceBtn li,', this.group).each(function(){
			$(this).removeClass('on');
			$('#'+this.id+'Tabchange').hide();
		});
		if($(this).parent().hasClass('ChoiceBtn')){
			$(".ChoiceBtn li img").each(function(){
				this.src=this.src.replace("_on","");
				if($(this).hasClass("active")){
					$(this).removeClass("active");
				}
			});
		} else if($(this).parent().hasClass('ChoiceBtn')){
			$(".ChoiceBtn li img").each(function(){
				this.src=this.src.replace("_on","");
				if($(this).hasClass("active")){
					$(this).removeClass("active");
				}
			});
		}	
		$(this).find("img").addClass("active");
		$(this).find("img").attr("src",$(this).find("img").attr("src").replace(".jpg","_on.jpg"));
		$(this).addClass('on');
		$(tab).fadeIn("slow");
		this.blur();
		return false;
	}
};

function imageEffect(){
	//$("#Content .Tabchange ul.loading li").hide();
	var num = 0;
	var int = setInterval(function(){
		if(num == 7){
			clearInterval(int);
				setTimeout(function(){
					//end
					Timer();
				},400);
			} else {
			$('#Content .Tabchange ul.loading li').eq(num).fadeIn(1000);
		}
		num++;
	},150);
}
function Timer(){
	setTimeout(loading,2000);
}
function loading(){
	$("#Content .Tabchange ul.loading").fadeOut("1000",function(){
		$("#Content .ChoiceBtn,#Content .MainImage").show();
		$(".ChoiceBtn li:first").click();
	});
}

$(function(){
	imageEffect();
});
