// 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;
	});
	
	// 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.');
		}

	});

	// 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().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");
	});
	
	$(window).bind("load", function() { $("div.svw").slideView({easeFunc: "easeOutExpo", easeTime: 1200}); }); 
	
	
	$('#slideshow').cycle({ 
	    prev:   '#next', 
	    next:   '#prev', 
	    timeout: 0,
		before: onBefore
	});
	
	// hide previous and next if no slideshow.
	
	if ($('#slideshow').length == 0)
	{
		//alert('no slideshow');
		$('#imagenav').css('display', 'none');
	}
	
	function onBefore()
	{
		$('#caption').html(this.alt);
	}
});
