// JavaScript Document

function billing_select_1(){
	
	var val = $('b_select');
	for(i = 0; i < val.length; i++)
	{
		if(val[i].selected) v = val[i].value;
	}	
	var file = '/aj/billing';
	new Ajax.Updater('billing1',file,{method:'get',
			 parameters:{value:v}
			});
}

function chap_select(){
	
	var val = $('chap_type');	
	var file = '/aj/billing2';
	new Ajax.Updater('chap_name',file,{method:'get',
			 parameters:{value:val.value}
			});
}

function show_prices(id){
	
	$('details1').style.display='block';
	var chap = $('chap').value;
	var file = '/aj/billing3';
	new Ajax.Updater('chap_prices',file,{method:'get',
			 parameters:{value:id,chap:chap}
			});
	new Ajax.Updater('details1','/aj/billing5',{method:'get',
			 parameters:{chap_id:chap}
			});		
}

function show_details(id,price){
	$('details').style.display='block';
	var chap = $('chap').value;
	var file = '/aj/billing4';
	new Ajax.Updater('details',file,{method:'get',
			 parameters:{value:id,chap:chap,price:price}
			});	
	$('pay_form').style.display='block';
	new Ajax.Updater('pay_form','/aj/billing7',{method:'get',
			 parameters:{value:id,chap:chap,price:price}
			});	
	$('billing2').style.display='block';
	$('billing3').style.display='block';
	$('billing31').style.display='none';
}

function show_details2(id){
	$('details').style.display='block';
	var file = '/aj/billing4';
	new Ajax.Updater('details',file,{method:'get',
			 parameters:{value:id}
			});
	$('billing2').style.display='block';
	$('billing3').style.display='none';
	$('billing31').style.display='block';
	new Ajax.Updater('pay_form','/aj/billing7',{method:'get',
			 parameters:{value:id}
			});
}

function send_payment(){
	

	var t = $('type');
	//var form = document.getElementById('pay_form').price.value;
	
	//alert(form.length);
	/*
	for (var i=0; i<form.length; i++)  {
	if (form.elements[i].type == 'radio' && form.elements[i].checked)  {
	
	var price = form.elements[i].value;
	//alert(form.elements[i].value);
	}
	}
*/
	var price = $('chap_price').value;
	var chap_type = $('chap_type').value;
	var chap = $('chap').value;
	var first = $('contfirst');
	var last = $('contlast');
	var address = $('chptaddy1');
	var address2 = $('chptaddy2');
	var city = $('chapcity');
	var state = $('chapstate');
	var zip = $('chptzip');
	var phone1 = $('chptphone1');
	var phone2 = $('chptphone2');
	var phone3 = $('chptphone3');
	var ext = $('chptext');
	var email = $('chptemail');
	var years = $('years');
	//var price = form.price.value;
	
	
	if(!reStr.test(first.value)){
		alert('Please enter the name of the Chapter Contact');
		first.select();
		first.focus();
		return false;
	}

	if(!reStr.test(last.value)){
		alert('Please enter the name of the Chapter Contact');
		last.select();
		last.focus();
		return false;
	}
	
	if(!reStrAlpha.test(address.value)){
	alert('Please enter the address for the Chapter Contact');
	address.select();
	address.focus()
	return false;
	}
	
	if(!reStr.test(city.value)){
	alert('Please enter the city');
	city.select();
	city.focus();
	return false;
	}
	
	if(!reStr.test(state.value)){
	alert('Please select the state');
	return false;
	}
	
	if(!reNumber.test(zip.value)){
	alert('Please enter the zip');
	zip.select();
	zip.focus();
	return false;
		
	}
	
	
	if(email.value  =='' || !reEmail.test(email.value)){
	alert('Please enter a valid email address');
	email.select();
	email.focus();
	return false;
	}

	var file = '/aj/billing6';
	
	$('billing0').puff();
	$('billing1').puff();
	$('billing2').puff();
	$('billing3').puff();
	$('billing3').puff();
	$('billing31').puff();
	$('billing4').style.display='block';
	new Ajax.Updater('billing4',file,{method:'get',
			 parameters:{type:t.value,price:price,chap_type:chap_type,chap:chap,first:first.value,last:last.value,address:address.value,address2:address2.value,city:city.value,state:state.value,zip:zip.value,phone:phone1.value+'-'+phone2.value+'-'+phone3.value,email:email.value,years:years.value}
			});

}


function send_payment2(){
	

	var t = $('type');
	var form = $('billing_form');
	
	//alert(form.length);
	
	for (var i=0; i<form.length; i++)  {
	if (form.elements[i].type == 'radio' && form.elements[i].checked)  {
	
	var price = form.elements[i].value;
	//alert(form.elements[i].value);
	}
	}
	
	var years = $('years');
	
	var file = '/aj/billing6';
	
	$('billing0').puff();
	$('billing1').puff();
	$('billing2').puff();
	$('billing3').puff();
	$('billing3').puff();
	$('billing31').puff();
	$('billing4').style.display='block';
	new Ajax.Updater('billing4',file,{method:'get',
			 parameters:{type:t.value,price:price,years:years.value}
			});
}

