/**
 * Web Site Interface Controller
 * Date: 03/19/2010
 * @author xe-que design works
 * @version 1.0
 *
 */

// 画像ロールオーバー等のエフェクト時間(ms)
var ROLLOVER_EFFECT_TIME = 300;


jQuery(function( $ ){

	// 別ドメインへのアンカーなら外部リンククラスを追加、また、pdf なら pdf 用クラスを追加
	$("#main-content a[@href^=http]:not(:has(img))").filter(function() { 
		return this.hostname && this.hostname !== location.hostname; 
	}).attr("target","_blank").addClass("external-link");
	$("#main-content a[href$='.pdf']").attr("target","_blank").addClass("pdf-link");

	// ボックス全体をリンク化
	$('.biggerlink').biggerlink();

	// 外部リンクのアイコンをインライン要素に表示させるための処理（IE6,7の不正表示対策）
	$('a.external-link').inlineBgFix();


	// グローバルメニューのロールオーバー用画像をセット
	$('#global-menu > li img').each(function(){
		$src_temp = $(this).attr('src').replace('.gif','-selected.gif');
		img_temp = new Image();
		$(img_temp).attr('src',$src_temp).addClass('global-menu-selected');
		$(this).after(img_temp);
	});

	// グローバルメニューロールオーバーハンドラ
	$('#global-menu > li > a').hover(
		function(){
			$(this).children().eq(1).fadeIn(ROLLOVER_EFFECT_TIME);
		},	
		function(){
			$(this).children().eq(1).fadeOut(ROLLOVER_EFFECT_TIME);
		}
	);
	
	// リンク内画像ロールオーバーハンドラ
	$('.content a:not(.bl-bigger) img, #container a:not(.bl-bigger)  img').hover(
		function(){
			$(this).fadeTo(ROLLOVER_EFFECT_TIME, 0.7);
		},	
		function(){
			$(this).fadeTo(ROLLOVER_EFFECT_TIME, 1);
		}
	);

	// トップの bigger-link 分のロールオーバーは個別に設定
	$('#page-top div.choice').hover(
		function(){
			$(this).children('h3').fadeTo(ROLLOVER_EFFECT_TIME, 0.7);
		},	
		function(){
			$(this).children('h3').fadeTo(ROLLOVER_EFFECT_TIME, 1);
		}
	);
	$('#page-top div.tech').hover(
		function(){
			$(this).fadeTo(ROLLOVER_EFFECT_TIME, 0.7);
		},	
		function(){
			$(this).fadeTo(ROLLOVER_EFFECT_TIME, 1);
		}
	);
	
	// メニューの親階層のロールオーバー（子階層のインデント部分を白くするための処理）
	$('#sidebar-wrapper #menu ul li#menu-parent a:first').hover(
		function() {
			// 選択色に変更
			$($(this).parent().get(0)).css('background-color','#F7F7F6');
		},
		function() {
			// 親階層が選択中の場合は、選択色変更を行わない
			temp = $($(this).parent().get(0));
			if (!temp.hasClass('selected')) temp.css('background-color','#e8e2d0');
		}
	);
	
	// <blockquote>〜</blockquote> の 〜 の前に span を記述
	$('blockquote').prepend('<span>&nbsp;</span>');
});

// LightBox 用設定
$(document).ready(function(){
	
	if ($.prettyPhoto)
		$("#photop-review-content .photopreview .preview-photo ul li a[rel^='prettyPhoto'], #main-content a[rel^='prettyPhoto'],#main-content p a[@href^=http]:has(img)").prettyPhoto({theme:'light_square'});
});

// 外部リンクのアイコンをインライン要素に表示させるための処理（IE6,7の不正表示対策）
$.fn.extend({
	inlineBgFix: function() {
		if ($.browser.msie && $.browser.version < 8.0) {
			$(this)
			.addClass('inline-bg-fix')
//			.prepend('<span class="bg-l">&nbsp;</span>')
			.append('<span class="bg-r">&nbsp;</span>');
		}
	}
});

