/* SET VIDEO */

var vol = 0;
var play = true;

function movVolume(mov){
	mov.SetVolume(vol);
	
	document.getElementById('soundTxt').innerHTML = vol==0 ? "<img src='img/control/soundOn.png' alt='sound on' />" : "<img src='img/control/soundOff.png' alt='sound off' />";
	
	vol = vol==0 ? 250 : 0;
}

function wmvVolume(mov){
	mov.mute = vol;
	
	document.getElementById('soundTxt').innerHTML = vol==0 ? "<img src='img/control/soundOn.png' alt='sound on' />" : "<img src='img/control/soundOff.png' alt='sound off' />";
	
	vol = vol==0 ? 1 : 0;
}

function movPlay(mov){	
	if(play){
		mov.Stop();
		//document.getElementById('playTxt').innerHTML = "<img src='img/control/play.png' alt='play' />";
	}else{
		mov.Play();
		//document.getElementById('playTxt').innerHTML = "<img src='img/control/pause.png' alt='pause' />";
	}
	
	play = !play;
}

function wmvPlay(mov){	
	if(play){
		mov.Pause();
		//document.getElementById('playTxt').innerHTML = "<img src='img/control/play.png' alt='play' />";
	}else{
		mov.Play();
		//document.getElementById('playTxt').innerHTML = "<img src='img/control/pause.png' alt='pause' />";
	}
	
	play = !play;
}

// insert movie

function insertMOV(movURL, width, height)
{
	document.write('<embed src="'+movURL+'" width="'+width+'" height="'+height+'" name="myndband" cache="true" controller="false" enablejavascript=true" loop="false" volume="100"></embed>');
	
	document.write('<div class="control">');
	document.write('	<a href="javascript:movPlay(myndband);" class="play"><span id="playTxt"><img src="img/control/pause.png" alt="pause" /></span></a> ');
	document.write('	<a href="javascript:myndband.Rewind(); myndband.Play();" class="rewind"><span><img src="img/control/play.png" alt="play" /></span></a> ');
	document.write('	<a href="javascript:movVolume(myndband);" class="stop"><span id="soundTxt"><img src="img/control/soundOff.png" alt="sound off" /></span></a> ');
	document.write('	<div class="clear"></div>');
	document.write('</div>');
}

function insertWMV(wmvURL, width, height)
{
	document.write('<object id="myndband" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="'+width+'" height="'+height+'">');
	document.write('	<param name="url" value="'+wmvURL+'">');
	document.write('	<param name="autoStart" value="true">');
	document.write('	<param name="uimode" value="none">');
	document.write('	<param name="showControls" value="none">');
	document.write('	<param name="enableContextMenu" value="false">');
	document.write('	<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" width="'+width+'" height="'+height+'" src="'+wmvURL+'" stretchToFit="false" showcontrols="false" autoSize="false">');
	document.write('</object>');
	
	document.write('<div class="control">');
	document.write('	<a href="javascript:wmvPlay(myndband.controls);" class="play"><span id="playTxt"><img src="img/control/pause.png" alt="pause" /></span></a> ');
	document.write('	<a href="javascript:myndband.controls.Stop();myndband.controls.Play(); myndband.controls.Play()" class="stop"><span><img src="img/control/play.png" alt="play" /></span></a> ');
	document.write('	<a href="javascript:wmvVolume(myndband.settings);" class="rewind"><span id="soundTxt"><img src="img/control/soundOff.png" alt="sound off" /></span></a> ');
	document.write('	<div class="clear"></div>');
	document.write('</div>');
}

function setKynningu()
{
	var os = String(navigator.userAgent);
	mac = os.split("Mac").length>1 ? true : false;
	win = os.split("Win").length>1 ? true : false;
	
	if(mac)
		insertMOV("video/kynning.mov", 500, 280);
	else
		insertWMV("video/kynning.wmv", 500, 280);
}

function setIntro()
{
	var os = String(navigator.userAgent);
	mac = os.split("Mac").length>1 ? true : false;
	win = os.split("Win").length>1 ? true : false;
	
	if(mac)
		insertMOV("video/introvid.mov", 500, 306);
	else
		insertWMV("video/introvid.wmv", 500, 299);
}

function setDance()
{
	var os = String(navigator.userAgent);
	mac = os.split("Mac").length>1 ? true : false;
	win = os.split("Win").length>1 ? true : false;
	
	if(mac)
		insertMOV("video/dance.mov", 500, 306);
	else
		insertWMV("video/dance.wmv", 500, 299);
}

function openbox(id){
	if(id == "B1"){
		MOOdalBox.open("pdflisti/b1.html","","600 480");
	}else if(id == "H1"){
		MOOdalBox.open("pdflisti/h1.html","","600 855");
	}else if(id == "H2"){
		MOOdalBox.open("pdflisti/h2.html","","600 695");
	}else if(id == "H3"){
		MOOdalBox.open("pdflisti/h3.html","","600 100");
	}else if(id == "S1"){
		MOOdalBox.open("pdflisti/s1.html","","600 100");
	}else if(id == "S2"){
		MOOdalBox.open("pdflisti/s2.html","","600 100");
	}else if(id == "OPIN"){
		MOOdalBox.open("pdflisti/torg.html","","600 480");
	}else if(id == "GLER"){
		MOOdalBox.open("pdflisti/gler.html","","600 695");
	}
}
