function HttpRequest(){
this.request = false;
this.responseText = false;
this.doGet = doGet;
this.doPost = doPost;
if (window.XMLHttpRequest) {
  try {
  this.request = new XMLHttpRequest();
  } catch (e) {
  this.request = false;
  }
} else if (window.ActiveXObject) {
  // For Internet Explorer on Windows
  try {
    this.request = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      this.request = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e) {
      this.request = false;
    }
  }
}
function doGet(url){
  if (this.request) {
  // Synchronous request, wait till we have it all  
  this.request.open('GET', url, false);
  this.request.setRequestHeader("If-Modified-Since","0");
  this.request.send();
  this.responseText = this.request.responseText;
  }
}   
function doPost(url, f){
  if(this.request) {
    this.request.open('POST', url, false);
    this.request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    this.request.send(formToContent(f));
    this.responseText = this.request.responseText;
  }
}
function formToContent(f){
  var sb = "";
  var o, tagName, type, n, v;
  for(var i=0;i<f.length;i++){
    o = f[i];
    tagName = o.tagName.toUpperCase();
    type = o.type.toLowerCase();
    ///alert(tagName + "," + type);
    n = o.name;
    switch(tagName){
      case "INPUT":
        switch(type){
          case "radio":
            if(o.length){
              for(var j=0;j<o.length;j++){
                if(o[j].checked){
                  sb += "&" + o.name + "=" + decodeURIComponent(o[j].value);
                }
              }
            }
            else{
              if(o.checked){
                sb += "&" + o.name + "=" + decodeURIComponent(o.value);
              }
            }
            break;
          case "checkbox":
            if(o.length){              
              for(var j=0;j<o.length;j++){
                if(o[j].checked){
                  sb += "&" + o.name + "=" + decodeURIComponent(o[j].value);
                }
              }
            }
            else{
              if(o.checked){
                sb += "&" + o.name + "=" + decodeURIComponent(o.value);
              }
            }
            break;
		  case "file":  //to prevent file to be parsed as string
			  break;
          default:
			  sb += "&" + o.name + "=" + decodeURIComponent(o.value);
        }
        break;
      case "SELECT":
        sb += "&" + o.name + "=" + decodeURIComponent(o.options[o.selectedIndex].value);
        break;
      case "TEXTAREA":
        sb += "&" + o.name + "=" + decodeURIComponent(o.value);
        break;
      default:
        //do nothing
    }
  }
  //alert(sb.substring(1));
  return sb;
}
}

function onList(catid,pcat,i){
	//var req = new HttpRequest();	
	window.location.href="list.php?cat=" + catid+"&pcat="+pcat+"&i="+i;
	//var rs = req.responseText;
	//document.getElementById("rightList").innerHTML=rs;
}

function doRequest(_url,idName){
	
	//var req = new HttpRequest();
	//req.doGet(_url);
	//var rs = req.responseText;
	//if(typeof _id=='undefined')_id="rightList";
	//document.getElementById("leftCate").innerHTML=rs;
}

function onListByURL(_url){	
	/*
	var req = new HttpRequest();
	req.doGet(_url);
	var rs = req.responseText;	
	document.getElementById("rightList").innerHTML=rs;
	*/
	window.location.href=_url.replace("subcategories.php","list.php");
}