// JavaScript Document

 $(function() {
       		     $(".carousel").jCarouselLite({
        	     btnNext: ".next",
        	     btnPrev: ".prev",
        	     visible: 4
    		     });
       		     $(".carousel2").jCarouselLite({
        	     btnNext: ".next",
        	     btnPrev: ".prev",

    		     });
           });

$(document).ready(function(){

        $('div#hero').css('visibility', 'visible');
	$('#heroImage .item').dumbCrossFade({
			'slideType':'fade',
			'fadeInOut':false,
			'showTime': 10000,
			'transitionTime': 400,
			'doHoverPause' : false,        
			'maxZIndex' : 25
			});
	$('#heroMessage .item').dumbCrossFade({
			'slideType':'slidevertical',
			'fadeInOut':false,
			'showTime': 10000,
			'transitionTime': 400,
			'doHoverPause' : false,
			'maxZIndex' : 50
			});
	$('#contentNav #description .item').dumbCrossFade({
			'slideType':'slidevertical',
			'fadeInOut':false,
			'showTime': 10000,
			'transitionTime': 400,
			'doHoverPause' : false,
			'maxZIndex' : 50
			});

	//$('#heroImage .item').dumbCrossFade('stop');
	//$('#heroMessage .item').dumbCrossFade('stop');
	//$('#contentNav #description .item').dumbCrossFade('stop');

	$('.rightArrow').click(function() {
		$('#heroImage .item').dumbCrossFade('next');
		$('#heroMessage .item').dumbCrossFade('next');
		$('#contentNav #description .item').dumbCrossFade('next');

	});
	$('.leftArrow').click(function() {
		$('#heroImage .item').dumbCrossFade('previous');
		$('#heroMessage .item').dumbCrossFade('previous');
		$('#contentNav #description .item').dumbCrossFade('previous');

	});

	$(".modal").colorbox();

	$('a.details').toggle(function() {
		  $(this).closest('span').children('p.details').show();
		$(this).css('background-position', 'right bottom');
		  $(this).html('Hide details');
		   return false;
	},function() {
		  $(this).closest('span').children('p.details').hide();
		$(this).css('background-position', 'right top');
		  $(this).html('More details');
		   return false;
	});
		  $('p.details').hide();

         $("input[type=text]").focus(function(){
            // Select field contents
            this.select();
	});
	

	$('#accordion2').easyAccordion({
			autoStart: false,
			slideNum: false

	});
	$('#accordion3').easyAccordion({
			autoStart: false,
			slideNum: false

	});
	$('#accreditations img').mouseenter(function() {
                     this.src = this.src.replace("_grayscale.png",".png");
           }).mouseleave(function() {
                     this.src = this.src.replace(".png","_grayscale.png");
                     });

	$('#social img').mouseenter(function() {
                     this.src = this.src.replace("_grayscale.png",".png");
           }).mouseleave(function() {
                     this.src = this.src.replace(".png","_grayscale.png");
                     });

              	$('#blogWidget').load('/home/blog-widget');



	$('#mainMenu ul.primary li').click(function(){
          var switchTitle = '#drawer ul li.'+$(this).attr('class');
                          $('#drawer ul li').hide();
                          $(switchTitle).show();
                          $('#drawer').show("slide", { direction: "down" }, 1000);
                          $('#mainMenu').hide("slide", { direction: "up" }, 1000);
			});

   	$('a.rollBack').click(function(){
                          $('#mainMenu').show("slide", { direction: "down" }, 1000);
                          $('#drawer').hide("slide", { direction: "up" }, 1000);
                          return false;
			});

	$(".subscribeButton").click(function() {

	var missinginfo = "";
		if (($("input#NLEmail").val() == "") ||
		($("input#NLEmail").val().indexOf('@') == -1) ||
		($("input#NLEmail").val().indexOf('.') == -1)) {
		missinginfo += "\n     -  Email Address";
		}
	if (missinginfo != "") {
	return false;
	};

	var newsletterEmail = $("input#NLEmail").val();
	var newsletterName = $("input#NLName").val();

	var dataString = 'NLEmail=' + newsletterEmail + '&NLName=' + newsletterName;
  	$.ajax({
	   type: "POST",
	   url: "/scripts/mailchimp/mailChimp.php",
	   data: dataString,
	   success: function() {
	        $('form#joinNewsletter').html("<p>Thank you for subscribing. Please check your email to confirm your subscription.</p>");
	      }
	 });
	 return false;
	});



function shiftClients (direction) {

 if(!($("#clientGallery ul").is(":animated"))){
  if (direction=='left'){
    $("#clientGallery ul").animate({marginLeft : '0px'}, 1200, function() {
        $("#clientGallery ul li:first").before( $("#clientGallery ul li:last") );
        $("#clientGallery ul").css('margin-left' , '-200px' );
      });
  }
  if (direction=='right'){
    $("#clientGallery ul").animate({marginLeft : '-400px'}, 1200, function() {
        $("#clientGallery ul li:last").after( $("#clientGallery ul li:first") );
        $("#clientGallery ul").css('margin-left' , '-200px' );
      });
  }
 }
}
var moveClients;
	$('#clientBack').click(function() { return false;})
	$('#clientForward').click(function() { return false;})

	$('#clientBack').mouseenter(function() {
                     moveClients = setInterval(function(){shiftClients('left');},10);
           }).mouseleave(function() {
                     clearInterval(moveClients);
                     });

      	$('#clientForward').mouseenter(function() {
                     moveClients = setInterval(function(){shiftClients('right');},10);
           }).mouseleave(function() {
                     clearInterval(moveClients);
                     });


	$('div.sectionSelect a').click(function()
	{
		var toShow = $(this).attr('href');
		$('div.sectionToggle').hide();
		$('div' + toShow).fadeIn('slow');
		return false;
	})
 (function() {
       		     $('div.sectionToggle').hide();
       		     $('div#team').show();
           });



});


