﻿$(document).ready(function() {
    
    //Find all text inputs and set title as text
    var inputs = $(document).find('input');
    for (var i = 0; i < inputs.length; i++) {
        if ((inputs[i].type == 'text') && (inputs[i].title != '')) {
            inputs[i].value = inputs[i].title;
            inputs[i].onfocus = inputFocus;
        }
    }
    
    // Find all anchors with the class popup and add the onclick function to open the link in a new window.
    $('a[class*="popup"]').click(function() {
        window.open($(this).attr('href'));
        return false;
    });
    
    // Traverse through all links with the class popup and modify the title attribute.
    $('a[class*="popup"]').each(function() {
        if($(this).attr('title') == '') {
            $(this).attr('title', '(Öppnas i nytt fönster)');
        }
    });  
});

function inputFocus() {
    if (this.value == this.title) this.value = '';
}