function isIE6() {
	return navigator.userAgent.toLowerCase().indexOf("msie 6.") != -1;
}

function roundedTabsCheck() {
	// Returns true for non-IE
	return $.support.leadingWhitespace;
}


function roundCommonLayoutComponents() {
    Nifty("div#top-bar", "bottom");
    Nifty("div#logo", "tl");
    Nifty("div#header-picture", "tr");
    Nifty("div#footer", "bottom");
    
    Nifty("h1", "top");
    if(roundedTabsCheck()) {
        Nifty("h2", "top");
        Nifty("h3", "top");
        Nifty("li.tab", "top");
    }
    else {
        Nifty("h2.not-tab", "top");
    }
}


function manageBackgrounds() {				
    var windowQ = $(window)
    var windowWidth = windowQ.width();
    var windowHeight = windowQ.height();
    
    if(windowWidth > 1100) {
        var leftBackground = 'url(/site-media/img/sidebar-background.png) repeat-y';
        var rightBackground = 'url(/site-media/img/sidebar-background-right.png) top right repeat-y';
    }
    else {
        var leftBackground = 'none';
        var rightBackground = 'none';
    }
    
    $('html').css('background', leftBackground);
    
    var bodyWrapper = $("#body-wrapper");
    bodyWrapper.css("background", rightBackground);
    if(windowHeight > bodyWrapper.height()) {
        bodyWrapper.height(windowHeight);
    }
}


function loadGoogleMap(dom_id, latitude, longitude, zoom, addMarker) {
    google.load("maps", "2.x");
    
    function initializeMap() {
        var memberLocation = new google.maps.LatLng(latitude, longitude);
        
        var map = new google.maps.Map2(document.getElementById(dom_id));
        map.setCenter(memberLocation, zoom);
        map.addControl(new google.maps.SmallMapControl());
        map.addControl(new google.maps.ScaleControl());
        
        if(addMarker) {
            var marker = new google.maps.Marker(memberLocation);
            map.addOverlay(marker);
        }
    }
    
    google.setOnLoadCallback(initializeMap);
}


$(function() {
    roundCommonLayoutComponents()
    manageBackgrounds();
    
    $(window).resize(function() {
        manageBackgrounds();
    });
});
