/********************************** Validation *******************************************************/
function machine_validation()
{
	
    var mach_type = document.getElementById("mach_type").value;
	if(mach_type=='')
	{
		document.getElementById("mach_type_validation_div").innerHTML="* This field is Required.";
		document.getElementById("mach_type").focus();
		return false;
	}
	
	 var machine_no = document.getElementById("machine_no").value;
	if(machine_no=='')
	{
		//alert();
		document.getElementById("machine_no_div").innerHTML="* This field is Required.";
		document.getElementById("machine_no").focus();
		return false;
	}
	
	
	
}

function machine_clear_validation(str)
{
	if(str!='')
	{
		document.getElementById("mach_type_validation_div").innerHTML="";
	}
	
	if(str!='')
	{
		document.getElementById("machine_no_div").innerHTML="";
	}
	
	
	
	
}

/********************************** Mainlist Add *******************************************************/
function machine_entry_add(mach_type,machine_no,description,system_no,edit_id,action)
{
if((mach_type!='')&&(machine_no!=''))
 {
  jQuery.ajax({
		type: "POST",
		url: "machine_entry_db.php",
		data: "mach_type="+mach_type+"&machine_no="+machine_no+"&description="+description+"&system_no="+system_no+"&edit_id="+edit_id+"&action="+action,
		success: function(msg){jQuery("#machine_list_div").html(msg);	
		alert(msg);
		window.close();
		window.opener.location.reload(true);
 }
		});
 }
else
{
    machine_validation();
}
}

/********************************** Mainlist Delete *******************************************************/
function machine_delete(id)
{
	
	if(confirm('Are You Sure! You Want To Delete?'))
	{
		jQuery.ajax({
		type: "POST",
		url: "machine_type/machine_entry_db.php",
		data: "id="+id+"&action=delete",
		success: function(msg){jQuery("#machine_list_div").html(msg);
		
				window.opener.location.reload(true);

	}
	});
    }
}


