//if there is no parent, route to the main site
if(self == top) {
  if(gup("debug")!=1) {
    //go to /route/id
    var s_ar=window.location.href.split("/");
    for(i=0; i<s_ar.length; i++) {
      if(!isNaN(s_ar[i]) && s_ar[i] > 0) {
        window.location = "/route/"+s_ar[i];
        break;
      }
    }
  }
}

// get url parameter
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}