/******************************************************************************
 * Kellari Global functions.
 * jQuery framework is required.
 * 
 * Author: Neal Krouse (krousen@comcast.net)
 *
 ******************************************************************************/

$(function() {
	if (typeof window.XMLHttpRequest == "undefined") {
		/* test for ie6, and add class to make up for lack of li:hover */
		$("#nav li").hover(
			function() {$(this).addClass("hover");},
			function() {$(this).removeClass("hover");}
		);
	}
	
	/* enhance drop-down menus */
	$("#nav li ul").hide();
	
	$("#nav>li").hover(
		function() {$(this).children("ul").slideDown("slow");},
		function() {$(this).children("ul").hide();}
	);
	
	$("#nav li li a:not('.current')").hover(
		function() {$(this).stop().animate({backgroundColor: "#ffe6c4"}, 500)},
		function() {$(this).stop().animate({backgroundColor: "#fece8b"}, 500)}
	);
	
	$("#opentable img").hover(
		function() {$(this).stop().animate({opacity: 0.6}, 500)},
		function() {$(this).stop().animate({opacity: 1.0}, 500)}
	);
	
	$("#links li ul").hide();
	$("#links>li:has(ul)").each(function() {
		$(this).children("span").toggle(
			function() {
				$("#links li ul:visible").parent("li").children("span").click();
				$(this).parent("li").children("ul").slideDown("slow");
				$(this).css({backgroundImage: "url(css/red-arrows-down.gif)"});
			},
			function() {
				$(this).parent("li").children("ul").slideUp("slow");
				$(this).css({backgroundImage: "url(css/red-arrows-left.gif)"});
			}
		);
	}).children("span").css({backgroundImage: "url(css/red-arrows-left.gif)", backgroundPosition: "left center", backgroundRepeat: "no-repeat", cursor: "pointer"})
		.hover(
			function() {$(this).css({backgroundColor:"#f5e8d8", color: "#ddb979"})},
			function() {$(this).css({backgroundColor:"#f5e8d8", color: "#34282a"})}
	);
	
	$("a[href^='http://rtvpix.com/']").attr({target: "_blank", title: "Opens in pop-up window"}).addClass("pop-up");
	
	$("a[href^='https://app.e2ma.net/']").click(function() {
		window.open("https://app.e2ma.net/app/view:Join/signupId:15684", "", "menubar=no, location=no, toolbar=no, scrollbars=yes, height=850, width=530, resizable=yes"); 
		return false;
	}).addClass("pop-up").attr("title", "Opens in pop-up window");
	
	// random quotes on left column
	$(".quote").cycle({
		fx: "scrollDown",
		timeout: 15000,
		cleartypeNoBg: true //,
		//after: function() {$(this).parent().animate( {height: $(this).height()}, 300)}
	});
	
	// random images on left column
	$("#rotator").cycle({
		random: 1,
		timeout: 500,
		speed: 9000
	});

});