// JavaScript Document

var obj = null;

function checkHover() {
	if (obj) {
		obj.find('ul').fadeOut('fast');	
	} //if
} //checkHover


$(document).ready(function(){
						   
	$('li.topItem').find('li').hover(function(){
		$(this).css({backgroundColor: '#CCCCCC' });
	},function(){ 
		$(this).css({backgroundColor: '#FFFFFF' });
	});

	$('li.topItem').hover(function(){
		var imgPath = $(this).find('a:first').children('img');
		
		if (imgPath.attr('alt') == "Why OakBend") {
			imgPath.attr('src','images/nav/nav_why_over.jpg');
		}else if (imgPath.attr('alt') == "Available") {
			imgPath.attr('src','images/nav/nav_ava_over.jpg');
		}else if (imgPath.attr('alt') == "Location") {
			imgPath.attr('src','images/nav/nav_loc_over.jpg');
		}else if (imgPath.attr('alt') == "Resources") {
			imgPath.attr('src','images/nav/nav_res_over.jpg');
		}	else if (imgPath.attr('alt') == "Contact Us") {
			imgPath.attr('src','images/nav/nav_con_over.jpg');
		}	
		
		if (obj) {
			obj.find('ul').fadeOut('fast');
			obj = null;
		} //if
		
		$(this).find('ul').fadeIn('fast');
		
		//$(this).find('ul:first').animate({width: "show"}, 500);
		//$(this).find('ul:first').animate({width: '130px' }); //Shows Sub Menu animates down. Adjust number for time.
		
	},function(){ 
		var imgPath = $(this).find('a:first').children('img');
		
		if (imgPath.attr('alt') == "Why OakBend") {
			imgPath.attr('src','images/nav/nav_why.jpg');
		}else if (imgPath.attr('alt') == "Available") {
			imgPath.attr('src','images/nav/nav_ava.jpg');
		}else if (imgPath.attr('alt') == "Location") {
			imgPath.attr('src','images/nav/nav_loc.jpg');
		}else if (imgPath.attr('alt') == "Resources") {
			imgPath.attr('src','images/nav/nav_res.jpg');
		}	else if (imgPath.attr('alt') == "Contact Us") {
			imgPath.attr('src','images/nav/nav_con.jpg');
		}
		
		
		obj = $(this);
		setTimeout("checkHover()", 200);
	});
	
	$('a.basic').click(function (e) {
		e.preventDefault();
		$('#basicModalContent').modal();
	});
	
	$('a.render').click(function (e) {
		e.preventDefault();
		$('#renderContent').modal();
	});
	
	$('a.popUp').click(function (e) {
		e.preventDefault();
		$('#popUpContent').modal();
	});
	
	$('a.features').click(function (e) {
		e.preventDefault();
		$('#featuresContent').modal();
	});
	
});

$(document).ready(function() {
	$('#Nav > li').hover(function() {
		if (obj) {
			obj.find('ul').fadeOut('fast');
			obj = null;
		} //if
		
		$(this).find('ul').fadeIn('fast');
	}, function() {
		obj = $(this);
		setTimeout(
			"checkHover()",
			400);
	});
});
