var my_base_url='http://www.internetdj.com';
var my_pligg_base='';


dochref = document.location.href.substr(document.location.href.search('/')+2, 1000);
if(dochref.search('/') == -1){
	$thisurl = document.location.href.substr(0,document.location.href.search('/')+2) + dochref;
} else {
	$thisurl = document.location.href.substr(0,document.location.href.search('/')+2) + dochref.substr(0, dochref.search('/'));
}
$thisurl = $thisurl + '';

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;
  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);
}

var mnmxmlhttp = Array ();
var xvotesString = Array ();
var mnmPrevColor = Array ();
var responsestring = Array ();
var myxmlhttp = Array ();
var responseString = new String;


function vote (voteuser, type, id, value, htmlid, bl)
{
  	if (xmlhttp) {
		url = $thisurl + "/media-vote.php";
		var mycontent = "id=" + id + "&voteuser=" + voteuser + "&type=" + type + "&value=" + value + "&bl=" + bl;
		anonymous_vote = true;
	        if (anonymous_vote == false && user == '0') {
        	    window.location="http://www.internetdj.com/user.php?returnfunc="+location.href;
        	} else {
    			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 ('xvotes-' + htmlid);    
    				mnmPrevColor[htmlid] = target1.style.backgroundColor;
	    			mnmxmlhttp[htmlid].onreadystatechange = function () {
    					if (mnmxmlhttp[htmlid].readyState == 4) {
    						xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;
    						if (xvotesString[htmlid].match (errormatch)) {
    							xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);
							changemnmvalues (htmlid, value, true);
						} else {
							if (xvotesString[htmlid].substring (1, 6) == "ERROR") { 
								alert(xvotesString[htmlid]);  
							} else {
								changemnmvalues (htmlid, value, false); 
							}
						}
					}
				}
			}
		}
	}
}

function changemnmvalues (id, value, error)
{
	split = new RegExp ("~--~");
	b = xvotesString[id].split (split);
	//alert(id);
	target1 = document.getElementById ('xvotes-' + id);
	target2 = document.getElementById ('xvote-' + id);
	target3 = document.getElementById ('xreport-' + id);
	target4 = document.getElementById ('xnews-' + id);
	if (error) {
		if (value > 0) { target2.innerHTML = "<span>Swarmed</span> "; }
		else if (value < 0) { target2.innerHTML = "<span>Buried</span> "; }
		return false;
	}
	if (b.length <= 3) {
		target1.innerHTML = b[0];
		target1.style.backgroundColor = mnmPrevColor[id];
		//new Effect.Fade(target3);
		if (value > 0) { target2.innerHTML = "<span>Bzz'd</span> "; }
		else if (value < 0 ) { target2.innerHTML = "<span>Kild</span> ";
		new Effect.Opacity(target4, {duration:0.8, from:1.0, to:0.3}); }
	}
	return false;
}
