$(function() {


	var root = $("div.scrollable").scrollable({size: 1})
		.navigator(); 
	
	// setup api
	window.api = root.scrollable(); 


$("#path a").click(function() {
     $("#path a").removeClass(function() {
      return 'current';
    });
	$(this).addClass('current');
});

$("#next-prev a").click(function() {
     $("#path a").removeClass(function() {
      return 'current';
    });
    var $index = api.getIndex();
    $("#path a").eq($index).addClass('current');
});

    $("#thumbs div").hoverIntent(
	function () {
        var $this = $(this); 
        $("#M" + $this.attr("id").replace(/T/, "")).addClass('active');
    },
	function () {
        var $this = $(this); 
        $("#M" + $this.attr("id").replace(/T/, "")).removeClass('active');
    }
	);

    $("#clients li").hoverIntent(
	function () {
        var $this = $(this); 
        $("#T" + $this.attr("id").replace(/M/, "")).addClass('active');
    },
	function () {
        var $this = $(this); 
        $("#T" + $this.attr("id").replace(/M/, "")).removeClass('active');
    }
	);

$("a[href^='http']").not("[href*='hamblywoolley.com']").click(function(){
	window.open(this.href);
	return false;
});

$("a[href*=.pdf]").click(function(){
	window.open(this.href);
	return false;
});

$("a[href$='.pdf']").addClass("pdf");
$("a[href$='.doc']").addClass("doc");





        $('a[href*=#]').click(function() {
          if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target
            || $('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
              var targetOffset = $target.offset().top;
              $('html,body')
              .animate({scrollTop: targetOffset}, 1000);
             return false;
            }
          }
        });

  $('#select').change(function() {
    var option = $(this).val();
    if( option ) {
        window.open(option, 'orange');
	}
  });



	$("#signupForm").validate({
		rules: {
			name: "required",
			"cm-125379-125379": {
				required: true,
				email: true
			},
			accept: "required"
		},
		messages: {
			name: "Please enter your name.",
			"cm-125379-125379": "Please enter a valid email address.",
			accept: "Please accept our policy"
		},
        errorPlacement: function(error, element) {
            error.insertBefore(element);
        }

	});

				

});



function validate()
{


	var continueToSubmit = true;
         email = document.getElementById("l125379-125379");
         name = document.getElementById("name");

	if( continueToSubmit && name.value.length == 0 )
	{
		continueToSubmit = false;
		alert('You must provide your name.');
		name.focus();
        }

	if( continueToSubmit && email.value.length == 0 )
	{
		continueToSubmit = false;
		alert('You must provide a value for email address.');
		email.focus();
	} else {

		var emailValue = email.value;
		if( ( emailValue.indexOf( '@' ) <= 0 ) || ( emailValue.indexOf( '.', emailValue.indexOf( '@' ) ) <= 0 ) )
	  	{
			continueToSubmit = false;
			alert('You must provide a valid email address.'); 
			email.focus();
		}

       }

       if (document.orange.accept.checked == false) {
			continueToSubmit = false;
			alert('You must agree to the Privacy Policy.'); 
			document.orange.accept.focus();
      }
       return continueToSubmit;

}

