
function submitSearchForm() {
	
	var blnValid = false;
	
	// Find form with id=searchForm
	if ( getRef('searchForm') ) {
		
		//Look for a text box named searchString
		if ( getRef('searchForm').searchString ) {
				//Main site detected, ensure something in search box
				if ( getRef('searchForm').searchString.value.length != 0 ) {
						blnValid = true;
				}
		//Look for a text box named q		
		} else if ( getRef('searchForm').q ) {
				//Forum area detected, ensure something in search box
				if ( getRef('searchForm').q.value.length != 0 ) {
						blnValid = true;
				}
		//Look for a text box with id wikiSearchString							
		} else if ( getRef('wikiSearchString') ) {
				//Wiki area, ensure something in search box
				if ( getRef('wikiSearchString').value.length != 0 ) {
						blnValid = true;
					}				
		}	
		
		if ( !blnValid ) {
			//Not valid - display error message and cancel form submission
			alert ( 'Please provide a Search Term!' );
			return false;
		} else {
			return true;
		}
		
	}	
	
}

function getRef ( element ) {
	
	if ( document.getElementById ( element ) )
			return document.getElementById ( element );
		
	if ( document.all ) 
		return document.all[element];
		
	if ( document.layers )
		return document.layers[element];
		
}
	
function swapTab ( tabOnId, tabOffId, tabOnContentId, tabOffContentId ) {
	
		toggleDisplay ( tabOffContentId, 'none' );
		swapClass ( tabOffId, '' );
		toggleDisplay ( tabOnContentId, 'block' );
		swapClass ( tabOnId, 'tabSelected' );		
	}


function toggleDisplay(ToggleId, WC3type) {
	if ( ToggleId ) {	
		getRef( ToggleId ).style.display = WC3type;
		//eval("document.getElementById(ToggleId).style.display = \"" + WC3type + "\"");
	}		
}

function swapClass( ToggleId, className ) {
			
		if ( ToggleId ) { 
			getRef( ToggleId ).className = className;
		}
}

function readCookie( cookieName ) {
	var nameEQ = cookieName + "=";
	var ca = document.cookie.split(';');

	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}

	return null;
}

function getJiveEditorMode() {
	if( readCookie( 'jive_default_editor_mode' ) == null ) {
		return 'advanced';
	} else {
		return readCookie( 'jive_default_editor_mode' );
	}
}