function urlencode( url ) {     
	return escape( url.replace( /\ /g, "+" ) );
}

function urldecode( url ) {
	return unescape( url.replace( /\+/g, " " ) );
}

function getElement( name ) {
	if ( document.getElementById )
		return document.getElementById( name );
	else
		if ( document.all )
			return document.all[ name ];
		else
			if ( document.layers )
				return document[ name ];
}

function getEvent( evt ) {
	evt = ( evt ) ? evt : ( ( window.event ) ? window.event : "" )
	return evt
}

function addEvent( obj, eventType, afunction, isCapture ) {
	if ( obj.addEventListener ) {
		// W3C DOM
		obj.addEventListener( eventType, afunction, isCapture )
		return true
	} else {
		if (obj.attachEvent) {
			// Internet Explorer
			return obj.attachEvent( "on" + eventType, afunction )
		} else {
			// ????? Linx ofzo ?????
			return false
		}
	}
}

// this function is needed to work around 
// a bug in IE related to element attributes
function hasClass(obj) {
	var result = false
	if ( obj.getAttributeNode( "class" ) != null ) {
		result = obj.getAttributeNode( "class" ).value
	}
	return result
}

function popWindow(url, name, x, y, width, height, toolbar, location, dirs, status, scroll, menu, resize) {
	features = "left=" + x +
		", top=" + y +
		", width=" + width +
		", height=" + height +
		", toolbar=" + toolbar +
		", location=" + location +
		", directories=" + dirs +
		", status=" + status +
		", scrollbars=" + scroll +
		", menubar=" + menu +
		", resizable=" + resize;
	window.open( url, name, features );
}

function popSimple(url, name, x, y, width, height) {
	popWindow( url, name, x, y, width, height, 0, 0, 0, 0, 0, 0, 0 );
}

function popSimpleDlg(url, width, height) {
	x = ( screen.width - width ) / 2;
	y = ( window.screen.height - height ) / 2;
	popSimple( url, 'simple_dlg', x, y, width, height );
}

function popOld(url) {
	popWindow( url, 'old_section', 100, 100, 650, 400, 0, 0, 0, 1, 1, 0, 1 );
}

function stripeTable( tableID ) {
	// the flag we'll use to keep track of 
	// whether the current row is odd or even
	var even = false;

	// if arguments are provided to specify the colours of the even &
	// odd rows, then use the them; otherwise use the following
	// defaults:
	var evenColor	= arguments[1] ? arguments[1] : "#fff";
	var oddColor	= arguments[2] ? arguments[2] : "#ddf";
	var borderColor	= arguments[3] ? arguments[3] : "#88a";

	// obtain a reference to the desired table
	// if no such table exists, abort
	var objTable = getElement( tableID );
	if ( ! objTable )
		return;
		
	objTable.style.border = "1px solid black";
	objTable.style.padding = "1px";
	objTable.style.backgroundColor = "white";
	
	var theads = objTable.getElementsByTagName( "thead" );
	for ( var h = 0; h < theads.length; ++h ) {
		
		var thead = theads[ h ];
		//thead.style.color = "white";
		//thead.style.backgroundColor = "black";
		var trs = thead.getElementsByTagName( "tr" );

		for ( var i = 0; i < trs.length; ++i ) {
			var tr = trs[ i ];

			ths = tr.getElementsByTagName( "th" );
			for ( var j = 0; j < ths.length; ++j ) {
				th = ths[ j ];
				th.style.color = "white";
				th.style.backgroundColor = "black";
			}

		}
		
	}

	// by definition, tables can have more than one tbody
	// element, so we'll have to get the list of child
	// &lt;tbody&gt;s 
	var tbodies = objTable.getElementsByTagName( "tbody" )

	// and iterate through them...
	for ( var h = 0; h < tbodies.length; h++ ) {
	
		// find all the &lt;tr&gt; elements... 
		var trs = tbodies[ h ].getElementsByTagName( "tr" );

		// ... and iterate through them
		for ( var i = 0; i < trs.length; i++ ) {

			// avoid rows that have a class attribute
			// or backgroundColor style
			if (! hasClass(trs[i]) &&
			! trs[i].style.backgroundColor) {

				// get all the cells in this row...
				var tds = trs[i].getElementsByTagName("td");

				// and iterate through them...
				for (var j = 0; j < tds.length; j++) {

					var mytd = tds[j];
					
					
					if ( i != 0 ) {
						mytd.style.borderTop = "1px solid " + borderColor
					}
					
					if ( j != 0 ) {
						mytd.style.borderLeft = "1px solid " + borderColor
					}

					// avoid cells that have a class attribute
					// or backgroundColor style
					if (! hasClass(mytd) &&
					! mytd.style.backgroundColor) {

						mytd.style.backgroundColor =
						even ? evenColor : oddColor;

					}
				}
			}
			// flip from odd to even, or vice-versa
			even =  ! even;

		}
	}
}

function blockTable( tableID ) {
	var evenRow = false;
	var evenCol = false;

	// if arguments are provided to specify the colours
	// of the even & odd rows, then use the them;
	// otherwise use the following defaults:
	var evenRowColor = arguments[1] ? arguments[1] : "#fff";
	var oddRowColor	 = arguments[2] ? arguments[2] : "#ddf";
	var evenColColor = arguments[3] ? arguments[3] : "#cce";
	var oddColColor	 = arguments[4] ? arguments[4] : "#eee";
	var borderColor	 = arguments[5] ? arguments[5] : "#88a"

	// obtain a reference to the desired table
	// if no such table exists, abort
	var objTable = getElement( tableID )
	if ( ! objTable )
		return

	// by definition, tables can have more than one tbody
	// element, so we'll have to get the list of child
	// &lt;tbody&gt;s 
	var tbodies = objTable.getElementsByTagName( "tbody" )

	// and iterate through them...
	for ( var h = 0; h < tbodies.length; h++ ) {
	
		// find all the &lt;tr&gt; elements... 
		var trs = tbodies[ h ].getElementsByTagName( "tr" );

		// ... and iterate through them
		for ( var i = 0; i < trs.length; i++ ) {

			// avoid rows that have a class attribute
			// or backgroundColor style
			if (! hasClass(trs[i]) &&
			! trs[i].style.backgroundColor) {

				// get all the cells in this row...
				var tds = trs[i].getElementsByTagName("td");

				evenCol = false;
				// and iterate through them...
				for (var j = 0; j < tds.length; j++) {

					var mytd = tds[j];
					
					
					if ( i != 0 ) {
						mytd.style.borderTop = "1px solid " + borderColor
					}
					
					if ( j != 0 ) {
						mytd.style.borderLeft = "1px solid " + borderColor
					}

					// avoid cells that have a class attribute
					// or backgroundColor style
					if (! hasClass(mytd) &&
					! mytd.style.backgroundColor) {

						if ( ! evenCol ) {
							mytd.style.backgroundColor =
							evenRow ? evenRowColor : oddRowColor;
						} else {
							mytd.style.backgroundColor =
							! evenRow ? evenColColor : oddColColor;
						}

					}
					
					evenCol = ! evenCol;
				}
			}
			// flip from odd to even, or vice-versa
			evenRow = ! evenRow;

		}
	}
}