// Add Classes to form elements automatically
$(document).ready(function() {
	// * Enable ability to custom style all input elements based on their type
	// * The equivalent CSS selectors doesn't work in IE 6 (and 7?)
	$("input[@type=text]").add("input[@type=password]").addClass("text");
	$("input[@type=checkbox]").addClass("checkbox");
	$("input[@type=radio]").addClass("radio");
	$("input[@type=submit]").addClass("submit");
	$("input[@type=button]").addClass("button");
	$("input[@type=image]").addClass("image");
	$("input[@type=file]").addClass("file");
});

// Adds a class focus to input text when focused
function focusfix(selector, className) {
$(selector).focus(function() {
$(this).addClass(className);
});
// Removes class when focus is lost
$(selector).blur(function() {
$(this).removeClass(className);
});
}

jQuery(document).ready(function($) {
focusfix('input', 'focus');
});

jQuery(document).ready(function($) {
focusfix('textarea', 'focus');
});

// Filetype icons and external links
$(document).ready(function() {	
		
	// Add pdf icons to pdf links
	$("a[href$='.pdf']").addClass("pdf").attr("target", "_blank");
	$("a[href$='.doc']").addClass("doc").attr("target", "_blank");
	
	// Add email icons to email links
	$("a[href^='mailto:']").addClass("email");

	//Add external link icon to external links - 
	$('a').filter(function() {
		//Compare the anchor tag's host name with location's host name
	    return this.hostname && this.hostname !== location.hostname;
	  }).addClass("external").attr("target", "_blank");	
	 
});



/*******

	***	Anchor Slider by Cedric Dugas   ***
	*** Http://www.position-absolute.com ***
	
	Never have an anchor jumping your content, slide it.

	Don't forget to put an id to your anchor !
	You can use and modify this script for any project you want, but please leave this comment as credit.
	
*****/
		


$(document).ready(function() {
	$("a.anchorLink").anchorAnimate()
});

jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 1100
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}
