/********************************** Validation *******************************************************/
function vehicle_validation()
{
    var vehicle_type = document.getElementById("vehicle_type").value;
	if(vehicle_type=='')
	{
		document.getElementById("vehicle_type_validation_div").innerHTML="* This field is Required.";
		document.getElementById("vehicle_type").focus();
		return false;
	}
	
	var vehicle_no = document.getElementById("vehicle_no").value;
	if(vehicle_no=='')
	{
		document.getElementById("vehicle_no_validation_div").innerHTML="* This field is Required.";
		document.getElementById("vehicle_no").focus();
		return false;
	}
	
	var radio_val = document.getElementById("radio_val").value;
	if(radio_val=='')
	{
		document.getElementById("own_validation_div").innerHTML="* This field is Required.";
		document.getElementById("radio_val").focus();
		return false;
	}
	
	
}

function vehicle_clear_validation(str)
{
	if(str!='')
	{
		document.getElementById("vehicle_type_validation_div").innerHTML="";
	}
	
	if(str!='')
	{
		document.getElementById("vehicle_no_validation_div").innerHTML="";
	}
	
	if(str!='')
	{
		document.getElementById("own_validation_div").innerHTML="";
	}
}

/********************************** Mainlist Add *******************************************************/
function vehicle_entry_add(vehicle_type,vehicle_no,own,address,edit_id,action)
{
if((vehicle_type!='')&&(vehicle_no!='')&&(own!=''))
 {
  jQuery.ajax({
		type: "POST",
		url: "vehicle_entry_db.php",
		data: "vehicle_type="+vehicle_type+"&vehicle_no="+vehicle_no+"&own="+own+"&address="+address+"&edit_id="+edit_id+"&action="+action,
		success: function(msg){jQuery("#vehicle_list_div").html(msg);	
		alert(msg);
		window.close();
		window.opener.location.reload(true);
 }
		});
 }
else
{
    vehicle_validation();
}
}

/********************************** Mainlist Delete *******************************************************/
function vehicle_delete_row(id)
{
	if(confirm('Are You Sure! You Want To Delete?'))
	{
		jQuery.ajax({
		type: "POST",
		url: "master_entry/vehicle_type/vehicle_entry_db.php",
		data: "id="+id+"&action=delete_vehicle",
		success: function(msg){jQuery("#vehicle_list_div").html(msg);
	}
	});
    }
}


