$(document).ready(function() {
    
    var totalSubNavWidth = 0;
    var currentElementWidth = 0;
    
    if ($("body").hasClass("frontpage")) {
        frontpage_image_resize();
        $(window).resize(frontpage_image_resize);
    }
    
    $('.secondaryNav li').each(function() {
        currentElementWidth = $(this).width();
        totalSubNavWidth = totalSubNavWidth + (currentElementWidth + 8);
    });
    
    totalSubNavWidth = totalSubNavWidth+1;
    
    subNavOffset = (555 - totalSubNavWidth) / 2;
    
    $('.secondaryNav').css({'width' : totalSubNavWidth+'px', 'position' : 'relative', 'left' : subNavOffset+'px'});
    
});

function getInternetExplorerVersion() {
	var rv = -1;
	if (navigator.appName == 'Microsoft Internet Explorer') {
		var ua = navigator.userAgent;
		var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
		rv = parseFloat( RegExp.$1 );
	}
	return rv;
}

function init() {
    $('a.popupLink').bind('click', function(e) { popupWindow($(this).attr('href'), $(this).attr('title').replace(/[^A-z]/ig, ''),'width=550, height=400, scrollbars'); e.preventDefault(); });
}

function popupWindow(url, name, attributes){
	var newWindow = window.open(url, name, attributes);
	newWindow.focus();
}
