﻿$(document).ready(function() {
    //ie6 check
    if ($.browser.msie && $.browser.version.substr(0, 2) == "6.") {
        //fix png
        DD_belatedPNG.fix('#services-menu-content, #news-menu-content');
        
        //show menu items
        $('#nav ul#menu li#home > a')
				.css('display', 'block')
				.css('margin', '0')
				.css('padding', '0')
				.css('width', '59px')
				.css('height', '30px')
				.css('background', 'url(\'/Images/menu/unrestricted/home.jpg\')')
				.hover(function() {
				    $(this).css('background-position', '0 -30px');
				}, function() {
				    $(this).css('background-position', '0 0');
				});

        $('#nav ul#menu li#products > a')
				.css('display', 'block')
				.css('margin', '0')
				.css('padding', '0')
				.css('width', '77px')
				.css('height', '30px')
				.css('background', 'url(\'/Images/menu/unrestricted/products.jpg\')')
				.hover(function() {
				    $(this).css('background-position', '0 -30px');
				}, function() {
				    $(this).css('background-position', '0 0');
				});

        $('#nav ul#menu li#services > a')
				.css('display', 'block')
				.css('margin', '0')
				.css('padding', '0')
				.css('width', '75px')
				.css('height', '30px')
				.css('background', 'url(\'/Images/menu/unrestricted/services.jpg\')')
				.hover(function() {
				    $(this).css('background-position', '0 -30px');
				}, function() {
				    $(this).css('background-position', '0 0');
				});

        $('#nav ul#menu li#aircraft-leasing > a')
				.css('display', 'block')
				.css('margin', '0')
				.css('padding', '0')
				.css('width', '119px')
				.css('height', '30px')
				.css('background', 'url(\'/Images/menu/unrestricted/aircraft_leasing.jpg\')')
				.hover(function() {
				    $(this).css('background-position', '0 -30px');
				}, function() {
				    $(this).css('background-position', '0 0');
				});

        $('#nav ul#menu li#news > a')
				.css('display', 'block')
				.css('margin', '0')
				.css('padding', '0')
				.css('width', '58px')
				.css('height', '30px')
				.css('background', 'url(\'/Images/menu/unrestricted/news.jpg\')')
				.hover(function() {
				    $(this).css('background-position', '0 -30px');
				}, function() {
				    $(this).css('background-position', '0 0');
				});

        $('#nav ul#menu li#careers > a')
				.css('display', 'block')
				.css('margin', '0')
				.css('padding', '0')
				.css('width', '71px')
				.css('height', '30px')
				.css('background', 'url(\'/Images/menu/unrestricted/careers.jpg\')')
				.hover(function() {
				    $(this).css('background-position', '0 -30px');
				}, function() {
				    $(this).css('background-position', '0 0');
				});

        $('#nav ul#menu li#about-us > a')
				.css('display', 'block')
				.css('margin', '0')
				.css('padding', '0')
				.css('width', '83px')
				.css('height', '30px')
				.css('background', 'url(\'/Images/menu/unrestricted/about_us.jpg\')') //ie6 must use jpg version
				.hover(function() {
				    $(this).css('background-position', '0 -30px');
				}, function() {
				    $(this).css('background-position', '0 0');
				});

        //menu items mouse over
        $('#menu li').hover(function() {
            //show menu items
            $('ul:first, iframe', this).css('left', 'auto').css('right', '0');

            //show menu content
            $('div#services-menu-content, #iframe-services', this).css('left', '-80px');
            $('div#news-menu-content, #iframe-news', this).css('left', '-97px');
        }, function() {
            //menu items mouseout
            //todo: change styles for menu section button

            //hide menu items
            $('ul:first', this).css('left', '-999em').css('right', 'auto');

            //hide menu content
            $('div, iframe', this).css('left', '-999em');
        });
    }

    /* keep rollover visible while hover over child element */
    //does not work with ie6

    //home
    $('#nav ul#menu li#home').hover(function() {
        $('#nav ul#menu li#home > a').css('background-position', '0 -30px');
    }, function() {
        $('#nav ul#menu li#home > a').css('background-position', '0 0');
    });

    //products
    $('#nav ul#menu li#products').hover(function() {
        $('#nav ul#menu li#products > a').css('background-position', '0 -30px');
    }, function() {
        $('#nav ul#menu li#products > a').css('background-position', '0 0');
    });
    
    //services
    $('#nav ul#menu li#services').hover(function() {
        $('#nav ul#menu li#services > a').css('background-position', '0 -30px');
    }, function() {
        $('#nav ul#menu li#services > a').css('background-position', '0 0');
    });

    //news
    $('#nav ul#menu li#news').hover(function() {
        $('#nav ul#menu li#news > a').css('background-position', '0 -30px');
    }, function() {
        $('#nav ul#menu li#news > a').css('background-position', '0 0');
    });

    //careers
    $('#nav ul#menu li#careers').hover(function() {
        $('#nav ul#menu li#careers > a').css('background-position', '0 -30px');
    }, function() {
        $('#nav ul#menu li#careers > a').css('background-position', '0 0');
    });

    //about us
    $('#nav ul#menu li#about-us').hover(function() {
        $('#nav ul#menu li#about-us > a').css('background-position', '0 -30px');
    }, function() {
        $('#nav ul#menu li#about-us > a').css('background-position', '0 0');
    });

    //remove bottom border from last elements and add top border to first elements
    $('#nav ul#menu li ul').each(function() {
        $('li:last', this).css('border-bottom', '4px solid #d6dcdf');
        $('li.sub', this).each(function() {
            $('li:first', this).css('border-top', '2px solid #d6dcdf');
        });
    });

    //make home links expand to right
    $('#nav ul#menu li#home ul li a').css('background', '#e6ecef');

    $('#nav ul#menu li#home').hover(function() {
        $('ul, #iframe-home', this).css('left', '0');
    }, function() {
        $('ul, #iframe-home', this).css('left', '-999em');
    });
});
