function crypt()
{
	$raw = document.login_form.pword.value;
	$crypt = hex_md5($raw);
	document.login_form.pword.value = $crypt;
}

function showLayer(layer)
{
	var i;
	var layerList = document.getElementById('alllayers').innerHTML;
	var allLayers = layerList.split(" ");
	allLayers.pop();
	for ( i = 0; i < allLayers.length; i++) {
		curobj = document.getElementById(allLayers[i]);
		curobj.style.visibility = "hidden";
		curobj.style.overflow = 'hidden';
		curobj.style.height = '0';
	}
	obj = document.getElementById(layer);
	obj.style.visibility = "visible";
	obj.style.overflow = 'auto';
	obj.style.height = 'auto';
}

function showPopup(theMonth, theYear, altDate, theTable, theVal, where, check, request)
{
	if ( (theMonth != '00') && (theYear != '0000') ) {
		document.updateForm.month.value = theMonth;
		document.updateForm.year.value = theYear;
		document.updateForm.altdate.value = altDate;
		document.getElementById('formDate').style.visibility = "visible";
		document.getElementById('formDate').style.position = "static";
	}
	document.updateForm.table.value = theTable;
	document.updateForm.val.value = theVal;
	document.updateForm.where.value = where;
	document.updateForm.check.value = check;
	document.updateForm.request.value = request;
	
	widgInit();
	
	popUp = document.getElementById('popup');
	popUp.style.visibility = "visible";
}

function showPopupLink(linkContent, linkTo, linkElement, linkPos, where, check, request)
{
	document.updateForm.table.value = 'link';
	document.updateForm.val.value = linkContent;
	document.updateForm.linkto.value = linkTo;
	document.updateForm.element.value = linkElement;
	document.updateForm.pos.value = linkPos;
	document.updateForm.request.value = request;
	document.updateForm.where.value = where;
	document.updateForm.check.value = check;
	document.getElementById('formPos').style.visibility = "visible";
	document.getElementById('formPos').style.position = "static";
	if (linkElement == 'category') {
		document.getElementById('formLink').style.visibility = "hidden";
	}
	
	widgInit();
	
	popUp = document.getElementById('popup');
	popUp.style.visibility = "visible";
}

function checkform()
{
	var myform = document.updateForm;
	var content = myform.val.value;
		// REMOVING/REPLACING SOME 'PROBLEM' CHARACTERS
	content = cleanup(content);
	myform.val.value = '';
	myform.newval.value = content;
	
		// CREATE 'LINK TO' FOR LINK CATEGORIES (TITLE WITHOUT SPACES)
		if ((myform.table.value == 'link') && ((myform.linkto.value == '') || (myform.linkto.value == 'http://')) && (myform.element.value == 'category')) {
			var linkName = myform.newval.value;
			var newLinkto = linkName.replace(/<?p>/g,'').replace(/\W/g,'').toLowerCase();
			myform.linkto.value = newLinkto;
		}
			// SWITCH TO REMOVE PARAGRAPH CODE FOR DATE LISTS
		switch(myform.table.value)
		{
			case 'link':
			case 'biogawards':
			case 'biogdemos':
			case 'biogexhibs':
				myform.newval.value = myform.newval.value.replace(/<p><\/p>/g,'<br />').replace(/<\/?p>/g,'');
				break;
		}
}

function cleanup(content)
{
		// REMOVING/REPLACING SOME 'PROBLEM' CHARACTERS
	content = content.replace(/\x27/g,'`');	// replaces apostrophie with an acute (`)
	content = content.replace(/\x9/g,'');	// removes any 'tabs' entered
	content = content.replace(/\xa/g,'');	// removes any new-lines entered in HTML source code (by IE)
	content = content.replace(/‘/g,'`');	// replaces left single quote (‘) with an acute
	content = content.replace(/’/g,'`');	// replaces right single quotes (’) with an acute
	content = content.replace(/“/g,'``');	// replaces left double quote (“) with two acutes
	content = content.replace(/”/g,'``');	// replaces right double quote (”) with two acutes
	content = content.replace(/"/g,'``');	// replaces double quote (“) with two acutes
	return content;
}


function confirmDelete(type, ident, table, where, check)
{
	var ans = confirm("Delete " + type + " (" + ident + ")?");
	
	if (ans) {
		theForm = document.updateForm;
		theForm.table.value = table;
		theForm.val.value = 'foo';
		theForm.where.value = where;
		theForm.check.value = check;
		theForm.request.value = 'del';
		theForm.submit();
	}
	else {
		alert( type + " not deleted.");
	}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
