// (C) 1998-2006 nc3 GmbH Leipzig
// all rights reserved
/**
	The aim here is to make it possible to use different pictures in different
	players. While most of the pictures can have several colors they still must
	fit into the raster. Raster is specified further down the line. More or less
	this library can be considered as a theme engine using pics.

	To make this possible each theme will have to be placed within a seperaet
	folder.
	loads a set of images and replaces the selected images on request
	must known variables:
	name and id of the images

	functions called from bodies onload attribute to initailize:
	loadButtonSet(theme);

	[TODO]
	- !!! define if a seperate css will be loaded from the theme folder is that
	  necessary? IDEA: document.write(<link type... src="themefolder/theme/std.css">
	  should work, shouldn't it?
	- there must be a function loadPlayerButtons(basecolor), which loads a set of
    buttons specifieing the mouseover color and the onclick
  - handling of images should be done within a seperate js-lib for image
    related functions only
  [/TODO]
*/
	// themes are following these conventions:
	
	// setting global variables
	// this array contains all possible images - note all templates will have to
	// follow the name conventions
	var ctrlButtonnames = new Array(
                          "ctrlPlay", "ctrlPause",            // all with mousestate
                          "ctrlStop", "ctrlFullscreen",
                          //"ctrlSlider",
						  "ctrlvolume"   // all without mousestate
						  				  
                          );
	
  // set a global for the currently active button
  currentButtonImg = "";
  // set global for currently active volume
  currentVolumeImg = "";

	// first two empty arrays holding either the onmouseover and the
	// onmouseout(standard) images
	var playerStdButtons = new Array();
	var playerVolButtons = new Array();

// ****************************************************************************
// initiates the theme
function initTheme() {
	// make themename a path
	//themename = "http://213.133.99.241/images/themes/playercontrols/"+ themename + "/";
	//backgroundthemename= "http://213.133.99.241/images/themes/background/" + backgroundthemename + "/";
	loadPlayerButtons();
	setPlayerButtons();
	loadVolumePics();
}


function loadVolumePics() {

	images = new Array();
	images2 = new Array();
	for (i=0; i<=8 ; i++) {
		images[i]=new Image;
		images2[i]=new Image;
		images[i].src=themename+"volume"+i+".gif";
		images2[i].src=themename+"volume"+i+"_ov.gif";
	}
}



// ****************************************************************************
// loads all the images fro a controltheme into a multidim array
function loadPlayerButtons() {
    // load all the buttons from a theme into one multidim array
  var k=0;
  for (k; k<(ctrlButtonnames.length); k++) {
    var bez = ctrlButtonnames[k];
    playerStdButtons[bez] = new Array();
    playerStdButtons[bez]['sd'] = new Image();
    playerStdButtons[bez]['sd'].src = themename + ctrlButtonnames[k] + "_sd.gif";
    playerStdButtons[bez]['ov'] = new Image();
    playerStdButtons[bez]['ov'].src = themename + ctrlButtonnames[k] + "_ov.gif";
    playerStdButtons[bez]['on'] = new Image();
    playerStdButtons[bez]['on'].src = themename + ctrlButtonnames[k] + "_on.gif";
  }
}

// ****************************************************************************
// set the theme by replacing all images by the images from the theme array
function setPlayerButtons() {
	var k=0;
  for (k; k<(ctrlButtonnames.length); k++) {
    if(document.images[ctrlButtonnames[k]]) {
		document.images[ctrlButtonnames[k]].src = themename + ctrlButtonnames[k] + "_sd.gif";
    }
  }
}

// ****************************************************************************
// handling of onmouseover, onmouseout and onclick
function setButtonimage(pic, state) {
    // nur wenn nicht geclickt('on') wird und wenn das bild nicht das "aktuelle" ist
  if ((pic != currentButtonImg) && (state != "on"))
      // bei over and out einfach src des jeweiligen images aus dem array zuordnen
    document.images[pic].src = playerStdButtons[pic][state].src;
  else {
      // was gerade geclickt ist auf standard(sd) setzen
    if (currentButtonImg != "")	// aber nur wenn ueberhaupt eines aktiv ist
      document.images[currentButtonImg].src = playerStdButtons[currentButtonImg]['sd'].src;
      // neues bild als aktiv merken
    currentButtonImg = pic;
      // neues aktives bild auf geclickt setzen
	  document.images[currentButtonImg].src = playerStdButtons[pic]['on'].src;
  }
}



//Links-rechts SLides: Mouseovereffekte
function slideSelectIn(pic) {
	if (ie) {
		document.getElementById(pic).src=themename+"ctrl"+pic+"_on.gif";
	}
}

function slideSelectOut(pic) {
	if (ie) {
		document.getElementById(pic).src=themename+"ctrl"+pic+"_sd.gif";
	}
}
