/**
 * @requires jQuery 1.6.2+
 * @requires DD_belatedPNG
 *
 */

// pngfix ( for IE 6 )
if( typeof DD_belatedPNG != 'undefined' ) {
	DD_belatedPNG.fix('#content_header img');
}

jQuery.noConflict();
jQuery(function($) {

	/**
	 * lightbox
	 *
	 */
	if( typeof $.fn.lightBox == 'function' ) {
		$('a[href$=jpeg], a[href$=jpg], a[href$=png], a[href$=gif]').each(function(){
			$(this).lightBox();
		});
	}

	/**
	 * .hover-hl (highlight)
	 *
	 */
	$('.hover-hl').each(function(){
		$(this).hover(
			function(){
				$(this).animate({opacity: 0.85}, 100);
			},
			function(){
				$(this).animate({opacity: 1}, 100);
			}
		);
	});

	/**
	 * .hover-ro (rollover)
	 *
	 */
	$('.hover-ro img, img.hover-ro, input[type=image].hover-ro').each(function(){
		var thisSrc = this.src;
		var overSrc = this.src.replace(/\.(gif|png|bmp|jpe?g)$/, '_on.$1');
		var overObj = new Image();
		overObj.src = overSrc;
		$(this).hover(
			function(){ this.src = overSrc; },
			function(){ this.src = thisSrc; }
		);
	});

	/**
	 * .pagetop
	 *
	 */
	$('#pagetop a, .pagetop a').each(function(){
		$(this).click(function(){
			$('html, body').animate({ scrollTop: 0 }, '3000', 'easeOutExpo');
			return false;
		});
	});

	/**
	 * anchor link
	 *
	 */
	$('a[href^=#]').each(function(){
		var $a = $(this);
		$a.click(function(){
			var target = $($a.attr('href')).offset();
			var wh = $(window).height();
			var dh = $(document).height();
			var st = ( dh - target.top > wh ) ? Math.floor(target.top) : Math.floor(dh - wh);
			$('html, body').animate({ scrollTop: st }, '3000', 'easeOutExpo');
			return false;
		});
	});

	/**
	 * .faqArea
	 *
	 */
	$('.faqArea').each(function(){
		var $a = $('.faq_answer', this);
		$a.hide();

		$('.faq-q', this).click(function(){
			$a.slideToggle(250, 'swing');
			return false;
		});
	});

	/**
	 * .tabArea
	 *
	 */
	$('.tabArea').each(function(i){
		var $tabLinks = $('.tabs a', this);
		var $contents = $('.tab_content', this);

		function initArea() {
			$tabLinks.stop(true, true).removeClass('current');
			$contents.stop(true, true).hide();
		};

		// show first
		initArea();
		$contents.eq(0).show();
		$tabLinks.eq(0).addClass('current');

		$tabLinks.each(function(i){
			var $tabLink = $(this);
			var targetID = $(this).attr('href');
			$(this).unbind('click');
			$(this).click(function(){
				initArea();
				$(targetID).fadeIn(800);
				$tabLink.addClass('current');
				return false;
			});
		});
	});

	/**
	 * odd
	 *
	 */
	//$('.section table').each(function(){
	//	$('tr:nth-child(odd)', this).addClass('odd');
	//});
	$('.section ul.list-zebra').each(function(){
		$('li:nth-child(2n+1)', this).addClass('odd');
	});
	$('.section ul.list-2zebra').each(function(){
		$('li:nth-child(4n+1)', this).addClass('odd');
		$('li:nth-child(4n)', this).addClass('odd');
	});

});

