//
// @(#)aos.js
//

$(function() {
	if(typeof(AA)=="undefined"){ AA={}; }
	if(typeof(AA.Aos)=="undefined"){ AA.Aos={}; }
	AA.Aos.getPopupFeature=function(w,h,f) {
		var gab = 20;
		var wx = (window.screen.width-w)/2;
		var wy = (window.screen.height-h)/2;
		if(wy > gab) {
			wy -= gab;
		}
		var features = "width="+w+",height="+h+",left="+wx+",top="+wy+",toolbar=no,menubar=no,location=no,status=no";
		if (f != null) {
			features += "," + f;
		}
		return features;
	};
	$(".aos-start").bind('click', function() {
		if(navigator.platform.indexOf('Win') == -1) {
			alert("키보드 보안은 Windows 환경만 지원합니다.");
			return false;
		}
		if(aos_is_new()) {
			if(aos_isrunning("40")) {
				if(!$(this).attr("checked")) {
					var now = new Date();
						document.cookie = AA.Aos.cookieName+"=; path=/; expires="+now.toGMTString()+";";
						alert("모든 브라우저를 닫아야 키보드 보안이 해제됩니다.");
				}
			} else {
				AA.Aos.start();
			}
			return;
		}
		if($(this).attr("checked")) {
			$(".aos-start").attr("checked", false);
			var w=window.open("/util/aos", "aos", AA.Aos.getPopupFeature(470, 550, "resizable=no"));
			w.focus();
		}
	});
});

if(typeof(AA)=="undefined"){ AA={}; }
if(typeof(AA.Aos)=="undefined"){ AA.Aos={}; }
AA.Aos.cookieName="use_aosak";
AA.Aos.isUseAk=function() {
	var cookies = new Array();
	var s = String(document.cookie);
	var a = s.split(/\s*;\s*/);
	for(var i=0;i<a.length;i++) {
		var b = a[i].split(/\s*=\s*/);
		if(b[1] != null && b[1] != "") {
			if(b[0] == AA.Aos.cookieName) {
				if(unescape(b[1]) == "true") {
					return true;
				}
			}
		}
	}
	return false;
}
AA.Aos.start=function() {
	var now = new Date();
	now.setHours(now.getHours() + 24);
		document.cookie = AA.Aos.cookieName+"="+escape("true")+"; path=/; expires="+now.toGMTString()+";";

	aos_set_subclsid("40","59B0298B-A7B5-4045-A34E-377EDF7BCB8E");
	aos_set_submimetype("40","application/ahnlab/asp/npmkd25aos");
	aos_set_authinfo("www.xlgames.com.html");
	aos_set_option("mkd_protect_level", "low");
	aos_set_option("uimode", true);
	aos_set_option("asyncmode", false);
	aos_set_option("obj_style", "hideout")
	aos_write_object();
	aos_start("40");
	$(".aos-start").attr("checked", true);
}
$(document).ready(function(){
	if(aos_is_new() && AA.Aos.isUseAk()) {
		if($(".aos-start").attr("checked") != undefined) {
			$(".aos-start").attr("checked", true);
		}
		AA.Aos.start();
	}
});

// EOF
