$(document).ready(function(){
  $('#contactBox input,#contactBox textarea,#contactPageForm input,#contactPageForm textarea').focus(function(){
    if($(this).val() == 'Enter '+$(this).attr('id').replace(/contact_/, '')+'..') {
      $(this).val('');
    }
  }).blur(function(){
    if(this.value == '') {
      $(this).val('Enter '+$(this).attr('id').replace(/contact_/, '')+'..');
    }
  });

  $('#banner .bannerSwitcherButton').each(function(i, button) {
    $(button).bind('click', function() {
      $('.bannerSwitcherButtonSelected').removeClass('bannerSwitcherButtonSelected');
      $(this).addClass('bannerSwitcherButtonSelected');
      ++i;
      // As there are only 4 images we don't want i going over 4 as it will show a blank
      if(i > 4) { i = 1; }
      var banner = $('#banners li:nth-child('+i+') img');
      $('#banner').css({background:'url('+$(banner).attr('src')+')'}).children('h2').html((banner).attr('alt'));

      j = i;

      return false;
    });
  });

		bannerSwitch =
		{
				init: function()
				{
						//Load the first banner image
						$('.bannerSwitcherButton').click(function(){
								bannerSwitch.load($(this));
						});
						bannerSwitch.load($('.bannerSwitcherButton:first'));
				},
				load: function(e)
				{
						clearTimeout(bannerSwitch.timer);
						var i = e.index('.bannerSwitcherButton');
						$('.bannerSwitcherButton').removeClass('bannerSwitcherButtonSelected').
								filter(e).addClass('bannerSwitcherButtonSelected');
						var banner = $('#banners>li:eq('+i+')>img');
						$('#banner').fadeOut(250,function(){
								$(this).css({
										background: 'url('+banner.attr('src')+') no-repeat right'
								}).fadeIn(250).children('h2').html(banner.attr('alt'));
						});
						bannerSwitch.timerStart();
				},
				next: function()
				{
						bannerSwitch.load(
								$('.bannerSwitcherButtonSelected').next('.bannerSwitcherButton').length?
										$('.bannerSwitcherButtonSelected').next('.bannerSwitcherButton'):
										$('.bannerSwitcherButton:first')
						);
				},
				timerStart: function(){
						bannerSwitch.timer = setTimeout(function(){
								bannerSwitch.next();
						},6000);
				}
		}

		bannerSwitch.init();

});

