jQuery(document).ready(function() {
	$("#text-search li.textsize a").click(function () {
	  $("#text-search li.textsize a").removeClass("active");
      $(this).toggleClass("active");
    });
    
    // cursor change to hand when over a form submit link
    // which is not a button but rendered as text.
    $("form input.form-submit,#ga_submit").hover(function() {
		$(this).css("cursor","pointer");
	});
	
	
	
	// 	Donation forms -------------
	
	/*	single / monthly form swap
		 
	*/
	$("input.donation_type").click(function() {
		if($(this).val() == 'monthly') {
			$("#donationdiv2").show();
			$("#donationdiv1").hide();
		} else {
			$("#donationdiv1").show();
			$("#donationdiv2").hide();
		}
	});
	
	
	/*	Other field 
		Only show when the Other... radio button
		is ticked 
	*/
	
	$(".form-radios input[type=radio]").click(function() {
		if($(this).val() == 'other') {
			if($("input.donation_type:checked").val() == 'monthly')
				$("#edit-varprice-arb-1-wrapper").show("fast");
			else
				$("#edit-varprice-arb-wrapper").show("fast");
		} else {
			if($("input.donation_type:checked").val() == 'monthly')
				$("#edit-varprice-arb-1-wrapper").hide("fast");
			else
				$("#edit-varprice-arb-wrapper").hide("fast");
		}
	});
	
	
/*
	rollover image border change
	
	$(".upcomingjobs .frame a").hover(function() {
		$(this).parent().addClass("picframe_hover_jobs");
	},function() {
		$(this).parent().removeClass("picframe_hover_jobs");
	
	});
*/
	var ga_tax_rate = 22;
	
	$('#ga_calculator #ga_submit').click(function(e) {
		e.preventDefault();
		
		var donation = parseInt($('#ga_calculator input#gift').val());
		var total = 0;
		
		if( ! isNaN(donation)) {
			total = (donation * (100 / 78)) *100;
		
			if(ga_tax_rate == 22) {
				$('#ga_calculator #self').val('');
				$('#ga_calculator #net').val('');
			
			} else {
			
				var selfReturn = (0.18*total)/100;
				var netgift = donation - selfReturn;
				//net gift is the overall cost to the donor
				selfReturn = selfReturn*100;
				selfReturn = Math.round(selfReturn).toString();
				//decimalise selfReturn figure
				var selfPounds = selfReturn.substring(0, selfReturn.length-2);
				var selfPence = selfReturn.substring(selfReturn.length-2, selfReturn.length);
				selfReturn = selfPounds + "." + selfPence;
				//decimalise netgift figure
				netgift = netgift*100;
				netgift = Math.round(netgift).toString();
				var netPounds = netgift.substring(0, netgift.length-2);
				var netPence = netgift.substring(netgift.length-2, netgift.length);
				netgift = netPounds + "." + netPence;
				$('#ga_calculator #self').val(selfReturn);
				$('#ga_calculator #net').val(netgift);				
			
			}
			
			total = Math.round(total).toString();
			var totPounds = total.substring(0, total.length-2);
			var totPence = total.substring(total.length-2, total.length);
			var total = totPounds + "." + totPence;

			$('#ga_calculator input#for_us').val(total);
		}
		
	});

	$('#ga_calculator .radios input').click(function() {
		ga_tax_rate = parseInt($(this).attr('value'));
	});

/*

//if 22% tax rate
if (the_tax_rate=="22"){
total=(gift*(100/78))*100;
document.calculator.self.value="";
document.calculator.net.value="";
}
//if 40% tax rate
else{
total=(gift*(100/78)*100);
selfReturn=(0.18*total)/100;
netgift=gift-selfReturn;
//net gift is the overall cost to the donor
selfReturn=selfReturn*100;
selfReturn=Math.round(selfReturn).toString();
//decimalise selfReturn figure
selfPounds = selfReturn.substring(0, selfReturn.length-2);
selfPence = selfReturn.substring(selfReturn.length-2, selfReturn.length);
selfReturn = selfPounds + "." + selfPence;
//decimalise netgift figure
netgift=netgift*100;
netgift=Math.round(netgift).toString();
netPounds = netgift.substring(0, netgift.length-2);
netPence = netgift.substring(netgift.length-2, netgift.length);
netgift = netPounds + "." + netPence;
document.calculator.self.value=selfReturn;
document.calculator.net.value=netgift;
}
//total is the amount Charity facts get when gift aid is included
total=Math.round(total).toString();
//decimalise total figure
totPounds = total.substring(0, total.length-2);
totPence = total.substring(total.length-2, total.length);
total = totPounds + "." + totPence;
document.calculator.for_us.value=total;
if(gift==0){
document.calculator.self.value="";
document.calculator.net.value="";
document.calculator.for_us.value="";
}
return false;

			<form name="ga_calculator" id="ga_calculator" method="get" action="#">
				<div class="label_input">
					<label for="gift">Your donation: &#163;</label> 
					<input type="text" name="gift" id="gift" size="10" class="giftaid_form" /><br />
				</div>
				<div class="label_input">
					<label for="tax_rate">Your tax rate:</label>
					<div class="radios">
						<input type="radio" name="tax_rate" id="tax_rate" size="10" value="22" checked />22%<br /> 
						<input type="radio" name="tax_rate" id="tax_rate" size="10" value="40" />40%
					</div>
				</div>
				<div class="label_input">
					<input id="ga_submit" type="submit" name="submit" value="Calculate" /> 
				</div>
				
				<div class="label_input">
					<label for="for_us">Trinity will<br />receive: &#163;</label> 
					<input type="text" name="for_us" id="for_us" size="10" class="giftaid_form" /> 
				</div>

			</form>

*/







/*
<div id="exposed-filter"/>
<div class="">
<div class="dv3 one">
<div class="frame">
<a href="/job/day-services-co-ordinator">
<img src="http://trinityhospice.fabrikbrands.com/sites/default/files/imagecache/medium/events_img5.jpeg" alt="Job Thumbnail" title="job thumbnail"/>
</a>
</div>

*/
$('.dv3 a').mouseover(function(){
	$(this).css('text-decoration','none');
});

$('.rml').mouseover(function(){
	$(this).css('text-decoration','underline');
});

});
