// JavaScript Document

function fn_get_window_sizes()
{
	var iebody = (document.compatMode && document.compatMode != 'BackCompat')? document.documentElement : document.body;

	return {
		'offset_x'   : iebody.scrollLeft ? iebody.scrollLeft : (self.pageXOffset ? self.pageXOffset : 0),
		'offset_y'   : iebody.scrollTop  ? iebody.scrollTop : (self.pageYOffset ? self.pageYOffset : 0),
		'view_height': self.innerHeight ? self.innerHeight : iebody.clientHeight,
		'view_width' : self.innerWidth ? self.innerWidth : iebody.clientWidth,
		'height'     : iebody.scrollHeight ? iebody.scrollHeight : window.height,
		'width'      : iebody.scrollWidth ? iebody.scrollWidth : window.width
	}
}

//
// Show/hide any tag by its id.
// parameters:
// id - element id
// @status - can be true (expand) or false (collapse)
function fn_show_tag(id, status, stop_listen)
{
	if (document.getElementById(id)) {
		if (status == true || status == false) {
			document.getElementById(id).style.display = (status == true)?"none":"";
		} else {
			document.getElementById(id).style.display = (document.getElementById(id).style.display == "")?"none":"";
		}
	}
	if (stop_listen == true) {
		window.onscroll = '';
	}
}


function show_notice_box(msg){
	//alert("xxxxx");	
	if(msg=="") return;
	document.getElementById('content_notice_box').innerHTML = msg;
	
	var msg = document.getElementById('ajax_message');
	
	var w = fn_get_window_sizes();
	msg.style.display = 'block';
	msg.style.top = w.offset_y + (w.view_height - msg.offsetHeight) / 2 + 'px';
	msg.style.left = w.offset_x + (w.view_width - msg.offsetWidth) / 2 + 'px';
	
	if (!window._timeouts) {
			window._timeouts = {};
	}
	if (window._timeouts['ajax_message']) {
			window.clearTimeout(window._timeouts['ajax_message']);
	}
	window._timeouts['ajax_message'] = window.setTimeout("fn_show_tag('ajax_message', true, true);", 2000);
		
		
	document.getElementById('ajax_message').onclick = function() {
			window.onscroll = null;
			this.style.display = 'none';
	}
}

function show_msg_box(msg){
	//alert("xxxxx");	
	if(msg=="") return;
	document.getElementById('content_notice_box').innerHTML = msg;
	document.getElementById('ajax_message').className = 'ajax-message-wrapper_popup';
	document.getElementById('content_notice_box').className = 'ajax-notification-p';
	document.getElementById('ajax_message_container').className = 'ajax-message_popup';
	var msg = document.getElementById('ajax_message');
	
	var w = fn_get_window_sizes();
	msg.style.display = 'block';
	msg.style.top = w.offset_y + (w.view_height - msg.offsetHeight) / 2 + 'px';
	msg.style.left = w.offset_x + (w.view_width - 830) / 2 + 'px';
	
	
}

function show_message_box(type, msg, top, left, timeout){
	if(msg=="") return;
	
	if(type == 'w'){
		document.getElementById('content_notice_box').className = 'ajax-notification-w';
	}
	else if(type == 'e'){
		document.getElementById('content_notice_box').className = 'ajax-notification-e';
	}
	
	document.getElementById('content_notice_box').innerHTML = msg;
	
	var msg = document.getElementById('ajax_message');
	
	var w = fn_get_window_sizes();
	msg.style.display = 'block';
	msg.style.top = top + 'px';
	msg.style.left = left + 'px';
	
	if (!window._timeouts) {
			window._timeouts = {};
	}
	if (window._timeouts['ajax_message']) {
			window.clearTimeout(window._timeouts['ajax_message']);
	}
	window._timeouts['ajax_message'] = window.setTimeout("fn_show_tag('ajax_message', true, true);", timeout);
		
		
	document.getElementById('ajax_message').onclick = function() {
			window.onscroll = null;
			this.style.display = 'none';
	}
}