$(document).ready(function() {
    if(jQuery.browser.msie) {
        $('#navMain li').hover(
            function() {
                $(this).addClass('hover');
            },
            function() {
                $(this).removeClass('hover');
            }
        );
    }
    if(jQuery.browser.msie) {
        $('a').hover(
            function() {
                $(this).addClass('hover');
            },
            function() {
                $(this).removeClass('hover');
            }
        );
    }
    $('a[class*=external]').attr('target', '_blank');
	$('li[class*=external] a').attr('target', '_blank');
    
    if($('#welcomeHeader').length > 0)
        imgRotation($('#welcomeHeader'));
        
    if($('#welcomeContent').length > 0)
        imgRotation2($('#welcomeContent'));
    
});

var maxImages = 12;
var maxImages2 = 4;
var timeout = 6; // in sec

function imgRotation(el, oldClass) {
    if (oldClass != null)
        el.removeClass(oldClass);
    
    cssClass = 'pic' + rand(1, maxImages);
    el.addClass(cssClass);
    setTimeout(function() { imgRotation(el, cssClass) }, timeout*1000);
}

function imgRotation2(el, oldClass) {
    if (oldClass != null)
        el.removeClass(oldClass);
    
    cssClass = 'pic' + rand(1, maxImages2);
    el.addClass(cssClass);
}

function rand(min, max) {
    if(min > max) {
        return(-1);
    }
    if(min == max) {
        return(min);
    }
    return (min + parseInt(Math.random() * (max-min+1)));
}


