$(document).ready(function() {

//initialize top of page

//$("#top > .container").hide();
$('#contact > a').click(function ($e) {
  $e.preventDefault();
  $("#top > .container").slideToggle("slow");
  });
$('#close').click(function ($e) {
  $e.preventDefault();
  $("#top > .container").slideUp("slow");
  });

//initialize contact form

    var options = { 
        target:        '#output',   // target element(s) to be updated with server response
        beforeSubmit:	validate,
        success:       showResponse  // post-submit callback 
 
        // other available options: 
        //url:       url         // override for form's 'action' attribute 
        //type:      type        // 'get' or 'post', override for form's 'method' attribute 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        //clearForm: true        // clear all form fields after successful submit 
        //resetForm: true        // reset the form after successful submit 
 
        // $.ajax options can be used here too, for example: 
        //timeout:   3000 
    };
 
	// bind form using 'ajaxForm' 
    $('#contactform').ajaxForm(options); 


//initialize portfolio filter

if($("#filter").length) {
$("#filter > li").css('cursor','pointer');
$("#all").addClass("current");
$('#all').click(function ($e) {
  $e.preventDefault();
  if(!$(this).hasClass("current")) {
  $("#filter > li").removeClass("current");
  $(this).addClass("current");
  $('.print,.branding,.web').hide();
  $('.web,.print,.branding').show();
  }});

$('#web').click(function ($e) {
  $e.preventDefault();
  if(!$(this).hasClass("current")) {
  $("#filter > li").removeClass("current");
  $(this).addClass("current");
  $('.print,.branding,.web').hide();
  $('.web').show();
  }});

$('#print').click(function ($e) {
  $e.preventDefault();
  if(!$(this).hasClass("current")) {
  $("#filter > li").removeClass("current");
  $(this).addClass("current");
  $('.print,.branding,.web').hide();
  $('.print').show();
  }});

$('#branding').click(function ($e) {
  $e.preventDefault();
  if(!$(this).hasClass("current")) {
  $("#filter > li").removeClass("current");
  $(this).addClass("current");
  $('.print,.branding,.web').hide();
  $('.branding').show();
  }});
}

//initialize carousel
if($("#carousel").length) {
	$("#carousel").jCarouselLite({
		btnNext: "#next",
       		btnPrev: "#prev",
		visible: 1,
		circular: true,
		speed: 600
	});
}

});


// post-submit callback 
function showResponse(responseText, statusText, xhr, $form)  {  
	$("#Submit").hide();
	$("#thanks").fadeIn("Slow");
}
//form validation
function validate(formData, jqForm, options) { 
    var form = jqForm[0]; 
    if (!form.name.value || !form.email.value || !form.message.value) { 
        alert('Please fill out all of the fields.'); 
        return false; 
    }
}


