var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    try {
         xmlhttp = new XMLHttpRequest();
    } catch (e) {
         xmlhttp=false;
    }
}

/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
if (!xmlhttp){
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
}
@end @*/

if (!xmlhttp && window.createRequest) {
    try {
        xmlhttp = window.createRequest();
    } catch (e) {
        xmlhttp=false;
    }
}
var please_wait = '<p><b><img src="../rating/images/working.gif" border="0" width="16" height="16">..Loading please wait!</b></p><br><br>';
function sndReq(vote, id_num, ip_num, units) {

  if(!xmlhttp)return false;
var unitsS = '5';
var queryString = "j=" + vote + "&q=" + id_num + "&t=" + ip_num + "&c=" + unitsS;
var url = "../rating/rpc.php";
var e = document.getElementById('ratingres');


    if(please_wait)e.innerHTML = please_wait;
    xmlhttp.open("POST", url, true);

    xmlhttp.onreadystatechange = function() { responsecus(url, e); }
    try{
	  xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
      xmlhttp.send(queryString);
    }catch(l){
    while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
    e.appendChild(document.createTextNode("request failed"));
  }
}

function tell_friend(url, targetId) {

  if(!xmlhttp)return false;
var name  = document.getElementById('name').value;
var email = document.getElementById('email').value;
var fname = document.getElementById('fname').value;
var femail= document.getElementById('femail').value;
//var remnick = document.getElementById('remnick').value;
var dothis= document.getElementById('dothis').value;
var chan = document.getElementById('channelname').value
var queryString = "dothis=" + dothis + "&name=" + name + "&email=" + email + "&fname=" + fname + "&femail=" + femail + "&chan=" + chan;

    var e=document.getElementById(targetId);if(!e)return false;
    if(please_wait)e.innerHTML = please_wait;
    xmlhttp.open("POST", url, true);

    xmlhttp.onreadystatechange = function() { responsecus(url, e); }
    try{
	  xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
      xmlhttp.send(queryString);
    }catch(l){
    while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
    e.appendChild(document.createTextNode("request failed"));
  }
}

function friend_form(url, targetId) {

  if(!xmlhttp)return false;

var chan = document.getElementById('channelname').value
var queryString = "chan=" + chan;

    var e=document.getElementById(targetId);if(!e)return false;
    if(please_wait)e.innerHTML = please_wait;
    xmlhttp.open("POST", url, true);

    xmlhttp.onreadystatechange = function() { responsecus(url, e); }
    try{
	  xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
      xmlhttp.send(queryString);
    }catch(l){
    while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
    e.appendChild(document.createTextNode("request failed"));
  }
}

function responsecus(url, e) {

  if(xmlhttp.readyState != 4)return;
    var tmp= (xmlhttp.status == 200 || xmlhttp.status == 0) ? xmlhttp.responseText : "Ooops!! A broken link! Please contact the webmaster of this website ASAP and give him the following error code: " + xmlhttp.status+" "+xmlhttp.statusText;
    var d=document.createElement("div");
    d.innerHTML=tmp;
    setTimeout(function(){
      while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
      e.appendChild(d);
    },10)
}
