$(function(){
var spt = $('span.mailme');
var at = / at /;
var dot = / dot /g;
var addr = $(spt).text().replace(at,"@").replace(dot,".");
$(spt).after('<a class="blue" href="mailto:'+addr+'" title="Send an email">'+ addr +'</a>')
.hover(function(){window.status="Send a letter!";}, function(){window.status="";});
$(spt).remove();
});

$(document).ready(function(){

	//$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
	
	$("ul.topnav li a").mouseover(function() { //When trigger is clicked...
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
	
	$('#slider1').bxSlider({displaySlideQty: 7, moveSlideQty: 1, wrapperClass: 'bx-wrapper1'});
	$('#slider1 img').hover(function() {
				$(this).fadeTo(500, 0.8);
			}, function() {
				$(this).fadeTo(500, 1);
			}
		);
	
	var slider4 = $('#slider4').bxSlider({
				controls: false
	});

	$('.thumbs a').click(function(){
		var thumbIndex = $('.thumbs a').index(this);
		slider4.goToSlide(thumbIndex);
		$('.thumbs a').removeClass('pager-active');
		$(this).addClass('pager-active');
		return false;
	});
	
	$('.thumbs a:first').addClass('pager-active');

	
});

function loading(){
	//animatedcollapse.show(['jason', 'kelly', 'michael']);
	window.setTimeout('show()', 1500);
}
function show(){
	//animatedcollapse.hide(['jason', 'kelly', 'michael']);
	animatedcollapse.show(['aboutc', 'publicationsc', 'contactc']);
}

function loading2(){
	window.setTimeout('show2()', 1500);
}
function show2(){
	//animatedcollapse.hide(['jason', 'kelly', 'michael']);
	animatedcollapse.show(['clienttestimonialsc', 'architecttestimonialsc']);
	$('#slider2').bxSlider({
            auto: false,
            autoControls: false,
            autoHover: false,
            pager: true,
            controls: false,
			pagerSelector: '#my-pager'
        });
}

function loading3(){
	window.setTimeout('show3()', 1500);
}
function show3(){
	animatedcollapse.show(['servicesc']);
	var slider = $('#slider3').bxSlider({
				controls: false,
				auto: false,
				pager: false
			});
	
	$('#slide0').addClass('pager-active');
	$('#slide0').click(function() {
		slider.goToSlide(0);
		$('#services-tab ul li a').removeClass('pager-active');
		$(this).addClass('pager-active');
		return false;
    });
        
	$('#construction').click(function() {
		slider.goToSlide(1);
		$('#services-tab ul li a').removeClass('pager-active');
		$(this).addClass('pager-active');
		return false;
	});
	
	$('#subcontractors').click(function() {
		slider.goToSlide(2);
		$('#services-tab ul li a').removeClass('pager-active');
		$(this).addClass('pager-active');
		return false;
	});
	
	$('#green-building').click(function() {
		slider.goToSlide(3);
		$('#services-tab ul li a').removeClass('pager-active');
		$(this).addClass('pager-active');
		return false;
	});
}
