//Starting functions
$(document).ready(function() {

//Active class in main menu

$("#nav a").each(function() {
	if(this.href == window.location || this.href == document.location.protocol + "//" + window.location.hostname + window.location.pathname){
		$(this).addClass("active");
	}
	else{
		if (window.location.href.match(/\/portfolio\/.+/)){
			if (this.href.match(/portfolio/)){
				$(this).addClass('active');
			}
		}	
	}
});

//Animate background in nav
$(window).load(function() {
    $('#slider').nivoSlider({effect: 'fade'});
});

//Open links in new window
$("a.new-window").click( function() {
    window.open( $(this).attr('href') );
    return false;
});

//Clear textfields on focus
(function($){
	$.fn.clearDefault = function(){
		return this.each(function(){
			var default_value = $(this).val();
			$(this).focus(function(){
				if ($(this).val() == default_value) $(this).val("");
			});
			$(this).blur(function(){
				if ($(this).val() == "") $(this).val(default_value);
			});
		});
	};
})(jQuery);
 
$('input#name').clearDefault();
$('input#email').clearDefault();
$('textarea#message').clearDefault();

//Hide contactform errors
/*window.setTimeout( hideTagFn, 5000);
function hideTagFn(){
   $('ul.zemError').hide();
}	*/

});//Closing functions

//PNGfix
window.onload = function(){
	DD_belatedPNG.fix('img, #header, ul#nav a:hover,');
}
