// JavaScript Document

 function ValidateDeleteProject()
	{
	    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();
				deleteproject();
			}
			else 
				return false;

		}
		else
		{
			alert("Please Select Project(s) to delete.");	
			return false;
		}
	}





 
function deleteproject()
 {
			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;											
								   a_arry[y]=arry;
									   y++;
				  }
				
			 }
			 var arrycount=a_arry.length;
  //var url='display_company.php?DELETE='+DELETE+'&arrycount='+arrycount+'&a_arry='+a_arry;  
  			var xmlhttp1 = new cl_xmlHttpObject();				
			xmlhttp1.open("POST","delete_project.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)
									 GetAdminContent(2);
									//display_info(xmlhttp1.responseText);
								}
								else
								{
								display_info("An Error Occured:"+ xmlhttp1.statusText);
								}
							}
			};
    	   xmlhttp1.send(null);  

 }





function GetProjectInfo(page)
	{
		var page= page;
		//var sid = document.getElementById("txtcustomerid").value;
       var xmlhttp1 = new cl_xmlHttpObject();
    	xmlhttp1.open("get","project_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)
							{
								 clear_message();
								display_info(xmlhttp1.responseText);
							}
							else
							{
							display_info("An Error Occured:"+ xmlhttp1.statusText);
							}
						}
    	};
    xmlhttp1.send(null);
	}
	



	/*function GetProjects(page)
	{
		var page= page;
		//var sid = document.getElementById("txtcustomerid").value;
       var xmlhttp1 = new cl_xmlHttpObject();
    	xmlhttp1.open("get","projects.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 EditProjectInfo(id)
	{   			
       	var id= id;
		//alert(id);
		var xmlhttp1 = new cl_xmlHttpObject();				
		xmlhttp1.open("GET","edit_project.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 UpdateProjectInfo(id)
	{   
		var id = id;		
		//var sid = document.getElementById("txtcustomerid").value;		
       var xmlhttp1 = new cl_xmlHttpObject();
	  		if(id)
			{
				var id= id;				
				var mode = "Edit";
				var customer = document.getElementById("txtcustomer").value;
				var title = document.getElementById("txttitle").value;
				var description = document.getElementById("txtdescription").value;
				var status = document.getElementById("txtstatus").value;
				var price = document.getElementById("txtprice").value;
				var milestone = document.getElementById("txtmilestone").value;
				var budgetcost = document.getElementById("txtbudgetcost").value;
				var realcost = document.getElementById("txtrealcost").value;
				var feedback = document.getElementById("txtfeedback").value;
				var startdate = document.getElementById("txtstartdate").value;
				var finisheddate = document.getElementById("txtfinisheddate").value;
				var manager = document.getElementById("txtmanager").value;						
				//var oform = document.forms[0];
    			//var message = Request_params(oform);
				xmlhttp1.open("POST","add_project_submit.php?id="+id+"&mode="+mode+"&customer="+customer+"&title="+title+"&description="+description+"&status="+status+"&price="+price+"&milestone="+milestone+"&budgetcost="+budgetcost+"&realcost="+realcost+"&feedback="+feedback+"&startdate="+startdate+"&finisheddate="+finisheddate+"&manager="+manager,true);
				//xmlhttp1.open("POST","add_video_submit.php?id="+id+"&mode="+mode+"&category="+category+"&title="+title+"&description="+description+"&statusedition="+statusedition+"&statusprocess="+statusprocess+"&statuscharged="+statuscharged+"&addresslink="+addresslink+"&assignedprice="+assignedprice+"&alerts="+alerts+"&video_date_captured="+video_date_captured+"&video_date_edited="+video_date_edited+"&video_date_filed="+video_date_filed,true);
			
			}
			else
			{
				var mode = "Add"
				var customer = document.getElementById("txtcustomer").value;
				var title = document.getElementById("txttitle").value;
				var description = document.getElementById("txtdescription").value;
				var status = document.getElementById("txtstatus").value;
				var price = document.getElementById("txtprice").value;
				var milestone = document.getElementById("txtmilestone").value;
				var budgetcost = document.getElementById("txtbudgetcost").value;
				var realcost = document.getElementById("txtrealcost").value;
				var feedback = document.getElementById("txtfeedback").value;
				var startdate = document.getElementById("txtstartdate").value;
				var finisheddate = document.getElementById("txtfinisheddate").value;
				var manager = document.getElementById("txtmanager").value;			
				//var oform = document.forms[0];
    			//var message = Request_params(oform);
				xmlhttp1.open("POST","add_project_submit.php?mode="+mode+"&customer="+customer+"&title="+title+"&description="+description+"&status="+status+"&price="+price+"&milestone="+milestone+"&budgetcost="+budgetcost+"&realcost="+realcost+"&feedback="+feedback+"&startdate="+startdate+"&finisheddate="+finisheddate+"&manager="+manager,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)
								GetProjectInfo();
								//display_info(xmlhttp1.responseText);								
							}
							else
							{
							display_info("An Error Occured:"+ xmlhttp1.statusText);
							}
						}
						
    	};

    xmlhttp1.send(null);
    }
	
	
	
	function AddProjectInfo()
	{   			
       	var xmlhttp1 = new cl_xmlHttpObject();				
		xmlhttp1.open("GET","edit_project.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 CallProjectCancel()
	{  // alert(url);			
       	/*var URL; 
		if(url == user)
		{
			URL = 'user_list.php';	
		}	*/
		
		var xmlhttp1 = new cl_xmlHttpObject();				
		xmlhttp1.open("GET","project_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();
								GetProjectInfo();
								//display_info(xmlhttp1.responseText);
							}
							else
							{
							display_info("An Error Occured:"+ xmlhttp1.statusText);
							}
						}
    	};

    xmlhttp1.send(null);
    }

function ProjectdocInfo(id)
	{   			
	 var prg_ID=id;
	 
       	var xmlhttp1 = new cl_xmlHttpObject();				
		xmlhttp1.open("GET","project_doc.php?Prg_Id="+prg_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 GetOrderMilestoneInfo(page,id)
	{
		var pages= page;
		var Prg_Id=id;
		//var sid = document.getElementById("txtcustomerid").value;
       var xmlhttp1 = new cl_xmlHttpObject();
    	xmlhttp1.open("get","project_doc.php?pages="+pages+"&Prg_Id="+Prg_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);
	}	
