<!--

 /*
    frames.js - version date 18-04-2003
    
    Checks, if document is presented in its frameset.
    If not, loads frameset with current document.
    Usage: LINK to all HTML pages in the frame
    and call it in the HEAD section like this:
    checkFrames(myFrameName,FramesetURL);
 */
 
 // Misc string functions we need
 
 function replace(text,from,to)  // replace strings in strings
 {
    while (( ti=text.indexOf(from) ) >= 0)
    {
        text = text.substr(0,ti)+to+text.substr(ti+1);
    }    
    return text;
 } 
     
 function x_escape(text)  // extended escape function
 {
    var x_chars = "*2A+2B-2D.2E/2F_5F";
    
    text = escape(text);
    for (ci=0; ci < x_chars.length; ci+=3)
    {
        text = replace(text,x_chars.substr(ci,1),
                       "%"+x_chars.substr(ci+1,2));
    }
    return text;
 }   
 
 function store_url(url)
 {
    var storevar = "STORED_URL="+url+" ORIG_NAME="+top.window.name;
    top.window.name = replace(x_escape(storevar),"%","_");
 }
 
 function retrieve_url()
 {
    var url = "";
    var storevar = unescape(replace(top.window.name,"_","%"));
    if (storevar.indexOf("STORED_URL=")==0 && 
        (ni=storevar.indexOf("ORIG_NAME=")) > 0) 
    {
        url = storevar.substr(11,ni-11);
        top.window.name = storevar.substr(ni+10);
    }    
    return url;
 }       

 // Check frame name and load frameset when necessary
 
 function checkFrames(frameset_url,frame_name)
 { 
   if (parent.frames[frame_name] && 
       parent.frames[frame_name].document == document) 
   {
     if(( stored_url=retrieve_url() ) > "") {
        document.location.replace(stored_url);
     }
   }
   else 
   {
     store_url(document.location.href);
     top.location.replace(frameset_url);
   }
 }
 
 /* 
    Written by Metin Savignano, originally published 
    in the JavaScript Library at www.savignano.net,
    based on an idea by Hatto von Hatzfeld
 */   
 
 // -->
