//Links with the class external will open in a new window, to get the code valid in xhtml-strict
$(function() {
	$(".external").attr("target","_blank");
});


//Mailme - Email Spam Protector
$(function() {
    var at = / at /;
    var dot = / dot /g;
    $('span.mailme').each( function() {
        var addr = jQuery(this).text().replace(at,"@").replace(dot,".");
        $(this)
            .after('<a href="mailto:'+addr+'" class="mailme">'+ addr +'</a>')
            .remove();
    });
});

//Validate - Validation of forms
$(document).ready(function(){
	var v = jQuery("#contactform").validate({
			submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					target: "#contactform_holder"
				});
			}
		});
});

$(document).ready(function(){ 
        $("ul.sf-menu").superfish({ 
            animation: {height:'show'},   // slide-down effect without fade-in 
            delay:     600               // 0.6 second delay on mouseout 
        }); 
    }); 

$(window).load(function() {
        $('#slideshow').nivoSlider();
});

$(document).ready(function(){	
	$('input[type="text"]').focus(function (){
			clearText(this);
		});
		$('input[type="text"]').blur(function (){
			addText(this);
		});
		$('textarea').focus(function (){
			clearText(this);
		});
		$('textarea').blur(function (){
			addText(this);
		});
		
		$('#submit').click(function() {
			post_form();
		});
});

function clearText(theField)
{
if (theField.defaultValue == theField.value)
theField.value = '';
}

function addText(theField)
{
if (theField.value == '')
theField.value = theField .defaultValue;
}

