var vAnimationInProgress=false;

$(document).ready(function(){
	$('ul>li:first-child,table>tbody>tr:first-child,table>tbody>tr>td:first-child').addClass('first-child');
	$('ul>li:last-child,table>tbody>tr:last-child,table>tbody>tr>td:last-child').addClass('last-child');
	$('img[src$=.png]').fixpng();
	$('.without-js').removeClass('without-js');
	$('li.dropdown, .footer-links a')
		.mouseover(	function(){
						$(this).addClass('hover');
					})
		.mouseout(	function(){
						$(this).removeClass('hover');
					});
	$('.tab-control').each(function(){
		//Hidden List Table
		var _tab = $(this);
		_tab.find('.tab-content:not(:first-child)').css('display','none');
		//Get First List Table ID
		var tmpID = _tab.find('.tab-titles>li:first-child').addClass('tab-title-selected').find('a').attr('href');
		$(tmpID).addClass('tab-content-selected');
		_tab.find('ul.tab-titles>li')
			.mouseover(function(){
				if(vAnimationInProgress==false){
					vAnimationInProgress=true;
					//Get List Table ID
					var tabContentID = $(this).find('>a').attr('href');	
					var _parent = $(this).parents('ul.tab-titles');
					_parent.find('li.tab-title-selected').removeClass('tab-title-selected');
					$(this).addClass('tab-title-selected')
					_tab.find('.tab-content-selected').removeClass('tab-content-selected')
						.hide();
					$(tabContentID).addClass('tab-content-selected')
						.show();//'1',function(){
							vAnimationInProgress=false;
						//});
				}
				return false;
			});
	});
	$('.tab-content').equalizeCols();
});

/* =jQuery Plugins*/
(function($){
	/* =plug-in : fix-png */
	$.fn.fixpng = function(){
		var hack = {
			isOldIE: $.browser.msie && $.browser.version < 7,
			filter: function(src){ return "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='scale',src='"+src+"');"; }
		};
		return this.each(function(){
			if(hack.isOldIE){
				var $$=$(this);
				if($$.attr('src')){
					var span = document.createElement('span');
					$(span).attr({
						id: $$.attr('id'), className: $$.attr('class')
					});
					$(span).css({
						display: 'inline-block', width: $$.width(), height: $$.height(), filter: hack.filter($$.attr('src')), float: $$.attr('align')=='left'?'left':($$.attr('align')=='right'?'right':'none')
					});
					this.outerHTML = span.outerHTML;
				}
			}
		});
	};
	/* =plug-in : equal-heights */
	$.fn.equalizeCols = function(){
		var height = 0,
			 reset = $.browser.msie ? "1%" : "auto";
		return this
			.css("height", reset)
			.each(function() {
				height = Math.max(height, $(this).outerHeight(true));
			})
			.css("height", height)
			.each(function() {
				var h = $(this).outerHeight(true);
				if (h > height) {
					$(this).css("height", height - (h - height));
				};
			});
	};
})(jQuery);