// ==========================================================
// with 'jquery.js'
// Y.Morita <post@my-kochi.com>
// copyright(c) my. all rights reserved.
// ==========================================================

// variables
// **********************************************************
// root directory
var root = 'http://' + document.domain + '/';
if ((root.indexOf('localhost') > -1) || (root.indexOf('192.168.24.51') > -1)) root += '~my/kasagumi.net/';
// anchor class
var blankWindow = '.blankWindow';
var blankMini = '.blankMini';
// mini window size
var mwW = 720;// width
var mwH = 560;// height
// lightbox style
var lightboxStyle = {overlayBgColor:'#000000', overlayOpacity:0.7, imageLoading:root + 'img/lightbox/loading.gif', imageBtnPrev:root + 'img/lightbox/prev.gif', imageBtnNext:root + 'img/lightbox/next.gif', imageBtnClose:root + 'img/lightbox/close.gif', imageBlank:root + 'img/lightbox/blank.gif', containerBorderSize:10, containerResizeSpeed:500}
// document title
var setDocumentTitle = true;
var titles = new Array();
titles[' '] = ' ';

// environment
// **********************************************************
// user agent
var ua = navigator.userAgent;
var ms_ie5or6 = new Boolean();// IE5 ~ 6
var winFirefox = new Boolean();// Windows Firefox
if (ua.indexOf("Win") > -1) {
  ms_ie5or6 = ((ua.indexOf("MSIE 5") > -1) || (ua.indexOf("MSIE 6") > -1)) ? true : false;
  winFirefox = (ua.indexOf("Firefox") > -1) ? true : false;
}

// opening small window from 'swf'
function safari() {
  return ((ua.indexOf("Safari")) > -1) ? true : false;
}

// jquery
// **********************************************************
// onload event
$(document).ready(function() {
  if ($('#javascriptEnabled')) $('#javascriptEnabled').html('<span class="green">ただいま JavaScript は有効になっています。</span>');// enabled check
  setAnchor();// anchor
  setLightbox();// lightbox
  setCeebox();// ceebox
	uiTabsSet();// ui.tabs
  if ($('#fade')) $('#fade').fadeTo(1000, 0).hide(100);// fadein
});

// anchor
function setAnchor() {
  if ($(blankWindow).size()) {
    $(blankWindow).each(function() {
      $(this).click(function () {
        window.open($(this).attr('href'));
        return false;
      });
    });
  }
  if ($(blankMini).size()) {
    $(blankMini).each(function() {
      $(this).click(function() {
        miniWindow($(this).attr('href'), mwW, mwH, false);
        return false;
      });
    });
  }
}

// lightbox
function setLightbox () {if ($('.lightbox').length != 0) $('.lightbox a:visible').lightBox(lightboxStyle);}

// ceebox
function setCeebox () {if ($('.ceebox').length != 0) $('.ceebox').ceebox();}

// ui.tabs
function uiTabsSet(){
  if ($('#menubook-container').length != 0) {
    $('#menubook-container').tabs({
      selected:0,
      fx:{ opacity:"toggle", duration:"normal" }
    });
    // footer adjust
/*
    $('#menubook-container .tabs a').mouseout(function() {
      $('#footer').css('bottom', '10px');
      $('#footer').css('bottom', '0');
    });
*/
    // footer adjust
  }
}

// interface
// **********************************************************
// mini window open
function miniWindow (url, w, h, swfCall) {
  if (w > screen.width) w = screen.width;
  if (h > screen.height) h = screen.height;
  var x = screen.width / 2 - w / 2;
  var y = (screen.height / 2 - h / 2) - 50;
  if (y < 0) y = 0;
  window.open(url, 'mini',"top=" + y + ", left=" + x + ", width=" + w + "px, height=" + h + "px, toolbar=0, directories=0, status=0, scrollbars=1, resizable=0");
}

// sub routine
// **********************************************************
// document title
if (setDocumentTitle == true) {
  if (titles[document.title]) document.title = titles[document.title];
}

// external interface
// **********************************************************
// set navigation bar
function forNavigation(){
  if (location.href.indexOf('/home') > -1) return 'home';
  else if (location.href.indexOf('/food') > -1) return 'food';
  else if (location.href.indexOf('/drink') > -1) return 'drink';
  else if (location.href.indexOf('/course') > -1) return 'course';
  else if (location.href.indexOf('/guide') > -1) return 'guide';
  else return 'home';
}


