var switch_time = 500000;
var indentation = 96;
var clearlyConfig = {
     sensitivity: 10, // number = sensitivity threshold (must be 1 or higher)
     interval: 30, // number = milliseconds for onMouseOver polling interval
     over: colorize, // function = onMouseOver callback (REQUIRED)
     timeout: 100, // number = milliseconds delay before onMouseOut
     out: normalize // function = onMouseOut callback (REQUIRED)
};

var navConfig = {
     sensitivity: 10, // number = sensitivity threshold (must be 1 or higher)
     interval: 30, // number = milliseconds for onMouseOver polling interval
     over: showTab, // function = onMouseOver callback (REQUIRED)
     timeout: 30, // number = milliseconds delay before onMouseOut
     out: hideTab // function = onMouseOut callback (REQUIRED)
};
var colors = ["orange", "yellow", "light blue", "red", "dark green", "silver"];
colors.sort(function() { return 0.5 - Math.random() });
var words = ["Whangdoodles", "Persnickety", "Enlightening", "Turing", "Helvetica", "Hornswoggle", "Mustachioed", "Auric", "Baubles", "Cygnet", "Effusive", "Gigglesome", "Halcyon", "Asynchronous", "Incognito", "Kismet", "EIEIO", "Louche", "Non-Newtonian", "Mellifluous", "Nepenthe", "Penumbra", "Monomath", "Quixotic", "Rhomboidal", "Syzygy"];
function getNewWord() {
    return "/" + words[Math.floor(Math.random() * words.length)] + "/";
};
function getIndentation() {
    return '-' + indentation + 'px';
};
function colorize() {
    var newColor = $("#page").css("background-color");
   $(this).animate({ color: "#000", backgroundColor: newColor }, 80);
};
function normalize() {
    $("h4", this).text(getNewWord());
    $(this).animate({ color: "#FFF", backgroundColor: "#000" }, 'slow');
};
function hideTab() {
	//    $(this).animate({ marginLeft: getIndentation(), color: "#FFF", background: "url('/media/img/tab.png') no-repeat top right" }, 'slow');
    $(this).find(".text").hide();
    $(this).animate({ width: '25px', color: "#FFF", background: "url('/media/img/tab.png') no-repeat top right" }, 'slow');

};
function showTab() {
    var newColor = $("#page").css("background-color");
    //    $(this).animate({ marginLeft: '-20px', color: newColor }, 280);
    $(this).animate({ width: '100px', color: newColor }, 280);
    $(this).find(".text").show();
};
$(document).ready(function() {
 	$("#page")
 	    .animate({ backgroundColor: colors[0] }, 700);
// 	    .animate({ backgroundColor: colors[1] }, switch_time)
// 	    .animate({ backgroundColor: colors[2] }, switch_time)
// 	    .animate({ backgroundColor: colors[3] }, switch_time)
// 	    .animate({ backgroundColor: colors[4] }, switch_time)
// 	    .animate({ backgroundColor: colors[5] }, switch_time)
// 	    .animate({ backgroundColor: colors[6] }, switch_time);
	if ($("body").attr("id") == 'home') {
	    var delay = 800;
	    $('.nav_buttons li').each(function(e) {
			    $(this).hide()
				    .fadeIn(delay)
				    .animate({ width: '100px' }, 'fast')
				    .animate({ width: '25px' }, 'slow');
			    delay += 100;
		    });
	}
	$(".clearly_buttons li").hoverIntent(clearlyConfig);
	$(".nav_buttons li").hoverIntent(navConfig);
	//	$('#page_content').jScrollPane();
	});

// 	    $('.nav_buttons li').each(function(e) {
// 			    var the_this = $(this);
// 			    $(this).find(".text").hide();
// 			    $(this).hide()
// 				    .fadeIn(delay)
// 				    .animate({ width: '120px' }, 'fast', function() {
// 						    the_this.find(".text").show(function(){the_this.find(".text").hide();
// 								    the_this.animate({ width: '25px' }, 'slow')});
// 					    });
// 			    delay += 100;
// 		    });

