$(function() {
	$('a.lightbox').lightBox(); // Select all links with lightbox class

});

window.onload = function()
{
	SetHover();
}

function lisa_flash(s,w,h)
{
	var a=arguments
	with(document)
	{
		writeln('<object codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" height="'+h+'" width="'+w+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">')
		writeln('<param name="Movie" value="'+s+'">')
		for(var i=3;i<a.length;i+=2)writeln('<param name="'+a[i]+'" value="'+a[i+1]+'">')
		write('<embed src="'+s+'" quality="high" height="'+h+'" width="'+w+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" ')
		for(i=3;i<a.length;i+=2)write(a[i]+'="'+a[i+1]+'" ')
		writeln('/>')
		write('</object>')
	}
}

function MediaPlay(id, volume)
{
	with(document)
	{
		writeln('<OBJECT ID="MediaPlayer" WIDTH="271" HEIGHT="200" CLASSID="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" STANDBY="Loading Windows Media Player components..." TYPE="video/x-ms-wmv" CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">')
		writeln('<PARAM NAME="SendPlayStateChangeEvents" VALUE="True" />')
		writeln('<PARAM name="filename" value="/lisalib/getfile.aspx?itemid='+id+'"/>')
		writeln('<PARAM name="showControls" value="1" />')
		writeln('<PARAM NAME="AutoStart" VALUE="0"/>')
		writeln('<PARAM name="ShowStatusBar" value="0" />')
		writeln('<PARAM name="stretchtofit" value="1" />')
		writeln('<PARAM name="uiMode" value="mini" />')
		writeln('<PARAM name="Mute" value="false" />')
		if(volume == null)
		{
			writeln('<PARAM name="Volume" value="37" />')
			writeln('<EMBED scale="aspect" stretchtofit="false" type="video/x-ms-wmv" src="lisalib/getfile.aspx?itemid='+id+'" width="271" height="200" uiMode="mini" AutoStart="0" showControls="1" Mute="false" Volume="37"></embed>');
		}
		else
		{
			writeln('<PARAM name="Volume" value="' + volume + '" />')
			writeln('<EMBED scale="aspect" stretchtofit="false" type="video/x-ms-wmv" src="lisalib/getfile.aspx?itemid='+id+'" width="271" height="200" uiMode="mini" AutoStart="0" showControls="1" Mute="false" Volume="' + volume + '"></embed>');
		}
		writeln('</OBJECT>')
	}

}

function schedule(dmy)
{
	if(logit){ alert('hi') }
	clearInterval(_timerID)
	var weekday=new Date(dmy.replace(/(..).(..).(....)/,'$3/$2/$1'))
	weekday=weekday.format('dddd')
	/*document.getElementById('thecss').href='/lisalib/objects/supportfiles/get.aspx?name='+weekday+'.css'*/
	var element=document.getElementById('weekly_program')
	element.innerHTML=''
	dmy='http://194.144.119.87/dagskra/vefur.php?midill=STOD2&time=19:45&count=4&dags='+dmy
	/*transformxml('/lisalib/objects/supportfiles/get.aspx?id=70bd1bc1-f55c-444f-accf-16ddac82feb0',dmy,element)*/
	wipe()
	_timerID=setInterval('wipe()', 5000)
	return false
}

function transformxml(xslurl,xmlurl,theid)
{
	if(logit){ alert('hi') }
	var thexsl = new XMLHttpRequest(1)
	var thexml = new XMLHttpRequest(1)
	if(logit){ alert('hi') }
	if(window.XSLTProcessor)
	{
		var tween = new XSLTProcessor()
		thexsl.open('GET', xslurl, false)
		thexsl.send(null)
		tween.importStylesheet(thexsl.responseXML)
		thexml.open('GET', xmlurl, false)
		thexml.send(null)
		//return tween.transformToFragment(thexml.responseXML, document)
		theid.appendChild(tween.transformToFragment(thexml.responseXML, document))
	}
	else if (window.ActiveXObject)
	{
		thexsl.async=false
		thexsl.load(xslurl)
		thexml.async=false
		thexml.load(xmlurl)
		//return thexml.transformNode(thexsl)
		theid.innerHTML = thexml.transformNode(thexsl)
	}
}

function SetHover()
{
	var subnavul = document.getElementById("subnavul");

	if(!subnavul)
		return;

	var children = subnavul;

	if(!children) return;

	for(var i = 0, n = children.childNodes.length; i<n; i++)
	{

		var child = children.childNodes[i];

		if(!child)
			continue;

		if(!child.tagName || child.tagName.toLowerCase() != "li")
			continue;

		child.onmouseover = (function(child) { return function()
		{
			child.className += " hover";
		} })(child);

		child.onmouseout = (function(child) { return function()
		{
			child.className = child.className.replace("hover", "");
		} })(child);
	}
}

/*
var browserCheck = navigator.userAgent.toLowerCase()
browserCheck={
    version: (browserCheck.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
    msie: /msie/.test( browserCheck ) && !/opera/.test( browserCheck )
}

if( browserCheck.msie && browserCheck.version < 7 )
	document.write('<sty'+'le type="text/css">#content{height:'+(document.documentElement.clientHeight-348)+'px}<'+'/style>');
else
	document.write('<sty'+'le type="text/css">#content{min-height:'+(document.documentElement.clientHeight-250)+'px}<'+'/style>');
*/


function WipeoutMediaPlay(id, volume, w, h, as)
{
	with(document)
	{
		writeln('<OBJECT ID="MediaPlayer" WIDTH="'+w+'" HEIGHT="'+h+'" CLASSID="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" STANDBY="Loading Windows Media Player components..." TYPE="video/x-ms-wmv" CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">')
		writeln('<PARAM NAME="SendPlayStateChangeEvents" VALUE="True" />')
		writeln('<PARAM name="filename" value="/lisalib/getfile.aspx?itemid='+id+'"/>')
		writeln('<PARAM name="showControls" value="1" />')
		writeln('<PARAM NAME="AutoStart" VALUE="'+as+'"/>')
		writeln('<PARAM name="ShowStatusBar" value="0" />')
		writeln('<PARAM name="stretchtofit" value="1" />')
		writeln('<PARAM name="uiMode" value="mini" />')
		writeln('<PARAM name="Mute" value="false" />')
		if(volume == null)
		{
			writeln('<PARAM name="Volume" value="37" />')
			writeln('<EMBED scale="aspect" stretchtofit="false" type="video/x-ms-wmv" src="lisalib/getfile.aspx?itemid='+id+'" width="'+w+'" height="'+h+'" uiMode="mini" AutoStart="'+as+'" showControls="1" Mute="false" Volume="37"></embed>');
		}
		else
		{
			writeln('<PARAM name="Volume" value="' + volume + '" />')
			writeln('<EMBED scale="aspect" stretchtofit="false" type="video/x-ms-wmv" src="lisalib/getfile.aspx?itemid='+id+'" width="'+w+'" height="'+h+'" uiMode="mini" AutoStart="'+as+'" showControls="1" Mute="false" Volume="' + volume + '"></embed>');
		}
		writeln('</OBJECT>')
	}

}

function SumarMediaPlay(id)
{
	with(document)
	{
		writeln('<OBJECT ID="MediaPlayer" WIDTH="640" HEIGHT="360" CLASSID="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" STANDBY="Loading Windows Media Player components..." TYPE="video/x-ms-wmv" CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">')
		writeln('<PARAM NAME="SendPlayStateChangeEvents" VALUE="True" />')
		writeln('<PARAM name="filename" value="/lisalib/getfile.aspx?itemid='+id+'"/>')
		writeln('<PARAM name="showControls" value="1" />')
		writeln('<PARAM NAME="AutoStart" VALUE="1"/>')
		writeln('<PARAM name="ShowStatusBar" value="0" />')
		writeln('<PARAM name="stretchtofit" value="1" />')
		writeln('<PARAM name="uiMode" value="mini" />')
		writeln('<PARAM name="Mute" value="false" />')
		writeln('<PARAM name="Volume" value="37" />')
		writeln('<EMBED scale="aspect" stretchtofit="1" type="application/x-ms-wmp" src="lisalib/getfile.aspx?itemid='+id+'" width="640" height="360" uiMode="mini" AutoStart="1" showControls="1" Mute="false" Volume="37"></embed>');
		writeln('</OBJECT>')
	}

}