App = {
    baseUrl : '/'
}

//////////////////////////
// Validation Functions //
//////////////////////////

val={
	isPostcode:function(postcode) {
		return postcode.match(/^\s*[a-zA-Z]{1,2}[0-9]{1,2}[a-zA-Z]{0,1}\s*[0-9]{1}[a-zA-Z]{2}\s*$/);
	}	
}

/////////////////////
// Event Functions //
/////////////////////

events={
	add : function (obj, type, fn) {
		//if (!obj) alert(obj+", "+type);
		if (obj.addEventListener)
			obj.addEventListener( type, fn, false );
		else if (obj.attachEvent)
		{
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
			obj.attachEvent( "on"+type, obj[type+fn] );
		}
	},
	remove : function (obj, type, fn) {
		if (obj.removeEventListener)
			obj.removeEventListener( type, fn, false );
		else if (obj.detachEvent)
		{
			obj.detachEvent( "on"+type, obj[type+fn] );
			obj[type+fn] = null;
			obj["e"+type+fn] = null;
		}
	},
	cancelClick : function (e) {
		if (window.event){
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
		if (e && e.stopPropagation && e.preventDefault){
			e.stopPropagation();
			e.preventDefault();
		}
	},
	getTarget : function (e) {
		var target = window.event ? window.event.srcElement : e ? e.target : null;
		if (!target) {return false;}
		while (target.nodeType != 1 && target.nodeName.toLowerCase() != 'body') {
			target = target.parentNode;
		}
		return target;
	}
}

////////////////////
// AJAX Functions //
////////////////////

ajax={
	adminAuthCheck : false,
//	adminAuthStatus : function() {
//		var xmlhttp = (window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Msxml2.XMLHTTP"));
//		if (xmlhttp != null) {
//			xmlhttp.open("GET", 'includes/ajax/adminAuthCheck.php', false);
//			xmlhttp.send(null);
//			return xmlhttp.responseText;
//		};
//	},
	requestLoadingShowText: true,
	requestLoadingText: '<strong>Loading... Please Wait</strong>',
	requestLoadingCallback: false,
	requestCompleteFunction : function(r) {
	  	if (ajax.adminAuthCheck) {
	  		var authResponse = r.responseText;
	  		if (authResponse < 0) {
		  		location.href = 'login.php?status='+authResponse+'&request='+escape(location.href.substr(location.href.lastIndexOf('/')+1));
		  		return false;
	  		}
		  	if (typeof(adminLock) != "undefined") adminLock.resetCountdown();
	  	}
	  	this.retrieved(r);
	},
	requestCompleteCallback : false,
	doxhr:function(container,url,method,params){
		if ( method != 'post' ) {
		    var method = 'get';
		}
	  	if (!document.getElementById || !document.createTextNode) {return;}
	  	if (location.href.search(/\/admin\//i) >= 0) ajax.adminAuthCheck = true;
	  	if (container != '') {
		    ajax.outputContainer=document.getElementById(container);
		    if(!ajax.outputContainer){return;}
		}
	    var request;
	    try {
	      request = new XMLHttpRequest();
	    } catch(error) {
	      try {
	        request = new ActiveXObject("Microsoft.XMLHTTP");
	      } catch(error) {
	        return true;
	      }
	    }
	    //alert(url);
	    request.onreadystatechange = function() {
	      if(request.readyState == 1){
	      	if (ajax.requestLoadingCallback) ajax.requestLoadingCallback();
	        if (ajax.outputContainer && ajax.requestLoadingShowText) ajax.outputContainer.innerHTML=ajax.requestLoadingText;
	      }
	      if(request.readyState == 4){
	        if (request.status && /200|304/.test(request.status)) {
	          ajax.requestCompleteFunction(request);
	        } else {
	          ajax.failed(request);
	        }
	      }
	    }

	    switch ( method ) {
		    case 'get':
			    request.open( 'get', url, true );
			    request.setRequestHeader( 'If-Modified-Since','Wed, 05 Apr 2006 00:00:00 GMT' );
			    request.setRequestHeader( "X-Requested-With", 'XMLHttpRequest' );
			    request.send( null );
			    break;
		    case 'post':
			    // extract params from url
			    //var q = url.indexOf( '?' );
			    //var params = url.slice( q + 1 );
			    //var url = url.substring( 0, q );
			    request.open( 'post', url, true );
			    request.setRequestHeader( 'If-Modified-Since','Wed, 05 Apr 2006 00:00:00 GMT' );
			    request.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" );
			    request.setRequestHeader( "Content-length", params.length );
			    request.setRequestHeader( "X-Requested-With", 'XMLHttpRequest' );
			    // removed on the basis that this can cause excessive connections to web server
			    // _possibly_ related to random "add note" bug
			    // if this turns out not to be the case, try disabling the admin auth check
			    //request.setRequestHeader( "Connection", "close" );
			    request.send( params );
			    break;
	    }

	    return false;
	},
	retrieved:function( requester ) {
	    var data=requester.responseText;
	    //alert(data);
	    ajax.outputContainer.innerHTML=data;
	    if (ajax.requestCompleteCallback) {
		ajax.requestCompleteCallback(data);
	    }
	    return false;
	},
	failed:function( requester ) {
	    alert('The XMLHttpRequest failed. Status: '+requester.status);
		return true;
	}
}

/////////////////////
// Cloak Functions //
/////////////////////

cloak={
	obj : false,
	height : false,
	width : false,
	left : false,
	top : false,
	loading: false,
	hideObjs : true,
	secure: false,
	elm: function() {
		if (!document.getElementById('cloak')) {
			var cloakDiv = document.createElement('div');
			cloakDiv.setAttribute('id', 'cloak');
			if (cloak.loading) {
				var loadingImg = document.createElement('img');
				loadingImg.setAttribute('id', 'loadingImg');
				if ( cloak.secure ) {
					loadingImg.setAttribute('src', 'https://secure.scottjordan.co.uk/images/ajax_loader.gif');
				} else {
					loadingImg.setAttribute('src', 'http://www.scottjordan.co.uk/images/ajax_loader.gif');
				}
				loadingImg.setAttribute('alt', '');
				loadingImg.setAttribute('height', 32);
				loadingImg.setAttribute('width', 32);
				cloakDiv.appendChild(loadingImg);
			}
			document.body.appendChild(cloakDiv);
		}
		return document.getElementById('cloak');
	},
	hideElms : function(fn) {
		var hideArray = new Array();
		if (document.getElementById('mediaPlayer')) hideArray.push(document.getElementById('mediaPlayer'));
		var select = document.getElementsByTagName("select");
		if ( select.length > 0 ) {
	    	for (var n = 0; n <select.length; n++) {
	    		hideArray.push = select[n];
	    	}
		}
		for (var i=0; i<hideArray.length; i++) {
			var visibility = (fn == 'hide' ? 'hidden' : 'visible');
			hideArray[i].style.visibility = visibility;
		}
	},
	getPos : function() {
		if (!cloak.obj) {return;}
		var obj = cloak.obj;

		var width  = obj.offsetWidth;
		var height = obj.offsetHeight;
	
		var left = 0;
		var top = 0;
		if (obj.offsetParent) {
			left = obj.offsetLeft;
			top = obj.offsetTop;
			while (obj = obj.offsetParent) {
				left += obj.offsetLeft;
				top += obj.offsetTop;
			}
		}

		cloak.left = left;
		cloak.top = top;
		cloak.width = width+2;
		cloak.height = height;
	},	
	showIt : function(obj,hide) {
		if (obj != '') cloak.obj = obj;
		if (hide != '') cloak.hide = hide;	
	
		var elm = cloak.elm();
		if (cloak.hideObjs) cloak.hideElms('hide');
		if (cloak.obj) cloak.getPos();
		
		if (cloak.left) elm.style.left = cloak.left+'px';
		if (cloak.top) elm.style.top = cloak.top+'px';
		elm.style.height = (cloak.height ? cloak.height+'px' : (document.body.scrollHeight > document.body.clientHeight ? document.body.scrollHeight+'px' : document.body.clientHeight+'px'));
		elm.style.width = (cloak.width ? cloak.width+'px' : (document.body.scrollWidth > document.body.clientWidth ? document.body.scrollWidth+'px' : document.body.clientWidth+'px'));

		elm.style.display = 'inline';	
	},
	hideIt : function() {
		var elm = cloak.elm();
		if (cloak.hideObjs) cloak.hideElms('show');
		
		elm.style.display = 'none';
	}
}

messageStack={
	elm : function () { return document.getElementById('messageStack') },
	stack : function () { return document.getElementById('messageStack').getElementsByTagName('li') },
	count : 0,
	countdown : 0,
	init : function () {
		messageStack.count = messageStack.stack().length;
		if (messageStack.count > 0) {
			for (var x in messageStack.elm().getElementsByTagName('img')) {
				messageStack.deleteEvent(messageStack.elm().getElementsByTagName('img')[x]);
			}
//			messageStack.countdown = setTimeout(function() {
//				messageStack.remove();
//			}, 15000);
		}
	},
	create : function () {
		var div = document.createElement('div');
		div.setAttribute('id', 'messageStack');
		div.appendChild(document.createElement('ul'));
		document.getElementById('content').insertBefore(div, document.getElementById('content').firstChild.nextSibling);
	},
	destroy : function () {
		messageStack.elm().parentNode.removeChild(messageStack.elm());
	},
	deleteEvent : function (elm) {
		events.add(elm, 'click', function(e) {
				if (this.parentNode.parentNode) this.parentNode.parentNode.removeChild(this.parentNode);
				if (messageStack.count > 0) messageStack.count--;
				if (messageStack.count == 0) messageStack.destroy();
				events.cancelClick(e);
		});
	},
	add : function (title,message,type) {
		if (!messageStack.elm()) messageStack.create();
		var li = document.createElement('li');
		li.className = 'message'+type.charAt(0).toUpperCase()+type.substr(1);
		var img = document.createElement('img');
		messageStack.deleteEvent(img);
		img.src = "http://www.scottjordan.co.uk/images/white_cross.gif";
		img.height = img.width = 10;
		li.appendChild(img);
		var div = document.createElement('div');
		var strong = document.createElement('strong');
		strong.appendChild(document.createTextNode(title+':'));
		div.appendChild(strong);
		div.appendChild(document.createTextNode(' '+message));
		li.appendChild(div);
		messageStack.elm().firstChild.appendChild(li);
		messageStack.count++;
	},
	remove : function () {
		messageStack.elm().parentNode.removeChild(messageStack.elm());	
	}
}// Browser Detect Lite  v2.1.4
// http://www.dithered.com/javascript/browser_detect/index.html
// modified by Chris Nott (chris@NOSPAMdithered.com - remove NOSPAM)


function BrowserDetectLite() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser name
   this.isGecko     = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isMozilla   = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isNS        = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   this.isIE        = ( (ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) ); 
   this.isSafari    = (ua.indexOf('safari') != - 1);
   this.isOpera     = (ua.indexOf('opera') != -1); 
   this.isKonqueror = (ua.indexOf('konqueror') != -1 && !this.isSafari); 
   this.isIcab      = (ua.indexOf('icab') != -1); 
   this.isAol       = (ua.indexOf('aol') != -1); 
   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isNS && this.isGecko) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
   }
   else if (this.isOpera) {
      if (ua.indexOf('opera/') != -1) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera/') + 6 ) );
      }
      else {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera ') + 6 ) );
      }
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isIcab) {
      if (ua.indexOf('icab/') != -1) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab/') + 6 ) );
      }
      else {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab ') + 6 ) );
      }
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin   = (ua.indexOf('win') != -1);
   this.isWin32 = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac   = (ua.indexOf('mac') != -1);
   this.isUnix  = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}
var browser = new BrowserDetectLite();

/////////////////////
// Navigation Menu //
/////////////////////

nav={
	// the timeout for the menu
	timeout : 1000,
	timeouts : new Array(),
	// this function apply the CSS style and the event
	init : function( menuId ) {
	    // a test to avoid some browser like IE4, Opera 6, and IE Mac
	    if ( browser.isDOM1 
	    && !( browser.isMac && browser.isIE ) 
	    && !( browser.isOpera && browser.versionMajor < 7 )
	    && !( browser.isIE && browser.versionMajor < 5 ) )
	    {
	        // get some element
	        var menu = document.getElementById( menuId ); // the root element
	        var lis = menu.getElementsByTagName( 'li' ); // all the li
	        
	        // change the class name of the menu, 
	        // it's usefull for compatibility with old browser
	        //menu.className = 'menu';
	        
	        // i am searching for ul element in li element
	        for ( var i=0; i < lis.length; i++ )
	        {
	            // is there a ul element ?
	            if ( lis.item(i).getElementsByTagName( 'ul' ).length > 0 )
	            {        
	                // improve IE key navigation
	                if ( browser.isIE )
	                {
	                    events.add( lis.item(i), 'keyup', nav.show );
	                }
	                // link events to list item
	                events.add( lis.item(i), 'mouseover', nav.show );
	                events.add( lis.item(i), 'mouseout', nav.timeoutHide );
	                events.add( lis.item(i), 'blur', nav.timeoutHide );
	                events.add( lis.item(i), 'focus', nav.show );
	                
	                // add an id to list item
	                lis.item(i).setAttribute( 'id', "li"+i );
	                //var link = lis.item(i).getElementsByTagName( 'a' )[0];
	                var link = lis.item(i);
	                link.style.backgroundImage = 'url(http://www.scottjordan.co.uk/images/toggle_arrow_open.gif)';
	                link.style.backgroundPosition = '98% 45%';
	                link.style.backgroundRepeat = 'no-repeat';
	            }
	        }
	    }
	},
	// hide the first ul element of the current element
	timeoutHide : function () {
    	nav.timeouts[ this.id ] = window.setTimeout( 'nav.hideUlUnder( "'+this.id+'" )', nav.timeout );
	},
	// hide the ul elements under the element identified by id
	hideUlUnder : function ( id ) {   
	    //document.getElementById(id).getElementsByTagName('ul')[0].style['visibility'] = 'hidden';
	    document.getElementById(id).getElementsByTagName('ul')[0].style['left'] = '-1000px';
	},
	// show the first ul element found under this element
	show : function () {
    	// show the sub menu
    	//this.getElementsByTagName('ul')[0].style['visibility'] = 'visible';
    	this.getElementsByTagName('ul')[0].style[ 'left' ] = '163px';
    	var currentNode=this;
    	while(currentNode)
    	{
            	if( currentNode.nodeName=='LI')
            	{
	                currentNode.getElementsByTagName('a')[0].className = 'linkOver';
            	}
            	currentNode=currentNode.parentNode;
    	}
    	// clear the timeout
    	if ( typeof( nav.timeouts[ this.id ] ) != "undefined" ) {
    		clearTimeout( nav.timeouts[ this.id ] );
    	}
    	nav.hideAllOthersUls( this );
	},
	// hide all ul on the same level of  this list item
	hideAllOthersUls : function( currentLi )
	{
	    var lis = currentLi.parentNode;
	    for ( var i=0; i<lis.childNodes.length; i++ )
	    {
        	if ( lis.childNodes[i].nodeName=='LI' && lis.childNodes[i].id != currentLi.id )
        	{
	            nav.hideUlUnderLi( lis.childNodes[i] );
        	}
    	}
	},
	// hide all the ul wich are in the li element
	hideUlUnderLi : function( li )
	{
	    var as = li.getElementsByTagName('a');
	    for ( var i=0; i<as.length; i++ )
	    {
        	as.item(i).className = "";
    	}
    	var uls = li.getElementsByTagName('ul');
    	for ( var i=0; i<uls.length; i++ )
    	{
	        //uls.item(i).style['visibility'] = 'hidden';
        	uls.item(i).style['left'] = '-1000px';
    	}
	} 	
}	

addthis_brand = 'Scott Jordan Ents';
addthis_pub  = 'ScottJordanEnts';
addthis_logo = 'http://www.scottjordan.co.uk/images/logo-100x50.png';
addthis_logo_background = '000000';
addthis_logo_color = 'ffffff';
addthis_options = 'favorites, email, digg, delicious, myspace, facebook, google, live, more';

// global event handlers
events.add(window, 'load', function() {
	//var links = document.getElementById('menu').getElementsByTagName('a');
	//for (var x in links) {
	//		if (links[x].nodeName && links[x].nodeName.toLowerCase() == 'a') events.add(links[x], 'focus', function(e) {events.getTarget(e).blur()});
	//	}
	var blur = getElementsByClass('blr', 'a');
	for (var x in blur) {
		events.add(blur[x], 'focus', function(e) {events.getTarget(e).blur()});
	}
	var back = getElementsByClass('bck', 'a');
	for (var x in back) {
		events.add(back[x], 'click', function(e) {
//			alert(history.length);
			history.back();
			events.cancelClick(e);
		});
	}
	if (document.getElementById('emailLink')) {
		events.add( document.getElementById('emailLink'), 'click', function(e) {
			location.href='http://www.scottjordan.co.uk/contact-success.html?id=email';
		});
	}

	if (document.getElementById('messageStack')) {
		messageStack.init();
	}

	if ( document.getElementById( 'nav' ) ) nav.init( 'nav' );
	if ( document.getElementById( 'catnav' ) ) nav.init( 'catnav' );

	//add this events
	if ( document.getElementById( 'addthis' ) ) {
		var addthis = document.getElementById( 'addthis' );
		events.add( addthis, 'mouseover', function(e) { return addthis_open(this, '', '[URL]', '[TITLE]') });
		events.add( addthis, 'mouseout', function(e) { addthis_close() });
		events.add( addthis, 'click', function(e) { return addthis_sendto() });
	}
});

//String.prototype.toTitleCase = function() {
//	return this.toLowerCase().replace(/\w+/g, function (s) {
//		return s.charAt(0).toUpperCase() + s.substr(1);
//	});
//}
String.prototype.toTitleCase = function () {
	var A = this.toLowerCase().split(' '), B = [];
	for (var i = 0; A[i] !== undefined; i++) {
		B[B.length] = A[i].substr(0, 1).toUpperCase() + A[i].substr(1);
	}
	return B.join(' ');
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g, '');
}
// no need to prototype document object as only one instance... IE doesn't let you anyway!
document.getElementsByClassName = function(searchClass,tag) {
	var classElements = new Array();
	if (tag == null) tag = '*';
	var els = document.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

function getElementsByClass(searchClass,tag,node) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function inArray(array, value) {
	for (var j=0; j < array.length; j++) {
		if (array[j] === value) {
			return true;
		}
	}
	return false;
}

address={
	prefix : 0,
	postcode : function() {
		if (!address.prefix || !document.getElementById(address.prefix+'Postcode')) return false;
		return document.getElementById(address.prefix+'Postcode').value;
	},
	lookup : function(prefix) {
		address.prefix = prefix;
		if (!address.postcode()) return false;
		// perform simple postcode validation... saves credits!
		if (!val.isPostcode(address.postcode())) {
			alert('Invalid Postcode, please try again.')
			return;
		}
		if (confirm('This will overwrite existing Address information, are you sure?')) {
		    var url = App.baseUrl + 'admin/index/address-lookup/';
		    url += "prefix/" + address.prefix + "/postcode/" + address.postcode();
		    ajax.requestLoadingShowText = false;
		    ajax.requestLoadingCallback = function() {cloak.showIt();}
		    ajax.requestCompleteCallback = function(data) {address.write(data)};
		    ajax.doxhr('ajaxMessage', url);
		}
	},
	write : function(data) {
	    //alert(data);
		//if (data != false) {
		if ( data ) {
			var addressData = data.split('#');
			for (i=0; i<addressData.length; i++) {
				var data = addressData[i].split('|');
				if (document.getElementById(data[0])) document.getElementById(data[0]).value = data[1];
			}
		} else {
			alert('No Address found. Please check the Postcode and try again.');
		}
		cloak.hideIt();
	}
}

function trim(sString) {
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ') {
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

//////////////////////////
// Find Object Position //
//////////////////////////

function getPos(obj) {
	var width  = obj.offsetWidth;
	var height = obj.offsetHeight;

	var left = 0;
	var top = 0;
	if (obj.offsetParent) {
		left = obj.offsetLeft;
		top = obj.offsetTop;
		while (obj = obj.offsetParent) {
			left += obj.offsetLeft;
			top += obj.offsetTop;
		}
	}
	return [height,width,left,top];
}
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent)
	    while(1)
	    {
	      curleft += obj.offsetLeft;
	      if(!obj.offsetParent)
	        break;
	      obj = obj.offsetParent;
	    }
	else if(obj.x)
	    curleft += obj.x;
	return curleft;
}
function findPosY(obj) {
	var curtop = 0;
	if(obj.offsetParent)
	    while(1)
	    {
	      curtop += obj.offsetTop;
	      if(!obj.offsetParent)
	        break;
	      obj = obj.offsetParent;
	    }
	else if(obj.y)
	    curtop += obj.y;
	return curtop;
}

//myField accepts an object reference, myValue accepts the text strint to add
function insertAtCursor(myField, myValue) {
	//IE support
	if (document.selection) {
		myField.focus();

		//in effect we are creating a text range with zero
		//length at the cursor location and replacing it
		//with myValue
		sel = document.selection.createRange();
		sel.text = myValue;
	} else if (myField.selectionStart || myField.selectionStart == '0') {
		//Mozilla/Firefox/Netscape 7+ support
		//Here we get the start and end points of the
		//selection. Then we create substrings up to the
		//start of the selection and from the end point
		//of the selection to the end of the field value.
		//Then we concatenate the first substring, myValue,
		//and the second substring to get the new value.
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos)+ myValue+ myField.value.substring(endPos, myField.value.length);
	} else {
		myField.value += myValue;
	}
	myField.focus();
}

// URL Encode/Decode Functions

url={
	encode : function(clearString) {
		var output = '';
		var x = 0;
		clearString = clearString.toString();
		var regex = /(^[a-zA-Z0-9_.]*)/;
		while (x < clearString.length) {
			var match = regex.exec(clearString.substr(x));
			if (match != null && match.length > 1 && match[1] != '') {
				output += match[1];
				x += match[1].length;
			} else {
			  if (clearString[x] == ' ') {
				output += '+';
			  } else {
			  	var charCode = clearString.charCodeAt(x);
			  	var hexVal = charCode.toString(16);
			  	output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
			  }
			  x++;
			}
		}
		return output;
	},
	decode : function(encodedString) {
		var output = encodedString;
		var binVal, thisString;
		var myregexp = /(%[^%]{2})/;
		while ((match = myregexp.exec(output)) != null
		&& match.length > 1
			&& match[1] != '') {
			binVal = parseInt(match[1].substr(1),16);
			thisString = String.fromCharCode(binVal);
			output = output.replace(match[1], thisString);
		}
		return output;
	}
}

///////////////////////////////
// Flash Detection Functions //
///////////////////////////////

flash={
	// Flash Player Version Detection - Rev 1.5
	// Detect Client Browser type
	// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
	isIE : (navigator.appVersion.indexOf("MSIE") != -1) ? true : false,
	isWin : (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false,
	isOpera : (navigator.userAgent.indexOf("Opera") != -1) ? true : false,
	ControlVersion:function () {
		var version;
		var axo;
		var e;
		// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
		try {
			// version will be set for 7.X or greater players
			axo = new ActiveXObject("Shockwaveflash.Shockwaveflash.7");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
		if (!version) {
			try {
				// version will be set for 6.X players only
				axo = new ActiveXObject("Shockwaveflash.Shockwaveflash.6");
				
				// installed player is some revision of 6.0
				// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
				// so we have to be careful. 
				
				// default to the first public version
				version = "WIN 6,0,21,0";
	
				// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
				axo.AllowScriptAccess = "always";
	
				// safe to call for 6.0r47 or greater
				version = axo.GetVariable("$version");
	
			} catch (e) {
			}
		}
		if (!version) {
			try {
				// version will be set for 4.X or 5.X player
				axo = new ActiveXObject("Shockwaveflash.Shockwaveflash.3");
				version = axo.GetVariable("$version");
			} catch (e) {
			}
		}
		if (!version) {
			try {
				// version will be set for 3.X player
				axo = new ActiveXObject("Shockwaveflash.Shockwaveflash.3");
				version = "WIN 3,0,18,0";
			} catch (e) {
			}
		}
		if (!version) {
			try {
				// version will be set for 2.X player
				axo = new ActiveXObject("Shockwaveflash.ShockwaveFlash");
				version = "WIN 2,0,0,11";
			} catch (e) {
				version = -1;
			}
		}
		return version;
	},
	GetSwfVer:function() {
	// JavaScript helper required to detect Flash Player PlugIn version information
		// NS/Opera version >= 3 check for Flash plugin in plugin array
		var flashVer = -1;
		
		if (navigator.plugins != null && navigator.plugins.length > 0) {
			if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
				var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
				var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;			
				var descArray = flashDescription.split(" ");
				var tempArrayMajor = descArray[2].split(".");
				var versionMajor = tempArrayMajor[0];
				var versionMinor = tempArrayMajor[1];
				if ( descArray[3] != "" ) {
					tempArrayMinor = descArray[3].split("r");
				} else {
					tempArrayMinor = descArray[4].split("r");
				}
				var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
				var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
			}
		}
		// MSN/WebTV 2.6 supports Flash 4
		else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
		// WebTV 2.5 supports Flash 3
		else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
		// older WebTV supports Flash 2
		else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
		else if ( flash.isIE && flash.isWin && !flash.isOpera ) {
			flashVer = flash.ControlVersion();
		}	
		return flashVer;
	},
	DetectFlashVer:function (reqMajorVer, reqMinorVer, reqRevision) {
	// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
		versionStr = flash.GetSwfVer();
		if (versionStr == -1 ) {
			return false;
		} else if (versionStr != 0) {
			if(flash.isIE && flash.isWin && !flash.isOpera) {
				// Given "WIN 2,0,0,11"
				tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
				tempString        = tempArray[1];			// "2,0,0,11"
				versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
			} else {
				versionArray      = versionStr.split(".");
			}
			var versionMajor      = versionArray[0];
			var versionMinor      = versionArray[1];
			var versionRevision   = versionArray[2];
	
	        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
			if (versionMajor > parseFloat(reqMajorVer)) {
				return true;
			} else if (versionMajor == parseFloat(reqMajorVer)) {
				if (versionMinor > parseFloat(reqMinorVer))
					return true;
				else if (versionMinor == parseFloat(reqMinorVer)) {
					if (versionRevision >= parseFloat(reqRevision))
						return true;
				}
			}
			return false;
		}
	}
}
/*	Unobtrusive Flash Objects (UFO) v3.20 <http://www.bobbyvandersluis.com/ufo/>
	Copyright 2005, 2006 Bobby van der Sluis
	This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
*/

UFO={
	req: ["movie", "width", "height", "majorversion", "build"],
	opt: ["play", "loop", "menu", "quality", "scale", "salign", "wmode", "bgcolor", "base", "flashvars", "devicefont", "allowscriptaccess", "seamlesstabbing"],
	optAtt: ["id", "name", "align"],
	optExc: ["swliveconnect"],
	ximovie: "ufo.swf",
	xiwidth: "215",
	xiheight: "138",
	ua: navigator.userAgent.toLowerCase(),
	pluginType: "",
	fv: [0,0],
	foList: [],
		
	create: function(FO, id) {
		if (!UFO.uaHas("w3cdom") || UFO.uaHas("ieMac")) return;
		UFO.getFlashVersion();
		UFO.foList[id] = UFO.updateFO(FO);
//		UFO.createCSS("#" + id, "visibility:hidden;");
		UFO.domLoad(id);
	},

	updateFO: function(FO) {
		if (typeof FO.xi != "undefined" && FO.xi == "true") {
			if (typeof FO.ximovie == "undefined") FO.ximovie = UFO.ximovie;
			if (typeof FO.xiwidth == "undefined") FO.xiwidth = UFO.xiwidth;
			if (typeof FO.xiheight == "undefined") FO.xiheight = UFO.xiheight;
		}
		FO.mainCalled = false;
		return FO;
	},

	domLoad: function(id) {
		var _t = setInterval(function() {
			if ((document.getElementsByTagName("body")[0] != null || document.body != null) && document.getElementById(id) != null) {
				UFO.main(id);
				clearInterval(_t);
			}
		}, 250);
		if (typeof document.addEventListener != "undefined") {
			document.addEventListener("DOMContentLoaded", function() { UFO.main(id); clearInterval(_t); } , null); // Gecko, Opera 9+
		}
	},

	main: function(id) {
		var _fo = UFO.foList[id];
		if (_fo.mainCalled) return;
		UFO.foList[id].mainCalled = true;
//		document.getElementById(id).style.visibility = "hidden";
		if (UFO.hasRequired(id)) {
			if (UFO.hasFlashVersion(parseInt(_fo.majorversion, 10), parseInt(_fo.build, 10))) {
				if (typeof _fo.setcontainercss != "undefined" && _fo.setcontainercss == "true") UFO.setContainerCSS(id);
				UFO.writeSWF(id);
			}
			else if (_fo.xi == "true" && UFO.hasFlashVersion(6, 65)) {
				UFO.createDialog(id);
			}
		}
//		document.getElementById(id).style.visibility = "visible";
	},
	
	createCSS: function(selector, declaration) {
		var _h = document.getElementsByTagName("head")[0]; 
		var _s = UFO.createElement("style");
		if (!UFO.uaHas("ieWin")) _s.appendChild(document.createTextNode(selector + " {" + declaration + "}")); // bugs in IE/Win
		_s.setAttribute("type", "text/css");
		_s.setAttribute("media", "screen"); 
		_h.appendChild(_s);
		if (UFO.uaHas("ieWin") && document.styleSheets && document.styleSheets.length > 0) {
			var _ls = document.styleSheets[document.styleSheets.length - 1];
			if (typeof _ls.addRule == "object") _ls.addRule(selector, declaration);
		}
	},
	
	setContainerCSS: function(id) {
		var _fo = UFO.foList[id];
		var _w = /%/.test(_fo.width) ? "" : "px";
		var _h = /%/.test(_fo.height) ? "" : "px";
		UFO.createCSS("#" + id, "width:" + _fo.width + _w +"; height:" + _fo.height + _h +";");
		if (_fo.width == "100%") {
			UFO.createCSS("body", "margin-left:0; margin-right:0; padding-left:0; padding-right:0;");
		}
		if (_fo.height == "100%") {
			UFO.createCSS("html", "height:100%; overflow:hidden;");
			UFO.createCSS("body", "margin-top:0; margin-bottom:0; padding-top:0; padding-bottom:0; height:100%;");
		}
	},

	createElement: function(el) {
		return (UFO.uaHas("xml") && typeof document.createElementNS != "undefined") ?  document.createElementNS("http://www.w3.org/1999/xhtml", el) : document.createElement(el);
	},

	createObjParam: function(el, aName, aValue) {
		var _p = UFO.createElement("param");
		_p.setAttribute("name", aName);	
		_p.setAttribute("value", aValue);
		el.appendChild(_p);
	},

	uaHas: function(ft) {
		var _u = UFO.ua;
		switch(ft) {
			case "w3cdom":
				return (typeof document.getElementById != "undefined" && typeof document.getElementsByTagName != "undefined" && (typeof document.createElement != "undefined" || typeof document.createElementNS != "undefined"));
			case "xml":
				var _m = document.getElementsByTagName("meta");
				var _l = _m.length;
				for (var i = 0; i < _l; i++) {
					if (/content-type/i.test(_m[i].getAttribute("http-equiv")) && /xml/i.test(_m[i].getAttribute("content"))) return true;
				}
				return false;
			case "ieMac":
				return /msie/.test(_u) && !/opera/.test(_u) && /mac/.test(_u);
			case "ieWin":
				return /msie/.test(_u) && !/opera/.test(_u) && /win/.test(_u);
			case "gecko":
				return /gecko/.test(_u) && !/applewebkit/.test(_u);
			case "opera":
				return /opera/.test(_u);
			case "safari":
				return /applewebkit/.test(_u);
			default:
				return false;
		}
	},
	
	getFlashVersion: function() {
		if (UFO.fv[0] != 0) return;  
		if (navigator.plugins && typeof navigator.plugins["Shockwave Flash"] == "object") {
			UFO.pluginType = "npapi";
			var _d = navigator.plugins["Shockwave Flash"].description;
			if (typeof _d != "undefined") {
				_d = _d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
				var _m = parseInt(_d.replace(/^(.*)\..*$/, "$1"), 10);
				var _r = /r/.test(_d) ? parseInt(_d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
				UFO.fv = [_m, _r];
			}
		}
		else if (window.ActiveXObject) {
			UFO.pluginType = "ax";
			try { // avoid fp 6 crashes
				var _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
			}
			catch(e) {
				try { 
					var _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
					UFO.fv = [6, 0];
					_a.AllowScriptAccess = "always"; // throws if fp < 6.47 
				}
				catch(e) {
					if (UFO.fv[0] == 6) return;
				}
				try {
					var _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
				}
				catch(e) {}
			}
			if (typeof _a == "object") {
				var _d = _a.GetVariable("$version"); // bugs in fp 6.21/6.23
				if (typeof _d != "undefined") {
					_d = _d.replace(/^\S+\s+(.*)$/, "$1").split(",");
					UFO.fv = [parseInt(_d[0], 10), parseInt(_d[2], 10)];
				}
			}
		}
	},

	hasRequired: function(id) {
		var _l = UFO.req.length;
		for (var i = 0; i < _l; i++) {
			if (typeof UFO.foList[id][UFO.req[i]] == "undefined") return false;
		}
		return true;
	},
	
	hasFlashVersion: function(major, release) {
		return (UFO.fv[0] > major || (UFO.fv[0] == major && UFO.fv[1] >= release)) ? true : false;
	},

	writeSWF: function(id) {
		var _fo = UFO.foList[id];
		var _e = document.getElementById(id);
		if (UFO.pluginType == "npapi") {
			if (UFO.uaHas("gecko") || UFO.uaHas("xml")) {
				while(_e.hasChildNodes()) {
					_e.removeChild(_e.firstChild);
				}
				var _obj = UFO.createElement("object");
				_obj.setAttribute("type", "application/x-shockwave-flash");
				_obj.setAttribute("data", _fo.movie);
				_obj.setAttribute("width", _fo.width);
				_obj.setAttribute("height", _fo.height);
				var _l = UFO.optAtt.length;
				for (var i = 0; i < _l; i++) {
					if (typeof _fo[UFO.optAtt[i]] != "undefined") _obj.setAttribute(UFO.optAtt[i], _fo[UFO.optAtt[i]]);
				}
				var _o = UFO.opt.concat(UFO.optExc);
				var _l = _o.length;
				for (var i = 0; i < _l; i++) {
					if (typeof _fo[_o[i]] != "undefined") UFO.createObjParam(_obj, _o[i], _fo[_o[i]]);
				}
				_e.appendChild(_obj);
			}
			else {
				var _emb = "";
				var _o = UFO.opt.concat(UFO.optAtt).concat(UFO.optExc);
				var _l = _o.length;
				for (var i = 0; i < _l; i++) {
					if (typeof _fo[_o[i]] != "undefined") _emb += ' ' + _o[i] + '="' + _fo[_o[i]] + '"';
				}
				_e.innerHTML = '<embed type="application/x-shockwave-flash" src="' + _fo.movie + '" width="' + _fo.width + '" height="' + _fo.height + '" pluginspage="http://www.macromedia.com/go/getflashplayer"' + _emb + '></embed>';
			}
		}
		else if (UFO.pluginType == "ax") {
			var _objAtt = "";
			var _l = UFO.optAtt.length;
			for (var i = 0; i < _l; i++) {
				if (typeof _fo[UFO.optAtt[i]] != "undefined") _objAtt += ' ' + UFO.optAtt[i] + '="' + _fo[UFO.optAtt[i]] + '"';
			}
			var _objPar = "";
			var _l = UFO.opt.length;
			for (var i = 0; i < _l; i++) {
				if (typeof _fo[UFO.opt[i]] != "undefined") _objPar += '<param name="' + UFO.opt[i] + '" value="' + _fo[UFO.opt[i]] + '" />';
			}
			var _p = window.location.protocol == "https:" ? "https:" : "http:";
			_e.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + _objAtt + ' width="' + _fo.width + '" height="' + _fo.height + '" codebase="' + _p + '//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + _fo.majorversion + ',0,' + _fo.build + ',0"><param name="movie" value="' + _fo.movie + '" />' + _objPar + '</object>';
		}
	},
		
	createDialog: function(id) {
		var _fo = UFO.foList[id];
		UFO.createCSS("html", "height:100%; overflow:hidden;");
		UFO.createCSS("body", "height:100%; overflow:hidden;");
		UFO.createCSS("#xi-con", "position:absolute; left:0; top:0; z-index:1000; width:100%; height:100%; background-color:#fff; filter:alpha(opacity:75); opacity:0.75;");
		UFO.createCSS("#xi-dia", "position:absolute; left:50%; top:50%; margin-left: -" + Math.round(parseInt(_fo.xiwidth, 10) / 2) + "px; margin-top: -" + Math.round(parseInt(_fo.xiheight, 10) / 2) + "px; width:" + _fo.xiwidth + "px; height:" + _fo.xiheight + "px;");
		var _b = document.getElementsByTagName("body")[0];
		var _c = UFO.createElement("div");
		_c.setAttribute("id", "xi-con");
		var _d = UFO.createElement("div");
		_d.setAttribute("id", "xi-dia");
		_c.appendChild(_d);
		_b.appendChild(_c);
		var _mmu = window.location;
		if (UFO.uaHas("xml") && UFO.uaHas("safari")) {
			var _mmd = document.getElementsByTagName("title")[0].firstChild.nodeValue = document.getElementsByTagName("title")[0].firstChild.nodeValue.slice(0, 47) + " - Flash Player Installation";
		}
		else {
			var _mmd = document.title = document.title.slice(0, 47) + " - Flash Player Installation";
		}
		var _mmp = UFO.pluginType == "ax" ? "ActiveX" : "PlugIn";
		var _uc = typeof _fo.xiurlcancel != "undefined" ? "&xiUrlCancel=" + _fo.xiurlcancel : "";
		var _uf = typeof _fo.xiurlfailed != "undefined" ? "&xiUrlFailed=" + _fo.xiurlfailed : "";
		UFO.foList["xi-dia"] = { movie:_fo.ximovie, width:_fo.xiwidth, height:_fo.xiheight, majorversion:"6", build:"65", flashvars:"MMredirectURL=" + _mmu + "&MMplayerType=" + _mmp + "&MMdoctitle=" + _mmd + _uc + _uf };
		UFO.writeSWF("xi-dia");
	},

	expressInstallCallback: function() {
		var _b = document.getElementsByTagName("body")[0];
		var _c = document.getElementById("xi-con");
		_b.removeChild(_c);
		UFO.createCSS("body", "height:auto; overflow:auto;");
		UFO.createCSS("html", "height:auto; overflow:auto;");
	},

	cleanupIELeaks: function() {
		var _o = document.getElementsByTagName("object");
		var _l = _o.length
		for (var i = 0; i < _l; i++) {
			_o[i].style.display = "none";
			for (var x in _o[i]) {
				if (typeof _o[i][x] == "function") {
					_o[i][x] = null;
				}
			}
		}
	}
};

if (typeof window.attachEvent != "undefined" && UFO.uaHas("ieWin")) {
	window.attachEvent("onunload", UFO.cleanupIELeaks);
}

// BOF Google Analytics // 

var pageTracker = _gat._getTracker("UA-4307098-1");
pageTracker._initData();
pageTracker._trackPageview();

// EOF Google Analytics //

acts={
	mediaPlayer: {
		movie:"flash/mediaplayer.swf",
		width:"200",
		majorversion:"7",
		build:"0",
		bgcolor:"#1a1a1a",
		id:"mediaplayer",
		xi:"true",
		ximovie:"flash/ufo.swf",
		flashvars:"shuffle=false&showdigits=false&showfsbutton=false&backcolor=0x1a1a1a&frontcolor=0xFFFFFF&lightcolor=0xFFFFFF&volume=100"
	}
}

bigPicture={
	height:0,
	width:0,
	count:0,
	current: 0,
	prev : function () {
		return (bigPicture.current == 0 ? bigPicture.count : bigPicture.current-1);
	},
	next : function () {
		return (bigPicture.current == bigPicture.count ? 0 : bigPicture.current+1);
	},
	init : function () {
		if (document.getElementById('imageNav')) {
			events.add(document.getElementById('prevImg').parentNode, 'click', function (e) {
				bigPicture.change(bigPicture.prev(), document.getElementById('image'+bigPicture.prev()).getAttribute('href'));
				//bigPicture.current = bigPicture.prev();
				events.cancelClick(e);
			});
			events.add(document.getElementById('nextImg').parentNode, 'click', function (e) {
				bigPicture.change(bigPicture.next(), document.getElementById('image'+bigPicture.next()).getAttribute('href'));
				//bigPicture.current = bigPicture.next();
				events.cancelClick(e);
			});
		}
		// image thumbs
		for (var i = 0; i <= bigPicture.count; i++) {
			if (document.getElementById('image'+i)) {
				events.add(document.getElementById('image'+i), 'click', function (e) {
						if (bigPicture.count > 0) {
							var num = Number(this.getAttribute('id').substring(5, 6));
							bigPicture.change(num, this.getAttribute('href'));
						}
						bigPicture.show();
						events.cancelClick(e);
					}
				);
				events.add(document.getElementById('image'+i), 'focus', function(e) {events.getTarget(e).blur()});
			}
		}
		events.add(document.getElementById('close'), 'click', bigPicture.hide);
	},
	show : function () {
		var height = bigPicture.height;
		var width = bigPicture.width;

		document.getElementById('bigPicture').style.height = height+"px";
		document.getElementById('bigPicture').style.width = width+"px";
		//document.getElementById('bigPicture').style.left = 380-(width/2)+"px";
		document.getElementById('bigPicture').style.marginLeft = (955-width)/2+"px";
		document.getElementById('bigPicture').style.top = 310-(height/2)+"px";

		if (bigPicture.count > 0) {
			document.getElementById('imageNav').style.margin = '0 auto';
			document.getElementById('imageNav').style.top = (bigPicture.height-50)+"px";
		}

		//document.getElementById('close').style.left = 360+(width/2)+"px";
		document.getElementById('close').style.marginLeft = (955-width)/2+width-20+"px";
		document.getElementById('close').style.top = 315-(height/2)+"px";

		// show the cloak
		cloak.showIt();
		window.scrollTo(0,0);
	},
	hide : function () {
		cloak.hideIt();

		var moveme = new Array('bigPicture', 'close');
		for (var i in moveme) {
			if (document.getElementById(moveme[i])) {
				//document.getElementById(moveme[i]).style.left = -700+"px";
				document.getElementById(moveme[i]).style.top = -700+"px";
			}
		}
	},
	change : function(num, url) {
		bigPicture.current = num;
		document.getElementById('bigPicture').style.backgroundImage = 'url('+url+')';

		if (bigPicture.count > 0) {
			document.getElementById('imageNav').getElementsByTagName('span')[0].innerHTML = num+1;
		}
	}
}

events.add(window, 'load', function () {
	// load the media player
	if (document.getElementById('mediaPlayer')) UFO.create(acts.mediaPlayer, 'mediaPlayer');

	bigPicture.init();

	// map pins
	if ( document.getElementById( 'map' ) ) {
		var pins = document.getElementById('map').getElementsByTagName('a');
		for (var x in pins) {
			if (pins[x].nodeName && pins[x].nodeName.toLowerCase() == 'a') events.add(pins[x], 'focus', function(e) {events.getTarget(e).blur()});
		}
	}

});

function sendEvent(typ,prm) {
	// check for the existence of the object and method - otherwise FF errors destroy everything (sort of)
	if (thisMovie("rotator").sendEvent) thisMovie("rotator").sendEvent(typ,prm);
};
function thisMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}
function getUpdate(typ,pr1,pr2) {
	var id = document.getElementById(typ);
	id.innerHTML = Math.round(pr1);
}
function setBookmark(url,str){
	if(str=='')str=url;
	if (document.all)window.external.AddFavorite(url,str);
	else alert('Press CTRL and D to add a bookmark to:\n'+str+'\n('+url+').');
}
