
  function reqajax(action, params, destination, async) {
  	try {
  		var xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (e) {
    }
  	
  	if (async) {
    	xmlhttp.onreadystatechange = function() { triggered(xmlhttp, destination); }
    }

  	var dest = main_url+"ajax/"+action+"/"+params;
    xmlhttp.open("GET", dest, async);
  	xmlhttp.send(null);
  	
  	if (async == false) {
      triggered(xmlhttp, destination);
    }
    return xmlhttp;
  }
  
  function switchDiv(elId) {
    if (document.getElementById(elId)) {
      if (document.getElementById(elId).style.display == "block") {
        hideDiv(elId);
      } else {
        document.getElementById(elId).style.display = "block";
        document.getElementById(elId).style.visibility = "visible";
      }
    }
  }
  
  function hideDiv(elId) {
    if (document.getElementById(elId)) {
      document.getElementById(elId).style.display = "none";
      document.getElementById(elId).style.visibility = "hidden";
    }
  }

  function triggered(xmlhttp, destination) {
    if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
      var response = xmlhttp.responseText.split("|||");
      for (var i = 0; i < response.length; ++i) {
        if (destination.length > i) {
          if (document.getElementById(destination[i])) {
            if (document.getElementById(destination[i]).nodeName.toLowerCase() == "input") {
              document.getElementById(destination[i]).value = response[i];
            } else {
              document.getElementById(destination[i]).innerHTML = response[i];
            }
          }
        }
      }
    }
  }
  
  function setOnLoad(target_id) {
    if (document.getElementById(target_id)) {
      document.getElementById(target_id).innerHTML = "<img src='images/preloader2.gif' class='loader' hspace='0' />";
    }
  }
  
  function reloadPage() {
    window.location.reload();
  }
  
  function redirect(urldest) {
    window.location = main_url+urldest;
  }
  
  var voted = 0;
  function setHoveredStars(name, count, max) {
    if (voted == 0) {
      for (i=1 ; i<=max ; i++) {
        if (document.getElementById(name+i)) {
          var img = document.getElementById(name+i);
          if (i <= count) {
            img.src = "images/stern.png";
          } else {
            img.src = "images/stern_sw.png";
          }
        }
      }
    }
  }
  
  function doVote(dlid, votevalue) {
    if (voted == 0) {
      voted = 1;
      reqajax('addvote', dlid+"V"+votevalue, new Array(), true);
    }
  }
