//<script>
// <script type="text/javascript" src="checkFrame.js">
 
 
// Run this script only in mainframe documents:
if(top.mainframe==self || !top.mainframe){
 var oldonload = window.onload;
 var NewLoad = function(){checkFrame();}
 if (typeof(NewLoad) != 'function') NewLoad=function(){};

 if (typeof(oldonload) == 'function')
  window.onload = function(){oldonload(); NewLoad()};
 else window.onload = function(){NewLoad()};
}

/* Copyright (c) Gaute Sandvik 2007,2008 */
// This script is placed in page head and called onload.   
// If this page is inside correct frameset, it will updateMenu. 
// Otherwise it will enable breakout of frameset.               

//onload:
function checkFrame(){
 var BSL = String.fromCharCode(92);
 var FSL = String.fromCharCode(47);
 var hrefString = location.pathname;
 var hrefArray  = hrefString.split(BSL);
 var pathString = hrefArray.join(FSL); 
 var pathArray  = pathString.split(FSL);
 var fileName   = pathArray.pop();

 if(top.menuframe && (parent.mainframe || parent.previewframe)){
  // This page seems to be in the correct frameset!
  top.menuframe.updateMenu(fileName);
  var menu_hor = document.getElementById("menu_hor");
  if(menu_hor) menu_hor.style.display="none";
  
  var footer_message = document.getElementById("footer_message");
  if(footer_message) footer_message.style.display="none";
 }
 else{  
  // This page is not in correct frameset
  var message=document.getElementById("footer_message");
  message.style.display="block";
  //  href       = Protocol + "//" + Hostname + "/" + Pathname
  //  --------------------------------------------------------
  //  protocol   = http: 
  //  hostname   = www.website.net 
  //  pathname   = folder/file.html
  var Protocol   = self.location.protocol; 
  var Hostname   = self.location.hostname;
  var Pathname   = self.location.pathname;
  if (Hostname == "localhost"){
   var pathArray = Pathname.split(FSL);
   pathArray = pathArray.reverse();
   var Sub = pathArray.pop();
   if(Sub == "") Sub = pathArray.pop();
   Hostname  = Hostname + "/" + Sub;
   pathArray = pathArray.reverse();
   Pathname  = pathArray.join(FSL);
  }
  var hrefString = Protocol+"//"+Hostname+"/index.php?search_="+Pathname;
  message.href = hrefString;
  if(top.location != self.location){
   alert("This page is captured in alien frameset, break out!");
   message.click();
  }
 }
}// end reframe

// end checkFrame.js
