//------------------------------------------------------------------------------
//
// Common
//
//------------------------------------------------------------------------------

/**
 * Convenience function for inheritance
 *
 * @param parentClassOrObject
 */
Function.prototype.extend = function( parentClassOrObject ){
	if ( parentClassOrObject.constructor == Function ) {
		this.prototype = new parentClassOrObject;
		this.prototype.constructor = this;
		this.prototype.parent = parentClassOrObject.prototype;
	}
	else {
		this.prototype = parentClassOrObject;
		this.prototype.constructor = this;
		this.prototype.parent = parentClassOrObject;
	}
	return this;
};


//------------------------------------------------------------------------------
//
// Namespace definitions
//
//------------------------------------------------------------------------------

if( ! seatuk )
	var seatuk = function() {};

seatuk.forms = {};
seatuk.dealers = {};
seatuk.ui = {};


//------------------------------------------------------------------------------
//
// Address finder
//
//------------------------------------------------------------------------------

seatuk.addressfinder = {
	search : function(postcode, successCallback, failureCallback){
		
		$.ajax(
		{
			type: "GET",
			url: "/ws/addressfinder/postcode/"+postcode,
			contentType: "application/json; charset=utf-8",
			data: {},
			dataType: "json",
			success: function(data){
				if (data != null){
					if (successCallback){
						successCallback(data);
					}
				}else{
					if (failureCallback){
						failureCallback();
					}
				}
			},
			error: function(data){
				if (failureCallback){
					failureCallback();
				}
			}
		});
		
	}
};
