// Load different row colors in table
Event.observe(window, 'load', function() {
    $$('table#evenodd tbody > tr:nth-child(odd)').each(function(s) {
        s.addClassName('row-a');
    });
    $$('table#evenodd tbody > tr:nth-child(even)').each(function(s) {
        s.addClassName('row-b');
    });
});
// Load different cell colors in table
Event.observe(window, 'load', function() {
    $$('table.cellodd td:nth-child(odd)').each(function(s) {
        s.addClassName('cell-a');
    });
    $$('table.cellodd td:nth-child(even)').each(function(s) {
        s.addClassName('cell-b');
    });
});
// Set target of external links to _blank
Event.observe(window, 'load', function() {

    $$('a[href!=""]').each(function(link){
        var siteregex = /^(http:\/\/)([a-z]*\.)?(kraftaffarer.se)/i;
        if(link.readAttribute('href').startsWith('http://') &&
          !link.readAttribute('href').match(siteregex)){
            link.writeAttribute('target','_blank');
            link.writeAttribute('rel','external');
        }
    });

    $$('a[rel="external"]').each(function(link){
        if(link.readAttribute('href') != '' && link.readAttribute('href') != '#'){
            link.writeAttribute('target','_blank');
        }
    });
});

// Real simple password protection
function pass()
{
if (document.arkivet.password.value != "")
{
window.location=escape(document.arkivet.password.value.toLowerCase()) + ".php";
document.arkivet.password.value = "";
}
}
