// control highlight and font size in text selector
$(document).ready(
function() 
{
	$('a[rel*=external]').click(function() {
		window.open(this.href);
		return false;
	});
	
	$('a.print').click(function() {
		window.print();
		return false;
	});
	
	$('#donate').click(function() {
		window.open(($(this).children().next().attr('href')));
		return false;
	});
	
	$('#newsletter').click(function() {
		window.open(($(this).children().next().attr('href')));
		return false;
	});
	
	// add a "rel" attrib if Opera 7+
	if(window.opera) {
		if ($("a.jqbookmark").attr("rel") != ""){ // don't overwrite the rel attrib if already set
			$("a.jqbookmark").attr("rel","sidebar");
		}
	}

	$("a.bookmark").click(function(event){
		event.preventDefault(); // prevent the anchor tag from sending the user off to the link
		var url = this.href;
		var title = document.title;
		
		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url, "");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite( url, title);
		} else if(window.opera) { // Opera 7+
			return false; // do nothing - the rel="sidebar" should do the trick
		} else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
			 alert('Unfortunately, this browser does not support the requested action,'
			 + ' please bookmark this page manually.');
		}

	});
		
	
	$("a.textsize").click(function() 
	{
		$("a.textsize").removeClass("highlighted");
		
		// change font size
		if($(this).is(".small")) 
		{
			$('html').css('font-size', 16);
			$.cookie('textsize', 'small', { path: '/' });
			$('#small').addClass("highlighted");
		} 
		else if ($(this).is(".medium"))
		{
			$('html').css('font-size', 17);
			$.cookie('textsize', 'medium', { path: '/' });	
			$('#medium').addClass("highlighted");	
		}
		else if ($(this).is(".large"))
		{
			$('html').css('font-size', 19);
			$.cookie('textsize', 'large', { path: '/' });
			$('#large').addClass("highlighted");
		}
	});
		
	// recall which text size to use if already chosen (uses jquery cookie plugin)
	var textSize = $.cookie('textsize');
	//alert(textSize);
	
	if ((textSize != null) && (textSize != ''))
	{
		if (textSize == 'small')
		{
			$('html').css('font-size', 16);
			$('#topNav li a').css('font-size', 16);
			$('#small').addClass("highlighted");
		}
		else if (textSize == 'medium')
		{
			$('html').css('font-size', 17);
			$('#topNav li a').css('font-size', 15);
			$('#medium').addClass("highlighted");
		}
		else if (textSize == 'large')
		{
			$('html').css('font-size', 19);
			$('#topNav li a').css('font-size', 14);
			$('#large').addClass("highlighted");
		}
	}
	else
	{
		$('#small').addClass("highlighted");
	}

	// inner form label
	$('#newsletter .clickable').focus(function()
	{
		// for text values
		if($(this).attr('name') == $(this).attr('value') || $(this).attr('alt') == $(this).attr('value'))
		{
			$(this).attr('value', '');	
		}
		
		// for textarea inner values
		if($(this).attr('name') == $(this).html())
		{
			$(this).attr('value', '');	
		}
		
	});
	
	// inner form label
	$('#newsletter .clickable').blur(function()
	{
		if($(this).attr('value') == '')
		{
			//alert('no value');
			if ($(this).attr('alt') != "")
			{
				$(this).attr('value', $(this).attr('alt'));
			}
			else
			{
				$(this).attr('value', $(this).attr('name'));
				$(this).html($(this).attr('name'));
			}
			
		}
	});
	
	// comment form on news
	$("a.comments").click(function ()
	{
		$(this).parent().next().slideToggle("fast");
		return false;
	});
	
	$(function() 
	{
		$(".contact_submit").hide();
	});
	
	$("#contact_post").click(function ()
	{
		$('#postform').slideToggle("fast");
	});
	
	$("#contact_sms").click(function ()
	{
		$('#smsform').slideToggle("fast");
	});
	
	$("#contact_telephone").click(function ()
	{
		$('#telephoneform').slideToggle("fast");
	});
	
	$("#friends h2.title").click(function () {
		$(this).next().slideToggle("fast");
		return false;
	});
	
	
});

function showRecaptcha(element, submitButton, recaptchaButton, themeName) 
{
  Recaptcha.destroy();
  Recaptcha.create("6Lf6MwsAAAAAAD61L09W35-lsiQNYHJDcTKGnoTI", element, 
  {
        theme: themeName,
        tabindex: 0,
        callback: Recaptcha.focus_response_field
  });
  $(".contact_submit").hide();
  $(".recaptcha_required").show();
  $("#"+recaptchaButton).hide();
  $("#"+submitButton).show();
}