﻿function BarOwnerSignUpWizard() {
    this.frm = { BarID: -1 };
}

BarOwnerSignUpWizard.prototype.readForm = function() {
	var vals = jQuery('#main-form').formToArray();
	for (var i in vals)
		this.frm[vals[i].name] = vals[i].value;
};

BarOwnerSignUpWizard.prototype.backTo = function(num) {
	this.readForm();
	f_map = null;
	f_marker = null;
	jQuery('.ajax_anim').css('display', 'inline');
	jQuery('#main_content').load(__root + 'BarOwner/Load/Step' + num, this.frm);
};

BarOwnerSignUpWizard.prototype.submit = function(num) {
	var th = this;
	this.readForm();
	f_map = null;
	f_marker = null;
	jQuery('.ajax_anim').css('display', 'inline');
	jQuery.get(__root + 'BarOwner/Run/SubmitSignUpStep' + num, this.frm, function(resp) {
		jQuery('#main_content').html(resp);
		th.readForm();
	});

};

BarOwnerSignUpWizard.prototype.findBars = function() {
	jQuery('#right-panel').css('display', 'none');
	var p = jQuery('#found_bars');
	p.html('<img src="' + __root + 'content/images/load_circle.gif" alt="loading..." style="margin:10px 0 10px 45%;"/>');
	p.load(__root + 'BarOwner/Load/FoundBars', { NeighborhoodToFind: jQuery('#NeighborhoodToFind').val(), BarNameToFind: jQuery('#BarNameToFind').val() });
};

BarOwnerSignUpWizard.prototype.selBar = function(id) {
	this.frm.BarID = id;
	jQuery('.found-bar').removeClass('active');
	jQuery('#bar-' + id).addClass('active');
};

BarOwnerSignUpWizard.prototype.newBar = function () {
    this.frm.BarID = 0;
    this.submit(3);
}
