// control highlight and font size in text selector
$(document).ready(
function() 
{
	$('#manifesto .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', '');	
		}
		
	});
	
	$('#manifesto .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'));
			}
			
		}
	});
	
	$("#sharelink").click(function() 
	{
		$('#shareform').slideToggle("slow");
		return 0;
	});	
	
	$("#manifestobutton").click(function()
	{
		var name = $("input#Name").val();
		var email = $("input#Email").val();
		var home = $("input#Hometown").val();
		var occupation = $("input#Occupation").val();
		
		var submit = 1;
		
		if (name == "Name*" || name == "")
		{
			var submit = 0;
			$('#errormessage').html("Sorry we still need more information, enter your name.");
			return false;
		}
		
		if (email == "Email*" || email == "")
		{
			var submit = 0;
			$('#errormessage').html('Sorry we still need more information, enter your email.');
			return false;
		}
		
		if (home == "Hometown*" || home == "")
		{
			var submit = 0;
			$('#errormessage').html('Sorry we still need more information, enter your hometown.');
			return false;
		}
		
		if (occupation == "Occupation*" || occupation == "")
		{
			var submit = 0;
			$('#errormessage').html('Sorry we still need more information, enter your occupation.');
			return false;
		}
		
		if (submit == 1)
		{
			$("#action").attr('value', 'submit');
			$("form.manifesto").submit();
			return false;
		}
		
	});
	
	$("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', 18);
			$.cookie('textsize', 'medium', { path: '/' });	
			$('#medium').addClass("highlighted");	
		}
		else if ($(this).is(".large"))
		{
			$('html').css('font-size', 20);
			$.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', 18);
			$('#topNav li a').css('font-size', 15);
			$('#medium').addClass("highlighted");
		}
		else if (textSize == 'large')
		{
			$('html').css('font-size', 20);
			$('#topNav li a').css('font-size', 14);
			$('#large').addClass("highlighted");
		}
	}
	else
	{
		$('#small').addClass("highlighted");
	}
	
});

