// KMS javascript functions

//menuRoll
function menuRoll(HTMLElementA)
{
	//Declare variables
	var sImgSuffix, aImg, srcURL, sExtention, sName, sPath;
	
	//Get the image inside the link using the firstChild method of the link element.
	//firstChild is a DOM level 1 function and is compatible with all relevant browsers.
	aImg = HTMLElementA.firstChild;

	//Retrieve current image source and split it up in relevant sections
	//Path
	//Name
	//Extention
	srcURL = new String(aImg.src);
	sPath = srcURL.substring(0,srcURL.lastIndexOf("/") + 1);
	sName = srcURL.substring(srcURL.lastIndexOf("/") + 1,srcURL.lastIndexOf("."));
	sExtention = srcURL.substring(srcURL.lastIndexOf("."),srcURL.length);

	//The assumption is made that the name of an active image ends with "_up"
	//Using the assumption it is checked wether a mouseover or mouseout action is performed;
	sImgSuffix = "_up";
	
	if (srcURL.indexOf(sImgSuffix) == -1){
		//Assign mouseover file, add the suffix
		aImg.src = sPath + sName + sImgSuffix + sExtention;
	}
	else{
		//Assugb mouseout file, remove the suffix
		aImg.src = sPath + sName.replace(sImgSuffix , "") + sExtention;
	}
}

//setColour
function setColour(HTMLElementA, img, mmId) 
{
	var doSetColour = false;
	
	if (HTMLElementA == null)
	{
		doSetColour  = true;
	}
	else
	{
		if (HTMLElementA.className == '')
		{
			doSetColour = true;
		}
	}
	
	if (doSetColour)
	{
		document.getElementById('colour').style.background = 'url(' + img + ') no-repeat';
		document.getElementById('colourTitle').innerHTML = HTMLElementA.innerHTML;
		
		if (mmId > 0) {
			logMultimedia(mmId);
		}
		
		if (HTMLElementA != null){
			var colourList;
			colourList = document.getElementById('colourList').getElementsByTagName("A");
			swapLinks(colourList, HTMLElementA);
		}
	}
}

//setMovie
function setMovie(HTMLElementA, mov, mmId)
{
	var doSetMovie = false;
	
	if (HTMLElementA == null)
	{
		doSetMovie  = true;
	}
	else{
		if (HTMLElementA.className == '')
		{
			doSetMovie = true;
		}
	}
	
	if (doSetMovie == true)
	{
		var movie='';
		movie += '<object ID="DSHOW" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="442" height="295">';
		movie += '<param NAME="URL" VALUE="' + mov + '">';
		movie += '<param NAME="autoStart" VALUE="-1">';
		movie += '<param NAME="currentMarker" VALUE="0">';
		movie += '<param NAME="DefaultFrame" VALUE="Content">';
		movie += '<param NAME="fullscreen" VALUE="0">';
		movie += '<param NAME="rate" VALUE="1">';
		movie += '<param NAME="balance" VALUE="0">';
		movie += '<param NAME="currentPosition" VALUE="0">';
		movie += '<param NAME="playCount" VALUE="1">';
		movie += '<param NAME="invokeURLs" VALUE="-1">';
		movie += '<param NAME="volume" VALUE="80">';
		movie += '<param NAME="mute" VALUE="0">';
		movie += '<param NAME="uiMode" VALUE="full">';
		movie += '<param NAME="stretchToFit" VALUE="0">';
		movie += '<param NAME="windowlessVideo" VALUE="0">';
		movie += '<param NAME="enableContextMenu" VALUE="-1">';
		movie += '<EMBED TYPE="application/x-mplayer2" NAME="MediaPlayer" width="442" HEIGHT="295" src="' + mov + '">';
		movie += '</object>';
		innerHTMLext(document.getElementById('movie'),movie);
		
		if (mmId > 0) {
			logMultimedia(mmId);
		}
		
		if (HTMLElementA != null)
		{
			var movieList;
			movieList = document.getElementById('movielist').getElementsByTagName("A");
			swapLinks(movieList, HTMLElementA);
		}
	}
}

//setAnimation
function setAnimation(flash){
	var animation='';
	animation += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="655" height="333">';
	animation += '<param name="allowScriptAccess" value="sameDomain" />';
	animation += '<param name="movie" value="Animations/' + flash + '" />';
	animation += '<param name="quality" value="high" />';
	animation += '<param name="wmode" value="transparent">';
	//animation += '<param name="bgcolor" value="#ffffff" />';
	animation += '<embed src="Animations/' + flash + '" quality="high" wmode="transparent" width="655" height="333" name="" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	//animation += '<embed src="Animations/' + flash + '" quality="high" bgcolor="#ffffff" width="655" height="333" name="" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	animation += '</object>';
	innerHTMLext(document.getElementById('flash'),animation);
}

//swapLinks
function swapLinks(HTMLElementACollection, HTMLElementA){	
	for(var i=0;i<HTMLElementACollection.length;i++){
		if(HTMLElementACollection[i] == HTMLElementA){
			HTMLElementACollection[i].className = 'link_inactive';
		}
		else{
			HTMLElementACollection[i].className = '';
		}
	}
}

// innerHTML external
function innerHTMLext(element,html) {
	element.innerHTML = html;
}

// logMultimedia
function logMultimedia(mmId){
	//alert(mmId);
	var logmm;
	logmm = new Image();
	logmm.src = '_lpvmm.asp?Id='+mmId+'&NC='+(new Date()).getTime();
}

