var anonymous_vote = true;
var xmlhttp
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
  try {
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
   xmlhttp=false
  }
 }
@else
 xmlhttp=false
@end @*/

if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
  try {
	xmlhttp = new XMLHttpRequest ();
  }
  catch (e) {
  xmlhttp = false}
}

function myXMLHttpRequest ()
{
  	var xmlhttplocal;
	if(window.XMLHttpRequest) {
			xmlhttplocal = new XMLHttpRequest();
			if(xmlhttplocal.overrideMimeType) {
				xmlhttplocal.overrideMimeType('text/xml');
			}
		} else if(window.ActiveXObject) {
			var versions = ['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];
			for(var i=0; i<versions.length; i++) {
				try {
					xmlhttplocal = new ActiveXObject(versions[i]);					
				} catch(e) {
					xmlhttplocal = false;
					//alert(e.message);
				}
			}
		}
		
  if (!xmlhttplocal && typeof XMLHttpRequest != 'undefined') {
	try {
	  var xmlhttplocal = new XMLHttpRequest ();
	}
	catch (e) {
	  var xmlhttplocal = false;
	}
  }
  return (xmlhttplocal);
}

var mnmxmlhttp = Array ();
var mnmString = Array ();
var mnmPrevColor = Array ();
var responsestring = Array ();
var myxmlhttp = Array ();
var responseString = new String;
var baseimg = "http://static.mymc.cn/rss.gif";

function ajax_call(url, htmlid)
{
	url = url + "&" + Math.random(); 
  	if (xmlhttp) {
		var h =  new myXMLHttpRequest ();
		if( h ) {
			h.open("GET", url,  true);
 			h.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');
			h.send(null);
			h.onreadystatechange = function () {
				if (h.readyState == 4) {
					res = h.responseText;
					if( res.substr(0, 4) == 'open' ) {
						window.open(res.substr(5) );
					} else {
	 					document.getElementById(htmlid).innerHTML = res; 
					}
				}
			}
		}
	}
}

function menealo (id, htmlid, value)
{
  	if (xmlhttp) {
		url = jsPath + 'comment/vote';	//digg提交地址
		var mycontent = "id=" + id + "&value=" + value;
		anonymous_vote = true;
		
		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
		if (mnmxmlhttp) {
			mnmxmlhttp[htmlid].open ("POST", url, true);
			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');

			mnmxmlhttp[htmlid].send (mycontent);
			errormatch = new RegExp ("^ERROR:");

			target1 = document.getElementById ('mnms-' + htmlid);

			mnmPrevColor[htmlid] = target1.style.backgroundColor;
			//target1.style.background = '#c00';
			//target1.style.backgroundColor = '#FF9D9F';
			mnmxmlhttp[htmlid].onreadystatechange = function () {
				if (mnmxmlhttp[htmlid].readyState == 4) {
					mnmString[htmlid] = mnmxmlhttp[htmlid].responseText;
					if (mnmString[htmlid].match (errormatch)) {
						mnmString[htmlid] = mnmString[htmlid].substring (0, mnmString[htmlid].length);
						changemnmvalues (htmlid, true);    					} else {
						changemnmvalues (htmlid, false);    					}
				}
			}
		}
		
	}
}


function haveVote(id) {
	target2 = document.getElementById ('mnmlink-' + id);
	target2.innerHTML = "<span>已投票</span> ";
}

function changemnmvalues (id, error)
{
	split = new RegExp ("~--~");
	b = mnmString[id].split (split);
	//alert(id);
	target1 = document.getElementById ('mnms-' + id);
	target2 = document.getElementById ('mnmlink-' + id);
	if (error) {
		target2.innerHTML = "<span>成功</span> ";
		return false;
	}
	if (b.length <= 3) {
		target1.innerHTML = b[0];
		target1.style.backgroundColor = mnmPrevColor[id];
		target1.href = "javascript:haveVote("+id+", true);";
		target2.innerHTML = "<span>成功</span> ";
	}
	return false;
}
var i =new Image();
i.src=baseimg;