// copyright(c) "my". all rights reserved.
//
// ==========================================================
// use for "hmaunion.com"
// ==========================================================

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

if((root.indexOf('localhost') > -1) || (root.indexOf('192.168.0.2') > -1)){
	root += '~my/hmaunion.com/';
}else if(root.indexOf('my-kochi.net') > -1){
	root += 'hmaunion.com';
}


// 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
	if($('#fade')){
		$('#fade').fadeTo(1000, 0).hide(100);// fadein
	}
	// document title
	var indexTitle = 'UNION - Hair & Make. Art -';
	document.title = indexTitle;
});


// 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()){
		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");
}


