// JavaScript Document

function confirmDelete(type, id)
{
	if (type == "a") 
	{
		if (confirm("Do you want to delete this answer?"))
		{
			window.document.location = "2006_forum_edit.asp?action=delete&type=a&id=" + id;
		}
	}
	else if (type == "q") 
	{
		if (confirm("Do you want to delete this question?\nPLEASE NOTE: This will delete the any associated answers."))
		{
			window.document.location = "2006_forum_edit.asp?action=delete&type=q&id=" + id;
		}
	}
}


function checksendemail() 
{
		if (document.sendmail.from.value=="")
		{
			alert("Please specify who the mail is from!");
			document.sendmail.from.focus();
			return (false);
		}
		if (document.sendmail.subject.value=="")
		{
			alert("Please enter a subject!");
			document.sendmail.subject.focus();
			return (false);
		}
		if (document.sendmail.message.value=="")
		{
			alert("Please enter a message!");
			document.sendmail.message.focus();
			return (false);
		}		
}

function checkadddoc() {
	
		if (document.upfile.title.value=="")
		{
			alert("Please enter a title for the file.");
			document.upfile.title.focus();
			return (false);
		}
		
		filename = document.upfile.fileup.value;
		
		if (filename.length == 0 )
		{
			alert('Your must choose a file to upload!');
			document.upfile.fileup.focus();
			return false;
		}
		
		if (filename.length != 0 )
		{
			fileend = filename.substr(filename.length-3, 3);
			if (fileend == 'exe')
			{
				alert('Your cannot upload a .exe file!');
				document.upfile.fileup.focus();
				return false;
			}
		}
}


function confirmDeleteDoc(id, docname)
{
	if (confirm("Do you want to delete this document?"))
		{
			window.document.location = "regionaldocs.asp?action=delete&docname=" + docname + "&id=" + id;
		}
}



function checksearch() 
{
		if (document.searchforum.srch.value=="")
		{
			alert("Please enter a search term.");
			document.searchforum.srch.focus();
			return (false);
		}
}

function check_form_post_answer() 
{
		if (document.fm.answer.value=="")
		{
			alert("Please enter a answer.");
			document.fm.answer.focus();
			return (false);
		}

 		if (document.fm.a_name.value=="")
		{
			alert("Please enter your name.");
			document.fm.a_name.focus();
			return (false);
		}
	
		var emailID=document.fm.a_email
	
		if ((emailID.value==null)||(emailID.value==""))
		{
			alert("Please enter a valid E-Mail address.")
			emailID.focus()
			return (false);
		}
				
		if (!echeck(emailID.value))
		{
			emailID.focus()
			return (false);
		}
		
		fm.Submit.disabled=true;
		fm.Submit.value="Loading...";
				
		return (true);
}


function check_form_post_question() 
{
		if (document.fm.question.value=="")
		{
			alert("Please enter a question.");
			document.fm.question.focus();
			return (false);
		}

 		if (document.fm.a_name.value=="")
		{
			alert("Please enter your name.");
			document.fm.a_name.focus();
			return (false);
		}
	
		var emailID=document.fm.a_email
	
		if ((emailID.value==null)||(emailID.value==""))
		{
			alert("Please enter a valid E-Mail address.")
			emailID.focus()
			return (false);
		}
				
		if (!echeck(emailID.value))
		{
			emailID.focus()
			return (false);
		}
		
		document.fm.Submit.disabled=true;
		document.fm.Submit.value="Loading...";
				
		return (true);
}






function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please enter a valid E-Mail address.")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please enter a valid E-Mail address.")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please enter a valid E-Mail address.")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please enter a valid E-Mail address.")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please enter a valid E-Mail address.")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please enter a valid E-Mail address.")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Please enter a valid E-Mail address.")
		    return false
		 }

 		 return true					
}