// JavaScript Document

jQuery(document).ready(function() {

    //png fix
    jQuery('img[@src$=.png], .ad a, .ad .btnBtm').IEPNGHack();


    // default setting
    var current = "aboutDefenceHealth";

    jQuery("#homeFeatureNav li").mouseover(function() {

        //Stop rotation on mouse over
        clearInterval(intId);

        jQuery("#homeFeatureNav li").removeClass("on");
        jQuery(this).addClass("on");

        //get class of link
        var getClass = jQuery("a", this).attr("class");

        // set the current one to disappear
        jQuery("#" + current).css({ marginLeft: -9999 });

        // set new current
        current = getClass;

        // set the new one to appear
        jQuery("#" + getClass).css({ marginLeft: 0 });

        return false;
    });

    jQuery("#homeFeatureNav li").mouseout(function() {
        //Re-Start rotation of options on mouseout
        intId = setInterval(Rotate, 5000);
    });
   
    //show the selected control 
    function Show(control) {
        jQuery("#homeFeatureNav li").removeClass("on");
        jQuery(control).addClass("on");

        //get class of link
        var getClass = jQuery("a", jQuery(control)).attr("class");

        // set the current one to disappear
        jQuery("#" + current).css({ marginLeft: -9999 });

        // set new current
        current = getClass;

        // set the new one to appear
        jQuery("#" + getClass).css({ marginLeft: 0 });

    }

    var counter = 0;
    function Rotate() {
        
        //Rotate the different home page option
        if (counter == 0)
            Show("#liAboutDef");
        if (counter == 1)
            Show("#liCoverCost");
        else if (counter == 2)
            Show("#liRightHealthCover");
        else if (counter == 3)
            Show("#liJoin");

        if (counter == 3)
            counter = 0;
        else
            counter++;

    }
    
    //Start rotation
    var intId = setInterval(Rotate, 5000);



    //////////////////

    /* javascript list over to include IE6 (to counter li:hover) */

    jQuery("#subNav li").hover(function() {
        jQuery(this).addClass('over');
    }, function() {
        jQuery(this).removeClass('over');
    });

    // add class to ones with 3rd level
    jQuery('#mainNav ul li ul').each(function() {
        jQuery('ul', this).parent('li').addClass('navExpand');
    });

    // drop down
    jQuery('#mainNav li').hover(function() {
        jQuery('ul', this).css({ display: 'block' });
        jQuery('ul li ul', this).css({ display: 'none' });
    }, function() {
        jQuery('ul', this).css({ display: 'none' });
    });


    // Popup the right-most menu's 3rd levels on the left, not the right.	
    jQuery('#mainNav > ul > li:last > ul > li.navExpand > ul').addClass('left');

    // top hospitals premium table
    jQuery('.premiums').toggle(function() {
        jQuery(this).addClass('close');
        jQuery(this).parents('tr').nextAll().each(function() {
            $(this).css({ display: 'none' });
        });
    }, function() {
        jQuery(this).removeClass('close');
        jQuery(this).parents('tr').nextAll().each(function() {
            $(this).css({ display: '' });
        });
    });







});



