function clickAll() {						//for clickable containers   
    var containerLink = $(".allClick");
    containerLink.click(function () {
        window.location = $(this).find("a:first").attr("href")
    });
    containerLink.hover(function () {
        window.status = $(this).find("a:first").attr("href")
    }, function () {
        window.status = ""
    })
}

function dropdownContact() {
	$("#ContactButton").hoverIntent(
		function() { 
			$("#ContactAction").addClass('active');
			$("#ContactForm").show();
			$("#ContactInner").show().animate({"marginTop":"0px", "height":"225px"});
		},
		function() { 
			$("#ContactAction").removeClass('active');
			$("#ContactForm").fadeOut('slow');
			$("#ContactInner").animate({"marginTop":"-30px", "height":"0px"}); 
		}
	);
}

function addTopNavActive() {
	$('#TopNavButtonWrap div a').each(function() {
		var thisNavButton =  $(this).attr("href");
		var currentURL = window.location.pathname;
		if ( thisNavButton == currentURL ) { $(this).parent().addClass('active'); }
		if ( currentURL == "/" ) 
			{  }
		else 
			{ $('#ContactBackground').css({'opacity' : 0.9, 'background-color' : '#ccc' }); }
	});
}


function hoverActions() {
	$("#Boxes .Box").hover(
		function() { 
			$(this).animate({ 
				'backgroundColor' : '#fff' }, 0 
			); 
			$(this).click( function() {
				window.location = $(this).find("a:first").attr("href");
			});
		},
		function() { 
 			$(this).animate({ 
				'backgroundColor' : '#f3f4f5' }, 400 
			); 
		}
	);
	$('a.hoverGold').hover(
		function() {
			$(this).animate({ 'color' : '#d4b263' }, 50);
		},
		function() {
			$(this).animate({ 'color' : '#666' }, 400);
		}
	);
	$("#ContactForm .Box").hover(
		function() { 
			$(this).find('.Left').animate({ 
				'height' : '100%' }, 200 
			); 
			$(this).find('.Right').animate({ 
				'height' : '100%' }, 200 
			);
		},
		function() { 
 			$(this).find('.Left').animate({ 
				'height' : '0px' }, 200 
			);
			$(this).find('.Right').animate({ 
				'height' : '0px' }, 200 
			);  
		}
	);
}

function mapPop() {
	$('#mapPop').click(function() {
		function windowMatch() { 
			var windowHeight = $('body').css('height');
			$('#cboxOverlay').css({ 'height' :  windowHeight });
		}
		$.colorbox({ href: "/includes/php/map.php", opacity: 0.5, width: "600px", height: "560px", iframe: true, scrolling: false, onOpen: function() { windowMatch();  } });
	});
	
}

function mailtoLinks() {
    $("a.mailto").each(function () {
        var emailData = $(this).attr("title").split(",");
        var emailAddr = emailData[0] + "@" + emailData[1] + "." + emailData[2];
        $(this).attr("href", "mailto:" + emailAddr).attr("title", emailAddr);
    });
}

$(window).ready(function() { 
					
    $(".ServiceContent:first").show() 		// for the services navigation
    $(".Service").click(function () {
        $(".ServiceContent").hide();
        var activeTab = $(this).find("a").attr("href"); 
        $(activeTab).fadeIn(1000);
        return false;
    });
	clickAll();
	dropdownContact();
	addTopNavActive();
	hoverActions();
	mapPop();
	mailtoLinks()

});
