$(document).ready(function(){
	//submit button state
	if($("#agree").is(":checked")){
			$("#submitBtn").show();
			$("#submitGrey").hide();
	}else{
			$("#submitBtn").hide();
			$("#submitGrey").show();
		
	}
	
	//clear other Option text Area
	$("#otherOption").val("");
	
	//save textarea state
	$("#singleRadio").attr("checked", "checked")
	
	$(".radioOption").change(function(){		
		if($(this).val()=='other'){ $("#otherOption").show(); }
		else{ $("#otherOption").hide(); }		
	});
	
	$("#submitBtn").hover(
		function(){ $(this).css("cursor", "pointer") },
		function(){ $(this).css("cursor", "default") }
	);

	$("#agree").click(function(){
	
		if($(this).is(":checked")){
			$("#submitBtn").show();
			$("#submitGrey").hide();
		}else{
			$("#submitBtn").hide();
			$("#submitGrey").show();
		
		}
	
	});
	
	$("#submitBtn").click(function(){
		
		var error=true;
		
		if($("#contactName").val()==""){
			$("#error").html("<li> Contact Name is Mandatory");
			$("#error").show();
			window.location = "#error"
		}else{
			if($("#contactPhone1").val()==""){
				$("#error").html("<li> Direct Phone is Mandatory");
				$("#error").show();
				window.location = "#error"				
			}else{
				if($("contactEmail1").val==""){
					$("#error").html("<li>Email is Mandatory");
					$("#error").show();
					window.location = "#error"
				}else{
					$("#error").hide();
					error=false;
				}
			}
		}
		
		if(!error){
			error=true;
			if($("#lenderName").val()==""){
				$("#error").html("<li> Lender Name is Mandatory");
				$("#error").show();
				window.location = "#error"
			}else{
				if($("#lenderAddress").val()==""){
					$("#error").html("<li> Lender Address is Mandatory");
					$("#error").show();
					window.location = "#error"
				}else{
					if($("#lenderCity").val()==""){
						$("#error").html("<li> Lender City is Mandatory");
						$("#error").show();
						window.location = "#error"
					}else{
						if($("#lenderState").val()==""){
							$("#error").html("<li> Lender State is Mandatory");
							$("#error").show();
							window.location = "#error"
						}else{
							if($("#lenderZip").val()==""){
								$("#error").html("<li> Lender Zip is Mandatory");
								$("#error").show();
								window.location = "#error"
							}else{
								if($("#lenderNumber").val()==""){
									$("#error").html("<li> Lender Phone is Mandatory");
									$("#error").show();	
									window.location = "#error"
								}else{
									$("#error").hide();
									error=false;
								}
							}
						}
					}
				}
			}
		}
		
		if(!error){
			error=true;
			if($("#borrowerName").val()==""){
				$("#error").html("<li> Borrower Name is Mandatory");
				$("#error").show();
				window.location = "#error"
			}else{
				if($("#borrowerPhone").val()==""){
					$("#error").html("<li> Borrower Phone is Mandatory");
					$("#error").show();
					window.location = "#error"
				}else{
					if($("#propertyAddress").val()==""){
						$("#error").html("<li> Property Address is Mandatory");
						$("#error").show();
						window.location = "#error"
					}else{
						if($("#city").val()==""){
							$("#error").html("<li> Property City is Mandatory");
							$("#error").show();
							window.location = "#error"
						}else{
							if($("#state").val()==""){
								$("#error").html("<li> Property State is Mandatory");
								$("#error").show();
								window.location = "#error"
							}else{
								if($("#zip").val()==""){
									$("#error").html("<li> Property Zip is Mandatory");
									$("#error").show();	
									window.location = "#error"
								}else{
									$("#error").hide();
									error=false;
								}
							}
						}
					}
				}
			}
		}

		if(!error){
			$("#orderform").submit();
		}
	
	});//submit
});//docuemnt ready