var nSpeed = 25000;
var nOwner = '';

var winWidth = 160;
var winHeight= 260;
var paddingY = -1;
var paddingX = -1;
var winStep = 2;
var mSpeed = 10;
var alignPos = 'right';
var urlPop = '/Common/AlertMsg.php'
var title =  '¾Ë¸²';
var autoclose = true;
var windowX = (screen.width/2)-(winWidth/2);
if (alignPos=='left') windowX=0+paddingX;
if (alignPos=='right') windowX=screen.availWidth-paddingX-winWidth;
var windowY = (screen.availHeight);
var windowYstop = windowY-winHeight-paddingY;
var windowYnow = windowY;
var s = 'width='+winWidth+',height='+winHeight;
var isIE = document.all?true:false
function AlertPop(id) {
   Optwindow = "top="+windowYnow+",left="+windowX+",width="+winWidth+",height="+winHeight;
	alertWin = window.open(urlPop+'?id='+id,'',Optwindow);
	
	alertWin.moveTo(windowX,windowY);
	alertWin.resizeTo(winWidth,winHeight);
	if (autoclose) window.onunload = function(){alertWin.close()}
	movealertWin();
}

function movealertWin() {
	if (document.all) {
		if (windowYnow>=windowYstop) {
			alertWin.moveTo(windowX,windowYnow);
			windowYnow=windowYnow-winStep;
			timer=setTimeout('movealertWin()',mSpeed);
		} else {
			clearTimeout(timer);
			alertWin.moveTo(windowX,windowYstop);
		}
	} else alertWin.moveTo(windowX,windowYstop);
}

function Agent(prc,f) {
	switch (prc) {
	case "put":
		neoWin("/MyFolder/Agent.php?Prc=put&f="+f,"",1,0,0,0,0,0,389,110,"C");
		break;
	case "syncup":	
		neoWin("/MyFolder/Agent.php?Prc=syncup&f="+f,"",1,0,0,0,0,0,389,200,"C");
		break;
	case "syncdown":	
		neoWin("/MyFolder/Agent.php?Prc=syncdown&f="+f,"",1,0,0,0,0,0,389,200,"C");
		break;
	}
}

function SyncPrc(mode,f,o) {
//	alert(mode+f+o);
	switch (mode) {
	case "SyncUp":
		switch (f) {
		case "Address.xml":
			document.location='/Agent/Address.php?p=syncPC&o='+o;
			break;
		}
		break;
	}
}

function cmdNotify(revCont){
	if (typeof(document)!="object") return;

	var xParser = Array();
	var xSet = Array();
	var xSet2 = Array();
	var xStr;
	xParser = revCont.split("&");	
	for(i=0;i<xParser.length;i++) {
		xStr = xParser[i];
		xSet = xStr.split("=");
		switch (xSet[0]) {
		case "todo":
			if (typeof(document.all.notify_todo)=="object") document.all.notify_todo.innerHTML = xSet[1];
			break;
		case "post":
			if (typeof(document.all.notify_post)=="object") document.all.notify_post.innerHTML = xSet[1];
			break;
		case "sch":
			if (typeof(document.all.notify_sch)=="object") document.all.notify_sch.innerHTML = xSet[1];
			break;
		case "mail":
			if (typeof(document.all.notify_mail)=="object") document.all.notify_mail.innerHTML = xSet[1];
			break;
		case "items":
			if (typeof(document.all.notify_items)=="object") document.all.notify_items.innerHTML = xSet[1];
			break;
		case "quota":
			xStr = xSet[1];
			xSet2 = xStr.split("/");
			if (typeof(document.all.notify_quota)=="object") document.all.notify_quota.innerHTML = DispSize(xSet2[0]);
			if (typeof(document.all.notify_space)=="object") document.all.notify_space.innerHTML = DispSize(xSet2[1]);
			if (typeof(document.all.notify_percent)=="object") document.all.notify_percent.innerHTML = Percent(xSet2[0],xSet2[1]);
			break;
		case "p":
			PostIt(xSet[1]);
			break;
		case "a":
			AlertPop(xSet[1]);
			break;
		}
	}
	//window.status=revCont;
}
function cmdAll(id,cmd,content){
	//window.status=id+":"+cmd+":"+content;
}

function cmdGroup(id,cmd,content){
	var x = Array();
	var obj;
	switch (cmd) {
	case "connect":
		if (nOwner==id) {/*ForceLogout();*/return;}
		if(typeof(memItems)=="object") {
			for(i=0;i<memItems.length;i++) {
				x = memItems[i];
				if (x[0]==id) {x[2]="C";break;}
			}	
			obj = eval("document.all.member_"+id);
			if (typeof(obj)=="object") obj.innerHTML = DispMember(x);
		}
		break;
	case "disconnect":
		if(typeof(memItems)=="object") {
			for(i=0;i<memItems.length;i++) {
				x = memItems[i];
				if (x[0]==id) {x[2]="";break;}
			}	
			obj = eval("document.all.member_"+id);
			if (typeof(obj)=="object") obj.innerHTML = DispMember(x);
		}
		break;
	}
	//window.status=id+":"+cmd+":"+content;
}

function cmdAlert(id,cmd,content) {
	self.focus();
	switch (cmd) {
	case "alert":
		alert(content);
		break;
	case "post":
		PostIt(content);
		break;
	case "appC":
		Alert('°áÀç¹®¼­['+content+']°¡ ¿Ï°áÃ³¸®µÇ¾ú½À´Ï´Ù.');
		break;
	case "invate":
		if(confirm(id+'´ÔÀÌ ['+content+']´ëÈ­¹æÀ¸·Î ÃÊÃ» Çß½À´Ï´Ù.\n'+
			'\n\nÃÊ´ë¸¦ ¼ö¶ôÇÏ½Ã°Ú½À´Ï±î?')){
			Chat(content);
		} else SendAlert(id,'alert',content+'´ÔÀÌ ´ëÈ­ÃÊÃ»À» °ÅºÎÇß½À´Ï´Ù.');
		break;
	case "invate2":
		var sendSet = Array();
      sendSet = content.split("¡×");
		if(confirm(id+'´ÔÀÌ ['+sendSet[0]+']´ëÈ­¹æÀ¸·Î ÃÊÃ» Çß½À´Ï´Ù.\n\n'+sendSet[1]+"\n\n"+
			'\n\nÃÊ´ë¸¦ ¼ö¶ôÇÏ½Ã°Ú½À´Ï±î?')){
			document.location = '/Chat/ChatMain.php?grpname='+sendSet[0];
		} else SendAlert(id,'alert',sendSet[0]+'´ÔÀÌ ´ëÈ­ÃÊÃ»À» °ÅºÎÇß½À´Ï´Ù.');
		break;
	}
}

function SendAlert(id,cmd,content){
	if (typeof(document.all.neoApp)=="object") {
		try {
			document.all.neoApp.putJavaAlert(id,cmd,content);
		} catch (e) {
			//window.status=e + "|" + e.name + "|" + e.message + "|" + e.number + "|" + e.description;
			return;
      }
	}	
}

function SendNotify(Notify){
	if (typeof(document.all.neoApp)=="object") {
		try {
			document.all.neoApp.putJavaNotify(Notify);
		} catch (e) {
//         window.status=e + "|" + e.name + "|" + e.message + "|" + e.number + "|" + e.description;
			return;
      }
	}
}

function SendMsg(cmd,content){
	if (typeof(document.all.neoApp)=="object") {
		try {
			document.all.neoApp.putJavaGroup(cmd,content);
		} catch (e) {
//         window.status=e + "|" + e.name + "|" + e.message + "|" + e.number + "|" + e.description;
			return;
      }
	}
}

function ForceLogout() {
	self.focus();
	alert('´Ù¸¥Ã¢ÀÌ³ª ´Ù¸¥ Å¬¶óÀÌ¾ðÆ®¿¡¼­ ·Î±×ÀÎÇÔÀ¸·Î ÀÎÇØ'+'\n'+'ÀÌ Ã¢Àº ·Î±×¾Æ¿ô µÇ¾ú½À´Ï´Ù.');
	location.href="/Common/Login.php?Prc=Logout";
}

function nxInit(nS,nO) {
	if (nS) nSpeed=nS;
	if (nO!="") nOwner=nO;
	sTouch();
}

function sTouch() {
	if (typeof(document)!="object") return;
	if (typeof(document.all.notify_quota)=="object") SendNotify(0);
	setTimeout("sTouch()",nSpeed)
}

function comma(x) {
	var txtNumber = '' + x;
	var rxSplit = new RegExp('([0-9])([0-9][0-9][0-9][,.])');
	var arrNumber = txtNumber.split('.');
	arrNumber[0] += '.';
	do {arrNumber[0] = arrNumber[0].replace(rxSplit, '$1,$2');} while (rxSplit.test(arrNumber[0]));
	if (arrNumber.length > 1) return arrNumber.join('');
	else return arrNumber[0].split('.')[0];
}

function DispSize(N) {
   if (N>=1048576) D=comma(Math.round(N/1048576))+"G"
   else if (N>1024) D=comma(Math.round(N/1024))+"M"
   else D=comma(N)+"K";
   return D;
}

function Percent(N1,N2) {
   if (N2<1) return "0%";
   D=Math.round(N1/N2*100);
	return D+"%";
}

function neo_fsc(c,a) {
	var c,a;
	switch (c) {
	case "popup_postit":
		var b=a.split("-");
		var s=b.length;
		for(i=0;i<s-1;i++) PostIt(b[i]);
		break;
	case "launch_alert":
		openPeeker();
		break;
	case "launch_chat":
		var b=a.split(":");
		ChatAccept(b[0],b[1]);
		break;
	case "userinfo":
		User(a);
		break;
	case "icon_mail":
		if (typeof(webmail)!="undefined"&&webmail!="") document.location='/AutoLogin.php';
		else Compose('New','',-1);
		break;
	case "icon_schedule":
		SchedulePopup(-1);
		break;
	case "icon_todo":
		ToDoPopup(-1);
		break;
	case "icon_postit":
		PostIt(-1);
		break;
	case "icon_alert":
		AlertMsgTo('');
		break;
	case "icon_sms":
		document.location='/MsgCenter/MsgCenter.php?mbox=/SMS';
		break;
	case "icon_chat":
		document.location='/Chat/ChatMain.php';
		break;
	case "check_mail":
		if (typeof(webmail)!="undefined"&&webmail!="") document.location='/AutoLogin.php';
		else document.location='/MsgCenter/MsgCenter.php?mbox=/Mail/INBOX';
		break;
	case "check_mail2":
		if (typeof(webmail)!="undefined"&&webmail!="") window.open('/AutoLogin.php','','');
		else window.open('/MsgCenter/MsgCenter.php?mbox=/Mail/INBOX','','');
		break;
	case "check_app":
      window.open('/Approval/Approval.php?abox=In','','');
		break;
	case "check_post":
		document.location='/MsgCenter/MsgCenter.php?mbox=/Postit/Inbox';
		break;
	case "check_post2":
		window.open('/MsgCenter/MsgCenter.php?mbox=/Postit/Inbox','','');
		break;
	case "check_todo":
		document.location='/Schedule/Schedule.php';
		break;
	case "check_todo2":
		window.open('/Schedule/Schedule.php','','');
		break;
	case "check_sch":
		document.location='/Schedule/Schedule.php';
		break;
	case "check_sch2":
		window.open('/Schedule/Schedule.php','','');
		break;
	case "check_sms":
		document.location='/MsgCenter/MsgCenter.php?mbox=/SMS';
		break;
	case "check_sms2":
		window.open('/MsgCenter/MsgCenter.php?mbox=/SMS','','');
		break;
	case "gohome":
		document.location='/Zone.php';
		break;
	case "test" :
		alert(a);
		break;
	case "messanger" :
		if (typeof(document.all["memberlist"])=="object") {
			var field=a.split('-');
			mid=field[0];
			if (mid=="") break;
			mNick=field[1];
			if(field[2]=='1')icon='UserC';
			else if(field[2]=='0')icon='User';
			if(typeof(document.all["d"+mid])=='object' && typeof(eval("i"+mid))=='object') eval("i"+mid+".src='/tempJasmine/Icon/btn"+icon+".gif';")
			else if(mNick!='')memberlist.innerHTML = memberlist.innerHTML + "<div class=mlist id=d"+mid+"><a class=hand onClick=User('"+mid+"')><img id=i"+mid+" src=/Custom/Jasmine/Icon/btn"+icon+".gif align=absmiddle border=0> "+mNick+"</a></div>";
			break;
		}
		break;
	case "help" :
		Help(a)
		break;
	case "link"	:
		if(a='sitemap') openIT('/WWW/Sitemap.php',870,580,null,null,'myidWin',1,true,true,true);	
	}
	c=a='';
}