var prev = "";
var current = "";

/*APPLICATION FOR TCC*/
function nameToggle()
{
		document.all.applcntName.disabled = false;
		document.all.applcntTradeName.disabled = true;
}

function tradeNameToggle()
{
		var applName = document.all.applcntName.value;
		var tradeName =  document.all.applcntTradeName.value;
		
		if(tradeName.length == 0){
			alert("No Trade Name found for Taxpayer !");
			inputTags = document.getElementsByTagName("input");
			for (i = 0; i < inputTags.length; i++){
				if (inputTags[i].type == "radio")
					if (inputTags[i].value = "1"){
						inputTags[i].checked = true;
						return false;			
					}			
			}

		}
		
		document.all.applcntTradeName.disabled = false;
		document.all.applcntName.disabled = true;
		
}	


function chgPurp()
{
	current = document.all.purp.value;
	prev = document.all.prevPurp.value;
	
	if(prev == "CCL" && current != "CCL")
	{
		alert("Any customs clearance information entered will be ignored");

	}


	/**
	 * If user selects Customs Clearance for TCC Reason
	 * toggle "Submit" and "Next" button enabled status
	 */
	if(current == "CCL"){
	
		// Enable "Next" button and disable "Submit" button
		document.all.nextCCL.disabled = false;
		if(document.all.subm)		
			document.all.subm.disabled = true;	
		
	}else{
		
		// Enable "Submit" button and disable "Next" button	
		document.all.nextCCL.disabled = true;
		if(document.all.subm)		
			document.all.subm.disabled = false;
		
	}
		
	// If current slection is CCL and previous selection was not CCl, 
	// do not allow user to submit screen without entering CCL info

}


/*Used to toggle the Next button and Other Reason based on the Reason field
Also, toggles the Other Category based on the Applicant Type field selected
Manages the enabling of the update button based on the user providing appl. no.
*/
function purpCheck()
{	

	if(document.all.nextCCL != null){
	
		document.all.nextCCL.disabled = true;
		if(document.all.subm)
			document.all.subm.disabled = false;
		
		if(document.all.purp.options[document.all.purp.selectedIndex].value == "CCL")
		{
			document.all.nextCCL.disabled = false;
			//document.all.othPurposeText.value = "";
			if(document.all.subm)			
				document.all.subm.disabled = true;
		}
			
		/*					
		if(document.all.purp.options[document.all.purp.selectedIndex].value == "OTH")
		{
			document.all.othPurposeText.disabled = false;
		}
		else
		{
			document.all.othPurposeText.disabled = true;
			document.all.othPurposeText.value = "";		
		}
			
		if(document.all.appType.options[document.all.appType.selectedIndex].value == "OTH")
		{
			document.all.othCategText.disabled = false;
		}		
		else
		{				
			document.all.othCategText.disabled = true;		
			document.all.othCategText.value = "";
		}
		*/

	}
	
}

function checkOthPurp()
{
	document.all.othPurposeText.value = TrimString(document.all.othPurposeText.value);
}

function checkOthCateg()
{
	document.all.othCategText.value = TrimString(document.all.othCategText.value);
}	


function cclEntries()
{	
	var found = false;
	document.all.GoodsDescription.value = TrimString(document.all.GoodsDescription.value);
	document.all.VesselName.value = TrimString(document.all.VesselName.value);
	
	//check that mandatory fields are entered
	if(document.all.DocumentType.value=="" || document.all.DocumentNo.value=="" || document.all.VesselName.value=="" || document.all.ReportDate.value=="" || document.all.GoodsDescription.value=="")
	{
		alert("Please enter mandatory information")
		document.all.DocumentType.focus();

	}else
	{ 
		
		if(d_cusClear.index == 0)
		{	
			
			d_cusClear.addRow();
		}else
		{
			//check if an entry exists in the list with the same document number
			for(var i=0;i<d_cusClear.index;i++)
			{
				//alert("i: " + i + "____index: "+d_cusClear.index + "rowfocus" + d_cusClear.getFocusRow())
				//if(MM_findObj("tccApplicationView.clearances["+i+"].documentNo").value == document.all.docNo.value)
				if(MM_findObj("tccApplicationView.clearances["+i+"].documentNo").value == document.all.DocumentNo.value
					&& i != (d_cusClear.getFocusRow()+1)) //add 1 to the getFocusRow for it to start from one instead of null
				{
					alert("Document Number cannot be reused");
					document.all.DocumentNo.focus();
					document.all.DocumentNo.value="";
										
					found = true;
					break;
				}				
			}//end for
			
			if(found == false)
			{
				d_cusClear.addRow();				
			}
	    }//end else		
	}
}

function reinitialize()
{
	document.all.DocumentType.value = document.all.DocumentNo.value = document.all.VesselName.value = document.all.ReportDate.value = document.all.GoodsDescription.value = "";
}

function TrimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}


function validateDate(dateString)
{
/*
   dateString is a date passed as a string in the following
   formats: yyyy-mm-dd

*/    
    
    var now = new Date();
    var today = new Date(now.getYear(),now.getMonth(),now.getDate());     
    var twoYearsPrior = new Date((now.getYear()-2),now.getMonth(),now.getDate());     
    
    var date = new Date(dateString.substring(0,4),
                        dateString.substring(5,7)-1,
                        dateString.substring(8,10));
   
	//valid date range   

    if(dateString == "")
    	return 1;

    //A.S. changed based on user session held 2004-11-24 where Customs personnel indicated that predated clearance documents are accepted.    	
    //else if (date <= today && date >= twoYearsPrior)
    else if (date >= twoYearsPrior)
    {
        //document.all.GoodsDescription.focus();
        return -1;
    }
    else
    {
        //A.S. changed based on user session held 2004-11-24 where Customs personnel indicated that predated clearance documents are accepted.    	
        //alert("Report Date not within required limit, as it cannot be two(2) years prior to today nor after today. Please re-enter.");
		
		alert("Report Date cannot be more than two(2) years prior to the current date. Please re-enter.");
		document.all.DateReported.value = "";
		document.all.DateReported.focus();
        return 0;
    }
}





/********************************************************************************************************/


/*GENERAL FUNCTIONS*/
var timer = null
var clock = null
function stop()
{
clearTimeout(timer)
}

function start()
{
var time = new Date()
var hours = time.getHours()
var minutes = time.getMinutes()
minutes=((minutes < 10) ? "0" : "") + minutes
var seconds = time.getSeconds()
seconds=((seconds < 10) ? "0" : "") + seconds
 clock = hours + ":" + minutes + ":" + seconds
//document.forms[0].display.value = clock
timer = setTimeout("start()",1000)
}

//**********************************************************
function openWin(loc){

open(loc,"","toolbar=1,scrollbars=1,resizable=1");

}

//**********************************************************

/* 	function clearForm clears the values of all form fields
	on a page (except for file input fields which cannot be
	changed via js)
	
	astewart
*/
function clearForm(){
	for (i = 0; i < document.forms.length; i++){
		for (j = 0; j < document.forms[i].length; j++){
			obj = document.forms[i].elements[j];
			if (obj.tagName == "INPUT"){
				switch (obj.type){
					case "text":
					case "password":
					case "hidden":
						obj.value = "";
						break;
					case "checkbox":
					case "radio":
						obj.checked = false;
						break;
				}
			}else if (obj.tagName == "SELECT"){
				obj.selectedIndex = 0;
			}else if (obj.tagName == "TEXTAREA"){
				obj.value = "";
			}
		}
	}
}
//**********************************************************
function onKeyUpEvents(){
// keycode: 9 is tab, 8 is backspace, 37 and 39 is left and right 
 if (event.keyCode == 37 || event.keyCode == 39 || event.keyCode ==9) return;

	
	if(window.event.srcElement.className =="dateBox" || window.event.srcElement.className =="requiredDateBox" ||window.event.srcElement.className =="failedDateBox"){
		dateMask();
	}
	
	if(window.event.srcElement.className =="currencyBox" || window.event.srcElement.className =="requiredCurrencyBox" ||window.event.srcElement.className =="failedCurrencyBox" ){
		currencyMask();
	}
	
	if(window.event.srcElement.className =="timeBox" ){
		timeMask();
	}
		//textToupper();

}
//*****************************************************
function onKeyDownEvents(){

}

//*****************************************************
function onChangeEvents(){
if(window.event.srcElement.className =="currencyBox" || window.event.srcElement.className =="requiredCurrencyBox" ||window.event.srcElement.className =="failedCurrencyBox" ){
		cashFormat();
	}
}
//***************************************
function onBlurEvents(){
	if(window.event.srcElement.className =="textBox" || window.event.srcElement.className =="requiredTextBox" ||window.event.srcElement.className =="failedTextBox"){
		temp = window.event.srcElement.value
		if(temp != "" || temp != null)
			window.event.srcElement.value = temp.toUpperCase();
	}/*else if(window.event.srcElement.className =="currencyBox" || window.event.srcElement.className =="requiredCurrencyBox" ||window.event.srcElement.className =="failedCurrencyBox" ){
		cashFormat();
	}else if(window.event.srcElement.className =="timeBox" ){
		if(window.event.srcElement.value == null || window.event.srcElement.value == ""){
		}else if(IsValidTime(window.event.srcElement.value)== false){
		window.event.srcElement.focus();
		}
	}else if(window.event.srcElement.className =="dateBox" || window.event.srcElement.className =="requiredDateBox" ||window.event.srcElement.className =="failedDateBox" ){
		if(window.event.srcElement.value == null || window.event.srcElement.value == ""){
		}else if(window.event.srcElement.value.length < 10){
		alert("Date entry is invalid")
		window.event.srcElement.focus();
		}
	}*/
}
//**********************************************************
function onfocusinEvent(){
	if(window.event.srcElement.className =="numberBox" || window.event.srcElement.className =="requiredNumberBox" ||window.event.srcElement.className =="failedNumberBox"){
		window.event.srcElement.focus();
		}else if(window.event.srcElement.className =="currencyBox" || window.event.srcElement.className =="requiredCurrencyBox" ||window.event.srcElement.className =="failedCurrencyBox" ){
		//-----CURRENCYBOX FILTER---------------
		return currencyMask();
		}else if(window.event.srcElement.className =="dateBox" || window.event.srcElement.className =="requiredDateBox" ||window.event.srcElement.className =="failedDateBox"){
		//-----DATEBOX FILTER---------------
		window.event.srcElement.focus();
		}else if(window.event.srcElement.className =="timeBox" ){
		//-----TIMEBOX FILTER---------------
		window.event.srcElement.focus();
		}
//alert(window.event.srcElement.className)
}
//**********************************************************
function parseKeystrokes(e){

	   /* if (event.altKey){
            if (keyCode == 37 || keyCode == 39) return (false);
        }
        
        if(event.ctrlKey){
			//if key that is pressed is 'n','h','l' or 'o' , 'i' , 'w'
			if(event.keyCode == 78 || event.keyCode == 72 || event.keyCode == 76 || event.keyCode == 73 ||
				event.keyCode == 69 || event.keyCode == 87  || event.keyCode == 80){return false;}
		}
		
		
        if (keyCode == 8){ 
			 
			if (window.event.srcElement.tagName =="INPUT"){
				
				 return false;
			}
			//if keycode == 8 which is backspace.
		}else*/

		var evt = e? e : event;
		var obj = evt.srcElement? evt.srcElement : evt.target;				
				
		if(evt.keyCode == 93){
			alert("The right mouse button feature has been disallowed for this application..")
		}else if(evt.keyCode == 122 || evt.keyCode == 114 || evt.keyCode == 116 ){
			//Disabling f11,f3 and f5 function  respectively aswell as the right mouse key
			//e.keyCode = 0;
			return false;
		}
				
//-----NUMBERBOX FILTER---------------			
		//here filters out the inputs for the numberbox....
		if(obj.className =="searchNumberBox" || obj.className =="numberBox" || obj.className =="requiredNumberBox" ||obj.className =="failedNumberBox"){
			return isNumberKeys();
		}else if(obj.className =="currencyBox" || obj.className =="requiredCurrencyBox" || obj.className =="failedCurrencyBox" ){
		//-----CURRENCYBOX FILTER---------------
			return currencyMask();
		}else if(obj.className =="dateBox" || obj.className =="requiredDateBox" || obj.className =="failedDateBox"){
		//-----DATEBOX FILTER---------------
			dateMask();
			
		}else if(obj.className =="timeBox" ){
		//-----TIMEBOX FILTER---------------
			timeMask();
		}else if(obj.className =="textBox" || obj.className =="requiredTextBox" || obj.className =="failedTextBox"){
			obj.focus();
		}

/*
		//here filters out the inputs for the numberbox....
		if(window.event.srcElement.className =="searchNumberBox" || window.event.srcElement.className =="numberBox" || window.event.srcElement.className =="requiredNumberBox" ||window.event.srcElement.className =="failedNumberBox"){
			return isNumberKeys();
		}else if(window.event.srcElement.className =="currencyBox" || window.event.srcElement.className =="requiredCurrencyBox" ||window.event.srcElement.className =="failedCurrencyBox" ){
		//-----CURRENCYBOX FILTER---------------
			return currencyMask();
		}else if(window.event.srcElement.className =="dateBox" || window.event.srcElement.className =="requiredDateBox" ||window.event.srcElement.className =="failedDateBox"){
		//-----DATEBOX FILTER---------------
			dateMask();
			
		}else if(window.event.srcElement.className =="timeBox" ){
		//-----TIMEBOX FILTER---------------
			timeMask();
		}else if(window.event.srcElement.className =="textBox" || window.event.srcElement.className =="requiredTextBox" ||window.event.srcElement.className =="failedTextBox"){
			window.event.srcElement.focus();
		}
*/


}//end of parseKeystrokes(evt)
//**********************************************************
function parseMousestrokes(evt){
  var keyCode = document.layers ? evt.which : document.all ? event.keyCode : document.getElementById ? evt.keyCode : 0;

	if(event.button == 2){
		//alert("The right mouse button feature has been disallowed for this application..")
	}
}
//**********************************************************
function buttonHover(e){
	var evt = e? e : event;
	var obj = evt.srcElement? evt.srcElement : evt.target;
	
	if(obj != null && obj.className == "button"){
		obj.className = "buttonHover";
	}else if(obj != null && obj.className == "workflowButton"){
		obj.className = "workflowButtonHover";
	}
	// By Craig Henry to facilitate cross browser reference
	/*
	if(window.event.srcElement != null && window.event.srcElement.className == "button"){
		window.event.srcElement.className="buttonHover"
	}else if(window.event.srcElement != null && window.event.srcElement.className == "workflowButton"){
		window.event.srcElement.className="workflowButtonHover"
	}*/
	
}

//**********************************************************
function buttonOut(e){
	var evt = e ? e : event;
	var obj = evt.srcElement? evt.srcElement : evt.target;
	
	if(obj != null && obj.className == "buttonHover"){
		obj.className = "button";
	}else if(obj != null && obj.className == "workflowButtonHover"){
		obj.className = "workflowButton";
	}
	/*	
	if(window.event.srcElement != null && window.event.srcElement.className =="buttonHover"){
		window.event.srcElement.className ="button"
	}else if(window.event.srcElement != null && window.event.srcElement.className == "workflowButtonHover"){
		window.event.srcElement.className="workflowButton"
	}
	*/
}

//**********************************************************
function formCheck(){

	for(var i=0;i<document.forms.length;i++){
		for(var j=0;j<document.form[i].elements.length;j++){
			if(document.form[i].element[j].className=="currencyBox" || document.form[i].element[j].className =="requiredCurrencyBox" ||document.form[i].element[j].className =="failedCurrencyBox"){
			currencyFormat(document.form[i].element[j]);
			}
			
			if(document.form[i] != null)document.form[i].focus();
		/*	if(document.form[i].element[j].className=="dateBox" || document.form[i].element[j].className =="requiredDateBox" ||document.form[i].element[j].className =="failedDateBox"){
			alert("its here....")
			document.form[i].element[j].maxlength="10";
			}*/
		}
	}
}
//**********************************************************
<!--
function fadeOut(ppage) {
var obj =MM_findObj(ppage)
    obj.style.filter="blendTrans(duration=2)";
    // Make sure the filter is not playing.
    if (obj.filters.blendTrans.status != 2) {
        obj.filters.blendTrans.apply();
        obj.style.visibility="hidden";
        obj.filters.blendTrans.play();
    }
}

function fadeIn(ppage) {
var obj =MM_findObj(ppage)
    obj.style.filter="blendTrans(duration=2)";
    // Make sure the filter is not playing.
    if (obj.filters.blendTrans.status != 2) {
        obj.filters.blendTrans.apply();
        obj.style.visibility="visible";
        obj.filters.blendTrans.play();
		
    }
}
function transparacy(ppage){

var obj =MM_findObj(ppage)
   obj.style.filter ="alpha(opacity=70, finishopacity=70, style=1, startx=0, starty=0, finishx=200, finishy=500)"
   obj.filters.alpha.apply();
}

function setLayerXY(lname,lX,lY){
	MM_findObj(lname).style.left= lX;
	MM_findObj(lname).style.top= lY;
}
//**********************************************************
function goBack()
{
history.back()
}
//**********************************************************
function Cash(money) {
money=Math.round(money*100).toString();
if (money<10) return '0.0'+money;
return (money<100)?'0.'+money:+money.substring(0,money.length-2)+'.'+money.substring(money.length-2,money.length);
}

//**********************************************************
 function formatNumber(num, decimalNum, bolLeadingZero, bolParens)
   /* IN - num:            the number to be formatted
           decimalNum:     the number of decimals after the digit
           bolLeadingZero: true / false to use leading zero
           bolParens:      true / false to use parenthesis for - num

      RETVAL - formatted number
   */
   {
       var tmpNum = num;

       // Return the right number of decimal places
       tmpNum *= Math.pow(10,decimalNum);
       tmpNum = Math.floor(tmpNum);
       tmpNum /= Math.pow(10,decimalNum);

       var tmpStr = new String(tmpNum);

       // See if we need to hack off a leading zero or not
       if (!bolLeadingZero && num < 1 && num > -1 && num !=0)
           if (num > 0)
               tmpStr = tmpStr.substring(1,tmpStr.length);
           else
               // Take out the minus sign out (start at 2)
               tmpStr = "-" + tmpStr.substring(2,tmpStr.length);                        


       // See if we need to put parenthesis around the number
       if (bolParens && num < 0)
           tmpStr = "(" + tmpStr.substring(1,tmpStr.length) + ")";


       return tmpStr;
   }

//**********************************************************
function numberCheck(param) {
   param.value = stripNonDigits(param.value);
   
 }

//**********************************************************
function stripNonDigits(str)
  {
  newStr = "";
  for(j=0; j<str.length; j++)
    {
    c = str.charAt(j);
    if(c >= "0" && c <= "9")
      {
      newStr += c;
      }
    }
  return newStr;
  }
//**********************************************************
function rowHighlight(rObj,col)
{
	rObj.style.background = col
}

//---newWindow disable all the unwanted bars from the browser window---
/*---it accepts 
		pageURL: this is the url to the page you want to open
		wName: name of the window
		wth: the width
		hth: the height
		srol: to enable scrollable, this could either be "1 / 0  or yes/no" '1' being enabled and '0'
			  being disabled, the same is true for 'yes/no'
		resiz: to enable or disabled resizing, input is the same as srol.
*/
function newWindow(pageURL,wName,wth,hth,srol,resiz)
{
window.open(pageURL, wName, "location=0, toolbar=0, directories=0, status=0, menubar=0, width="+wth+", height="+hth+", left=120,top=150,scrollbars="+srol+", resizable="+resiz+",fullscreen=0")
}

//--------------------------------------------------------------
//this function hides or shows of specified layer on a page.

function on_off(ppage,pimage)
{ 
var obj =MM_findObj(ppage)

	if(pimage==null){
		if(obj.style.visibility == 'hidden'){
			MM_showHideLayers(ppage,'','show')
			obj.style.visibility = 'inherit'
		}else{
			MM_showHideLayers(ppage,'','hide')
			obj.style.visibility = 'hidden'
		}
	}else{
		if(obj.style.visibility == 'hidden'){
		MM_showHideLayers(ppage,'','show')
		MM_swapImage(pimage,'','file:///E|/My%20Documents/IBM/wsad/pims/images/icons/visible.gif',1)
		obj.style.visibility = 'inherit'
		}else{
		MM_showHideLayers(ppage,'','hide')
		MM_swapImage(pimage,'','file:///E|/My%20Documents/IBM/wsad/pims/images/icons/hidden.gif',1)
		obj.style.visibility = 'hidden'
		}
	}

}

//--------------------------------------------------------------
//this function hides or shows of specified layer on a page.

function showHide(ppage,pimage)
{ 
var obj =MM_findObj(ppage)

	if(pimage==null){
		if(obj.style.visibility == 'hidden'){
			MM_showHideLayers(ppage,'','show')
			obj.style.position = 'relative'
			obj.style.visibility = 'inherit'
		}else{
			MM_showHideLayers(ppage,'','hide')
			obj.style.position = 'absolute'
			obj.style.visibility = 'hidden'
		}
	}else{
		if(obj.style.visibility == 'hidden'){
		MM_showHideLayers(ppage,'','show')
		MM_swapImage(pimage,'','file:///E|/My%20Documents/IBM/wsad/pims/images/icons/visible.gif',1)
		obj.style.position = 'relative'
		obj.style.visibility = 'inherit'
		}else{
		MM_showHideLayers(ppage,'','hide')
		MM_swapImage(pimage,'','file:///E|/My%20Documents/IBM/wsad/pims/images/icons/hidden.gif',1)
		obj.style.position = 'absolute'
		obj.style.visibility = 'hidden'
		}
	}

}

//this function is used to hide the select elements on the 
//the html page when i layer is over it..
function dropDowns()
{
	var ddArray = dropDowns.arguments;
	
	for(var i=0,obj;i< ddArray.length;i++){
		on_off(ddArray[i]);
		layerVisibility(ddArray[i])
	}
}

function layerVisibility(ppage)
{
var obj =MM_findObj(ppage)
if(obj.style.visibility == 'hidden')
obj.style.visibility = 'hidden'
else
obj.style.visibility = 'inherit'
}

function positionLayer(ppage)
{

var obj =MM_findObj(ppage)
if(obj.style.visibility == 'hidden')
obj.style.position = 'absolute'
else
obj.style.position = 'relative'
}
//-----------------------------------------------------------
// this function is responsible for setting the page title
// at the top area of the application 
function setTitle(icon,textimg){
parent.document.all.pageTitle.innerHTML=" "+"<img src='../../../images/icons/"+icon+".gif'>&nbsp;<img src='../../../images/titles/"+textimg+".gif'>"

}
//----------------------------------------------------------------------------------

function applicationMode(){
var winWsize = 560
var winHsize = 300
//window.location ="splash.do"
if(is_ie5up == true){
window.open("splash.do", "lmisWebApplication", "location=0, toolbar=0, directories=0, status=1, menubar=0, width="+winWsize +", height="+winHsize+", left="+(screen.availWidth-winWsize)/2+",top="+(screen.availHeight-winHsize)/2+",scrollbars=0, resizable=0,fullscreen=0")
}else{
document.all.pageMessage.innerHTML ="<br><h5>"+
									"This application requires Internet Explorer 5.x and above.<br>"+
									" You will need to get this browser to continue.. <br>"+
									"</h5>"
}

}

//----------------predefind functions----------------------------------------------

function MM_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; 
    n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) 
  	x=d.all[n]; 
  for (i=0;!x&&i<d.forms.length;i++) 
  	x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
  	x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) 
  	x=d.getElementById(n); 

  return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


function MM_controlSound(x, _sndObj, sndFile) { //v3.0
  var i, method = "", sndObj = eval(_sndObj);
  if (sndObj != null) {
    if (navigator.appName == 'Netscape') method = "play";
    else {
      if (window.MM_WMP == null) {
        window.MM_WMP = false;
        for(i in sndObj) if (i == "ActiveMovie") {
          window.MM_WMP = true; break;
      } }
      if (window.MM_WMP) method = "play";
      else if (sndObj.FileName) method = "run";
  } }
  if (method) eval(_sndObj+"."+method+"()");
  else window.location = sndFile;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj) obj.value = newText;
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

//=====================================================================================
//=====================================================================================
//assign function to events.........
document.onkeydown = parseKeystrokes;
//document.onmousedown =  parseMousestrokes;
document.onmouseover = buttonHover;
document.onmouseout = buttonOut;
document.onfocusout = onBlurEvents; 
//document.onfocusin = onfocusinEvent;
//document.onkeyup = parseKeystrokes;
//document.onchange = onChangeEvents;

//default function calls.............
//formCheck();
//-->

//=====================================================================================
/*This function controls a maximum textarea input amount and updates a small counter with how many characters 
are left with each keystroke. Dynamic fix now allows you to use this script in multiple textboxes on a page. 
<!-- Original:  Ronnie T. Moore -->
<!-- Web Site:  The JavaScript Source -->

<!-- Dynamic 'fix' by: Nannette Thacker -->
<!-- Web Site: http://www.shiningstar.net -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin*/
function textCounter(field, countfield, maxlimit) {

	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
	else // otherwise, update 'characters left' counter
		countfield.value = maxlimit - field.value.length;

}

/*
* Responsible for the enabling and disabling of the [update] button object as per application number entry.
*/
function check4ApplNbrEntry(){

	// By default, [update] button should be disabled.
	document.all.update.disabled = true;
	
	// Only if application number was entered, enable [update] button object.
	if(document.all.applNbr.value.length != 0){
		
		document.all.update.disabled = false;
	}	
}

/*
* This function is reposnsible for disabling the given 'Submit Button' 
* when clicked and continue with its processing
*/
count = 0;
function disableClickedButton(obj){
	//obj.disabled = true; 
	if(++count > 1)
		return false;
	return true;
}

/*  actions to perform on page load
    astewart
*/
function loadEvents(){
	//prevent resubmission during form processing
	var i;
	for (i = 0; i < document.forms.length; i++){
		document.forms[i].onsubmit = checkResubmit;
	}
}
/* 	function checkResubmit disables submit buttons if a
	form submission is already in progress

	astewart
*/
var submissions = 0;

function checkResubmit(){
	if (++submissions > 1){
		inputTags = document.getElementsByTagName("input");
		for (i = 0; i < inputTags.length; i++){
			if (inputTags[i].type == "submit")
				inputTags[i].disabled = "true";
		}
		alert("Button clicked is recognized -- No need to repeat this action.");
		return false;
	}
	return true;
}

window.onload = loadEvents;
 
// End -->