$('html').addClass('js');

 $(function() {
	// do something here
 
// Form Validation - empty fields
$('.required').blur(function() {
if ($(this).val().length == 0) {
$(this)
.addClass('input-error')
.after('<div class="input-error-message">This field must be completed</div>');
}
});
$('.required').focus(function() {
$(this)
.removeClass('input-error')
.next('div')
.remove();
});

// Validate checkboxes
$('.required-checkbox').blur(function() {
if (!$(this).is(':checked')) {
$(this)
.addClass('input-error')
.after('<div class="input-error-message">This field must be completed</div>');
}
});
$('.required-checkbox').focus(function() {
$(this)
.removeClass('input-error')
.next('div')
.remove();
});


$("form").submit(function() {
var error = false;

// text inputs
$(this).find(".required").each(function() {
if ($(this).val().length == 0) {
alert("Please complete required fields.");
$(this).focus();
error = true;
return false; // Only exits the “each” loop
}
});

// checkboxes
$(this).find(".required-checkbox").each(function() {
if (!$(this).is(':checked')) {
alert("Please complete required fields.");
$(this).focus();
error = true;
return false; // Only exits the “each” loop
}
});

if (error) {
return false;
}
return true;
});
  

// reveal hidden more link
$("a.more").removeClass('hidden');

// show hidden text when more link is clicked
$("a[href=#]").click(function (e) {
	e.preventDefault();
	targetDiv = $(this).attr('rel');
      $("div."+targetDiv).slideToggle("slow");
	  // change link text accordingly
	  if ($(this).text() == 'more') {
		  $(this).text('less');
		  $(this).addClass('less');
	  }
	  else {
		  $(this).text('more');
		  $(this).removeClass('less');
	  }
    });
	
/* Roll over images */
// Preload all rollovers
		$("#header a.roll img").each(function() {
			// Set the original src
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace('OFF', 'ON');
			newImg = new Image(); // create new image obj
			$(newImg).attr("src", rollON); // set new obj's src
		});

		
		// Navigation rollovers
		$("#header a.roll").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			
			if (typeof(imgsrc) != 'undefined') {
			imgsrcON = imgsrc.replace('OFF', 'ON');
			$(this).children("img").attr("src", imgsrcON);
			}
			
		});
		
		// Handle mouseout
		$("#header a.roll").mouseout(function(){
			if (typeof(imgsrc) != 'undefined') {
			$(this).children("img").attr("src", imgsrc);
			}
		});

 

// colorbox gallery
$("a[rel='gallery']").colorbox({innerWidth:"630", innerHeight:"500", scalePhotos:true});

// contact info pulled via ajax
$("a.ajax-contact").click(function(){ 
	var targetUrl = $(this).attr('href');
	var targetDiv = $(this).attr('rel');
	$(this).colorbox({href:targetUrl+' .'+targetDiv, 
		initialHeight:120,
        initialWidth:200,
		innerHeight:120,
        innerWidth:564});
	
	});

// youtube video
	$(".youtube").colorbox({iframe:true, innerWidth:840, innerHeight:503});



});
 







 

