/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
@end @*/

if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}

function sndReq(image_ptr,artist_id,image_name) {
    xmlHttp.open('get', 'rpc.php?image_ptr='+image_ptr+'&artist_id='+artist_id+'&image_name='+image_name, true);
    xmlHttp.onreadystatechange = handleResponse;
    xmlHttp.send(null);
}

function sndPage(item,limit,album_id,artist_name,page,increment) {
    xmlHttp.open('get', 'rpc2.php?item='+item+'&limit='+limit+'&album_id='+album_id+'&artist_name='+artist_name+'&page='+page+'&increment='+increment, true);
    xmlHttp.onreadystatechange = handlePage;
    xmlHttp.send(null);	
}

function getVideo(id) {
	xmlHttp.open('get', 'rpc3.php?id='+id, true);
    xmlHttp.onreadystatechange = handleVideo;
    xmlHttp.send(null);	
}

function handleVideo() {
	if(xmlHttp.readyState == 4){
        var response = xmlHttp.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');
            document.getElementById(update[0]).innerHTML = update[1];
        }
    }
}

function handlePage() {
    if(xmlHttp.readyState == 4){
        var response = xmlHttp.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');
            document.getElementById(update[0]).innerHTML = update[1];
            document.getElementById(update[2]).innerHTML = update[3];            
        }
    }
}

function handleResponse() {
    if(xmlHttp.readyState == 4){
        var response = xmlHttp.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');
            document.getElementById(update[0]).innerHTML = update[1];
         }
    }
}

