var hidden=true;

function findStyleSheetProperty(selector)
{
	for (i=0; i<document.stylesheets.length; i++)
	{
		ss = document.styleSheets[i]
		rules = ss.cssRules ? ss.cssRules : ss.rules
		for (x in rules)
		{
			rule = rules[x]
			if (rule.selectorText)
				if (rule.selectorText.toLowerCase() == selector)
					return rule
		}
	}
}

$(function() {
	$('#ShowUntagbuttons')
		.click(showUntag)
	} )
	
function showUntag()
{
	if ($(this).text() == 'Show Untag buttons')
	{
		$(this).text('Hide Untag buttons');
		$('.untag').show()
	}
	else
	{
		$(this).text('Show Untag buttons');
		$('.untag').hide()
	}
	return
	
	
	rule = findStyleSheetProperty('.untag')
	if (!rule) return
	var actionbutton = document.getElementById('Show Untag buttons')
	if (hidden)
	{
		rule.style.visibility = 'visible';
		actionbutton.innerHTML = 'Hide Untag buttons';
		hidden = false;
	}
	else
	{
		rule.style.visibility = 'hidden';
		actionbutton.innerHTML = 'Show Untag buttons';
		hidden = true;
	}
}

function showEditor()
{
	if (
	$('.untag, .subs')
		.toggle()
		.is(':visible')
		)
		$('#Showdetails')
			.text('Hide details')
		else
			$('#Showdetails')
				.text('Show details')
	return
	var rule = findStyleSheetProperty('.untag')
	var rule2 = findStyleSheetProperty('.subs')
	if (!rule) return
	
	var actionbutton = document.getElementById('Show editor buttons')
	if (hidden)
	{
		rule.style.visibility = 'visible';
		rule2.style.visibility = 'visible';
		actionbutton.innerHTML = 'Hide editor buttons';
		hidden = false;
	}
	else
	{
		rule.style.visibility = 'hidden';
		rule2.style.visibility = 'hidden';
		actionbutton.innerHTML = 'Show editor buttons';
		hidden = true;
	}
}


function popterms()
{
	document.getElementById('terms').style.visibility='visible'
	document.getElementById('agree').checked = false
}
function closeterms()
{
	document.getElementById('terms').style.visibility='hidden';
	return false;
}

// this is for the "contact members" form
$(function() {
	$('#mail_selected,#mail_selected_label')
		.click( function() {
			$('#mail_member_list').show()
			} )
		.mouseenter( function() {
			if ($('#mail_selected').get(0).checked)
				$('#mail_member_list').show()
			} )
	$('#mail_all')
		.click (function () {
			$('#mail_member_list').hide()
		} )
	$('#mail_member_list')
		.css('opacity', '.9')
		.mouseleave( function() {
			$(this).hide()
		} )
	} )

$(function() {
	$('.deleteForum')
		.click( function() {
			return areyousure()
		} )
	} )
		

// page listings
$(function() {
	$('.pagelist img')
		.click(function()	{
			$('.b' + this.id)
				.toggle()
			if ($(this).attr('src') == '/images/plus.gif')
				$(this).attr('src', '/images/minus.gif')
			else if ($(this).attr('src') == '/images/minus.gif')
				$(this).attr('src', '/images/plus.gif')
		} )
	})


// this is for the edit group form, for geography selector
$(function() {
	$('#group_geography')
		.change(function() {
			if ($(this).attr('checked'))
				$('#geo_div').show();
			else
				$('#geo_div').hide()
			} )
	} )

// drop-down for editor to view unused tabs
$(function() {
	$('#unusedTabs')
		.mouseenter(function() {
			$('#unusedTabs > div').show()
		} )
		.mouseleave(function() {
			$('#unusedTabs > div').hide()
		} )
		.width($('#unusedTabs > div').width() - 6)
	$('#unusedTabs > div')
		.css('top',$('#unusedTabs').outerHeight()+'px')
	} )

