<?php
header( 'Content-type: text/javascript' );
?>//
// Start of Javascript for the Counterize plugin
//


//a function to get an element by its id regardless of the used browser
function counterize_getElementByIdUniversal( id )
{
	var elem;
	if( document.getElementById )
	{
		elem = document.getElementById( id );
	}
	else
	{
		elem = document.all[ id ];
	}
	return elem;
}

//toggle folding of corresponding ID
function counterize_fold( sourceElemId, targetElemId )
{
	var source = counterize_getElementByIdUniversal( sourceElemId );
	var target = counterize_getElementByIdUniversal( targetElemId );

	if( target && source )
	{
		if( target.className == "collapsed" )
		{
			target.className = "expanded";
			source.innerHTML = "[-]";
		}
		else
		{
			target.className = "collapsed";
			source.innerHTML = "[+]";
		}
	}
}

//
function counterize_conf( url )
{
	if( confirm( 'Are you sure that you want to delete this entry?' ) )
	{
		self.location.href = url;
	}
}

//Add filter data to the specified field
function add_filter( data, filter_field_name )
{
	var filter_field = counterize_getElementByIdUniversal( filter_field_name );
	if( filter_field )
	{
		if( filter_field.value != '' )
		{
			var tmp = filter_field.value + '||';
			if( tmp.indexOf( data + '||' ) < 0 )
			{
				filter_field.value += '||' + data;
			}
			else
			{
				alert( 'This filter is already set!' );
			}
		}
		else
		{
			filter_field.value += data;
		}
	}
}

//Clear the fields specified in the array 'fields'
function clear_filter_form( fields )
{
	var field;
	for( var i = 0; i < fields.length; i++ )
	{
		field = counterize_getElementByIdUniversal( fields[i] );
		if( field )
		{
			field.value = '';
		}
	}
}

//
// by Nannette Thacker
// http://www.shiningstar.net
//

function counterize_check_all( field )
{
	for( i = 0; i < field.length; i++ )
	{
		field[i].checked = true ;
	}
}

function counterize_uncheck_all( field )
{
	for( i = 0; i < field.length; i++ )
	{
		field[i].checked = false ;
	}
}


//
// End of Counterize Javascript
//