window.onload = throwPayPal;
function throwPayPal(){
	//var myStr = "I\n want my \n string \n";
	//myStr = myStr.split(/\s+/);
	//alert(myStr.join("_"));
	throwSelectRegion();
	document.getElementById("region").onchange=throwSelectSequence1;
}
function throwSelectRegion(){
	var priceEast = "675.00";
	var priceWest = "700.00";
	var priceOther = "725.00";
	var selectString =		'<CENTER>'
	+   '<SELECT id="region" />'
	+   '<OPTION   />CHOOSE ONE OF THREE REGIONS'
	+   '<OPTION  VALUE="675" />EAST OF THE MISSISSIPI($' + priceEast + ')'
	+   '<OPTION  VALUE="700"  />WEST OF THE MISSISSIPI($' + priceWest + ')'
	+   '<OPTION VALUE="725" />HAWAII OR ALASKA($' + priceOther + ')'
	+   '</SELECT />'
	+   '</CENTER>';
	//
	document.getElementById("selectRegion").innerHTML=selectString;
	//	
	
}
function throwComments(){
	commentString ='<center><FONT SIZE=2>COMMENTS?</center>'
	+'<center><TEXTAREA ROWS=4 COLS=25 NAME=Comments WRAP=PHYSICAL name = "comments" id = "comments">'
	+'</TEXTAREA></center>'
	+'<center><span class = "bigRed">Is this information correct?</span></center>'
	+'<center><input type = "button" value ="Go To PayPal" id = "commentButton">'
	+'</center>';
	document.getElementById("commentArea").innerHTML=commentString;
	document.getElementById("commentButton").onclick=throwButton;
}
function value(selectId){
/*	function showSelected()

	var selObj = document.getElementById('selSeaShells');
	var txtIndexObj = document.getElementById('txtIndex');
	var txtValueObj = document.getElementById('txtValue');
	var txtTextObj = document.getElementById('txtText');
	
	var selIndex = selObj.selectedIndex;
	txtIndexObj.value = selIndex;
	txtValueObj.value = selObj.options[selIndex].value;
	txtTextObj.value = selObj.options[selIndex].text;
*/
	var selObj = document.getElementById(selectId);
	var selIndex = selObj.selectedIndex;
	//alert(selObj.options[selIndex].value);
	//alert(selObj.options[selIndex].text);
	return selObj.options[selIndex].value;
}

function throwSelectSequence1(){
	var sequence1String= '<center>'
	+'<SELECT id = "sequence1" />'
	+'<OPTION   />Choose Sequence One'
	+'<OPTION VALUE="Dinghy" />Dinghy'
	+'<OPTION VALUE="RollDinghy" />Rolling Dinghy'
	+'<OPTION VALUE="TwoDingy" />Two Minute Dinghy'
	+'<OPTION VALUE="RollTwoDingy" />Rolling Two Minute Dinghy'
	+'<OPTION VALUE="Rule26" />Rule 26'
	+'<OPTION VALUE="RollRule26" />Rolling Rule 26'
	+'<OPTION VALUE="Recall26" />Recall Rule 26	'
	+'<OPTION VALUE="RecallRoll26" />Rolling Recall Rule 26'
	+'<OPTION VALUE="Opti" />Opti'
	+'<OPTION VALUE="RollingTens" />Rolling Tens'
	+'<OPTION VALUE="RollingSixes" />Rolling Sixes'
	+'</SELECT /></CENTER />';
	document.getElementById("selectSequence1").innerHTML=sequence1String;
	document.getElementById("sequence1").onchange=throwSelectSequence2;
}

function throwSelectSequence2(){
	//alert('made it here');
	var sequence2String= '<CENTER />'
	+'<SELECT id = "sequence2" />'
	+'<OPTION  VALUE="" />Choose Sequence Two'
	+'<OPTION VALUE="Dinghy" />Dinghy'
	+'<OPTION VALUE="RollDinghy" />Rolling Dinghy'
	+'<OPTION VALUE="TwoDingy" />Two Minute Dinghy'
	+'<OPTION VALUE="RollTwoDingy" />Rolling Two Minute Dinghy'
	+'<OPTION VALUE="Rule26" />Rule 26'
	+'<OPTION VALUE="RollRule26" />Rolling Rule 26'
	+'<OPTION VALUE="Recall26" />Recall Rule 26	'
	+'<OPTION VALUE="RecallRoll26" />Rolling Recall Rule 26'
	+'<OPTION VALUE="Opti" />Opti'
	+'<OPTION VALUE="RollingTens" />Rolling Tens'
	+'<OPTION VALUE="RollingSixes" />Rolling Sixes'
	+'</SELECT /></CENTER /></td /></tr>';
	document.getElementById("selectSequence2").innerHTML=sequence2String;
	document.getElementById("sequence2").onchange= throwSelectSequence3;
}
function throwSelectSequence3(){
	var sequence3String= ''
	
	+'<CENTER /><SELECT id = "sequence3" />'
	+'<OPTION  VALUE="" />Choose Sequence Three'
	+'<OPTION VALUE="Dinghy" />Dinghy'
	+'<OPTION VALUE="RollDinghy" />Rolling Dinghy'
	+'<OPTION VALUE="TwoDingy" />Two Minute Dinghy'
	+'<OPTION VALUE="RollTwoDingy" />Rolling Two Minute Dinghy'
	+'<OPTION VALUE="Rule26" />Rule 26'
	+'<OPTION VALUE="RollRule26" />Rolling Rule 26'
	+'<OPTION VALUE="Recall26" />Recall Rule 26	'
	+'<OPTION VALUE="RecallRoll26" />Rolling Recall Rule 26'
	+'<OPTION VALUE="Opti" />Opti'
	+'<OPTION VALUE="RollingTens" />Rolling Tens'
	+'<OPTION VALUE="RollingSixes" />Rolling Sixes'
	+'</SELECT /></CENTER /></td /></tr>';
	document.getElementById("selectSequence3").innerHTML=sequence3String;
	document.getElementById("sequence3").onchange= throwComments;
}

function throwButton(){
	var sequenceString = "";
	var commentString = document.getElementById("comments").value;
	commentString = commentString.split(/\s+/);
	commentString = commentString.join("_");
	//dummy = dummy.split(" ");
	//dummy = dummy.join("_");
	//commentString = dummy;
	//alert(commentString);
	var priceString;
	sequenceString +=value("sequence1") + ",";
	sequenceString +=value("sequence2") + ",";
	sequenceString +=value("sequence3") + "\n" ;
	priceString = value("region");
	//alert(sequenceString);
	//alert(priceString);
	var buttonString = ''
	+'<input type="hidden" name="cmd" value="_xclick">'
	+'<input type="hidden" name="business" value="ollie@ecohsystems.com">'
	+'<input type="hidden" name="currency_code" value="USD">'
	+'<input type="hidden" name="item_name" value="Ollie Box">'
	+'<input type="hidden" name="amount" value='+priceString+'>'
	+'<input type="hidden" name="shipping" value="0.00">'
	+'<input type="hidden" name="no_shipping" value="0">'
	+'<input type="hidden" name="no_note" value="1">'
	+'<input type="hidden" name="tax" value="0.00">'
	+'<input type="hidden" name="lc" value="US">'
	+'<center>'
	+'<select  name="os0" id="os0"><option value='+sequenceString+' />'+sequenceString+
	+'</select>'
	+'<center><p><input type="hidden" name="on0" value="Sequences"></p>'
	+'<input type="hidden" name="on1" value=Comments maxlength="200">'
    +'<input type="text" name="os1"  id = "os1" value = '+commentString+' >'
	+'<p><input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif"' 
	+'border="0" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!">'
	+'</p></center>'
	
	+'</center></tr></form>';
	document.getElementById("button").innerHTML=buttonString;
	document.getElementById("os0").style.display="none";
	document.getElementById("os1").style.display="none";
	document.getElementById("region").onchange=throwButton;
	document.getElementById("sequence1").onchange=throwButton;
	document.getElementById("sequence2").onchange=throwButton;
	document.getElementById("sequence3").onchange=throwButton;
	document.getElementById("commentButton").onclick=throwButton;

}

