
function openImgViewer( strType, intID )
{
  var url      = "../image_viewer/index.php?id=" + intID + "&type=" + strType;
  var features = "status=no, scrollbars=no, width=600, height=400";
  window.open( url,'',features);
  return false;
}
function openMediaPlayer( strType, strSize, intID )
{
  intID = intID ? intID : 1;
  var url      = "../media_player/"+ strType +"_"+ strSize +".php?id="+ intID;
  var features = "resizable=yes, status=yes, scrollbars=no, ";
  switch (strType)
  {
    case 'dj':
      if (strSize == 'medium') features += "width=450, height=400";
      if (strSize == 'large') features += "width=600, height=500";
      break;
    case 'otay':
      if (strSize == 'large')  features += "width=600, height=360";
      break;
    case 'feature':
      if (strSize == 'large')  features += "width=600, height=500";
      break;
    default:
      if (strSize == 'small')  features += "width=500, height=360";
      if (strSize == 'medium') features += "width=600, height=360";
      if (strSize == 'large')  features += "width=755, height=360";
      break;
  }
  window.open( url, "", features );
  return false;
}

function openSoundPlayer( strType, strSize, intID )
{
  var url      = "../media_player/soundclips_all.php?id=" + intID;
  var features = "status=yes, scrollbars=no, width=600, height=220";
  window.open( url,'',features);
  return false;
}


function openCastAndCrew() 
{
  var features = 'scrollbars=yes,resizable=yes,toolbar=no,menubar=no,status=no,width=607,height=607';
  var url = "../castandcrew.html";
  window.open(url,"",features);  
}


function initBackground()
{
  var arrBacks = new Array();
  arrBacks.push("#EC3607 url( ../images/backtile_orangefade.jpg ) top left repeat-x");
  arrBacks.push("transparent url( ../images/backtile_wood.jpg ) top left");
  arrBacks.push("transparent url( ../images/backtile_greendots.gif ) top left");
  arrBacks.push("transparent url( ../images/backtile_bluedots.jpg ) top left");

  function rndnumber( intLimit )
  {
    var randnum = -1;
    while ( randnum < 0 || randnum > intLimit || isNaN( randnum ) )
    {
      randnum = parseInt( Math.random()  * ( intLimit+1 ) );
    }
    return randnum;
  }

  var mybody = document.getElementsByTagName("body").item(0);
  mybody.style.background = arrBacks[ rndnumber( arrBacks.length - 1 ) ];
}



// preload  main nav images...
function initMainNav( strActiveSection )
{
  var img1 = new Image();
  img1.src = '../images/left_nav_ibiza_over.jpg';
  var img2 = new Image();
  img2.src = '../images/left_nav_ibiza_off.jpg';
  var img3 = new Image();
  img3.src = '../images/left_nav_ibiza_down.jpg';

  var navIbiza = document.getElementById( 'mainNavIbiza' );
  navIbiza.onmouseover = function () { switchBackground( navIbiza, '../images/left_nav_ibiza_over.jpg' ) };
  navIbiza.onmousedown = function () { switchBackground( navIbiza, '../images/left_nav_ibiza_down.jpg' ) };
  if ( strActiveSection == 'ibiza' )
  {
    switchBackground( navIbiza, '../images/left_nav_ibiza_over.jpg' );
    navIbiza.onmouseout  = function () { switchBackground( navIbiza, '../images/left_nav_ibiza_over.jpg' ) };
    navIbiza.onmouseup   = function () { switchBackground( navIbiza, '../images/left_nav_ibiza_over.jpg' ) };
  }
  else
  {
    navIbiza.onmouseout  = function () { switchBackground( navIbiza, '../images/left_nav_ibiza_off.jpg' ) };
    navIbiza.onmouseup   = function () { switchBackground( navIbiza, '../images/left_nav_ibiza_off.jpg' ) };
  }


  var img4 = new Image();
  img4.src = '../images/left_nav_iagpt_over.jpg';
  var img5 = new Image();
  img5.src = '../images/left_nav_iagpt_off.jpg';
  var img6 = new Image();
  img6.src = '../images/left_nav_iagpt_down.jpg';

  var navIagpt = document.getElementById( 'mainNavIagpt' );
  navIagpt.onmouseover = function () { switchBackground( navIagpt, '../images/left_nav_iagpt_over.jpg' ) };
  navIagpt.onmousedown = function () { switchBackground( navIagpt, '../images/left_nav_iagpt_down.jpg' ) };

  if ( strActiveSection == 'iagpt' )
  {
    switchBackground( navIagpt, '../images/left_nav_iagpt_over.jpg' );
    navIagpt.onmouseout  = function () { switchBackground( navIagpt, '../images/left_nav_iagpt_over.jpg' ) };
    navIagpt.onmouseup   = function () { switchBackground( navIagpt, '../images/left_nav_iagpt_over.jpg' ) };
  }
  else
  {
    navIagpt.onmouseout  = function () { switchBackground( navIagpt, '../images/left_nav_iagpt_off.jpg' ) };
    navIagpt.onmouseup   = function () { switchBackground( navIagpt, '../images/left_nav_iagpt_off.jpg' ) };
  }


  var img7 = new Image();
  img7.src = '../images/left_nav_dj_over.jpg';
  var img8 = new Image();
  img8.src = '../images/left_nav_dj_off.jpg';
  var img9 = new Image();
  img9.src = '../images/left_nav_dj_down.jpg';

  var mainNavDj = document.getElementById( 'mainNavDj' );
  mainNavDj.onmouseover = function () { switchBackground( mainNavDj, '../images/left_nav_dj_over.jpg' ) };
  mainNavDj.onmousedown = function () { switchBackground( mainNavDj, '../images/left_nav_dj_down.jpg' ) };

  if ( strActiveSection == 'dj' )
  {
    switchBackground( mainNavDj, '../images/left_nav_dj_over.jpg' );
    mainNavDj.onmouseout  = function () { switchBackground( mainNavDj, '../images/left_nav_dj_over.jpg' ) };
    mainNavDj.onmouseup   = function () { switchBackground( mainNavDj, '../images/left_nav_dj_over.jpg' ) };
  }
  else
  {
    mainNavDj.onmouseout  = function () { switchBackground( mainNavDj, '../images/left_nav_dj_off.jpg' ) };
    mainNavDj.onmouseup   = function () { switchBackground( mainNavDj, '../images/left_nav_dj_off.jpg' ) };
  }

}


function switchBackground( obj, strFileName )
{
  obj.style.backgroundImage = "url(" + strFileName + ")";
}



// rollover lib globals

var ROLLOVER_IMAGE_PATH   = "../images/";
var ROLLOVER_IMAGE_EXT    = ".gif";
var ROLLOVER_HOVER_SUFFIX = "_hover";
var ROLLOVER_IMAGES       = new Object();

function initRollovers()
{
	
	if ( document.images )
	{ 
		var objImageElement;
		var rgxFileName = /\/(\w+)\.(\w+)$/
		
		for ( var intCount = 0; ( objImageElement = document.images[intCount] ); intCount++ )
		{
			if ( /\brollover\b/.exec(objImageElement.className) )
			{
				var strImageID = objImageElement.id;
				var strImageSource = objImageElement.src;
								
				ROLLOVER_IMAGES[strImageID] = new Object();
				ROLLOVER_IMAGES[strImageID]["off"] = new Image();
				ROLLOVER_IMAGES[strImageID]["off"].src = strImageSource;
				ROLLOVER_IMAGES[strImageID]["on"] = new Image();
				ROLLOVER_IMAGES[strImageID]["on"].src = strImageSource.replace( rgxFileName, "/$1" + ROLLOVER_HOVER_SUFFIX + ".$2" );

				eval("addEvent( objImageElement, 'mouseover', function () { return toggleRollovers('" + strImageID + "', 'on'); } )");
				eval("addEvent( objImageElement, 'mouseout', function () { return toggleRollovers('" + strImageID + "', 'off'); } )");
			}
			
		}
		
	}
}

function toggleRollovers( strImageID, strSwitchType )
{
	if ( strSwitchType == 'on' )
	{
		document.images[strImageID].src = ROLLOVER_IMAGES[strImageID]["on"].src;
	}
	if ( strSwitchType == 'off' )
	{
		document.images[strImageID].src = ROLLOVER_IMAGES[strImageID]["off"].src;
	}
}

  
    
// cross-browser addEventListener function
function addEvent( objElement, strEventType, objCallback )
{
	if (objElement.addEventListener)
	{ 
	    objElement.addEventListener(strEventType, objCallback, true); 
	    return true; 
	} 
	else if (objElement.attachEvent)
	{
	    strEventType = "on" + strEventType;
	    var blnSuccess = objElement.attachEvent(strEventType, objCallback); 
	    return blnSuccess; 
	} 
	else 
	{
	    strEventType = "on" + strEventType;
	    eval("var objOldCallback = objElement." + strEventType );
	    if ( typeof objOldCallback != 'function' ) {
	        eval("objElement." + strEventType + " = objCallback");
	    }
	    else {
	        eval("objElement." + strEventType + " = function() { objOldCallback(); objCallback(); }")
	    }
	    return true;
	} 
}

addEvent( window, 'load', initRollovers );
addEvent( window, 'load', initBackground );

