	var menuArray = new Array();
	
	function fillMenuItems(){
		
		var count = 0;
		
		jQuery("ul.kwicks > li").each(function(i){
			if (i == 0) {count = 1}
			menuArray[count] = jQuery(this).children('.menuItem').html();	
			count++;
		});
		
		count = "";
	}
	
	function getURLhash(){
		var fullurl = window.location.href.toString();
		
		if (fullurl.indexOf("#") != -1){
			var urlsplit = fullurl.split("#", 2);
			var hash = urlsplit[1].toLowerCase();
			
			for (var i=1; i < menuArray.length; i++){
				if (hash == menuArray[i].toLowerCase()) {
					openContent(i);	
				}
			}
		}
			
	}
	
	function setURLhash(id){
		var oldurl = window.location.toString();
		
		if (oldurl.indexOf("#") != -1){
			var spliturl = oldurl.split("#", 2);
			var fullurl = spliturl[0] + "#" + menuArray[id];
			openContent(id);
			window.location.href = fullurl;
		} else {
			var fullurl = oldurl + "#" + menuArray[id];
			openContent(id);
			window.location.href = fullurl;
		}
	}
	
	function openContent(option){
		jQuery('div[class^=contentItem]').hide();
		var fadeItem =  '.contentItem' + option;
		jQuery(fadeItem).fadeIn("fast");
	}

jQuery(document).ready(function(){
	fillMenuItems();
	getURLhash();
	
	jQuery('li[id^="kwick"]').click(function(){
		sI = jQuery(this).attr("id");
		var content = sI.substring(5, sI.length);
		setURLhash(content);
		basicTitle = "Sonrise Biblical Counseling";
	});
		
	jQuery('.eContact').click(function(){
		e = "mailto:";
		m = "info";
		a = "@";
		i = "sonrisebiblicalcounseling";
		l = ".com";
		em = e + m + a + i + l;
		popupEmail = window.open(em);
		popupEmail.close();
	});
		
	jQuery('.fadeLink').fadeTo("slow", .80);
	
	jQuery('.fadeLink').mouseover(function(){
		jQuery(this).fadeTo("fast", 1);
	});
	
	jQuery('.fadeLink').mouseout(function(){
		jQuery(this).fadeTo("slow", .80);
	});
	
	jQuery('.copyright').click(function(){
		window.open("http://www.sonrisebaptist.com");
	});	
	
	jQuery(document).ready(function(){
		jQuery('.kwicks').kwicks({
			max: 180,
			spacing: 2,
			duration: 400,
			sticky: true
			/* event: 'click'*/
		});
	});		
});


