$(document).ready(function(){ 
		$('#property_type_fields').hide();
	
      $('#sidebar ul ul').hide();
		$('#sidebar ul ul li:first-child').parent().parent().find('a').not('ul ul a').toggle(function(){
			$(this).next('ul').slideDown('fast');
		}, function(){
			$(this).next('ul').slideUp('fast');
		})		
		$('#locations_menu, #loc_label').hide();
		$('#pickup').click(function(){
			if ($(this).is(':checked')){
				$('#locations_menu, #loc_label').show();
			}
		})
		$('#mail').click(function(){
			if ($(this).is(':checked')){
				$('#locations_menu, #loc_label').hide();
			}
		})
		$("input[name='property_type']").click(function(){
		     if ($("input[name='property_type']:checked").val() == 'vacantland')
					$('#property_type_fields').hide();
		     else
				$('#property_type_fields').show();
		});
		$("input[name='company_type_seller']").click(function(){
		     if ($("input[name='company_type_seller']:checked").val() == 'N') {
					$('#company_type_seller_fields').hide();
					$('#company_type_seller_fields_2').hide();
				}
		     else {
				
				$('#company_type_seller_fields').show();
				$('#company_type_seller_fields_2').show();
			}	
		});
		$("input[name='refi']").click(function(){
		     if ($("input[name='refi']").is(":checked")) {
					$('#company_type_seller_fields').hide();
					$('#company_type_seller_fields_2').hide();
				}
		     else {
				
				$('#company_type_seller_fields').show();
				$('#company_type_seller_fields_2').show();
			}	
		});
		$("#form").submit(function() {
		if(validateForm() == false) {
			return false;
		}
		            });
		$('.promo .closing101').click(function(e){
			e.preventDefault();
			$('body').append('<div id="popupshade"></div><div id="flashbox"><a href="#" id="closeflashbox">Close Window</a><iframe src="/Choice_Flash.html" width="750" height="550"><p>Your browser does not support iframes.</p></iframe></div>');
			$('#closeflashbox').click(function(e){
				e.preventDefault();
				$('#popupshade, #flashbox').remove();
			})
		})
  });
	$('input[name="company_type_borrower"]').click(function(){
		alert($('input[name="property_type"]:checked').val());
	})
	function validateForm() 
	{ 


	    var company_type_borrower       = $('input[name="company_type_borrower"]:checked').val();
	    var company_type_seller         = $('input[name="company_type_seller"]:checked').val();
		var borrowername    			=  $('input[name="borrowername"]').val();
	    var loan_payoffs    			=  $('input[name="loan_payoffs"]').val();
	    var property_address   			=  $('input[name="property_address"]').val();
	    var parish	 	 	  			=  $('select[name="parish"]').val();
	    var property_type    			=  $('input[name="property_type"]:checked').val();
	    var loan_amount 	  			=  $('input[name="loan_amount"]').val();
	    var mortgage_type    			=  $('input[name="mortgage_type"]:checked').val();
	    var assignment_of_mortgage		=  $('input[name="assignment_of_mortgage"]:checked').val();
	    var notice_of_seizure    		=  $('input[name="notice_of_seizure"]:checked').val();
	    var person_name    				=  $('input[name="person_name"]').val();
	    var phone    					=  $('input[name="phone"]').val();
	    var address    					=  $('input[name="address"]').val();
	    var email_address    			=  $('input[name="email_address"]').val();
	  
	    var errors                 = 0; 

	    if (company_type_borrower == null || company_type_borrower == '') 
	    {  
	        errors++; 	
	    } 
	    if (borrowername == null || borrowername == '') 
	    { 
	        errors++; 
	    } 
	    if (company_type_seller == null || company_type_seller == '') 
	    { 
	        errors++; 
	    }
		if (loan_payoffs == null || loan_payoffs == '') 
	    { 
	        errors++;
		}    
		if (property_address == null || property_address == '') 
	    { 
	        errors++;
	    }    
		if (parish == null || parish == '') 
	    { 
	        errors++;
	    }    
		if (property_type == null || property_type == '') 
	    { 
	        errors++;
	    }    
  	if (loan_amount == null || loan_amount == '') 
	    { 
	        errors++;
	    }    
  	if (mortgage_type == null || mortgage_type == '') 
	    { 
	        errors++;
	    }    
     	if (assignment_of_mortgage == null || assignment_of_mortgage == '') 
 	    { 
	        errors++;
 	    }    
     	if (notice_of_seizure == null || notice_of_seizure == '') 
	    { 
	        errors++;
	    }    
     	if (person_name == null || person_name == '') 
	    { 
	        errors++;
	    }    
     	if (phone == null || phone == '') 
	    { 
	        errors++;
	    }    
     	if (address == null || address == '') 
	    { 
	        errors++;
	    }    
     	if (email_address == null || email_address == '') 
  	{ 
	        errors++;
  	}

	    if (errors > 0) 
	    { 
	        alert ("Please make sure that all fields are filled in."); 
	        return false; 
	    } 

	}
	
	function clearForm() {
	if (confirm("Are you sure you want to request a new quote?  This will clear the form.")) {
	document.quoteform.reset();
	}
	}