function getSelectedChoice(){
	var index=document.getElementById("choiceMenu").selectedIndex;
	var response=document.getElementById("response");
	//document.write("text="+document.getElementById("choiceMenu").options[index].text);
	pickChoice(index);
}

function getSelectedSelect(){
	var index=document.getElementById("selectMenu").selectedIndex;
	var response=document.getElementById("response");
	//document.write("text="+document.getElementById("choiceMenu").options[index].text);
	pickSelect(index);
}



function pickChoice(){
	//$.getJSON("http://localhost/~goat/fruit4london/choice.json", 
		
		var boxes;
			var index= document.getElementById("choiceMenu").selectedIndex;
		$.getJSON("http://www.fruit4london.co.uk/homes/choice.json",null, function(boxes){
		//$.getJSON("/fruit4londontest/choice.json",null, function(boxes){
		//$.getJSON("/~goat/fruit4london/choice.json",null, function(boxes){
			//boxes=eval( boxes );
			document.getElementById("fruit").innerHTML="";
			document.getElementById("fruit").innerHTML="Apples  x "+
						"<br/>Pears x "+"<br/>Bananas x "+"<br/>Clementines x "
						+"<br/>Peaches* x "+"<br/>Plums* x "+
						"<br/>Nectarines* x ";
			
			document.getElementById("quantity").innerHTML="";
			document.getElementById("quantity").innerHTML=boxes[index].Apples+
						"<br/>"+boxes[index].Pears+"<br/>"+boxes[index].Bannanas+"<br/>"
						+boxes[index].Clementines+"<br/>"+boxes[index].Peaches+"<br/>"+boxes[index].Plums+
						"<br/>"+boxes[index].Nectarines+'<br/>';
			document.getElementById("boxname").innerHTML="";
			document.getElementById("boxname").innerHTML="Package Selected<br>"+boxes[index].name;
			document.getElementById("cost").innerHTML="";
			document.getElementById("cost").innerHTML=boxes[index].price;
			document.getElementById('order_button').innerHTML='';
			document.getElementById('order_button').innerHTML="<a onclick=\"setbox('order')\" class='orderbuttonboxes' href=\"#\">Order</a>";
			document.getElementById('fruit_of_the_month').innerHTML="";
			writeContactForm('choice', boxes, index);
			
		});
		
}
		
	
function pickSelect(){
		var boxes;
		var index= document.getElementById("selectMenu").selectedIndex;
		
		$.getJSON("http://www.fruit4london.co.uk/homes/select.json",null, function(boxes){
		//$.getJSON("/fruit4londontest/select.json",null, function(boxes){	
		//$.getJSON("/~goat/fruit4london/select.json",null, function(boxes){
			//boxes=eval(boxes);
			var content="";
			var qcontent='';
			document.getElementById("fruit").innerHTML="";
			content="Apples  x "+
						"<br/>Pears x "+"<br/>Bananas x "+"<br/>Clementines x "
						+"<br/>Peaches* x "+"<br/>Plums* x ";
			if (boxes[index].Nectarines >0){
				content=content+"<br/>Nectarines* x ";
			}
			if (boxes[index].Red_seedless_grapes >0){
				content=content+"<br/>Red Seedless Grapes x ";
			}
			if (boxes[index].White_seedless_grapes >0){
				content=content+"<br/>White Seedless Grapes x ";
			}
			if (boxes[index].Berries >0){
				content=content+"<br/> Berries x ";
			}
			document.getElementById("fruit").innerHTML=content;			
			document.getElementById("quantity").innerHTML="";
			qcontent=boxes[index].Apples+
						"<br/>"+boxes[index].Pears+"<br/>"+boxes[index].Bannanas+"<br/>"
						+boxes[index].Clementines+"<br/>"+boxes[index].Peaches+"<br/>"+boxes[index].Plums;
			if (boxes[index].Nectarines >0){
				qcontent=qcontent+"<br/>"+boxes[index].Nectarines;
			}
			if (boxes[index].Red_seedless_grapes >0){
				qcontent=qcontent+"<br/>"+boxes[index].Red_seedless_grapes;
			}
			if (boxes[index].White_seedless_grapes >0){
				qcontent=qcontent+"<br/>"+boxes[index].White_seedless_grapes;
			}
			if (boxes[index].Berries >0){
				qcontent=qcontent+"<br/>"+boxes[index].Berries;
			}
			document.getElementById("quantity").innerHTML=qcontent;
						
			
			document.getElementById("boxname").innerHTML="";
			document.getElementById("boxname").innerHTML="Package Selected<br>"+boxes[index].name;
			document.getElementById("cost").innerHTML="";
			document.getElementById("cost").innerHTML=boxes[index].price;
			document.getElementById("order_button").innerHTML="";
			
			document.getElementById("order_button").innerHTML="<a onclick=\"setbox('order')\" class='orderbuttonboxes' href=\"#\">Order</a>";
			document.getElementById('fruit_of_the_month').innerHTML="";
			writeContactForm('select', boxes, index);
		});
		
}
		

function writeContactForm($id, $boxes, $index){
	//var $web_link='http://www.fruit4london.com/';
	var $web_link='www.fruit4london.co.uk/homes/';
	var $content="I would like to order a "+ $boxes[$index].name + " box at a cost of " +document.getElementById('cost').innerHTML;
	var $subject="An order for an "+$boxes[$index].name+ " fruit box";
	
	var $form="<form  id='"+$id+"_form' name='contact form' action='contactemail.php' method='GET' class='contact_form' >"+
	"<fieldset><legend>e-mail form</legend><label for='email_subject'>Subject:</label><input type='text' name='subject' id='email_subject' value='"+$subject+"' ><br />"+
	"<label for='customer'>Your name:</label><input type='text' id='customer' name='customer' /><br />" +
	"<label for='"+$id+"_customer_email'> Your email:</label> <input type='text' id='"+$id+"_customer_email' name='customer_mail' onblur=\"validate('"+$id+"_form','"+$id+"_customer_email','"+$id+"_submit' )\"/><br /> "+
	"<label for='delivery'>Your delivery address: </label><input type='text' id='delivery' name='delivery'/><br /> "+
	"<label for='number'>Your phone number: </label><input type='text' id='number' name='number' onblur=\"validate('"+$id+"_form','"+$id+"_customer_email','delivery','number','"+$id+"_submit' )\" /><br /> \n"+
	" <textarea name='content' id='email_body' rows=5 columns= 80> "+$content+"  </textarea> <br />"+
	"<input class='submit' type='submit' id='"+$id+"_submit' disabled=TRUE value='Send e-mail'  /></fieldset></form> <br /> <a href='#' onclick=\"clearbox('order')\" > close </a>";
	document.getElementById('order').innerHTML="";
	document.getElementById('order').innerHTML=$form;
	
	
}	
			
	

