


function flashMsg(msg) {
	if (msg) {
		//scroll to the flash screen
		ScrollToElement('flash_shell');
		//put the message in the flash box (nl2br) and show it
		var flashContainer = document.getElementById('flash_container');
		msg = URLDecode(msg);
		flashContainer.innerHTML = msg.replace(/\n/g,'<br />');
		showMe('flash_shell');
	}
}

function flashClear() {
	var flashContainer = document.getElementById('flash_container');
	flashContainer.innerHTML = '';
	hideMe('flash_shell');
}









<!-- adjust the position of the metaheader, if screensize is wrong -->
function adjustForScreensize() {
	//scroll through style sheets until we find the lowres one, and distable it
	for (var StyleSheetIterator = 0; StyleSheetIterator<document.styleSheets.length; StyleSheetIterator++) {
		if(document.styleSheets[StyleSheetIterator].title == "lowres") {
			if (screen.height>750) {
				document.styleSheets[StyleSheetIterator].disabled = true;
			} else {
				document.styleSheets[StyleSheetIterator].disabled = false;
			}
		}
	}
}







function hideDropdown () {
	//hide it
	var e = window.parent.document.getElementById('metaheader_dropdown_cloak');
	e.style.display = 'none';
	//put the old contents back
	window.parent.document.getElementById('metaheader_dropdown').innerHTML = '<img src="' + _path['relative_root'] + 'images/logo-spinning.gif" id="metaheader_dropdown_default"/>';
}

function revealDropdown () {
	//put the old contents back, just to be safe
	document.getElementById('metaheader_dropdown').innerHTML = '<img src="' + _path['relative_root'] + 'images/logo-spinning.gif" id="metaheader_dropdown_default"/>';
	//scroll to top, if screen size is too small
	if (screen.height<750) {
		window.scrollTo(0,0);
	}
	//show the dropdown
	showMe('metaheader_dropdown_cloak');
}	



function replaceDropdownContents (contentsVar,iFrame,height) {
	/* This function is meant to be used with Ajax -- Ajax pulls the contents
	and then it places them into a global var, which this script waits for and
	then sticks into the dropdown frame.  So the global variable name is submitted
	to this function, not the contents themselves */
	if (iFrame) {
		var newContents = "<iframe src=\"" + iFrame + "\" name=\"dropdown_iFrame" + Math.round(Math.random()*1000) + "\" style=\"width: 100%; height: " + height + "px\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" vspace=\"0\" hspace=\"0\"></iframe>";
	} else {
		eval("var newContents = window." + contentsVar + ";");
	}

	if (newContents) {
		document.getElementById('metaheader_dropdown').innerHTML = newContents;
	} else {
		setTimeout("replaceDropdownContents('" + contentsVar + "'," + height + ");",100);
	}
}




function replaceDropdownContentsWithURL (url,postedVars,iFrame,height) {
	revealDropdown();
	if (!height) {
		var height = 200;
	}
	if (iFrame) {
		var iFrame = url;
	} else {
		var data = postedVars;
		var resultsVar = "dropdownContents";
		postAjax(data,url,resultsVar);
	}
	setTimeout("replaceDropdownContents('dropdownContents','" + iFrame + "'," + height + ")",2000);
}





//focus on the first field (ignore ones that are readonly, disabled, or have a set tab index)
function focusFirstField() {
	var fields = document.getElementsByTagName('input');
	if (fields) {
		var i=0;
		var foundOne = 0;
		while (foundOne==0 && fields[i]) {
			if (fields[i].disabled==false && fields[i].readOnly==false && fields[i].tabIndex==false) {
				fields[i].focus();
				foundOne = 1;
			}
			i++;
		}
	}
}
