$(function(){

	// Setup font resizer
	$('#layer-body').fontresizer({excluded: '#layer-menu-main, #wc-breadcrumbs'});
	
	// Fix calendar font size
	/*
	$('.link-resize').click(function(){
		$('#layer-calendar > table > tbody > tr > td, #layer-calendar > table > tbody > tr > th').css('font-size', '12px');
		$('#layer-calendar > h4').css('font-size', '13px');
	});
	$('#layer-calendar > table > tbody > tr > td, #layer-calendar > table > tbody > tr > th, #layer-calendar > h4').css('font-size', '12px');
	$('#layer-calendar > h4').css('font-size', '13px');
	*/
	// Initialise collapsible toggle 				
	$('a.toggle-item').click(function(){
		if($(this).hasClass('collapse')) {
			$(this).removeClass('collapse');
			$('#'+$(this).attr('rel')).show();
			// Toggle Hide/Show wordings
			$('span.expand', this).hide();	
			$('span.collapse', this).show();
			
		} else {
			$(this).addClass('collapse');
			$('#'+$(this).attr('rel')).hide();
			// Toggle Hide/Show wordings
			$('span.expand', this).show();	
			$('span.collapse', this).hide();				
		}		
		return false;
	});		
	// Hide default wordings 
	$('a.toggle-item').each(function(){
		var toggleItem = $('#'+$(this).attr('rel'));
		if(toggleItem.hasClass('hidden')){
			toggleItem.removeClass('hidden');
			
			$(this).addClass('collapse');
			toggleItem.hide();
			$('span.collapse', this).hide();
		}
		else {
			
			$('span.expand', this).hide();
		}
	});	
	
	//$('.style-tabs li a').corner('5px top');	
	
	// menu
	$('#layer-menu > ol > li > a').corner('5px top cc:#741372');	
	$('#layer-menu > ol > li > ol').corner('5px tr br bl');

	//$('#layer-top-toolbar > ul > li > a').corner('5px cc:#741372');	

	//$('.link-resize').corner('5px cc:#741372');
	
	$('#listing-our-sites').corner('5px tl br bl cc:#741372');
	
	$('#link-our-sites').hover(function(){
		$(this).css('background-color', '#953193');
		$('#listing-our-sites').show();
	},function(){
		$(this).css('background-color', '#7B2079');
		$('#listing-our-sites').hide();
	});
	
	$('#listing-our-sites').hover(function(){
		$('#link-our-sites').css('background-color', '#953193');
		//$('#link-our-sites').uncorner().corner('5px top').css('background-color', '#953193');
		$(this).show();
	},function(){
		$('#link-our-sites').css('background-color', '#7B2079');
		//$('#link-our-sites').uncorner().corner('5px').css('background-color', '#7B2079');
		$(this).hide();
	});	
	
	/*
	// pullquote functions
	$('span.pullquote-left').each(function() {
		var parentTag = $(this).parent();
		var newNode = $('<blockquote class="pulledquote"></blockquote>');
		
		$(this).removeClass('pullquote-left');
		$('<span class="pulledquote-text>'+$(this).html()+'</span>').appendTo(newNode);
		$('<span class="pullquote-bottom"></span>').appendTo(newNode);
		newNode.removeClass('pullquote-left');
		newNode.addClass('pulledquote-left').prependTo( $(this).parent());
		
	});
	
	$('span.pullquote-right').each(function() {
		var parentTag = $(this).parent();
		var newNode = $('<blockquote class="pulledquote"></blockquote>');
		
		$(this).removeClass('pullquote-right');
		newNode.html('<span class="pulledquote-text>'+$(this).html()+'</span>');
		$('<span class="pullquote-bottom"></span>').appendTo(newNode);
		newNode.removeClass('pullquote-right');
		newNode.addClass('pulledquote-right').prependTo( $(this).parent());
	});
	
	$('span.pullquote-center').each(function() {
		var newNode = $('<blockquote class="pulledquote"></blockquote>');
		
		$(this).removeClass('pullquote-center');
		newNode.html('<span class="pulledquote-text>'+$(this).html()+'</span>');
		$('<span class="pullquote-bottom"></span><span style="display:block;clear:both></span>"').appendTo(newNode);
		newNode.removeClass('pullquote-center');
		newNode.addClass('pulledquote-center').prependTo($(this).parent());
	});
	*/
	
	$('.link-collapsible').click(function(){
		if($(this).hasClass('link-collapse')) {
			$(this).removeClass('link-collapse').addClass('link-expand');
			$($(this).attr('href')).show();
		} else {
			$(this).addClass('link-collapse').removeClass('link-expand');
			$($(this).attr('href')).hide();				
		}		
		return false;
	});	
	
	// Open new window (pop up)
	$("a[rel='external']").click(function(){
		var sHref = $(this).attr('href');
		if(sHref.indexOf('http://') < 0) sHref = 'http://' +  sHref;
		window.open(sHref);
		return false;
	});
	
});	