if (window.top.frames.length!=0) {
if (window.location.href.replace)
  window.top.location.replace(self.location.href);
 else
  window.top.location.href=self.document.href;
}

var xmlObj=null;

function jackwhich() {
  if (location.hash.length > 4) {
    jack(location.hash.substring(1));
  } else {
    jack('news');
  }
}

function jack(url) {
  if(window.XMLHttpRequest)
  {
    xmlObj = new XMLHttpRequest();
  }
  else if(window.ActiveXObject)
  {
    xmlObj = new ActiveXObject('MSXML2.XMLHTTP');
  } else {
    alert('No Object To This Browser');
    return;
  }
  location.hash = url;
  xmlObj.onreadystatechange = jacked;
  xmlObj.open('GET','http://gp2x.fullsack.com/cocoon/gp2x/docs/' + url + '.xml', true);
  xmlObj.send(null);
}

function jacking(obj)
{   
 /* 
  0 UNINITIALIZED obj created but uninitialized
  1 LOADING       obj created but not yet sent
  2 LOADED        sent no answer yet
  3 INTERACTIVE   retrieval in progress
  4 COMPLETED     all data received
  */
 if(obj.readyState == 0) { document.getElementById('stats').innerHTML = 'Unintialized'; }
 if(obj.readyState == 1) { document.getElementById('stats').innerHTML = 'Loading...'; }
 if(obj.readyState == 2) { document.getElementById('stats').innerHTML = 'Loaded'; }
 if(obj.readyState == 3) { document.getElementById('stats').innerHTML ='In Progress'; }
 if(obj.readyState == 4) { 
   if(obj.status == 200) {
     document.getElementById('stats').innerHTML = 'Powered by Ajax';
     return true; 
   } else if(obj.status == 404) {
     document.getElementById('stats').innerHTML = 'File not found';
   } else {
     document.getElementById('stats').innerHTML = 'Oops fetching XML';
   }
  }
}

function jacked()
{
  if(jacking(xmlObj))
  {
    var str = xmlObj.responseText;
    var b = str.search(/<tab>/m);
    var e = str.search(/<\/tab>/m);
    if(b>0&&e>0) {
      document.getElementById('tab').innerHTML = str.substring(b+5,e);
    }
    b = str.search(/<content>/m);
    e = str.search(/<\/content>/m);
    if(b>0&&e>0) {
      document.getElementById('folder').innerHTML = str.substring(b+9,e);
//      alert(str.substring(b+9,e));
    }
  }
}


// kick it off 
jackwhich();


