/*
 * common.js
 */


$().ready(function(){
	PEPS.rollover.init();
	if(/a/.__proto__=='//') $("body").css("font-size", "11px");
	if($("#reservationLink").size() > 0)$("#reservationLink").colorbox({width:"850px", height:"680px", iframe:true});
	if($(".reservationLink").size() > 0)$(".reservationLink").colorbox({width:"850px", height:"680px", iframe:true});
	if($("#thumb-gallery").size() > 0)$("#thumb-gallery a").colorbox();
	if($("#galleryNavi").size() > 0)$("#galleryNavi li a").colorbox();


	
	
	if($("#news").size() > 0)
	{
		$(".mainbody a").each( function()
		{

			if($(this).attr("href").match(/(\.jpg|\.gif|\.png)/))
			{
				$(this).colorbox();
			}
			
		});
	}
	startAnalytics();
});



/*
 * Roll over
 */

PEPS = {};
PEPS.rollover = {
init: function(){
	this.preload();

	$(".over").hover(
	function () { $(this).attr( 'src', PEPS.rollover.newimage($(this).attr('src')) ); },
	function () { $(this).attr( 'src', PEPS.rollover.oldimage($(this).attr('src')) ); }
	);},

	preload: function(){
	$(window).bind('load', function() {
	$('.over').each( function( key, elm ) { $('<img>').attr( 'src', PEPS.rollover.newimage( $(this).attr('src') ) ); });
	$('.idx img').each( function( key, elm ) { $('<img>').attr( 'src', PEPS.rollover.newimage( $(this).attr('src') ) ); });
	$('.idx2 img').each( function( key, elm ) { $('<img>').attr( 'src', PEPS.rollover.newimage( $(this).attr('src') ) ); });
	});},

	newimage: function( src ){
	return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_over' + src.match(/(\.[a-z]+)$/)[0];
	},

	oldimage: function( src ){
	return src.replace(/_over\./, '.');
	}
};


/*
 * Google Analytics
 */

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

function startAnalytics() {
	try {
	var pageTracker = _gat._getTracker("UA-1052315-17");
	pageTracker._trackPageview();
	} catch(err) {}
}


