// JavaScript Document

// Div 추가
if(window.addEventListener) window.addEventListener("load", add_alert, false);
else if(window.attachEvent) window.attachEvent("onload", add_alert);
else window.onload=add_alert;
var div_height2;
function add_alert() {
	var get_load = document.getElementById("alert_blindn");
	if(get_load){
		return;
	}
	
	var div_height = 0;
	var div_width = 0;

	var get_clientheight = document.body.clientHeight;
	var get_clientwidth = document.body.clientWidth;

	var get_declientheight = document.documentElement.clientHeight;
	var get_declientwidth = document.documentElement.clientWidth;
	
	var get_base = document.getElementById("div_main_base");
	if( get_clientheight > get_declientheight ) {
		div_height = get_clientheight;
	} else {
		div_height = get_declientheight;
	}
	if( get_clientwidth > get_declientwidth ) {
		div_width = get_clientwidth;
	} else {
		div_width = get_declientwidth;
	}
	
	if (div_height2){
		div_height = div_height2;
	}
	var div_screen = document.createElement("div");
	div_screen.style.clear = "both";
	div_screen.style.position = "absolute";
	div_screen.style.left = "0px";
	div_screen.style.top = "0px";
	div_screen.style.width = div_width + 'px';
	div_screen.style.minWidth = div_width + 'px';
	div_screen.style.height = div_height + 'px';
	div_screen.style.minHeight = div_height + 'px';
	div_screen.style.margin = "0px";
	div_screen.style.padding = "0px";
	div_screen.style.backgroundColor = "#000000";
	div_screen.style.filter = "alpha(opacity=50,FinishOpacity=0,Style=0)";
	div_screen.style.opacity = 0.50;
	div_screen.style.MozOpacity = 0.50;
	div_screen.style.zIndex = "9990";
	div_screen.style.display = "none";
	div_screen.id = "alert_blindn";
	document.body.appendChild(div_screen);

	var div_screen = document.createElement("div");
	div_screen.style.clear = "both";
	div_screen.style.position = "absolute";
	div_screen.style.left = "0px";
	div_screen.style.top = "0px";
	div_screen.style.width = div_width + 'px';
	div_screen.style.minWidth = div_width + 'px';
	div_screen.style.height = div_height + 'px';
	div_screen.style.minHeight = div_height + 'px';
	div_screen.style.margin = "0px";
	div_screen.style.padding = "0px";
	div_screen.style.backgroundColor = "#000000";
	div_screen.style.filter = "alpha(opacity=50,FinishOpacity=0,Style=0)";
	div_screen.style.opacity = 0.50;
	div_screen.style.MozOpacity = 0.50;
	div_screen.style.zIndex = "10000";
	div_screen.style.display = "none";
	div_screen.id = "alert_blind";
	document.body.appendChild(div_screen);
	
	var div_window = document.createElement("div");
	div_window.style.clear = "both";
	div_window.style.position = "absolute";
	div_window.style.left = "100px";
	div_window.style.top = "100px";
	div_window.style.width = "300px";
	div_window.style.minWidth = "300px";
	div_window.style.height = "180px";
	div_window.style.minHeight = "180px";
	div_window.style.margin = "0px";
	div_window.style.padding = "0px";
	div_window.style.border = "0px none";
	div_window.style.zIndex = "10001";
	div_window.style.display = "none";
	div_window.id = "alert_window";

	var div_window_object = "";
	div_window_object += "<table cellpading=0 cellspacing=0 border=0 height=100% width=100%>";
	div_window_object += "<tr><td style='padding:0px;width:14px;height:14px;font-size:11px;'><img src='/imageroot/common/alert/gray/alert_window_7.png'></td><td style='padding:0px;height:14px;font-size:11px;'><img src='/imageroot/common/alert/gray/alert_window_8.png' width='272' height='14'></td><td style='padding:0px;width:14px;height:14px;font-size:11px;'><img src='/imageroot/common/alert/gray/alert_window_9.png'></td></tr>";
	div_window_object += "<tr><td style='padding:0px;width:14px;font-size:11px;'><img src='/imageroot/common/alert/gray/alert_window_4.png' width='14' height='40'></td><td style='padding:0px;height:40px;background-color:#FFF;text-align:center;'><img src='/imageroot/common/alert/alert_attention.gif'></td><td style='padding:0px;width:14px;font-size:11px;'><img src='/imageroot/common/alert/gray/alert_window_6.png' width='14' height='40'></td></tr>";
	div_window_object += "<tr><td style='padding:0px;width:14px;font-size:11px;'><img src='/imageroot/common/alert/gray/alert_window_4.png' width='14' height='96'></td><td style='padding:0px;height:96px;font-weight:bold;background-color:#FFF;FONT-SIZE:12px;LINE-HEIGHT:160%;text-align:center;' id='alert_window_msg'></td><td style='padding:0px;width:14px;font-size:11px;'><img src='/imageroot/common/alert/gray/alert_window_6.png' width='14' height='96'></td></tr>";
	div_window_object += "<tr><td style='padding:0px;width:14px;font-size:11px;'><img src='/imageroot/common/alert/gray/alert_window_4.png' width='14' height='24'></td><td style='padding:0px;height:24px;background-color:#FFF;text-align:center;font-size:11px;'><img src='/imageroot/common/inbox_confirm_btn.gif' onclick='alert_close();' style='cursor:pointer;border:0px;' /></td><td style='padding:0px;width:14px;font-size:11px;'><img src='/imageroot/common/alert/gray/alert_window_6.png' width='14' height='24'></td></tr>";
	div_window_object += "<tr><td style='padding:0px;width:14px;height:14px;font-size:11px;'><img src='/imageroot/common/alert/gray/alert_window_1.png'></td><td style='padding:0px;height:14px;font-size:11px;'><img src='/imageroot/common/alert/gray/alert_window_2.png' width='272' height='14'></td><td style='padding:0px;width:14px;height:14px;font-size:11px;'><img src='/imageroot/common/alert/gray/alert_window_3.png'></td></tr>";
	div_window_object += "</table><input type='hidden' id='alert_window_focus' value=''>";
	div_window_object += "<input type='hidden' id='alert_window_url' value=''>";
	div_window.innerHTML= div_window_object;
	document.body.appendChild(div_window);
	
}

function alert2(txt,target,url) {
	add_alert();
	var screen_x = screen_size_width();
	var screen_y = screen_size_height();
	var screen_stop = screen_scroll_top();
	var screen_sleft = screen_scroll_left();
	var get_screen = document.getElementById("alert_blind");
	get_screen.style.display = "block";
	
	var get_window = document.getElementById("alert_window");
	var get_window_msg = document.getElementById("alert_window_msg");
	get_window_msg.innerHTML = txt;

	var alert_left = parseInt(screen_sleft) + (parseInt(screen_x)/2)-(parseInt(get_window.style.width)/2);
	var alert_top  = parseInt(screen_stop) + (parseInt(screen_y)/2)-(parseInt(get_window.style.height)/2);
	get_window.style.left = alert_left + 'px';
	get_window.style.top = alert_top + 'px';
	get_window.style.display = "block";
	var alert_window_target = document.getElementById("alert_window_focus");
	if ( target ) {
		alert_window_target.value = target;
	} else {
		alert_window_target.value = '';
	}
	var alert_window_url = document.getElementById("alert_window_url");
	if ( url ) {
		alert_window_url.value = url;
	} else {
		alert_window_url.value = '';
	}
}
function alert_close()
{
	var alert_window_url = document.getElementById("alert_window_url").value;
	if ( alert_window_url ) {
		window.open(alert_window_url,"_top");
	}else{
		alert2_blind_off();
		var alert_window_focus = document.getElementById("alert_window_focus").value;
		if ( alert_window_focus ) {
			var get_focus = document.getElementById(alert_window_focus);
			if ( get_focus ) {
				get_focus.focus();
			}
		}
		var get_window = document.getElementById("alert_window");
		get_window.style.display = "none";
	}
}

function alert2_blind_on(){
	var get_screen = document.getElementById("alert_blind");
	get_screen.style.display = "block";
}

function alert2_blind_off(){
	var get_screen = document.getElementById("alert_blind");
	get_screen.style.display = "none";
}

function alert2_blindn_on(){
	var get_screen = document.getElementById("alert_blindn");
	get_screen.style.display = "block";
}

function alert2_blindn_off(){
	var get_screen = document.getElementById("alert_blindn");
	get_screen.style.display = "none";
}

function alert2_blind_toggle(){
	var get_screen = document.getElementById("alert_blind");
	if (get_screen.style.display == "none"){
		get_screen.style.display = "block";
	}else{
		get_screen.style.display = "none";
	}
}

function screen_size_height() {
	var myHeight = 0;
	if( typeof( window.innerHeight ) == 'number' ) {
		//Non-IE
		myHeight = window.innerHeight;
	} else if( document.documentElement && document.documentElement.clientHeight ) {
		//IE 6+ in 'standards compliant mode'
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && document.body.clientHeight ) {
		//IE 4 compatible
		myHeight = document.body.clientHeight;
	}
	return myHeight;
}

function screen_size_width() {
	var myWidth = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
	} else if( document.documentElement && document.documentElement.clientWidth ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
	} else if( document.body && document.body.clientWidth ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
	}
	return myWidth;
}

function screen_scroll_top() {
	var myScrollTop = 0;
	var get_de = document.documentElement.scrollTop;
	if ( get_de ) {
		myScrollTop = get_de;
	} else {
		myScrollTop = window.pageYOffset;
		if ( !myScrollTop ) {
			myScrollTop = 0;
		}
	}
	return parseInt(myScrollTop);
}

function screen_scroll_left() {
	var myScrollLeft = 0;
	var get_de = document.documentElement.scrollLeft;
	if ( get_de ) {
		myScrollLeft = get_de;
	} else {
		myScrollLeft = window.pageXOffset;
		if ( !myScrollLeft ) {
			myScrollLeft = 0;
		}
	}
	return parseInt(myScrollLeft);
}
