function RemoveHTMLTags(strText, strFormFieldName) {
	var regEx = new RegExp("<|%3C|>|%22|%3E|%2F|%3c|%3e|%2f/","g");
	var m = regEx.exec(strText.value);
	if (m == null) {
		//alert("No match"); do nothing
	} else	{
		alert("\r\nPotentially dangerous characters were removed from the " + strFormFieldName + "\r\n Characters like {<>/} are not allowed\r\n");
	}
	strText.value = strText.value.replace(regEx, "");
}

function profileTextCounter(txtArea,maxChars,spanName){
	var strTemp = "";
	if (txtArea.value.length > maxChars){
		alert("Oops!  Please shorten your answer.\r\nYour answer can contain up to " + maxChars + " characters, including letters, numbers and underscores.  Watch the counter to tell how many characters you have remaining.");
		strTemp = txtArea.value.substring(0, maxChars);
		txtArea.value = strTemp;
	}
document.getElementById(spanName).innerHTML = maxChars - txtArea.value.length;
}

function popup(page,name,w,h,scroll) {        
	tempWindow = window.open(page,name,"scrollbars="+scroll+",resizable=yes,width="+w+",height="+h+",status=yes,location=no,toolbar=no,menubar=yes");
	tempWindow.focus();      
}

function newUserImg(imgID, thesrc) {
	// loads new Cap image
	if(document.getElementById) {
		// extract image name from image source (i.e. cut off ?randomness)
		if(thesrc == '') {
			thesrc = document.getElementById(imgID).src;
			thesrc = thesrc.substring(0,thesrc.lastIndexOf(".")+4);
		}
		
		// add ?(random) to prevent browser/isp caching
		document.getElementById(imgID).src = thesrc+"?"+Math.round(Math.random()*100000);
	} else {
		alert("Sorry, cannot autoreload image\nSubmit the form and the new image will be loaded");
	}
}

// function to prevent submitting form data twice
var submitcount=0;
function checkSubmit(spanName,string) {
	if (submitcount == 0) {
		submitcount++;
		// show text
		if(spanName)
			document.getElementById(spanName).innerHTML = string;
		
		return true;
	} else {
		return false;
	}
}