jQuery.noConflict();


// SMOOTH SCROLL //
/* ------------------------------------------------------------ */

jQuery(function($) {
$(function(){
	// #で始まるアンカーをクリックした場合に処理
	$('a[href^=#], area[href^=#]').click(function() {
		var tabClass = $(this).parent().parent().parent().attr("class");
		if(tabClass != "tab-navi"){
			// スクロールの速度
			var speed = 400;// ミリ秒
			// アンカーの値取得
			var href= $(this).attr("href");
			// 移動先を取得
			var target = $(href == "#" || href == "" ? 'html' : href);
			// 移動先を数値で取得
			var position = target.offset().top;
			// スムーススクロール
			$($.browser.safari ? 'body' : 'html').animate({scrollTop:position}, speed, 'swing');
			return false;
		}
	});
});
});


/* ---------------------------------------------------------------
 * rollover.js
--------------------------------------------------------------- */
// initRollOverImages //
(function($){
	$(document).ready(function () {
		var image_cache = new Object();
			$("a.rollover img,img.rollover, input.rollover").each(function(i) {
			var imgsrc = this.src;
			var dot = this.src.lastIndexOf('.');
			var imgsrc_on = this.src.substr(0, dot) + '-on' + this.src.substr(dot, 4);
			image_cache[this.src] = new Image();
			image_cache[this.src].src = imgsrc_on;
			$(this).hover(
			function() { 
			this.src = imgsrc_on; 
			},		// onmouseover
			function() { 
			this.src = imgsrc; 
			});		// onmouseout
		});
	});
})(jQuery);


/* ---------------------------------------------------------------
 * popup window
--------------------------------------------------------------- */
// initRollOverImages //
(function($){
	$(document).ready(function () {
		$("a.popuplink").each(function() {
			var target = $(this);
			target.click(function(e) {
				e.preventDefault();
				var href = target.attr("href");
				if (href) {
					window.open(href, '_blank', 'width=620, height=440, menubar=no, toolbar=no, scrollbars=yes');
				}
				return false;
			});
		});
	});
})(jQuery);


/* ---------------------------------------------------------------
 * jquery-auto-height.js
 * Copyright (c) 2010 Tomohiro Okuwaki (http://www.tinybeans.net/blog/)
 * Licensed under MIT Lisence:
 * http://www.opensource.org/licenses/mit-license.php
--------------------------------------------------------------- */
//BLOCK HEIGHT
(function($){
	$.fn.autoHeight = function(options){
		var op = $.extend({
		
			column  : 0,
			clear   : 0,
			height  : 'minHeight',
			reset   : '',
			descend : function descend (a,b){ return b-a; }
		
		},options || {}); // optionsに値があれば上書きする

		var self = $(this);
		var n = 0,
			hMax,
			hList = new Array(),
			hListLine = new Array();
			hListLine[n] = 0;

		// 要素の高さを取得
		self.each(function(i){
			if (op.reset == 'reset') {
				$(this).removeAttr('style');
			}
			var h = $(this).height();
			hList[i] = h;
			if (op.column > 1) {
				// op.columnごとの最大値を格納していく
				if (h > hListLine[n]) {
					hListLine[n] = h;
				}
				if ( (i > 0) && (((i+1) % op.column) == 0) ) {
					n++;
					hListLine[n] = 0;
				};
			}
		});
		// 取得した高さの数値を降順に並べ替え
		hList = hList.sort(op.descend);
		hMax = hList[0];
		
		// 高さの最大値を要素に適用
		var browser = $.browser.version;
		if (op.column > 1) {
			for (var j=0; j<hListLine.length; j++) {
				for (var k=0; k<op.column; k++) {
					if (browser == '6.0') {
						self.eq(j*op.column+k).height(hListLine[j]);
						if (k == 0 && op.clear != 0) self.eq(j*op.column+k).css('clear','both');
					} else {
						self.eq(j*op.column+k).css(op.height,hListLine[j]);
						if (k == 0 && op.clear != 0) self.eq(j*op.column+k).css('clear','both');
					}
				}
			}
		} else {
			if (browser == '6.0') {
				self.height(hMax);
			} else {
				self.css(op.height,hMax);
			}
		}
	};
	$(window).load(function() {
		$(".option-block").autoHeight({column: 2});
	});
})(jQuery);

jQuery(function($) {
	$("input.placeholder").each(function(i) {
		var holder = $(this).attr('defaultValue');
		// ready
		if( $(this).val() != holder ) $(this).css('color', '#333');
		// focus, blur
		$(this).focus(function() {
			if( $(this).val() == holder ) $(this).val('').css('color', '#333');
		});
		$(this).blur(function() {
			if( $(this).val() == '' ) $(this).val(holder).css('color', '#999');
		});
	});
});

jQuery(function($) {
	$('.action-block-tab').each(function(){
		var $navi     = $('ul.tab_navi', this);
		var $contents = $('div.tab_content', this);
		var selected_id = $('li.selected a', $navi).attr('href');

		// init
		$contents.hide();
		$(selected_id).show();

		$('li', $navi).each(function(){
			$('a', this).unbind('click');
			$(this).click(function(){
				var id = $('a', this).attr('href');
				var $content = $(id);
				$('li', $navi).toggleClass('selected');
				$contents.hide();
				$content.show();
				return false;
			});
		});
	});
});

