function countit()
  {
	var count=0
	var len=0
	var formcontent=document.Quote.adtext.value // grab the text from the textarea
	formcontent=formcontent.split(" ") // split the words into an array
	for(i=0;i<formcontent.length;i++)
		{
		 if(formcontent[i]=="") // Count the number of spaces or nulls
		   { 
			count++
		   } 
		}
	 len=formcontent.length-count  // subtract spaces or nulls from the length
	 document.Quote.WordCount.value=len
	}




//' applications backend form validation functions, to make sure something's chosen before submitting a form:
function appIsChosen(form)
{
	if (form.frmAppID.options[form.frmAppID.selectedIndex].value == "")
	{
		alert("Please choose an applicant from the drop-down list.");
		form.frmAppID.focus();
		return false;
	}
	return true;
}

function locIsChosen(form)
{
	if (form.frmLocID.options[form.frmLocID.selectedIndex].value == "")
	{
		alert("Please choose a location from the drop-down list.");
		form.frmLocID.focus();
		return false;
	}
	return true;
}

function deleteAppIsChosen(form)
{
	if(form.frmDeleteAppID.options[form.frmDeleteAppID.selectedIndex].value == "")
	{
		alert("Please choose an applicant from the drop-down list.");
		form.frmDeleteAppID.focus();
		return false;
	}
	return true;
}

function confirmDelete()
{
	if (confirm("Are you sure you want to delete this application from the database?"))
		location="Default.asp";
	 else
	 {
		return false;
		document.deleteAppForm.frmDeleteAppID.focus();
	}
}
//' ---- End backend form validation functions ---


//'This function is used to make sure that the form gets clicked once. Is called in checkRequiredFields 
//' if the function does not return false.
var clicks = 0;
function countClicks()
{
	clicks++;
	if (clicks > 2)
	{
		alert ("Please click the Submit button only once. If you are experiencing technical issues with the application, please send an e-mail to webmaster@lionbridge.com, with the text copied from any error messages you received.");
		return false;
	}
	return true;
}

//' This function launches a popup window with the page containing the HTML content and the window's width, height, x position and y position passed as parameters:
function whatsthisWindow(page,width,height,x,y)
{
	whatsthisWindow = window.open(page,"whatsthis","toolbar=no,width=" + width + ",height=" + height + ",status=0,scrollbars=0,menubar=0,resizable=0,screenX=" + x + ",screenY=" + y + ",left=" + x + ",top=" + y + "");
}

//'this function counts the number of characters in a textarea to see if the length of the text is below a limit, passed as a parameter. If not, the offending text is hightlighted in the offending textarea, and an alert box appears.
function checkTextareaLimit(textArea, limitNum)
{
	var limit = limitNum;
	var objTextarea = eval(textArea);
	if (objTextarea.value.length > limit)
	{
		objTextarea.select();
		objTextarea.focus();	
		alert('This area contains more text than the allowed limit. Please edit the text amount to fewer than ' + limit + ' characters.');
		return false;
	}
	return true;
}

//' validate required fields in application:
function checkRequiredFields(limitNum) 
{
	var form = window.document.theForm;
	var limit = limitNum;
	var reNum = /[1-9]+/;
	for (var i = 0; i < form.elements.length; i++) 
	{
		var reqStr = String(form.elements[i].name);
		if (form.elements[i].type == "text"
			&& reqStr.substring(0,3) == "req"
			&& form.elements[i].value == "")
		{
				alert('Please fill in this required information.');
				form.elements[i].focus();
				return false;
		} else if (form.elements[i].type == "textarea" 
			&& form.elements[i].value.length > limit)
		{
				alert('This area contains more text than the allowed limit. ' +
				'Please edit the text amount to fewer than ' + limit + ' characters.');
				form.elements[i].select();
				form.elements[i].focus();	
				return false;
		} else if (form.elements[i].type == "textarea" 
			&& reqStr.substring(0,3) == "req" 
			&& form.elements[i].value == "")
		{
				alert('Please fill in this required information.');
				form.elements[i].focus();
				return false;
		} else if (form.elements[i].type == "select-one" 
			&& reqStr.substring(0,3) == "req" 
			&& form.elements[i].options[form.elements[i].selectedIndex].value == "")
		{
				alert('Please choose \"Yes\" or \"No\" from this drop-down menu.');
				form.elements[i].focus();
				return false;
		} else if (form.elements[i].type == "select-one"
			&& form.elements[i].name == "intLocID"
			&& form.elements[i].options[form.elements[i].selectedIndex].value == "")
		{
				alert('Please choose a location from this drop-down menu.');
				form.elements[i].focus();
				return false;
		} else if ((form.elements[i].name.indexOf("reqfrmSalary") != -1 ||
			form.elements[i].name.indexOf("frmEmpEndSal") != -1 ||
			form.elements[i].name.indexOf("frmEmpStartSal") != -1)
			&& form.elements[i].value != ""
			&& !reNum.test(form.elements[i].value))
		{
				alert("Please enter this information in numerical format.");
				form.elements[i].select();
				form.elements[i].focus();
				return false;
		}
	}
	// application has been validated. Now count the number of times submitted:
	return countClicks();
}

//' This function counts the number of characters typed into a textarea and alerts the user when the amount passes the limit, passed as a parameter. The number is passed to a text input area a sthe value of a counter, displayed in real time while user types.
function countChars(textArea, counter, limitNum)
{
	var limit = limitNum;
	var objTextarea = eval(textArea);
//	alert(objTextarea);
	var objCounter = eval(counter);
 	var oldValue = objCounter.value;
  	objCounter.value = objTextarea.value.length;
  	if (objCounter.value > limit && oldValue <= limit) 
	{
    	alert('Please limit your text to ' + limit + ' characters.');
    	if (document.styleSheets)
		{
      		objCounter.fontWeight = 'bold';
	      	objCounter.style.color = '#ff0000'; 
		}
	}
	else if (objCounter.value <= limit && oldValue > limit && document.styleSheets)
	{
		objCounter.style.fontWeight = 'normal';
		objCounter.style.color = '#000000'; 
	}
}


// --- YET ANOTHER POPUP WINDOW FUNCTION:
function newWin(name,width,height,x,y,page)
{
	newWindow = window.open(page,name,"toolbar=no,width=" + width + ",height=" + height + ",status=no,scrollbars=no,menubar=no,address=no,resizable=yes,screenX=" + x + ",screenY=" + y + ",left=" + x + ",top=" + y + "");
}



