
var xmlHttp = createXmlHttpRequestObject();
var currentEnemy = "";
var cpic;
var pg;

//------------------------------------------------------//
function createXmlHttpRequestObject(){

  var xmlHttp;
  
  try{
    xmlHttp = new XMLHttpRequest();
  }
  catch(e){

    var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
                                    "MSXML2.XMLHTTP.5.0",
                                    "MSXML2.XMLHTTP.4.0",
                                    "MSXML2.XMLHTTP.3.0",
                                    "MSXML2.XMLHTTP",
                                    "Microsoft.XMLHTTP");

    for(var i=0; i<XmlHttpVersions.length && !xmlHttp; i++){

      try{ 
        xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
      } 
      catch(e){}
    
    }//for
  }//catch

  if(!xmlHttp){
   //alert("Error creating the XMLHttpRequest object.");
   return;
  }

  else{
   //alert("successfully created XMLHttp object");
   return xmlHttp;
  }

}//createXmlHttpRequestObject
//------------------------------------------------------//
function paw(pic, page){

 cpic = pic;
 pg   = page;

 document.getElementById(pic).innerHTML = "<font color='#000000'>tapizás...</font>";

 if(xmlHttp){        
          
   var get_page = "http://chatfoto.hu/chat/titpaw.php?pic="+pic+"&page="+page;
   xmlHttp.open("GET", get_page, true);                                                                                                        
   xmlHttp.onreadystatechange = getPawResp;
   xmlHttp.send(null);

 }//if

}//paw
//------------------------------------------------------//
function getPawResp(){

 if(xmlHttp.readyState == 4){

  var resp = xmlHttp.responseText;

  document.getElementById(cpic).innerHTML = "<img src='/image/titvotebtndis.png'>";

  if(resp == "er"){

   alert("Hiba!");

  }//if

  else if(resp == "no"){

   alert("Ezt a képet ma már tapiztad, legközelebb holnap tudod!");

  }//if

  else if(resp == "ok"){

   alert("Sikeres tapizás :-)");

   if(pg != "" && pg != undefined && pg != "undefined")
    document.location.reload();
   else
    document.location.href = "/chat-mellszepsegverseny";

  }//if 

 }//if 

}//getPawResp
//------------------------------------------------------//
