// JavaScript Document

$(document).ready(function(){

    $('#website').cycle({
		fx: 'scrollHorz',
		prev:   '#button-left', 
    	next:   '#button-right',
		easeout: true,
		speed: 300,
		timeout:0
	});
	
	$('#website-title').cycle({
		fx: 'scrollHorz',
		prev:   '#button-left', 
    	next:   '#button-right',
		easeout: true,
		speed: 600,
		timeout:0
	});


	$('.website-image-1, .enlarge-button-1').hover(
      function () {
        $('.enlarge-button-1').show();
      }, 
      function () {
        $('.enlarge-button-1').hide();
    });
	
	
	
	$('.enlarge-button-1')
  		.html('<a href="#site-1-full" id="site-1"><img src="img/enlarge2.png" alt="Web Sample 1" /></a>');
		
		
		
	$('.website-image-2, .enlarge-button-2').hover(
      function () {
        $('.enlarge-button-2').show();
      }, 
      function () {
        $('.enlarge-button-2').hide();
    });
	
	
	
	$('.enlarge-button-2')
  		.html('<a href="#site-2-full" id="site-2"><img src="img/enlarge2.png" alt="Web Sample 2" /></a>');
		
		
		
	$('.website-image-3, .enlarge-button-3').hover(
      function () {
        $('.enlarge-button-3').show();
      }, 
      function () {
        $('.enlarge-button-3').hide();
    });
	
	
	
	$('.enlarge-button-3')
  		.html('<a href="#site-3-full" id="site-3"><img src="img/enlarge2.png" alt="Web Sample 3" /></a>');
		
		
		
	$('.website-image-4, .enlarge-button-4').hover(
      function () {
        $('.enlarge-button-4').show();
      }, 
      function () {
        $('.enlarge-button-4').hide();
    });
	
	
	
	$('.enlarge-button-4')
  		.html('<a href="#site-4-full" id="site-4"><img src="img/enlarge2.png" alt="Web Sample 4" /></a>');
		
		
		
	$('.website-image-5, .enlarge-button-5').hover(
      function () {
        $('.enlarge-button-5').show();
      }, 
      function () {
        $('.enlarge-button-5').hide();
    });
	
	
	
	$('.enlarge-button-5')
  		.html('<a href="#site-5-full" id="site-5"><img src="img/enlarge2.png" alt="Web Sample 5" /></a>');
		
		
		
	$('.website-image-6, .enlarge-button-6').hover(
      function () {
        $('.enlarge-button-6').show();
      }, 
      function () {
        $('.enlarge-button-6').hide();
    });
	
	
	
	$('.enlarge-button-6')
  		.html('<a href="#site-6-full" id="site-6"><img src="img/enlarge2.png" alt="Web Sample 6" /></a>');
		
		
		
	$('.website-image-7, .enlarge-button-7').hover(
      function () {
        $('.enlarge-button-7').show();
      }, 
      function () {
        $('.enlarge-button-7').hide();
    });
	
	
	
	$('.enlarge-button-7')
  		.html('<a href="#site-7-full" id="site-7"><img src="img/enlarge2.png" alt="Web Sample 7" /></a>');
		
		
		
	$('.website-image-8, .enlarge-button-8').hover(
      function () {
        $('.enlarge-button-8').show();
      }, 
      function () {
        $('.enlarge-button-8').hide();
    });
	
	
	
	$('.enlarge-button-8')
  		.html('<a href="#site-8-full" id="site-8"><img src="img/enlarge2.png" alt="Web Sample 8" /></a>');
	
	
	
	
	$('#button-left').hover(
      function () {
        $('#button-left-hover').fadeIn(300);
      }, 
      function () {
        $('#button-left-hover').fadeOut(300);
    });
	$('#button-right').hover(
      function () {
        $('#button-right-hover').fadeIn(300);
      }, 
      function () {
        $('#button-right-hover').fadeOut(300);
    });
	
	
	
	$('#information').hover(
      function () {
        $('#information').addClass('green');
      }, 
      function () {
        $('#information').removeClass('green');
    });
	
	$('#contact, #contact-2').hover(
      function () {
        $('#contact').addClass('green');
      }, 
      function () {
        $('#contact').removeClass('green');
    });
	
	$('#resume').hover(
      function () {
        $('#resume').addClass('green');
      }, 
      function () {
        $('#resume').removeClass('green');
    });
	
	$('#twitter').hover(
      function () {
        $('#twitter').addClass('green');
      }, 
      function () {
        $('#twitter').removeClass('green');
    });
	
	
	
	$("#information").click(function () {
      $("#information").addClass('active');
	  $("#contact, #resume, #twitter").removeClass('active');
	  $("#contact-content, #resume-content, #twitter-content").hide();
	  $("#information-content").show();
    });

	
	$("#contact, #contact-2").click(function () {
      $("#contact").addClass('active');
	  $("#information, #resume, #twitter").removeClass('active');
	  $("#information-content, #resume-content, #twitter-content").hide();
	  $("#contact-content").show();
    });
	
	
	$("#resume").click(function () {
      $("#resume").addClass('active');
	  $("#information, #contact, #twitter").removeClass('active');
	  $("#information-content, #contact-content, #twitter-content").hide();
	  $("#resume-content").show();
    });
	
	
	$("#twitter").click(function () {
      $("#twitter").addClass('active');
	  $("#information, #contact, #resume").removeClass('active');
	  $("#information-content, #contact-content, #resume-content").hide();
	  $("#twitter-content").show();
    });
	
	
	
	$('#resume_box_link').fancyZoom();
	$('#site-1, #site-2, #site-3, #site-4, #site-5, #site-6, #site-7, #site-8').fancyZoom();


	$(function() {
	  $('.error').hide();
	  $('input.text-input, textarea').css({backgroundColor:"#DDDDDD"});
	  $('input.text-input, textarea').focus(function(){
	    $(this).css({backgroundColor:"#FFFFFF"});
	  });
	  $('input.text-input, textarea').blur(function(){
	    $(this).css({backgroundColor:"#DDDDDD"});
	  });

	  $(".button").click(function() {
			// validate and process form
			// first hide any error messages
	    $('.error').hide();

		  var name = $("input#name-input").val();
			if (name == "") {
	      $("label#name_error").show();
	      $("input#name-input").focus();
	      return false;
	    }
			var email = $("input#email-input").val();
			if (email == "") {
	      $("label#email_error").show();
	      $("input#email-input").focus();
	      return false;
	    }
			var message = $("textarea#message-input").val();
			if (message == "") {
	      $("label#message_error").show();
	      $("textarea#message-input").focus();
	      return false;
	    }

			var dataString = 'name='+ name + '&email=' + email + '&message=' + message;
			//alert (dataString);return false;

			$.ajax({
	      type: "POST",
	      url: "bin/sendamessage.php",
	      data: dataString,
	      success: function() {
	        $('#contact_form').html("<div id='the-message'></div>");
	        $('#the-message').html("<h2>Thank You For Your Email</h2>")
	        .append("<p>Tony Bebber will be in touch with you as soon as possible.<br />If you need immediate assistance feel free to call 720.280.3121</p>")
	        .hide()
	        .fadeIn(1500, function() {
	          $('#the-message').append();
	        });
	      }
	     });
	    return false;
		});
	});
	
	runOnLoad(function(){
	  $("input#name-input").select().focus();
	  $("#loader").fadeOut();	
	});
	
});
