$(document).ready(function(){


	$(".clearable").focus(function () {		
			if ( $(this).val() == $(this).attr("title") ) $(this).val("");
	});
	
	$(".clearable").blur(function () {		
			if ( $(this).val() == '' ) $(this).val($(this).attr("title"));
	});

	$("#top-controls").jFlow({
		slides: "#top-slides",
		controller: ".top-slide-navi", // must be class, use . sign
		slideWrapper : "#top-slide", // must be id, use # sign
		selectedWrapper: "top-controls-selected",  // just pure text, no sign
		auto: true,		//auto change slide, default true
		width: "324px",
		height: "167px",
		duration: 0,
		prev: ".top-slide-prev", // must be class, use . sign
		next: ".top-slide-next" // must be class, use . sign
	});

	
	var pageID = $("body").attr("id");// Get Page ID
	

/*
$("ul#topnav li").hover(function() { //Hover over event on list item
var navClass = $(this).attr("class");	
	if (pageID != navClass) { //If page ID is not the same as hovered list class name...
			$(this).find("span").show(); //Show the subnav
		}
} , function() { //on hover out...
var navClass = $(this).attr("class");
if (pageID != navClass) { //If page ID is not the same as hovered list class name...
			$(this).css({ 'background' : 'none'}); //Ditch the background
	$(this).find("span").hide(); //Hide the subnav
		}
	
});
*/
/* DISABLED NAV!!
$("ul#topnav li").hover(navhover, navout);
*/


/*
 * Drop down menu for filtering
 */

            $("#filter-wrap").hover(function() {
                $(".dropdown dd ul").toggle();
            },
	function() {
		$(".dropdown dd ul").toggle();
	});

                        
            $(".dropdown dd ul li a").click(function() {
                var text = $(this).html();
                $(".dropdown dt a span").html(text);
                $(".dropdown dd ul").hide();
                top.location="?filter=" + getSelectedValue("filter");
				
            });
                        
            function getSelectedValue(id) {
                return $("#" + id).find("dt a span.value").html();
				
            }

            $(document).bind('click', function(e) {
                var $clicked = $(e.target);
                if (! $clicked.parents().hasClass("dropdown"))
                    $(".dropdown dd ul").hide();
            });



/*
 * Share This Settings
 */
	$(document).ready(function() {


    var loc = window.location;
	var title = $("#event-details h1").html();
	var content = $("#event-details h2").html();
	
	//$("#result").html("a href='" + (loc) + (contents));
	var facebookpath = "<a title=\"Share On Facebook\" class=\"facebook vtip\" href=\"http://www.facebook.com/share.php?u="+loc+"\"></a>";
	var myspacepath = "<a title=\"Share On Myspace\" class=\"myspace vtip\" href=\"http://www.myspace.com/index.cfm?fuseaction=postto&t="+title+"&c="+content+"&u="+loc+"&l=\"></a>";
	var stumblepath = "<a title=\"Share On StumbleUpon\" class=\"stumble vtip\" href=\"http://www.stumbleupon.com/submit?url="+loc+"&title="+title+"\"></a>";
	var diggpath = "<a title=\"Share On Digg\" class=\"digg vtip\" href=\"http://digg.com/submit?phase=2&url="+loc+"\"></a>";
	var deliciouspath = "<a title=\"Share On Delicious\" class=\"delicious vtip\" href=\"http://del.icio.us/post?url="+loc+"&title="+title+"\"></a>";
	var twitterpath = "<a title=\"Share On Twitter\" class=\"twitter vtip\" href=\"http://twitter.com/home?status=Currently looking at "+loc+"\"></a>";
	
	
	$(facebookpath).appendTo("div.sharethis");
	$(myspacepath).appendTo("div.sharethis");
	$(stumblepath).appendTo("div.sharethis");
	$(diggpath).appendTo("div.sharethis");
	$(deliciouspath).appendTo("div.sharethis");
	$(twitterpath).appendTo("div.sharethis");
	
	


});
			
	
});

/*
 * Main nav functions
 */
 
var navtimeout;
var el;

function navhover()
{ //Hover over event on list item
    clearTimeout(navtimeout);
    if(el) donavout();
    var pageID = $("body").attr("id");
    var navClass = $(this).attr("class");
    if (pageID != navClass)
    { //If page ID is not the same as hovered list class name...
        $(this).find("span").show(); //Show the subnav
    }
}

function navout()
{ //on hover out...

    el = $(this);
    navtimeout = setTimeout(donavout, 500);
}

function donavout()
{ //on hover out...
    var pageID = $("body").attr("id");
    var navClass = el.attr("class");
    if (pageID != navClass)
    { //If page ID is not the same as hovered list class name...
        //el.css({ 'background' : 'none'}); //Ditch the background
        el.find("span").hide(); //Hide the subnav
    }
}

$(document).ready(function(){
    /***********************************************
    * Easy Email Scrambler script- ¬© Dynamic Drive (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    var maildivider="[-at-]" //enter divider you use to divide your email address strings
    for (i=0; i<=(document.links.length-1); i++)
    {
            if (document.links[i].href.indexOf(maildivider)!=-1)
            document.links[i].href=document.links[i].href.split(maildivider)[0]+"@"+document.links[i].href.split(maildivider)[1]
            //
            if (document.links[i].innerHTML.indexOf(maildivider)!=-1)
            document.links[i].innerHTML=document.links[i].innerHTML.split(maildivider)[0]+"@"+document.links[i].innerHTML.split(maildivider)[1]
    }
});


$(document).ready(function(){

        $("#searchbox").autocomplete("/search-autocomplete.php", {
		width: 234,
		selectFirst: false
	});

        $("#searchbox").result(function(event, data, formatted) {
		if(data) window.location = data[1];
	});
});