﻿function nuc_textCounter(field, countfield, maxlimit)
 {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}

function submit_on_change(theform){

document.getElementById(theform).submit();
}


function submitform(pressbutton){
	document.adminForm.func.value=pressbutton;
	try {
		document.adminForm.onsubmit();
		}
	catch(e){}
	document.adminForm.submit();
}



function submitform_dir(pressbutton){
	document.adminForm.directory.value=pressbutton;
	try {
		document.adminForm.onsubmit();
		}
	catch(e){}
	document.adminForm.submit();
}

function checkBox(id){

var element=document.getElementById(id);

element.checked=true;

//document.adminForm.checked;
}

//public form validations
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{alert(alerttxt);return false}
else {return true}
}
}

function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt);return false}
else {return true}
}
}



function printpage() {
window.print();  
}

//******** Stop right click and save
// Set this to 1 if you want to display alerts; set to 0 if not
var noisy=1;

var z=0;
function right(e) {
	var myDate = new Date();
	var yyyy = myDate.getYear();
	var msg = "Copyright 1996-"+yyyy+" by DABD (uk) All Rights Reserved.";
	if (z){
		//if we're on a thumbnail page, we want to allow left clicking, but not right clicking
		if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)){
			if (noisy){
				alert(msg);
			}
			return false;
		}
		if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) {
			if (noisy){
				alert(msg);
			}
			return false;
		}
		else return true;
	} else {
		//if we're on a display page, we want to disallow all mouse clicks on the hi-res image
		if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2 || e.which == 1)){
			if (noisy){
				alert(msg);
			}
			return false;
		}
		if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 1 || event.button == 2 || event.button == 3)) {
			if (noisy){
				alert(msg);
			}
			return false;
		}
		else return true;
	}
}

function trap(type){
	if(document.images){
		if (type == "all"){
			//if we're on a thumbnail page, protect all of the images
			for(i=0;i<document.images.length;i++){
				document.images[i].onmousedown = right;
				document.images[i].onmouseup = right;
			}
			z=type;
		} else {
			//if we're on a display page, we only care about the hi-res image
			//the "type" variable should pass a number that corresponds to 
			//the document.image index for the hi-res image.
			//the [type] variable should contain a subscript corresponding
			//to the image you want to protect from the document.images array.
			document.images[type].onmousedown = right;
			document.images[type].onmouseup = right;
		}
		document.oncontextmenu=new Function("return false");
	}
}

//end stop right click and save