function CheckRequiredFields(){
	
	
	if (document.getElementById('papersize')[document.getElementById('papersize').selectedIndex].value == "") {
			alert("Please Select a Paper Size.")
			document.getElementById('papersize').focus();
			return false;
	}
	
	
	if (document.getElementById('ink-side1')[document.getElementById('ink-side1').selectedIndex].value == "") {
			alert("Please Select Side 1: Ink Color.")
			document.getElementById('ink-side1').focus();
			return false;
	}
	
	if(document.getElementById('parts')[document.getElementById('parts').selectedIndex].value == ""){
			alert("Please Select How Many Parts.")
			document.getElementById('parts').focus();
			return false;
	}
	
	if (document.getElementById('quanity').value == "") {
			alert("Please Enter a Quantity.")
			document.getElementById('quanity').focus();
			return false;
	}
	
	if (document.getElementById('projectName').value == "") {
		alert("Please Enter a Project Name.")
		document.getElementById('projectName').focus();
		return false;
	}
	
	
	return true;
	
}

function totalCost(){

	var papersize = document.getElementById('papersize')[document.getElementById('papersize').selectedIndex].value;
	
	var inkside1 = document.getElementById('ink-side1')[document.getElementById('ink-side1').selectedIndex].value;
	var parts = document.getElementById('parts')[document.getElementById('parts').selectedIndex].value;
	
	var quanity = document.getElementById('quanity').value;
	
	
	if (quanity != "") {quanity = Number(quanity);}
	if (parts != "") {parts = Number(parts);}
	
	quanity = quanity * parts;
	
	var baseprice = 0;
	var basestock = .00;
	var basepaper = 0;
	var basefold = 0;
	var subtotal = 0;
	var subtotal2 = 0;
	var halfprice = 0;
	
	if (quanity != "") {quanity = Number(quanity);}
	
	var basepricefinder = quanity;
	
	switch (papersize) {

		case "6": basepaper = .00;
					      halfprice = 1;
						  break;
				
		case "7": basepaper = .00;
						break;

		case "1": basepaper = .00;
						break;
				}
	

	if(halfprice == 1){
		
		var checktype = quanity % 2;
		
		if (checktype == "1"){
			
			quanity = quanity + 1;

		}
		

		quanity = quanity/2;
		basepricefinder = quanity;
		
	}

	
	if (inkside1 == "color"){
	
	// GET BASE PRICE	
	baseprice = getBasePrice(basepricefinder);
}
else {
	var baseprice = .07;
}
	
	
	
	// Preparing for 1 page ordering single or double sided.
	
	var clicks = 1;
	
		
	
	subtotal = ((baseprice * clicks) * quanity) + ((basestock * clicks) * quanity) + ((basepaper * clicks) * quanity) + (basefold * quanity);
	
	var totalprice = subtotal + subtotal2;
	
	if(halfprice == "1"){
		
		var trimming_cost = quanity * .00;
		
		totalprice = totalprice + trimming_cost;
		
		}

	
		// START SHIPPING CALC Determine which chart to use:


		if(inkside1 == "color")
		{
			var whichChart = "color";
		}
		else{
			var whichChart = "mix";
		}

		// Get Shipping Rate
		var mediamail = calcShipping(totalprice, whichChart, "media");
		var priority = calcShipping(totalprice, whichChart, "priority");
		var fedex = calcShipping(totalprice, whichChart, "fedex");
		var expressfedex = calcShipping(totalprice, whichChart, "expressfedex");
		
		// START NUMBERS & TEXT: Take Numbers to 2 Decimals, Leave Text Alone
	
		if (typeof mediamail == "number"){
			
			document.getElementById('shippingcost-mediamail').value = '$' + mediamail.toFixed(2);
		}
		else{
			document.getElementById('shippingcost-mediamail').value = mediamail;
		}
		
		if (typeof priority == "number"){
			
			document.getElementById('shippingcost-priority').value = '$' + priority.toFixed(2);
		}
		else{
			document.getElementById('shippingcost-priority').value = priority;
		}	
		
		if (typeof fedex == "number"){
			
			document.getElementById('shippingcost-fedex').value = '$' + fedex.toFixed(2);
		}
		else{
			document.getElementById('shippingcost-fedex').value = fedex;
		}	
		
		if (typeof expressfedex == "number"){
			
			document.getElementById('shippingcost-expressfedex').value = '$' + expressfedex.toFixed(2);
		}
		else{
			document.getElementById('shippingcost-expressfedex').value = expressfedex;
		}		
		// END NUMBERS & TEXT


		// Calc Selected Shipping & Price
		
		if (document.getElementById('shipping-type-media').checked){

			var shippingTotal = document.getElementById('shippingcost-mediamail').value;

		}
		else if (document.getElementById('shipping-type-priority').checked){

			var shippingTotal = document.getElementById('shippingcost-priority').value;

		}
		else if (document.getElementById('shipping-type-fedex').checked){

			var shippingTotal = document.getElementById('shippingcost-fedex').value;

		}
		else if (document.getElementById('shipping-type-expressfedex').checked){

			var shippingTotal = document.getElementById('shippingcost-expressfedex').value;

		}
		else if (document.getElementById('shipping-type-localpickup').checked){

			var shippingTotal = document.getElementById('shippingcost-localpickup').value;

		}
		
		// Preparing Shipping Total for Calculations.
		if (shippingTotal == "Free Shipping"){
			shippingTotal = 0;
		}
		else if (shippingTotal == "Not Available"){
			alert("Please select an available shipping service.")
			shippingTotal = 0;
		}
		else if (shippingTotal == "call for quote")
		{
			alert("Please Call For A Quote.");
			shippingTotal = 0;
		}
		else if (shippingTotal == "Free")
		{
			shippingTotal = 0;
		}
		else {
			
			shippingTotal = shippingTotal.slice(1);
			
		}


		var totalEstimatedPriceShipping = Number(shippingTotal) + Number(totalprice);


		// Display Prices

		document.getElementById('totalEstimatedPriceShipping').value = '$' + totalEstimatedPriceShipping.toFixed(2);
		document.getElementById('totalprice').value = '$' + totalprice.toFixed(2);

}