jQuery.noConflict();

function mainmenu(){
jQuery("#nav-one ul").css({display: "none"}); // Opera Fix

jQuery("#nav-one li").hover(function(){//rollover
	jQuery(this).find('ul:first').css({visibility: "visible",display: "none"}).fadeIn(500);
  	jQuery(this).addClass('activeHover');
  	}, function(){//rollout
  	jQuery(this).find('ul:first').fadeOut(300);
   	jQuery(this).removeClass('activeHover');
  });
  
  //add in Top & bottom extra LIs for style
 jQuery("#nav-one UL LI:first-child").before("<li class='navcap'>&nbsp; </li>");
 jQuery("#nav-one UL LI:last-child").after("<li class='navbot'>&nbsp; </li>"); 
 
}


jQuery.fn.hoverClass = function(c) {
	return this.each(function(){
		jQuery(this).hover( 
			function() { jQuery(this).addClass(c); },
			function() { jQuery(this).removeClass(c);}
		);
	});
};	


jQuery(document).ready(function(){

	mainmenu();
		
	//isolate offsite links and make blank
	jQuery("a[href*='http://']:not([href*='"+location.hostname+"'])").attr("target","_blank");
	
	//tweak parent image settings
	jQuery("#imageCollectionHolder :nth-child(3), #imageCollectionHolder :nth-child(6), #imageCollectionHolder :nth-child(9)").css("margin-right", "0px");
	
	//tweak parent image settings
	jQuery("#contentInner .latestNews li:last").css("border-bottom", "none");
	
	//tweak footer logo margin
	jQuery("#footerLogos UL li:last").css("margin-right", "0px");
	
	//add pdf icons
	jQuery('#maincontent a[href$=".pdf"]').each(function(){
    	jQuery(this).wrap("<span class='pdf'></span>");
		jQuery(this).attr("target","_blank");
	}); 
	
	//add ppt icons
	jQuery('#maincontent a[href$=".ppt"]').each(function(){
    	jQuery(this).wrap("<span class='ppt'></span>");
		jQuery(this).attr("target","_blank");
	}); 
	
	//add doc icons
	jQuery('#maincontent a[href$=".doc"], #maincontent a[href$=".docx"]').each(function(){
    	jQuery(this).wrap("<span class='doc'></span>");
		jQuery(this).attr("target","_blank");
	}); 

	
	//tooltips 
		
	//tooltips Images on Mouse over and out	
	jQuery('#imageCollectionHolder .parentPagePostImage IMG').hover(
			//roll over
			function(){
				var tip = jQuery(this).attr('alt');
				jQuery('#tooltips').html("<div class='btooltipHolder'><div class='btooltip'> "+ tip +"</div><div class='btooltippointerBottom'>&nbsp;</div></div>");
			},
			//rollout
			function () {
				jQuery('.btooltipHolder').remove();
     		 }
	 );			
	
	
	
	//tooltips A HREF on Mouse over and out	
	jQuery('#footerLogos LI A').hover(
			//roll over
			function(){
				var tip = jQuery(this).html();
				jQuery('#tooltips').html("<div class='btooltipHolder footerTips' style='display:none'><div class='btooltipHolderInner'><div class='btooltip'> "+ tip +"</div><div class='btooltippointerBottom'>&nbsp;</div></div></div>");
				jQuery('.btooltipHolder').slideUp(200);
			},
			//rollout
			function () {
				jQuery('.btooltipHolder').remove();
     		 }
	 );			
	
	
	
	//tooltips on Move
	jQuery('#imageCollectionHolder .parentPagePostImage IMG, #footerLogos LI A').mousemove(function(event) {
			var myHeight = jQuery(".btooltipHolder").height()
			jQuery('.btooltipHolder').css({
				top: (event.pageY - (myHeight +11)) + 'px',
				left: (event.pageX - 11) + 'px'
			});
			jQuery('.btooltipHolder').fadeIn(400);
	}); 
	
	
	
	//tooltips from title tag
	jQuery('#mgfarm').hover(
			//roll over
			function(){
				tip = jQuery(this).attr('title');
				// remove the title tag
				jQuery(this).attr('title', "");
				jQuery('#tooltips').html("<div class='btooltipHolder' style='display:none'><div class='btooltipHolderInner'><div class='btooltip'>"+ tip +"</div></div></div>");
				jQuery('.btooltipHolder').fadeIn(200);
			},
			//rollout
			function () {
				jQuery('.btooltipHolder').slideUp(170);
				// set the title tag back
				jQuery(this).attr('title', tip );
     		 }
	 );			
	
	
	
	//tooltips on Move below
	jQuery('#mgfarm').mousemove(function(event) {
			var myHeight = jQuery(".btooltipHolder").height()
			jQuery('.btooltipHolder').css({
				top: (event.pageY + (21)) + 'px',
				left: (event.pageX - 16) + 'px'
			});
			jQuery('.btooltipHolder').fadeIn(400);
	}); 
	
	
	//thumbnail gallery
	
	
	jQuery("#thumbGalleryThumbnailImage li a").click(function(){
		//get the title from image to change heading to
		getTitleFromImage = jQuery("> img", this).attr("title");
		//hide the heading and change the title text
		jQuery("#thumbGallery h3").hide().html(getTitleFromImage);
		//hide and swap the image
		jQuery("#thumbGalleryLargeImage img").hide().attr({"src": jQuery(this).attr("href")}).fadeIn(400, showHeadingText(this));
		jQuery("#thumbGalleryThumbnailImage LI A").removeClass('active');	
		jQuery(this).addClass('active');
		//jQuery(this).attr("href", "#thumbGallery")
		return false;
	});
	
	
	function showHeadingText(what){
	
		jQuery("#thumbGallery h3").fadeIn(900);
		return false
	}
	
	
	jQuery("#thumbGalleryLargeImage>img").load(function(){jQuery("#thumbGalleryLargeImage>img:hidden").fadeIn("slow")});
	jQuery("#thumbGalleryLargeImage h2").fadeIn("slow");	
	jQuery("#thumbGalleryThumbnailImage LI A:first").addClass('active');	
	jQuery("#thumbGalleryThumbnailImage LI:last").addClass('last');	
	jQuery("#thumbGallery").append('<div class="cleaner">&nbsp;</div>');	
	
	//show hide headings
	jQuery("H3.more").prepend("<span class=\"moreText\">Read More</span>")
	
	jQuery("H3.more").next("DIV").hide().addClass('moreHiddenContent');	
	
	jQuery("H3.more").click(function(){	
		
		var targetObject = jQuery(this).next("DIV");
		
		if (targetObject.is(":hidden") == true){targetObject.slideDown(500, changeMoreText(this))} else {targetObject.slideUp(500, changeMoreText(this))}
		
	});
	
	function changeMoreText(what){
		
		var textlink = jQuery(what).children("SPAN.moreText");
		//textlink.css("border", "1px solid red")
		
		var targetObject = jQuery(what).next("DIV");
		//targetObject.css("border", "1px solid red")
		
		if (targetObject.is(":hidden") == true){
			textlink.text("Close");
			jQuery(what).removeClass("closed")
			jQuery(what).addClass("open")
			} else {
			jQuery(what).removeClass("open")
			jQuery(what).addClass("closed")
			textlink.text("Read More")
			}
		
   	}

	//contact screen on email send
	jQuery('.emailSuccess').hide().fadeIn(500)
	
	//zebra the tables
	jQuery("TABLE tr:odd").addClass("oddRow");  
 	jQuery("TABLE tr:even").addClass("evenRow");
			
//closing on doc ready	
});





