$(document).ready(function(){
	
	$('li:first-child, tr:first-child,td:first-child, div:first-child, dd:first-child').addClass('first-child');	
	$('li:last-child,tr:last-child,td:last-child, div:last-child, dd:last-child').addClass('last-child');
	
	
	$('ul.main-menu li').hover(function(){
											$(this).addClass('hover');
										},function(){
											$(this).removeClass('hover');
										});
	
	$('label.overlabel').overlabel();
	$('img[src$=.png]').fixpng();
	$('.without-js').removeClass('without-js');
	$('.blue-box, .blue-box-large, .gris-box .content-box').append("<div class='bg-bottom'>&nbsp;</div>");
	
	$(".eq").equalizeCols();
	$(".internal .eq2").equalizeCols();
	$(".content-banner, .img-container").equalizeCols();
	$('.banner li').addClass('clearfix');
	$('label.overlabel').overlabel();

	if(jQuery.browser.msie && parseInt(jQuery.browser.version) == 7){
		$(".content-banner").removeAttr("style");
	}


});

/* =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.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);