$(function()
{







		
	// external links
	$('a.external').click(function()
	{
		$(this).attr('target', '_blank');
	});
	
	
	var wrapper = $('#contentWrap');	

	// text sizing up
	$('#control_textUp').click(function()
	{
		var sizeNow = parseFloat($(wrapper).css('font-size'));
		
		if ( sizeNow <= 15 ) // make it big
		{
			$(wrapper).css({'font-size':'1.2em', 'line-height':'1.7em'});
		}
		
		return false;
	});
	
	// text sizing down
	$('#control_textDown').click(function()
	{
		var sizeNow = parseFloat($(wrapper).css('font-size'));

		if ( sizeNow >= 11 || sizeNow=='1.2') // make it normal
		{
			$(wrapper).css({'font-size':'1em', 'line-height':'1.4em'});
		}
		return false;
	});


	
	

	
	

	// header images
	//$('#bannerImages').load('/_banners.php', function()
	//{
	//	setTimeout(function(){
			$('#bannerImages').cycle({
				fx: 'fade', 
				speed: 1500, 
				timeout: 7000
			});
	//	},1000);	
	//});



	
	
	
	
	// dropdowns main nav
	$('#mainNavigation li.mainMenu').mouseover(function()
	{
		$('ul', $(this)).css({'display':'block'});
	}).mouseout(function()
	{
		$('ul', $(this)).css({'display':'none'});
	});
	
	
	
	
	
	
	
	
	
	
	// dynamic links - town guide
	$('#download_townGuide').click(function()
	{
		window.location = '/totnes-town-guide';
	})
	.mouseover(function()
	{
		$(this).addClass('bigButtonOver');
	})
	.mouseout(function()
	{
		$(this).removeClass('bigButtonOver');
	});


	// dynamic links - town map
	$('#download_townMap')
	.mouseover(function()
	{
		$(this).addClass('bigButtonOver');
	})
	.mouseout(function()
	{
		$(this).removeClass('bigButtonOver');
	});
	




	
	
	
	
	// last sidebar panel should have no bottom border  
	$('.sidebarPanelWrap:last').css({'border-bottom':'0'});
	
	// last '.block' - take bottom border away
	$('.block:last').css({'border':'none'});
	
	// assign classes to form submit buttons
	$('form input:submit').addClass('formSubmit');
	
	
	
	
	
	
	
	// css (invalid - would fail validation against 2.1)
	$('#bannerQuoteWrap').css({'opacity':'0.85'});
	
	
	
	
	// history page, dt toggles dd
	$('dl.numberedNicely dt').click(function()
	{
		var x = $(this).next().attr('id');
		var y = x.replace(/mapInfoDescription_/, '');
		$(this).next().toggle();
		$('#historyMapImageWrap_' + y).toggle();
	});

	
	// gallery lightbox
	if ( document.getElementById('galleryWrap') )
	{
		$('#galleryWrap a').lightbox();
	}
	
	
	
	
	// accommodation stars
	$('#accommodationStarSearchWrap a')
	.mouseover(function()
	{
		$(this).removeClass('colourMe').addClass('colourMeLight');
	})
	.mouseout(function()
	{
		$(this).removeClass('colourMeLight').addClass('colourMe');
	});
	
	
	
	// accommodation search form
	$('#accommodationSearchForm').submit(function()
	{
		var x = $('#accommodationSearchTerm').val();
		if ( x.length < 1 )
		{
			alert('Please enter a search term!');
			return false;
		}
	});
	
	
	// accommodation image nav
	$('#accommodationImageNavigation a').click(function()
	{
		var h = $(this).attr('href');
		$('#accommodationDetailMainImage').attr('style', 'background-image:url(\'' + h + '\');');
		return false;
	});
	
	
	
	
	$('#v_code_why').click(function(){
		$('#v_code_why_text').fadeIn();
		
		return false;
	});






if ( $.browser.msie && $.browser.version <= 7 )
{
	$('.block').css({'padding-top':'0px'});
	$('.block img').css({'margin-top':'10px'});

	$('#ie7bs img').css({'margin-top':'25px'});

}



});
