
      var http_request = false;
   function makeRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      //http_request.onreadystatechange = alertContents;
      http_request.open('GET', url + parameters, true);
      http_request.send(null);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('myspan').innerHTML = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
   function get(obj) {
      var getstr = "?";
      for (i=0; i<obj.childNodes.length; i++) {
         if (obj.childNodes[i].tagName == "INPUT") {
            if (obj.childNodes[i].type == "text") {
               getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
            }
            if (obj.childNodes[i].type == "checkbox") {
               if (obj.childNodes[i].checked) {
                  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
               } else {
                  getstr += obj.childNodes[i].name + "=&";
               }
            }
            if (obj.childNodes[i].type == "radio") {
               if (obj.childNodes[i].checked) {
                  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
               }
            }
         }   
         if (obj.childNodes[i].tagName == "SELECT") {
            var sel = obj.childNodes[i];
            getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
         }
         
      }
      makeRequest('get.php', getstr);
   }

function voteUp(thing_id) {
	var trr = readCookie('r_' + thing_id);
	if (trr) {
		return;
	}
	makeRequest('rate.php','?thing_id=' + thing_id + '&v=u')	
			var tid = document.getElementById('uv_'+thing_id);
			tid.childNodes[0].nodeValue = ( parseInt(tid.childNodes[0].nodeValue) + 1 );
	//		Set_Cookie('r_'+thing_id, '1','1','','','');
}

function voteDown(thing_id) {
	var trr = readCookie('r_' + thing_id);
	if (trr) {
		return;
	}
	makeRequest('rate.php','?thing_id=' + thing_id + '&v=d')	
			var tid = document.getElementById('dv_'+thing_id);
			tid.childNodes[0].nodeValue = ( parseInt(tid.childNodes[0].nodeValue) + 1 );
		//	Set_Cookie('r_'+thing_id, '1','1','','','');
}
function meToo(thing_id) {
	var trr = readCookie('smt_' + thing_id);
	if (trr) {
		return;
	}
	makeRequest('rate.php','?thing_id=' + thing_id + '&v=mt')	
			var tid = document.getElementById('mt_'+thing_id);
			tid.childNodes[0].nodeValue = ( parseInt(tid.childNodes[0].nodeValue) + 1 );
			//Set_Cookie('smt_'+thing_id, '1','1','','','');
}

function doWtf(thing_id) {
	var trr = readCookie('wtf_' + thing_id);
	if (trr) {
		return;
	}
	makeRequest('rate.php','?thing_id=' + thing_id + '&v=wtf')	
			var tid = document.getElementById('wtf_'+thing_id);
			tid.childNodes[0].nodeValue = ( parseInt(tid.childNodes[0].nodeValue) + 1 );
			//Set_Cookie('smt_'+thing_id, '1','1','','','');
}

/*
function voteUp(thing_id) {
        $.get('/rate.php', { thing_id: thing_id, v: 'u' }, function(data, status) {
                if(status == 'success' && data.result == 1)
                        $('#uv'+thing_id).text(parseInt($('#uv'+thing_id).text())+1);
        }, 'text');
}

function voteDown(thing_id) {
        $.get('/rate.php', { thing_id: thing_id, v: 'd' }, function(data, status) {
                if(status == 'success' && data.result == 1)
                        $('#dv'+thing_id).text(parseInt($('#dv'+thing_id).text())+1);
        }, 'text');
}

function meToo(thing_id) {
        $.get('/rate.php', { thing_id: thing_id, v: 'mt' }, function(data, status) {
                if(status == 'success' && data.result == 1)
                        $('#mt'+thing_id).text(parseInt($('#mt'+thing_id).text())+1);
        }, 'text');
} */


function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function getdata(dest) {
        try {
                xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
        }
var dt = new Date( ).valueOf();
//xmlhttp.onreadystatechange = triggered;
xmlhttp.open("GET", dest + "?dt=" + dt);
xmlhttp.send(null);

}

function triggered() {
        if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
                document.getElementById("sbblive").innerHTML = xmlhttp.responseText;
        }
}

function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}


