// JavaScript Document


function GetService(id)
	{
		var id= id;		
		//var sid = document.getElementById("txtcustomerid").value;
       var xmlhttp1 = new cl_xmlHttpObject();
    	xmlhttp1.open("get","service.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);
	}
	
	
	function GetImage(id,imgid,fldno,descid)
	{
		var id = id;
		var imgid = imgid;	
		var fldno = fldno;	
		var desc = descid;
		//var sid = document.getElementById("txtcustomerid").value;
       var xmlhttp1 = new cl_xmlHttpObject();
    	xmlhttp1.open("Post","service.php?id="+id+"&imgid="+imgid+"&fldno="+fldno+"&desc="+desc,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);
	}
	
	
	
	
	
	
	
	
	
	function EditServiceInfo(id)
	{   			
       	var id= id;
		var xmlhttp1 = new cl_xmlHttpObject();				
		xmlhttp1.open("GET","edit_service.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);
    }







function UpdateServiceInfo(id)
	{   
		//var sid = document.getElementById("txtcustomerid").value;		
       var xmlhttp1 = new cl_xmlHttpObject();
	  
			
			if(id)
			{
				var id= id;
				var mode = "Edit";
				var category = document.getElementById("txtcategory").value;				
				var service = document.getElementById("txtservice").value;
				var description = document.getElementById("txtdescription").value;
				var pageurl = document.getElementById("txtpageurl").value;
				var status = document.getElementById("txtStatus").value;		
				xmlhttp1.open("POST","add_service_submit.php?id="+id+"&mode="+mode+"&category="+category+"&service="+service+"&description="+description+"&pageurl="+pageurl+"&status="+status,true);
	
			}
			else
			{
				var mode = "Add"
				var category = document.getElementById("txtcategory").value;
				var service = document.getElementById("txtservice").value;
				var description = document.getElementById("txtdescription").value;
				var pageurl = document.getElementById("txtpageurl").value;
				var status = document.getElementById("txtStatus").value;
				xmlhttp1.open("POST","add_service_submit.php?mode="+mode+"&category="+category+"&service="+service+"&description="+description+"&pageurl="+pageurl+"&status="+status,true);
	
			}
	
	
        xmlhttp1.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

        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)
								GetServiceInfo();
								//display_info(xmlhttp1.responseText);								
							}
							else
							{
							display_info("An Error Occured:"+ xmlhttp1.statusText);
							}
						}
						
    	};

    xmlhttp1.send(null);
    }
	
	
	
	
	
	
	
function AddServiceInfo()
	{   			
       	var xmlhttp1 = new cl_xmlHttpObject();				
		xmlhttp1.open("GET","edit_service.php",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);
}
	
	
	
	
	
	

	
	
	function CallServiceCancel()
	{  // alert(url);			
       	/*var URL; 
		if(url == user)
		{
			URL = 'user_list.php';	
		}	*/
		
		var xmlhttp1 = new cl_xmlHttpObject();				
		xmlhttp1.open("GET","service_list.php",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);
    }




function GetDetailServiceInfo(page,catid,servid)
	{
		var page= page;		
		var catid= catid;
		var servid= servid;		
		
		//var sid = document.getElementById("txtcustomerid").value;
       var xmlhttp1 = new cl_xmlHttpObject();
    	xmlhttp1.open("POST","detail_service_list.php?page="+page+"&catid="+catid+"&servid="+servid,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 EditDetailServiceInfo(detailservicevalueid,catid,serviceid)
	{   			
       	var detailservicevalueid= detailservicevalueid;
		var catid= catid;
		//alert(catid);
		var serviceid= serviceid;
		var xmlhttp1 = new cl_xmlHttpObject();				
		xmlhttp1.open("GET","edit_detail_service.php?detailservicevalueid="+detailservicevalueid+"&catid="+catid+"&serviceid="+serviceid,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);
    }
	
	
	function AddDetailServiceInfo(catid,servid)
	{   
		var catid = catid;
		var serviceid = servid;
		//alert(catid);
		//alert(servid);
       	var xmlhttp1 = new cl_xmlHttpObject();				
		xmlhttp1.open("GET","edit_detail_service.php?catid="+catid+"&serviceid="+serviceid,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);
}

 function ValidateDeleteDetailService()
	{
	    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'))
			{
				//document.frmlist.action="submit.php?mode=deletecrewcategory";
				//document.frmlist.submit();
				deletedetailservice();
			}
			else 
				return false;

		}
		else
		{
			alert("Please Select Service(s) to delete.");	
			return false;
		}
	}
 
 
 
 
 function deletedetailservice()
 {
			var a_arry=new Array(); 
			 var checkLen=document.getElementsByName('chk_id[]').length;
			//alert(checkLen);
			var y=0;
		   for(i=0;i<checkLen;i++)
			 {	//alert(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);
  //var url='display_company.php?DELETE='+DELETE+'&arrycount='+arrycount+'&a_arry='+a_arry;  
  			var xmlhttp1 = new cl_xmlHttpObject();				
			xmlhttp1.open("POST","delete_detail_service.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)
									GetDetailServiceInfo();
									//display_info(xmlhttp1.responseText);
								}
								else
								{
								display_info("An Error Occured:"+ xmlhttp1.statusText);
								}
							}
			};
    	   xmlhttp1.send(null);  

 }
 
 
 function CallDetailServiceCancel(catid,servid)
	{  // alert(url);			
       	/*var URL; 
		if(url == user)
		{
			URL = 'user_list.php';	
		}	*/
		var catid= catid;
		var servid= servid;
		var xmlhttp1 = new cl_xmlHttpObject();				
		xmlhttp1.open("GET","detail_service_list.php?catid="+catid+"&servid="+servid,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);
    }



function GetServiceFieldsInfo(service)	{
		
		var servid= service;		
		
		//var sid = document.getElementById("txtcustomerid").value;
       var xmlhttp1 = new cl_xmlHttpObject();
    	xmlhttp1.open("POST","add_servicefields.php?servid="+servid,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 UpdateServiceFieldsInfo(id)
	{   
		//var sid = document.getElementById("txtcustomerid").value;		
       var xmlhttp1 = new cl_xmlHttpObject();
	  
			
			if(id)
			{
				var id= id;
				var mode = "Edit";
				var category = document.getElementById("txtcategory").value;				
				var service = document.getElementById("txtservice").value;
				var description = document.getElementById("txtdescription").value;
				var pageurl = document.getElementById("txtpageurl").value;
				var status = document.getElementById("txtStatus").value;		
				xmlhttp1.open("POST","add_service_submit.php?id="+id+"&mode="+mode+"&category="+category+"&service="+service+"&description="+description+"&pageurl="+pageurl+"&status="+status,true);
	
			}
			else
			{
				var mode = "Add"
				var category = document.getElementById("txtcategory").value;
				var service = document.getElementById("txtservice").value;
				var description = document.getElementById("txtdescription").value;
				var pageurl = document.getElementById("txtpageurl").value;
				var status = document.getElementById("txtStatus").value;
				xmlhttp1.open("POST","add_service_submit.php?mode="+mode+"&category="+category+"&service="+service+"&description="+description+"&pageurl="+pageurl+"&status="+status,true);
	
			}
	
	
        xmlhttp1.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

        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)
								GetServiceInfo();
								//display_info(xmlhttp1.responseText);								
							}
							else
							{
							display_info("An Error Occured:"+ xmlhttp1.statusText);
							}
						}
						
    	};

    xmlhttp1.send(null);
    }
	