

function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}

function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}

function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}

function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}

/*

function toggleImage(id, ischeck)

{

	var obj = document.getElementById(id);

	if (typeof(ischeck)=="undefined")

		obj.checked = (!obj.checked);



	lastPos = 0;

	floatImage();



	obj = document.getElementById("txt");

	obj.innerHTML = "<ol><li>Check text</li></ol>";



	showModalDialog("brochure.pdf");

}

function floatImage()

{

	var obj = document.getElementById("floating");

	obj.style.visibility = "visible";



	onmousemove();

}

function hideImage()

{

	var obj = document.getElementById("floating");

	obj.style.position = "absolute";

	obj.style.visibility = "hidden";

}

*/



function init(imageList)

{

	if (typeof(document.captureEvents)!="undefined")

	{

		document.captureEvents();

		addEventListener("onmouseevent");

	}

	MM_preloadImages(imageList);

}

function getElement(ID)

{

var elem;

		if(document.getElementById)

		{

			var elem = document.getElementById(ID);

		}

		else

		if (document.all)

		{

			var elem = document.all[ID];

		}

		return elem;

}

function onmouseevent(evt)

{

	if (!evt) {

		evt = window.event;

	}

	var obj;

	obj = getElement("floating");



	if (typeof(floatingObj)=="object")

	{

		var iebody	=	(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;

		var dsocleft	=	(typeof(pageXOffset)=="undefined") ? iebody.scrollLeft : pageXOffset;

		var dsoctop	=	(typeof(pageXOffset)=="undefined") ? iebody.scrollTop : pageYOffset;

		

		obj.style.left = (dsocleft+evt.clientX+1)+ 'px';

		obj.style.top = (dsoctop+evt.clientY+1)+ 'px';

	}

}

function enlargePoster(code)

{

var obj;

	obj = getElement('floating_image');



	obj.src= "posters/poster_images/"+code+".jpg";

	obj.alt= code+" -> "+selectionCount;



	floatingObj.style.position="absolute";

	floatingObj.style.visibility="visible";

}

function hidePoster(code)

{

	floatingObj.style.visibility="hidden";

}

var selectionCount = 0;

function getCheckedCount()

{

	return selectionCount;

}

var selection_array = new Array();

function getCheckedText(selection_array)

{

var txt = "You have selected the following:<br/>";

	txt += "<ol>";

	for (code in selection_array)

	{

		if (selection_array[code] != "")

		{

			var obj = getElement(code+"_name");

			txt += "<li>"+obj.innerHTML+"</li>";

		}

	}

	txt += "</ol>";

	return txt;

}

function togglePoster(code, count)

{

var obj;



	obj = getElement(code);

	

//	try

	{

	if (typeof(count)!="undefined")	// If the checkbox is used to toggle the poster

		obj.checked = (!obj.checked);



	var checking = (!obj.checked);



		if (checking) {

			if ( getCheckedCount() >= 5)

			{

				var msg = "You have selected your 5 posters.\r\n";

				    msg += "To select an alternative poster please uncheck one of the posters you currently have selected.\r\n\r\n";

				    msg += "When you are happy with your selection press the 'Submit' button at the bottom of the page.";

				alert(msg);



				return;

			}

		}

		obj.checked = (!obj.checked);

		

		if (obj.checked)

		{

			selection_array[code] = code;

			selectionCount++;

		}

		else {

			selection_array[code] = "";

			selectionCount--;

		}

			

		obj = getElement("poster_selection");

		obj.innerHTML = getCheckedText(selection_array);

	}

//	catch (e) { }

}

document.onmousemove = onmouseevent;

