/********************************************************************
   共通 JavaScript
   iLINK SYSTEMS, Inc.
 ********************************************************************/

/**
 * ウィンドウを開く
 */
function openWindow(url, name, height, width, scrollbars, resizable, status) {
	var window_condition = "height=" + height + ",width=" + width + 
		",scrollbars=" + scrollbars + ",resizable=" + resizable + ",toolbar=no,status=" + status;
	
	subWindow = window.open(url, name, window_condition);
	subWindow.focus();
	return subWindow;
}

/**
 * 常に手前に表示するウィンドウを開く
 */
function openModalWindow(url, name, height, width, scrollbars, resizable, status) {
	ModalWindow = openWindow(url, name, height, width, scrollbars, resizable, status);
	onfocus = function onFocus() {
		try {
			if (null !=ModalWindow && !ModalWindow.closed) {
				try {
					ModalWindow.focus();
				} catch(e) {
					document.onmousemove = null;
				}
			} else {
				document.onmousemove = null;
			}
		} catch (ex) {}
	};
	document.onmousemove = onfocus;
	return ModalWindow;
}

/**
 * ウィンドウを後ろに開く
 */
function openWindowBack(url, name, height, width, scrollbars, resizable, status) {
	var window_condition = "height=" + height + ",width=" + width + 
		",scrollbars=" + scrollbars + ",resizable=" + resizable + ",toolbar=no,status=" + status +
		",left=" + window.screen.width;
	subWindow = window.open(url, name, window_condition);
	subWindow.blur();
	window.focus();
	subWindow.moveTo(0,0);
	return subWindow;
}

/**
 * 曜日を取得する関数
 * year:  年
 * month: 月
 * day:   日
 */
function getDayOfWeek(year, month, day) {

	DateOfWeek	= new Date();
	DateOfWeek.setYear(year);
	DateOfWeek.setMonth(month - 1);
	DateOfWeek.setDate(day);
	day_of_week_number	= DateOfWeek.getDay();

	days = new Array('日','月','火','水','木','金','土');
	return days[day_of_week_number];
}

/**
 * Windowの幅を取得します
 */
function getWindowSize() {
	var myWidth = 0, myHeight = 0;
	
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	
	return [myWidth, myHeight];
}

