function checkOnlineTransfer(){
	if(purchaseMethod==2){
		if(transactionHandler==0){
			if(paymentPlan!=0){
				var message="If you wish to use PayPal to handle this transaction:\n"+
				"Please go back and choose the \"Single Payment Plan\".\n\n"+
				"  << OR >> \n\nMake monthly payments to Jane Darin.";
				alert(message);return;
			}
			if(confirm(getStudioOrder("customer")+"\n\n<< SEND ORDER NOW >>")){
				ge("f1").submit();
				purchasePageIndex++;
				createPurchasePage();
				currentPage.createPageHtml(container);
				pageFrame.location.reload();
			}
		}
		else if(transactionHandler==1){
			if(confirm(getStudioOrder("customer")+"\n\n<< SEND ORDER NOW >>")){
				var so=ge("emailMessage");
				so.value=getStudioOrder();
				ge("f2").submit();
				setTimeout("delayCustomerEmail()", 500);
			}
		}
	}
}
function delayCustomerEmail(){
	var so=ge("emailMessage");
	so.value=getStudioOrder("customer");
	var fo=ge("f2");
	fo.action="http://www.janedarin.com/cgi-bin/cgiemail/BIN/emailToCustomer.txt";
	fo.submit();
	purchasePageIndex++;
	createPurchasePage();
	currentPage.createPageHtml(container);
	pageFrame.location.reload();
}
function clearAmountFields(){	
	shipping=0;salesTax=0;subtotal=0;grandTotal=0;downpayment1=0;downpayment2=0;monthly=0;
}
function confirmRemove(chkbox,index){
	if(confirm("Remove "+cart.items[index].label.toUpperCase()+" from shopping cart?")){
		cart.remove(index);
		if(cart.items.length==0)purchasePageIndex=0;
		changePage();
	}else if(chkbox != null) chkbox.checked = false;
}
function createForms(){
	var fh="<div style='position:absolute;visibility:hidden;top:-1000;'>"+
	"<form name=f1 id=f1 target=paypal action='https://www.paypal.com/cgi-bin/webscr' "+
	"method=post>"+
	"<input type=hidden name=cmd value=_cart></input>"+
	"<input type=hidden name=upload value=1></input>"+
	"<input type=hidden name=business value=janed@san.rr.com></input>";
	var itemName="";var qtyName="";var amountName="";
	for(var i=0;i<cart.items.length;i++){
		itemName="item_name_"+(i+1);
		qtyName="quantity_"+(i+1);
		amountName="amount_"+(i+1);
		fh+="<input type=hidden name='"+itemName+"' "+
		"value='"+cart.items[i].label+"'></input>"+
		"<input type=hidden name='"+qtyName+"' "+
		"value='"+cart.qtys[i]+"'></input>"+
		"<input type=hidden name='"+amountName+"' "+
		"value='"+ShoppingCart.fix(cart.items[i].price)+"'></input>";
	}
	fh+="<input type=hidden name=handling_cart value='"+
	ShoppingCart.fix(shipping)+"'></input>"+
	"<input type=hidden name=tax_cart value='"+ShoppingCart.fix(salesTax)+"'></input>"+
	//"<input type=hidden name=return value='http://www.janedarin.com/BIN/page_view.html'></input>"+
	//"<input type=hidden name=cancel_return value='http://www.janedarin.com/BIN/page_view.html'></input>"+
	//"<input type=hidden name=shopping_url value='http://www.janedarin.com/BIN/page_view.html'></input>"+
	"<input type=hidden name=no_note value=0></input>"+
	"<input type=hidden name=cpp_headerback_color value=#bbaa88></input>"+
	"<input type=hidden name=cpp_headerborder_color value=#807040></input>"+
	"</form>"+
	"<form id=f2 name=f2 method=post "+
	"action=http://www.janedarin.com/cgi-bin/cgiemail/BIN/emailToJane.txt'>"+
	"<input type=hidden name=emailAddress value='"+profile.email+"'></input>"+
	"<input type=hidden name=emailSubject value='Jane Darin Studio - Online Order'></input>"+
	"<input type=hidden name='cgiemail-mailopt' value='sync'></input>"+
	"<textarea id=emailMessage name=emailMessage wrap=soft cols=100 rows=30></textarea>"+
	"</form></div>";
	return fh;
}
function createPurchasePage(){
	container=new Container();
	container.paintLayout(PAINT_LAYOUT);
	container.setSpacing(CONTAINER_SPACING);
	switch(purchasePageIndex){
		case 0:setTotals();
			if(cart.items.length>0){
				nch= createForms() + "<h3>1. Approve shopping cart items...</h3>";
				cch=cart.getHtml()+"<br>"+
				"<p>"+getNavButtons(false,false,true)+"</p><br />";
			}else{
				nch="<h3>0 items in shopping cart...</h3>";
				cch=
"<table><tr><td><b>To purchase a Scuplture from Jane:</b><br>"+
"<ul><li>Go to the Sculptures Page.</li>"+
"<li>Select a Sculpture by clicking on the title.</li>"+
"<li>Click the Purchase / Add to Cart button.</li>"+
"<li>Finish the checkout process.</li></ul>"+
"<p><b>To Purchase a CD:</b></p>"+
"<ul><li>Go to the Art Services Page and select \"Seminars and CD's\".</li>"+
"<li>Select a CD by clicking on the title.</li>"+
"<li>Click the Add to Cart button.</li>"+
"<li>Finish the checkout process.</li></ul>"+
"</td></tr></table>"+

"<p><b>Your order will be packed carefully and shipped to your address via USPS.</b></p>";
			}
			break;
		case 1: setTotals();
			nch = getIcons()+"<h3>2. Enter customer details...</h3>";
			cch=getCustomerForm();
			break;
		case 2:	setTotals();
			nch=getIcons()+"<h3>3. Choose a Payment Plan...</h3>";
			cch=getPaymentPlans();
			break;
		case 3: nch=getIcons()+"<h3>4. How will you place the order?</h3>";
			cch=getMethodsOfPayment();
			break;
		case 4:	switch(purchaseMethod){
				case 0:	printOrder();
					nch="<h1>ORDER BY PHONE<h1><img src='"+wPath+"phone.gif'>"+
					"<h2>Call (858) 514-8154</h2>";
					cch="<p><i>Keep a printed copy for your records...</p>"+
					"<br/><p><i>Thank you for the order!</i></p>"+
					getNavButtons(true, false, false);
					break;
				case 1:	printOrder();
					nch="<h1>ORDER BY MAIL</h1><img src='"+wPath+"mail.gif'>"+
					"<h2>Send a copy of the printed order and payment to:</h2>";
					cch="<h3>Jane Darin Studio<br/>5648 Camber Dr.<br/>San Diego, CA 92117</h3>"+
					"<br/><p><i>Thank you for the order!</i></p>"+
					getNavButtons(true, false, false);
					break;
				case 2:	nch=createForms()+"<h1>ORDER ONLINE</h1><img src='"+wPath+"online.gif' />"+
					"<h2>Send payment to:</h2>";
					cch=getOnlineChoice(); 
					break;
			}
			break;
		case 5: nch="";
			cch=
"<table width='550'><tr><td align='left'><h1>Thank you for using Jane Darin Studio</h1>"+
"<ul><li>You will receive an email shortly notifying you of your order.</li><li>Your order will be shipped via USPS.</li>"+
"<li>Please allow 2 to 4 weeks</li><li>Click the \"Finish\" button below to finalize your order and to prevent "+
"multiple payments.</li></ul></td></tr><td align='center'><br /><br /><input type='button' value='Finish' "+
 "onclick='top.actionPerformed(\"cancel\")' /></td></tr></table>";
			break;
				
	}
	container.setNorthComponent(nch, "top", "center");
	container.setCenterComponent(cch, "top", "center");
	purchasePage = new Page("Shopping Cart");
	purchasePage.paintLayout(PAINT_LAYOUT);
	purchasePage.createPageHtml(container);
	purchasePage.update=purchasepage_update;
	pages[4] = purchasePage;
}
function populate(){
	if(ge("chkPop").checked){
		ge("cName").value = profile.name;
		ge("cAddress").value = profile.address;
		ge("cCity").value = profile.city;
		ge("selectState").selectedIndex = profile.stateIndex;
		ge("cZip").value = profile.zip;
		ge("cPhone").value = profile.phone;
		ge("cEmail").value = profile.email;
		ge("selectCCType").selectedIndex = profile.cardTypeIndex;
		ge("cHolder").value = profile.cardHolder;
		ge("cNumber").value = profile.cardNumber;
		ge("selectCCExpMonth").selectedIndex = profile.cardExpMonthIndex;
		ge("selectCCExpYear").selectedIndex = profile.cardExpYearIndex;
		ge("cPIN").value = profile.cardPIN;	
	}else ge("form1").reset();
}
function printOrder(){openInfowin("printable order");actionPerformed("next");}
function switchMethods(index,type){
	var oldVal;
	if(type=="purchase")oldVal=purchaseMethod;
	else if(type=="plan")oldVal=paymentPlan;
	else if(type=="online")oldVal=transactionHandler;
	var element=ge(new String("e"+oldVal));
	if(element){
		element.style.border="4px solid #aaa";
		element.style.color="#aaa";
		element.style.backgroundColor="transparent";
	}
	element=ge(new String("e"+index));
	element.style.border="4px solid "+LIGHT_COLOR;
	element.style.color="black";
	element.style.backgroundColor="white";
	var imgStr=wPath;
	var oldStr=wPath;
	if(type=="purchase"){
		purchaseMethod=index;
		switch(oldVal){
			case 0:oldStr+="phone";break;
			case 1:oldStr+="mail";break; 
			case 2:oldStr+="online";break;
		}
		switch(index){
			case 0:imgStr+="phone";break;
			case 1:imgStr+="mail";break;
			case 2:imgStr+="online";break;
		}
		ge("img"+oldVal).src=oldStr+"_disabled.gif";
		ge("img"+index).src=imgStr+".gif";
	}else if(type=="plan")paymentPlan = index;
	else if(type=="online"){
		transactionHandler=index;
		switch(oldVal){
			case 0:oldStr+="paypal";break;
			case 1:oldStr+="onlineLogo";break;
		}
		switch(index){
			case 0:imgStr+="paypal";break;
			case 1:imgStr+="onlineLogo";break;
		}
		ge("img"+oldVal).src=oldStr+"_disabled.gif";
		ge("img"+index).src=imgStr+".gif";
	}
}
