google.load("jquery", "1");
google.load("swfobject", "2");


google.setOnLoadCallback(function() {
	
	$.getScript("/wordpress/wp-content/themes/deltawye/lib/js/jquery.cycle.js", function(){
		if ($('.testimonials div#logos')) {
			$('div#logos').show().cycle({slideExpr: 'img'});
		}
		
		if ($('#greenServices')) {
			$('div#greenServices div div').show().cycle({
				fx: 'scrollVert',
				timeout:  5000,
				speed: 'slow',
				next: '.down',
				prev: '.up',
				pause:  1
			});
			$('#greenServices a.btn').show('slow');
		}
	});
	
	if ($('#menu')) {
		$('#menu #top a').mouseover( function() {
			var btnClass = $(this).parent().attr("class");
			var subNav = "up";
			$('#menu ul:visible').each( function() {
				if ($(this).attr("id") != "top" && $(this).attr("id") != btnClass) {
					subNav = "up";
					$(this).css({'z-index' : 1 });			
					$(this).slideUp();
				}
			});	
			$('#menu ul:hidden').each( function() {
				if ($(this).attr("id") == btnClass) {
					subNav = "down";
					$(this).css({'z-index' : 2 });	
					$(this).slideDown();
				}
			});
			if (subNav == "up") {
				$('#menu #top').css({'height' : "auto"});
			}else {
				$('#menu #top').animate({'height' : 52}, "fast");
			};
		});
		
		$('div#menu').mouseleave( function() {
			$('#menu ul:visible').each( function() {
				if ($(this).attr("id") != "top" && $(this).attr("class") != "clearfix selected") {
					$(this).css({'z-index' : 1 });			
					$(this).slideUp();
				}
			});
			$('#menu ul.selected:hidden').each( function() {
				$(this).css({'z-index' : 2 });	
				$(this).slideDown();
			});
			
			$('#menu #top').css({'height' : "auto"});
		});
	}
});
