// copyright(c) "my". all rights reserved.

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

if((root.indexOf('localhost') > -1) || (root.indexOf('192.168.0.2') > -1)) root += '~my/utsuboya.com/';

// interface
// ***************************
var ua = navigator.userAgent;
var ms_ie5or6 = new Boolean();
var winFirefox = new Boolean();
//'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){
//		alert($('.lightbox a:visible').length);
		$('.lightbox a:visible').lightBox({
			overlayBgColor:'#000000',
			overlayOpacity:0.5,
			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()){
		var ct = 0;
		$(".blankWindow").each(function(){
			$(".blankWindow:eq(" + ct + ")").click(function(){newWindow($(this));});
			ct++;
		});
	}
	// mini window
	if($(".blankMini").size()){
		var ct = 0;
		$(".blankMini").each(function(){
			$(".blankMini:eq(" + ct + ")").click(function(){miniWindow($(this));});
			ct++;
		});
	}
}

// new window open
function newWindow(obj){
	var url = obj.attr('href');
	obj.attr('href', 'javascript:void(0);');
	obj.mouseout(function(){obj.attr('href', url);});
	window.open(url);
}

// mini window
function miniWindow(obj){
	var url = obj.attr('href');
	obj.attr('href', 'javascript:void(0);');
	obj.mouseout(function(){obj.attr('href', url);});
	subWindowOpen(url, 720, 560, 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");
}

