/**
 * MaxiScale global JS.
 * 
 * 
 */


/**
 * Runs on document load.
 * 
 * 
 */
$(document).ready(function() {
    if ($.browser.msie) {
        try {
            document.execCommand('BackgroundImageCache', false, true);
        } catch(e) {};
    }
    // Assign JS mouseover and mouseout handlers only for IE 6. Other browsers
    // will use CSS :hover to show active nav states and subnavigation.
    if ($.browser.msie && $.browser.version.substr(0, 1) == '6') {
        assignNavHandlers();
    }

	if ($.browser.msie && parseInt($.browser.version) == 6) {
		$('#nav_product ul').bgiframe();
	}
    $('.trans').find('*').pngfix();
    highlightNav(); /* TEMPORARY */
	
});


/**
 * Loops through all navigation <li> elements, and assigns handlers.
 * 
 * 
 */
function assignNavHandlers() {
    var nav_elements = $('#nav').children('li');
    for (var i = 0; i < nav_elements.length; i++) {
        $(nav_elements[i]).bind('mouseover', navOver);
        $(nav_elements[i]).bind('mouseout', navOut);
    }
}


/**
 * Nav mouseover handler.
 * 
 * 
 */
function navOver() {
    $($(this).children('a')[0]).addClass('over');
    $($(this).children('ul')[0]).addClass('over');
}


/**
 * Nav mouseout handler.
 * 
 * 
 */
function navOut() {
    $($(this).children('a')[0]).removeClass('over');
    $($(this).children('ul')[0]).removeClass('over');
}


/**
 * Temporary. Highlights current section.
 * 
 * 
 */
function highlightNav() {
    var sections = [
        'product',
        'support',
        'careers',
        'company',
        'news',
        'partners'
    ];
    for (var i = 0; i < sections.length; i++) {
        if ($('body').hasClass(sections[i])) {
            $('#nav_' + sections[i]).children('a').addClass('on');
        }
    };
}




