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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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 playSound() {
	//document.soundByte.GotoFrame(1);
	if (document.all){
		document.all.btnSound.src = "sounds/button4.wav";
	}
}


//Display user links
var txtObjRef = "";


function elementPosition(elem) {
	var x = 0;
	var y = 0;
			
	while (elem.offsetParent) {	
		x += elem.offsetLeft + (elem.clientLeft || 0);
		y += elem.offsetTop + (elem.clientTop || 0);
		elem = elem.offsetParent;
	}
	return {x: x, y: y};
}
	
function getPosition(obj) { 
	var pos = elementPosition(document.getElementById(obj));
	var objNum = obj.substring(obj.length - 1);
	var xpos = pos.x - 2;
	var ypos = pos.y;
	
	document.getElementById("addurl").style.top = ypos;
	document.getElementById("addurl").style.left = xpos;
	document.getElementById("addurl").style.display = 'block';
	txtObjRef = "tnt" + objNum;
}

function addURL(){
	var currText = document.getElementById(txtObjRef).value;
	var url = document.all.txtUrl.value;
	var name = document.all.txtUrlName.value;
	//Update with inserted html
	if(checkLink()){
		var htmlUrl = ' <a href="' + url + '" target="_blank" >' + name + '</a> ';
		document.getElementById(txtObjRef).value += htmlUrl;
		document.getElementById("addurl").style.display = 'none';
	}
}

function closeURL(){
	document.getElementById("addurl").style.display = 'none';
}
//Form validations
function checkLink(){
	valid = true;
	var errors = "";
	doc = document.all;
	
	if(doc.txtUrl.value == ""){
		errors = errors + "Enter url address.\n";
		valid = false;
	}
	else {
		if(doc.txtUrl.value.indexOf("http://") == -1 || doc.txtUrl.value.indexOf(".") == -1){
			errors = errors + "Address must be of the form http://www.domain.com.\n";
			valid = false;
		}
	}

	if(doc.txtUrlName.value == ""){
		errors = errors + "Enter link name.\n";
		valid = false;
	}
	
	if(!valid){
		alert(errors);
	}
	
	return valid;
}

function checkNewsLetter() {
	valid = true;
	var errors = "";
	doc = document.form1;
	
	if (doc.month.value == "") {
			errors = errors + "You must select a Month\n";
			valid = false;
	}
	if (doc.year.value == "") {
			errors = errors + "You must select a Year\n";
			valid = false;
	}
	
	if(!valid){
		alert(errors);
	}
	return valid;
}
	
function checkUser() {
	valid = true;
	var errors = "";
	doc = document.form1;
	
	if (doc.username.value == "") {
		errors = errors + "You must enter a Username\n";
		valid = false;
	}
	if (doc.fullname.value == "") {
		errors = errors + "You must enter your Fullname\n";
		valid = false;
	}
	if (doc.password.value == "") {
		errors = errors + "You must enter a Password\n";
		valid = false;
	}
	if (doc.access.value == 0) {
		errors = errors + "You must select an Access Level\n";
		valid = false;
	}
	if (doc.password.value != doc.password2.value) {
		errors = errors + "Please confirm your password";
		valid = false;
	}
	
	if(!valid){
		alert(errors);
	}
	return valid;

}
function checkAnnouncement() {
	valid = true;
	var errors = "";
	doc = document.form1;
	
	if (doc.title.value == "" ) {
		errors = errors + "You must enter a Title.\n";
		valid = false;
	}
	if (doc.caption.value == "" ) {
		errors = errors + "You must enter a Caption.\n";
		valid = false;
	}
	if (doc.fulldesc.value == "" ) {
		errors = errors + "You must enter a Full Description.\n";
		valid = false;
	}
	
	if (!valid) {
		alert(errors);
	}
	return valid;
}
function checkURL() {
	valid = true;
	var errors = "";
	doc = document.form1;
	count = 1;
	count2 = count;
	names = "";
	
	for (i = 0; i < doc.elements.length; i++){
		obj = 'hdr'+ count;
		obj2 = 'tnt'+ count2;
		
		//alert(document.form1.elements[i].name)
		if (document.form1.elements[i].name == obj) {
			if(doc.elements[i].value == "") {
				errors = errors + "You must enter a Link Name for Link Name " + count + "\n"
				valid = false;
			}
			count++;
		}
		if (document.form1.elements[i].name == obj2) {
			if(document.form1.elements[i].value == "" ){
				errors = errors + "You must enter a link for URL " + count2 + "\n";
				valid = false;
			}
			else {
				http = document.form1.elements[i].value.substring(0,7);
			
				if(http != "http://"){
					errors = errors + "Link must be in the form http://www.website.com for URL " + count2 + "\n";
					valid = false;
				}
			}
			count2++;
		}
		
	}
	if(!valid){
		alert(errors);
	}
	return valid;
}