var IfengAppVote = {
	encoding:'utf-8',
	author:'huweiqi',
	date:'2008.1.28'
};

(function(){
	//IFRAME提交
	IfengAppVote.iframeSubmit = function (rURL){
		try{
			document.getElementById('voteIframe').src = rURL;
		}catch(err){
		}
	}
	
	//截取字符串
	IfengAppVote.substr = function(s, d) {
		if(typeof(s)=='undefined'||s.length==0){
			return '';
		}
		if(s.length>d){
			return s.substr(0, d)+'...';
		}else{
			return s;
		}
	}
	
	IfengAppVote.voteflag = true;
	IfengAppVote._a = new Object();
	
	//提交投票
	IfengAppVote.vote = function(_a,sid,vid,iid){
		var requesturl = "http://space.ifeng.com/vote/votingJSON.do?surveyId="+sid+"&aw"+vid+"="+iid+"&t="+new Date().getTime();
		IfengAppVote._a = _a;
		IfengAppVote.iframeSubmit(requesturl);
		setTimeout('voteResult(IfengAppVote._a,IfengAppVote.voteflag,IfengAppVote.vote_msg);',200);
	}
	
	voteResult = function(_a,_v,_m){
		if(_v){
			_a.innerHTML = (new Number(_a.innerHTML)) + 1;
		}
		if(typeof(_m)=='undefined'){
			alert('投票成功！');
		}else{
			alert(_m);
		}
	}
	
})()