/*
function ajax_submit(form)
{
	var winId = 'popup' + (modalWindow.length-1);
	var container = $0($0(form).parents('#'+winId ).get(0));

	var data_multi = {};
	var data = {};

	$0(form).find('input, textarea, select, button').each(function(){
		if (/\[\]$/.test(this.name))
		{
			if (typeof(data_multi[this.name]) == 'undefined')
			{
				data_multi[this.name] = new Array();
			}

			if (this.checked)
			{
				data_multi[this.name].push($0(this).val());
				data[this.name] = data_multi[this.name];
			}
		}
		else
		{
			data[this.name] = $0(this).val();
		}
	})

	container.load($0(form).attr('action'), data, function(){
		showWindow({w:container}, true);
		var height = container.get(0).clientHeight*1 + 50;
		$0('#popupscript').css('height', height + 'px');
	});
}
*/
var winId;

function ajax_check_submit( id )
{	
	winId = 'popup' + (modalWindow.length-1);
	//we need only .modalWindowContent content here. If we update the whole 'window' content we loose the close by cross ability.
	
	//ATTENTION: if any script exists in a form response (e.g. google tracking in 'thank you' face) it will be executed twice:
	//first time in the frame and the second one when the frame's content is copied to the parent DOM.
	//To avoid this behavior you can wrap the form's script into [if (!window.frameElement){...}].
	//That will prevent inframe script execution.
	data = $0('#__for_popup_form_submission_' + id ).contents().find('body .modalWindowContent').html();
	if ( data.length > 0 )
	{
		var container = $0('#'+winId);
		container.find( '.modalWindowContent' ).html( data );
		showWindow({w:container}, true);
		
		var height = container.get(0).clientHeight*1 + 50;
		$0('#popupscript').css('height', height + 'px');
	}
}
