$(document).ready(function(){

//WHERE ARE YOU
$('body.calendar li#sidebar_calendar, body.blog li#sidebar_blog, body.blog_home li#sidebar_blog').addClass('active');

//CALENDAR POPUP
$('div#event_list ul li a').click(function() {
	$('.popup_info').hide();
	$(this).next().show();
	//var eventTitle = $(this).children().html();
	//var eventInfo = $(this).next().html();
	//$('#calendar_popup h1').empty().html(eventTitle);
	//$('#calendar_popup div p').empty().html(eventInfo);
	//$('#calendar_popup div p').autolink();
	//$('#calendar_popup').fadeIn('fast');
});

$('#calendar_popup span.forward-entries a').click(function() {
	$('#calendar_popup').fadeOut('fast');
});


//CALENDAR FORM
$('body.calendar #field_id_12, body.calendar #field_id_4').datepick({dateFormat: 'yy-mm-dd 00:00'}).attr('size','').css('width','176px');

//striping
$('div.content-blog ul li:odd').addClass("link");

//SEARCH FORM
$('div.search-form form input').focus(function() {
	$(this).attr('value','');
});

//EXCERPTS
$('span.more_link').parent().next().show();

//ROTATING LISTS
$('div#event_list ul li:gt(6)').hide();
$('div#forum_list ul li:gt(5)').hide();

$('div#event_list_more span.show a').click(function() {
	$('div#event_list li:visible').remove();
	$('div#event_list ul li:lt(6)').fadeIn();
	if ($('div#event_list ul li').size() <= 0) {
		$('div#event_list ul').append("<li><a href='http://www.lbjlivewire.com/index.php/calendar'><span>There are no more new items. Go to Event Calendar&raquo;</span></a></li>");
	}//close if
	return false;
});

$('div#forum_list_more span.show a').click(function() {
	$('div#forum_list li:visible').remove();
	$('div#forum_list ul li:lt(5)').fadeIn();
	if ($('div#forum_list ul li').size() <= 0) {
		$('div#forum_list ul').append("<li><a href='http://www.lbjlivewire.com/index.php/forums'><span>There are no more new items. Go to Forum&raquo;</span></a></li>");
	}//close if
	return false;
});

//blur links
$('a').click(function() {
	this.blur();
});

//SAEF - hide some fields we don't want to show
//$('body.blog form#entryform #field_id_1').parent().remove();
//$('body.blog form#entryform #field_id_3').parent().remove();


//FORUM

	//collapses

	
$('body.forum tr.forumRow').hide();

$('body.forum a.expand_collapse').click(function() {
	$('tr.forumRow').hide();
	var stop = 0;
	$(this).parent().parent().nextAll().each(function(i) {
		if (stop == 0) {
			if ($(this).hasClass("main_category")) {
				stop = 1;
			}//close if
			else {
				$(this).show();
			}//close else
		}//close if
	});//close each
	return false;
});//close click

//$('body.forum td.forum').each(function() {
	//var rel = $(this).attr("rel");
	//if (rel = "http://www.lbjlivewire.com/themes/forum_themes/minimalist/images/marker_new_topic.gif") {
		//$(this).parent().addClass("new_posts");
	//}//close if
//})


});//close onReady

jQuery.fn.autolink = function () {
	return this.each( function(){
		var re = /((http|https|ftp):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>))/g;
		$(this).html( $(this).html().replace(re, '<a href="$1">$1</a> ') );
	});
}
