var xmlhttp
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	 try {
	  xmlhttp = new XMLHttpRequest();
	 } catch (e) {
	  xmlhttp=false
	 }
	}
	function myXMLHttpRequest() {
	  var xmlhttplocal;
	  try {
	    xmlhttplocal= new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	    xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	    xmlhttplocal=false;
	  }
	 }

	if (!xmlhttplocal && typeof XMLHttpRequest!='undefined') {
	 try {
	  var xmlhttplocal = new XMLHttpRequest();
	 } catch (e) {
	  var xmlhttplocal=false;
	  alert('couldn\'t create xmlhttp object');
	 }
	}
	return(xmlhttplocal);
}

function getJoke(id_num) {
	
    xmlhttp.open('get', 'AJAXAdminJoke.asp?id='+id_num);
    xmlhttp.onreadystatechange = handleResponse;
    xmlhttp.send(null);	
}

function getJokeLive(id_num) {
	
    xmlhttp.open('get', '../AJAXJokeLive.asp?id='+id_num);
    xmlhttp.onreadystatechange = handleResponseLive;
    xmlhttp.send(null);	
}

function handleResponseLive() {
  if(xmlhttp.readyState == 4){
if (xmlhttp.status == 200){
       	
        var response = xmlhttp.responseText;
        var update = new Array();
        if(response.indexOf('|') != -1) {
            update = response.split('|');
            
            document.getElementById("JOKE_TITLE").innerHTML = update[0];
            document.getElementById("THEJOKE").innerHTML = update[1];
            document.getElementById("JOKE_FB").innerHTML = update[2];
            
        }
		}
		else alert(xmlhttp.status);
    }
}
function handleResponse() {
  if(xmlhttp.readyState == 4){
if (xmlhttp.status == 200){
       	
        var response = xmlhttp.responseText;
        var update = new Array();
        if(response.indexOf('|') != -1) {
            update = response.split('|');
            
            document.getElementById("JID").innerHTML = update[0];
            document.getElementById("JOKEID").value = update[0];
            document.getElementById("JOKE_TITLE").value = update[2];
            document.getElementById("THE_CAT").selectedIndex = update[1];
            document.getElementById("EDITJOKE").innerHTML = "<textarea name=THE_JOKE id=THE_JOKE rows=28 cols=45>"+update[3]+"</textarea>";
            document.getElementById("JOKEPREV").innerHTML = update[3];
            
        }
		}
    }
}
function getiPhoneJoke() {
	
    xmlhttp.open('get', '../AJAXRandjoke.asp');
    xmlhttp.onreadystatechange = handleResponseiPhone;
    xmlhttp.send(null);	
}

function handleResponseiPhone() {
  if(xmlhttp.readyState == 4){
if (xmlhttp.status == 200){
       	
        var response = xmlhttp.responseText;
        var update = new Array();
        if(response.indexOf('|') != -1) {
            update = response.split('|');
            
            document.getElementById("JOKE_TITLE").innerHTML = update[0];
            document.getElementById("THEJOKE").innerHTML = update[1];
            
        }
		}
		else alert(xmlhttp.status);
    }
}

function getRandJoke() {
	
    xmlhttp.open('get', '../AJAXRandjoke.asp');
    xmlhttp.onreadystatechange = handleResponseRand;
    xmlhttp.send(null);	
}

function handleResponseRand() {
  if(xmlhttp.readyState == 4){
if (xmlhttp.status == 200){
       	
        var response = xmlhttp.responseText;
        var update = new Array();
        if(response.indexOf('|') != -1) {
            update = response.split('|');
            
            document.getElementById("JOKE_TITLE").innerHTML = update[0];
            document.getElementById("THEJOKE").innerHTML = update[1];
            document.getElementById("CATIMAGE").innerHTML = update[2];
            
        }
		}
		else alert(xmlhttp.status);
    }
}

