if (typeof(newsletterSubscriptionObject) == 'undefined') 
{
    newsletterSubscriptionObject = function(objectName, useAlertResponse, ajaxEventUID, franchiseeId, successHandler)
    {
        this.objectName       = objectName;
        this.useAlertResponse = useAlertResponse;
        this.ajaxEventUID     = ajaxEventUID;
        this.franchiseeId     = franchiseeId;
        this.successHandler   = successHandler;
    }
}
newsletterSubscriptionObject.prototype.init = function()
{
    var currentObject     = this;
    this.defaultValue     = $('#' + this.objectName + '_Email').val();
    this.loaderHtml       = $('#' + this.objectName + '_Messagebox').html();
    $('#' + this.objectName + '_Messagebox').html('');
    $('#' + this.objectName + '_Messagebox').show();
    $('#' + this.objectName + '_Email').toggleVal();
    $('#' + this.objectName + '_Submit').click(function() {
        currentObject.submit()
    } );
    $('#' + this.objectName + '_Email').setEnterHandler(function() {
        currentObject.submit()
    } );
}
newsletterSubscriptionObject.prototype.submit = function()
{
    var currentObject = this;
    $('#' + this.objectName + '_Body').hide();
    $('#' + this.objectName + '_Messagebox').show();
    $('#' + this.objectName + '_Messagebox').html(this.loaderHtml);
    var email = $('#' + this.objectName + '_Email').val();
	
    var postData = {
        __callHandler: 'addNewsletterSubscriber',
        email: email,
        franchiseeId: this.franchiseeId
    };
    postData[currentObject.objectName + '__ajaxEventUID'] = this.ajaxEventUID;
	
    $.post(selfUrl, postData,
        function(responseData) {
            currentObject.onGetResponse(responseData);
        },
        'json');
}
newsletterSubscriptionObject.prototype.onGetResponse = function(responseData)
{
    if ((typeof(showAJAXDebugInfo) != 'undefined') && responseData.PHPAJAXDebug != null) 
    {
        showAJAXDebugInfo(responseData.PHPAJAXDebug.Info, responseData.PHPAJAXDebug.Owner);
    }

    if (responseData.Response.Code == 1)
    {
        $('#' + this.objectName + '_Body').show();
        $('#' + this.objectName + '_Messagebox').hide();
        alert(responseData.Response.Message);
    }
    else
    {
        $('#' + this.objectName + '_Email').val(this.defaultValue);
        if (!this.useAlertResponse)
        {
            $('#' + this.objectName + '_Messagebox').html(responseData.Response.Message);
        }
        else
        {
            $('#' + this.objectName + '_Body').show();
            $('#' + this.objectName + '_Messagebox').hide();
            alert(responseData.Response.Message);
        }

        if (responseData.Response.Code == 2) {
			if(undefined===pageTracker){
				var pageTracker = _gat._getTracker("UA-880487-1");
				pageTracker._setDomainName(".granitetransformations.com");
			}
				pageTracker._trackPageview('/occa/subscribe-to-our-newsletter/thank-you/');
			
	 		if(this.successHandler)
				this.successHandler();
		}
 			
    }
}