function showAnswer(id){
	var a = $(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){
	$(id).focus();
	}
function f_anthemConfirm(){
	if (!confirm("Are you sure?")) {
		return false;
	}
}
function trim(str) {
   return str.replace(/^\s*|\s*$/g,"");
}

function showControlWin(id,pageid) {		
	locvar=sApplicationPath+'Engine/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+'Engine/Assets/Controls/controlWin.aspx?id=' + ItemID + '&pageid=' + pageid + '&entryid=' + EntryID;
	window.status = 'Control Window Loading...';
	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';
	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 showUploadWin(controlID,postBackID) {		
	locvar=sApplicationPath+'engine/Assets/Controls/controlWin.aspx?rcid=' + controlID + '&pbid=' + postBackID;
	window.status = 'Control Window Loading...';
	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';
	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 showWin(controlID,postBackID) {		
	locvar=sApplicationPath+'engine/Assets/Controls/controlWin.aspx?rcid=' + controlID + '&pbid=' + postBackID;
	window.status = 'Control Window Loading...';
	CtrlWin = window.open (locvar,"ControlWindow",AdmWinStats);
	window.status = '';	
	}


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;
	}
function setHiddenValue(controlID,returnValue,returnClientID) {
	parent.window.opener.document.getElementById(controlID).value = returnValue;
	//parent.window.opener.document.getElementById(returnClientID).click;
	//parent.window.opener.document.eval('__doPostBack('' + returnClientID + '','''')');
	parent.window.opener.__doPostBack(returnClientID,'');
	//Don't want to reload..  we need the form submited
	//parent.window.opener.location.reload();
	parent.window.opener.focus();
	parent.close();
	}
function alertValue(id) {
	alert($(id).value);
	}
	
// 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);
}

function showBin(loc) {		
	//locvar=sApplicationPath+'/BinRoutingSheet.aspx?bn=' + binNo;;
	window.status = 'Control Window Loading...';
	stats = 'height=555,width=800,';
	stats += 'center=yes,help=no,resizable=yes,scrollbars=yes,';
	stats += 'channelmode=no,fullscreen=no,directories=no,';
	stats += 'status=yes,location=no,menubar=yes,titlebar=yes,toolbar=yes';
	CtrlWin = window.open (loc,"BinWindow",stats);
	window.status = '';	
	}
function EmailWindow(idvar,modevar) {
	var sTop = screen.height/2 - 250;
	var sLeft = screen.width/2 - 250;
	locvar=sApplicationPath+'EmailForm.aspx?oid='+idvar+'&mode='+modevar;
	stats='toolbar=no,location=no,directories=no,status=no,menubar=no,'
	stats += 'scrollbars=no,resizable=no,width=500,height=580,top=' + sTop + ',left=' + sLeft;
	NewsWin = window.open (locvar,"emailForm",stats) 
	}
function PrintWindow(idvar,modevar) {
	var sTop =  50;
	var sLeft = 20;
	locvar=sApplicationPath+'SampleReport.aspx?oid='+idvar+'&mode='+modevar;
	stats='toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,'
	stats += 'width=800,height=500,top=' + sTop + ',left=' + sLeft;
	NewsWin = window.open (locvar,"PrintForm",stats) 
	}
function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
function FormCoords(x,y) {
	this.left = x;
	this.top = y;
}
function getObjPosition(obj) {
	var xo, yo;	xo=0; yo=0;
	//alert(obj.offsetHeight);
	while(obj.tagName!="BODY") {
		xo += obj.offsetLeft;
		yo += obj.offsetTop;
		obj = obj.offsetParent;
		//obj = obj.parentElement;
	}
	return new FormCoords(xo,yo);
}
function positionElements(e1,e2,offsetx,offsety) {
	var obj1 =$(e1);
	var obj2 =$(e2);
	if (offsetx==null||offsetx=='undefined') offsetx = 5;
	obj2.style.top=getObjPosition(obj1).top+oMenu.offsetHeight+offsetx;
	if (offsety==null||offsety=='undefined') offsety = 0;
	obj2.style.left=getObjPosition(obj1).left+offsety;
}

function ctrlFocus(id){
	//alert(id.id);
	$(id).focus();
	}


function Anthem_Error(result) {
	alert('Anthem Error: ' + result.error);
}
function Anthem_PreCallBack() {
if ($('disabledZone') != null)
	$('disabledZone').style.visibility = 'visible';
}
function Anthem_CallBackCancelled() {}

function Anthem_PostCallBack() {
if ($('disabledZone') != null)
	$('disabledZone').style.visibility = 'hidden';
}
