/* Author: 
  Michael S. Christian Jr.
*/
$(function(){

// FORMS
// --------------------------------------------------------------------------
	  $(".search").validate();
		$(".validate").validate();
// ----------------------

// MISC EFFECTS
// --------------------------------------------------------------------------

	// Scroll to Top
	/*
			var defaults = {
	  			containerID: 'moccaUItoTop', // fading element id
				containerHoverClass: 'moccaUIhover', // fading element hover class
				scrollSpeed: 1200,
				easingType: 'linear' 
	 		};
	*/
			
	$().UItoTop({ easingType: 'easeOutQuart' });

	// Colorbox
	$('.machine_listing a').colorbox();

  // ---- Preloaded Images
	//$(["img.main"]).preload();
	
	// ---- Lazyload other images
	$("article img").lazyload({
     placeholder : "/img/style/loader.gif",       
     effect: "fadeIn",
		 threshold : 300
 });
	
	// ---- A little flair...
	$("img.main").hide().fadeIn('slow');
	

  // ---- Table Sorting
	$("table.sortable").tablesorter({ 
        // sort on the first column and third column, order asc 
        sortList: [[0,0]]
    });

	// ---- Offsite links get a class and open in a new window/tab
	$('a, area').filter(function() {     return this.hostname && (this.hostname).split(":")[0]       !== (location.hostname).split(":")[0]     || $(this).attr('rel') == 'external';   })   .not(':has(img, div, mailto)')   .addClass('external')   .end()   .click(function(e) {     open(this.href);      e.preventDefault();   });
	
	// ---- PDF files
	$('a').filter(
    function(){
        return $(this).attr('href').match('.pdf$');
    })
    .addClass('pdf');
// ----------------------	
	

	// ---- Link effect
	$("a.roofing, a.hvac, a.machinery, .menu li a").hover(
		function() {
		$(this).stop().animate({opacity: '.6'}, "slow");
		},
		function() {
		$(this).stop().animate({opacity: '1'}, "fast");
		});
	
	$("a figure").hover(
		function() {
		$(this).stop().animate({opacity: "1"}, "fast");
		$(this).children("img").stop().animate({opacity: '.8'}, "fast");
		$(this).children("figcaption").stop().animate({height: '40px'}, "fast"); //141
		},
		function() {
		$(this).children("img").stop().animate({opacity: '1'}, "fast");
		$(this).children("figcaption").stop().animate({height: '35px'}, "fast");
		$(this).stop().animate({"opacity": "1"}, "fast");
		});	

	$(".cover").hover(  // Machinery Listing efect
		function() {
		$(this).stop().animate({opacity: '0'}, "fast");
		},
		function() {
		$(this).stop().animate({opacity: '1'}, "fast");
		});
// ----------------------

// LOCATIONS 
// --------------------------------------------------------------------------

	$('.locations_map').mobilymap({
		position: '100 100',
		popupClass: 'bubble',
		markerClass: 'point',
		popup: true,
		cookies: false,
		caption: true,
		setCenter: true,
		navigation: true,
		navSpeed: 1000,
		navBtnClass: 'navBtn',
		outsideButtons: '.map_buttons a',
		onMarkerClick: function(){},
		onPopupClose: function(){},
		onMapLoad: function(){}
	});
// ----------------------

// TABS 
// --------------------------------------------------------------------------

	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$("ul.tabs li").click(function() {

		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});
// ----------------------



// FORMS
//----------------------------------------------------------------------------





// END
});


















