// ----- Deframer -----

if (self!=top)
{
  self.location.reload(true)
  top.location.replace(self.location.href)
}

// ----- Popup handling -----

function ClosePopUpWindow()
{
  if (typeof PopUpWindow!="undefined")
  {
    if (typeof PopUpWindow.close!="undefined")
      PopUpWindow.close()
    delete PopUpWindow
  }
}

function OpenPopUp(url,width,height)
{
  ClosePopUpWindow()
  PopUpWindow=window.open(url,"popup","width="+width+",height="+height+",scrollbars=yes,resizable=yes,dependent=yes,top=0,left=0")
}

function OpenPopUpFull(url,width,height)
{
  ClosePopUpWindow()
  PopUpWindow=window.open(url,"popup","width="+width+",height="+height+",scrollbars=yes,resizable=yes,dependent=yes,top=0,left=0,fullscreen=1")
}

// ----- Background sound handling -----

var backgroundSound=1
var cookieName="soundEnabled="

function StartBackgroundAudio(audioSuffix)
{
  offset=document.cookie.indexOf(cookieName)
  if (offset==-1)
    backgroundSound=1
  else
  {
    offset+=cookieName.length
    end=document.cookie.indexOf(";",offset)
    if (end==-1)
      end=document.cookie.length
    backgroundSound=parseInt(document.cookie.substring(offset,end))
    if ((typeof backgroundSound)!="number")
      backgroundSound=1
  }
  if (backgroundSound!=0)
  {
    audioFile=window.location.pathname
    separator=audioFile.lastIndexOf("/")
    if (separator==audioFile.length-1)
      audioFile="index"
    else
    {
      audioFile=audioFile.substring(separator+1,audioFile.length)
      separator=audioFile.lastIndexOf(".")
      if (separator!=-1)
        audioFile=audioFile.substring(0,separator)
    }
    audioFile+=audioSuffix
    document.write('<EMBED SRC="'+audioFile+'" VSPACE="0" HSPACE="0" AUTOSTART="TRUE" HIDDEN="TRUE" TYPE="audio/midi">')
    document.write('<BGSOUND SRC="'+audioFile+'">')
  }
}

function ToggleBackgroundAudio()
{
  backgroundSound=backgroundSound==0?1:0
  expireDate=(new Date((new Date()).getTime()+24*60*60*1000)).toGMTString()
  document.cookie=cookieName+backgroundSound+";expires="+expireDate+";path=/"
  location.reload()
}

// ----- Menu link and image handling -----

function MenuLink(associatedName,width,height,vspace,hspace,altText)
{
  slash=window.location.pathname.indexOf("/",1)
  if (slash==-1)
    groupName=""
  else
    groupName=window.location.pathname.substring(1,slash)
  if (associatedName=="")
    linkTarget="/"
  else
    linkTarget="/"+associatedName+"/"
  if (associatedName==groupName)
    imageName="/shared/images/menu/"+associatedName+"_a.gif"
  else
    imageName="/shared/images/menu/"+associatedName+"_n.gif"
  document.write('<A HREF="'+linkTarget+'"><IMG SRC="'+imageName+'" WIDTH="'+width+'" HEIGHT="'+height+'" VSPACE="'+vspace+'" HSPACE="'+hspace+'" ALT="'+altText+'" BORDER="0"></A>')
}

