document.writeln("<script type='text/javascript' src='/Main/scripts/popup.js' charset='utf-8'></script>");
function IM(self, talk, path) {
	this.self = self;
	this.talk = talk;
	this.path = path;
}

IM.prototype.showWebIM = function() {
	if (this.getSelf() && this.getSelf() == "anonymously") {
//		alert("please login. And try again.");
		var popUp = new PopUp({selLang:1});
		popUp.memLoginView();
		popUp.setForwardState(false);
		popUp.setSuccessURL(" http://www.163.com");
		return;
	}else{
		var url =this.getBasePath()+"/Main/SparkWeb.jsp?talk="+this.getTalk().replace("@", "[ksys]");
		window.open(url, 'newwindow', 'top=0, left=0, toolbar=no,menubar=no, scrollbars=no, resizable=no,location=no, status=no')
	
	}
}
IM.prototype.getBasePath = function() {
	if(this.path){
		return this.getPath().substring(0, this.getPath().indexOf("/servlet"));
	}else{ 
		alert("the path error.");
		return "";
	}
}
IM.prototype.getPath = function() {
	return this.path;
}
IM.prototype.getSelf = function() {
	return this.self;
}
IM.prototype.getTalk = function() {
	return this.talk;
}
IM.prototype.processReq = function() {
	var obj = $("#imstatus");
	if (!obj) {
		alert("conld not find imstatus element.");
		return;
	}
	var temp = this;
	$(obj).bind('click', function() {
		// alert(temp.getPath());
			$.post(temp.getPath(), {
				user : temp.getSelf(),
				talk : temp.getTalk()
			}, function(data) {
				if (data) {
					temp.showWebIM();
				}
			});
		});
}

