$(document).ready(function(){
	
	$('label.overlabel').overlabel();
	$('.selected-box, .box').box_round('default');	
	//$(
	$(".list-recources li:odd").addClass("odd");
	//Finding and Hidden the Tab Content; except the first tab content 
	$('.tab-control').each(function(){
		//Hidden List Table
		$(this).find('.tab-content').not(':first-child').each(function(){
			$(this).css({display:'none'});
		});
		$('.tab-control ul.tab-titles li:hover').mouseover(function(){$(this).addClass('hover');}).mouseout(function(){$(this).removeClass('hover');});
		//Get First List Table ID
		var tmpID = $(this).find('.tab-titles li:first-child').addClass('tab-title-selected').find('a').attr('title');
		$(tmpID).addClass('tab-content-selected');
		$(this).find('ul.tab-titles>li>a').mouseover(function(){			
				//Get List Table ID
				var tabContentID = $(this).attr('title');	
				$(this).parent().parent().find('li.tab-title-selected').removeClass('tab-title-selected');
				$(this).parent().addClass('tab-title-selected').parent().parent()
					.find('.tab-content-selected').removeClass('tab-content-selected')
					.hide();
				$(tabContentID).addClass('tab-content-selected')
					.show();//'1',function(){
						vAnimationInProgress=false;
					//});
			$('.content-left, .content-section, .content-right').equalizeCols();
			return false;
		});
	});

	if($(".content-landing").length > 0){
		$('.content-left, .content-landing').equalizeCols();	
	}
	else if($(".content-right").length > 0){
		$('.content-left, .content-section, .content-right').equalizeCols();	
	}
	else {
		$(".col").equalizeCols();	
	}
	
	
	if($("div[id^='EkTb']").length > 0) {
	$(".content-home > div").css({"width": "317", "display":"inline-block", "float":"left", "margin-right" : "10"});
	$(".content-home > div:last").css("margin-right", "0");
	$(".footer > div").css("width", "48%");
	$(".footer > div:last").css({"margin-top": "15", "width": "49%", "float": "right"});
	$("div[id$='RightContent_ContentBlock2']").css("width", "791");
	if($.browser.mozilla) {
		$("#main-container").mousemove(function() {
			$("div[id^='EkTbBase']").css("overflow", "hidden");
			$("div[id^='EkTbOuterElmt']").css("overflow", "hidden");											
		});
	}
	}
	
	/*
	if($(".content-home .col").length > 0){
		$(".content-home .col").each(function() {
			var width = $(this).width();
			var css = "{'width':'"+width+"','display': 'inline-block'}";
			alert(css);
			$(this).parent().css(css);
			$(this).parent().parent().css(css);
			$(this).parent().parent().parent().css(css);
		});
	}*/
	
	
});



/* =jQuery Plugins*/
(function($){
	/* = plug-in : overlabel */
	$.fn.overlabel = function(options){
		var opts = $.extend( {},$.fn.overlabel.defaults, options );
		var selection = this.filter('label[for]').map(function(){
				var label = $(this);
				var id = label.attr('for');
				var field = $('#'+id);
				if(!field) return;
				var o = $.meta ? $.extend( {}, opts, label.data() ) : opts;
				label.addClass(o.label_class);
				var hide_label = function(){ label.css(o.hide_css) };
				var show_label = function(){ this.value || label.css(o.show_css) };
				$(field)
					.parent().addClass(o.wrapper_class).end()
					.focus(hide_label).blur(show_label).each(hide_label).each(show_label);
				return this;
		});
		return opts.filter ? selection : selection.end();
	};
	$.fn.overlabel.defaults = {
		label_class: 'overlabel-apply',
		wrapper_class: 'overlabel-wrapper',
		hide_css: { 'display': 'none' },
		show_css: { 'display': 'block' },
		filter: false
	};
	/* =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;
				}
			}
		});
	};
	$.fn.box_round = function(options) {
		var type = options ? options : 'default'; /*default, only-top, only-bottom*/
		return this.each(function() {
		if (type == 'default' || type == 'only-top') {
		var _tleft = document.createElement("span"); _tleft.className = "corner tl";
		$(this).prepend(_tleft);
		}
		if (type == 'default' || type == 'only-top') {
		var _tright = document.createElement("span"); _tright.className = "corner tr";
		$(this).prepend(_tright);
		}
		if (type == 'default' || type == 'only-bottom') {
		var _bleft = document.createElement("span"); _bleft.className = "corner bl";
		$(this).prepend(_bleft);
		}
		if (type == 'default' || type == 'only-bottom') {
		var _bright = document.createElement("span"); _bright.className = "corner br";
		$(this).prepend(_bright);
		}
		if (type == 'title' || type == 'title-left') {
		var _bleft = document.createElement("span"); _bleft.className = "left-title";
		$(this).prepend(_bleft);
		}
		if (type == 'title' || type == 'title-right') {
		var _bright = document.createElement("span"); _bright.className = "right-title";$(this).prepend(_bright);}});
	};
	/* =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);
