///////////JS array for ineed pages ///////////////////////////////////////////////////////////////////////////////////
	var iNeedPageArray =new Array("branding-strategies","lead-generation-marketing","user-experience","website-design","search-engine-optimization","marketing-measurement-metrics","social-media-marketing"); // condensed array
	
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Scope: This file contains the all functions neccessary to allow the 3 unique buckets located within the footer to open and close 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$(function() {
	
	//#################################### Bucket Open/Close #####################################################//
	var bucketStatus = new Array();
	bucketStatus[1] = "closed";
	bucketStatus[2] = "closed";
	bucketStatus[3] = "closed";
	
	function closeBucket1() {
		$('#footer-bucket1').children('.occ').removeClass('curtain-close');
		$('#footer-bucket1').animate({ marginTop: '0'}, 300).animate({ height: '76px' }, 300).queue(function() { 
			$('#footer-bucket1').removeClass('bucket-open');
			$('#footer-bucket1').dequeue();
		});
		$('#footer-bucket1').children('.occ').siblings('.additional-info').fadeOut();
		
		////////// Handle the special contact for case //////////////
		$('.doorContact').css('display','none');	
		$('#mapFooterContainer').css('display','inline');
		$('#comments').css('height','40px');
	}
	
	function openBucket1() {
		$('#footer-bucket1').children('.occ').addClass('curtain-close');
		$('#footer-bucket1').animate({ height: '392px' }, 300).animate({ marginTop: '-306px'}, 300).addClass('bucket-open');
		$('#footer-bucket1').children('.occ').siblings('.additional-info').show();
	}
	
	function openBucket2() {
		$('#footer-bucket2').children('.occ').addClass('curtain-close');
		$('#footer-bucket2').animate({ height: '392px' }, 300).animate({ marginTop: '-306px'}, 300).addClass('bucket-open-middle');
		$('#initialNewsTitle').css('display','none');
		$('#newsbankContainer').load('include/ajaxFiles/getNewsBanners.php','sid='+Math.random());
	}
	
	function closeBucket2() {
		$('#newsbankContainer').html('');
		$('#initialNewsTitle').css('display','block');
		$('#footer-bucket2').children('.occ').removeClass('curtain-close');
		$('#footer-bucket2').animate({ marginTop: '0'}, 300).animate({ height: '76px' }, 300).queue(function() { 
			$('#footer-bucket2').removeClass('bucket-open-middle');
			$('#footer-bucket2').dequeue();
		});
	}
	
	function openBucket3() {
		/*$('#footer-bucket3').children('.occ').addClass('curtain-close');
		$('#ca').hide();
		$('#footer-bucket3').animate({ height: '332px' }, 300).animate({ marginTop: '-306px'}, 300).addClass('bucket-open').queue(function() {
			$('#project-list').show();
			$('#footer-bucket3').dequeue();
		});*/
	}

	
	function closeBucket3() {
		$('#footer-bucket3').children('.occ').removeClass('curtain-close');
		$('#footer-bucket3').animate({ marginTop: '0'}, 300).animate({ height: '76px' }, 300).queue(function() { 
			$('#footer-bucket3').removeClass('bucket-open');
			$('#footer-bucket3').dequeue();
		});
		$('#ca').show();
		$('#project-list').hide();	
	}
	
	/////////// Close all open buckets and set their status to closed ////////////////////////////////
	function closeBuckets() {
		for(var i=1;i<=3;++i) {
			///////////// Only close the buckets, if they are already open ////////////
			if(bucketStatus[i] == "open") {
				eval("closeBucket"+i+"()");
				bucketStatus[i] = "closed";
			}
		}
	}
	
	//////////// This is the "constructor" for this open/close navigation. Initially it will close all open buckets on click, than it will open the clicked on bucket
	//////////// assuming it wasn't open from the start //
	$('.occ').livequery('click',function() {
		var idName = $(this).parent('div').get(0).id;
		var clickedOnBucketNumber = idName.substring(idName.length-1); //Takes the last character from the id name (1,2,3)
		var clickedOnBucketInitialStatus = bucketStatus[clickedOnBucketNumber]; // The initial status of the clicked on bucket
		
		closeBuckets();
		
		///////// Only open the bucket, if was initially closed (NOT closed via a user click [closeBuckets]) ///////////////
		if(clickedOnBucketInitialStatus == "closed") {
			eval("openBucket"+clickedOnBucketNumber+"()");
			bucketStatus[clickedOnBucketNumber] = "open";
		}
	});
	
	$('a.callOpenModal[rel=news]').livequery('click',function() {
		closeBucket2();
		return false;
	});
	
	$('#returnToArticle').livequery('click',function() {
		openBucket2();
	});
	
	/////////// This is a call from the doors, where we open a special contact form ////////////////////////////////////////
	$('.contactEmailFromDoors').livequery('click',function() {

		///////// Only open the bucket, if was initially closed (NOT closed via a user click [closeBuckets]) ///////////////
		if(bucketStatus[1] == "closed") {
			////// Close other buckets ///////
			closeBuckets();
			
			////// Open the first bucket ////
			openBucket1();
			
			bucketStatus[1] = "open";
			
			/////////Display the hidden form element fields and increase the comments box size //////////
			$('.doorContact').css('display','inline');
			$('#comments').css('height','100px');
			
			/////////Set the current page as the default dropdown ///
			var matchOptionID = 0;
			for(var i=0;i<=iNeedPageArray.length;++i) {
				if(iNeedPageArray[i] == currentPage) {matchOptionID = i;}
			}
			
			$("#iNeedTo option:eq("+matchOptionID+")").attr("selected","selected");
			
			/////// Hide the map ///////////
			$('#mapFooterContainer').css('display','none');
			
		}
		
		return false;
	});
	
	$('a.hijackLink').livequery('click',function() {closeBuckets()}); //Close all buckets on link click
});