function castvote(vid, vnum, response){
        if (response != '' && response != 'alreadyvoted') {
			 therid = "Rate" + vid;
			 document.getElementById(therid).title = response;
			 Outr(vid);
			 therid = "Ratedeco" + vid;
			 document.getElementById(therid).innerHTML = vnum + ' users rate this:' + response + ' of 5 stars';
        } else if(response != 'alreadyvoted'){
            loadXMLDoc('http://www.bestofbatonrouge.com/ajaxCastVote.php?vid=' + vid + '&vnum=' + vnum);
        }
}

function getdate(vid, vnum, response){
        if (response != '' && response != 'alreadyvoted') {
		     //vnum needs to be the date
		     //target for new content is therid
			 therid = vid;
			 //document.getElementById(therid).title = response;
			 //Outr(vid);
			 //therid = "Ratedeco" + vid;
			 document.getElementById(therid).innerHTML = xmlunescape(xmlunescape(response));
        } else if(response != 'alreadyvoted'){
            loadXMLDoc('http://www.bestofbatonrouge.com/ajaxGetDate.php?vid=' + vid + '&vnum=' + vnum);
        }
}

var xmlhttp;

function loadXMLDoc(url) {
    // Native
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = processStateChange;
        xmlhttp.open("GET", url, true);
        xmlhttp.send(null);
    // ActiveX
    } else if (window.ActiveXObject) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        if (xmlhttp) {
            xmlhttp.onreadystatechange = processStateChange;
            xmlhttp.open("GET", url, true);
            xmlhttp.send();
        }
    }
}

function processStateChange() {
    if (xmlhttp.readyState == 4) {
	  	if(xmlhttp.status == 200){
	        response = xmlhttp.responseXML.documentElement;
			var method = '';
			var result = '';
			var input = '';
			if(response.getElementsByTagName('method')[0]){ method = response.getElementsByTagName('method')[0].firstChild.data; }
			if(response.getElementsByTagName('result')[0]){ result = response.getElementsByTagName('result')[0].firstChild.data; }
			if(response.getElementsByTagName('input')[0]){ input = response.getElementsByTagName('input')[0].firstChild.data; }
			if(response.getElementsByTagName('theid')[0] != null){   //means that there is a target document item theid
				theid = response.getElementsByTagName('theid')[0].firstChild.data;
				if(theid != '' ){
				    eval(method + '(input, theid, result)');
				}
			}
		}
    }
}

// Escape characters
function xmlescape (string) {
  string = string.replace ("&", "&amp;");
  string = string.replace ("<", "&lt;");
  string = string.replace (">", "&gt;");
  string = string.replace ("\"", "&quot;");
  return string;
}
// unEscape characters
function xmlunescape (string) {
  string = string.replace (/&amp;/gi,"&");
  string = string.replace (/&lt;/gi,"<");
  string = string.replace (/&gt;/gi,">");
  string = string.replace (/&quot;/gi,"\"");
  string = string.replace (/&#039;/gi,"'");
  return string;
}