/*  BaseJQ JavaScript framework, version 3
 *  要jquery.js version 1.3.2
 *--------------------------------------------------------------------------*/ 

overImageClass= "overimage"; //ロールオーパー対象class
overImageClassFoot= "_over"; //ロールオーパーイメージ付加文字列
toggleImageFoot = "_over"; //トグル機能で現在のページを示す画像イメージ付加文字列

/*ロールオーバー・トグル*/

$(function(){
	var conf = {
		className : "." + overImageClass,
		overNode : overImageClassFoot,
		toggleNode : toggleImageFoot
	};
	//トグルエンジン実行

	if(typeof(PAGEID) != "undefined" ){	
		for(var i = 0; i < PAGEID.length; i++){
		var TGTID = PAGEID[i]
		var NODEID = "#" + TGTID
		$(NODEID).each(function(){
		this.oriSrc = this.src;
		this.cngSrc = this.oriSrc.replace(/(\.gif|\.jpg|\.png)/, conf.toggleNode+"$1");
		this.src = this.cngSrc;
		$(NODEID).removeClass(overImageClass);
		});
		};		
	};

	//ロールオーバーエンジン実行
	$(conf.className).each(function(){
		this.originalSrc = this.src;
		this.rolloverSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)/, conf.overNode+"$1");
		
		preloadImage(this.rolloverSrc);

		}).hover(function(){
			this.src = this.rolloverSrc;
		},function(){
			this.src = this.originalSrc;
		}).click(function(){
			this.src = this.originalSrc;
		});
	
});

/*汎用スクリプトここから*/



/*イメージプリロードエンジン*/

preloadedImages = [];
function preloadImage(url){
	var p = preloadedImages;
	var l = p.length;
	p[l] = new Image();
	p[l].src = url;
};



/*ポップアップウインドウエンジン*/
function openwin(theURL,winName,features) {
	window.open(theURL,winName,features);
};



/*にゅる*/
$(function(){
	$("a[href='#stage']").easingScroll({
		easing: "easeOutExpo",
		duration: 1000
	});
});



/*chapel engine*/
$(document).ready(function(){
	
	$('#large_list li').css({ position:'absolute',top:'0px'});
	$('#large_list li:not(:first)').css({ display:'none' });
	$('#thumbnail li').css({ position:'relative'});
	$('#thumbnail li:first').append($('<img src="/chapel/img/thumbnail_over.png" style="position: absolute; top: 0; left: 0;" class="thumbnail_on">'));
	
	$('#thumbnail li').click(function(){
									  
		var index = $('#thumbnail li').index(this);
		
		$('#large_list li').fadeOut();
		$('#large_list li').eq(index).fadeIn();
		
		$('#thumbnail li').find('img.thumbnail_on').css({ display:'none' });
		$(this).append($('<img src="/chapel/img/thumbnail_over.png" style="position: absolute; top: 0; left: 0;" class="thumbnail_on">'));
		$(this).attr('id','positive');

	});
	
	$('#thumbnail li').not('#positive').hover(
		function(){
			$(this).append($('<img src="/chapel/img/thumbnail_over.png" style="position: absolute; top: 0; left: 0;" class="thumbnail_hover">'));
		}, 
		function(){
			$(this).find("img.thumbnail_hover").remove();
    })	
});


/* wide link area engine (top, party top) */
$(document).ready(function(){
	$('#fair_area .mini_column,#plan_area .mini_column,#partyStyle .mini_column').mouseover(function(){
		var onSrc = $(this).find('.detail_btn img').attr('src').replace('.jpg', '_over.jpg');
		$(this).find('.detail_btn img').attr('src', onSrc);
		$(this).css({ cursor:'pointer' });
		})
		.mouseout(function(){
		var offSrc = $(this).find('.detail_btn img').attr('src').replace('_over.jpg', '.jpg');
		$(this).find('.detail_btn img').attr('src', offSrc);
		})
		.click(function(){
		var offSrc = $(this).find('.detail_btn img').attr('src').replace('_over.jpg', '.jpg');
		$(this).find('.detail_btn img').attr('src', offSrc);
	});
	$('#fair_area .detail_btn a,#plan_area .detail_btn a,#partyStyle .detail_btn a').each(function(){
		var Href = $(this).attr('href');
		$(this).parents('.mini_column').click(function() {
			window.open(Href,'_self');
			return false;
		});
	});
});


/*faq tab engine*/
$(document).ready(function(){
	$('#tabs .tab_contents').hide();
	$('#tabs .tab_contents:first').show();
	$('#tabs .tabs_list li:first-child').addClass('active');
	
	$('#tabs .tabs_list li').click(function(){
											  
		var index = $('#tabs .tabs_list li').index(this);
		
		$('#tabs .tabs_list li').removeClass('active');
		
		$(this).addClass('active');
		$('#tabs .tabs_list li').eq(index-5).addClass('active');
		$('#tabs .tabs_list li').eq(index+5).addClass('active');
		
		var currentTab = $(this).find('a').attr('href');
		$('#tabs .tab_contents').hide();
		if($.browser.msie)
			$(currentTab).fadeIn("slow",function(){ this.style.removeAttribute("filter"); });
		else
			$(currentTab).fadeIn("slow");
		
		return false;
	});
});



/*option engine*/
$(document).ready(function(){	
	$('.photo_area li').css({ position:'absolute',top:'10px'});
	$('.photo_area li:not(:first-child)').css({ display:'none' });
	
	$('.thumbnail_area li').css({ position:'relative'});
	$('.thumbnail_area li:first-child').append($('<img src="/option/img/thumbnail_over.png" style="position: absolute; top: 0; left: 0;" class="thumbnail_on">'));
	
	$('#option1 .thumbnail_area li').click(function(){									  
		var index = $('#option1 .thumbnail_area li').index(this);		
		$('#option1').find('.photo_area li').fadeOut();
		$('#option1').find('.photo_area li').eq(index).fadeIn(function(){
			if ( !jQuery.support.leadingWhitespace ) { this.style.removeAttribute('filter'); }
		});
		
		$('#option1').find('.thumbnail_area li img.thumbnail_on').css({ display:'none' });
		$(this).append($('<img src="/option/img/thumbnail_over.png" style="position: absolute; top: 0; left: 0;" class="thumbnail_on">'));
		$(this).attr('class','positive');
	});
	
	$('#option2 .thumbnail_area li').click(function(){									  
		var index = $('#option2 .thumbnail_area li').index(this);		
		$('#option2').find('.photo_area li').fadeOut();
		$('#option2').find('.photo_area li').eq(index).fadeIn(function(){
			if ( !jQuery.support.leadingWhitespace ) { this.style.removeAttribute('filter'); }
		});
		
		$('#option2').find('.thumbnail_area li img.thumbnail_on').css({ display:'none' });
		$(this).append($('<img src="/option/img/thumbnail_over.png" style="position: absolute; top: 0; left: 0;" class="thumbnail_on">'));
		$(this).attr('class','positive');
	});	
	
	$('.thumbnail_area li').not('.positive').hover(
		function(){
			$(this).append($('<img src="/option/img/thumbnail_over.png" style="position: absolute; top: 0; left: 0;" class="thumbnail_hover">'));
		}, 
		function(){
			$(this).find("img.thumbnail_hover").remove();
    })	
});


/*google*/
$(function(){
	$("a").click(function(){
		url = $(this).attr('href');
		if (url.match(/^http(s?):\/\//) && url.indexOf(window.location.host) == -1){
			pageTracker._trackPageview("/external_link/" +encodeURI($(this).text()));
		}
	})
})
