//*********************************************************************************
// file: loss.js
// purpose: provides functionality for the Claims/loss reporting asp pages
// date modified: dec-20-2000
// Modified by:   Brandon Edwards and Brett Cooper
// date modified: jan-15-2001
// Modified by:   Art Scholar
// date modified: feb-07-2001  by Tina Cheng
// Modified:  set cursor focus on the txtfield, changes made under Next()
// date modified: feb-22-2001
// Modified by:   Art Scholar
// Modified:  Added dayfrom and dayto fields on contact overlay
// date modified: feb-26-2001  by Tina Cheng
// Modified:  set cursor focus after alert mesg
//*********************************************************************************

var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode;
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
return true;
}

function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}

function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}



//*********************************************************************************
//Fucntion: language 
//purpose: Prompts user for "Other" Language and gives Loss.OtherLanguage input field the value
//
//*********************************************************************************
function Language(sVar)
{
  if(document.all)
  {
    if (sVar.value == 'Other')
    {
      strLang = "Other";
      strLang = prompt("Please enter in the other language of your preferance (maximum 20 characters)",strLang);
      document.Loss.OtherLanguage.value = strLang;
    }
  }
  else
  {
    if (sVar[sVar.selectedIndex].value == 'Other')
    {
  
  
      strLang = "Other";
      strLang = prompt("Please enter in the other language of your preferance (maximum 20 characters)",strLang);
      document.Loss.OtherLanguage.value = strLang;
      
    }
  }
}
 

//*********************************************************************************
//Hides changes all class's to LrNumbers and then changes selected Class to LRNumbersSel
//
//*********************************************************************************
function OMOVClass(sVar)
{
 if (document.all)
 {
    Number1.className = 'LrNumbers';
    Number2.className = 'LrNumbers';
    Number3.className = 'LrNumbers';
    Number4.className = 'LrNumbers';
    sVar.className = 'LRNumbersSel';
 }
 else
 {
    //hide all of the big numbers 
	document.Number1on.visibility = "Hide";
	document.Number2on.visibility = "Hide";
	document.Number3on.visibility = "Hide";
	document.Number4on.visibility = "Hide";
    //show the new number
    document.layers[sVar].visibility = "Show";
  
 }
  
}


//*********************************************************************************
//Hides all Layers or Divs
//
//*********************************************************************************
function HideAll()
{

  if(document.all)
  {
    ContactDiv.style.display = 'none';
    PersonalDiv.style.display = 'none';
    BeginDiv.style.display = 'none';
    LossDiv.style.display = 'none';
    LineDiv1.style.display = 'none';
    LineDiv2.style.display = 'none';
    LineDiv3.style.display = 'none';
    LineDiv4.style.display = 'none';
  }
  else
  {
    document.ContactDiv.visibility = "Hide";
    document.PersonalDiv.visibility = "Hide";
    document.BeginDiv.visibility = "Hide";
    document.LossDiv.visibility = "Hide";
    document.LineDiv1.visibility = "Hide";
    document.LineDiv2.visibility = "Hide";
    document.LineDiv3.visibility = "Hide";
    document.LineDiv4.visibility = "Hide";
  }
}


//*********************************************************************************
//Displays Title, hide's and shows apropriated Divs or Layers as well as Image Lines
//
//*********************************************************************************
var sVarPage = 1;
function InfoBody(sVarText, sVarLine, sVarTitle, sVar)
{
  if (document.all)
  {
    HideAll();
    sVarText.style.display = '';
    sVarLine.style.display = '';
    Title.innerHTML = sVarTitle;
  }
  else
  {
    HideAll();
    document.layers[sVarText].visibility = "Show";
    document.layers[sVarLine].visibility = "Show";
    document.Title.document.open();
    document.Title.document.write(sVarTitle);
    document.Title.document.close();
      }
  sVarPage = sVar;
}



//*********************************************************************************
//Checks current page goes forward depending on page
// date modified: feb-07-2001  by Tina Cheng
// Modified:  set cursor focus on the txtfield, changes made under Next()
//*********************************************************************************
function NextPage()
{
		
  if (document.all)
  {
      if (sVarPage == 1)
   
	{
	  if (ValidatePage(sVarPage))
      {
		InfoBody(PersonalDiv, LineDiv2, ' ', 2);
        OMOVClass(Number2);
        document.Loss.firstName.focus();
     
        return true;
      }
          }
    if (sVarPage == 2)
      {
	  
      if(ValidatePage(sVarPage))
      {
		InfoBody(ContactDiv, LineDiv3, ' ', 3);
        OMOVClass(Number3);
           
        return true;
      }
          }
    if (sVarPage == 3)
    
    {
	  if(ValidatePage(sVarPage))
      {
	   InfoBody(LossDiv, LineDiv4, ' ', 4);
       OMOVClass(Number4);
       document.Loss.month.focus();
   
        return true;
      }  
    }

    if (sVarPage == 4)
    {
    CheckValidation();
	return true;
    }

 }
  else
  {
    if (sVarPage == 1)
    {
       InfoBody('PersonalDiv','LineDiv2','','2');
       OMOVClass('Number2on');
       document.PersonalDiv.document.Personal.firstName.focus();
       return true;
    }
    if (sVarPage == 2)
    {
      if(ValidatePage(sVarPage))
      {
        InfoBody('ContactDiv','LineDiv3',' ','3');
        OMOVClass('Number3on');
        document.ContactDiv.document.Contact.areacphone.focus();
        return true;
      }
    }
    if (sVarPage == 3)
    {	document.Loss[41].value = "Submit";	
	  if(ValidatePage(sVarPage))
      {
		
	    InfoBody('LossDiv','LineDiv4',' ','4');
        OMOVClass('Number4on');
        document.LossDiv.document.LossInfo.month.focus();
        return true;
      }
    }
        if (sVarPage == 4)
    {
		CheckValidation();
		return true;
    }

 }
  return false;
}

//*********************************************************************************
//Checks current page goes back depending on page
//
//*********************************************************************************
function BackPage()
{
  if (document.all)
  {
	
    if (sVarPage == 2)
    {
    
    //  if(ValidatePage(sVarPage))
      {
		
		document.Loss[41].value = "Next";	
		InfoBody(BeginDiv, LineDiv1, ' ', 1);
        OMOVClass(Number1);
        return true;
      }
    }
    if (sVarPage == 3)
    {
	   //  if(ValidatePage(sVarPage))
      {
		
		InfoBody(PersonalDiv, LineDiv2, '', 2);
        OMOVClass(Number2);
        document.Loss[41].value = "Next";	
	    return true;
      }
    }
    if (sVarPage == 4)
    {
		
		document.Loss[41].value = "Next";	
	   //  if(ValidatePage(sVarPage))
      {
		InfoBody(ContactDiv, LineDiv3, ' ', 3);
        OMOVClass(Number3);
	    return true;
      }
    }
  }
  else
  {
    if (sVarPage == 2)
    {
   //   if (ValidatePage(sVarPage))
      {
        InfoBody('BeginDiv','LineDiv1',' ','1');
        OMOVClass('Number1on');
        return true;
      }
    }
    if (sVarPage == 3)
    {
  //    if (ValidatePage(sVarPage))
      {
        InfoBody('PersonalDiv','LineDiv2','','2');
        OMOVClass('Number2on');
        return true;
      }
    }
    if (sVarPage == 4)
    {
  //    if(ValidatePage(sVarPage))
      {
        InfoBody('ContactDiv','LineDiv3',' ','3');
        OMOVClass('Number3on');
        return true;
      }
    }
  }
}

//*********************************************************************************
// By Alok ,
// if Submit button is already clicked and user clicked it again..advice him to wait for while.
// THIS FUNCTION IS NOT BEING USED 
//*********************************************************************************
function button1_onclick() {
if (document.Loss[1].value == "Submit") {
document.Loss[1].value = "Wait..request is being proccessed" 
return true;
}
else {
alert("Please wait.. Request is still being processed");
return false;
}
}

//*********************************************************************************
//Number Navagation for the numbers on top left of the screen
//
//*********************************************************************************
function NextNumber(sNum)
{
  if (document.all)
  {
    if(sNum == "1")
    {
      if (ValidatePage(sVarPage))
      {
        InfoBody(BeginDiv,LineDiv1,' ',1);
        OMOVClass(Number1);
        return true;
      }
    }
    if(sNum == "2")
    {
      if (ValidatePage(sVarPage))
      {
        InfoBody(PersonalDiv,LineDiv2,'',2);
        OMOVClass(Number2);
        return true;
      }
    }
    if(sNum == "3")
    {  
      if (ValidatePage(sVarPage))
      {
        InfoBody(ContactDiv,LineDiv3,' ',3);
        OMOVClass(Number3);
        return true;
      }
    }
    if(sNum == "4")
    {
      if (ValidatePage(sVarPage))
      {
        InfoBody(LossDiv,LineDiv4,' ',4);
        OMOVClass(Number4);
        return true;
      }
    }
  }
  else
  {
    if(sNum == "1")
    {
      if (ValidatePage(sVarPage))
      {
        InfoBody('BeginDiv','LineDiv1','','1');
        return true;
      }
    }
    if(sNum == "2")
    {
      if (ValidatePage(sVarPage))
      {
        InfoBody('PersonalDiv','LineDiv2','','2');
        return true;
      }
    }
    if(sNum == "3")
    {  
      if (ValidatePage(sVarPage))
      {
        InfoBody('ContactDiv','LineDiv3','','3');
        return true;
      }
    }
    if(sNum == "4")
    {  
      if (ValidatePage(sVarPage))
      {
        InfoBody('LossDiv','LineDiv4',' ','4');
        return true;
      }
    }
  }
}



//*********************************************************************************
//Makes sure that Validated only happens once per page
//So that strValidated is not incrimented past 4
//
//*********************************************************************************
var blPerValidated = false;
var blConValidated = false;
var blLosValidated = false;
function ValiInc(sPageNum)
{
  if (sPageNum == "2")
  {
    if (blPerValidated == false)
    {
      Validated();
      blPerValidated = true;
 	  document.Loss[41].value = "Next";	
 
    }
  }
  if (sPageNum == "3")
  {
       document.Loss[41].value = "Submit";
    if (blConValidated == false)
    {
      Validated();
      blConValidated = true;
    
 }
  
  }
  if (sPageNum == "4")
  {	
	if (blLosValidated == false)
    {
	  Validated();
	  blLosValidated = true;
    }
   }
}


//*********************************************************************************
//returns true if empty.
//
//*********************************************************************************
function isEmpty(sVar)
{
  return(sVar.length == 0)  
}

//*********************************************************************************
//Characters bags for validation
//*********************************************************************************
//"Numeric"
var sDigits = "1234567890";
//"NumericS"
var sDigitsS = "1234567890 ";
//"AlphaNoSpaces"
var sAlpha = "abcdefghijklmnopqrstuvwxyz";
//"AlphaNumericNoSpaces"
var sAlphaNumeric = "1234567890abcdefghijklmnopqrstuvwxyz";
//"AlphaNumeric"
var sAplhaNumericS = "1234567890abcdefghijklmnopqrstuvwxyz,.# \'\t\n\r";
//"Alpha"
var sAlphaS = "abcdefghijklmnopqrstuvwxyz ";
//"AlphaWithBracket"
var sAlphaWithBracketS = "abcdefghijklmnopqrstuvwxyz() ";



//*********************************************************************************
// validates characters are correct type
//
//*********************************************************************************
function CharacterValidate(sValue, sCharacters)
{
  var sInt;
  for (sInt = 0; sInt < sValue.length; sInt++)
  {
    var cVar = sValue.charAt(sInt);
    if (sCharacters.indexOf(cVar) == -1)
      return true;      
  }
  return false;
}


//*********************************************************************************
//Validation used by passing in input names
//
//*********************************************************************************
function ValidateInput(sLayer,sForm,sName,sErrMsg,sType)
{
  var sVar
  
  if(sType == "Numeric")
  sCharacters = sDigits;
  if(sType == "NumericS")
  sCharacters = sDigitsS;
  if(sType == "AlphaNoSpaces")
  sCharacters = sAlpha;
  if(sType == "AlphaNumericNoSpaces")
  sCharacters = sAlphaNumeric;
  if(sType == "AlphaNumeric")
  sCharacters = sAplhaNumericS;
  if(sType == "Alpha")
  sCharacters = sAlphaS;
  if(sType == "AlphaWithBracket")
  sCharacters = sAlphaWithBracketS;
 
  if (document.all) //IE Section
  {
    sVar = document.Loss(sName).value;
    if (isEmpty(sVar))
    {
      alert(sErrMsg);
      return false; 
    }
    if (CharacterValidate(sVar.toLowerCase(),sCharacters))
    {
      alert(sErrMsg);
      return false; 
    }
    return true; 
  }
  else             //Netscape Section
  {
    sVar = document.layers[sLayer].document[sForm][sName].value;
    if(isEmpty(sVar))
    {
      alert(sErrMsg);
      return false;
    }
    if (CharacterValidate(sVar.toLowerCase(),sAplhaNumericS))
    {
      alert(sErrMsg);
      return false; 
    }
    return true;
  }
}


//*********************************************************************************
//Checks to see if the email space is either empty or has a valid email
//
//*********************************************************************************
function ValidateEmail(s)
  {
   
    // if (isEmpty(s)) or blank then don't check the value
     if (isEmpty(s)) return true;
     if (isWhitespace(s)) return true;
 
     // there must be >= 1 character before @, so we
     // start looking at character position 1
     // (i.e. second character)
     var i = 1;
     var sLength = s.length;
 
     // look for @
     while ((i < sLength) && (s.charAt(i) != "@"))
     { i++
     }
     if ((i >= sLength) || (s.charAt(i) != "@")) 
      {
       alert("Please enter a valid email");
	
	// set focus and select after invalid inpu alert  -- TC 02/26/01
       	if (document.all){
       		document.Loss.email.focus();
       		document.Loss.email.select();}
       	else {
       		document.PersonalDiv.document.Personal.email.focus();
       		document.PersonalDiv.document.Personal.email.select();}
        // end change made on set focus and select
        
       return false;
     }
     else i += 2;
 
     // look for .
     while ((i < sLength) && (s.charAt(i) != "."))
     { i++
     }
 
     // there must be at least one character after the .
     if ((i >= sLength - 1) || (s.charAt(i) != ".")) 
     {
       alert("Please enter a valid email");

	// set focus and select after invalid inpu alert  -- TC 02/26/01
       	if (document.all){
       		document.Loss.email.focus();
       		document.Loss.email.select();}
       	else {
       		document.PersonalDiv.document.Personal.email.focus();
       		document.PersonalDiv.document.Personal.email.select();}
        // end change made on set focus and select
        
       return false;
     }
     else return true;
  }

//*********************************************************************************
//  to see if a policy number is valid
//
//*********************************************************************************
function ValidatePolicyNo(sState, sPolicy)
{
if ( ((!isEmpty(sState))&&(!isWhitespace (sState) )) || ((!isEmpty(sPolicy))&&(!isWhitespace(sPolicy) )) )

    {

    if ( (CharacterValidate(sState,sAlphaNumeric))|| ((sState.length)<2))
        {
            alert("Please Enter a valid Policy State code");
            
            	// set focus and select after invalid inpu alert  -- TC 02/26/01
	          	if (document.all){
	           		document.Loss.PolicyState.focus();
	           		document.Loss.PolicyState.select();}
	           	else {
	           		document.PersonalDiv.document.Personal.PolicyState.focus();
	           		document.PersonalDiv.document.Personal.PolicyState.select();}
	    	// end change made on set focus and select
        
            return false; 
        }

    if ( (CharacterValidate(sPolicy,sAlphaNumeric))|| ((sPolicy.length)<1))
        {
            alert("Please Enter a valid Policy State/Number code");
            
            	// set focus and select after invalid inpu alert  -- TC 02/26/01
	          	if (document.all){
	           		document.Loss.PolicyNumber.focus();
	           		document.Loss.PolicyNumber.select();}
	           	else {
	           		document.PersonalDiv.document.Personal.PolicyNumber.focus();
	           		document.PersonalDiv.document.Personal.PolicyNumber.select();}
	    	// end change made on set focus and select
    
            return false; 
        }
    }
return true;
}
//*********************************************************************************
//  to see if a phone number is valid
//
//*********************************************************************************
function ValidatePhone(sArea, sPre, sPost, sExt, sPhone)
{
var  sAltPhone = sArea + sPre + sPost + sExt;

if ((sPhone == "1") && ((sAltPhone.length) < 1) )
    {
      return true;
    } 

if ( (CharacterValidate(sArea,sDigits))|| ((sArea.length)<3))
    {
      alert("Please Enter a valid area code");
            
    	// set focus and select after invalid inpu alert  -- TC 02/26/01
	       	if (document.all){
	       		document.Loss.areacphone.focus();
	   		document.Loss.areacphone.select();}
	       	else {
	      		document.ContactDiv.document.Contact.areacphone.focus();
	       		document.ContactDiv.document.Contact.areacphone.select();}
	// end change made on set focus and select
    
      return false; 
    }
if ( (CharacterValidate(sPre,sDigits))|| ((sPre.length)<3))
    {
      alert("Please Enter a valid Phone Prefix");
            
    	// set focus and select after invalid inpu alert  -- TC 02/26/01
	       	if (document.all){
	       		document.Loss.prefcphone.focus();
	   		document.Loss.prefcphone.select();}
	       	else {
	      		document.ContactDiv.document.Contact.prefcphone.focus();
	       		document.ContactDiv.document.Contact.prefcphone.select();}
	// end change made on set focus and select

      return false; 
    }
if ( (CharacterValidate(sPost,sDigits)) || ((sPost.length)<4))
    {
      alert("Please Enter a valid Phone Number");
            
    	// set focus and select after invalid inpu alert  -- TC 02/26/01
	       	if (document.all){
	       		document.Loss.cphone.focus();
	   		document.Loss.cphone.select();}
	       	else {
	      		document.ContactDiv.document.Contact.cphone.focus();
	       		document.ContactDiv.document.Contact.cphone.select();}
	// end change made on set focus and select

      return false; 
    }
if (CharacterValidate(sExt,sDigits))
   	  {
       	     alert("Please Enter a numeric phone extension");
            
    	// set focus and select after invalid inpu alert  -- TC 02/26/01
	       	if (document.all){
	       		document.Loss.extcphone.focus();
	   		document.Loss.extcphone.select();}
	       	else {
	      		document.ContactDiv.document.Contact.extcphone.focus();
	       		document.ContactDiv.document.Contact.extcphone.select();}
	// end change made on set focus and select

      	     return false; 
    	  }
return true;

}

//*********************************************************************************
//  to see if a phone number is valid
//
//*********************************************************************************
function ValidateAltPhone(sArea, sPre, sPost, sExt, sPhone)
{
var  sAltPhone = sArea + sPre + sPost + sExt;

if ((sPhone == "1") && ((sAltPhone.length) < 1) )
    {
      return true;
    } 

if ( (CharacterValidate(sArea,sDigits))|| ((sArea.length)<3))
    {
      alert("Please Enter a valid area code");
            
    	// set focus and select after invalid inpu alert  -- TC 02/26/01
	       	if (document.all){
	       		document.Loss.areaaphone.focus();
	   		document.Loss.areaaphone.select();}
	       	else {
	      		document.ContactDiv.document.Contact.areaaphone.focus();
	       		document.ContactDiv.document.Contact.areaaphone.select();}
	// end change made on set focus and select
    
      return false; 
    }
if ( (CharacterValidate(sPre,sDigits))|| ((sPre.length)<3))
    {
      alert("Please Enter a valid Phone Prefix");
            
    	// set focus and select after invalid inpu alert  -- TC 02/26/01
	       	if (document.all){
	       		document.Loss.prefaphone.focus();
	   		document.Loss.prefaphone.select();}
	       	else {
	      		document.ContactDiv.document.Contact.prefaphone.focus();
	       		document.ContactDiv.document.Contact.prefaphone.select();}
	// end change made on set focus and select

      return false; 
    }
if ( (CharacterValidate(sPost,sDigits)) || ((sPost.length)<4))
    {
      alert("Please Enter a valid Phone Number");
            
    	// set focus and select after invalid inpu alert  -- TC 02/26/01
	       	if (document.all){
	       		document.Loss.aphone.focus();
	   		document.Loss.aphone.select();}
	       	else {
	      		document.ContactDiv.document.Contact.aphone.focus();
	       		document.ContactDiv.document.Contact.aphone.select();}
	// end change made on set focus and select

      return false; 
    }
if (CharacterValidate(sExt,sDigits))
   	  {
       	     alert("Please Enter a numeric phone extension");
            
    	// set focus and select after invalid inpu alert  -- TC 02/26/01
	       	if (document.all){
	       		document.Loss.extaphone.focus();
	   		document.Loss.extaphone.select();}
	       	else {
	      		document.ContactDiv.document.Contact.extaphone.focus();
	       		document.ContactDiv.document.Contact.extaphone.select();}
	// end change made on set focus and select

      	     return false; 
    	  }
return true;

}




//*********************************************************************************
//  to see if Call Time is valid
//
//*********************************************************************************
function ValidateCallTime(sASAP, sFhr, sFmn, sFAP, sThr, sTmn, sTAP)
{
var sTimes
sTimes = sFhr + sFmn + sFAP + sThr + sTmn + sTAP;

if ( ((sASAP == true) && ((sTimes.length) > 0) ) || ((sASAP == false) && ((sTimes.length)<1)) )
    {
      alert("Please choose ASAP or Call Time");
      return false; 
    }
if (sASAP != true)
    {
	if ( sFhr.length < 1 ) 
	{
      		alert("Please choose 'from' Hour");

	    	// set focus and select after invalid inpu alert  -- TC 02/27/01
	       	if (document.all){document.Loss.bsttimefromhr.focus();}
	       	else {document.ContactDiv.document.Contact.bsttimefromhr.focus();}
		// end change made on set focus and select
      		
      		return false; 
    	}
	if ( sFmn.length < 1 ) 
	{
      		alert("Please choose 'from' Minute");
      		
	    	// set focus and select after invalid inpu alert  -- TC 02/27/01
	       	if (document.all){document.Loss.bsttimefrommn.focus();}
	       	else {document.ContactDiv.document.Contact.bsttimefrommn.focus();}
		// end change made on set focus and select
      		
      		return false; 
    	}
	if ( sFAP.length < 1 ) 
	{
      		alert("Please choose 'from' AM/PM");
	    	// set focus and select after invalid inpu alert  -- TC 02/27/01
	       	if (document.all){document.Loss.fromampm.focus();}
	       	else {document.ContactDiv.document.Contact.fromampm.focus();}
		// end change made on set focus and select
      		
      		return false; 
    	}
	if ( sThr.length < 1 ) 
	{
      		alert("Please choose 'to' Hour");

	    	// set focus and select after invalid inpu alert  -- TC 02/27/01
	       	if (document.all){document.Loss.bsttimetohr.focus();}
	       	else {document.ContactDiv.document.Contact.bsttimetohr.focus();}
		// end change made on set focus and select
      		
      		return false; 
    	}
	if ( sTmn.length < 1 ) 
	{
      		alert("Please choose 'to' Minute");

	    	// set focus and select after invalid inpu alert  -- TC 02/27/01
	       	if (document.all){document.Loss.bsttimetomn.focus();}
	       	else {document.ContactDiv.document.Contact.bsttimetomn.focus();}
		// end change made on set focus and select
      		
      		return false; 
    	}
	if ( sTAP.length < 1 ) 
	{
      		alert("Please choose 'to' AM/PM");

	    	// set focus and select after invalid inpu alert  -- TC 02/27/01
	       	if (document.all){document.Loss.toampm.focus();}
	       	else {document.ContactDiv.document.Contact.toampm.focus();}
		// end change made on set focus and select
      		
      		return false; 
    	}
	//if ( sZone.length < 1 ) 
	//{
      	//	alert("Please choose Time Zone");
      	//	return false; 
    	//}
    }
return true;

}
//*********************************************************************************
//  to set day choice to visible 
//
//*********************************************************************************
function Lockdays()
{
if (document.all)
{    if (document.Loss.ASAP.checked == true)
	{
	document.Loss.dayfrom.disabled = true;
	document.Loss.dayto.disabled = true;
	}
    else
	{
	document.Loss.dayfrom.disabled = false;
	document.Loss.dayto.disabled = false;
	}
}
else
{    if (document.ContactDiv.document.Contact.ASAP.checked == true)
	{
	document.ContactDiv.document.Contact.dayfrom.disabled = true;
	document.ContactDiv.document.Contact.dayto.disabled = true;
	}
    else
	{
	document.ContactDiv.document.Contact.dayfrom.disabled = false;
	document.ContactDiv.document.Contact.dayto.disabled = false;
	}
}
return true;

}
//*********************************************************************************
//  to see if Call Time is valid
//
//*********************************************************************************
function ValidateIncidentTime(sIhr, sImn, sIAP)
{
var sTimes
sTimes = sIhr + sImn + sIAP;

if ((sTimes.length)>0)
    {
	if ( sIhr.length < 1 ) 
	{
      		alert("Please choose Incident Hour");
      		
	    	// set focus and select after invalid inpu alert  -- TC 02/27/01
	       	if (document.all){document.Loss.timeoflosshr.focus();}
	       	else {document.LossDiv.document.LossInfo.timeoflosdhr.focus();}
		// end change made on set focus and select
      		
      		return false; 
    	}
	if ( sImn.length < 1 ) 
	{
      		alert("Please choose Incident Minute");

	    	// set focus and select after invalid inpu alert  -- TC 02/27/01
	       	if (document.all){document.Loss.timeoflossmn.focus();}
	       	else {document.LossDiv.document.LossInfo.timeoflossmn.focus();}
		// end change made on set focus and select

      		return false; 
    	}
	if ( sIAP.length < 1 ) 
	{
      		alert("Please choose Incident AM/PM");

	    	// set focus and select after invalid inpu alert  -- TC 02/27/01
	       	if (document.all){document.Loss.ampm1.focus();}
	       	else {document.LossDiv.document.LossInfo.ampm1.focus();}
		// end change made on set focus and select

      		return false; 
	}    	
    }
return true;

}
//*********************************************************************************
//  to see if a ZipCode is valid
//
//*********************************************************************************
function ValidateZip(sZip)
{
if ( (CharacterValidate(sZip,sDigits))|| ((sZip.length)<5))
    {
       alert("Please Enter a valid Zip code");

    	// set focus and select after invalid inpu alert  -- TC 02/27/01
	       	if (document.all){
	       		document.Loss.zip.focus();
	       		document.Loss.zip.select();}
	       	else {
	       		document.PresonalDiv.document.Personal.zip.focus();
	       		document.PresonalDiv.document.Personal.zip.select();}
	// end change made on set focus and select

      return false; 
    }
return true;

}
//*********************************************************************************
//  to see if a ZipCode Extension is valid
//
//*********************************************************************************
function ValidateZipExt(sZip)
{

// Check to see if there is nothing in the space
if ((!isEmpty(sZip))&&(!isWhitespace (sZip)))
    {
	if ( (CharacterValidate(sZip,sDigits))|| ((sZip.length)<4))
    	  {
       	     alert("Please Enter a valid Zip code extension");

	    	// set focus and select after invalid inpu alert  -- TC 02/27/01
		       	if (document.all){
		       		document.Loss.zipext.focus();
		       		document.Loss.zipext.select();}
		       	else {
		       		document.PresonalDiv.document.Personal.zipext.focus();
		       		document.PresonalDiv.document.Personal.zipext.select();}
		// end change made on set focus and select

      	     return false; 
    	  }
     }
return true;
}


//*********************************************************************************
//Checks which page is going to be validated then validates
//Use ValInc to only validate page once.
//To decide wich type of validation you need on each field use
//"Numeric" for numeric only
//"NumericS" for numeric with spaces
//"AlphaNumeric" for alpha numeric with spaces
//"AlphaNumericNoSpaces" for alphanumeric and no spaces
//"AlphaNoSpaces" for alpha characters with no spaces
//"Alpha" for alpha characters
//"AlphaWithBracket for alpha with bracket
//*********************************************************************************
function ValidatePage(sCurPage)
{
  
  if (document.all)
  {
    if(sCurPage == "2")
    {
      if (isWhitespace (document.Loss.firstName.value))
	{
	alert('Please enter your first name');
	document.Loss.firstName.focus();  //add focus TC 02/27/01
	document.Loss.firstName.select(); //add select TC 02/27/01
	return false;
	}
      if (!ValidateInput('','','firstName','Please enter your first name using valid alpha characters','Alpha'))
       return false;

      if (isWhitespace (document.Loss.lastName.value))
	{
	alert('Please enter your last name');
	document.Loss.lastName.focus();  //add focus TC 02/27/01
	document.Loss.lastName.select(); //add select TC 02/27/01
	return false;
	}
      if (!ValidateInput('','','lastName','Please enter your last name using valid alpha characters','AlphaNumeric'))
        return false;

      if (!ValidatePolicyNo(document.Loss.PolicyState.value,document.Loss.PolicyNumber.value))
        return false;
      if (isWhitespace (document.Loss.street.value))
	{
	alert('Please enter your street address');
	document.Loss.street.focus();  //add focus TC 02/27/01
	document.Loss.street.select(); //add select TC 02/27/01	
	return false;
	}
      if (!ValidateInput('','','street','Please enter your street address','AlphaNumeric'))
        return false;
 
     if (isWhitespace (document.Loss.city.value))
   	{
   	alert('Please enter your city');
	document.Loss.city.focus();  //add focus TC 02/27/01
	document.Loss.city.select(); //add select TC 02/27/01	
   	return false;
   	}
      if (!ValidateInput('','','city','Please enter your city','Alpha'))
        return false;

      if (!ValidateInput('','','state','Please enter your state','AlphaNumeric'))
        return false; 
      if (!ValidateZip(document.Loss.zip.value))
        return false;
      if (!ValidateZipExt(document.Loss.zipext.value))
        return false;
      if (!ValidateEmail(document.Loss.email.value))
        return false;
      ValiInc(2);
    }
    if(sCurPage == "3")
	 { 
     if (!ValidatePhone(document.Loss.areacphone.value,
			document.Loss.prefcphone.value,
			document.Loss.cphone.value,
			document.Loss.extcphone.value,
			'0' ))
        return false;

     if (!ValidateAltPhone(document.Loss.areaaphone.value,
  			document.Loss.prefaphone.value,
  			document.Loss.aphone.value,
  			document.Loss.extaphone.value,
  			'1'))
  	return false;
	
	
     if (!ValidateCallTime(document.Loss.ASAP.checked,
  			   document.Loss.bsttimefromhr.value,
  			   document.Loss.bsttimefrommn.value,
  			   document.Loss.fromampm.value,
  			   document.Loss.bsttimetohr.value,
  			   document.Loss.bsttimetomn.value,
  			   document.Loss.toampm.value))
  	return false;

     if (!ValidateInput('','','timezone','Please select a time zone.','AlphaWithBracket'))
        return false;

      if (document.Loss.ASAP.checked == false)
     {
 	if (!ValidateInput('','','dayfrom','Please select a From Day.','Alpha'))
          return false;

     	if (!ValidateInput('','','dayto','Please select a To Day.','Alpha'))
     		     	
          return false;	
     }
      ValiInc(3);
    }
    
    
    if(sCurPage == "4")
    {
      if (!ValidateInput('','','month','Please select a incident month.','Numeric'))
        return false;
      if (!ValidateInput('','','day','Please select a incident day.','Numeric'))
        return false;
      if (!ValidateInput('','','Year','Please select a incident year.','Numeric'))
        return false;
      if (!DayMatchMonth(document.Loss.month.value, 
			 document.Loss.day.value, 
			 document.Loss.year.value))
	return false;
      if (!ValidateIncidentTime(document.Loss.timeOfLosshr.value,
  			   	document.Loss.timeOfLossmn.value,
  			   	document.Loss.ampm1.value))
	return false;
      if (!ValidateInput('','','timezone1','Please select a time zone.','AlphaWithBracket'))
        return false;
      if (!ValidateInput('','','IssueState','Please select a location where loss occured.','Alpha'))
        return false;
      if (isWhitespace (document.Loss.factsOfLoss.value))             
   	{
   	alert('Please enter in a description of what occurred.');
	document.Loss.factsOfLoss.focus();  //add focus TC 02/27/01
	document.Loss.factsOfLoss.select(); //add select TC 02/27/01	
	
		
   	return false;
   	}

      ValiInc(4);
    }
  }
  else
  {
    if(sCurPage == "2")
    {
      if (isWhitespace (document.PersonalDiv.document.Personal.firstName.value))
	{
	alert('Please enter your first name');
	document.PersonalDiv.document.Personal.firstName.focus();  //add focus TC 02/27/01
	document.PersonalDiv.document.Personal.firstName.select(); //add select TC 02/27/01	
	return false;
	}
      if (!ValidateInput('PersonalDiv','Personal','firstName','Please enter your first name using valid characters','AlphaNumeric'))
        return false;

      if (isWhitespace (document.PersonalDiv.document.Personal.lastName.value))
	{
	alert('Please enter your last name');
	document.PersonalDiv.document.Personal.lastName.focus();  //add focus TC 02/27/01
	document.PersonalDiv.document.Personal.lastName.select(); //add select TC 02/27/01	
	return false;
	}
      if (!ValidateInput('PersonalDiv','Personal','lastName','Please enter your last name using valid characters','AlphaNumeric'))
        return false;

      if (!ValidatePolicyNo(document.PersonalDiv.document.Personal.PolicyState,document.PersonalDiv.document.Personal.PolicyNumber))
        return false;
      if (isWhitespace (document.PersonalDiv.document.Personal.street.value))
	{
	alert('Please enter your street address');
	document.PersonalDiv.document.Personal.street.focus();  //add focus TC 02/27/01
	document.PersonalDiv.document.Personal.street.select(); //add select TC 02/27/01	
	return false;
	}
      if (!ValidateInput('PersonalDiv','Personal','street','Please enter your street address','AlphaNumeric'))
        return false;

      if (!ValidateInput('PersonalDiv','Personal','city','Please enter your city','AlphaNumeric'))
        return false;
      if (!ValidateDropDown('PersonalDiv','Personal','state','Please enter your state','AlphaNumeric'))
        return false;
      if (!ValidateZip(document.layers['PersonalDiv'].document.Personal.zip.value))
        return false;
      if (!ValidateZipExt(document.layers['PersonalDiv'].document.Personal.zipext.value))
        return false;
      if (!ValidateEmail(document.layers['PersonalDiv'].document.Personal.email.value))
        return false;
      ValiInc(2);
    }
    if(sCurPage == "3")
    { 
     if (!ValidatePhone(document.layers['ContactDiv'].document.Contact.areacphone.value,document.layers['ContactDiv'].document.Contact.prefcphone.value, document.layers['ContactDiv'].document.Contact.cphone.value,document.layers['ContactDiv'].document.Contact.extaphone.value))
        return false;
     if (!ValidateCallTime(document.ContactDiv.document.Contact.ASAP.checked,
   			   document.ContactDiv.document.Contact.bsttimefromhr.options[document.ContactDiv.document.Contact.bsttimefromhr.selectedIndex].value,
   			   document.ContactDiv.document.Contact.bsttimefrommn.options[document.ContactDiv.document.Contact.bsttimefrommn.selectedIndex].value,			   
   			   document.ContactDiv.document.Contact.fromampm.options[document.ContactDiv.document.Contact.fromampm.selectedIndex].value,
   			   document.ContactDiv.document.Contact.bsttimetohr.options[document.ContactDiv.document.Contact.bsttimetohr.selectedIndex].value,
   			   document.ContactDiv.document.Contact.bsttimetomn.options[document.ContactDiv.document.Contact.bsttimetomn.selectedIndex].value,			   
   			   document.ContactDiv.document.Contact.toampm.options[document.ContactDiv.document.Contact.toampm.selectedIndex].value))
   			//   document.ContactDiv.document.Contact.timezone.options[document.ContactDiv.document.Contact.timezone.selectedIndex].value))
	return false;
     if (!ValidateDropDown('ContactDiv','Contact','timezone','Please select a time zone.','AlphaWithBracket'))
       return false;
     if (document.ContactDiv.document.Contact.ASAP.checked == false)
     {
     if (!ValidateDropDown('ContactDiv','LossInfo','dayfrom','Please select a From Day.','Alpha'))
       return false;
     if (!ValidateDropDown('ContactDiv','LossInfo','dayto','Please select a To Day.','Alpha'))
       return false;
     }
     ValiInc(3);
    }
    if(sCurPage == "4")
    {
      if (!ValidateDropDown('LossDiv','LossInfo','month','Please select a incident month.','Numeric'))
        return false; 
      if (!ValidateDropDown('LossDiv','LossInfo','day','Please select a incident day.','Numeric'))
       return false;
      if (!ValidateDropDown('LossDiv','LossInfo','year','Please select a incident year.','Numeric'))
       return false;
      if (!DayMatchMonth(document.LossDiv.document.LossInfo.month.options[document.LossDiv.document.LossInfo.month.selectedIndex].value, 
			 document.LossDiv.document.LossInfo.day.options[document.LossDiv.document.LossInfo.day.selectedIndex].value, 
			 document.LossDiv.document.LossInfo.year.options[document.LossDiv.document.LossInfo.year.selectedIndex].value))
       return false;
      if (!ValidateIncidentTime(document.LossDiv.document.LossInfo.timeOfLosshr.options[document.LossDiv.document.LossInfo.timeOfLosshr.selectedIndex].value,
  			   	document.LossDiv.document.LossInfo.timeOfLossmn.options[document.LossDiv.document.LossInfo.timeOfLossmn.selectedIndex].value,
  			   	document.LossDiv.document.LossInfo.ampm1.options[document.LossDiv.document.LossInfo.ampm1.selectedIndex].value))
       return false;
      if (!ValidateDropDown('LossDiv','LossInfo','timezone1','Please select a time zone.','AlphaWithBracket'))
       return false;
      if (!ValidateDropDown('LossDiv','LossInfo','IssueState','Please select a location where loss occurred.','Alpha'))
       return false;
      if (isWhitespace(document.LossDiv.document.LossInfo.factsOfLoss.value))
   	{
   	alert('Please enter in a description of what occurred.');
	document.LossDiv.document.LossInfo.factsOfLoss.focus();  //add focus TC 02/27/01
	document.LossDiv.document.LossInfo.factsOfLoss.select(); //add select TC 02/27/01	   	
   	return false;
   	}
    ValiInc(4);
    }    
  }
  return true;
}



//*********************************************************************************
//Adds 1 to strValidated if validation is successful
//
//*********************************************************************************
var strValidated = "1";
function Validated()
{
  //if validated then strValidated = 1
  strValidated++;
}
//*********************************************************************************
//
//Checks day & month combination
//
//*********************************************************************************
function DayMatchMonth(month, day, year)
{
	var CurrDate = new Date();
	var MyDate = new Date(month + "/" + day + "/" +year);
	
	if(month == "04" || month == "06" || month == "09" || month == "11")
	{
		if(day > 30)
		{
			alert("Invalid Month/Day combination");
			if (document.all){document.Loss.month.focus();}  //add focus for IE TC 02/27/01	
			else {document.LossDiv.document.Loss.month.focus();} //add focus for Netscape
			return false;
		}
	}			
	else if(month == "02")
	{
		if (year%4 == 0)
		{
			if(day > 29)
			{
				alert("Invalid Month/Day combination");
				if (document.all){document.Loss.month.focus();}  //add focus for IE TC 02/27/01	
				else {document.LossDiv.document.Loss.month.focus();} //add focus for Netscape
				return false;
			}
		}
		else
		{
			if(day > 28)
			{
				alert("Invalid Month/Day combination");
				if (document.all){document.Loss.month.focus();}  //add focus for IE TC 02/27/01	
				else {document.LossDiv.document.Loss.month.focus();} //add focus for Netscape
				return false;
			}
		}
	}	
	{
	if (Date.parse(MyDate) > Date.parse(CurrDate))
		{
			alert("Please select a valid date that is before or the same as current Date");
			if (document.all){document.Loss.day.focus();}  //add focus for IE TC 02/27/01	
			else {document.LossDiv.document.Loss.day.focus();} //add focus for Netscape
			return false;
		}
			else 
				return true;
	}	
	return true;
}

//*********************************************************************************
//Submits the form if strValidated is equal to 4..
//
//*********************************************************************************
function CheckValidation()
{
//  if (document.Loss[1].value == "Wait..") {
//		alert("Please wait.. Request is still being processed");
//		return false;
//	}
  if (!document.all)
  { Netsubmit();
   }
  else
  {
    document.Loss.policyno.value=document.Loss.PolicyState.value + 
                                 "-" + 
                                 document.Loss.PolicyNumber.value;
  }

    if (ValidatePage(sVarPage))
    {
		
      if (strValidated == 4)
		document.Loss.submit();
		document.getElementById("lyrMsg").style.visibility ="visible"; //  Code by Alok ,added on 02/13 ,working fine
		document.getElementById("lyrBtn").style.visibility ="hidden";   

//		document.Loss[40].style.visibility='hidden'
//		document.Loss[41].style.visibility='hidden' //Code by Alok ,added on 02/06 ,working fine
		return false;
		
	 strValidated++;
      if (strValidated < "4")
        alert("You have not filled in all of the required fields. You may need to return to a previous page.");
        
        
    }
    

}


//*********************************************************************************
//In netscape Goes to every layer and puts the information into Loss form for submition.
//
//*********************************************************************************
function Netsubmit()
{


//Personal

  document.Loss.firstName.value 	= document.PersonalDiv.document.Personal.firstName.value;
  document.Loss.lastName.value  	= document.PersonalDiv.document.Personal.lastName.value;
  document.Loss.PolicyState.value    	= document.PersonalDiv.document.Personal.PolicyState.value;
  document.Loss.PolicyNumber.value    	= document.PersonalDiv.document.Personal.PolicyNumber.value;
  document.Loss.policyno.value 		= document.PersonalDiv.document.Personal.PolicyState.value + "-" + document.PersonalDiv.document.Personal.PolicyNumber.value;
  document.Loss.Contact_Role.value  	= document.PersonalDiv.document.Personal.Contact_Role.options[document.PersonalDiv.document.Personal.Contact_Role.selectedIndex].value;
  document.Loss.email.value 		= document.PersonalDiv.document.Personal.email.value;
  document.Loss.state.value 		= document.PersonalDiv.document.Personal.state.options[document.PersonalDiv.document.Personal.state.selectedIndex].value;
  document.Loss.city.value 		= document.PersonalDiv.document.Personal.city.value;
  document.Loss.street.value 		= document.PersonalDiv.document.Personal.street.value;
  document.Loss.zip.value 		= document.PersonalDiv.document.Personal.zip.value;
  document.Loss.zipext.value 		= document.PersonalDiv.document.Personal.zipext.value;  
    
  
  //Contact
  document.Loss.areacphone.value  	= document.ContactDiv.document.Contact.areacphone.value;
  document.Loss.prefcphone.value 	= document.ContactDiv.document.Contact.prefcphone.value;
  document.Loss.cphone.value  		= document.ContactDiv.document.Contact.cphone.value;
  document.Loss.extcphone.value 	= document.ContactDiv.document.Contact.extcphone.value;
  document.Loss.areaaphone.value 	= document.ContactDiv.document.Contact.areaaphone.value;
  document.Loss.prefaphone.value 	= document.ContactDiv.document.Contact.prefaphone.value;
  document.Loss.aphone.value 		= document.ContactDiv.document.Contact.aphone.value;
  document.Loss.extaphone.value 	= document.ContactDiv.document.Contact.extaphone.value;
  document.Loss.alt_phone_location.value = document.ContactDiv.document.Contact.alt_phone_location.options[document.ContactDiv.document.Contact.alt_phone_location.selectedIndex].value;
  document.Loss.ASAP.checked 		= document.ContactDiv.document.Contact.ASAP.checked;
  document.Loss.fromampm.value 		= document.ContactDiv.document.Contact.fromampm.options[document.ContactDiv.document.Contact.fromampm.selectedIndex].value;
  document.Loss.toampm.value 		= document.ContactDiv.document.Contact.toampm.options[document.ContactDiv.document.Contact.toampm.selectedIndex].value;
  document.Loss.bsttimefromhr.value     = document.ContactDiv.document.Contact.bsttimefromhr.options[document.ContactDiv.document.Contact.bsttimefromhr.selectedIndex].value;
  document.Loss.bsttimefrommn.value     = document.ContactDiv.document.Contact.bsttimefrommn.options[document.ContactDiv.document.Contact.bsttimefrommn.selectedIndex].value;
  document.Loss.bsttimetohr.value 	= document.ContactDiv.document.Contact.bsttimetohr.options[document.ContactDiv.document.Contact.bsttimetohr.selectedIndex].value;
  document.Loss.bsttimetomn.value 	= document.ContactDiv.document.Contact.bsttimetomn.options[document.ContactDiv.document.Contact.bsttimetomn.selectedIndex].value; 
  document.Loss.timezone.value 		= document.ContactDiv.document.Contact.timezone.options[document.ContactDiv.document.Contact.timezone.selectedIndex].value;
  document.Loss.dayfrom.value 		= document.ContactDiv.document.Contact.dayfrom.options[document.ContactDiv.document.Contact.dayfrom.selectedIndex].value;
  document.Loss.dayto.value 		= document.ContactDiv.document.Contact.dayto.options[document.ContactDiv.document.Contact.dayto.selectedIndex].value;
  document.Loss.hdPrefLang.value 	= document.ContactDiv.document.Contact.hdPrefLang.options[document.ContactDiv.document.Contact.hdPrefLang.selectedIndex].value;
  
 
  //LossInformation
  document.Loss.factsOfLoss.value 	= document.LossDiv.document.LossInfo.factsOfLoss.value; 
  document.Loss.timeOfLosshr.value 	= document.LossDiv.document.LossInfo.timeOfLosshr.options[document.LossDiv.document.LossInfo.timeOfLosshr.selectedIndex].value;
  document.Loss.timeOfLossmn.value	= document.LossDiv.document.LossInfo.timeOfLossmn.options[document.LossDiv.document.LossInfo.timeOfLossmn.selectedIndex].value;
  document.Loss.month.value 		= document.LossDiv.document.LossInfo.month.options[document.LossDiv.document.LossInfo.month.selectedIndex].value;
  document.Loss.day.value	 	= document.LossDiv.document.LossInfo.day.options[document.LossDiv.document.LossInfo.day.selectedIndex].value;
  document.Loss.year.value	 	= document.LossDiv.document.LossInfo.year.options[document.LossDiv.document.LossInfo.year.selectedIndex].value;
  document.Loss.ampm1.value 		= document.LossDiv.document.LossInfo.ampm1.options[document.LossDiv.document.LossInfo.ampm1.selectedIndex].value;
  document.Loss.IssueState.value  	= document.LossDiv.document.LossInfo.IssueState.options[document.LossDiv.document.LossInfo.IssueState.selectedIndex].value;
  document.Loss.timezone1.value 	= document.LossDiv.document.LossInfo.timezone1.options[document.LossDiv.document.LossInfo.timezone1.selectedIndex].value;


  
}


//*********************************************************************************
// validates the drop down boxes, used only by netscape
//
//*********************************************************************************
function ValidateDropDown(sLayer,sForm,sName,sErrMsg,sType)
{
	var sVar;
			
		sVar = document[sLayer].document[sForm][sName].options[document[sLayer].document[sForm][sName].selectedIndex].value;
		
		if(sVar == "")
		{
		alert(sErrMsg);
		return false;
	 	}
     return true;
}



//*********************************************************************************
//Test fucntion - used as a dummy function for ie/netscape compatability
//
//*********************************************************************************
function Test()
{
}


//*********************************************************************************
//Gettime fucntion - Sets the usrtime variable
//
//*********************************************************************************
function GetTime()
{
    var userdate = new Date();
    var currdate = userdate.getDate()
    var currmonth = parseInt(userdate.getMonth(), 10) + 1
    var curryear = userdate.getFullYear()
    var currhours = userdate.getHours()
    var currmins = parseInt(userdate.getMinutes(), 10)
    
    if(currmins < 10)
    {
      document.Loss.usrtime.value = (currmonth + '/' + currdate + '/' + curryear + ' ' +  currhours + ':0' + currmins)    
    }
    else
    {
      document.Loss.usrtime.value = (currmonth + '/' + currdate + '/' + curryear + ' ' + currhours + ':' + currmins)
    }
    
    if (document.all) {
	document.getElementById("lyrMsg").style.visibility ="hidden"   
	document.getElementById("lyrBtn").style.visibility ="visible"   
	}
    
}
//*********************************************************************************
//isWhitespace function - test for non blank (space ) characters
//
//*********************************************************************************

function isWhitespace (s)
{
     var whitespace = " \t\n\r";
     var i;
    // Is s empty?
     if (isEmpty(s))
 	   	return true;
 	   // Search through string's characters one by one
 	   // until we find a non-whitespace character.
 	   // When we do, return false; if we don't, return true.
 	   for (i = 0; i < s.length; i++){   
 	       // Check that current character isn't whitespace.
 	       var c = s.charAt(i);
 	       if (whitespace.indexOf(c) == -1)
 	       	return false;
 	   	}
 	   // All characters are whitespace.
	    return true;
	} 
//--------------------------------------
// Functions implemented for counting
// characters in the textarea,text_area.
// This implementation works only for
// IE 4.0+ and Netscape 4.0+.
// --------------------------------

function charCount(mode)
{
	var maxChar=1445;
	var txtString=document.Loss.factsOfLoss.value;

	var returnKey=countReturnKey(txtString);
	var strLength=txtString.length-returnKey;

	if (strLength>maxChar)
	{
		alert("Maximum message length reached. Your message has been truncated at maximum")
		document.Loss.factsOfLoss.value=txtString.substring(0,maxChar + returnKey);
	}
}
function countReturnKey(data)
{
	var i=0, returnKey=0, dataLength=data.length;
	while (i<dataLength-2)
		{
		if (data.charAt(i++)=="\r")
			{
			returnKey++;
			}
		}
	return (returnKey);
}

//*********************************************************************************
//This function resets the values in the form when the Navigation Back Button id pressed 
//
//*********************************************************************************
function ResetForm()
{

  if (document.all)
  {
	//Personal
  	document.Loss.firstName.value = "";
  	document.Loss.lastName.value = "";
  	document.Loss.PolicyState.value = "";
  	document.Loss.PolicyNumber.value = "";
	document.Loss.Contact_Role.value = "Insured";
  	document.Loss.street.value = "";
  	document.Loss.city.value = "";
  	document.Loss.state.value = "";
  	document.Loss.zip.value = "";
  	document.Loss.zipext.value = "";
  	document.Loss.email.value = "";
  
	//Contact
  	document.Loss.areacphone.value = "";
  	document.Loss.prefcphone.value = "";
  	document.Loss.cphone.value = "";
  	document.Loss.extcphone.value = "";
  	document.Loss.areaaphone.value = "";
  	document.Loss.prefaphone.value = "";
  	document.Loss.aphone.value = "";
  	document.Loss.extaphone.value = "";
  	document.Loss.ASAP.checked = "";
  	document.Loss.bsttimefromhr.value = "";
	document.Loss.bsttimefrommn.value = "";
  	document.Loss.fromampm.value = "";
  	document.Loss.bsttimetohr.value = "";
  	document.Loss.bsttimetomn.value = "";
  	document.Loss.toampm.value = "";
  	document.Loss.timezone.value = "";
	document.Loss.dayfrom.value = "";
	document.Loss.dayto.value = "";


	//LossInformation
  	document.Loss.month.value = "";
  	document.Loss.day.value = "";
  	document.Loss.year.value = "";
  	document.Loss.timezone1.value = "";
  	document.Loss.IssueState.value = "";
  	document.Loss.factsOfLoss.value = "";  
  }
  else
  {
	//Personal

  	document.PersonalDiv.document.Personal.firstName.value = "";
  	document.PersonalDiv.document.Personal.lastName.value = "";
	document.PersonalDiv.document.Personal.PolicyState.value = "";
 	document.PersonalDiv.document.Personal.PolicyNumber.value = "";
  	document.PersonalDiv.document.Personal.Contact_Role.value = "Insured";
  	document.PersonalDiv.document.Personal.email.value = "";
  	document.PersonalDiv.document.Personal.state.value = "";
  	document.PersonalDiv.document.Personal.city.value = "";
  	document.PersonalDiv.document.Personal.street.value = "";
  	document.PersonalDiv.document.Personal.zip.value = "";
  	document.PersonalDiv.document.Personal.zipext.value = "";  

  
  	//Contact
  	document.ContactDiv.document.Contact.areacphone.value = "";
  	document.ContactDiv.document.Contact.prefcphone.value = "";
  	document.ContactDiv.document.Contact.cphone.value = "";
  	document.ContactDiv.document.Contact.extcphone.value = "";
  	document.ContactDiv.document.Contact.areaaphone.value = "";
 	document.ContactDiv.document.Contact.prefaphone.value = "";
 	document.ContactDiv.document.Contact.aphone.value = "";
  	document.ContactDiv.document.Contact.extaphone.value = "";
  	document.ContactDiv.document.Contact.ASAP.checked = "";
  	document.ContactDiv.document.Contact.fromampm.options.value = "";
  	document.ContactDiv.document.Contact.toampm.options.value = "";
  	document.ContactDiv.document.Contact.bsttimefromhr.options.value = "";
  	document.ContactDiv.document.Contact.bsttimefrommn.options.value = "";
  	document.ContactDiv.document.Contact.bsttimetohr.options.value = "";
  	document.ContactDiv.document.Contact.bsttimetomn.options.value = ""; 
  	document.ContactDiv.document.Contact.timezone.options.value = "";
	document.ContactDiv.document.Contact.dayfrom.options.value = "";
	document.ContactDiv.document.Contact.dayto.options.value = "";
  	document.ContactDiv.document.Contact.hdPrefLang.options.value = "";
  
 
  	//LossInformation
  	document.LossDiv.document.LossInfo.factsOfLoss.value = ""; 
  	document.LossDiv.document.LossInfo.timeOfLosshr.options.value = "";
  	document.LossDiv.document.LossInfo.timeOfLossmn.options.value = "";
  	document.LossDiv.document.LossInfo.month.options.value = "";
  	document.LossDiv.document.LossInfo.day.options.value = "";
 	document.LossDiv.document.LossInfo.year.options.value = "";
  	document.LossDiv.document.LossInfo.ampm1.options.value = "";
  	document.LossDiv.document.LossInfo.IssueState.options.value = "";
  	document.LossDiv.document.LossInfo.timezone1.options.value = "";

  }

  
}


//*********************************************************************************
