function hide_show_joint_form(mode) {
	if (mode == 'show') {
		$('#joint_form').show();
		$('#joint_link').hide();
		$('#id_joint_application').val('true');
	} else {
		$('#joint_form').hide();
		$('#joint_link').show();
		$('#id_joint_application').val('false');
	}
}
function validateApplication() {
	
	// applicant 1 info 
    if($('#application_type').val()=="") {
		alert("Please select an application type.")
    } else if($('#application_first_name1').val()=="Name") {
        alert("Please enter your name.")
    } else if($('#application_last_name1').val()=="Surname") {
        alert("Please enter your surname.")
    } else if($('#application_dob1').val()=="Date Of Birth") {
        alert("Please enter your date of birth.")
    } else if($('#application_occ_status1').val()=="") {
        alert("Please select your occupation status.")
    } else if($('#application_occ_desc1').val()=="Occupation") {
        alert("Please enter your occupation.")
    } else if ($('#application_annual_income1').val() == "Gross Annual Income") {
    	alert ("Please enter the gross annual income.")
    } else if($('#application_residence1').val()=="Country Of Residence") {
        alert("Please enter your country of residence.")
    } else if ($('#application_income_currency1').val() == "") {
    	alert ("Please enter your income currency.")
    }

    // applicant 2 info - only validate if joint_application == true
	else if ($('#application_first_name2').val() == "Name" && $('#id_joint_application').val() == "true") {
    	alert("Please enter the name of applicant 2.")
    } else if ($('#application_last_name2').val() == "Surname" && $('#id_joint_application').val() == "true") {
    	alert ("Please enter the surname of applicant 2.")
    } else if ($('#application_dob2').val() == "Date Of Birth" && $('#id_joint_application').val() == "true") {
    	alert ("Please enter the date of birth for applicant 2.")
    } else if ($('#application_occ_status2').val() == "" && $('#id_joint_application').val() == "true") {
    	alert ("Please enter the occupation status of applicant 2.")
    } else if ($('#application_occ_desc2').val() == "Occupation" && $('#id_joint_application').val() == "true") {
    	alert ("Please enter the occupation of applicant 2.")
    } else if ($('#application_annual_income2').val() == "Gross Annual Income" && $('#id_joint_application').val() == "true") {
    	alert ("Please enter the gross annual income of applicant 2.")
    } else if ($('#application_income_currency2').val() == "" && $('#id_joint_application').val() == "true") {
    	alert ("Please enter the income currency of applicant 2.")
    }
    
    // contact info
    else if($('#application_number').val()=="Contact Number") {
        alert("Please enter your contact number.")
    } else if($('#application_email').val()=="Email Address") {
        alert("Please enter your email address.")
    } else if(val_email('#application_email') == false){
        alert("Please enter a valid email address.")
    }
    
    // property info
    else if($('#application_property_country').val()=="") {
        alert("Please select where you would like to purchase property.")
    } else if($('#application_property_country').val()=="Other" && $('#application_property_country_other').val()=="Please Specify") {
        alert("Please select where you would like to purchase property.")
    } else if($('#application_property_type').val()=="") {
        alert("Please select the property type your interested in.")
    } else if($('#application_property_type').val()=="Other" && $('#application_property_type_other').val()=="Please Specify") {
        alert("Please select the property type your interested in.")
    } else if($('#application_mortgage_type').val()=="") {
        alert("Please select the type of mortgage.")
    } else if($('#application_currency').val()=="") {
        alert("Please select the currency of purchase.")
    }
    
    // mortgage info    
    else if($('#application_purchase_price').val()=="Purchase Price") {
        alert("Please enter the purchase price.")
    } else if($('#application_loan_required').val()=="Loan Required") {
        alert("Please enter the loan required.")
    
    } else if($('#application_funds_available').val()=="Funds Available") {
        alert("Please enter your funds available.")
    } else if($('#application_interest_rate').val()=="") {
        alert("Please select the desired interest rate type.")
    } 
    
    // source
    else if($('#application_source').val()=="") {
        alert("Please select where you heard about us.")
    } 
    
    // yay we can submit - eventually :)
    else {
        $("#applicationform").submit();    
    }        
}
function toggleOtherInput(elementID, otherElementID) {
    ($('#'+elementID).val()=='Other') ? disableInput = false : disableInput = true;
    document.getElementById(otherElementID).disabled = disableInput;
}
