function is_safari(){
	if(navigator.userAgent.indexOf("Safari") != -1) return 1;
	return 0;
}

function is_moz_one(){
	if (navigator.userAgent.indexOf("Mozilla/5.0") != -1 && navigator.userAgent.indexOf("rv:1.0") != -1) return 1;
	return 0;
}

function click_button(){
	if (is_safari()){
		hide_form();
		document.getElementById('progressActionForm').submit();
	}
	return true;
}

function submit_form(){
	if (!is_safari() && !is_moz_one()) hide_form();
	return true;
}

function hide_form(){
	//document.getElementById('progressActionInitiator').style.display = 'none';
	document.getElementById('progressDisplayDiv').style.display = 'block';
}

function toggle_display( the_area, the_image, the_text ) {
	if( the_area.style.display == 'none' ) {
		the_area.style.display = 'block';
		the_image.src = '/pachyderm/images/ArrowDown-black.gif';
		the_text.data = ' Collapse';
	} else {
		the_area.style.display = 'none';
		the_image.src = '/pachyderm/images/ArrowRight-black.gif';
		the_text.data = ' Expand';
	}
}

function collapse_all()
{
	the_elements = getElementsByClass( 'collapser' );
	for( i = 0; i < the_elements.length; i++ )
	{
		if( the_elements[i].parentNode.parentNode.parentNode.childNodes[1].className == 'beditor_body' ) 
		{
			the_area = the_elements[i].parentNode.parentNode.parentNode.childNodes[1]
			the_image = the_elements[i].childNodes[0]
			the_text = the_elements[i].childNodes[1]
		}
		else
		{
			the_area = the_elements[i].parentNode.parentNode.parentNode.childNodes[3]
			the_image = the_elements[i].childNodes[1]
			the_text = the_elements[i].childNodes[2]
		}
		
		the_area.style.display = 'none';
		the_image.src = '/pachyderm/images/ArrowRight-black.gif';
		the_text.data = ' Expand';
	}
}

function expand_all()
{
	the_elements = getElementsByClass( 'collapser' );
	for( i = 0; i < the_elements.length; i++ )
	{
		if( the_elements[i].parentNode.parentNode.parentNode.childNodes[1].className == 'beditor_body' ) 
		{
			the_area = the_elements[i].parentNode.parentNode.parentNode.childNodes[1]
			the_image = the_elements[i].childNodes[0]
			the_text = the_elements[i].childNodes[1]
		}
		else
		{
			the_area = the_elements[i].parentNode.parentNode.parentNode.childNodes[3]
			the_image = the_elements[i].childNodes[1]
			the_text = the_elements[i].childNodes[2]
		}
		
		the_area.style.display = 'block';
		the_image.src = '/pachyderm/images/ArrowDown-black.gif';
		the_text.data = ' Collapse';
	}
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}