
function min(a, b) {

	if(a < b ) {
	
		return a;
	
	} else {
	
		return b;
	
	}

}


function max(a, b) {

	if(a > b ) {
	
		return a;
	
	} else {
	
		return b;
	
	}

}

    
function goeven(value) {

	if(!isNaN(value)) {
	
		value = Math.ceil(value);
		
		if(value % 2 != 0) {
		
			value++;
		
		}
	
	}
	
	return value;

}



function sqft(a, b, c, d) {

	return goeven(a + b) * goeven(c + d) / 144;

}


function sizecost(length, width, standard_length, standard_width, orig_price) {

	var overage = (length - standard_length) + (width - standard_width);
	

	if(overage >= 30)
		return orig_price * .5;
	else if(overage >= 24)
		return orig_price * .45;
	else if(overage >= 18)
		return orig_price * .35;
	else if(overage >= 12)
		return orig_price * .25;
	else if(overage >= 6)
		return orig_price * .15;
	else if(overage > 0)
		return orig_price * .1;
	else
		return 0;
	

}



function range(values, value) {


	
	var regExp = new RegExp("{\\d+-\\d+:\\d+}", "g");
    var matches = values.match(regExp);
	
	for(i=0;i<matches.length;i++) {
	
		var process = matches[i];
		process = process.substr(1).substr(0, process.length - 2);
		
		var low = process.split("-")[0];
		var high = process.split("-")[1].split(":")[0];
		var result = process.split(":")[1];
		
		if(Number(low) <= Number(value) && Number(value) < Number(high)) {
		
			return result;
		
		}
	
	}

}
