
var loadFunctions = new Array()

function loaded() {
	
	for(var i=0;i<loadFunctions.length;i++) {
		
		loadFunctions[i]()
	}
	
	
}

function delete_vehicle(vID,el) {
	
	if(confirm("Are you sure you want to delete this vehicle? You will not be able to recover this in future.")) {
	
		confirmed_delete_vehicle(vID,el)
		
	}
	
}

function confirmed_delete_vehicle(vID,el) {
	
	var button = el
	
	var obj = {url:"/actions/delete_vehicle.aspx",data:{vID:vID},dataType:"xml"}
	
	obj.error = function(e) {
		
		alert("ajax request failure")	
		
		
	}
	
	obj.success = function(data) {
		
		if($("success",data).size()>0) {
			
			$(button).parents("tr").filter("table.vehicleSearchResultsTable tr").remove()
			location.reload(true)
		}
		
		else {
			if($("failed",data).size()>0) {
			
				alert($("failed",data).attr("error_message"))
				
			}
			else {alert("ajax response failure")}
		}
		
		
	}
	
	$.ajax(obj)
	
}


function numbersOnly(el) {
	var oValue = el.value
	var newValue = ""
	var hasError = false
	for(var i=0;i<oValue.length;i++) {
		if(oValue.charCodeAt(i)>47&&oValue.charCodeAt(i)<58) {
			newValue+=oValue.charAt(i)
		}
		else {hasError=true}
	}
	var nValue = parseFloat(oValue.replace(",",""))
	if(!isNaN(nValue)) {newValue=Math.round(nValue)+""}
	el.value = newValue
	if(hasError) {alert("Please enter numeric characters only for this value")}
}


function loginRadioSwitch(el,disabled) {
	
	if(el.checked) {
		el.form.password.disabled=disabled
	}
}
		
		
		
$(loaded)