window.onload = init;

var mad_hermit = new Image;
mad_hermit.src = '/images/mad_hermit.gif';

function init () {
    //  if (popup_init) {
    //    popup_init();
    //  }
    var nav_text = document.getElementById('navigation');
    //alert(window.document.mp3_stage.TGetProperty('/play_button', 13));
  
    if(document.getElementById('musicians')){ 
      mp3_stage();
    }

    resize_content();
    window.onresize = resize_content;
  
    init_help_divs();
}





function init_help_divs() {
  /*var a = '';
  for(var p in ) {
    a += p +' ';
  }
  alert(a);*/
  var a = new Array;
  if(document.getElementsByTagName('div')){
    var help_divs = new Array;
    var divs = document.getElementsByTagName('div');
    var c=0;
    for(var i=0;i<divs.length;++i) {
      if(divs[i].className == 'help-div'){
        //help_divs[c] = divs[i];
        //++c;
        a[i] = document.createElement('a');
        a[i].appendChild(document.createTextNode('\u00A0[?]'));
        a[i].setAttribute('href', 'javascript:show_hide_el("'+ divs[i].id +'")');
        divs[i].previousSibling.appendChild(a[i]);
        //alert (divs[i].previousSibling.tagName);
        divs[i].style.display = 'none';
      }
    }
  }
}



var content_table;
var navigation;
function resize_content() {
  if( (content_table=document.getElementById('content-table')) && (navigation=document.getElementById('navigation')) && (content_table.clientHeight<navigation.clientHeight)) {
    content_table.style.height = navigation.clientHeight +'px';
  }
}


function show_hide_el(id) {
  if(document.getElementById(id).style.display == 'block' ) {
    document.getElementById(id).style.display = 'none';
  } else {
    document.getElementById(id).style.display = 'block';
  }
}






// This is for the checkbox that disabled the select menu.
function enable_changepassword() {
  if (document.forms.userdetails.changepassword.checked) {
    document.forms.userdetails.passwd.disabled=false;
    document.getElementById('form_div_passwd').style.display = 'block';
    document.forms.userdetails.passwd2.disabled=false;
    document.getElementById('form_div_passwd2').style.display = 'block';
  } else {
    document.forms.userdetails.passwd.disabled=true;
    document.getElementById('form_div_passwd').style.display = 'none';
    document.forms.userdetails.passwd2.disabled=true;
    document.getElementById('form_div_passwd2').style.display = 'none';
  }
}




function play_mp3( song_name, base_dir, filename ) {
  file_full_path = '/'+base_dir+'/'+filename;
  document.mp3_stage.SetVariable('song_name', song_name );
  document.mp3_stage.SetVariable('path', file_full_path );
  document.mp3_stage.stream_mp3( filename , file_full_path);
}


function thisMovie(movieName) {
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  return (isIE) ? window[movieName] : document[movieName];
}

function makeCall(str) {
  thisMovie("extint").asFunc(str);
}

// This function "jsFunc" will be called from ActionScript
function jsFunc(str) {
  alert('test');
}


function rollover(imgname,imageObject) {
  document.images.imgname.src = imageObject.src;
}



function get_page_width(){
  if (window.innerWidth){
    return window.innerWidth - 20;
  } else {
    return document.body.clientWidth - 20;
  }  
}

function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  window.alert( 'Width = ' + myWidth + "\n" + 'Height = ' + myHeight );
}

function getClientWidth() {
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight() {
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}




// //////////////////////////////////////////////////
// //////////////////////////////////////////////////
// ////////////                             /////////
// ////////////  WHAT GOOD'S A DEATHROBOT   /////////
// ////////////  IF YOU CAN'T PUT HIM IN    /////////
// ////////////  HIGH-ALERT MODE, AGITATED  /////////
// ////////////  AND READY TO KILL?         /////////
// ////////////                             /////////
// //////////////////////////////////////////////////
// //////////////////////////////////////////////////
var x = 150;

function move_deathrobot() {
  a = parseInt(Math.random()*2);

  if (a%2==0) {
    b=5;
  } else {
    b=-5;
  }

  x = x+ b;

  if (x>250) {
    x=250;
  }
  if (x<120) {
    x=120;
  }
  document.images.deathrobot.style.left = x+"px";
  setTimeout("move_deathrobot()", 100);
}

//move_deathrobot();



function mp3_stage() { 
  // The following flash jukebox/stage is at the end of the code because by now,
  // we should have the $files_available array which will in time be passed to flash via html,
  // which seems the simplest and most reliable way.
  var flash_jukebox_url = "/images/mp3_stage.swf";
  //var flash_variables = db_get_flash_variables($artform_id);
  var flash_jukebox_url = flash_jukebox_url + '?path=/downloads/blue_jeans/demo_lo.mp3&amp;name=Blue%20Jeans%20Rock';

  var output = '\n <object\n   classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"\n   codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"\n   width="256"\n   height="152"\n   id="mp3_stage"\n   align="middle"\n >\n <param name="allowScriptAccess" value="sameDomain">\n <param name="movie" value="' + flash_jukebox_url + '">\n <param name="quality" value="high">\n <param name="bgcolor" value="#402010">\n <embed \n   src="' + flash_jukebox_url + '" \n   quality="high" \n   bgcolor="#402010" \n   width="256"\n   height="152" \n   swLiveConnect="true"\n   name="mp3_stage" \n   id="mp3_stage" \n   align="middle"\n   allowScriptAccess="sameDomain" \n   type="application/x-shockwave-flash" \n   pluginspage="http://www.macromedia.com/go/getflashplayer">\n </object>\n ';
  
  document.getElementById('musicians').innerHTML = output;
}
  
  
function show_mad_hermit() {
  var welcome = document.getElementById('welcome')
  welcome.style.backgroundImage = "url(/images/mad_hermit.gif)";
  welcome.style.backgroundTop = '0';
  welcome.style.backgroundLeft = '0'; 
  welcome.style.backgroundRepeat = 'no-repeat';	
}

function hide_mad_hermit() {
  document.getElementById('welcome').style.backgroundImage = "none";
}
