$(document).ready(function(){
	
	$('body').addClass('js');
	
	//$('div#main-inner').addClass('image-one');  // That div already has class image-one in the markup.
	// $('ul#bg-switcher li.imageone').addClass('active');

	$('ul#bg-switcher li.imageone').click(function() {	
		$('div#main-inner').removeClass('image-two image-three image-four image-x').addClass('image-one');
		$(this).addClass('active').siblings().removeClass('active');
	});
	$('ul#bg-switcher li.imagetwo').click(function() {	
		$('div#main-inner').removeClass('image-one image-three image-four image-x').addClass('image-two');	
		$(this).addClass("active").siblings().removeClass("active");
	});
	$('ul#bg-switcher li.imagethree').click(function() {	
		$('div#main-inner').removeClass('image-one image-two image-four image-x').addClass('image-three');
		$(this).addClass('active').siblings().removeClass('active');
	});
	$('ul#bg-switcher li.imagefour').click(function() {	
		$('div#main-inner').removeClass('image-one image-two image-three image-x').addClass('image-four');
		$(this).addClass('active').siblings().removeClass('active');
	});
	
	$('ul#bg-switcher li').hover(function(){
		$(this).css('background-position', 'bottom');
	}, function() {
		$(this).css('background-position', 'top');	
	});
	
	//Collapsing the contact us section on the homepage only
	    
	$(function(){
		$('#contact-area div.tab-sections').hide();
		var tabContainers = $('div#contact-area div.tab-sections');
		$('#contact-nav a').click(function () {
			var thisPane = $(this.hash);
			var leaveActive = 1;
			if($(".tab-sections:visible").length && !thisPane.is(":visible")){
				//just switch
				$(".tab-sections:visible").hide();
				thisPane.show();
			}
			else if(thisPane.is(":visible")){
				//slide up
				thisPane.slideUp("100");
				$(this).removeClass('active');
				leaveActive = 0;
			}
			else{
				//slide down
				thisPane.slideDown("100");
			}
			$('#contact-nav a.active').removeClass('active');
			if (leaveActive == 1)
				$(this).addClass('active');
			return false;
		});
	});
	
	// General Tabs for Content Areas
	
	var tabContent = $('div.tab-control div.tab-content');
			//tabContent.hide().filter(':first').show();
			
			$('div.tab-control ul.tab-list a').click(function () {
	    		tabContent.filter(this.hash).siblings().filter(":not(ul)").hide();
	    		tabContent.filter(this.hash).show();
	    		$(this).parent().siblings().children().removeClass('active');
	    		$(this).addClass('active');
	    		return false;
	    	});
	    	
	        $('div.tab-control').each(function() {
	        	$(this).children().filter("div").hide().filter(":first").show();
	    	    $(this).children().filter("ul").children().filter(':first').children().click();
	       	});
	    	

	// Adding the class of "pdf" to all links that point to a pdf file
	    	
	$("a[href$='pdf']").parent().addClass("pdf");
	
	// Slideshow Scripts

	$("a._slideshow").click(function() {
		window.open( $(this).attr('href'),'Video','menubar=0,scrollbars=0,toolbar=0,location=0,status=0,resizable=0,width=560,height=375,screenX=110,screenY=10,left=110,top=1' );
		return false;	
	});
		    
});