// JavaScript Document

function Validate()	{
	

	var formErrors = true;
	var nextMove  = false;
	var curr;
	var currLength;
	$('.reqfield',document.forms[0]).each(function(){
												   /*curr = $(this).attr("name");
												   currLength = $(this).val().length;
												   console.log("%d length: %d", curr, currLength);*/
		if (!$(this).val().length) {
				$(this).keydown(function() {
					$(this).parent().next().css("display","none");
				});
				$(this).parent().next().css("display","block");
				//alert($(this).next());
				formErrors = false;
		}
	});
	
	
	return formErrors;
}
	


function PrepareForm() {
	
   $("#contactSubmit").click(function(){
   		return (Validate());
 	});
   
   $("#ddWidth").change(function(){
									   //alert($(this).val());
    $.getJSON("/classes/ajax_quote.php",{width: $(this).val(), ajax: 'true'}, function(j){
      var options = '';
      for (var i = 0; i < j.length; i++) {
        options += '<option>' + j[i].optionDisplay + '</option>';
      }
	  //alert(options);
	  $("#ddLength").children("option").each(function(){
                $(this).remove();
        }).end().css('background-color','#0096B7').append(options).animate({backgroundColor:'white'}, "slow"); ;
    })
  }) 
}
 
  $(document).ready(PrepareForm);