// JavaScript Document


$(document).ready(function(){  
			$("#WildPhoneMake").change(onMakeChange);  
			$("#WildPhoneModel").change(onModelChange); 
			$("#WildPhoneService").change(onServiceChange);
			$("#makeoutput").show(); // hide
			$("#nojavascript").hide(); // hide
			
			$("#WildPhoneAddForm").validate();
		});  
		
		function onMakeChange(){
			$("#priceoutput").hide(); // hide
			var selected = $("#WildPhoneMake option:selected");
			if(selected.val()==""){
				$("#priceoutput").hide(); // hide
				$("#modeloutput").hide(); // hide
				$("#serviceoutput").hide(); // hide
			
			} else {
				$("#WildPhoneTextmake").val(selected.text());
				$("#WildPhoneModel").load("/PriceList/getModels/"+selected.val());
				$("#serviceoutput").hide(); // hide
				$("#modeloutput").hide(); // hide
				$('#modeloutput').fadeIn("slow"); // then fade in
			}
		}
		
		function onModelChange(){
			var selected = $("#WildPhoneModel option:selected");	
			if(selected.val()=="0"){
				$("#serviceoutput").hide(); // hide
				$("#priceoutput").hide(); // hide
			} else {
				$("#WildPhoneTextmodel").val(selected.text());
				$("#WildPhoneService").load("/PriceList/getServices/"+selected.val());
				$("#serviceoutput").hide(); // hide
				$('#serviceoutput').fadeIn("slow"); // then fade in
			}
		}
		
		function onServiceChange(){
			var selected = $("#WildPhoneService option:selected");	
			
			// get the price .. and then display the data
			if(selected.val()=="0"){
				$("#priceoutput").hide(); // hide
			} else {
				$("#WildPhoneTextservice").val(selected.text()); 
				$("#priceoutput").hide(); // hide
				$('#priceoutput').fadeIn("slow"); // then fade in
				$('#calculated').text(selected.val());
			}
		}
		