// site specific javascript

	/* html 5 elements	*/
	$(document).ready(function(){
    document.createElement("header");
    document.createElement("hgroup");
    document.createElement("nav");
    document.createElement("article");
    document.createElement("address");
    document.createElement("section");
    document.createElement("datalist");
    document.createElement("time");
    document.createElement("footer");
	});
	
	
		if(!jQuery.browser.safari)
	{
		$(document).ready(function(){
			behavior_binder();
		});
	}
	else
	{
		$(window).load(function(){
			behavior_binder();
		});
	}


	/*	Binds behaviors, can be re-run whenever there are DOM changes*/
	function behavior_binder(){


	/* MENU FUNCTIONS */
	// adds a className to each menu item's LI that matches the text content, removing all non-alphanumeric characters and replacing spaces with a dash
	$('#menu-nav li a').each(function(){
		$(this).parent('li').addClass('menu-item-'+$(this).html().toLowerCase().replace(/\&amp;/g,'').replace(/[^a-zA-Z0-9 ]/g,'').replace(/\s+/g,'-'));
	})
	
	$(document).ready(function () {	
	$('#menu-nav li.menu-item').hover(
		function () {
			//show its submenu
			$('ul', this).slideDown(100);
		}, 
		function () {
			//hide its submenu
			$('ul', this).slideUp(100);			
		}
	);
	
});
	
}
	$(document).ready(function() {
	
		$('#carousel').cycle({fx: 'fade' });
		
		$("#content").addClass("clearfix");
		
		$("#tab_twitter").click(function() {
			$("#tabs").css( {backgroundPosition: "0 -66px"} )
		});
		
		$("#tab_foursquare").click(function() {
			$("#tabs").css( {backgroundPosition: "0 -132px"} )
		});
	  
		$("#tab_facebook").click(function() {
			$("#tabs").css( {backgroundPosition: "0 0"} )
		});
	  
		$("#tab_robert_says ").click(function() {
			$("#tabs").css( {backgroundPosition: "0 -198px"} )
		});
	  
	 $("#tabs li").click(function() {
            var val = $(this).attr('id');
            //alert(val);
            $('#list_'+val).removeClass("off").siblings(".list").addClass("off");
            if(!$('#list_'+val).length){
            	$('#tabs').siblings('.list').addClass('off');
            }
            $(this).addClass("selected").removeClass("hover").siblings().removeClass("selected");        
        }).hover(function() {
            if(!$(this).hasClass("selected")) $(this).addClass("hover");
        }, function() {
            $(this).removeClass("hover");
        });
			
	});
