/* RESEN MEDIA */
/* Drop Down Menu Javascript
----------------------------------------------------------------------------- */


	// GET BROWSER
	var browser = navigator.userAgent;


/* PAGE LOAD FUNCTION
----------------------------------------------------------------------------- */
$(window).load(function() {


/* NORMAL FUNCTION
----------------------------------------------------------------------------- */
if (!browser.match('MSIE')) {

	
		// GET EXISTING DIMENSIONS
		var navHeight = $('#navigation').height();
		var subNavHeight = $('#navigation div ul').height();
		

		// SET REMAINING DIMENSIONS
		$('#navigation div').css('top', navHeight + 'px');
		$('#navigation div').css('height', subNavHeight + 40 + 'px');
		$('#navigation div ul').css('top', subNavHeight * -1 + 'px');	

		// DEFINE SUBNAV POSITIONS	
		$('#navigation > li').each(function() {
		
			// IF THIS HAS SUBNAV
			if ($(this).children('div').length > 0) {

				var navWidth = $(this).parent().width();
				var parentLeft = $(this).position();
				parentLeft = parentLeft['left'];
				var parentWidth = $(this).width();
							
				var childWidth = $(this).children('div').children('ul').outerWidth({margin: true});
				
				var childLeft = parentLeft - childWidth / 2 + parentWidth / 2;
				var childRight = navWidth - childLeft;
							
				if (childLeft + childWidth > navWidth) {
				
					childLeft = navWidth - childWidth;
					childRight = childWidth;
				
				}
				
				$(this).children('div').children('ul').css('padding-left', childLeft + 'px');
				$(this).children('div').children('ul').css('width', childRight + 'px');
				$(this).children('div').hide();
			
			}

		});
	
	
		/* NAVIGATION
		----------------------------------------------------------------------------- */


		$('#navigation > li').hover(function() {
		
			// ADD HOVER CLASS
			$(this).children('a').addClass('selected');

			// STOP CURRENT ANIMATION
			$(this).children('div').children('ul').stop();
			
			// ANIMATION
			$(this).children('div').show();
			$(this).children('div').children('ul').animate({
			top: 0},
			200, function() {});
		
		}, function() {
			
			// REMOVE HOVER CLASS
			$(this).children('a').removeClass('selected');
			
			// STOP CURRENT ANIMATION
			$(this).children('div').children('ul').stop();
			
			// ANIMATE
			$(this).children('div').children('ul').animate({
			top: navHeight * -1 + "px"},
			200, function() {
			
				$(this).parent().hide();

			});
		
		});
		
		
		$('#navigation a[href=#]').each(function() {
		
			$(this).css('cursor', 'default');
			$(this).click(function() { return false });
		
		});
	
	

		// BILLBOARD SLIDESHOW
		$('#billboard').cycle({ 
			fx:      'fade', 
			speed:    400, 
			timeout:  7000 
		});
		
		
/* INTERNET EXPLORER 7 FUNCTION
----------------------------------------------------------------------------- */
} else if (!browser.match('MSIE 6')) {
	
		
		// GET EXISTING DIMENSIONS
		var navHeight = 29;
		var subNavHeight = 29;
		

		// SET REMAINING DIMENSIONS
		$('#navigation div').css('top', navHeight + 'px');
		$('#navigation div').css('height', subNavHeight + 40 + 'px');
		$('#navigation div ul').css('top', subNavHeight * -1 + 'px');	

		
		// ASSIGN GENERIC SUB NAV POSITIONS
		$('#navigation > li div ul').css('padding-left', '0');
		$('#navigation > li div ul').css('width', '748px');
		$('#navigation > li div').hide();
	
	
		/* NAVIGATION
		----------------------------------------------------------------------------- */


		$('#navigation > li').hover(function() {
		
			// ADD HOVER CLASS
			$(this).children('a').addClass('selected');

			// STOP CURRENT ANIMATION
			$(this).children('div').children('ul').stop();
			
			// ANIMATION
			$(this).children('div').show();
			$(this).children('div').children('ul').animate({
			top: 0},
			200, function() {});
		
		}, function() {
			
			// REMOVE HOVER CLASS
			$(this).children('a').removeClass('selected');
			
			// STOP CURRENT ANIMATION
			$(this).children('div').children('ul').stop();
			
			// ANIMATE
			$(this).children('div').children('ul').animate({
			top: navHeight * -1 + "px"},
			200, function() {
			
				$(this).parent().hide();

			});
		
		});
		
		
		$('#navigation a[href=#]').each(function() {
		
			$(this).css('cursor', 'default');
			$(this).click(function() { return false });
		
		});
	
	

		// BILLBOARD SLIDESHOW
		$('#billboard').cycle({ 
			fx:      'fade', 
			speed:    400, 
			timeout:  7000 
		});


/* INTERNET EXPLORER 6 FUNCTION
----------------------------------------------------------------------------- */
} else if (browser.match('MSIE 6')) {


		$('#navigation > li').hover(function() {
		
			// ADD HOVER CLASS
			$(this).children('a').addClass('selected');

			// SHOW
			$(this).children('div').show();
		
		}, function() {
			
			// REMOVE HOVER CLASS
			$(this).children('a').removeClass('selected');
			
			// HIDE
			$(this).children('div').hide();
		
		});
		
		
		// ASSIGN CURSUR BASED ON 
		$('#navigation a[href=#]').each(function() {
		
			$(this).css('cursor', 'default');
			$(this).click(function() { return false });
		
		});
	
	

		// BILLBOARD SLIDESHOW
		$('#billboard').cycle({ 
			fx:      'fade', 
			speed:    400, 
			timeout:  7000 
		});


/* End Load Function
----------------------------------------------------------------------------- */
}});
