// copyright(c) "my". all rights reserved.
//
// ==========================================================
// use for "robento.jp"
// ==========================================================

// environment
// **********************************************************
var root = 'http://' + document.domain + '/';

if((root.indexOf('localhost') > -1) || (root.indexOf('192.168.0.2') > -1)){
	root += '~my/megumiya.jp/';
}

// interface
// **********************************************************

var ms_ie5or6 = new Boolean();
var winFirefox = new Boolean();
var ua = navigator.userAgent;
//'IE5~6'
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;
}
// Safari for swf
function safari(){
	return ((ua.indexOf("Safari")) > -1) ? true : false;
}


// onload event
// **********************************************************
$(document).ready(function(){
	if($('#javascriptEnabled')) $('#javascriptEnabled').html('<p class="center green bold">ただいま JavaScript は有効になっています。</p>');// enabled check
	targetWindowSet();// anchor
	lightboxSet();// lightbox
});



// intialize for jquery
// **********************************************************

// lightbox
function lightboxSet(){
	if($('.lightbox a:visible').length != 0){
		$('.lightbox a:visible').lightBox({
			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
		});
	}
}

// window open
// **********************************************************
function targetWindowSet(){
	// new window
	if($(".blankWindow").size()){
		$(".blankWindow").each(function(){
			$(this).click(function(){
				window.open($(this).attr('href'));
				return false;
			});
		});
	}
	// mini window
	if($(".blankMini").size()){
		$(".blankMini").each(function(){
			$(this).click(function(){
				subWindowOpen($(this).attr('href'), 720, 560, false);
				return false;
			});
		});
	}
}

// public method
function subWindowOpen(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");
}


