/**
 * @name main.js
 * @fileOverview
 * @version 1.0
 * @description
 * <p>(c) FOURDIGIT Inc. Licensed <a href="http://ja.wikipedia.org/wiki/GNU_General_Public_License">GNU General Public License</a>.</p>
 */
//他ライブラリと共存する場合、下の一行削除($無効化)
//jQuery.noConflict();
(function($){
	var config = function () {
	//bodyのクラスにブラウザ情報を追加
		$.addClassUA();
	//easyOverのターゲット設定
		$("img.ahover, .ahoverArea img").easyOver();
	//IE5,6にてPNG有効化 (pngfixの読み込みが必要)
		$("img[src$=png],p.png").enablePNG();
	//Flash
		//$("object, embed").enableFlash();
	//ポップアップリンクに置換
		$(".commonPop").easyPop();
	//他ドメインリンク時にpageTracker有効化
		//$("a,area").blankLogToGoogle();
	//アンカーリンクをスムージング
		$("a[href^=#]").smoothScroll();
	//対象の要素をスクロールに追従するようにする
		//$("#fixBox").fixPosition("stopperID","normal");
	}
	//onload
	$(function() {
		config();
		switch (jQuery("div.page").attr("id")) {
			case "pageID":
				//eachPageFunction
			break;
		}
		if($('form.formArea')[0]) {
		/* form - textType or checkType or passwordType or fileType */
			$('.formArea input[type=checkbox],form.formArea input[type=radio]').addClass('inputBtns');
			$('form.formArea input[type=text]').addClass('inputTexts');
			$('form.formArea input[type=password]').addClass('inputPw');
			$('form.formArea input[type=file]').addClass('inputFile');
		}

		/* allOver */
		$('.allOver').hover(
			function(){
				$(this).addClass('hoverArea');
			},
			function(){
				$(this).removeClass('hoverArea');
			}
		);
		$('.allOver').click(
			function(){
				if($(this).find('a.commonPop')[0]){
					$(this).find('a').click();
					return false;
				}else{
					if($(this).find('a')[0].target == "_blank") {
						window.open($(this).find('a')[0].href);
						return false;
					}else{
						location.href = $(this).find('a')[0].href;
					}
				}		
			}
		);

		/* donatePriceInput */
		$('dl.donatePrice').each(function(){
			var parent = $(this);
			$(this).find('dd').each(function(){
				var donatePriceArea = $(this);
				$(this).find('select').change(function(){
					$(this).find('option').each(function(){
						$(donatePriceArea).find('div.priceOtherInput').slideUp(
							20,
							function(){
								var ddHeight = $(parent).find('dd').height();
								$(parent).find('dt').height(ddHeight);
								$(donatePriceArea).find('div.priceOtherInput input').val('');
							}
						);
					});
					$(this).find('option.priceOther:selected').each(function(){
						$(donatePriceArea).find('div.priceOtherInput').show(
							20,
							function(){
								var ddHeight = $(parent).find('dd').height();
								$(parent).find('dt').height(ddHeight);
							}
						);
					});
				});
			});
		});

		/* heightAuto */
		function heightAuto(){
			$('form.formArea .section dl').each(function(){
					var ddHeight = $(this).find('dd').height();
					$(this).find('dt').height(ddHeight);
			});
		}
		heightAuto();

		/* donateStop */
		$('#donateStop').click(function(){$('#donateStopArea').slideToggle();});

		/* newMemberRepair */
		$('#newMemberRepair').hover(
			function(){
				$(this)
					.css('background-position','left -40px')
					.css('color','#ff0000')
					.css('text-decoration','none');
			},
			function(){
				$(this)
					.css('background-position','left top')
					.css('color','#000000')
					.css('text-decoration','underline');
			}
		);
		/* stepArea */
		$('#stepArea dt:has(br)').addClass('line2');
	});
})(jQuery);
