// JavaScript Document

 function ValidateDeleteApply()
	{   clear_message();
	    var ch=0;
	    len = document.frmlist.elements.length;
		var i=0;
		for( i=0 ; i<len ; i++) 
		{
		
			if (document.frmlist.elements[i].name=='chk_id[]') 
				{
	
					if (document.frmlist.elements[i].checked==1)
						{
					
							ch = 1;
						}
				}
		}	
	
		if (ch == 1)
		{
			if(confirm('Confirm Delete'))
			{
				deleteapply();
			}
			else 
				return false;

		}
		else
		{
			alert("Please Select Apply to delete.");	
			return false;
		}
	}





 
function deleteapply()
 {
	 
			var a_arry=new Array(); 
			 var checkLen=document.getElementsByName('chk_id[]').length;
			//alert(checkLen);
			var y=0;
		   for(i=0;i<checkLen;i++)
			 {	 
				if(document.all.frmlist.elements[i].checked==true) 
				 { 	    
								   var arry=document.all.frmlist.elements[i].value;
								   //alert(arry);
								   var x=arry.length;
								   //alert(x);
								   a_arry[y]=arry;
									   y++;
				  }
				
			 }
			 var arrycount=a_arry.length;
			 //alert(arrycount);
			// alert(a_arry);
  //var url='display_company.php?DELETE='+DELETE+'&arrycount='+arrycount+'&a_arry='+a_arry;  
  			var xmlhttp1 = new cl_xmlHttpObject();				
			xmlhttp1.open("POST","delete_apply.php?arrycount="+arrycount+"&a_arry="+a_arry,true);
				xmlhttp1.onreadystatechange = function()
			{
				 if (xmlhttp1.readyState <4) {
	 
						 document.getElementById('home_id').innerHTML = "<img src='images/working.gif'>Loading......";
						  //display_info(xmlhttp1.responseText);
	  
					  }
					  else if(xmlhttp1.readyState ==4)
							{
								if(xmlhttp1.status==200)
								{
									get_message(xmlhttp1.responseText)
									applyInfo();
									
								}
								else
								{
								display_info("An Error Occured:"+ xmlhttp1.statusText);
								}
							}
			};
    	   xmlhttp1.send(null);  

 }


function ApplyInfo1(page)
	{
		 clear_message();
		var page= page;
		//var sid = document.getElementById("txtcustomerid").value;
       var xmlhttp1 = new cl_xmlHttpObject();
    	xmlhttp1.open("get","apply_list.php?page="+page,true);
        xmlhttp1.onreadystatechange = function()
    	{
    		
			 if (xmlhttp1.readyState <4) {
 
                      document.getElementById('home_id').innerHTML = "<img src='images/working.gif'>Loading......";
					  //display_info(xmlhttp1.responseText);
  
                  }
				  else if(xmlhttp1.readyState ==4)
						{
							if(xmlhttp1.status==200)
							{
								display_info(xmlhttp1.responseText);
							}
							else
							{
							display_info("An Error Occured:"+ xmlhttp1.statusText);
							}
						}
    	};
    xmlhttp1.send(null);
	}
	


function ApplyInfo(page)
	{
		var page= page;
		//var sid = document.getElementById("txtcustomerid").value;
       var xmlhttp1 = new cl_xmlHttpObject();
    	xmlhttp1.open("get","apply_list.php?page="+page,true);
        xmlhttp1.onreadystatechange = function()
    	{
    		
			 if (xmlhttp1.readyState <4) {
 
                      document.getElementById('home_id').innerHTML = "<img src='images/working.gif'>Loading......";
					  //display_info(xmlhttp1.responseText);
  
                  }
				  else if(xmlhttp1.readyState ==4)
						{
							if(xmlhttp1.status==200)
							{
								display_info(xmlhttp1.responseText);
							}
							else
							{
							display_info("An Error Occured:"+ xmlhttp1.statusText);
							}
						}
    	};
    xmlhttp1.send(null);
	}
	
		
	
	
function EditCategoryInfo(id)
	{   			
       	var id= id;
		//var mode = 'Edit';
		//alert(id);
		var xmlhttp1 = new cl_xmlHttpObject();				
		xmlhttp1.open("GET","edit_category.php?id="+id,true);
        xmlhttp1.onreadystatechange = function()
    	{
    		 if (xmlhttp1.readyState <4) {
 
                     document.getElementById('home_id').innerHTML = "<img src='images/working.gif'>Loading......";
					  //display_info(xmlhttp1.responseText);
  
                  }
				  else if(xmlhttp1.readyState ==4)
						{
							if(xmlhttp1.status==200)
							{
								clear_message();
								display_info(xmlhttp1.responseText);
							}
							else
							{
							display_info("An Error Occured:"+ xmlhttp1.statusText);
							}
						}
    	};

    xmlhttp1.send(null);
	}
	
	
	

///////////////Apply for project ///////////////

	function apply(id)
	{   
		
       var xmlhttp1 = new cl_xmlHttpObject();
	  	
		var id= id;
							
				xmlhttp1.open("POST","add_apply_submit.php?id="+id,true);
				
			
			
       xmlhttp1.setRequestHeader('Content-Type','multipart/form-data;');

        xmlhttp1.onreadystatechange = function()
    	{
    		
			
			if (xmlhttp1.readyState <4) {
 
                      document.getElementById('home_id').innerHTML = "<img src='images/working.gif'>Loading......";
					  //display_info(xmlhttp1.responseText);
  
                  }
				  else if(xmlhttp1.readyState ==4)
						{
							if(xmlhttp1.status==200)
							{
								get_message(xmlhttp1.responseText)
								//clear_message();
								GetProviderWorksheetInfo();
								//display_info(xmlhttp1.responseText);								
							}
							else
							{
							display_info("An Error Occured:"+ xmlhttp1.statusText);
							}
						}
						
    	};

    xmlhttp1.send(null);
    }