// Checks if form has required fields & if they have content 
$('form').submit(function(){

    // Config
    var state = true;
    
    // Iterate all input fields
    $(this).find('input').each(function(){
    
        // Attach error handling if fields required & empty
        if($(this).attr('rel') == 'required' && $(this).attr('value') == ''){
            $(this).addClass('required');
            state = false;
            
            // Reset field when field has been filled in
            $(this).keydown(function(){
                $(this).removeClass('required');            
            });
            
        }
    });

    // Show errormessage if needed                           
    if(!state)alert($(this).find('input.errormessage').attr('value'))   	     
    return state;	
});

// Add confirm delete dialog
$('body a.delete').click(function(){
    return confirm('Vill du radera denna post?');    
});


// External links
$('a').click(function(){
    if($(this).attr('rel') == 'external'){
        window.open(this.href);
        return false;
    }else{
        return true;
    }
});

// Set wrapper height on resize
$(window).resize(function() {
  $('div#wrapper').css('height',$(window).height());
});
function setFooterPosition() {
      
}