// Detect if the current page is in a frameset
// If it is not, load 'framesetpage' and tag the current page to its url
//
// file:///D:/1/frameset.html?file&&&/D:/1/currentpage.html
//
// The framesetpage must know what to do with it.
// (source: http://www.echoecho.com/jsframes.htm)
//
function checkframeset(framesetpage)
{
thispage=window.location.href;
if (thispage.indexOf('://')<0) {thispage="://"+thispage;};
prefix=thispage.substring(0,thispage.lastIndexOf('://'));
suffix=thispage.substring(thispage.lastIndexOf('://')+3,thispage.length);
// alert('the subpage is:['+prefix+']['+suffix+']');
if (parent.location.href==window.location.href) {parent.location.href=framesetpage+"?"+prefix+"&&&"+suffix};
}

// Detect if the current page is in a frameset
// If it is not, load 'framesetpage'
//
// (source: http://www.echoecho.com/jsframes.htm)
//
function testframeset(framesetpage)
{
if (parent.location.href==window.location.href)
  {parent.location.href=framesetpage};
}

var subpage;

// Get a valid url for 'page' from:
// file:///D:/1/frameset.html?file&&&/D:/1/page.html
// If no url is available, use 'defaulturl'
//
function decodeurl(defaulturl)
{
  if (location.search)
    {subpage=location.search.substring(1)}
  else
    {subpage=defaulturl}

  if (subpage.indexOf('&&&')>=0)
  {
    prefix=subpage.substring(0,subpage.indexOf('&&&'))+"://";
    suffix=subpage.substring(subpage.indexOf('&&&')+3,subpage.length);
    subpage=prefix+suffix;
  }
}

