function changeto(highlightcolor){
source=event.srcElement
if (source.tagName=="TR"||source.tagName=="TABLE")
return
while(source.tagName!="TD")
source=source.parentElement
if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
source.style.backgroundColor=highlightcolor;
}

function changeback(originalcolor){
if (event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")
return
if (event.toElement!=source)
source.style.backgroundColor=originalcolor
}

function openWindow(param) {
  popupWin = window.open('../../servlet/page.ShowHelp?PARAM='+param, 'remote', 'width=300,height=500,scrollbars=yes,resizable=yes')
}

function writeMarquee(param) {
document.write("<marquee id=marquee onMouseover='marquee.stop();' onMouseout='marquee.start();'scrolldelay='30' scrollamount='1' behavior='scroll'><strong><small><small>"+param+"</small></small></strong></marquee>");
}

function showDisAppReason(refNo,refDt,status) {
  popupWin = window.open('../../servlet/WebTran.ShowDisAppReason?REFERENCENUMBER='+refNo+'&REFERENCEDATE='+refDt+'&PROPSTATUS='+status, 'remote', 'width=300,height=300,scrollbars=yes,resizable=yes')
}

function validation()
{
   var claimno=document.CustInt.CLAIMNUMBER.value;
   var polno=document.CustInt.POLICYNUMBER.value;
   var vouno=document.CustInt.VOUCHERNUMBER.value;
   var grivtext=document.CustInt.GRIEVANCEDESC.value;


   if(document.CustInt.DATE!=null)
   {
   var userdate=document.CustInt.DATE.value;
   }
   if(document.CustInt.TIME!=null)
   {
   var usertime=document.CustInt.TIME.value;
   }


   if(document.CustInt.DATE!=null && document.CustInt.TIME!=null)
   {
      if(userdate.length>0 || usertime.legth>0 )
      {


      }
      else
      {
       alert("Date and time field not be empty");
       return false;
      }


   }

    if(grivtext.length==0)
    {

     alert("please specify the grievance details.......");
     document.CustInt.GRIEVANCEDESC.focus();
     return false;

    }

    document.CustInt.product_notknown.value=document.CustInt.unkown_product_detail.value;
    if(document.CustInt.CategorySel.value=="" || document.CustInt.CategorySel.value=="0")
	{
		alert("Enter Category of Insurance")
		document.CustInt.CategorySel.focus()
		return false ;

	}







     if(polno.length!=20&&polno.length>=1)
    {
     alert("Is not a valid Policy No");
     document.CustInt.POLICYNUMBER.focus();
     return false;
    }

    if(claimno.length!=20&&claimno.length>=1)
    {
     alert("Is not a valid Claim No");
     document.CustInt.CLAIMNUMBER.focus();
     return false;
    }
    if(vouno.length!=20&&vouno.length>=1)
    {
     alert("Is not a valid Vouchar No");
     document.CustInt.VOUCHERNUMBER.focus();
     return false;
    }


   if(userdate!=null&&userdate.length>0)
   {



   if(!DateValid())
   {
   document.CustInt.DATE.focus();
   return false;
   }

  }

 if(document.CustInt.DATE!=null&&userdate.length>0)
 {
 if(!NotFutureDate())
 {
 document.CustInt.DATE.focus();
  return false;
 }

}

}

function DateValid()
{
var userdate=document.CustInt.DATE.value;
var len=userdate.length;
if(len !=10)
{
alert("is not a valid dd/mm/yyyy formate");
return false;
}
index1=userdate.indexOf("/");
day=userdate.substr(0,index1);
mmyyyy=userdate.substr(index1+1,len);
index2=mmyyyy.indexOf("/");
month=mmyyyy.substr(0,index2);
year=mmyyyy.substr(index2+1,len);

if(day.length!=2 || month.length!=2 || year.length!=4)
{

 alert("is not a valid dd/mm/yyyy formate");
 return false;

}
if(isNaN(day))
{
 alert("day sould be numeric value");
 return false;

}
if(isNaN(month))
{
 alert("month should numeric value");
 return false;

}

if(isNaN(year))
{
 alert("year should be numeric value");
 return false;

}



 if(day>31 || day<1)
 {
 alert("Day should be  between 1 to 31");
 return false;
 }

 if(month>12 || month<1)
 {
 alert("Month should be between 1 to 12 ");
 return false;
 }

 if(year>3000 || year<1900)
 {
 alert("year should be between 1900 to 3000");
 return false;
 }
 return true;
}

function TimeValid()
{
var usertime=document.CustInt.TIME.value;
index=usertime.indexOf(":");
len=usertime.length;
hour=usertime.substr(0,index);
minute=usertime.substr(index+1,len);

if(len !=5 || hour.length!=2 || minute.length!=2)
{
 alert("is not a valid hh:mm time format");
 return false;


}
if(isNaN(hour))
{
 alert("Hour should be numeric");
 return false;

}

if(isNaN(minute))
{
 alert("minute should be numeric");
 return false;
}
if(hour>24 || hour<0)
{
 alert("hour should be between 0 to 24");
 return false;


}
if(minute>59 || minute<0)
{
 alert("minute sould be between 0 to 59");
 return false;


}

return true;
}


function NotFutureDate()
{
document.forms[0].style.cursor="wait";
var userdate=document.CustInt.DATE.value;
var sending='../resources/jsp/FutureDateValidation.jsp?userdate='+userdate;
xmlhttp=new Object(null);
try
    {
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
        try
        {
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e1)
        {
            xmlhttp=new XMLHttpRequest();
        }
    }
    xmlhttp.open('GET',sending, true);
  //alert("before sending");
  xmlhttp.send('');

    xmlhttp.onreadystatechange = function(){
        if(xmlhttp.readyState==4)
        {
           //alert(xmlhttp.responseText);
          document.forms[0].style.cursor="default";
          myname=(xmlhttp.responseXML).getElementsByTagName("general");
          //alert(myname.item(0).childNodes.length);
          if(myname.item(0).childNodes.length==0)
          {
           //alert("ok");
           document.CustInt.submit();

          }
          else
          {
           alert("Future date is not allowed here");
           return false;

          }

        }





};

}


function UserAlertMsg()
{
document.forms[0].style.cursor="wait";
var griv_no=document.GRIEVTRANS.GRIEVANCEID.value;
var choice=document.GRIEVTRANS.CHOICE.value;
var status;
//var return_status=false;
//var dummy=document.GRIEVTRANS.DUMMY.value;
//alert('GRIVNUMBER:'+griv_no);
//alert('GRIVNUMBER:'+choice);
for(j=0;j<document.GRIEVTRANS.CHANGESTATUS.length;j++)
{
 if(document.GRIEVTRANS.CHANGESTATUS[j].checked==true)
 {
  status=document.GRIEVTRANS.CHANGESTATUS[j].value;
  //alert(status);
  break;
 }
}
if(status=="C")
{
document.GRIEVTRANS.submit();
}


var sending='../resources/jsp/GrivUserAlertMsg.jsp?griv_no='+griv_no+'&choice='+choice;
//alert(sending);
xmlhttp1=new Object(null);


    try
    {
        xmlhttp1=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
        try
        {
            xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e1)
        {
            xmlhttp1=new XMLHttpRequest();
        }
    }
    xmlhttp1.open('GET',sending, true);
 // alert("before sending");
  xmlhttp1.send('');

    xmlhttp1.onreadystatechange = function(){
        if(xmlhttp1.readyState==4)
        {
          // alert(xmlhttp1.responseText);
          document.forms[0].style.cursor="default";
          myname=(xmlhttp1.responseXML).getElementsByTagName("general");
          //alert(myname.item(0).childNodes.length);
          if(myname.item(0).childNodes.length==0)
          {

           document.GRIEVTRANS.submit();

          }

          for(i=0;i<myname.item(0).childNodes.length;i++)
          {
           if(myname.item(0).childNodes.item(i).nodeName=="usermsg")
           {
            if(status=="R")
            {
            alert("Before 7 days you can't post a reminder");
            }
            for(j=0;j<document.GRIEVTRANS.CHANGESTATUS.length;j++)
            {
                if(document.GRIEVTRANS.CHANGESTATUS[j].checked==true)
               {
                  document.GRIEVTRANS.CHANGESTATUS[j].checked=false;
                  if(j==1)
                  {
                   document.GRIEVTRANS.CHANGESTATUS[j-1].checked=true;

                  }
                  else
                  {
                  document.GRIEVTRANS.CHANGESTATUS[j+1].checked=true;

                  }
                 //alert(status);
                  break;
                }
            }

           }
        }

      }


    };










}

function Office_pertain_Combo()
{
 var policyNo=document.CustInt.POLICYNUMBER.value;
 var temp;
  var len;
   if(policyNo.length==0)
  {
    len=document.CustInt.OFFICEPERTAIN.length;
    for(i=len;i>=0;i--)
    {
        //alert(document.CustInt.ProductSel.options[i]);
        document.CustInt.OFFICEPERTAIN.remove(i);
    }
     var option=document.createElement("OPTION");
        option.text="NIAHO" ;
        option.value=0;
        document.CustInt.OFFICEPERTAIN.add(option);

    len=document.CustInt.TARGETOFFICE.length;
   for(i=len;i>=1;i--)
    {
        //alert(document.CustInt.ProductSel.options[i]);
        document.CustInt.TARGETOFFICE.remove(i);
    }

        return false;



  }
 else if(policyNo.length!=20&&policyNo.length>=1||policyNo.length>=1&&isNaN(policyNo))
    {
     alert("Is not a valid Policy No");
     len=document.CustInt.OFFICEPERTAIN.length;
     for(i=len;i>=0;i--)
    {
        //alert(document.CustInt.ProductSel.options[i]);
        document.CustInt.OFFICEPERTAIN.remove(i);
    }
     var option=document.createElement("OPTION");
        option.text="NIAHO" ;
        option.value=0;
        document.CustInt.OFFICEPERTAIN.add(option);
     document.CustInt.POLICYNUMBER.focus();
     return false;
    }
 else
 {
   temp=policyNo.substr(0,8);
    office_exist(temp)





 }




}




function office_exist(temp)
{
 var office_code=temp.substr(0,6);
  var dep_code=temp.substr(6,8);
  temp=office_code;
 var officename;
 var roname;
 document.forms[0].style.cursor="wait";
 var sending='../resources/jsp/OfficeCodeValidate.jsp?office_code='+office_code+'&dep_code='+dep_code;
xmlhttp1=new Object(null);
    try
    {
        xmlhttp1=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
        try
        {
            xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e1)
        {
            xmlhttp1=new XMLHttpRequest();
        }
    }
    xmlhttp1.onreadystatechange = function(){

           if(xmlhttp1.readyState==4)
        {

            document.forms[0].style.cursor="default";
            myname=(xmlhttp1.responseXML).getElementsByTagName("general");
             for(i=0;i<myname.item(0).childNodes.length;i++)
       {
              if(myname.item(0).childNodes.item(i).nodeName=="officename")
              {

               officename=myname.item(0).childNodes.item(i).firstChild.nodeValue;

              }


               if(myname.item(0).childNodes.item(i).nodeName=="roname")
               {

                roname=myname.item(0).childNodes.item(i).firstChild.nodeValue;

               }



                if(myname.item(0).childNodes.item(i).nodeName=="officeexist")
           {
            if(myname.item(0).childNodes.item(i).firstChild.nodeValue=="NO" || myname.item(0).childNodes.item(i).attributes.getNamedItem("dep_code_exist").nodeValue=="NO")
            {
             alert("Is not a valid policy number");
             document.CustInt.POLICYNUMBER.focus();
            break;
            }
            else
            {
            var len=document.CustInt.OFFICEPERTAIN.length;
               for(i=len;i>=0;i--)
                {
                    //alert(document.CustInt.ProductSel.options[i]);
                    document.CustInt.OFFICEPERTAIN.remove(i);
                }

               var option=document.createElement("OPTION");
                    option.text=temp;
                    option.value=temp;
                    document.CustInt.OFFICEPERTAIN.add(option);

                option=document.createElement("OPTION");
                    option.text="NIAHO";
                    option.value=0;
                    document.CustInt.OFFICEPERTAIN.add(option);

                len=document.CustInt.TARGETOFFICE.length;
                for(j=len;j>=0;j--)
                {
                    //alert(document.CustInt.ProductSel.options[i]);
                    document.CustInt.TARGETOFFICE.remove(j);
                }

                var option=document.createElement("OPTION");
                    option.text="NIAHO";
                    option.value=0;
                    document.CustInt.TARGETOFFICE.add(option);



                  var option=document.createElement("OPTION");
                    option.text=roname+"-"+temp.substr(0,2)+"0000";
                    option.value=temp.substr(0,2)+"0000";
                    document.CustInt.TARGETOFFICE.add(option)


                var option=document.createElement("OPTION");
                    option.text=officename+"-"+temp;
                    option.value=temp;
                    document.CustInt.TARGETOFFICE.add(option)
                    break;

            }


      }

   }
 }
};

    xmlhttp1.open('GET',sending, true);
    xmlhttp1.send('');



}


function HeadOffice_RegOffice_Combo()
{
    var policyNo=document.CustInt.POLICYNUMBER.value;
    if(policyNo.length>0)
    {
    document.forms[0].style.cursor="wait";
    var a=document.getElementById('TARGETRO');

    var id;
    var name;
    name=a.options[a.selectedIndex].innerText;
    for(i=0;i<document.CustInt.TARGETRO.length;i++)
    {
        if(document.CustInt.TARGETRO.selectedIndex==i)
        {
            id=document.CustInt.TARGETRO.value;
            //alert(id);

            break;
        }
    }
    var sending='../resources/jsp/HeadOffice_RegOffice_combo.jsp?paramvalue='+id+'&paramtext='+name;
   // alert(sending);

    xmlhttp1=new Object(null);
    try
    {
        xmlhttp1=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
        try
        {
            xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e1)
        {
            xmlhttp1=new XMLHttpRequest();
        }
    }
    xmlhttp1.onreadystatechange = function(){
        if(xmlhttp1.readyState==4)
        {

            document.forms[0].style.cursor="default";


            var len=document.CustInt.TARGETOFFICE.length;
            //alert(xmlhttp1.responseText);
            for(i=len;i>=1;i--)
            {

                document.CustInt.TARGETOFFICE.remove(i);
            }


            myname=(xmlhttp1.responseXML).getElementsByTagName("general");

            for(i=0;i<myname.item(0).childNodes.length;i++)
            {
                if(myname.item(0).childNodes.item(i).nodeName=="companyName")
                {
                    var option=document.createElement("OPTION");
                    option.text=myname.item(0).childNodes.item(i).firstChild.nodeValue;
                    option.value=id;
                    document.CustInt.TARGETOFFICE.add(option);

                }
                if(myname.item(0).childNodes.item(i).nodeName=="DoName")
                {
                    var option=document.createElement("OPTION");
                    option.text=myname.item(0).childNodes.item(i).firstChild.nodeValue;
                    option.value=myname.item(0).childNodes.item(i).attributes.getNamedItem("key").nodeValue;
                    document.CustInt.TARGETOFFICE.add(option);
                }

                if(myname.item(0).childNodes.item(i).nodeName=="OoName")
                {
                    var option=document.createElement("OPTION");
                    option.text=myname.item(0).childNodes.item(i).firstChild.nodeValue;
                    option.value=myname.item(0).childNodes.item(i).attributes.getNamedItem("key").nodeValue;
                    document.CustInt.TARGETOFFICE.add(option);
                }
             if(myname.item(0).childNodes.item(i).nodeName=="rostatus")
                {

                  var option=document.createElement("OPTION");
                    option.text=name;
                    option.value=id;
                    document.CustInt.TARGETOFFICE.add(option);


                }


            }



        }

    };
    //alert('----------');
    xmlhttp1.open('GET',sending, true);
    xmlhttp1.send('');
    //alert(name);
    document.CustInt.ro_selected.value=name;
    //alert(document.CustInt.ro_selected.value);
   }
   else
   {
   var len=document.CustInt.TARGETOFFICE.length;
   for(i=len;i>=1;i--)
    {
        //alert(document.CustInt.ProductSel.options[i]);
        document.CustInt.TARGETOFFICE.remove(i);
    }




   }
}

function func_cause_griv()
{

  for(i=0;i<document.GRIEVREDRESS.DEP_OF_GRIV.length;i++)
 {
   if(document.GRIEVREDRESS.DEP_OF_GRIV.selectedIndex==i)
   {
     if(document.GRIEVREDRESS.DEP_OF_GRIV[i].value=="0")
      {

      alert("Please selected the Department of Grievance");
      document.GRIEVREDRESS.DEP_OF_GRIV.focus();
      return false;


      }


   }



 }





 for(i=0;i<document.GRIEVREDRESS.CAUSE_OF_GRIV.length;i++)
 {
   if(document.GRIEVREDRESS.CAUSE_OF_GRIV.selectedIndex==i)
   {
     if(document.GRIEVREDRESS.CAUSE_OF_GRIV[i].value=="0")
      {

      alert("Please selected the Cause of Grievance");
      document.GRIEVREDRESS.CAUSE_OF_GRIV.focus();
      return false;


      }


   }





}


}


