// This is a different change

function emptyContents (strForm, strField, bitEmpty, strContents) {
	if (document.forms[strForm]) {
		var objForm = document.forms[strForm];
		if (objForm.elements[strField]) {
			var objField = objForm.elements[strField];
			if (bitEmpty && objField.value == strContents) {
				objField.value = "";
			} else if (!bitEmpty && objField.value == "") {
				objField.value = strContents;
			}
		}
	}
}

// This is some more code

function isDate(strFieldName, strFieldText){
   	var objFormField = document.forms[0].elements[strFieldName];
   	
	strDate = objFormField.value;
   
	if(strDate.length>0){

		var dateregex=/^[ ]*[0]?(\d{1,2})\/(\d{1,2})\/(\d{4,})[ ]*$/;
		var match=strDate.match(dateregex);
		if (match){
			var tmpdate=new Date(match[3],parseInt(match[2],10)-1,match[1]);
			if (tmpdate.getDate()==parseInt(match[1],10) && tmpdate.getFullYear()==parseInt(match[3],10) && (tmpdate.getMonth()+1)==parseInt(match[2],10)){ 
				return true; 
			}
		}
		alert(strFieldText + " must be a valid date.");
		objFormField.focus();
		return false;
	} else {
		return true;
	}
}

function validateKeyPress(e, bitAllowBrackets) {
	var key;
	if (window.event || !e.which) {
		key = e.keyCode;
	} else if (e) {
		key = e.which;
	}

	if (key >= 48 && key <= 57) {
		return true;
	} else {
		if (bitAllowBrackets && (key == 40 || key == 41)) {
			return true;
		} else {
			return false;
		}
	}
}

function isEmailAddr(email) {
	var result = false
	var theStr = new String(email)
	var index = theStr.indexOf("@");

	if (index > 0) {
		var pindex = theStr.indexOf(".",index);
		if ((pindex > index+1) && (theStr.length > pindex+1))
			result = true;
	}
	
	return result;
}

// Check a text field value is a number.
function isNumber (field) {
   var num = field.value;
   var str = num.toString();

   if (isNaN(num) && str.length != 0) {
      return false;
	}

   return true;
}

	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_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_findObj(n, d) { //v3.0
	  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); return x;
	}
	
	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 MM_showHideLayers() { //v3.0
	  var i,p,v,obj,args=MM_showHideLayers.arguments;
	  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
	    obj.visibility=v; }
	  document.onmouseup = mouseUp ;
	  if (document.captureEvents) document.captureEvents(Event.MOUSEUP )
	}


	
function navItemHover (divId, imageId) {
	var newImageName = '/Common/Images/arrowHover.gif';

	MM_swapImage(imageId,'',newImageName,1);
	
	changeCssClass(divId, 'navItemHover');
}

function navItemRestore (divId, imageId) {
	MM_swapImgRestore();

	changeCssClass(divId, 'navItem');
}

function navItemSubHover (divId, imageId) {
	var newImageName = '/Common/Images/arrowSubHover.gif';

	MM_swapImage(imageId,'',newImageName,1);
	
	changeCssClass(divId, 'navItemSub1Hover');
}

function navItemSubRestore (divId, imageId) {
	MM_swapImgRestore();
	changeCssClass(divId, 'navItemSub1');
}

function imageHover (imageId, newImageSrc) {
	MM_swapImage(imageId,'',newImageSrc,1);

}

function imageHoverRestore (imageId,blah) {
	MM_swapImgRestore();

}
	
function changeCssClass (divId, cssClass) {
	if (document.getElementById) {
		document.getElementById(divId).className = cssClass;
	} else if (document.all) {
		document.all[divId].className = cssClass;
	} else if (document.layers) {
		if (document[divId].className) {
			document[divId].className = cssClass;
		}
	}
}

//function for date validation
function dateValidate(strDate)
{
	var bitValid = false;
	var dateregex=/^[ ]*[0]?(\d{1,2})\/(\d{1,2})\/(\d{4,})[ ]*$/;
	var match=strDate.match(dateregex);
	
	if (match){
		var tmpdate=new Date(match[3],parseInt(match[2],10)-1,match[1]);
		if (tmpdate.getDate()==parseInt(match[1],10) && tmpdate.getFullYear()==parseInt(match[3],10) && (tmpdate.getMonth()+1)==parseInt(match[2],10)){ 
			bitValid = true; 
		}
	}
	
	return bitValid;

}

//form button hover
var refs=['Search'];
for(var i=0;i<refs.length;i++){ preload(refs[i]);}
function preload(ref)
{
   var im=new Image();
   im.src="/Common/Images/button" + ref + ".gif";
}
function imageOver(ob,ref)
{
 ob.src="/Common/Images/button" + ref + "Hover.gif";
}
function imageOut(ob,ref)
{
 ob.src="/Common/Images/button" + ref + ".gif";
}



// focus and blur on form fields

function FormFocus(FormName,ObjectName,ObjectValue) {
var CheckValueOnFocus = eval("document."+FormName+"."+ObjectName+".value");
	if(CheckValueOnFocus == ObjectValue) {
	eval("document."+FormName+"."+ObjectName+".value = ''");
	} else {}
}

function FormBlur(FormName,ObjectName,ObjectValue) {
var CheckValueOnBlur = eval("document."+FormName+"."+ObjectName+".value");
	if(CheckValueOnBlur == '') {
	eval("document."+FormName+"."+ObjectName+".value = '"+ObjectValue+"'");
	} else {}
}







/*-------------------------------------------------
Mootoole multi box - http://www.liamsmart.co.uk/Downloads/
-------------------------------------------------*/

/**************************************************************

	Script		: Overlay
	Version		: 1.2
	Authors		: Samuel birch
	Desc		: Covers the window with a semi-transparent layer.
	Licence		: Open Source MIT Licence
	Modified	: Liam Smart (liam_smart@hotmail.com) - MooTools 1.2 support

**************************************************************/

//start overlay class
var Overlay = new Class({
	
	getOptions: function(){
		return {
			colour: '#000',
			opacity: 0.7,
			zIndex: 1,
			container: $(document.body),
			onClick: new Class()
		};
	},

	initialize:function(options)
	{
		this.setOptions(this.getOptions(),options);
		
		this.container = new Element('div').setProperty('id','OverlayContainer').setStyles({
			position: 'absolute',
			left: '0px',
			top: '0px',
			width: '100%',
			visibility: 'hidden',
			overflow: 'hidden',
			zIndex: this.options.zIndex
		}).inject(this.options.container,'inside');
		
		this.iframe = new Element('iframe').setProperties({
			id: 'OverlayIframe',
			name: 'OverlayIframe',
			src: 'javascript:void(0);',
			frameborder: 0,
			scrolling: 'no'
		}).setStyles({
			position: 'absolute',
			top: 0,
			left: 0,
			width: '100%',
			height: '100%',
			filter: 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)',
			opacity: 0,
			zIndex: 1
		}).inject(this.container,'inside');
		
		this.overlay = new Element('div').setProperty('id','Overlay').setStyles({
			position: 'absolute',
			left: '0px',
			top: '0px',
			width: '100%',
			height: '100%',
			zIndex: 2,
			backgroundColor: this.options.colour
		}).inject(this.container,'inside');
		
		this.container.addEvent('click',function(){
			this.options.onClick();
		}.bind(this));
		
		this.fade = new Fx.Morph(this.container);
		this.position();
		
		window.addEvent('resize',this.position.bind(this));
	},
	
	position: function(){
		this.container.setStyle('height','0');//reset container height ready for resize( removes scrollbar so new calc is true - liam)
		if(this.options.container == document.body){
			if(this.options.container.getSize().y >= this.options.container.getScrollSize().y){
				this.container.setStyles({
					width: window.getSize().x+'px',
					height: window.getSize().y+'px'
				});
			}else{
				this.container.setStyles({
					width: window.getSize().x+'px',
					height: window.getScrollSize().y+'px'
				});
			}
		}else{ 
			var myCoords = this.options.container.getCoordinates(); 
			this.container.setStyles({
				top: myCoords.top+'px',
				height: myCoords.height+'px',
				left: myCoords.left+'px',
				width: myCoords.width+'px'
			});
		};
	},
	
	show: function(){
		this.fade.start({
			opacity: this.options.opacity,
			visibility: 'visible'
		});
	},
	
	hide: function(){
		this.fade.start({
			opacity: 0,
			visibility: 'hidden'
		});
	}
});

Overlay.implement(new Options);

/**************************************************************

	Script		: MultiBox
	Version		: 1.3.1
	Authors		: Samuel Birch (modified by Liam Smart for MooTools 1.2)
	Desc		: Supports jpg, gif, png, flash, flv, mov, wmv, mp3, html, iframe
	Licence		: Open Source MIT Licence
	Modified	: Leonardo Di Lella (leonardo@dilella.org) - MooTools 1.2 support
				: Liam Smart (liam_smart@hotmail.com)
	Usage		: window.addEvent('domready', function(){
					  if($$('.mb').length > 0)//only triggered if 'mb' class found on page
					  {
						  var initMultiBox = new multiBox('mb', {
							  descClassName: 'multiBoxDesc',//the class name of the description divs
							  path: './Files/',//path to mp3 and flv players
							  useOverlay: true,//use a semi-transparent background. default: false;
							  maxWidth: 600,//max width (set to false to disable)
							  maxHeight: 400,//max height (set to false to disable)
							  addDownload: false,//do you want the files to be downloadable?
							  pathToDownloadScript: './Scripts/ForceDownload.asp',//if above is true, specify download script
							  addRollover: true,//add rollover fade to each multibox link
							  addOverlayIcon: true,//adds overlay icons to images within multibox links
							  addChain: true,//cycle through all images fading them out then in
							  recalcTop: true//subtract the height of controls panel from top position
						  });
					  };
				  });

**************************************************************/

//start multibox class
var multiBox = new Class({
	
	getOptions: function(){
		return {
			initialWidth: 250,
			initialHeight: 250,
			container: $(document.body),
			useOverlay: false,
			contentColor: '#FFF',
			showNumbers: true,
			showControls: true,
			waitDuration: 2000,
			descClassName: false,
			movieWidth: 400,
			movieHeight: 300,
			offset: {x:0, y:0},
			fixedTop: false,
			path: './Files/',
			openFromLink: true,
			relativeToWindow: true,
			onOpen: new Class(),
			onClose: new Class()
		};
	},

	initialize:function(className,options)
	{
		this.setOptions(this.getOptions(),options);
		this.openClosePos = {};
		this.timer = 0;
		this.contentToLoad = {};
		this.index = 0;
		this.opened = false;
		this.contentObj = {};
		this.containerDefaults = {};
		this.content = $$('.'+className);
		
		if(this.options.useOverlay)
		{
			this.overlay = new Overlay({container:this.options.container,onClick:this.close.bind(this)});
		};
		
		//only if overlay is enabled in the top settings (liam)
		if(this.options.addOverlayIcon == true)
		{
			this.addOverlayIcon(this.content);
		};
		
		//only if addRollover is enabled in the top settings (liam)
		if(this.options.addRollover == true)
		{
			this.addRollover(this.content);
		};
		
		//only if startChain is enabled in the top settings (liam)
		if(this.options.addChain == true)
		{
			this.addChain(this.content);
		};
		
		if(this.options.descClassName)
		{
			this.descriptions = $$('.'+this.options.descClassName);
			this.descriptions.each(function(el){
				el.setStyle('display','none');
			});
		};
		
		this.container = new Element('div').addClass('MultiBoxContainer').inject(this.options.container,'inside');
		this.iframe = new Element('iframe').setProperties({
			'id': 'multiBoxIframe',
			'name': 'mulitBoxIframe',
			'src': 'javascript:void(0);',
			'frameborder': 0,
			'scrolling': 'no'
		}).setStyles({
			'position': 'absolute',
			'top': '0',
			'left': '0',
			'width': '100%',
			'height': '100%',
			'filter': 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)',
			'opacity': 0
		}).inject(this.container,'inside');
		this.box = new Element('div').addClass('MultiBoxContent').inject(this.container,'inside');
		
		this.closeButton = new Element('div').addClass('MultiBoxClose').inject(this.container,'inside').addEvent('click', this.close.bind(this));
		
		this.controlsContainer = new Element('div').addClass('MultiBoxControlsContainer').inject(this.container,'inside');
		this.controls = new Element('div').addClass('MultiBoxControls').inject(this.controlsContainer,'inside');
		
		this.previousButton = new Element('div').addClass('MultiBoxPrevious').inject(this.controls,'inside').addEvent('click', this.previous.bind(this));
		this.nextButton = new Element('div').addClass('MultiBoxNext').inject(this.controls,'inside').addEvent('click', this.next.bind(this));
		
		this.title = new Element('div').addClass('MultiBoxTitle').inject(this.controls,'inside');
		this.number = new Element('div').addClass('MultiBoxNumber').inject(this.controls,'inside');
		this.description = new Element('div').addClass('MultiBoxDescription').inject(this.controls,'inside');
		if(this.options.addDownload == true)//only if download is enabled in the top settings (liam)
		{
			this.download = new Element('div').addClass('MultiBoxDownload').inject(this.controls,'inside');
			this.download.setStyles({
				'margin-left': 0
			});
		};
		
		if(this.content.length == 1)
		{
			this.title.setStyles({
				'margin-left': 0
			});
			this.description.setStyles({
				'margin-left': 0
			});
			this.previousButton.setStyle('display', 'none');
			this.nextButton.setStyle('display', 'none');
			this.number.setStyle('display', 'none');
		};
		
		new Element('div').setStyle('clear', 'both').inject(this.controls,'inside');
		
		this.content.each(function(el,i){
			el.index = i;
			el.addEvent('click', function(e){
				new Event(e).stop();
				this.open(el);
			}.bind(this));
			if(el.href.indexOf('#') > -1)
			{
				el.content = $(el.href.substr(el.href.indexOf('#')+1));
				if(el.content)
				{
					el.content.setStyle('display','none');
				};
			};
		}, this);
		
		this.containerEffects = new Fx.Morph(this.container, {duration: 400});
		this.controlEffects = new Fx.Morph(this.controlsContainer, {duration: 300});
		
		this.reset();
	},
	
	setContentType: function(link)
	{
		var str = link.href.substr(link.href.lastIndexOf('.')+1).toLowerCase();
		var contentOptions = {};
		if($chk(link.rel))
		{
			var optArr = link.rel.split(',');
			optArr.each(function(el){
				var ta = el.split(':');
				contentOptions[ta[0]] = ta[1];
			});
		};
		
		if(contentOptions.type != undefined)
		{
			str = contentOptions.type;
		};
		
		this.contentObj = {};
		this.contentObj.url = link.href;
		this.contentObj.xH = 0;
		
		if(contentOptions.width)
		{
			this.contentObj.width = contentOptions.width;
		}
		else
		{
			this.contentObj.width = this.options.movieWidth;
		};
		if(contentOptions.height)
		{
			this.contentObj.height = contentOptions.height;	
		}
		else
		{
			this.contentObj.height = this.options.movieHeight;
		};
		if(contentOptions.panel)
		{
			this.panelPosition = contentOptions.panel;
		}
		else
		{
			this.panelPosition = this.options.panel;
		};
		
		switch(str){
			case 'jpg':
			case 'gif':
			case 'png':
				this.type = 'image';
				break;
			case 'swf':
				this.type = 'flash';
				break;
			case 'flv':
				this.type = 'flashVideo';
				this.contentObj.xH = 70;
				break;
			case 'mov':
				this.type = 'quicktime';
				break;
			case 'mp4'://to support mp4 format (code from phatfusion forum - liam)
			   this.type = 'quicktime';
			   break;
			case 'wmv':
				this.type = 'windowsMedia';
				break;
			case 'rv':
			case 'rm':
			case 'rmvb':
				this.type = 'real';
				break;
			case 'mp3':
				this.type = 'flashMp3';
				this.contentObj.width = 320;
				this.contentObj.height = 70;
				break;
			case 'element':
				this.type = 'htmlelement';
				this.elementContent = link.content;
				this.elementContent.setStyles({
					display: 'block',
					opacity: 0,
					width: 'auto'//added this to get htmlElement to behave (liam)
				});
	
				if(this.elementContent.getStyle('width') != 'auto')
				{
					this.contentObj.width = this.elementContent.getSize().x;
				};
				
				this.contentObj.height = this.elementContent.getSize().y;
				this.elementContent.setStyles({
					display: 'none',
					opacity: 1
				});
				break;
				
			default:
				
				this.type = 'iframe';
				if(contentOptions.req)
				{
					this.type = 'req';
				};
				break;
		}
	},
	
	reset: function()
	{
		this.container.setStyles({
			'opacity': 0,
			'display': 'none'
		});
		this.controlsContainer.setStyles({
			'height': 0
		});
		this.removeContent();
		this.previousButton.removeClass('MultiBoxButtonDisabled');
		this.nextButton.removeClass('MultiBoxButtonDisabled');
		this.opened = false;
	},
	
	getOpenClosePos: function(el)
	{
		if(this.options.openFromLink)
		{
			if (el.getFirst())
			{
				var w = el.getFirst().getCoordinates().width - (this.container.getStyle('border').toInt() * 2);
				if(w < 0)
				{
					w = 0;
				};
				var h = el.getFirst().getCoordinates().height - (this.container.getStyle('border').toInt() * 2);
				if(h < 0)
				{
					h = 0;
				};
				this.openClosePos = {
					width: w,
					height: h,
					top: el.getFirst().getCoordinates().top,
					left: el.getFirst().getCoordinates().left
				};
			}
			else
			{
				var w = el.getCoordinates().width - (this.container.getStyle('border').toInt() * 2);
				if(w < 0)
				{
					w = 0;
				};
				var h = el.getCoordinates().height - (this.container.getStyle('border').toInt() * 2);
				if(h < 0)
				{
					h = 0;
				};
				this.openClosePos = {
					width: w,
					height: h,
					top: el.getCoordinates().top,
					left: el.getCoordinates().left
				};
			}
		}
		else
		{
			if(this.options.fixedTop)
			{
				var top = this.options.fixedTop;
			}
			else
			{
				var top = ((window.getHeight()/2)-(this.options.initialHeight/2)-this.container.getStyle('border').toInt())+this.options.offset.y;
			};
			this.openClosePos = {
				width: this.options.initialWidth,
				height: this.options.initialHeight,
				top: top,
				left: ((window.getWidth()/2)-(this.options.initialWidth/2)-this.container.getStyle('border').toInt())+this.options.offset.x
			};
		};
		return this.openClosePos;
	},
	
	open: function(el)
	{
		this.index = this.content.indexOf(el);
		
		this.openId = el.getProperty('id');
		
		if(!this.opened)
		{
			this.opened = true;
			
			if(this.options.useOverlay)
			{
				this.overlay.show();
			};
			
			this.container.setStyles(this.getOpenClosePos(el));
			this.container.setStyles({
				opacity: 0,
				display: 'block'
			});
			
			if(this.options.fixedTop)
			{
				var top = this.options.fixedTop;
			}
			else
			{
				var top = ((window.getHeight()/2)-(this.options.initialHeight/2)-this.container.getStyle('border').toInt())+this.options.offset.y;
			};
			
			this.containerEffects.start({
				width: this.options.initialWidth,
				height: this.options.initialHeight,
				top: top,
				left: ((window.getWidth()/2)-(this.options.initialWidth/2)-this.container.getStyle('border').toInt())+this.options.offset.x,
				opacity: [0, 1]
			});
			
			this.load(this.index);
		
		}
		else
		{
			if(this.options.showControls)
			{
				this.hideControls();
			};
			this.getOpenClosePos(this.content[this.index]);
			this.timer = this.hideContent.bind(this).delay(500);
			this.timer = this.load.pass(this.index, this).delay(1100);
		};
	},
	
	getContent: function(index)
	{
		this.setContentType(this.content[index]);
		var desc = {};
		if(this.options.descClassName)
		{
			this.descriptions.each(function(el,i)
			{
				if(el.hasClass(this.openId))
				{
					desc = el.clone();
				};
			},this);
		};
		if(this.options.addDownload == true)//only if download is enabled in the top settings (liam)
		{
			var FilePath = this.content[index];//get full path to file
			var splitFileName = String(FilePath).split('/');//split it into array to get file name
			var FileName = splitFileName[splitFileName.length-1];//file name will equal the last part obviously
			FilePath = String(FilePath);//make sure its in a string format
			this.download.set('html','<a href=\"'+this.options.pathToDownloadScript+'?FilePath='+FilePath+'\" title="Download File '+FileName+'\">Download File</a>');//force download the file using ASP
		};
		//var title = this.content[index].title;
		this.contentToLoad = {
			title: this.content[index].title || '&nbsp;',
			desc: desc,
			number: index+1
		};
	},
	
	close: function()
	{
		if(this.options.useOverlay)
		{
			this.overlay.hide();
		};
		if (this.options.showControls)
		{
			this.hideControls();
		};
		this.hideContent();
		this.containerEffects.cancel();
		this.zoomOut.bind(this).delay(500);
		this.options.onClose();
	},
	
	zoomOut: function()
	{
		this.containerEffects.start({
			width: this.openClosePos.width,
			height: this.openClosePos.height,
			top: this.openClosePos.top,
			left: this.openClosePos.left,
			opacity: 0
		});
		this.reset.bind(this).delay(500);
	},
	
	load: function(index)
	{
		this.box.addClass('MultiBoxLoading');
		this.getContent(index);
		if(this.type == 'image')
		{
			var xH = this.contentObj.xH;
			this.contentObj = new Asset.image(this.content[index].href, {onload: this.resize.bind(this)});
			this.contentObj.xH = xH;
		}
		else
		{
			this.resize();
		};
	},
	
	resize: function()
	{
		//only resize if values have been set to resize to (liam)
		if(this.options.maxHeight != false || this.options.maxWidth != false)
		{
			if(this.options.maxHeight != null)//resize image added for new version(can only resize images! not video)
			{
				var maxH = this.options.maxHeight;//declare max height at top of script
			};
			if(this.options.maxWidth != null)
			{
				var maxW = this.options.maxWidth;//declare max width at top of script
			};
				
			var dW = 0;//set initial final width to 0
			var dH = 0;//set initial final height to 0
			var h = dH = this.contentObj.height;//retrieve image height
			var w = dW = this.contentObj.width;//retrieve image width
				
			if ((h >= maxH) && (w >= maxW))
			{
				if (h > w)
				{
					dH = maxH;
					dW = parseInt((w * dH) / h, 10);
				}
				else
				{
					dW = maxW;
					dH = parseInt((h * dW) / w, 10);
				};
			}
			else if((h > maxH) && (w < maxW))
			{
				dH = maxH;
				dW = parseInt((w * dH) / h, 10);
			}
			else if ((h < maxH) && (w > maxW))
			{
				dW = maxW;
				dH = parseInt((h * dW) / w, 10);
			};
				
			this.contentObj.height = dH;//resize image height
			this.contentObj.width = dW;//resize image width
		};
		
		if(this.options.fixedTop)
		{
			var top = this.options.fixedTop;
		}
		else
		{
			var top = ((window.getHeight() / 2) - ((Number(this.contentObj.height) + this.contentObj.xH) / 2) - this.container.getStyle('border').toInt() + window.getScrollTop()) + this.options.offset.y;
		};
		var left = ((window.getWidth() / 2) - (this.contentObj.width / 2) - this.container.getStyle('border').toInt()) + this.options.offset.x;
		if(top < 0)
		{
			top = 0;
		};
		if(left < 0)
		{
			left = 0;
		};
		
		this.containerEffects.cancel();
		this.containerEffects.start({
			width: this.contentObj.width,
			height: Number(this.contentObj.height) + this.contentObj.xH,
			top: top,
			left: left,
			opacity: 1
		});
		this.timer = this.showContent.bind(this).delay(500);
	},
	
	showContent: function()
	{
		this.box.removeClass('MultiBoxLoading');
		this.removeContent();

		this.contentContainer = new Element('div').setProperties({id: 'MultiBoxContentContainer'}).setStyles({opacity: 0, width: this.contentObj.width+'px', height: (Number(this.contentObj.height)+this.contentObj.xH)+'px'}).inject(this.box,'inside');
		
		if(this.type == 'image')
		{
			this.contentObj.inject(this.contentContainer,'inside');
		}
		else if(this.type == 'iframe')
		{
			new Element('iframe').setProperties({
				id: 'iFrame'+new Date().getTime(), 
				width: this.contentObj.width,
				height: this.contentObj.height,
				src: this.contentObj.url,
				frameborder: 0,
				scrolling: 'auto'
			}).inject(this.contentContainer,'inside');
		}
		else if(this.type == 'htmlelement')
		{
			this.elementContent.clone().setStyle('display','block').inject(this.contentContainer,'inside');
		}
		else if(this.type == 'req')//fixes ajax bug (mootools docs code - liam)
		{
			new Request.HTML({
				update: $('MultiBoxContentContainer'),
				autoCancel: true
			}).get(this.contentObj.url);
		}
		else
		{
			var obj = this.createEmbedObject().inject(this.contentContainer,'inside');
			if(this.str != '')
			{
				$('MultiBoxMediaObject').set('html',this.str);
			};
		};
		
		this.contentEffects = new Fx.Morph(this.contentContainer, {duration: 500});
		this.contentEffects.start({
			opacity: 1
		});
		
		this.title.set('html',this.contentToLoad.title);
		this.number.set('html',this.contentToLoad.number+' of '+this.content.length);
		if(this.options.descClassName)
		{
			if(this.description.getFirst())
			{
				this.description.getFirst().destroy();
			};
			this.contentToLoad.desc.inject(this.description,'inside').setStyles({
				display: 'block'
			});
		};

		if(this.options.showControls)
		{
			this.timer = this.showControls.bind(this).delay(800);
		};
	},
	
	hideContent: function()
	{
		this.box.addClass('MultiBoxLoading');
		this.contentEffects.start({
			opacity: 0
		});
		this.removeContent.bind(this).delay(500);
	},
	
	removeContent: function()
	{
		if($('MultiBoxMediaObject'))
		{
			$('MultiBoxMediaObject').destroy();
		};
		if($('MultiBoxContentContainer'))
		{
			$('MultiBoxContentContainer').destroy();	
		};
	},
	
	showControls: function()
	{
		this.clicked = false;
		
		if(this.container.getStyle('height') != 'auto')
		{
			this.containerDefaults.height = this.container.getStyle('height');
			this.containerDefaults.backgroundColor = this.options.contentColor;
			
			//controls box isnt taken into consideration when positioning the container from the top so correct this
			if(this.options.recalcTop == true)
			{
				if(this.container.getStyle('top').toInt() > this.controls.getStyle('height').toInt()/2)
				{
					this.finalResize = new Fx.Morph(this.container,{duration:400});
					this.finalResize.start({
						top: this.container.getStyle('top').toInt()-(this.controls.getStyle('height').toInt()/2)+'px'
					});
				};
			};
		};
		
		this.container.setStyles({
			'height': 'auto'
		});

		if(this.contentToLoad.number == 1)
		{
			this.previousButton.addClass('MultiBoxPreviousDisabled');
		}
		else
		{
			this.previousButton.removeClass('MultiBoxPreviousDisabled');
		};
		if(this.contentToLoad.number == this.content.length)
		{
			this.nextButton.addClass('MultiBoxNextDisabled');
		}
		else
		{
			this.nextButton.removeClass('MultiBoxNextDisabled');
		};
		
		this.controlEffects.start({'height': this.controls.getStyle('height')});
	},
	
	hideControls: function(num)
	{
		this.controlEffects.start({'height': 0}).chain(function(){
			this.container.setStyles(this.containerDefaults);
		}.bind(this));
	},
	
	showThumbnails: function()
	{
		
	},
	
	next: function()
	{
		if(this.index < this.content.length-1)
		{
			this.index++;
			this.openId = this.content[this.index].getProperty('id');
			if (this.options.showControls)
			{
				this.hideControls();
			};
			this.getOpenClosePos(this.content[this.index]);
			this.timer = this.hideContent.bind(this).delay(500);
			this.timer = this.load.pass(this.index, this).delay(1100);
		};
	},
	
	previous: function()
	{
		if(this.index > 0)
		{
			this.index--;
			this.openId = this.content[this.index].getProperty('id');
			if (this.options.showControls)
			{
				this.hideControls();
			};
			this.getOpenClosePos(this.content[this.index]);
			this.timer = this.hideContent.bind(this).delay(500);
			this.timer = this.load.pass(this.index, this).delay(1000);
		};
	},
	
	createEmbedObject: function()
	{
		if(this.type == 'flash')
		{
			var url = this.contentObj.url;
			var obj = new Element('div').setProperties({id: 'MultiBoxMediaObject'});
			this.str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" '
			this.str += 'width="'+this.contentObj.width+'" ';
			this.str += 'height="'+this.contentObj.height+'" ';
			this.str += 'title="MultiBoxMedia">';
  			this.str += '<param name="movie" value="'+url+'" />'
  			this.str += '<param name="quality" value="high" />';
			this.str += '<param name="wmode" value="transparent" />';//better way to embed flash(liam)
  			this.str += '<embed src="'+url+'" ';
  			this.str += 'quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" ';
  			this.str += 'width="'+this.contentObj.width+'" ';
  			this.str += 'height="'+this.contentObj.height+'"></embed>';
			this.str += '</object>';
		};
		
		if(this.type == 'flashVideo')
		{
			//var url = this.contentObj.url.substring(0, this.contentObj.url.lastIndexOf('.'));
			var url = this.contentObj.url;
			var obj = new Element('div').setProperties({id: 'MultiBoxMediaObject'});
			this.str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" '
			this.str += 'width="'+this.contentObj.width+'" ';
			this.str += 'height="'+(Number(this.contentObj.height)+this.contentObj.xH)+'" ';
			this.str += 'title="MultiBoxMedia">';
  			this.str += '<param name="movie" value="'+this.options.path+'flvplayer.swf" />'
  			this.str += '<param name="quality" value="high" />';
  			this.str += '<param name="salign" value="TL" />';
  			this.str += '<param name="scale" value="noScale" />';
  			this.str += '<param name="FlashVars" value="path='+url+'" />';
  			this.str += '<embed src="'+this.options.path+'flvplayer.swf" ';
  			this.str += 'quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" ';
  			this.str += 'width="'+this.contentObj.width+'" ';
  			this.str += 'height="'+(Number(this.contentObj.height)+this.contentObj.xH)+'"';
  			this.str += 'salign="TL" ';
  			this.str += 'scale="noScale" ';
  			this.str += 'FlashVars="path='+url+'"';
  			this.str += '></embed>';
			this.str += '</object>';
		};
		
		if(this.type == 'flashMp3')
		{
			var url = this.contentObj.url;
			var obj = new Element('div').setProperties({id: 'MultiBoxMediaObject'});
			this.str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" '
			this.str += 'width="'+this.contentObj.width+'" ';
			this.str += 'height="'+this.contentObj.height+'" ';
			this.str += 'title="MultiBoxMedia">';
  			this.str += '<param name="movie" value="'+this.options.path+'mp3player.swf" />'
  			this.str += '<param name="quality" value="high" />';
  			this.str += '<param name="salign" value="TL" />';
  			this.str += '<param name="scale" value="noScale" />';
  			this.str += '<param name="FlashVars" value="path='+url+'" />';
  			this.str += '<embed src="'+this.options.path+'mp3player.swf" ';
  			this.str += 'quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" ';
  			this.str += 'width="'+this.contentObj.width+'" ';
  			this.str += 'height="'+this.contentObj.height+'"';
  			this.str += 'salign="TL" ';
  			this.str += 'scale="noScale" ';
  			this.str += 'FlashVars="path='+url+'"';
  			this.str += '></embed>';
			this.str += '</object>';
		};
		
		if(this.type == 'quicktime')
		{
			var obj = new Element('div').setProperties({id: 'MultiBoxMediaObject'});
			this.str = '<object  type="video/quicktime" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab"';
			this.str += ' width="'+this.contentObj.width+'" height="'+this.contentObj.height+'">';
			this.str += '<param name="src" value="'+this.contentObj.url+'" />';
			this.str += '<param name="autoplay" value="true" />';
			this.str += '<param name="controller" value="true" />';
			this.str += '<param name="enablejavascript" value="true" />';
			this.str += '<embed src="'+this.contentObj.url+'" autoplay="true" pluginspage="http://www.apple.com/quicktime/download/" width="'+this.contentObj.width+'" height="'+this.contentObj.height+'"></embed>';
			this.str += '<object/>';
		};
		
		if(this.type == 'windowsMedia')
		{
			var obj = new Element('div').setProperties({id: 'MultiBoxMediaObject'});
			this.str = '<object  type="application/x-oleobject" classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112"';
			this.str += ' width="'+this.contentObj.width+'" height="'+this.contentObj.height+'">';
			this.str += '<param name="filename" value="'+this.contentObj.url+'" />';
			this.str += '<param name="Showcontrols" value="true" />';
			this.str += '<param name="autoStart" value="true" />';
			this.str += '<embed type="application/x-mplayer2" src="'+this.contentObj.url+'" Showcontrols="true" autoStart="true" width="'+this.contentObj.width+'" height="'+this.contentObj.height+'"></embed>';
			this.str += '<object/>';
		};
		
		if(this.type == 'real')
		{
			var obj = new Element('div').setProperties({id: 'MultiBoxMediaObject'});
			this.str = '<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"';
			this.str += ' width="'+this.contentObj.width+'" height="'+this.contentObj.height+'">';
			this.str += '<param name="src" value="'+this.contentObj.url+'" />';
			this.str += '<param name="controls" value="ImageWindow" />';
			this.str += '<param name="autostart" value="true" />';
			this.str += '<embed src="'+this.contentObj.url+'" controls="ImageWindow" autostart="true" width="'+this.contentObj.width+'" height="'+this.contentObj.height+'"></embed>';
			this.str += '<object/>';
		};
		return obj;
	},
	
	addOverlayIcon:function(el)
	{
		//loop through each instance
		el.each(function(el,i)
		{
			//if link contains an image ad overlay
			if(el.getElement('img'))
			{
				//add position:relative to them so that icon is contained
				el.setStyle('position','relative');
					
				//inject a new div that is the overlay icon
				var overlayIcon = new Element('div').inject(el,'inside');
				overlayIcon.addClass('Overlay');
					
				//if not IE6 as IE6 causes too many issues due to lack of PNG support
				if(Browser.Engine.trident4 != true)
				{
					overlayIcon.setStyle('opacity',0);
					overlayIcon.set('tween',{duration:3000,transition:Fx.Transitions.Expo.easeIn}).tween('opacity',1);
				};
			};
		});
	},
	
	addRollover:function(el)
	{
		el.each(function(el,i)
		{
			//if link contains an image ad overlay
			if(el.getElement('img'))
			{
				//add event listener
				el.addEvents
				({
					'mouseenter': function()
					{	
						el.getElement('img').set('tween',{duration:200,transition:Fx.Transitions.linear}).tween('opacity',0.5);
					},
					'mouseleave': function()
					{
						el.getElement('img').set('tween',{duration:400,transition:Fx.Transitions.linear}).tween('opacity',1);
					}
				});
			};
		});
	},
	
	addChain:function(el)
	{
		//create new array to hold all links with images to chain through
		var chainArray = new Array();
		
		//push link into chainArray if it contains an image
		el.each(function(el,i)
		{
			//detect whether link contains image
			if(el.getElement('img'))
			{
				chainArray.push (el);
			};
		});
		
		//now chain through each item in the new array
		chainArray.each(function(el,i)
		{
			//detect whether link contains image
			if(el.getElement('img'))
			{
				//chain through each multibox link that contains an image
				var HoverMe = new Chain();
			 
				var hoverOn = function()
				{
					el.getElement('img').set('tween',{duration:200,transition:Fx.Transitions.linear}).tween('opacity',0.5);
				};
					
				var hoverOff = function()
				{
					el.getElement('img').set('tween',{duration:400,transition:Fx.Transitions.linear}).tween('opacity',1);
				};
					 
				HoverMe.chain(hoverOn);
				HoverMe.chain(hoverOff);

				HoverMe.callChain.delay(2000+(i+1)*1000,HoverMe);
				HoverMe.callChain.delay((i+2)*1000,HoverMe);
			};
		});
	}
});

multiBox.implement(new Options);
multiBox.implement(new Events);



/*------------------------------------------*/
// Mootools link tracker
//http://davidwalsh.name/track-file-downloads-google-analytics-mootools

window.addEvent('load', function() {
	if(pageTracker) {
		$$('.download').addEvent('click',function() {
			pageTracker._trackPageview('/downloads/' + this.get('href').replace('http://',''));
		});
	}
});




/*-------------------------------------------------
Mootoole multi box - http://www.liamsmart.co.uk/Downloads/
-------------------------------------------------*/

window.addEvent('domready', function(){
	
	
	// Multbox link (red black)
	if($$('.popup').length > 0)//only triggered if 'mb' class found on page
	{
		var initMultiBox = new multiBox('popup', {
			descClassName: 'multiBoxDesc',//the class name of the description divs
			path: './Files/',//path to mp3 and flv players
			useOverlay: false,//use a semi-transparent background. default: false;
			maxWidth: 970,//max width (set to false to disable)
			maxHeight: 650,//max height (set to false to disable)
			addDownload: false,//do you want the files to be downloadable?
			pathToDownloadScript: '',//if above is true, specify download script
			addRollover: true,//add rollover fade to each multibox link
			addOverlayIcon: false,//adds overlay icons to images within multibox links
			addChain: false,//cycle through all images fading them out then in
			recalcTop: true//subtract the height of controls panel from top position
		});
	};
	
});


/*-------------------------------------------------
Flash video Player
-------------------------------------------------

 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;


