﻿/**
@class Static class with all publish dialogs functionality.
*/
var StartDialogs = {};




/**
Open the "Buy Hosting Plan" dialog.
@param {Function}	callbackFunction	The function to call when the dialog is closed.
*/
StartDialogs.OpenStartDialog = function(callbackFunction)
{
	Tracking.TrackImEvent("editor_open_start_dialog/")
	var dialogElement = $('.start-dialog');
	//dialogElement.fadein();
	Dialogs.OpenDialogInternal(dialogElement, 980, function()
	{
		//dialogElement.ready(function(){dialogElement.fadeIn("slow")}) 
			Editor.EnableCheckOnClose(true);
	});

	dialogElement.find('.submit A').click(function()
	{
		Tracking.TrackImEvent("editor_click_buy_hosting/")
		// Upon submit...
		dialogElement.find('.progress').show();

		dialogElement.find('.paypal-form .hosted_button_id').val('T5EGA6JGL9FM6');
		dialogElement.find('.paypal-form .sucesss-return-url').val(Configuration.GetPaypalSuccessCallbackUrl(window.location.href));
		dialogElement.find('.paypal-form .cancel-return-url').val(Configuration.GetPaypalCancelCallbackUrl(window.location.href));
		dialogElement.find('.paypal-form .item-number').val(CurrentWebsite().vbId);
		dialogElement.find('.paypal-form .item-name').val(CurrentWebsite().vbId);
		Editor.EnableCheckOnClose(false);

		dialogElement.find('.paypal-form').submit();
		setInterval("Editor.EnableCheckOnClose(true);", 1000);
	});
}


/**
Close the "Buy Hosting Plan" dialog.
*/
StartDialogs.CloseStartDialog = function()
{
	
	var dialogElement = PublishDialogs.GetBuyHostingDialogElement();
	Dialogs.CloseDialogInternal(dialogElement);
}


