$(document).ready(function() {
	
$('a.fancy').fancybox();
$('a.map').fancybox({
	width: 800,
	height: 650	
});
$('a.vid').fancybox({
	width: 800,
	height: 650	
});
$('#home-news').prependTo('#home .main-content');
	
// SLIDESHOWS

$('#sub-banner').has('ul').addClass('has-subnav');
	
// VALIDATION
$("#appointment-form").validate();
$("#contact-form").validate();
$("#feedback-form").validate();
	
   // DROPDOWN
$('#nav li').hover(
	function () {
		$(this).children('a:first').addClass("active");	
		$('ul', this).stop(true,true).slideDown(200);
	}, 
	function () {
		$(this).find('a').removeClass("active");
		$('ul', this).stop(true,true).slideUp(100);			
	}
);

// SMOOTH SCROLL

  $('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}, 500);
    return false;
   }
 }
});
	
// EQUAL COL HEIGHT
var max_height = 0;
$("div.container").each(function(){
if ($(this).height() > max_height) { max_height = $(this).height(); }
});
$("div.container").height(max_height);


// CLICKABLE CONTAINER
$('.container').click(function() {
       var href = $(this).find("a").attr("href");
       if(href) {
           window.location = href;
       }
});
	
// STIPED TABLES
$("table.striped tr:odd").addClass("alt-row");
	
	
// STYLE LINKS
// $("a[href$='.pdf']").addClass("pdf");
$("a[href$='.zip'], a[href$='.rar']").addClass("zip"); 
$("a[href^='mailto:']").addClass("email");
$('a').filter(function() {
    return this.hostname && this.hostname !== location.hostname;
}).addClass("external").attr("target", "_blank");

// HTML5 Placeholder //
// Return if native support is available.	
if ("placeholder" in document.createElement("input")) return;
	$(':input[placeholder]').each(function() {
		setupPlaceholder($(this));
	}); 
	$('form').submit(function(e) {
		clearPlaceholdersBeforeSubmit($(this));
	});
function setupPlaceholder(input) {
	var placeholderText = input.attr('placeholder');
	if (input.val() === '') input.val(placeholderText);
	input.bind({
		focus: function(e) {
			if (input.val() === placeholderText) input.val('');
		},
		blur: function(e) {
			if (input.val() === '') input.val(placeholderText); 
		}
	});
}
function clearPlaceholdersBeforeSubmit(form) {
	form.find(':input[placeholder]').each(function() {
		var el = $(this);
		if (el.val() === el.attr('placeholder')) el.val('');
	});
}



});
 
  
