function calcShipping(totalprice, whichChart, serviceType, discountSwitch){
	
	// BEGIN CALC SHIPPING BASED ON TOTALPRICE
	
	var standard = 0;
	var priority = 0;
	var fedex = 0;
	var expressups = 0;
	
	if (whichChart == "mix-disabled")
	{
	// Give Mixed Shipping Rate
		if (totalprice > 0 && totalprice <= 4)
		{
			standard = 2.85;
			priority = 5.80;
			fedex = "Not Available";
		}
		else if (totalprice > 4 && totalprice <= 8)
		{
			standard = 3.20;
			priority = 8.25;
			fedex = 7.80;
		}
		else if (totalprice > 8 && totalprice <= 12)
		{
			standard = 4.75;
			priority = 14.50;
			fedex = 9.20;
		}
		else if (totalprice > 12 && totalprice <= 20)
		{
			standard = 5.77;
			priority = 17.85;
			fedex = 12.20;
		}
		else if (totalprice > 20 && totalprice <= 40)
		{
			standard = 9.32;
			priority = 31.30;
			fedex = 16.35;
		}
		else if (totalprice > 40 && totalprice <= 60)
		{
			standard = 11.86;
			priority = 36.15;
			fedex = 26.00;
		}
		else if (totalprice > 60 && totalprice <= 80)
		{
			standard = 15.41;
			priority = 41.95;
			fedex = 23.40;
		}
		else if (totalprice > 80 && totalprice <= 100)
		{
			standard = 17.95;
			priority = 49.64;
			fedex = 27.36;
		}
		else if (totalprice > 100 && totalprice <= 120)
		{
			standard = 20.00;
			priority = 59.25;
			fedex = 31.88;
		}
		else if (totalprice > 120 && totalprice <= 140)
		{
			standard = 24.00;
			priority = 68.80;
			fedex = 35.31;
		}
		else if (totalprice > 140 && totalprice <= 160)
		{
			standard = 27.00;
			priority = 78.40;
			fedex = 38.75;
		}
		else if (totalprice > 160 && totalprice <= 200)
		{
			standard = 33.00;
			priority = 95.00;
			fedex = 42.00;
		}
		else if (totalprice > 200 && totalprice <= 240)
		{
			standard = 37.00;
			priority = 120.00;
			fedex = 49.00;
		}
		else if (totalprice > 240)
		{
			standard = "call for quote";
			priority = "call for quote";
			fedex = "call for quote";
		}
		
	}
	else
	{
	// Give Color Shipping Rate
	
	 	if (totalprice > 0 && totalprice <= 15)
		{
			standard = 7.00;
			priority = 8.25;
			fedex = "Not Available";
		}
		else if (totalprice > 15 && totalprice <= 30)
		{
			standard = 7.00;
			priority = 8.25;
			fedex = 7.80;
		}
		else if (totalprice > 30 && totalprice <= 42)
		{
			standard = 7.00;
			priority = 14.50;
			fedex = 9.20;
		}
		else if (totalprice > 42 && totalprice <= 65)
		{
			standard = 5.77;
			priority = 17.85;
			fedex = 12.20;
		}
		else if (totalprice > 65 && totalprice <= 120)
		{
			standard = 9.32;
			priority = 31.30;
			fedex = 16.35;
		}
		else if (totalprice > 120 && totalprice <= 180)
		{
			standard = 11.86;
			priority = 36.15;
			fedex = 26.00;
		}
		else if (totalprice > 180 && totalprice <= 240)
		{
			standard = 15.41;
			priority = 41.95;
			fedex = 23.40;
		}
		else if (totalprice > 240 && totalprice <= 275)
		{
			standard = 17.95;
			priority = 49.64;
			fedex = 27.36;
		}
		else if (totalprice > 275 && totalprice <= 330)
		{
			standard = 20.00;
			priority = 59.25;
			fedex = 31.88;
		}
		else if (totalprice > 330 && totalprice <= 385)
		{
			standard = 24.00;
			priority = 68.80;
			fedex = 35.31;
		}
		else if (totalprice > 385 && totalprice <= 440)
		{
			standard = 27.00;
			priority = 78.40;
			fedex = 38.75;
		}
		else if (totalprice > 440 && totalprice <= 550)
		{
			standard = 33.00;
			priority = 95.00;
			fedex = 42.00;
		}
		else if (totalprice > 550 && totalprice <= 650)
		{
			standard = 37.00;
			priority = 120.00;
			fedex = 49.00;
		}
		else if (totalprice > 650)
		{
			standard = "call for quote";
			priority = "call for quote";
			fedex = "call for quote";
		}
		
	}

	// Add Free Shipping Exception for Media Mail
	if (totalprice >= 40){
			
			standard = "Free Shipping";	
	}
	else if (discountSwitch == 1 && totalprice >= 20)
	{
		standard = "Free Shipping";
		
	}
	
	// Return Values
	
	if (serviceType == "standard")
	{
		return standard;
	}
	else if (serviceType == "priority")
	{
		return priority;
	}
	else if (serviceType == "fedex")
	{
		return fedex;
	}
	else if (serviceType == "expressups")
	{
		return expressups;
	}
		
	// END CALC SHIPPING
	
}

function getSinglePageBasePrice(quanity){
	
	var baseprice = 0;
	
	
	if (quanity <= 250)
	{
		baseprice = .15;
	}
	else if(quanity <= 500){
		
		baseprice = .14;
	}
	else if (quanity <= 1000)
	{
		baseprice = .13;
	}
	else if (quanity <= 1500)
	{
		baseprice = .12;
	}
	else if(quanity <= 2000){
		
		baseprice = .1126;
	}
	else if(quanity <= 3000){
	
		baseprice = .0864;
	}
	else if(quanity <= 4000){
		baseprice = .0733;
	}
	else if(quanity <= 5000){
		baseprice = .0640;
	}
	else if(quanity <= 6000){
		baseprice = .0587;
	}
	else if(quanity <= 7000){
		baseprice = .0548;
	}
	else if(quanity <= 8000){
		baseprice = .0519;
	}
	else if(quanity <= 9000){
		baseprice = .0496;
	}
	else if(quanity <= 10000){
		baseprice = .0472;
	}
	else if(quanity <= 15000){
		baseprice = .0411;
	}
	else if(quanity <= 20000){
		baseprice = .0388;
	}
	else if(quanity <= 25000){
		baseprice = .0374;
	}
	else if(quanity <= 30000){
		baseprice = .0365;
	}
	else if(quanity <= 35000){
		baseprice = .0359;
	}
	else if(quanity <= 40000){
		baseprice = .0354;
	}
	else if(quanity <= 45000){
		baseprice = .0350;
	}
	else if(quanity <= 50000){
		baseprice = .0347;
	}
	else if(quanity <= 60000){
		baseprice = .0342;
	}
	else if(quanity <= 70000){
		baseprice = .0339;
	}
	else{
		baseprice = .0339;
	}


	return baseprice;

}



function getBasePrice(quanity){
	
	var baseprice = 0;
	
	
	if (quanity <= 249)
	{
		baseprice = .15;
	}
	else if(quanity <= 499){
		
		baseprice = .14;
	}
	else if(quanity <= 999){
	
		baseprice = .13;
	}
	else if(quanity <= 2499){
		baseprice = .12;
	}
	else if(quanity <= 9999){
		baseprice = .11;
	}
	else{
		baseprice = .11;
	}


	return baseprice;

}

function getStockPrice(stock){


	switch (stock) {
		
		// 20# - 92 Bright White
		case "1": 
		basestock = .00;
		break;
		
		// 24/60# - 96 Bright Opaque	
		case "2": 
		basestock = .01;
		break;
		
		// 28/70# - 96 Bright Opaque
		case "3": 
		basestock = .02;
		break;
				
		// 80# - 96 Bright White Opaque - Cover Stock	
		case "5": 
		basestock = .04;
		break;
		
		// 100# - 96 Bright White Opaque - Cover Stock
		case "6": 
		basestock = .05;
		break;
	
		
		// 80# - 96 Bright White Opaque - Text Gloss
		case "4": 
		basestock = .03;
		break;
	
		// 100# - 96 Bright White Opaque - Text Gloss
		case "12": 
		basestock = .05;
		break;
		
		// 80# - Bright White, Blue/White shade - Text Matte
		case "14": 
		basestock = .03;
		break;
		
		// 100# - Bright White, Blue/White shade - Text Matte
		case "15": 
		basestock = .05;
		break;
		
		
		// 80# - Bright White, Blue/White shade - Cover Gloss
		case "9": 
		basestock = .07;
		break;
				
		// 100# - Bright White, Blue/White shade - Cover Gloss
		case "10": 
		basestock = .09;
		break;
		
		// 80# - Bright White, Blue/White shade - Cover Matte
		case "16": 
		basestock = .04;
		break;
	
		//100# - Bright White, Blue/White shade - Cover Matte
		case "17": 
		basestock = .06;
		break;
	
		// 80# - Color Cover Stock,
		case "7": 
		basestock = .07;
		break;
				
		// 20# Color Paper
		case "8": 
		basestock = .03;
		break;
		
		// 24/60# - Color Paper
		case "13": 
		basestock = .03;
		break;
			
					}
					
		return basestock;
}

function paymentMethod(){

	// Display - Hide Payment Methods:
	
	if (document.getElementById('credit').checked){
	document.getElementById('displayCredit').style.display = "block";
	}
	else{
	document.getElementById('displayCredit').style.display = "none";
	}

}


function submitProject(){

	
	document.getElementById('submitproject').style.display = "block";
	document.getElementById('submitbutton').style.display = "none";

	
}


function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.match(numericExpression)){
		return true;
	}else{
		alert(helperMsg);
		return false;
	}
}



function empty(elem){
	if(elem.length == 0){
		return true;
	}
	return false;
}


function removeCommas(aNum) {

//remove any commas

aNum=aNum.replace(/,/g,"");

//remove any spaces

aNum=aNum.replace(/\s/g,"");

return aNum;

}

function stopRKey(evt) {
  var evt = (evt) ? evt : ((event) ? event : null);
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
  if ((evt.keyCode == 13) && (node.type=="text"))  {return false;}
}

document.onkeypress = stopRKey;