function detect(elem) {
  thispage=window.location.href;
  if (thispage.indexOf('-'+elem+'.php')>=0) {                       
    if (parent.location.href==window.location.href) {
        mainframe=thispage.substring(0,thispage.lastIndexOf('-'+elem)); 
        parent.location.href=mainframe+".php"
    };
  }
}

