﻿/**********************************************************************************************

  CSS on Sails Framework
  Title: Office of the Federal Safety Commission
  Author: XHTMLized (http://www.xhtmlized.com/)
  Date: July 2010

***********************************************************************************************/

/**
 *
 * Copyright (c) 2007 Tom Deater (http://www.tomdeater.com)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */

(function($) {
	/**
	 * equalizes the heights of all elements in a jQuery collection
	 * thanks to John Resig for optimizing this!
	 * usage: $("#col1, #col2, #col3").equalizeCols();
	 */

	$.fn.equalizeCols = function(){
		var height = 0,
			reset = $.browser.msie && $.browser.version < 7 ? "1%" : "auto";

		return this
			.css("height", reset)
			.each(function() {
				height = Math.max(height, this.offsetHeight);
			})
			.css("height", height)
			.each(function() {
				var h = this.offsetHeight;
				if (h > height) {
					$(this).css("height", height - (h - height));
				};
			});

	};

})(jQuery);

$(document).ready(function() {

	//
	$('a[rel=_blank]').click(function(){
		this.target = "_blank";
	});

	//
	if (($.browser.msie)){

		//
		$('table.default tbody tr:nth-child(even) th, table.default tbody tr:nth-child(even) td').css({'padding': '3px 0 2px 7px', 'background':'#ededed' });
		$('.content .resource-list dl dd:nth-child(odd)').css({'background':'#f2f2f2' });

	}

	//
	if (($.browser.msie) && ($.browser.version == "8.0")){

		//
		$('html').addClass('ie8');

	}

	//
	if (($.browser.msie) && ($.browser.version == "7.0")){

		//
		$('html').addClass('ie7');

		$('.wrapper-content .breadcrumbs a').after(" >");

		//
		$('input[type="text"]').focus(function() {
			$(this).addClass('focus');
		});
		$('input[type="text"]').blur(function() {
			$(this).removeClass('focus');
		});

	}

	if (($.browser.msie) && ($.browser.version == "6.0")){

		//
		$('html').addClass('ie6');

		//
		$('input[type="text"]').focus(function() {
			$(this).addClass('focus');
		});
		$('input[type="text"]').blur(function() {
			$(this).removeClass('focus');
		});

		//
		$("#navigation li").hover(
			function () {
				$(this).addClass("hover");
			},
			function () {
				$(this).removeClass("hover");
			}
		);

		//
		$('.tabs-wrapper .tabs .tabs-menu li:first-child').css({'background':'none'});
		$('.wrapper-content .breadcrumbs a').after(" >");

		//
		$('input[type=text]').addClass("text");
		$('input[type=password]').addClass("text");
		$('input[type=button]').addClass("button");
		$('input[type=reset]').addClass("reset");
		$('input[type=submit]').addClass("submit");
		$('input[type=radio]').addClass("radio");
		$('input[type=checkbox]').addClass("checkbox");
		$('input[type=file]').addClass("file");
		$('input[type=image]').addClass("image");

		$('.content .news .h3 h3').addClass("fixPNG");
		$('.box h3').addClass("fixPNG");
		$('.box').addClass("fixPNG");
		$('.wrapper-content ul li').addClass("fixPNG");
		$('.tabs-wrapper .tabs .tabs-menu li a').addClass("fixPNG");
		$('.tabs-wrapper .tabs .tabs-menu li').addClass("fixPNG");
		$('.tabs-wrapper .tabs .tabs-content ul li').addClass("fixPNG");
		$('.tabs-wrapper .tabs').addClass("fixPNG");
		$('.tabs-wrapper .box-left').addClass("fixPNG");
		$('.h1 h1').addClass("fixPNG");
		$('#header .middle a img').addClass("fixPNG");
		$('#header .tools-top .contactus').addClass("fixPNG");
		$('#header').addClass("fixPNG");
		$('#footer .footer-top').addClass("fixPNG");
		$('#footer .footer-bottom').addClass("fixPNG");
		$('#footer .footer-top ul li').addClass("fixPNG");
		DD_belatedPNG.fix('.fixPNG');

	}

});


/*  Homepage Banner
------------------------------------------------------------------------------*/
function initBanner(){
	$("[id^='tab-button']").click(function(e){
		var thisIndex = $(this).attr('id').slice(-1);
		var thisLength = $("[id^='tab-button']").length;
		for(i=0; i<thisLength; i++){
			if(i==thisIndex){
				$('#tabs-content_'+i).show();
				$('.tabs-menu').addClass('ico_0'+(i+1));
				$('#tab-button_'+i).addClass('active');
				} else {
				$('#tabs-content_'+i).hide();
				$('.tabs-menu').removeClass('ico_0'+(i+1));
				$('#tab-button_'+i).removeClass('active');
			}
		}
		//Prevent event propagation on click
  		e.preventDefault();
	});
}


$(window).load(function() {
	initBanner();
});
