/*
	globally used javascript functions here
*/

// redirect them to the relevant parts url
function redirect(url, f) {
	url += "parts/" + f[f.selectedIndex].value.substr(1);
	self.location = url;
}

// a basic function to open a basic window with user specified url, width and heights.
function popup(url, width, height) {
	featurestr = "directories=0,height=" + height + ",location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0,width=" + width;
	open(url, "_blank", featurestr);
}

// this one is a function that makes sure that a field (this) is an integer.
function make_int(f) {
	if(isNaN(f.value) || (f.value == "") || (f.value < 0)) {
		f.value = "0";
	}
	else {
		f.value = Math.round(f.value);
	}
}

// this one makes sure a field value is a float value
function make_float(f) {
	if(isNaN(f.value) || (f.value == "")) {
		f.value = "0";
	}
}

// this function makes sure a field contains a money value
function make_money(field) {
	if(isNaN(field.value) || (field.value == "")) {
		field.value = "0.00";
	}
	else {
		val = Math.round(field.value * 100) / 100;
		val += "";
		dot = val.indexOf(".");
		if(dot < 0) {
			val += ".00";
		}
		else if((val.length - dot) == 2) {
			val += "0";
		}
		field.value = val;
	}
}
