function ValidateCheckbox(lst,message)
{

        var lstarray1 = lst.split(",");
        var flag = 0;
        for(i=0;i<lstarray1.length; i++ )
        {
                //if(document.getElementById(lstarray1[i]).value == "" )
                if(document.getElementById(lstarray1[i]).checked)
                {
                        //alert ("select atleast one Event.");
                        return (true);
                }
        }
        if (i >= lstarray1.length)
        {
            alert (message);
                return (false);
        }
}


 function checkAll(value)
   {
        var userchk = document.getElementsByName(value);
        for(i=0;i<userchk.length;i++)
            {
                userchk[i].checked=document.getElementById('all').checked;
            }
  }

   function checkType(type,message)
   {
        var obj1 = document.getElementsByName(type);
        val ='';
                for (var i = 0; i < obj1.length; i++)
                {
                        if (obj1[i].checked)
                        {
                                val = obj1[i].value;
                        }
                }

        if(val!='0')
        {
                return char_count(message);
        }
}



function populate_adjusters() 
{ 
	var peventobj = document.getElementById('event');    
        var ptierobj = document.getElementById('tier');
        var adjobj = document.getElementById('adjust');
	 
	
	var peventIndex1 = peventobj.selectedIndex;
	var ptierIndex1 = ptierobj.selectedIndex;
	  	
	var sel_event=peventobj.options[peventIndex1].value;
	var sel_tier=ptierobj.options[ptierIndex1].value;
	 
 
        if ((sel_tier=='0') || (sel_tier=='4')) 
		sel_tier='';
	xmlhttp.open('GET', 'ajfns.php?sel_event='+ sel_event+'&sel_tier='+sel_tier,true); 
       	xmlhttp.onreadystatechange = function() 
  	{ 
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
		{
           		
			del= ',';
			valarr = xmlhttp.responseText.split(del);
			var valarrlen = valarr.length - 1;
			adjobj.options.length = 0;
			adjobj.options[0] = new Option('- Select Adjuster -', '');
		   
			for (var i=0; i <= valarrlen; i++ ) 
			{
				del2=':';
				var event_arr=trim(valarr[i]).split(del2);
           			adjobj.options[i+1] = new Option(trim(event_arr[1]), trim(event_arr[0]));
           		}
		} 
      	} 
     	xmlhttp.send(null); 
}

function checkSelUser(toadj,tosup,toadm)
{
        if((document.getElementById(toadj).selectedIndex==0))
        {
           if((document.getElementById(tosup).selectedIndex==0))
                 {
                        if((document.getElementById(toadm).selectedIndex==0))
                        {
                                //alert('Please choose whom to send alert to from Adjuster/Supervisor/Administrator');
                                alert('Please choose one or more recipients for your message.');
                                return (false);
                        }
                }
        }
        return (true);
}

function uncheck(claction,val)
{
        var obj1 = document.getElementsByName(claction);
         for (var i = 0; i < obj1.length; i++)
         {
                 if (obj1[i].value==val)
                         obj1[i].checked='';
         }

}
		
//2 messages in following fn are changed by Manish as per Dawn 04/11/06
function checkstat(action)
{
        if(action=='3')
        {

                //if(!(confirm('You selected to Submit this claim to supervisor.\n Are you sure you want to change status of the claim?')))
                if(!(confirm('Selecting the Submit/Process button will close the selected claim for payment by the insurance company.\nAre you sure this claim is complete?')))
                         uncheck('claction','3');
        }
        if(action=='4')
        {
                if(!(confirm('You selected to Return this claim to an adjuster.\n Are you sure you want to change status of the claim?')))
                         uncheck('claction','4');
        }

        if(action=='5')
        {
                if(!(confirm('You selected to Reject this claim.\n Are you sure you want to change status of the claim?')))
                         uncheck('claction','5');
        }

        if(action=='6')
        {
                //if(!(confirm('You selected to Close this claim.Payment process will start for this claim.\n Are you sure you want to change status of the claim?')))
                if(!(confirm('Selecting the Close button will FTP the completed claim to insurance company for payment.\nAre you sure all the records are complete?')))
                         uncheck('claction','6');
        }

        if(action=='7')
        {
                if(!(confirm('You selected to Close & Complete the claim to an adjuster.\n Are you sure you want to change status of the claim?')))
                         uncheck('claction','7');
        }

}

function ShowHide(id)
{
        if(document.getElementById(id).style.display == '')
        {
                document.getElementById(id).style.display ='none';
                return;
        }
        if(document.getElementById(id).style.display == 'none')
        {
                document.getElementById(id).style.display ='';
                return;
        }
}

// checking whether claim number exists under closed claims or not
// used on payroll processing screen

function CheckClaim(clid,insid)
{

        var cl = document.getElementById(clid).value;

        xmlhttp.open('GET', 'chkclaim.php?clno='+cl+'&insp='+insid,true);
        xmlhttp.onreadystatechange = function()
        {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                {
			if(xmlhttp.responseText!=1)
			{
				//cl ='';
				alert("This claim does not exist under closed claims.");
				document.getElementById(clid).value = '';	
			}
			else	
				return;
                }
        }
        xmlhttp.send(null);
}

// check duplicate claims

function CheckDuplicateClaim(clid,inspro)
{
        var cl = document.getElementById(clid).value;
	var insproobj = document.getElementById(inspro); 
	var insproIndex1 = insproobj.selectedIndex;
	var insid=insproobj.options[insproIndex1].value;

	var flag = true;

        xmlhttp.open('GET', 'chkduplicateclaim.php?clno='+cl+'&insp='+insid,true);
        xmlhttp.onreadystatechange = function()
        {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                {
			alert(xmlhttp.responseText);
                        if(xmlhttp.responseText==1)
                        {
                                //cl ='';
                                alert("This claim already exists.");
                                document.getElementById(clid).value = '';
				flag = false;
                        }
                }
        }
        xmlhttp.send(null);
	return (flag);
}


