/*
*
*/
(function($) {
	var container;
	var infobox;
	var num;
	var img = "url(/images/header_animation/ie-numbers/";
	
	// activate or deactivate number
	function reactivate(obj, number, state)
	{
		// activate
		if (state == 1)
		{
			// check activating number by class name
			switch (number) {
				case "one":    num = 1; break; 
				case "two":    num = 2; break;
				case "three":  num = 3; break;
				case "four":   num = 4; break;
				case "five":   num = 5; break;
				case "six":    num = 6; break;
			}	
				
			number += "-act";
			
			// show info box
			infobox.slideDown(300);
			infobox.find('div').eq(num-1).show(0);
			infobox.find('.num > span').text(num);
		}
		// deactivate number
		else
		{
			// check deactivating number by class name
			switch (number) {
				case "one-act":    num = 1; break; 
				case "two-act":    num = 2; break;
				case "three-act":  num = 3; break;
				case "four-act":   num = 4; break;
				case "five-act":   num = 5; break;
				case "six-act":    num = 6; break;
			}	
				
			number = number.substr(0,number.indexOf('-'));	
			infobox.stop();
			
			// return normal opacity for fadeOut element
			if (jQuery.browser.msie) {
				obj.css("filter","alpha(opacity = 100)");
			}
			else 
			{
				obj.css({opacity: 1});	
			}
			
			// return normal height for slideDown element
			infobox.css("height", infobox.h+'px');
			infobox.slideUp(50);
			infobox.find('div').eq(num-1).hide(0);
		}
		
		
		obj.stop();
		obj.hide(0);
		obj.attr("class",number);
		obj.fadeIn(500);
	}
	
	// animate header
	$.fn.header_animate = function (){
		container = $(this);
		infobox = container.find('.info');
		infobox.h = infobox.height();
		$.fn.header_animate.init();
	}
	
	// init number mouse over and mouse out
	$.fn.header_animate.init = function(){
		container.find('.numbers > div').each(function(){
			
			$(this).mouseover(function(){
				reactivate($(this),$(this).attr("class"),1)});
				
			$(this).mouseout(function(){
				reactivate($(this),$(this).attr("class"),0)});
		})
	}
})(jQuery);
