//http://rajshekhar.net/blog/archives/85-Rasmus-30-second-AJAX-Tutorial.html

function createRequestObject() {
  var xmlhttp;

  if(window.XMLHttpRequest){
    xmlhttp = new XMLHttpRequest();
  }
  else if (window.ActiveXObject){
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    if (!xmlhttp){
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
    }

}
  return xmlhttp;
}

/*function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer")
	{
    	ro = new ActiveXObject("Microsoft.XMLHTTP");
		if (!ro)
		{
        	ro = new ActiveXObject("Msxml2.XMLHTTP");
    	}
	}
    else
	{
        ro = new XMLHttpRequest();
    }
    return ro;
}*/

var http = createRequestObject();
//var site = 'http://localhost/aggielandcarpetone/';
var site = 'http://www.aggielandcarpetone.com/newsite/';

function sndReq(action, cat) {
    http.open('get', site+'admin/cat.php?action='+action);
    http.onreadystatechange = handleResponse;
    http.send(null);
}
function sndReqPost(action, poval) {
    http.open('get', site+'admin/cat.php?action='+action+'&poval='+poval);
    http.onreadystatechange = handleResponse;
    http.send(null);
}
function postCat(action, cat) {
	alert(action);
    sendReq('action','');
}
function sndReqEdit(action, id) {
    http.open('get', 'cat.php?action='+action+'&id='+id);
    http.onreadystatechange = handleResponse;
    http.send(null);
}
function sndReqSpecs(action, id) {
    http.open('get', 'spec.php?action='+action+'&id='+id);
    http.onreadystatechange = handleResponse;
    http.send(null);
}
function SendTab(action, id) {
	http.open('get', 'prod.php?action='+action+'&id='+id);
    http.onreadystatechange = handleResponse;
    http.send(null);
}


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

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

        if (http.readyState == 4) {

              if(http.status==200) {
                  var update=http.responseText;

              document.getElementById('foo').innerHTML = update;
              }
			  
              }
        }