function checkEmail (aTextField) {
var strng = aTextField.value;
var error="";
if (strng == "") {
   error = "Invalid e-mail.\n";
}
   var emailFilter=/^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$/;
    if (!(emailFilter.test(strng))) { 
       error = "Invalid e-mail.\n";
    }
if(error != "") {aTextField.focus();alert(error);return false;}
else return true;
}
function checkEmpty(aField)
{
	switch(aField.type) {
		case 'text':
		case 'textarea':
				if(aField.value == null || aField.value.length == 0) {aField.focus();return false};
			break;
		case 'checkbox':
				if(!aField.checked) {aField.focus();return false};	
		case 'select-one':
				if(aField.selectedIndex == 0) {aField.focus();return false};
	}
	return true;
}

extArray = new Array(".gif", ".jpg", ".png");
function LimitAttach(file) {
	allowSubmit = false;
	if (!file) return true;
	
	while (file.indexOf("\\") != -1)
		file = file.slice(file.indexOf("\\") + 1);
	ext = file.slice(file.indexOf(".")).toLowerCase();
	for (var i = 0; i < extArray.length; i++) {
		if (extArray[i] == ext) { allowSubmit = true; break; }
	}
	
	if (allowSubmit) 
		return true;
	else 
		return false;
}


var fileIndex = 2;
function showAttFile() {
       if (fileIndex <= 3) {
         try {
           document.getElementById("attFile" + fileIndex).style.display = "table-row";
         } catch (e) {
           document.getElementById("attFile" + fileIndex).style.display = "block";
			}
			
			if (fileIndex == 3) {
			  document.getElementById("attFileLink").style.display = "none";
			}
			
         fileIndex++;
       }
}
var fileIndex1 = 2;
function showAttFile1() {
       if (fileIndex1 <= 3) {
         try {
           document.getElementById("attFile1" + fileIndex1).style.display = "table-row";
         } catch (e) {
           document.getElementById("attFile1" + fileIndex1).style.display = "block";
			}
			
			if (fileIndex == 3) {
			  document.getElementById("attFileLink1").style.display = "none";
			}
			
         fileIndex1++;
       }
}
function simpletag(field,str,button)
{
	textField = document.getElementById(field);
	if(button.title == 0)
	{
		button.title = 1;
		button.value = button.value + " *";
		textField.value = textField.value + "[" + str + "]";
	}
	else 
	{
		ind=str.lastIndexOf('=');
		if(ind != -1)
		{
			str = str.substr(0,ind);
		}
		button.title = 0;
		len = button.value.length - 1;
		button.value = button.value.substr(0,len);
		textField.value = textField.value + "[/" + str + "]";
	}
	
}
