$(function()
{
	if($('.submitQ').size() > 0)
	{
		$('.submitQ, #newsletter').lightBox({
			boxObj: {
				submitQ: {
					boxContent: $('#submitQform').html(),
					width: 385,
					height: 460,
					animate: false,
					className: 'yellow',
					afterShown: function()
					{
						$('.replace').inputReplacer();
						if(Cufon)
							Cufon.replace('#lightbox-container-content .content h1', { fontFamily: 'DINPro-Bold' });
						$('#lightbox-content .loader').ajaxStart(function()
						{
							$(this).show();
						});
						$('#lightbox-content .loader').ajaxStop(function()
						{
							$(this).hide();
						});
						if($('#lightbox-content .close').size() > 0)
							$('#lightbox-content .close').click(function()
							{
								$.fn.lightBox.end();
							});
						if($('#lightbox-content form').size() > 0)
						{
							$('#lightbox-content form').submit(function()
							{
								$.getJSON('/index.php', { 
									c_: 'VALGPANELET_SubmitQuestion',
									m_: 'submit',
									name: $('#lightbox-content form input[name="name"]').val(),
									email: $('#lightbox-content form input[name="email"]').val(),
								 	message: $('#lightbox-content form textarea[name="message"]').val(),
								 	recipient: $('#lightbox-content form input[name="recipient"]').val()
								},
								function(transportJSON)
					   			{
						   			if(transportJSON.success == true)
						   			{
						   				$('#lightbox-content .content > *').fadeOut(200);
						   				$('#lightbox-content .content .feedback').fadeIn(1500, function()
								    	{
											var t1 = setTimeout(function()
											{
												$.fn.lightBox.end();
												clearTimeout(t1);
											}, 2500);
										});
						   			}
						   			else
									{
					   					$('#lightbox-content .error').html('<p>'+transportJSON.error+'</p>');
										if(Cufon)
											Cufon.replace('#lightbox-container-content .content .error', { fontFamily: 'DINPro-Bold' });
										$('#lightbox-content .content .error').fadeIn(500, function()
								    	{
											var t2 = setTimeout(function()
											{
												$('#lightbox-content .content .error').fadeOut(500);
												clearTimeout(t2);
											}, 3000);
										});
									}
								});
								return false;
							});
						}
					}
				}
			}
		});
	}
});