// This script sets music player options based on browser version and session only cookie
// set by music.htm popup

// If browser version 6.x or higher
if(document.getElementById) {
 document.write('<a href="javascript:;" onclick="openMusic();" class="selectmusic">Select Music</a><br />');
 document.write('<div id="title"></div>');
 document.write('<div id="selection"></div>');

var mysong

// Set dynamic content based on cookie value
 // If cookie set by music.htm
 if (get_cookie("tocsong")!=""){
 mysong=get_cookie("tocsong")

 switch (mysong) {
  case "None": document.getElementById('title').innerHTML='None';
  document.getElementById('selection').innerHTML='<br />';
  break;
  case "Volcano": document.getElementById('title').innerHTML='Volcano';
  document.getElementById('selection').innerHTML='<embed src="sounds/volcano2.mov" autostart="true" controller="true" loop="true" name="Volcano" height="14" width="100" pluginspage="http://www.apple.com/quicktime/download/"></embed>';
  break;
  case "Margaritaville": document.getElementById('title').innerHTML='Margaritaville';
  document.getElementById('selection').innerHTML='<embed src="sounds/margaritaville.mov" autostart="true" controller="true" loop="true" name="Volcano" height="14" width="100" pluginspage="http://www.apple.com/quicktime/download/"></embed>';
  break;
  case "Feel Hi": document.getElementById('title').innerHTML='Feel Hi';
  document.getElementById('selection').innerHTML='<embed src="sounds/feelhi.mov" autostart="true" controller="true" loop="true" name="Volcano" height="14" width="100" pluginspage="http://www.apple.com/quicktime/download/"></embed>';
  break;
  case "Hot Hot": document.getElementById('title').innerHTML='Hot Hot';
  document.getElementById('selection').innerHTML='<embed src="sounds/hot_hot2.mov" autostart="true" controller="true" loop="true" name="Volcano" height="14" width="100" pluginspage="http://www.apple.com/quicktime/download/"></embed>';
  break;
  default : document.getElementById('title').innerHTML='Volcano';
  document.getElementById('selection').innerHTML='<embed src="sounds/volcano2.mov" autostart="false" controller="true" loop="true" name="Volcano" height="14" width="100" pluginspage="http://www.apple.com/quicktime/download/"></embed>';
  }

 // No cookie set
 } else {
 document.getElementById('title').innerHTML='Volcano';
 document.getElementById('selection').innerHTML='<embed src="sounds/volcano2.mov" autostart="false" controller="true" loop="true" name="Volcano" height="14" width="100" pluginspage="http://www.apple.com/quicktime/download/"></embed>';
 }
// Not browser version 6.x or higher
} else {
// If browser version 4.x or higher
 if(document.images) {
  // Set initial variable values
  var mysong; play1="controller"; play2="hidden"; play3="hidden"; play4="hidden"; on1="false"; on2="false"; on3="false"; on4="false"

  // If cookie set by music.htm
  if (get_cookie("tocsong")!="") {
   mysong=get_cookie("tocsong")
   switch (mysong) {
    case "None": play1="hidden"; play2="hidden"; play3="hidden"; play4="hidden";
    on1="false"; on2="false"; on3="false"; on4="false";
    break;
    case "Volcano": play1="controller"; play2="hidden"; play3="hidden"; play4="hidden";
    on1="true"; on2="false"; on3="false"; on4="false";
    break;
    case "Margaritaville": play1="hidden"; play2="controller"; play3="hidden"; play4="hidden";
    on1="false"; on2="true"; on3="false"; on4="false";
    break;
    case "Feel Hi": play1="hidden"; play2="hidden"; play3="controller"; play4="hidden";
    on1="false"; on2="false"; on3="true"; on4="false";
    break;
    case "Hot Hot": play1="hidden"; play2="hidden"; play3="hidden"; play4="controller";
    on1="false"; on2="false"; on3="false"; on4="true";
    break;
    default : play1="controller"; play2="hidden"; play3="hidden"; play4="hidden";
    on1="false"; on2="false"; on3="false"; on4="false";
    }
  // No cookie set
  } else {
   mysong="Volcano"
  }

  // Embeds all available music files, sets controller and autoplay settings based on
  // cookie for song selection
  document.writeln('<a href="javascript:openMusic()" class="selectmusic">Select Music</a><br />');
  document.writeln('<font color="green"><b>'+mysong+'</b></font><br />');
  document.writeln('<embed src="sounds/volcano2.mov" autostart="' + on1 + '" ');
  document.writeln(play1 + '="true" loop="true" name="Volcano" height="14" width="100" ');
  document.writeln('pluginspage="http://www.apple.com/quicktime/download/"></embed>');
  document.writeln('<embed src="sounds/margaritaville.mov" autostart="' + on2 + '" ');
  document.writeln(play2 + '="true" loop="true" name="Margaritaville" height="14" width="100" ');
  document.writeln('pluginspage="http://www.apple.com/quicktime/download/"></embed>');
  document.writeln('<embed src="sounds/feelhi.mov" autostart="' + on3 + '" ');
  document.writeln(play3 + '="true" loop="true" name="Feel Hi" height="14" width="100" ');
  document.writeln('pluginspage="http://www.apple.com/quicktime/download/"></embed>');
  document.writeln('<embed src="sounds/hot_hot2.mov" autostart="' + on4 + '" ');
  document.writeln(play4 + '="true" loop="true" name="Hot Hot" height="14" width="100" ');
  document.writeln('pluginspage="http://www.apple.com/quicktime/download/"></embed><br />');
 
 // Not browser version 4.x or higher 
 } else {
 // Browser version 3.x or lower, no support
  document.write('<font color="red" face="arial"><b>Music<br />');
  document.write('NO SUPPORT</b></font><br />');
 }
}

