function clearForm(form) 
{
	
	for (counter = 0; counter < form.elements.length; counter++){
    	if (form.elements[counter].type == 'checkbox' || form.elements[counter].type == 'radio') {
    		form.elements[counter].checked = false ;    		
		}
		else if(form.elements[counter].name =='action'){
			//do not reset the value of action
		}
		else if(form.elements[counter].type =='hidden'){
			//do not reset the value of hidden inputs
		} 
		else if (form.elements[counter].type == 'select-multiple') {
			form.elements[counter].options[0].selected = true;
			var size = form.elements[counter].options.length;
			for( i = 1; i < size; i++ ) {
				form.elements[counter].options[i].selected = false;
			}
		}
		else{
            form.elements[counter].value = '';
         }
     }
     	//clear error messages must have a table around the error messages with the id of errorTable
     	var myTable=document.getElementById('errorTable')
     	if(myTable != null){
	     	var mycells = myTable.rows[0].cells
			mycells[0].innerHTML=""
		}
}
function submitForm(action, form) {
       form.action.value=action;
       form.target="_self";
       form.submit();
}

    
function setAction(action, form) {
    form.action.value=action;
    form.target="_self"

}

function setActionBlankTarget(action, form) {
    form.action.value=action;
    form.target="_blank"

}

function setSelectedSection(selectedSection, form) {
	form.selectedSection.value=selectedSection;
}

function setParams(action, selectedSection, form) {
	setAction(action, form);
	setSelectedSection(selectedSection, form);
    
}

function init(){
}
 
function popupWindow(link)
{
	window.open(link, "popup", "width=600,height=500,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,screenX=500,screenY=0,top=0,left=1,directories=no,location=no" )
}

function TrackCount(fieldObj,countFieldName,maxChars)
{
  var countField = eval("fieldObj.form."+countFieldName);
  var diff = maxChars - fieldObj.value.length;

  // Need to check & enforce limit here also in case user pastes data
  if (diff < 0)
  {
    fieldObj.value = fieldObj.value.substring(0,maxChars);
    diff = maxChars - fieldObj.value.length;
  }
  countField.value = diff;
}

function LimitText(fieldObj,maxChars)
{
  var result = true;
  if (fieldObj.value.length >= maxChars)
    result = false;

  if (window.event)
    window.event.returnValue = result;
  return result;
}

  var clickTimes = 0;    
  function countClicks(element)
  {  	
	clickTimes++;
  	if(clickTimes != 1)
  	{
  		element.href="#";
  		alert("You already clicked " + clickTimes + " times! Please wait.");
  	}
  } 
 
   

