$().ready(function(){

//global current ///////////////////////////////
var domain = location.href.split('/');
var serverURL = 'http://'+domain[2]+'/';

var thisURL = location.href;
if (thisURL == serverURL){
var homeSRC = $('#navi a:first img').attr('src').replace('.gif','_over.gif');
$('#navi a:first img').attr('src',homeSRC).removeClass();
} else if (thisURL.match("/shop/")){
var homeSRC = $('#navi a:eq(3) img').attr('src').replace('.gif','_over.gif');
$('#navi a:eq(3) img').attr('src',homeSRC).removeClass();
} else {
$('#navi a:not(#navi a:first)').each(function(){
var linkURL = $(this).attr('href');
if (thisURL.match(linkURL)){
var thisSRC = $(this).children('img').attr('src').replace('.gif','_over.gif');
$(this).children('img').attr('src',thisSRC).removeClass();
} 
});
}

// shop nav ////////////////////////////////////////////////
$('#shopAreaNav a').each(function(){
var linkURL = $(this).attr('href');								  
if (thisURL.match(linkURL)){
var thisSRC = $(this).children('img').attr('src').replace('.gif','_over.gif');
$(this).children('img').attr('src',thisSRC).removeClass();
}
});

// sub nav ////////////////////////////////////////////////
menuURL = serverURL + 'menu/';
knowledgeURL = serverURL + 'knowledge/';
activitiesURL = serverURL + 'activities/';
online_shopURL = serverURL + 'online_shop/';

if (thisURL == menuURL || thisURL == knowledgeURL || thisURL == activitiesURL || thisURL ==online_shopURL ){
var homeSRC = $('#sub a:first img').attr('src').replace('.gif','_over.gif');
$('#sub a:first img').attr('src',homeSRC).removeClass();
} else {
$('#sub a:not(#sub a:first)').each(function(){
var linkURL = $(this).attr('href');		
if (thisURL.match(linkURL)){
var thisSRC = $(this).children('img').attr('src').replace('.gif','_over.gif');
$(this).children('img').attr('src',thisSRC).removeClass();
}
});
};




// window blank open ////////////////////////////////////////
$('a[href^="http"]').not('[href*="' + serverURL +'"]' && '[href*="torafugu.co.jp"]').each(function(){
$(this).attr('target', '_blank');
});



// jump menu ////////////////////////////////////////
$('.jumpMenu select').change(function(){
jumpURL =$(this).attr('value');
location.href = jumpURL; 
});



//round corner ///////////////////////////////

DD_roundies.addRule('.round', '5px', true);



//shop banner margin////////////////////////////////////
$('.shopDetail .bnrArea li:last').css('margin-top','15px');

//shop detail height  ///////////////////////////////
var btnOrNot = $('.shopDetail .info .btn').height();
if(btnOrNot == null){
$('.shopDetail .info').css('padding-bottom','20px');
$('.mapLink').css('padding', '0 0 0 1px');
}

var photo = $('.shopDetail .photo').height();
var info = $('.shopDetail .info').height(); 
var infoOut = $('.shopDetail .info').outerHeight(); 
var infoPd = infoOut - info; 
var photoInr = photo - infoPd;
if ( photo > infoOut ){
$('.shopDetail .info').css('height', photoInr+'px' );
}


//sub line  ///////////////////////////////
$('#sub').parent().parent().css( 'background','url(/img/bg_border.gif) repeat-y 189px 0');

// png fix for IE6 ////////////////////////////////////////
if ($.browser.msie && $.browser.version <= 6){
DD_belatedPNG.fix('.pfix');
}

//jprintArea  ///////////////////////////////

//$('.print a').click(function(){ $.jPrintArea('.shopDetail') });

// Roll over ////////////////////////////////////////
PEPS.rollover.init();

//End of doccument ready ////////////////////////////////////////
});

// 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') ) ); });
});},

newimage: function( src ){
return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_over' + src.match(/(\.[a-z]+)$/)[0];
},

oldimage: function( src ){
return src.replace(/_over\./, '.');
}
};
// Roll over end ////////////////////////////////////////



// sendmail form ////////////////////////////////////////
function mobileMail(){
if(navigator.userAgent.indexOf("Win") != -1 ){
location.href = 'mailto: ' + document.forms[0].mail.value + '?subject=%82%C6%82%E7%82%D3%82%AE%92%E0%83%82%83o%83C%83%8B&body=http://www.torafugu.co.jp/m/';
};
if(navigator.userAgent.indexOf("Mac") != -1 ){
	location.href = 'mailto: ' + document.forms[0].mail.value + '?subject=とらふぐ亭モバイル&body=http://www.torafugu.co.jp/m/';
};
}

