﻿var httpf, httph;

httpf = new HttpHandleFactory();
httph = new HttpHandler();
httphlogin = new HttpHandler();
httphaddlogin = new HttpHandler();
httph.doIt = function(response_) {
	try{
		//alert(response_);
		if (response_ == '0') {
			if (confirm('投票成功！留下您的联系方式，即可参加本月的抽奖活动！')) {
				location.href = 'http://disney.dolmagic.cn/passport/login?rt=2&ru=http://d.dolmagic.cn/story/character.jsp';
			} else {
				location.reload();
			}
		} else if (response_ == '1') {
			alert('投票成功！');
			location.reload();
		} else if (response_ == '3') {
			alert('请不要重复投票');
		} else if (response_ == '9') {
			alert('网络繁忙!!');
		} else {
			alert('网络繁忙，请稍候再试！！');
		}
	}catch(e){
		alert('网络繁忙，请稍候再试！！');
	}
}

httph.doErr = function(status_) {
	alert('网络繁忙，请稍候再试！！');
}

httphlogin.doIt = function(response_) {
	try{
		var logininfo;
		var httpurl;
		if (response_.length > 0){
			logininfo = response_.split('&#&');
			httpurl = 'loginnew.jsp?n=' + logininfo[0] + '&l=' + logininfo[1] + '&i=' + logininfo[2] + '&ue=' + logininfo[3] + '&a=' + logininfo[4] + '&ge=' + logininfo[5];
			addlogin(httpurl);
		}
	} catch(e) {
		alert(e);
	}
}

httphlogin.doErr = function(status_) {
	alert(status_);
}

function vote(role_id){
	httpf.connection('vote.jsp?role_id='+role_id, httph);
	//alert('vote.jsp?role_id='+role_id);
}

function checklogin() {
	//httpf.connection('http://disney.dolmagic.cn/registerServlet', httphlogin);
}

function addlogin(uri) {
	httpf.connection(uri, httphaddlogin);
}
