$(document).ready(function(){
$("#contactLink").click(function(){
		if ($("#contactForm").is(":hidden")){
			$("#contactLink").css({'background' : 'url(http://www.llamaproductions.co.uk/images/up_arrow.png) center center no-repeat #f0f0f0'});
			$("#contactForm").slideDown("slow");
			$('#name').val("");
			$('#email').val("");
			$('#message').val("");
			if ($("#form").is(":hidden")){
				$("#form").fadeIn("slow");
			}
		}
		else{
			$("#contactForm").slideUp("slow");
			$("#contactLink").css({'background' : 'url(http://www.llamaproductions.co.uk/images/down_arrow.png) center center no-repeat #f0f0f0'});
		}
	});

$("ul.thumb li").hover(function() {
	$(this).css({'z-index' : '10'});
	$(this).find('img').addClass("hover").stop()
		.animate({
			marginTop: '-100px', 
			marginLeft: '-100px', 
			top: '50%', 
			left: '50%', 
			width: '174px', 
			height: '174px' 
		}, 650);
	
	} , function() {
	$(this).css({'z-index' : '0'});
	$(this).find('img').removeClass("hover").stop()
		.animate({
			marginTop: '0', 
			marginLeft: '0',
			top: '0', 
			left: '0', 
			width: '100px', 
			height: '100px'
		}, 500);
});

	$("ul.thumb li a").click(function() {
		
		var mainImage = $(this).attr("href");
		$("#mainView img").attr({ src: mainImage });

		var mainLink = $(this).attr("title");
		$("#mainView a").attr({ href: mainLink });
		
		var linkNumber = $(this).attr("href");
		switch (linkNumber)
			{
			case 'images/main_image1.jpg':
			  document.getElementById("mainTitle").innerHTML = '<span class="slash">/</span>1';
			  document.getElementById("mainText").innerHTML = '1';
			  break;
			case 'images/main_image2.jpg':
			  document.getElementById("mainTitle").innerHTML = '<span class="slash">/</span>2';
			  document.getElementById("mainText").innerHTML = '2';
			  break;
			case 'images/main_image3.jpg':
			  document.getElementById("mainTitle").innerHTML = '<span class="slash">/</span>3';
			  document.getElementById("mainText").innerHTML = '3';
			  break;
			case 'images/main_image4.jpg':
			  document.getElementById("mainTitle").innerHTML = '<span class="slash">/</span>4';
			  document.getElementById("mainText").innerHTML = '4';
			  break;
			case 'images/main_image5.jpg':
			  document.getElementById("mainTitle").innerHTML = '<span class="slash">/</span>5';
			  document.getElementById("mainText").innerHTML = '5';
			  break;
			case 'images/main_image6.jpg':
			  document.getElementById("mainTitle").innerHTML = '<span class="slash">/</span>6';
			  document.getElementById("mainText").innerHTML = '6';
			  break;
			default:
			  document.getElementById("mainTitle").innerHTML = '<span class="slash">/</span>default';
			  document.getElementById("mainText").innerHTML = 'default';
			}
		return false;
	});
 
});
$(function() {
  $('.error').hide();
  $('.text-input').css({backgroundColor:"#fdfdfd"});
  $('.text-input').focus(function(){
    $(this).css({backgroundColor:"#efffff"});
  });
  $('.text-input').blur(function(){
    $(this).css({backgroundColor:"#fdfdfd"});
  });

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var name = $("input#name").val();
		if (name == "") {
      $("label#name_error").show();
      $("input#name").focus();
      return false;
    }
		var email = $("input#email").val();
		if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
		var message = $("textarea#message").val();
		if (message == "") {
      $("label#message_error").show();
      $("textarea#message").focus();
	  
      return false;
    }
		
		var dataString = 'name='+ name + '&email=' + email + '&message=' + message;
		$.ajax({
      type: "POST",
      url: "http://www.llamaproductions.co.uk/bin/process.php",
      data: dataString,
      success: function() {
        $("#messageSent").show("fast"), 600;
		$("#contactLink").css({'background' : 'url(http://www.llamaproductions.co.uk/images/down_arrow.png) center center no-repeat'});
		setTimeout('$("#messageSent").hide();$("#contactForm").slideUp("slow")', 1300);
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#name").select().focus();
});

