$(document).ready(function(){
	
	// **************************************************************************************************************************
	// GENERAL ACTIONS
	
	// external links
	$("a[rel='external']").click(function() {
		return !window.open($(this).attr("href"));
	});
	$('.hide-with-js').hide(); // use this class to hide the message "please open this link in new window"
	
	// fade in messages
	//$('.successMsg').hide();
	//$('.successMsg').fadeIn(1000);
	//$('.errorMsg div').hide();
	//$('.errorMsg div').fadeIn(1000);
	//$('.warningMsg').hide();
	//$('.warningMsg').fadeIn(1000);
	
	// non-clickable links
	$(".return-false").click( function() {
		return false;
	});
	
	// clear inputs
	$("#projects input, #projects textarea, #contact-form input, #contact-form textarea, #form-newsletter-footer input").each(function(i){
		var inputValue = $(this).val();
		var inputTitle = $(this).attr("title");
		
		if (inputValue=="" || inputValue==inputTitle) {
			$(this).focus(function(){ 
				if ($(this).val()==inputValue) {
					$(this).val("");
				}
			});
			$(this).blur(function(){ 
				if ($(this).val()=="") {
					$(this).val(inputValue);
				}
			});
		}
		
	});
	
	
	// Fading links
	$(".fading-link img").fadeTo(1000, 0.50);
	$(".fading-link").hover(
		function(){
			$("img", this).fadeTo(50, 1);
		},
		function(){
			$("img", this).fadeTo(50, 0.50);
		}
	);
	
	// END GENERAL ACTIONS
	// **************************************************************************************************************************
	
	
	// Font replacement
	replaceFonts();
	
});


// Font replacement
function replaceFonts() {
	Cufon.replace('#main-menu a', { fontFamily: 'ArialNArrow', hover: true, hoverables: { a: true } });
}

