function addFormEvent(func) {
  if (!document.getElementById | !document.getElementsByTagName) return
  var oldonload=window.onload
  if (typeof window.onload != 'function') { window.onload=func }
  else {
    window.onload=function() { oldonload(); func() }
  }
}


function writeObject(filename){
  var str=''
  str+='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase=" http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="20" height="20">'
  str+='<param name="movie" value="/media/wimpy_button.swf?theFile=/media/'+filename+'" />'
  str+='<param name="quality" value="high" />'
  str+='<param name="bgcolor" value="#d7e1e3" />'
  str+='<!--[if !IE]> <-->'
  str+='<object data="/media/wimpy_button.swf?theFile=/media/'+filename+'" width="20" height="20" type="application/x-shockwave-flash">'
  str+='<param name="quality" value="high" />'
  str+='<param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer" />'
  str+='<param name="bgcolor" value="#d7e1e3" />'
  str+='</object>'
  str+='<!--> <![endif]-->'
  str+='</object>'
  return (str)
}


function openClose(what) {
  if (document.getElementById){
    if (document.getElementById(what).style.display=='block')
      document.getElementById(what).style.display='none'
    else
      document.getElementById(what).style.display='block'
  }
}


function replaceContent(id,content){
  document.getElementById(id).innerHTML = content
}


function closedropLists(){
  document.getElementById('creditlist').style.display = "none"
  document.getElementById('linklist').style.display   = "none"
  document.getElementById('as1').style.display        = "none"
  document.getElementById('ms1').style.display        = "none"
  document.getElementById('mf1').style.display        = "none"
  document.getElementById('np1').style.display        = "none"
}


function replace(string,text,by) {
  var strLength = string.length,txtLength = text.length
  if ((strLength==0) || (txtLength==0)) return string
  var i = string.indexOf(text)
  if ((!i) && (text!=string.substring(0,txtLength))) return string
  if (i == -1) return string
  var newstr = string.substring(0,i) + by
  if (i+txtLength<strLength) newstr += replace(string.substring(i+txtLength,strLength),text,by)
  return newstr
}


function rollover(linkid,imgid){
  var obj0 = document.getElementById(linkid)
  var srcL = document.getElementById(imgid).src
  var srcH = replace(srcL,'_link','_hover')
  obj0.onmouseover= function() {document.getElementById(imgid).src = srcH}
  obj0.onmouseout = function() {document.getElementById(imgid).src = srcL}
}


function replaceText(){
  closedropLists()
  replaceContent('mph'            , '<img src="/images/makepovertyhistory.gif" width="163" height="163" border="0" title="" alt="make poverty history" usemap="#mphRight" />'+ '<map name="mphRight"><area shape="poly" coords="0,0,163,163,163,133,30,0" href="http://www.makepovertyhistory.org/index.shtml" target="_blank"></map>')
  replaceContent('playtext'       , 'Press the play button to listen online now, or ')
  replaceContent('replaceEmail'   , ': '+'<a href="mailto:'+'mikefoskett'+'&#64;'+'hotmail'+'.com'+'?subject=Bangers%20and%20Mashed">'+"mikefoskett"+"&#64;"+"hotmail"+".com"+'</a>')
  replaceContent('replaceEmail2'  , '<a href="mailto:'+'mikefoskett'+'&#64;'+'hotmail'+'.com'+'?subject=Bangers%20and%20Mashed">'+"email me"+'</a>')
  replaceContent('andysimmonds1'  , writeObject("andy_simmonds_001.mp3"))
  replaceContent('mattsenuik1'    , writeObject("matt_senuik_001.mp3"))
  replaceContent('mikefoskett1'   , writeObject("mike_foskett_001.mp3"))
  replaceContent('nilaesh1'       , writeObject("nilaesh_deckquirks_001.mp3"))
  replaceContent('andysimmonds2'  , writeObject("Missy Elliot - Missy Bitch [andy simmonds].mp3"))
  replaceContent('mattsenuik2'    , writeObject("Nirvana - Polly [dj sen].mp3"))
  replaceContent('creditslist'    , '<a href="#creditlist" onclick="openClose(\'creditlist\'); return false" title="click to fold / unfold">Mix Ingredients:</a>')
  replaceContent('as0'            , '<a href="#as0" onclick="openClose(\'as1\'); return false" title="click to fold / unfold">andy simmonds:</a>')
  replaceContent('ms0'            , '<a href="#ms0" onclick="openClose(\'ms1\'); return false" title="click to fold / unfold">matt senuik:</a>')
  replaceContent('mf0'            , '<a href="#mf0" onclick="openClose(\'mf1\'); return false" title="click to fold / unfold">mike foskett:</a>')
  replaceContent('np0'            , '<a href="#np0" onclick="openClose(\'np1\'); return false" title="click to fold / unfold">nilaesh:</a>')
  replaceContent('linkslist'      , '<a href="#links" onclick="openClose(\'linklist\'); return false" title="click to fold / unfold">Tasty places to dine:</a>')
  rollover('posterlink','poster')
  rollover('flyerlink','flyer')
}



addFormEvent(replaceText)

