
bcse_ship_submitted = false;

function bcse_ship_form_submit(){

	if(bcse_ship_submitted){
		return false;
	}else{
		bcse_ship_submitted = true;
	}

	var f = $('#userinfoform');

	var w = $('#product-ship-wrapper');
	var d = $('#product-ship-data');
	var l = $('#product-ship-loader');

	$.ajax({
		type: 'POST',
		url: f.attr('action'),
		data: f.serialize(),
		beforeSend: function(){
			l.css({opacity: 0, display: 'block'});
			var h = l.outerHeight();
			l.css({display: 'none', opacity: 1});

			w.animate({height: h + 'px'}, 200);
			d.fadeOut(200, function(){d.html('');});
			l.fadeIn(200);

		},
		success: function(data){

			setTimeout(function(){

			var el = document.createElement('div');
			document.body.appendChild(el);
			el = $(el);
			el.attr('id', 'product-ship-data');
			el.css({position: 'absolute', opacity: 0});
			el.html(data);
			var h = el.outerHeight(true);
			el.remove();

			d.html(data);
			w.animate({height: h + 'px'}, 200, function(){w.css('height', 'auto');});
			d.fadeIn(200);
			l.fadeOut(200);

			}, 200);

		},
		complete: function(){
			bcse_ship_submitted = false;
		}
	})

	return false;
}

