
/*
 iNum 070821, dcinside corp.
 AlertMessanger
*/


function AlertMessanger(cName){

	if(cName==null || cName=="") return errorStr("클래스 초기화 오류입니다.");
	this._AJC = new AjaxClass(cName+"._AJC");

	var openAlert=false;
	var autoCloseId;
//	this.setPosition();
	
	this.checkSameMember2Info = function(){
		var query=[];
		query.push({name: "gid", value : G_ID});
		query.push({name: "mode", value:"SOC_CHK_SAME_M2INFO"});
		this._AJC.getAHAHData("/ajdb.php", new Function(cName+".receive_checkSameMember2Info();"), query);
	}

	this.receive_checkSameMember2Info = function(){
		var dObj = convertFunc(this._AJC.getAHAH() );
		try{
			if(dObj.result) {
				GEID('notyTitle').innerHTML="반갑습니다.";
				GEID('notyContent').innerHTML= "- " + dObj.data[0].msg + (dObj.data[0].data!=""? "<br>&nbsp;&nbsp;&nbsp;(" + URLdecode(dObj.data[0].data, "URI")+")" : "");
				if(dObj.data.length>1) GEID('notyContent').innerHTML+="<br>"+"- " + dObj.data[1].msg + (dObj.data[1].data!=""? "<br>&nbsp;&nbsp;&nbsp;(" + URLdecode(dObj.data[1].data, "URI")+")" : "");
				
				GEID('notyAddMsg').innerHTML = "<span onclick=\"window.open('http://dcid.dcinside.com/join/member_profile.php?profile_no="+G_ID_NO+"', 'gProfile', 'left=200, top=200, width=400, height=550, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, copyhistory=no, resizable=no');\" style='cursor:pointer;'>확인(" + dObj.data.length +")</span>";
				this.open();
			}else {
				//alert(URLdecode(dObj.msg, "URI"));
			}
		}catch(e){
			alert(e + "서버와의 통신이 원활치 않습니다. 잠시 후 다시 시도해 주십시오");
		}

	}

	this.fadeId = [];
	this.open = function(id, msg){
		if(openAlert) return;
		var o = GEID('notyDiv');
		this.setPosition();
		disOn(o);
		setOpacityObj(o, 0);

		this.fadeId = ObjFadeIn(o, this.fadeId);
		openAlert=true;
		autoCloseId = setTimeout(new Function(cName+".close();"), 7000);

	}

	this.close =function(act){
		if(act!=null && act) {
			window.clearTimeout(autoCloseId);
			autoCloseId=null;
			this.closeComp();
		}else{
			if(!openAlert) return;
			var o = GEID('notyDiv');
	//		this.setPosition();
			this.fadeId = ObjFadeOut(o, this.fadeId, new Function(cName+".closeComp();"));
		}
	}

	this.closeComp = function(){
		var o = GEID('notyDiv');
		setOpacityObj(o, 0);
		openAlert=false;
		disOff(o);
	}

	
	this.setPosition = function(){
		if(!openAlert) return;

		var o = GEID('notyDiv');
		hInfo = getHtmlInfo();

		x = hInfo.clientWidth + hInfo.scrollLeft - (10 + 200);
		y = hInfo.clientHeight + hInfo.scrollTop - (10 + 150);

		moveToXY(o, x, y);
//		this.open();

	}


}
