$(function(){
	/*
	 * setup corners
	 */
	//$('div#footer').corner('20px');
	//$('div#main').corner('10px');
	//$('div#sub_nav a').corner('10px');
	//$('div#home_text').corner('20px');
	$('div.banner_image').corner('20px');
	/*
	 * append extra span to all top nav links
	 * we use these spans to do the rounded corners
	 */
	$('ul.sf-menu li > a').append('<span class="corner topLeft"></span><span class="corner topRight"></span>');
	$('ul#sub_menu a:first').append('<span class="corner topLeft"></span><span class="corner topRight"></span>');
	$('ul#sub_menu a:last').append('<span class="corner bottomLeft"></span><span class="corner bottomRight"></span>');
	
	/*
	 * initialise siperfish drop down enhancement
	 */
	
	$('ul.sf-menu').superfish({
		pathLevels: 3,
		speed: 0
	});
	//hide children categories
	jQuery('ul#sub_menu ul ul').css('display', 'none');
	//show children categories of the current cat
	jQuery('ul#sub_menu li.current > ul').css('display', 'block');
	//show category parent ul of any selected cat
	jQuery('ul#sub_menu li.current').parent().css('display', 'block');
		
	/*
	 * add styles to every first p tag after H1 in the main content
	 */
	$('div#main_content h1+p').css({
		'color' : '#036cda',
		'font-size': '1.2em'								
	});
	$('div#main_content h1+p a').css('font-weight', 'bold');
	/*
	 * we need this extra rule incase a page banner is present
	 */
	$('div#page_banner+p').css({
		'color' : '#036cda',
		'font-size': '1.2em'								
	});
	$('div#main_content h1+p a').css('font-weight', 'bold');
	
	 
	/*
	 * automatically add css stryles to link types
	 */
	 // Add pdf icons to pdf links
	$("a[href$='.pdf']").addClass("pdf");	 
	// Add txt icons to document links (doc, rtf, txt)
	$("a[href$='.txt'], a[href$='.rft']").addClass("txt");	
	//add word icons
	$("a[href$='.doc']").addClass("word");
	// Add zip icons to Zip file links (zip, rar)
	$("a[href$='.zip'], a[href$='.rar']").addClass("zip"); 	
	// Add email icons to email links
	$("a[href^='mailto:']").addClass("email");
	//Add external link icon to external links - 
	$('a').filter(function() {
		//Compare the anchor tag's host name with location's host name
		return this.hostname && this.hostname !== location.hostname;
	 }).addClass("external");

	/*
	* setup smooth scroll on back to top links
	*/
	$('#top_link').click(function(e) {
		e.preventDefault();
		$.scrollTo(0,300);
	});
	
	/*
	 * setup page banner slide shows
	 */
	$('#page_banner').cycle({
		prev:   '#prev',
		next:   '#next',
		timeout: 6000,
		speed: 4000
	});
	$('#page_banner').css("display", "block");
	$('#home_banner').cycle({
		prev:   '#prev',
		next:   '#next',
		timeout: 6000,
		speed: 4000
	});
	$('#home_banner').css("display", "block");
	
	$("a[rel='signup']").colorbox({
		transition: 'fade',
		width: '500px',
		height: '500px',
		initialWidth: '500px',
		initialHeight: '500px',
		speed: 0
	});

	/*
	 * setup lighboxes, has an ie problem at the moment
	 */
	 // Select all links that contains lightbox in the attribute rel
	 //$('a[@rel*=lightbox]').lightBox(); 

});
