function imagestyle() {
	if(!(jQuery.browser.msie&&parseInt(jQuery.browser.version,10)<8&&parseInt(jQuery.browser.version,10)>4)){
		$('a.enlarge').append('<span class="click">Click to enlarge</span>');
		$('a.enlarge').wrapInner('<div />');
		$('a.enlarge').addClass('processed');
		$('#container a.enlarge img:not(.system, form img, .buttonbar img, .buttons img, #gallery img)').each(function(){
			if($(this).attr('width') != ''){$(this).parent().css({border:$(this).attr('width')+'px'});}
			if($(this).attr('height') != ''){$(this).parent().css({border:$(this).attr('height')+'px'});}
			if($(this).attr('border') != ''){$(this).parent().css({border:$(this).attr('border')+'px solid #000000'}).removeAttr('border');}
			if($(this).attr('vspace') != ''){$(this).parent().css({marginTop:$(this).attr('vspace')+'px',marginBottom:$(this).attr('vspace')+'px'}).removeAttr('vspace');}
			if($(this).attr('hspace') != '' && $(this).attr('align') == 'left'){$(this).parent().css({marginRight:$(this).attr('hspace')+'px'});}
			if($(this).attr('hspace') != '' && $(this).attr('align') == 'right'){$(this).parent().css({marginLeft:$(this).attr('hspace')+'px'});}
			if($(this).attr('hspace') != '' && $(this).attr('align') == ''){$(this).parent().css({marginRight:$(this).attr('hspace')+'px',marginLeft:$(this).attr('hspace')+'px'});}
			$(this).removeAttr('hspace');
			if($(this).attr('align') != ''){$(this).parent().css({float:$(this).attr('align')}).removeAttr('align');}
		});
	}
	$('#container img:not(.system, .processed img, form img, .buttonbar img, .buttons img, #gallery img)').each(function(){
		if($(this).attr('width') != ''){$(this).css({border:$(this).attr('width')+'px'});}
		if($(this).attr('height') != ''){$(this).css({border:$(this).attr('height')+'px'});}
		if($(this).attr('border') != ''){$(this).css({border:$(this).attr('border')+'px solid #000000'}).removeAttr('border');}
		if($(this).attr('vspace') != ''){$(this).css({marginTop:$(this).attr('vspace')+'px',marginBottom:$(this).attr('vspace')+'px'}).removeAttr('vspace');}
		if($(this).attr('hspace') != '' && $(this).attr('align') == 'left'){$(this).css({marginRight:$(this).attr('hspace')+'px'});}
		if($(this).attr('hspace') != '' && $(this).attr('align') == 'right'){$(this).css({marginLeft:$(this).attr('hspace')+'px'});}
		if($(this).attr('hspace') != '' && $(this).attr('align') == ''){$(this).css({marginRight:$(this).attr('hspace')+'px',marginLeft:$(this).attr('hspace')+'px'});}
		$(this).removeAttr('hspace');
		if($(this).attr('align') != ''){$(this).css({float:$(this).attr('align')}).removeAttr('align');}
	});
}

//REGEX FOR EXTERNAL LINKS
var regex = RegExp('^(?:f|ht)tps?://(?!' + location.hostname + ')');

$('#outer').removeClass('nojs');

$(document).ready(function(){

// MODIFY HTML CONTENT
	// DISPLAY JAVASCRIPT FRIENDLY STYLES

	// ADD nav CLASS TO FIRST UL IN divide DIV
	$('#divide ul:first').addClass('nav');
	$('#footer div.content ul:first').addClass('nav');

	// ADD LEFT & RIGHT CAPS TO NAVIGATION ITEMS
	$('#divide > ul li a').each(function(){
		$(this).html('<span class="left"></span><span class="main">' + $(this).text() + '</span><span class="right"></span>');
	});

	// ADD HEADERS & FOOTERS TO FEATURE BOXES
	$('#body div.box').each(function(){
		var c = $(this).html();
		$(this).html('<div class="head"><div class="foot">' + c + '</div></div>');
	});

	//ADD MAILTO LINK TO p.contactdetail.email ELEMENTS
	$('p.contactdetail.email').each(function(){
		$(this).wrapInner('<a href="mailto:'+$(this).text()+'" />');
	});

	//ADD TWITTER BIRD
	if($('#social a.twitter').length != 0){
		$('#social').append('<div id="twitterer"></div>');
	}

	//ADD SHADOW TO TOP TEXT
	$('div.featuretext').clone().appendTo('#header').addClass('shadow');

	// REWRITE NAV CODE
	$('#divide > ul li ul').wrap('<div class="subnav" />');
	$('#divide > ul li div.subnav ul').wrap('<div class="content" />');
	$('#divide > ul li div.subnav').append('<div class="foot"><span class="left"></span><span></span><span class="right"></span></div>');
	//ADD VISUAL INDICATOR OF SUB NAVIGATION
	$('#divide > ul li div.subnav').before('<span class="dropdown"></span>');

	//OPEN/CLOSE LOGIN FORM SLIDER
	$('#loginform').css({display:'block'});
	$('#login').css({top:$('#loginform').outerHeight()*-1+'px'});
	$('#login div.slidetab a.show').clone().appendTo('#login div.slidetab').attr('class','hide').css({display:'none'}).text('^^^ Hide ^^^');
	$('#login div.slidetab a.show').click(function(e){
		e.preventDefault();
		$(this).hide();
		$('#login').animate({top:0},{duration: 1000, easing:'easeOutBounce'});
		$('#login div.slidetab a.hide').fadeIn();
	} );
	$('#login div.slidetab a.hide').click(function(e){
		e.preventDefault();
		$(this).hide();
		$('#login').animate({top:$('#loginform').outerHeight()*-1},{duration: 1000, easing:'easeOutBounce'});
		$('#login div.slidetab a.show').fadeIn();
	} );

	// ANIMATE NAVIGATION DROP DOWNS
	$('#divide ul.nav li').each(function(){

		$(this).mouseenter(function(){
			$(this).find("div.subnav:first").css({zIndex:10}).stop(true,true).slideDown(150);
		});

		$(this).mouseleave(function(){
			$(this).find("div.subnav:first").css({zIndex:0}).stop(true,true).delay(150).slideUp(150);
		});

	});

	// ADD DECORATIVE QUOTE MARKS TO BLOCKQUOTES
	$('blockquote').append('<div class="quote open"></div><div class="quote close"></div>');

	//FADE NAV IN
	$('#divide ul').hide().fadeIn(1000);

	//ADD LISTING LINKS TO li ELEMENT
	$('ul.listing li').css({cursor:'pointer'});
	$('ul.listing li').click(function(){window.location = $(this).find('a:first').attr('href'); return false;});

	imagestyle();

	// >IE6 ONLY
	if((jQuery.browser.msie&&parseInt(jQuery.browser.version,10)<7&&parseInt(jQuery.browser.version,10)>4)){

		$('.logo').supersleight({shim: 'images/x.gif'});
		$('.logo_mini').supersleight({shim: 'images/x.gif'});
		$('#banner').supersleight({shim: 'images/x.gif'});
		$('#twitterer').supersleight({shim: 'images/x.gif'});

	}
	//END IE6 ONLY

	// ACTIVATE ACCORDION
if ($('#accordion').length != 0){
	$('#accordion').accordion({active:false,autoHeight:false});
}

	//SET BOXES TO EQUAL HEIGHTS
	$('#body div.box.set1 div.foot').equalHeights();

	$('a[rel^=gallery]').colorbox({photo:true});
	$("a.iframe").colorbox({
		iframe:true,
		title: function(){
			var url = $(this).attr('href');
			return '<a href="'+url+'" target="_blank">Open In New Window</a>';
		},
		width:800,
		height:600
	});

var total = $('#slider img').length;
var rand = Math.floor(Math.random()*total);
$('#slider').nivoSlider({
		effect:'boxRandom,boxRain,boxRainReverse,boxRainGrow,boxRainGrowReverse',
		pauseOnHover:false,
		pauseTime:7000,
		animSpeed:500,
		boxCols: 8,
		boxRows: 4,
		slices:30,
		startSlide:rand
	});

}); // END DOCUMENT READY

//SCROLL MENU WHEN IT HITS WINDOW TOP
var nav = $('#divide');
if (nav.length != 0){
	var navpos = nav.offset();
	var navposstart = navpos.top;
	$(document).scroll(function(){
		if (document.documentElement.scrollTop > navposstart || self.pageYOffset > navposstart) {
			$('#divide').css({position:'fixed'});
			$('#divide').css({top:'0px'});
			$('#backtotop').fadeIn(300);
		} else if (document.documentElement.scrollTop < navposstart || self.pageYOffset < navposstart) {
			$('#divide').css({position:'absolute'});
			$('#divide').css({top:navposstart+'px'});
			$('#backtotop').fadeOut(300);
		}
	});
	$('#backtotop').click(function(e){
		e.preventDefault();
		if (document.documentElement.scrollTop > navposstart || self.pageYOffset > navposstart) {
			$('html').animate({scrollTop:0},1000); // PAGE TOP
	//		$('html').animate({scrollTop:navposstart},1000); // CONTENT TOP
		}
	});
}

