$(document).ready(function() {
	$('img[src$=.png], #header #logo a').ifixpng();
	
	// main navigation lavaLamp effect
	$("#nav ul li").each(function(){
		if ( $(this).attr("class") == "activeParent" ) {
			$(this).attr("class", "selectedLava");
		}
	});
	$('#nav ul').lavaLamp({fx: 'swing', speed: 500});
	
	//simulate mouseover on nav to get the lavalap BG to position correctly
	$('#nav ul').mouseover();

// adds square bracket to selected menu item
//if ( $("#sidemenu li.active > a") ) {
//		$("#sidemenu li.active > a").each(function(){
//			$(this).prepend("&lt; ");
//		});
//	}
	
	// homepage services switcher
	if ( $("#services").length > 0 ) {
		$("#services a").hover(function(){
			
			var selectedLI = $(this).parents("li");
			if ( selectedLI.attr("class") != "hover" ) {

				$("#services li").each(function(){
					if ( $(this).attr("id") == selectedLI.attr("id") ) {
						$(this).attr("class", "hover");
					} else {
						$(this).attr("class", "");
					}
				});
				
				$(".herobox").hide();
				hoverDiv = "#" + $(this).attr("class");
				var hoverbox = $(hoverDiv);
				hoverbox.fadeIn(1000);
			}
	
		});
	}

	// cycle tweets
	if ( $("#twitterfeed").length > 0 ) {
		$("#twitterfeed").cycle({
			fx:     'fade', 
			timeout: 10000, 
			delay:  -15000 
		});
	}

	// hide error message and stop click event
	if ( $(".goback") ) {
		$(".goback").click(function(event){
			$(".bad").hide();
			event.preventDefault();
		});
	}
  
  // validate forms
  if ( $("#contacthome").length > 0 ) {
    $("#contacthome").validate();
  }
  if ( $("#contact").length > 0 ) {
    $("#contact").validate();
  }
	
	//simulate mouseover on nav to get the lavalap BG to position correctly
	$('#nav ul').mouseover();
	
	});
