// initialise plugins
jQuery(document).ready(function(){ 
	
	//contact form vaildation
	jQuery("#contactForm").validate();
	
	// image hover effect
	jQuery('.viewport').mouseenter(function(e) {
		jQuery(this).children('a').children('img').animate({ height: '161', left: '0', top: '0', width: '220'}, 100);
		jQuery(this).children('a').children('span').fadeIn(200);
	}).mouseleave(function(e) {
		jQuery(this).children('a').children('img').animate({ height: '181', left: '-10', top: '-10', width: '240'}, 100);
		jQuery(this).children('a').children('span').fadeOut(200);
	});

	// large image scroller
	jQuery('#banner') 
	.before('<div id="homebannernav">') 
	.cycle({
		fx:     'scrollHorz',
		speed:  'slow', 
		timeout: 8000, 
		pager:  '#homebannernav',
		next : '.nextButton a', 
		prev: '.prevButton a'
	});
	
	// recent scroller
	jQuery('.slider-wrap-recent') 
	.cycle({
		fx:     'scrollHorz',
		speed:  'slow', 
		timeout: 0, 
		next : '.nextrecent', 
		prev: '.prevrecent'
	});
	
	// news scroller
	jQuery('.slider-wrap-news') 
	.cycle({
		fx:     'scrollHorz',
		speed:  'slow', 
		timeout: 0, 
		next : '.nextnews', 
		prev: '.prevnews'
	});
	
	jQuery("ul#nav").supersubs({ 
		dropShadows:   true,
		minWidth:    9,   // minimum width of sub-menus in em units 
		maxWidth:    27,   // maximum width of sub-menus in em units 
		extraWidth:  2     // extra width can ensure lines don't sometimes turn over 
						   // due to slight rounding differences and font-family 
	}).superfish();  // call supersubs first, then superfish, so that subs are 
					 // not display:none when measuring. Call before initialising 
					 // containing tabs for same reason. 


	// portfolio tabs

	// Default Action
	jQuery(".tab_content").hide(); //Hide all content
	jQuery("ul.tabs li:first").addClass("active").show(); //Activate first tab
	jQuery(".tab_content:first").show(); //Show first tab content
	
	// On Click Event
	jQuery("ul.tabs li").click(function() {
		jQuery("ul.tabs li").removeClass("active"); //Remove any "active" class
		jQuery(this).addClass("active"); //Add "active" class to selected tab
		jQuery(".tab_content").hide(); //Hide all tab content
		var activeTab = jQuery(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		jQuery(activeTab).fadeIn(); //Fade in the active content
		return false;
	});

	jQuery(".col-220 img d d").hover(function() {
		jQuery(this).css({'z-index' : '999'}); /*Add a higher z-index value so this image stays on top*/ 
		jQuery(this).addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
			.animate({
				marginTop: '-8px', /* The next 4 lines will vertically align this image */ 
				marginLeft: '-6px',
				top: '50%',
				left: '50%',
				width: '231px', /* Set new width */
				height: '169px', /* Set new height */
				padding: '0'
			}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */
	
		} , function() {
		jQuery(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
		jQuery(this).removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
			.animate({
				marginTop: '0', /* Set alignment back to default */
				marginLeft: '0',
				top: '0',
				left: '0',
				width: '220px', /* Set width back to default */
				height: '161px', /* Set height back to default */
				padding: '0'
			}, 400);
	});
	
	
	
	// social icons
	
	// Hide all the tooltips
	jQuery(".social-icons li").each(function() {
	   jQuery("a span", this).css("opacity", "0");
	});
	  
	jQuery(".social-icons li").hover(function() { // Mouse over
	   jQuery(this)
		  .stop().fadeTo(500, 1)
		  .siblings().stop().fadeTo(500, 0.2);
			
	   jQuery("a span", this)
		  .stop()
		  .animate({
			 opacity: 1,
			 top: "30px"
		  }, 300);
		 
	}, function() { // Mouse out
	   jQuery(this)
		  .stop().fadeTo(500, 1)
		  .siblings().stop().fadeTo(500, 1);
		 
	   jQuery("a span", this)
		  .stop()
		  .animate({
			 opacity: 0,
			 top: "20px"
		  }, 300);
	});
	

}); 
