$(document).ready(function() {

	$("#searchField").hover(function(){
			$(this).animate({backgroundColor: "#8D8D8D"},500);
			},
			function(){
			if (!$(this).hasClass("focus"))
				$(this).animate({backgroundColor: "#7D7D7D"},500);
		});
	$("#searchField").focus(function(){
		$(this).addClass("focus");
		if ($(this).attr("value") == "Search")
			$(this).attr("value","");
		});
	$("#searchField").blur(function(){
		$(this).removeClass("focus");
		if ($(this).attr("value") == "")
			$(this).attr("value","Search");
		$(this).animate({backgroundColor: "#7D7D7D"},500).css({'background-color':''});
		});
	$("#searchButton").hover(function(){
			$(this).animate({backgroundColor: "#111111"},500);
			},
			function(){
			$(this).animate({backgroundColor: "#222222"},500);
		});
	$("#searchButton").click(function(e){
		$("#search").submit();
		});
	$("#search").submit(function(e){
		e.preventDefault();
		q = $("#searchField").attr("value");
		if (q != "" && q != "Search") {
			url = "http://www.google.com/cse?cx=013960890312892790350%3Aw-ntfefiiby&cof=FORID%3A10&ie=UTF-8&ad=w9&num=10&q=" + q;
			$('<iframe id="modalDialog" src="' + url + '" frameborder="0" />').dialog({
						title:"Search",
						autoOpen:true,
						width:700,
						height:500,
						modal:true,
						resizable:true,
						autoResize:true
			}).width(680).height(480);
		}
		});
	$(".nav").children(":has(ul)").not(".active").each(function(){
		$(this).children("a").click(function(e){
			e.preventDefault();
			$(this).parent().children("ul").slideToggle();
		})
		});
	$("#topnav li a").hover(function(){
		$(this).animate({backgroundColor: "#111111", color: "#FFFFFF"},500);	
	},function(){
		$(this).animate({backgroundColor: "#222222", color: "#DDDDDD"},500);
	});
	
	
	$(".modal").click(function(e){
		e.preventDefault();
		url = $(this).attr('href');
		ptitle = $(this).attr('title');
		$('<iframe id="modalDialog" src="' + url + '" frameborder="0" />').dialog({
			title:ptitle,
			autoOpen:true,
			width:700,
			height:500,
			modal:true,
			resizable:true,
			autoResize:true
			}).width(680).height(480);			
	});
	
	$(".modal860").click(function(e){
			e.preventDefault();
			url = $(this).attr('href');
			ptitle = 'Calendar';
			$('<iframe id="modalDialog" src="' + url + '" frameborder="0" />').dialog({
				title:ptitle,
				autoOpen:true,
				width:880,
				height:520,
				modal:true,
				resizable:true,
				autoResize:true
				}).width(860).height(500);
	});

        $(".modal860menu").click(function(e){
                        e.preventDefault();
                        url = $(this).attr('href');
                        ptitle = $(this).attr('title');
                        $('<iframe id="modalDialog" src="' + url + '" frameborder="0" />').dialog({
                                title:ptitle,
                                autoOpen:true,
                                width:880,
                                height:520,
                                modal:true,
                                resizable:true,
                                autoResize:true
                                }).width(860).height(500);
        });



});
