	var xmlHttp_dp;
	var voteType_dp;
	var listId_dp;
  	function createXMLHttpRequest_dp() {
		try{
	        xmlHttp_dp = new XMLHttpRequest();
	   	}catch(trymicrosoft){
	        try{
	            xmlHttp_dp = new ActiveXObject("Msxml2.XMLHTTP");
	        }catch(othermicrosoft){
	            try{
	                xmlHttp_dp = new ActiveXObject("Microsoft.XMLHTTP");
	            }catch(faild){
	                xmlHttp_dp = false;
	            }
	        }
	    }
    }

    function vote_com(com_id,vote_type,goods_id,list_id) {
		voteType_dp=vote_type;
		listId_dp=list_id;
        createXMLHttpRequest_dp();
		var url = "http://"+getHost_dp()+"/dianping/vote.jsp?com_id="+com_id
					+"&vote_type="+vote_type+"&goods_id="+goods_id;
        xmlHttp_dp.open("GET", url, true);
		xmlHttp_dp.onreadystatechange = callback_dp;
        xmlHttp_dp.send(null);
    }
    function callback_dp() {
        if (xmlHttp_dp.readyState == 4) {
            if (xmlHttp_dp.status == 200) {
				var result =xmlHttp_dp.responseXML.getElementsByTagName("mes")[0].firstChild.data;
				setMessage_dp(result);
            }
        }
    }
	function getHost_dp(url) { 
        var host = "null";
        if(typeof url == "undefined"
                        || null == url)
                url = window.location.href;
        var regex = /.*\:\/\/([^\/]*).*/;
        var match = url.match(regex);
        if(typeof match != "undefined"
                        && null != match)
                host = match[1];
        return host;
	}
    function setMessage_dp(result) {
		switch(result)
        {
            case "0"://未登陆
            window.location.href="http://"+getHost_dp()+"/login/login.jsp?href="
			+escape(window.location.href);            
                break;
            case "1":
            alert("对不起，你只能投票一次！");
                break;
            case "2":
            	alert("投票成功！");
				 if(voteType_dp==1){
        			document.getElementById(listId_dp+"help").innerHTML =parseInt(document.getElementById(listId_dp+"help").innerHTML)+1;
        			document.getElementById(listId_dp+"total").innerHTML =parseInt(document.getElementById(listId_dp+"total").innerHTML)+1; 
        		}
        		else{
               	 document.getElementById(listId_dp+"total").innerHTML =parseInt(document.getElementById(listId_dp+"total").innerHTML)+1;
        		}
                break;
			case "3":
            alert("投票失败！");
            default:
                break;
        }
      
    }