// JavaScript Document
// --------------------------------------------
 
$(document).ready(function() { 
	// Show hide the previous lender is this is a refinance
	changeprevLender();
    $(":input[name='subproductid']").bind("click", changeprevLender);
}); 


// --------------------------------------------
function changeprevLender() {
    var isRefi = $('#subproductid_refi').attr('checked'); 
    if (isRefi)  {
	$('#prevlenderrow').show();
    } else {
	$('#prevlenderrow').hide(); 
    }
}


// --------------------------------------------
function initCityTown() {
    changeCity('propertycity', 'propertytown', selectedTown);
}

// --------------------------------------------
// Validates the form
var submitButton = null;

function validateOnSubmit(obj) {
  undoAutoformat(obj);
  if ((submitButton == 'cancel') || (submitButton == 'back')) {return true;}
    var errs=0;
    // execute all element validations in reverse order, so focus gets set to the first one in error.
	if (!validateRequired('propertytown', 'inf_propertytown', 'Boş bırakamazsınız.', true)) {errs ++; }
	if (!validateRequired('propertycity', 'inf_propertycity', 'Boş bırakamazsınız.', true)) {errs ++; }
	if (!validateRequired('duration', 'inf_duration', 'Rakam giriniz.', true)) {errs ++; }
    if (!validateNumber('creditamount', 'inf_creditamount', 'Rakam giriniz.', true)) {errs ++; }
    if (!validateNumber('propertyvalue', 'inf_propertyvalue', 'Rakam giriniz.', true)) {errs ++; }
	if (!validateRadio('foundproperty', 'inf_foundproperty', 'Boş bırakamazsınız.',true)) {errs ++; }
    if (!validateRadio ('credittype', 'inf_credittype', 'Boş bırakamazsınız.',true)) {errs ++; }
	if (errs > 0) doAutoformat();
	return (errs==0);
};


