
//laddar om dokumentet med frameset om det saknar frameset.
function makeURLIfDocumentOnTop(location_,document_)
{
  if( location_.href.indexOf("showsingle=1") == -1 )
  {
  if (document_ == top)
  {
    var strLocation = location_.href;
    var strRemove = "http\:\/\/" +location_.hostname;
    var regexRemove = new RegExp(strRemove);
     
    //ta bort "http://" och urlen från söksträngen
    strLocation =  strLocation.replace(strRemove,"");  
  
    //leta efter första slashen
    intSlashPosition = strLocation.indexOf("/",[0]);
  
    //plocka ut dokumentnamnet ur strängen
    strLocation = strLocation.substring(intSlashPosition+1, strLocation.length)
      
    top.location.href = "http://" +location_.hostname +"/" +"?p=" +tst(strLocation);
  }
  }
}

    function charFromCharCode(charCode) 
    {
      return unescape('%' + charCode.toString(16));
    }
  
    
    function tst(str_)
    {
      var strInString = new String(str_);
      var arrChars = new Array();
      var arrCharCodes = new Array();
      var strOutString = new String();
      
      for(i=0;i<strInString.length;i++)
      {
      arrChars[i] = strInString.charAt( strInString.length - (strInString.length-i) ); 
      }
    
      for(i=0;i<arrChars.length;i++)
      {
      arrCharCodes[i] = ( (arrChars[i].charCodeAt())+1 );      
      }
    
      for(i=0;i<arrCharCodes.length;i++)
        strOutString += charFromCharCode(arrCharCodes[i]);

      return escape(strOutString);  
    
    }
    
makeURLIfDocumentOnTop(window.location, this);