function showAnswer(id){
	a = document.getElementById(id);
	if (a.style.display == "none"){
		if (navigator.appName=="Netscape")
			{a.style.display = "table-row";}
		else
			{a.style.display = "block";}}
	else
		{a.style.display = "none";}
	}
function Focus(id){
	document.getElementById(id).focus();
	}

function showControlWin(id,pageid) {		
	locvar=sApplicationPath+'Assets/Controls/controlWin.aspx?id=' + id + '&pageid=' + pageid + '&entryid=';
	window.status = 'Control Window Loading...';
	//  Window Stats:::
	stats = 'height=555,width=615,';
	stats += 'center=yes,help=no,resizable=yes,scrollbars=yes,';
	stats += 'channelmode=no,fullscreen=no,directories=no,';
	stats += 'status=yes,location=no,menubar=no,titlebar=yes,toolbar=no';
	//Modal Stats:::
//	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,false);
	//alert('i');
	CtrlWin.focus();
	var Post = 0;
//	Post = window.showModalDialog(locvar,"",stats);
//	alert(Post);
	window.status = '';	
	
//	alert(isThere(Post));
//	alert(!isNullGuid(Post));
	if (isThere(Post) && isGuid(Post) && !isNullGuid(Post)) {
	alert('reload');
		window.location.reload();
		}
	}
	
function showEditWin(ItemID,pageid,EntryID) {		
	locvar=sApplicationPath+'Assets/Controls/controlWin.aspx?id=' + ItemID + '&pageid=' + pageid + '&entryid=' + 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; }
	}
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();
		}
	}
} 
// Admin Functions
function closeControlWin(id) {
	//alert(parent.window.opener.location);
	parent.returnValue = id;
	parent.window.opener.location.reload();
	parent.window.opener.focus();
	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();}
	}
}
function CreateGalleryControl(DivID, WIDTH, HEIGHT, URL, mode, mode2, FlashVars)
{
  var d = document.getElementById(DivID);
  d.innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' +
     ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ' +
     mode2 + ' width="' + WIDTH + '" height="' + HEIGHT +'" align="middle"  >' +
    ' <param name="movie" value="' + URL + '" />' +
     ' <param name="quality" value="BEST" />' +
	' <param name="scale" value="noscale" />' +
    mode +    
	' <param name="FlashVars" value="xmlDataPath=' + FlashVars + '" />' +
	'<embed src="' + URL + '" width="' + WIDTH + '" height="' + HEIGHT +
	'" align="middle"  quality="BEST" ' + mode2 + ' scale="noscale" type="application/x-shockwave-flash" ' +
	' pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="xmlDataPath='+ FlashVars +'" />';
}

function CreateFlashControl (DivID, Alt, mode, mode2, Width, Height, Quality, URL)
{
	var d = document.getElementById(DivID);
  d.innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' +
  ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ' +
     mode2 + ' width="' + Width + '" height="' + Height +'" align="middle"  >' +
     ' <param name="movie" value="' + URL + '" />' +
     ' <param name="quality" value="' + Quality + '" />' +
	mode +    
	'<embed src="' + URL + '" width="' + Width + '" height="' + Height +
	'" align="middle"  quality="' + Quality + '" ' + mode2 + ' type="application/x-shockwave-flash" ' +
	' pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
	' <NOEMBED>' + Alt + '</NOEMBED>';
	//alert(d.innerHTML);
}


