function setUnderline(elementToApplyTo){
	for(i=1;i<6;i++){
			$('#slideButton'+i).css('textDecoration','none');
			$('#slideButton'+i).css('color','#212121');
	}
	$('#'+elementToApplyTo).css('textDecoration','underline');
	$('#'+elementToApplyTo).css('color','#212121');
}

$(document).ready(function(){
	$('#pod1Link').mouseover(function() {
		$('#pod1').animate({
   		opacity: 0.80
    	}, 500);
		});
    
  $('#pod1Link').mouseout(function() {
		$('#pod1').animate({
   		opacity: 0
    	}, 1000);
		});
    
   $('#pod2Link').mouseover(function() {
		$('#pod2').animate({
   		opacity: 0.80
    	}, 500);
		});
    
  $('#pod2Link').mouseout(function() {
		$('#pod2').animate({
   		opacity: 0
    	}, 1000);
		});
    
   $('#pod3Link').mouseover(function() {
		$('#pod3').animate({
   		opacity: 0.80
    	}, 500);
		});
    
  $('#pod3Link').mouseout(function() {
		$('#pod3').animate({
   		opacity: 0
    	}, 1000);
		});
    
   $('#pod4Link').mouseover(function() {
		$('#pod4').animate({
   		opacity: 0.80
    	}, 500);
		});
    
  $('#pod4Link').mouseout(function() {
		$('#pod4').animate({
   		opacity: 0
    	}, 1000);
		});
  
  $('#slideButton1').click(function() {
  	$('#homepageStatement').html($('#slideText1').html());
  	setUnderline('slideButton1');
  	$('#slideTrack').animate({ 
    	marginLeft: "0px"
    	}, 1500 );
	});
  
  $('#slideButton2').click(function() {
  	
    $('#homepageStatement').html($('#slideText2').html());
    setUnderline('slideButton2');
  	$('#slideTrack').animate({ 
    	marginLeft: "-749px"
    	}, 1500 );
	});
  
  $('#slideButton3').click(function() {
  	$('#homepageStatement').html($('#slideText3').html());
  	setUnderline('slideButton3');
  	$('#slideTrack').animate({ 
    	marginLeft: "-1498px"
    	}, 1500 );
	});
  
  $('#slideButton4').click(function() {
  $('#homepageStatement').html($('#slideText4').html());
  	setUnderline('slideButton4');
  	$('#slideTrack').animate({ 
    	marginLeft: "-2247px"
    	}, 1500 );
	});
  
  $('#slideButton5').click(function() {
  $('#homepageStatement').html($('#slideText5').html());
  	setUnderline('slideButton5');
  	$('#slideTrack').animate({ 
    	marginLeft: "-2996px"
    	}, 1500 );
	});
  
  $("#registrationForm").submit( function () {
  	alert('ive been submitted woohoo');
	});
  
  $('#yearLeft').click(function() {
  	var curYear = parseInt($('#yearDisplay').html());
    var maxYear = parseInt($('#maxYear').html());
    var minYear = parseInt($('#minYear').html());
    
    if(curYear==(minYear+1)){
      $('#yearLeft').hide();
    }
    $('#yearRight').show();
    
    $('#yearDisplay').html((curYear-1));
  	$('#availabilityCalendarScroller').animate({ 
    	marginLeft: "+=783px"
    	}, 0 );
	});
  
  $('#yearRight').click(function() {
  	var curYear = parseInt($('#yearDisplay').html());
    var maxYear = parseInt($('#maxYear').html());
    var minYear = parseInt($('#minYear').html());
    
    if(curYear==(maxYear-1)){
    	$('#yearRight').hide();
    }
    $('#yearLeft').show();
    
    $('#yearDisplay').html((curYear+1));
  	$('#availabilityCalendarScroller').animate({ 
    	marginLeft: "-=783px"
    	}, 0 );
	});
  
  $('.small-caravan-image').live('click',function(){
  	var thumbIdParts = $(this).attr('id').split('-');
  	$('.large-caravan-image').fadeOut(0,function(){
    	$('#large-caravan-image-'+thumbIdParts[3]).fadeIn(0,function(){
      		
      });
    })
  });
  
  $('#filmStripLeft').click(function() {
  	
    var curSlide = parseInt($('#galleryCurrent').html());
    var maxSlide = parseInt($('#galleryTotal').html());
    
    if(curSlide==1){
    	var distanceToMove = ((maxSlide-7)*123);
    	$('#filmStrip').animate({ 
    		marginLeft: '-='+distanceToMove+'px'
    	}, 1000 );
      $('#galleryCurrent').html((maxSlide-6));
    }else{
    	$('#galleryCurrent').html((curSlide-1));
  		$('#filmStrip').animate({ 
    		marginLeft: "+=123px"
    	}, 500 );
    }
    
    
	});
  
  $('#filmStripRight').click(function() {
  	
    var curSlide = parseInt($('#galleryCurrent').html());
    var maxSlide = parseInt($('#galleryTotal').html());
    
    if(curSlide==(maxSlide-6)){
    	var distanceToMove = (0);
    	$('#filmStrip').animate({ 
    		marginLeft: '0px'
    	}, 1000 );
      $('#galleryCurrent').html(1);
    }else{
    	$('#galleryCurrent').html((curSlide+1));
  		$('#filmStrip').animate({ 
    	marginLeft: "-=123px"
    	}, 500 );
    }
	});

  

});

	function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   /* alert("Invalid E-mail ID") */
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   /* alert("Invalid E-mail ID") */
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    /* alert("Invalid E-mail ID")*/
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    /* alert("Invalid E-mail ID")*/
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    /* alert("Invalid E-mail ID")*/
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    /* alert("Invalid E-mail ID")*/
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    /* alert("Invalid E-mail ID")*/
		    return false
		 }

 		 return true					
	}

  function passwordStrength(password){

    var desc = new Array();
		desc[0] = "Password strength: Very Weak";
    desc[1] = "Password strength: Weak";
    desc[2] = "Password strength: Better";
    desc[3] = "Password strength: Medium";
    desc[4] = "Password strength: Strong";
    desc[5] = "Password strength: Strongest";
    var score   = 0;
    
    //if password bigger than 6 give 1 point
    
    if (password.length > 6) score++;
    //if password has both lower and uppercase characters give 1 point      
    if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++;
    //if password has at least one number give 1 point
    if (password.match(/\d+/)) score++;
    //if password has at least one special caracther give 1 point
    if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) ) score++;
    //if password bigger than 12 give another 1 point
    if (password.length > 12) score++;
    
    document.getElementById("passwordDescription").innerHTML = desc[score];
    document.getElementById("passwordStrength").className = "strength" + score;
	}
