var xmlHttp;
function createXMLHttpRequest(){
  if(window.ActiveXObject){
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  }else if(window.XMLHttpRequest){
     xmlHttp = new XMLHttpRequest();
  }
}
function page(Page) {
  createXMLHttpRequest();
  PageId = Page;
  var queryString = "./includes/random.php?page="+PageId;
  queryString = queryString + "&timeStamp=" + new Date().getTime();
  xmlHttp.onreadystatechange = HandleBase;
  xmlHttp.open("GET", queryString, true);
  xmlHttp.send(null);
}
function HandleBase(){
  if(xmlHttp.readyState == 4) {
    if(xmlHttp.status == 200) {
      document.getElementById("random").innerHTML = xmlHttp.responseText;
    }
  }
}
function scan(Yahoo){
  if(Yahoo.length < 4 || Yahoo.length > 32){
    alert("You must enter an ID between 4 and 32 characters!");
    return false;
  }else{
    document.getElementById('Avatar').innerHTML='<a title="Click here to download avatar" href="./download.php?yids='+Yahoo+'"><img alt="Click here to download avatar" src="http://img.msg.yahoo.com/avatar.php?yids='+Yahoo+'" width="94" height="94" border="0" /></a>';
    createXMLHttpRequest();
    var queryString = "./includes/PersianExisTeam.php?yahoo="+Yahoo;
    queryString = queryString + "&timeStamp=" + new Date().getTime();
    xmlHttp.onreadystatechange = ScanHandleBase;
    xmlHttp.open("GET", queryString, true);
    xmlHttp.send(null);
    return false;
  }
}
function ScanHandleBase(){
  if (xmlHttp.readyState==1){
    document.getElementById('result').innerHTML='<br><br><center><img width="16" height="16" src="images/progress.gif"></center>';
  }
  if(xmlHttp.readyState == 4){
    if(xmlHttp.status == 200){
      var string=xmlHttp.responseText;
      if(string=="bussy"){
        document.getElementById('result').innerHTML='Server is bussy!';
      }else if(string=="incorrect"){
        document.getElementById('result').innerHTML='Yahoo id is incorrect!';
      }else{
        var imgstr=xmlHttp.responseText.split(" is ");
        document.getElementById('result').innerHTML='<div align="left">'+string+'<font style="font-size:9pt;"><br><br><a href="ymsgr:sendim?'+imgstr[0]+'">Send</a> a message to '+imgstr[0]+'<br /><a href="ymsgr:addfriend?'+imgstr[0]+'">Add</a> '+imgstr[0]+' to the friend list<br /><a href="http://360.yahoo.com/'+imgstr[0]+'" target="_blank">View</a> '+imgstr[0]+'\'s yahoo 360 profile<br /></font></div>';
        document.getElementById('status').innerHTML='<img alt="'+string+'" src="images/'+imgstr[1]+'.gif">';
      }
    }
  }
  return false;
}


