// Create a form in the page
document.writeln("<FORM name='myForm'><INPUT TYPE='HIDDEN' NAME='navFrame'>");
document.writeln("<INPUT TYPE='HIDDEN' NAME='mainFrame'></FORM>");

// To be run on "<body onLoad=...>"
function checkFrames()
{
// If there is no whichFrame (the expected name of the current frame)
// defined by the calling page, assume the default is wanted
  if (!document.whichFrame)
  {
    document.whichFrame = "inlineskatemain" ;
  }

// Set the URL of the main frame to be loaded to the specified value
// (if set) or the default of the current page
  if (document.mainFrameText) 
  {
    document.myForm.mainFrame.value=document.mainFrameText ;
  }
  else
  {
    document.myForm.mainFrame.value=this.location.href ;
  }

// Set the URL of the navigation frame (not used yet)
  document.myForm.navFrame.value="" ;

// Set some parameters for the form.  These could be added to the form
// directly, but I think it looks neater here.
  document.myForm.method="POST" ;
  document.myForm.target="_top" ;

// Now to the crunch...  If this frame does not have the expevted name, or
  if (this.name != document.whichFrame)
  {
    escapeFrames();
  }

// if it's parent frame has a name at all (so isn't the top frame) escape.
//  if (parent.name != "")
//  {
//    document.myForm.target="_blank" ;
//    alert ("parent.name="+parent.name);
//    alert ("frames.length="+frames.length);
//    escapeFrames();
//  }
}

// This is the bit which actually redirects you
function escapeFrames()
{

// Decide what base frameset page you want to load.  Depends on what the
// current page is because there are a number of ways in, and each has
// different paths.
  if (this.location.host == "inlineskate.co.uk" || this.location.host == "inlineskate") 
  { 
    document.myForm.action="http://"+this.location.host+"/frame_me/index.pl" ;
  }
  else if (this.location.host == "www.skater.uklinux.net" || this.location.host == "vert")
  {
    document.myForm.action="http://"+this.location.host+"/skating/frame_me/index.pl" ;
  }
  else
  {
    document.myForm.action="http://inlineskate.co.uk/frame_me/index.pl" ;
  }

// Now load the frameset by submitting the form.
  document.myForm.submit();
}
