function showAnswer(id){
	a = document.getElementById(id);
	if (a.style.display == "none")
		{a.style.display = "block";}
	else
		{a.style.display = "none";}
	}
function Focus(id){
	document.getElementById(id).focus();
	}

function showControlWin(id,pageid) {		
	locvar=sApplicationPath+'Assets/Controls/popUp.htm?i=' + id + '&p=' + pageid + '&e=';
	window.status = 'Control Window Loading...';
	stats='dialogHeight:555px;dialogWidth:615px;dialogTop: px;dialogLeft: px;';
	stats += 'edge:Raised;center:Yes;help:No;resizable:Yes;status:Yes;scroll:No;';
	//CtrlWin = window.open (locvar,"ControlWindow",stats);
	var Post = 0;
	Post = window.showModalDialog(locvar,"",stats);
	window.status = '';	
	if (isThere(Post) && isGuid(Post) && !isNullGuid(Post)) {
		window.location.reload();
		}
	}
	
function showEditWin(ItemID,pageid,EntryID) {		
	locvar=sApplicationPath+'Assets/Controls/popUp.htm?i=' + ItemID + '&p=' + pageid + '&e=' + EntryID;
	window.status = 'Control Window Loading...';
	stats='dialogHeight:555px;dialogWidth:615px;dialogTop: px;dialogLeft: px;';
	stats += 'edge:Raised;center:Yes;help:No;resizable:Yes;status:Yes;scroll:No;';
	CtrlWin = window.open (locvar,"ControlWindow",stats);
	var Post = 0;
	//Post = window.showModalDialog(locvar,"",stats);
	window.status = '';	
	if (isThere(Post) && isGuid(Post) && !isNullGuid(Post)) {
		window.location.reload();
		}
	}
function changeClass(obj,css) {
	if (obj.className == css) {
		obj.className = '';
		} else {
		obj.className = css; }
	}
// Admin Functions
function closeControlWin(id) {
	parent.returnValue = id;
	parent.close();
	}
function setItemID(id) {
	parent.returnValue = id;
	}


// regex tests //
var reWhitespace = /^\s+$/;
var reNumber = /^\d+$/;
var reGuid = /^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/;
var reNullGuid = /^[0]{8}-[0]{4}-[0]{4}-[0]{4}-[0]{12}$/;
function isEmpty(s) { return ((s == null) || (s.length == 0)) }
function isNumber(s) { return ((s == null) || reNumber.test(s)); }
function isWhitespace (s) { return (isEmpty(s) || reWhitespace.test(s)); }
function isGuid(s) { return ((s == null) || reGuid.test(s)); }
function isNullGuid(s) { return ((s == null) || reNullGuid.test(s)); }
function isThere(s) { 
	if (isEmpty(s)) return false;
   	else {
	if (isWhitespace(s))
      	return false; } 
	return true; }
// FileBrowser Scripts //
function CatchKeyPress(e, KeyCode, Sender) {
    RemoveEnterAndEscEvents(e, KeyCode); 
    if(KeyCode == '13') { 
		var ButtonName = Sender.getAttribute("TargetButton"); 
		var Button = document.getElementById(ButtonName);
		if(Button) { 
			Button.focus();
			Button.click();
		}
	}
} 
function RemoveEnterAndEscEvents(e, KeyCode) { 
	if (KeyCode == 13 || KeyCode == 27) { 
		e.cancel = true;
		e.returnValue = false;
		e.cancelBubble = true;
		var s = navigator.appName.toLowerCase().indexOf('microsoft');
		if(s == -1)
		{e.preventDefault();}
	}
}