function toggle_it(itemID,formerID,futureID){
	// Toggle visibility between none and inline
	if (itemID != 0)
	{
		if ((document.getElementById(itemID).style.display == 'none'))
		{
		document.getElementById(itemID).style.display = 'inline';
		} else {
		document.getElementById(itemID).style.display = 'none';
		}
	}
	
	//TOGGLE ORIGINAL BETWEEN VISIBLE AND NOT
	if (formerID != 0)
	{
		if ((document.getElementById(formerID).style.display == 'none'))
		{
		document.getElementById(formerID).style.display = 'inline';
		} else {
		document.getElementById(formerID).style.display = 'none';
		}
	}
  
	//TOGGLE NEXT LIST ITEM
	//if toggle shows file uploaded don't do anything
	if (futureID != 0)
	{
		//set the remove variable
		//var remove = "remove" + futureID;
		if (document.getElementById(futureID + 2).style.display != 'inline')
		{ //procede with swap
			if ((document.getElementById(futureID).style.display == 'none'))
			{
			document.getElementById(futureID).style.display = 'inline';
			} else {
			document.getElementById(futureID).style.display = 'none';
			}
		}
	}
  } 
  

//<!-- Original:  Cyanide_7 (leo7278@hotmail.com) -->
//<!-- Web Site:  http://members.xoom.com/cyanide_7 -->

//<!-- This script and many more are available free online at -->
//<!-- The JavaScript Source!! http://javascript.internet.com -->

//<!-- Begin
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode)) {
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
	var found = false, index = 0;
	while(!found && index < arr.length)
	if(arr[index] == ele)
		found = true;
	else
		index++;
		return found;
}
function getIndex(input) {
	var index = -1, i = 0, found = false;
	while (i < input.form.length && index == -1)
	if (input.form[i] == input)index = i;
	else i++;
	return index;
	}
	return true;
}
//-->

function validateForm(theForm){
	if (theForm.FName.value == "")
	{
		alert("Please provide a first name.");
		theForm.FName.focus();
		return (false);
	}
	
	if (theForm.Name.value == "")
	{
		alert("Please provide a company name.");
		theForm.Name.focus();
		return (false);
	}

	if (theForm.Email.value != "") {
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.Email.value))
		{
				//The e-mail is formatted correctly
		}else{
			//alert(theForm.Email.value)
			alert("Invalid E-mail Address. Please check your spelling and try again.");
			theForm.Email.focus();
			return (false);
		}
	}
	
	if (theForm.Email.value != theForm.Email2.value) {
		alert("E-Mail addresses do not match. Please check your spelling and try again.")
		return (false)
	}
	//END FUNCTION VALIDATE FORM
}
	
function validateForm2(theForm){
	if (theForm.Name.value == "")
	{
		alert("Please provide a company name.");
		theForm.Name.focus();
		return (false);
	}
	
	if (theForm.chiefEmail.value != "") {
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.chiefEmail.value))
		{
				//The e-mail is formatted correctly
		}else{
			//alert(theForm.Email.value)
			alert("Invalid E-mail Address. Please check your spelling and try again.");
			theForm.chiefEmail.focus();
			return (false);
		}
	}
	
	if (theForm.pcEmail.value != "") {
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.pcEmail.value))
		{
				//The e-mail is formatted correctly
		}else{
			//alert(theForm.Email.value)
			alert("Invalid E-mail Address. Please check your spelling and try again.");
			theForm.pcEmail.focus();
			return (false);
		}
	}
	//END FUNCTION VALIDATE FORM
}

function validateThisForm(theForm)
{
	//alert("function entered");
	//START CONFIRM DELETE
	var answer = confirm("Do you wish to delete this entry?");
	if (answer != false)
	{
		//DO NOT DELETE
		return(true);
	}
	else
	{
		return(false);
	}
	//END CONFIRM DELETE
}	

function extract(what,hiddenvar) {
    if (what.indexOf('/') > -1)
	{
        answer = what.substring(what.lastIndexOf('/')+1,what.length);
	}
    else
	{
        answer = what.substring(what.lastIndexOf('\\')+1,what.length);
	}
    //alert(answer);
	//return answer;	

	if (answer + "X" != "X")
	{
		if (hiddenvar == 1)
		{
			document.admin.filePathContainer1.value = "nosave1";
		}
		
		if (hiddenvar == 2)
		{
			document.admin.filePathContainer2.value = "nosave2";
		}
		
		if (hiddenvar == 3)
		{
			document.admin.filePathContainer3.value = "nosave3";
		}
		
		if (hiddenvar == 4)
		{
			document.admin.filePathContainer4.value = "nosave4";
		}
		
		if (hiddenvar == 5)
		{
			document.admin.filePathContainer5.value = "nosave5";
		}
	}
}
