//rotator
	
		$(document).ready(function(){
		  var currentPosition = 0;
		  var slideWidth = 650;
		  var infoWidth = 300;
		  var slides = $('.slide');
		  var infos = $('.info');
		  var numberOfSlides = slides.length;
		  // Remove scrollbar in JS
		  $('#overview').css('overflow', 'hidden');
		  $('#details').css('overflow', 'hidden');

		  // Wrap all .slides with #slideInner div
		  // Float left to display horizontally, readjust .slides width
		  slides
		  .wrapAll('<div id="slideInner"></div>')
		  .css({
			'float' : 'left',
			'width' : slideWidth
		  });
		  infos
		  .wrapAll('<div id="infoInner"></div>')
		  .css({
			'float' : 'left',
			'width' : infoWidth
		  });
		  // Set #slideInner width equal to total width of all slides
		  $('#slideInner').css('width', slideWidth * numberOfSlides);
		  $('#infoInner').css('width', infoWidth * numberOfSlides);
		  // Insert left and right arrow controls in the DOM
		  $('#controlbox')
		  	.append('<span class="control" id="rightControl">Move right</span>')
			.append('<span class="control" id="leftControl">Move left</span>');
		  // Hide left arrow control on first load
		  manageControls(currentPosition);
		  // Create event listeners for .controls clicks
		  $('.control')
			.bind('click', function(){
			$('#slideInner').stopTime('slide');
			$('body').oneTime(14500, 'slide2', newsTimer);
			// Determine new position
			  currentPosition = ($(this).attr('id')=='rightControl')
			? currentPosition+1 : currentPosition-1;

			  // Hide / show controls
			  manageControls(currentPosition);
			  // Move slideInner using margin-left
			  $('#slideInner').animate({
				'marginLeft' : slideWidth*(-currentPosition)
			  });
			  $('#infoInner').animate({
				'marginLeft' : infoWidth*(-currentPosition)
			  });
			});
			
		  // manageControls: Hides and shows controls depending on currentPosition
		  function manageControls(position){
			// Hide left arrow if position is first slide
			if(position==0){ $('#leftControl').hide() }
			else{ $('#leftControl').show() }
			// Hide right arrow if position is last slide
			if(position==numberOfSlides-1){ $('#rightControl').hide() }
			else{ $('#rightControl').show() }
			}
		
			//timer			
			function newsTimer(){
				$('#slideInner').everyTime(5500, 'slide', function() {
					if(currentPosition == numberOfSlides-1){
					currentPosition = 0;
					$(this).animate({
					'marginLeft' : 0
					});
					$('#infoInner').animate({
					'marginLeft' : 0
					});
					manageControls(currentPosition);
					
					}else if(currentPosition < numberOfSlides-1){
					currentPosition++;
					$(this).animate({
					'marginLeft' : slideWidth*(-currentPosition)
					});
					$('#infoInner').animate({
					'marginLeft' : infoWidth*(-currentPosition)
					});					
					manageControls(currentPosition);
					};				
				});			
			};

			newsTimer();
		  

});
				  
		  $(document).ready(function(){
		  

		  
		  //set value to null on focus
		  /*var inputs = $('input');
		  alert(inputs);
		  inputs
		  .each(
		  alert($(this).attr('title'))
		  );*/
		  
		  $('input')
		  
		  .bind('click', function(){
		  
		  if($(this).attr('title') == $(this).val()){
		  
		  var formValue = $(this).val();
		  $(this).attr({
		  title: formValue
		  });
		  $(this).val("");
		  
		  }
		  
		  //replace value if empty

			})
			.blur(function(){
			
			if($(this).val() == ""){
			
			var formValue = $(this).attr('title');
			$(this).val(formValue);
			
			};
			});
			
					  //set value to null on focus
		  $('textarea.edit')
		  
		  .bind('click', function(){
		  
		  if($(this).attr('title') == $(this).val()){
		  
		  var formValue = $(this).val();
		  $(this).attr({
		  title: formValue
		  });
		  $(this).val("");
		  
		  }
		  
		  //replace value if empty

			})
			.blur(function(){
			
			if($(this).val() == ""){
			
			var formValue = $(this).attr('title');
			$(this).val(formValue);
			
			};
			});
		  
		  
		  //grab clicks on email icon
		  $('.sendfriend')
			.bind('click', function(){

			if($("#sendtofriend:first").is(":hidden")) {
			
			//show the form
			$('#sendtofriend').slideDown("slow");
			
			//focus on name after 1.1 secs
			//setTimeout('$(".name").focus();',1100);
			
			}else {
			
			//if form is shown, hide the form
			$("#sendtofriend").slideUp("slow");
			}
			
			//return false to prevent going to non-javascript URL
			return false;
			
			});
		  
		  
		  });
		  
		  
		  //Form Validation
		  
		  $(document).ready(function(){
		  
			  var requiredFields = $('.requiredfield');
			  
			  $('.button')
				.bind('click', function(event){

				requiredFields.each(function(){
				
				//prevent empty fields
				
				var title = $(this).attr('title');
				
					if($(this).val() == title){
					
					$(this).before('<h3>This field cannot be left blank</h3>');
					event.preventDefault();
					
					};
				})
				
				//check for well formed email
				
				function isValidEmailAddress(emailAddress) {
				var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
				return pattern.test(emailAddress);
				}
				
				if(!isValidEmailAddress($('.email').val())){
				$('.email').before('<h3>Please enter a valid email address</h3>');
				//event.preventDefault();
				};
				
				

			  
			  }); 
		  });
		  