function showModal(fadeId, lightId) {
	
	var body =(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body
	var top_px=document.all? body.scrollTop : pageYOffset
			
	document.getElementById(lightId).style.top=top_px + (screen.availHeight * 0.15) + "px";
	document.getElementById(lightId).style.display='block';
	
	var bodyHeight= Math.max(body.scrollHeight, body.offsetHeight, body.clientHeight);
	
	document.getElementById(fadeId).style.height = bodyHeight + "px";
	document.getElementById(fadeId).style.display='block';
}

function checkLength(field, maxLength) {
	//Textarea values might have the character combos "\n\r" in the text box,
	//but once they are pulled into Javascript, "\n\r" becomes JUST "\n".
	var length = fixNewLinesTextArea(document.getElementById(field).value).length;
	if (length > maxLength) {
		document.getElementById(field).value = fixNewLinesTextArea(document.getElementById(field).value)
				.substring(0, maxLength);
	}
}

function fixNewLinesTextArea (txt) {             
	//Count a newline as 2 characters.
	if (txt.indexOf( '\r\n' ) != -1) {
//This is IE on windows. Puts both characters for a newline, just what MySQL does. No need to alter
	} else if (txt.indexOf('\r') != -1 ) {
		txt = txt.replace (/\r/g, "\r\n");//This is IE on a Mac. Need to add the line feed
	} else if (txt.indexOf('\n')!=-1) {
		txt = txt.replace (/\n/g, "\r\n");//This is Firefox on any platform. Need to add carriage return
	}  
	return txt;
}

function showHideDiv(divId) {
	if(document.getElementById(divId).style.display == 'none') {
		document.getElementById(divId).style.display = 'block';
	} else {
		document.getElementById(divId).style.display = 'none';
	}
}

