var xmlhttp
if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
try {
xmlhttp = new XMLHttpRequest ();
}
catch (e) {
xmlhttp = false}
}
function myXMLHttpRequest ()
{
var xmlhttplocal;
try {
xmlhttplocal = new ActiveXObject ("Msxml2.XMLHTTP")}
catch (e) {
try {
xmlhttplocal = new ActiveXObject ("Microsoft.XMLHTTP")}
catch (E) {
xmlhttplocal = false;
}
}
if (!xmlhttplocal && typeof XMLHttpRequest != 'undefined') {
try {
var xmlhttplocal = new XMLHttpRequest ();
}
catch (e) {
var xmlhttplocal = false;
}
}
return (xmlhttplocal);
}
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }
var mnmxmlhttp = Array ();
var xvotesString = Array ();
var mnmPrevColor = Array ();
var responsestring = Array ();
var myxmlhttp = Array ();
var responseString = new String;
function voteup (id, md5, value)
{
if (xmlhttp) {
url = "/voteup.php";
var mycontent = "id=" + id + "&md5=" + md5 + "&value=" + value;
mnmxmlhttp[id] = new myXMLHttpRequest ();
if (mnmxmlhttp) {
mnmxmlhttp[id].open ("POST", url, true);
mnmxmlhttp[id].setRequestHeader ('Content-Type',
'application/x-www-form-urlencoded');
mnmxmlhttp[id].send (mycontent);
errormatch = new RegExp ("^ERROR:");
mnmxmlhttp[id].onreadystatechange = function () {
if (mnmxmlhttp[id].readyState == 4) {
xvotesString[id] = mnmxmlhttp[id].responseText;
if (xvotesString[id].match (errormatch)) {
xvotesString[id] = xvotesString[id].substring (6, xvotesString[id].length);
changemnmvalues (id, value, true);	} else {
if (xvotesString[id].substring (1, 6) == "ERROR") {
} else {
changemnmvalues ('up',id, value, false);
}	}
}
}
}
}
}
function flag (id, md5, value)
{
if (xmlhttp) {
url = "/flag.php";
var mycontent = "id=" + id + "&md5=" + md5 + "&value=" + value;
mnmxmlhttp[id] = new myXMLHttpRequest ();
if (mnmxmlhttp) {
mnmxmlhttp[id].open ("POST", url, true);
mnmxmlhttp[id].setRequestHeader ('Content-Type',
'application/x-www-form-urlencoded');
mnmxmlhttp[id].send (mycontent);
errormatch = new RegExp ("^ERROR:");
mnmxmlhttp[id].onreadystatechange = function () {
if (mnmxmlhttp[id].readyState == 4) {
xvotesString[id] = mnmxmlhttp[id].responseText;
if (xvotesString[id].match (errormatch)) {
xvotesString[id] = xvotesString[id].substring (6, xvotesString[id].length);
changemnmvalues (id, value, true);	} else {
if (xvotesString[id].substring (1, 6) == "ERROR") {
} else {
changemnmvalues ('flag',id, value, false);
}	}
}
}
}
}
}
function changemnmvalues (vote_type, id, value, error)
{
split = new RegExp ("~--~");
b = xvotesString[id].split (split);
if( b[0]!=''){
if(vote_type=='up'){
target1 = document.getElementById ('xapplaud-' + id);
if(b[0].trim()=="1"){
target1.innerHTML = "" + b[0].trim() + " person likes this photo";	} else {
target1.innerHTML = "" + b[0].trim() + " people like this photo";
}
target2 = document.getElementById ('xvotes-' + id);
target2.innerHTML = b[0].trim();
target3 = document.getElementById ('xvote-' + id);
target3.innerHTML = "Thanks";
target4 = document.getElementById ('xbox-' + id);
newImage = "url(/images/vote-l-mobile.png)";
target4.style.backgroundImage = newImage;	} else if (vote_type=='down'){
target1 = document.getElementById ('xsmite-' + id);
target1.innerHTML = "(-" + b[0].trim() + ")";
}  else {
target1 = document.getElementById ('xflag-' + id);
target1.innerHTML = " Flagged (" + b[0].trim() + ")";
}
}
return false;
}
function comment (id, md5, author, guid, value)
{
if (xmlhttp) {
nocomments = document.getElementById ('nocomments');
nocomments.innerHTML = "";
if(author==''){
	author='Anonymous';
}
newcomments = document.getElementById ('newcomments');	newcomments.innerHTML += '<div class="sblGreen"><div class="sbrGreen"><div class="stlGreen"><div class="strGreen">' +
'' + value + '' +
'</div></div></div></div><div class="sbGreen">&nbsp;</div>' +
'<div style="text-align:right;"><strong>' + author + '</strong></div><br />';
url = "/addComment.php";
var mycontent = "id=" + id + "&md5=" + md5 + "&author=" + author + "&guid=" + guid + "&value=" + value ;
mnmxmlhttp[id] = new myXMLHttpRequest ();
if (mnmxmlhttp) {
mnmxmlhttp[id].open ("POST", url, true);
mnmxmlhttp[id].setRequestHeader ('Content-Type',
'application/x-www-form-urlencoded');
mnmxmlhttp[id].send (mycontent);
errormatch = new RegExp ("^ERROR:");
mnmxmlhttp[id].onreadystatechange = function () {
if (mnmxmlhttp[id].readyState == 4) {
xvotesString[id] = mnmxmlhttp[id].responseText;
if (xvotesString[id].match (errormatch)) {
xvotesString[id] = xvotesString[id].substring (6, xvotesString[id].length);
changemnmvalues (id, value, true);	} else {
if (xvotesString[id].substring (1, 6) == "ERROR") {
} else {
document.getElementById('commentfield').value="";
}	}
}
}
}
}
}
