var $ = jQuery.noConflict();	

$(document).ready(function($) {
	if ($('.options').length) {	
	
		$('.options').hover(function() {
					$(this).addClass('selected');
				}, function() {
					$(this).removeClass('selected');
				});
		
			if (jQuery.browser.msie && jQuery.browser.version == "6.0") {
			
		} else {
			$("#our-journey a").append("<em></em>");
	
			$("#our-journey a").hover(function() {
				$(this).find("em").animate({opacity: "show", top: "-80"}, "slow");
				var text = $(this).attr("title");  // Grab the title attribute from the anchor tag and place it in a javascript variable arbitrarily named "text". "text" now holds the information
				$(this).find("em").text(text);  // place "text" inside <em>. 
			}, function() {
				$(this).find("em").animate({opacity: "hide", top: "0"}, "slow");
			});
		}
	};
	
	//mega-dropdowns
	//when hovering over link
  	$('#main-nav ul li').hover(function() {
	var currentID = $(this).attr("id"); 
		$("#drop-"+currentID).css("display", "block");
        $(this).addClass('hover'); 
        return false;
     }, function(){
        $(this).removeClass('hover'); 
		var currentID = $(this).attr("id");
		$("#drop-"+currentID).css("display", "none");
     }); 
     
    //when hovering over the drop down
    $('.drop').hover(function() {
		var dropId = $(this).attr("id");
		var theId = dropId.substr(5);
		$(this).css("display", "block");
        $("#"+theId).addClass('hover'); 
        return false;
     }, function(){
		 var dropId = $(this).attr("id");
		 var theId = dropId.substr(5);
         $(this).css("display", "none");
         $("#"+theId).removeClass('hover'); 
     });
	
	
	//open & close program headers
	$('#more-info-btn').click(function(){		
		var theClass = $('#more-info').attr("class");
			
		if (theClass == "open") {	
									   
		$('#more-info').animate({
    			height: "0px",
				height:'toggle'
  			}, 1000, function(){
				$('#more-info').removeClass("open").addClass("closed");
				$('#more-info-btn span').html('(+) More');
  			});
		} else if (theClass == "closed") {	
		$('#more-info').animate({
    			height: "265px",
				height:'toggle'
  			}, 1000, function(){
				$('#more-info').removeClass("closed").addClass("open");
				$('#more-info-btn span').html('(-) Less');
  			});
		}
		
								   
	 });
	
	
	//tabs for events & programs
	$('#tabs ul li').click(function(){ //shows tabs
		var curtab = $(this).attr('class');
		$('#tabs-text div').css('display', 'none');
		$('#tabs-text .' + curtab).css('display', 'block');	
		$('#tabs ul li').removeClass('active');
		$(this).addClass('active');
		return false;
			});
	
	//hide-show for picture thumbnails
	$('#thumbnails ul li').click(function(){ //shows tabs
		var curPic = $(this).attr('class');
		$('#pictures div').hide();
		$('#pictures .' + curPic).show();	
		$('#thumbnails ul li').removeClass('active');
		$(this).addClass('active');
		return false;
				
			});	

	$('#thumbnails ul li img').click(function(){
		var pic = $(this).parent().attr('class');
		if($(this).parent().hasClass('active')){
			//already active
		}else{
			$('#thumbnails ul li img').parent().removeClass('active');
			$(this).parent().addClass('active');
			$('#pictures div').hide();
			$('#pictures .'+pic).show();
		}
		return false;
	});
	
	$('#video-container a').click(function(){
	    $(this).hide();
	    $('#video-container > div').show();
	    return false; 
	});
	
//clears out and resets input fields
	$('input[type!=submit]').each(function() {

       var default_value = this.value;

       $(this).focus(function(){
               if(this.value == default_value) {
                       this.value = '';
               }
       });

       $(this).blur(function(){
               if(this.value == '') {
                       this.value = default_value;
               }
       });

	});
	
	
	//validates the EOH 2011 form
	
	if($('body#eohform form#eoh2011form').length){
		$('body#eohform form#eoh2011form').validate();
	};
	
	//experts page popups
	if ($(".experts").length)
	{
	$("img[rel], a[rel]").overlay({expose: '#ccc'});
	};

	
});
