function calculatePrice(){
	var d = document;
	var fp = d.printingCalculator;
	var quantity = fp['quantity'].value;
	var q;
	var colors;
	var stockType;
	var stock;
	var setup = 50;
	var prices = new Array(162.50,125,100);
	var totalPrice;
		for(var i=0;i<fp['colorAmount'].length;i++){
			if(fp['colorAmount'][i].checked){
				colors = fp['colorAmount'][i].value;
			}
		}
		for(var i=0;i<fp['stockType'].length;i++){
			if(fp['stockType'][i].checked){
				stockType = fp['stockType'][i].value;
			}
		}
	if(colors==2){
		cPrice = 15;
	}
	else{
		cPrice = 0;
	}
	if(stockType=='White'){
		stock = 3;
	}
	else{
		stock = 0;
	}
	
	q = parseInt(quantity);
	
	if(q==1){
		cPrice = 0;
		fp['colorAmount'][0].checked = 'checked';
		fp['colorAmount'][1].disabled = 'disabled';
	}
	else{
		fp['colorAmount'][colors-1].checked = 'checked';
		fp['colorAmount'][1].disabled = '';
	}
	
	if(q<5){
		totalPrice= (q*(stock+cPrice+prices[0]))+setup;
	}
	else if(q<10){
		totalPrice= (q*(stock+cPrice+prices[1]))+setup;
	}
	else if(q>=10){
		totalPrice= (q*(stock+cPrice+prices[2]))+setup;
	}
	if(q>"0" && q<"9999"){
		d.getElementById('totalCost').innerHTML = "$"+totalPrice.toFixed(2);
		d.getElementById('sleeveQuantity').value = q;
		d.getElementById('sleeveColors').value = colors;
		d.getElementById('sleeveStock').value = stockType;
		d.getElementById('sleeveCost').value = totalPrice;
	}
	else{
		d.getElementById('totalCost').innerHTML = "";
		fp['quantity'].value="";
		d.getElementById('sleeveQuantity').value = "";
		d.getElementById('sleeveColors').value = "";
		d.getElementById('sleeveStock').value = "";
		d.getElementById('sleeveCost').value = "";
		//alert("Please use numbers only");
	}
}
function calculatePrice2(){
	var d = document;
	var fp = d.printingCalculator2;
	var quantity = fp['quantity2'].value;
	var q;
	var colors;
	var stockType;
	var stock;
	var setup = 50;

	d.getElementById('totalCost2').innerHTML = "";
	d.getElementById('cupQuantity').value    = "";
	d.getElementById('cupColors').value      = "";
	d.getElementById('cupSize').value        = "";
	d.getElementById('cupCost').value        = "";


	if(d.getElementById('size16').checked){
		var stockType = d.getElementById('size16').value;
		var prices = new Array(220,190,170);
	}else if(d.getElementById('size20').checked){
		var stockType = d.getElementById('size20').value;
		var prices = new Array(159,147,138);
	}else{
		var stockType = d.getElementById('size24').value;
		var prices = new Array(165,153,144);
	}
	var totalPrice;
		for(var i=0;i<fp['colorAmount2'].length;i++){
			if(fp['colorAmount2'][i].checked){
				colors = fp['colorAmount2'][i].value;
			}
		}
	
	q = parseInt(quantity);
	
	if(colors==2){
		cPrice = q*0.15;
	}
	else{
		cPrice = 0;
	}
	
	
	if(q==1){
		cPrice = 0;
		fp['colorAmount2'][0].checked  = 'checked';
		fp['colorAmount2'][1].disabled = 'disabled';
		fp['size'][0].checked 	       = 'checked';
		fp['size'][1].disabled 	       = 'disabled';
		fp['size'][2].disabled	       = 'disabled';
	}
	else{
		//fp['colorAmount2'][0].checked  = 'checked';
		fp['colorAmount2'][1].disabled = '';
		fp['size'][1].disabled 	       = '';
		fp['size'][2].disabled	       = '';
}
	
	if(q<6){
		totalPrice= (q*(cPrice+prices[0]))+setup;
	}
	else if(q<10){
		totalPrice= (q*(cPrice+prices[1]))+setup;
	}
	else if(q>=10){
		totalPrice= (q*(cPrice+prices[2]))+setup;
	}
	if(q>"0" && q<"9999"){
		d.getElementById('totalCost2').innerHTML = "$"+totalPrice.toFixed(2);
		d.getElementById('cupQuantity').value = q;
		d.getElementById('cupColors').value = colors;
		d.getElementById('cupSize').value = stockType;
		d.getElementById('cupCost').value = totalPrice.toFixed(2);
	}
	else{
		d.getElementById('totalCost2').innerHTML = "";
		fp['quantity2'].value="";
		d.getElementById('cupQuantity').value = "";
		d.getElementById('cupColors').value = "";
		d.getElementById('cupSize').value = "";
		d.getElementById('cupCost').value = "";
		//alert("Please use numbers only");
	}
}

function checkForm(fname){
	var d = document;
	var f = d.forms[fname];
	for(var i=0;i<f.length;i++){
		if(f[i].value==''){
			if(f[i].title=='Comments:'){}
			else{
				alert('Please fill in the \"'+f[i].title+'\" field');
				return false;
			}
		}
	}
	var correct = true;
	var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
	var emailFilter=/^.+@.+\..{2,3}$/;
	if(f['emailAddress'].value!=''){
		if (!(emailFilter.test(f['emailAddress'].value))){ alert("Please enter a valid email address."); return false;  }
		else if(f['emailAddress'].value.match(illegalChars)){ alert("The email address contains illegal characters."); return false; }  
	}
	else{
		return false;
	}
	
	var file = f['file'].value;
	file = file.split(".");
	
	if(file[1]=='eps' || file[1]=='ai' || file[1]=='zip' || file[1]=='pdf' || file[1]=='sit'){
		correct=true;
	}
	else{
		alert('File must be an .eps .ai .zip .pdf .sit');
		correct=false;
	}
	return correct;
}

function checkDelete(index){
	var d = document;
	var f = d.forms[0][0];
	d.getElementById('deleteFile').innerHTML = "<b>DELETE FILE:<br />"+f[index].value+"</b><br /><br />Are you sure you want to delete this file?<br /><a href=\"admin.php?deleteFile="+f[index].value+"\">Yes</a> &nbsp; | &nbsp; <a href=\"#\" onclick=\"clearDelete()\">No</a>";
}

function clearDelete(){
	document.getElementById('deleteFile').innerHTML = "";
}