/********************************** Validation *******************************************************/
function place_validation()
{
    var from_place = document.getElementById("from_place").value;
	if(from_place=='')
	{
		document.getElementById("from_place_validation_div").innerHTML="* This field is Required.";
		document.getElementById("from_place").focus();
		return false;
	}
	
	var to_place = document.getElementById("to_place").value;
	if(to_place=='')
	{
		document.getElementById("to_place_validation_div").innerHTML="* This field is Required.";
		document.getElementById("to_place").focus();
		return false;
	}
	
	var kms = document.getElementById("kms").value;
	if(kms=='')
	{
		document.getElementById("kms_validation_div").innerHTML="* This field is Required.";
		document.getElementById("kms").focus();
		return false;
	}
	
	var from = document.getElementById("from_place").value;
	var to = document.getElementById("to_place").value;
	if(from_place==to_place)
	{
		alert("From and To place Shouldn't To Be Same");
		document.getElementById("from_place").focus();
		return false;
	}
}

function place_clear_validation(str)
{
	if(str!='')
	{
		document.getElementById("from_place_validation_div").innerHTML="";
	}
	
	if(str!='')
	{
		document.getElementById("to_place_validation_div").innerHTML="";
	}
	
	if(str!='')
	{
		document.getElementById("kms_validation_div").innerHTML="";
	}
}

/********************************** Mainlist Add *******************************************************/
function place_entry_add(from_place,to_place,kms,edit_id,action)
{
if((from_place!='')&&(to_place!='')&&(kms!='')&&(from_place!=to_place))
 {
  jQuery.ajax({
		type: "POST",
		url: "place_entry_db.php",
		data: "from_place="+from_place+"&to_place="+to_place+"&kms="+kms+"&edit_id="+edit_id+"&action="+action,
		success: function(msg){jQuery("#place_list_div").html(msg);	
		alert(msg);
		window.close();
		window.opener.location.reload(true);
 }
		});
 }
else
{
    place_validation();
}
}

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


