window.onload = init;

function init()
{
	SetHover();
	// LightBox
	$('.lightbox a:has(img)').lightBox(
		{
			imageLoading:	'/lisalib/getfile.aspx?itemid=6150',
			imageBtnClose:	'/lisalib/getfile.aspx?itemid=6149',
			imageBtnPrev:	'/lisalib/getfile.aspx?itemid=6148',
			imageBtnNext:	'/lisalib/getfile.aspx?itemid=6147',
			imageBlank:	'/lisalib/getfile.aspx?itemid=6146',
			txtImage : 	'Mynd',
			txtOf : 		'af'
		}
	);
}

$(function()
{
        $('.box').click(function() 
        {
		location = $('a:first',this).attr('href');
        });
});

function SetHover()
{
	var nav = document.getElementById("nav");

	if(!nav)
		return;

	var children;

	for(var i = 0, n = nav.childNodes.length; i<n; i++)
	{
		if(nav.childNodes[i].tagName && nav.childNodes[i].tagName.toLowerCase() == "ul")
		{
			children = nav.childNodes[i];
			break;
		}
	}

	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);
	}
}

function lisa_flash(source, width, height, params)
{
	document.writeln('<object codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" height="' + height + '" width="' + width + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">');
	document.writeln('<param name="Movie" value="' + source + '">');

	for(var param in params)
		document.writeln('<param name="' + param + '" value="' + params[param] + '">')

	document.write('<embed src="' + source + '" quality="high" height="' + height + '" width="' + width + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" ')

	for(var param in params)
		document.write(param + '="' + params[param] + '" ')

	document.write('/>');
	document.writeln('</object>');
}

function play_video_old(id)
{
	var width = 480;
	var height = 360;

	var player = document.createElement("div");
	player.id = "video-player";
	var close = document.createElement("a");
	var that = this;
	close.onclick = function()
	{
		stop_video();
		return false;
	}
	close.href = "#";
	close.appendChild(document.createTextNode("Close"));

	var flash = document.createElement("div");

	flash.innerHTML = ''+
		'<object id="IVP" codeBase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" height="' + height + '" width="' + width + '" align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">' +
		'	<param name="_cx" VALUE="13229" />' +
		'	<param name="_cy" VALUE="7144" />' +
		'	<param name="FlashVars" VALUE="showTrace=false&video=' + id + '&xml=e73e9c3f-7099-45b5-a772-0578aa58ad4d" />' +
		'	<param name="Movie" VALUE="/lisalib/getfile.aspx?itemid=3988" />' +
		'	<param name="Src" VALUE="/lisalib/getfile.aspx?itemid=3988" />' +
		'	<param name="WMode" VALUE="Transparent" />' +
		'	<param name="Play" VALUE="-1" />' +
		'	<param name="Loop" VALUE="-1" />' +
		'	<param name="Quality" VALUE="High" />' +
		'	<param name="SAlign" VALUE="LT" />' +
		'	<param name="Menu" VALUE="0" />' +
		'	<param name="Base" VALUE="" />' +
		'	<param name="AllowScriptAccess" VALUE="sameDomain" />' +
		'	<param name="Scale" VALUE="ShowAll" />' +
		'	<param name="DeviceFont" VALUE="0" />' +
		'	<param name="EmbedMovie" VALUE="0" />' +
		'	<param name="BGColor" VALUE="FFFFFF" />' +
		'	<param name="SWRemote" VALUE="" />' +
		'	<param name="MovieData" VALUE="" />' +
		'	<param name="SeamlessTabbing" VALUE="1" />' +
		'	<param name="Profile" VALUE="0" />' +
		'	<param name="ProfileAddress" VALUE="" />' +
		'	<param name="ProfilePort" VALUE="0" />' +
		'	<param name="AllowNetworking" VALUE="all" />' +
		'	<param name="AllowFullScreen" VALUE="false" />' +
		'	<embed src="/lisalib/getfile.aspx?itemid=3988" menu="false" quality="high" salign="lt" wmode="transparent" bgcolor="#ffffff" width="' + width + '" height="' + height + '" name="IVP" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="showTrace=false&video=' + id + '&xml=e73e9c3f-7099-45b5-a772-0578aa58ad4d" />' +
		'</object>';

	player.appendChild(close);
	player.appendChild(flash);

	document.body.appendChild(player);

	/* opacity overlay */	
	var overlay = document.createElement("div");
	overlay.id = "wrapper-overlay";

	var heights =
	[
		self.innerHeight ? self.innerHeight : 0,
		document.body.scrollHeight ? document.body.scrollHeight : 0,
		document.documentElement.clientHeight ? document.documentElement.clientHeight : 0,
		document.body.clientHeight ? document.body.clientHeight : 0,
		document.body.offsetHeight ? document.body.offsetHeight : 0
	]

	overlayHeight = Math.max.apply(this, heights)

	overlay.style.width = document.body.clientWidth + "px";
	overlay.style.height = overlayHeight + "px";

	document.body.appendChild(overlay);
}

function play_video(id)
{
	var width = 480;
	var height = 360;

	var player = document.createElement("div");
	player.id = "video-player";
	var close = document.createElement("a");
	var that = this;
	close.onclick = function()
	{
		stop_video();
		return false;
	}
	close.href = "#";
	close.appendChild(document.createTextNode("Close"));

	var flash = document.createElement("div");

	flash.innerHTML = '<embed src="/library/5347/filename/player.swf" width="480" height="360" bgcolor="#000000" allowscriptaccess="always" allowfullscreen="true" flashvars="file=/library/' + id + '/filename/video.flv&autostart=true" />';

	player.appendChild(close);
	player.appendChild(flash);

	document.body.appendChild(player);

	/* opacity overlay */	
	var overlay = document.createElement("div");
	overlay.id = "wrapper-overlay";

	var heights =
	[
		self.innerHeight ? self.innerHeight : 0,
		document.body.scrollHeight ? document.body.scrollHeight : 0,
		document.documentElement.clientHeight ? document.documentElement.clientHeight : 0,
		document.body.clientHeight ? document.body.clientHeight : 0,
		document.body.offsetHeight ? document.body.offsetHeight : 0
	]

	overlayHeight = Math.max.apply(this, heights)

	overlay.style.width = document.body.clientWidth + "px";
	overlay.style.height = overlayHeight + "px";

	document.body.appendChild(overlay);
}


function stop_video()
{
	var player = document.getElementById("video-player");
	document.body.removeChild(player);
	document.body.removeChild(document.getElementById('wrapper-overlay'));
}

function ShowDropMenu(element)
{
	doc = document.getElementById(element);
	if(doc.style.display == 'block')
	{
		doc.style.display = 'none'
 	}
 	else
 	{
 		doc.style.display = 'block'
 	};
}

function HideElements(elementname)
{
	document.getElementById(elementname).style.display = 'none';
	return false;
}

function replaceChar(inputString,charIndex,replaseString) {
	return inputString.substr(0,charIndex) + replaseString + inputString.substr(charIndex + 1);
}

function fixEncoding(theString) {
	var intLength = theString.length;
	
	//var strWindowsLatin=' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷úûýþÿ';
	var strISO88591 = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~, ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷úûýþÿ';
	
	strISO88591 += String.fromCharCode(10) + String.fromCharCode(13) //New line chars
	strISO88591 += String.fromCharCode(9) //Tab char
	var arrISO88591 = new Array();
	var intChar = 0;

	for (i=0;i<strISO88591.length;i++){
		arrISO88591[strISO88591.charCodeAt(i)] = 1;
	}	
	if (intLength) {
		for (i=intLength;i!=0;i--){
				intChar = theString.charCodeAt(i - 1);
				if(!arrISO88591[intChar]){
					theString = replaceChar(theString,i - 1,'&#' + intChar + ';')
				}
		}
	}
	arrISO88591 = null;
	return theString;
}

function email(address1, address2)
{
 location.href = 'mailto:' + address1 + '@' + address2;
}

$(function()
	{
		$('.lightbox a:has(img)').lightBox(
			{
				imageLoading:	'/lisalib/getfile.aspx?itemid=4720',
				imageBtnClose:	'/lisalib/getfile.aspx?itemid=4718',
				imageBtnPrev:	'/lisalib/getfile.aspx?itemid=4719',
				imageBtnNext:	'/lisalib/getfile.aspx?itemid=4721',
				imageBlank:	'/lisalib/getfile.aspx?itemid=4717'
			}
		);

		$('.lightbox2 a').lightBox(
			{
				imageLoading:	'/lisalib/getfile.aspx?itemid=4720',
				imageBtnClose:	'/lisalib/getfile.aspx?itemid=4718',
				imageBtnPrev:	'/lisalib/getfile.aspx?itemid=4719',
				imageBtnNext:	'/lisalib/getfile.aspx?itemid=4721',
				imageBlank:	'/lisalib/getfile.aspx?itemid=4717'
			}
		);

	}
);