// JavaScript Document
(function($) {
	$(document).ready(function(){
		$('.date-prev a').html('<img src="/sites/default/files/calendar-arrow-left.png" />');
		$('.date-next a').html('<img src="/sites/default/files/calendar-arrow-right.png" />');


		// Reset Font Size
		var maxIncrease=3;
		var thisIncrease=1;
		var originalFontSize = $('#content').css('font-size');
		var originalLineHeight = $('#content').css('line-height');
			$(".resetFont").click(function(){
			$('#content').css('font-size', originalFontSize);
			$('#content').css('line-height', originalLineHeight);
			thisIncrease=1;
		});
		// Increase Font Size
		$(".increaseFont").click(function(){
		
			if (thisIncrease>=maxIncrease) return false;
		
			var currentFontSize = $('#content').css('font-size');
			var currentFontSizeNum = parseFloat(currentFontSize, 10);
			var newFontSize = currentFontSizeNum*1.2;

			var currentLineHeight = $('#content').css('line-height');
			var currentLineHeightNum = parseFloat(currentLineHeight, 10);
			var newLineHeight = currentLineHeightNum*1.2;

			$('#content').css('font-size', newFontSize);
//			$('#content').css('line-height', newLineHeight);
			thisIncrease++;
			return false;
		});
		// Decrease Font Size
		$(".decreaseFont").click(function(){
			var currentFontSize = $('#content').css('font-size');
			var currentFontSizeNum = parseFloat(currentFontSize, 10);
			var newFontSize = currentFontSizeNum*0.8;
			$('#content').css('font-size', newFontSize);
			$('#content').css('line-height', newFontSize);
			return false;
		});
		
		//join address functionality
		$("#edit-submitted-same-as-billing-1").click(function(){
			$("#edit-submitted-billing-name").val($("#edit-submitted-name").val());
			$("#edit-submitted-billing-street-address").val($("#edit-submitted-street-address").val());
			$("#edit-submitted-billing-city").val($("#edit-submitted-city").val());
			$("#edit-submitted-billing-state").val($("#edit-submitted-state").val());
			$("#edit-submitted-billing-zip-code").val($("#edit-submitted-zip-code").val());
			$("#edit-submitted-billing-phone").val($("#edit-submitted-phone").val());
		});
		
		//put repeat info at the end for the When field on Event pages
		var s=$('.content .field-name-field-when').html();
		if ( s && s.indexOf('Repeat') >0 ) {
			var s = $('.content .field-name-field-when div.field-items div div').html();
			$('.content .field-name-field-when div.field-items div div').remove();
			$('.content .field-name-field-when div.field-items .field-item').first().prepend('Starts ');
			$('.content .field-name-field-when div.field-items').append('<div>' +s+ '</div>');
		}

		//put repeat info at the end for the When field on Progam listings
		var s=$('.content .content .views-field-field-when').html();
		if ( s && s.indexOf('Repeat') >0 ) {
			var s = $('.content .content .views-field-field-when div.field-content div').html();
			$('.content .content .views-field-field-when div.field-content div').remove();
			$('.content .content .views-field-field-when div.field-content').first().prepend('Starts ');
			$('.content .content .views-field-field-when div.field-content').append('<div>' +s+ '</div>');
		}

	});
})(jQuery)

;

