/**
 * Created by JetBrains PhpStorm.
 * User: garethablett
 * Date: 26/04/2011
 * Time: 12:24
 */

var navMan = new Class({

    mainNav : null,

    initialize : function( options ){

        this.mainNav = options.navElement;

        this.mainNav.getChildren().each( function( item, index){
            subNav = item.getChildren('ul');
            subNav.each( function( item2, index2 ){
                item.addEvents({
                    'mouseover' : function(){
                        item2.setStyle('display','block');
                    },
                    'mouseout' : function(){
                        item2.setStyle('display','none');
                    }
                })
             //   console.log( item2);
            });

        })

    }

});

window.addEvent('domready', function(){
     var navloader = new navMan({
        navElement : $('nav')
     })
     
     if (Browser.Plugins.Flash.version < 1) {
     	$$('body')[0].addClass('noflash');
     }
})

window.addEvent('load', function(){
     
     // set the class of the body depending on the height of the window
     fixBar ();
})

window.addEvent('resize', function(){
     
     // set the class of the body depending on the height of the window
     fixBar ();
})

function fixBar () {

	// find the height of the window and the content
	var winHeight = window.innerHeight ;
	var pageContainer = $('container');
	var pageSize = pageContainer.getSize() ;
	var pageHeight = pageSize.y ;
	
	//console.log( winHeight + ' - ' + pageHeight );
	
	// if the window is taller than the page
	if ( winHeight > pageHeight ) {
	
		$$('body')[0].addClass('tall');
	
	// if the window is shorter than the page
	} else if ( $$('body')[0].hasClass('tall') ) {
	
		$$('body')[0].removeClass('tall');
	
	}

}



