<!--
var emailName = null;
$(document).ready(function()
{
	var contactForm = document.createElement('DIV');
	$(contactForm).attr("id", "contactForm");
	$(contactForm).attr("title", "Formularz kontaktowy");
	$(contactForm).hide();
	$(contactForm).html('<div id="form"><table cellpadding="0" cellspacing="0" style="font-size:12px"><tr><td>Temat:</td></tr><tr><td><input id="subject" type="text" style="width:250px;" /><br/><br/></td></tr><tr><td>Wiadomość:</td></tr><tr><td><textarea id="message" rows="5" cols="50"></textarea></td></tr><tr><td>&nbsp;</td></tr><tr><td>E-mail lub telefon kontaktowy:</td></tr><tr><td><input id="contact" type="text" style="width:150px;" /><br/><br/></td></tr><tr><td><input type="button" id="sendButton" value="Wyślij" /></td></tr><tr><td>&nbsp;</td></tr><tr><td><img id="loader" src="images/ajax-loader.gif" mce_src="images/ajax-loader.gif" /><div id="info"></div></td></tr></td></tr></table></div>');
	document.body.appendChild(contactForm);
	$(contactForm).dialog({
           autoOpen: false,
           modal: true,
           height: 350,
           width: 500
       });
	
	$("img#loader").hide();
	$("#message").focus(function() { $(this).html(""); });
	
    $("input#sendButton").click(function()
	{
		disableForm();
	$.post("index.php?module=Contact&type=ajax", {emailName: escape(emailName),  subject: escape($("#subject").val()), contact: escape($("#contact").val()), message: escape($("#message").val()) },
  		function(xml)
		{
			if($(xml).find("contact").text() == 1)
			{
				$("div#info").html('<div style="color:#00FF00">Wiadomość została poprawnie wysłana.</div>');
			}
			else
			{
				$("div#info").html('<div style="color:#FF0000">Wystąpił błąd podczas wysyłania wiadomości, spróbuj jeszcze raz.</div>');
				enableForm();
			}
			$("img#loader").hide();
  		}, "xml");
	$("div#info").html("Trwa wysyłanie...");
	$("img#loader").show();
	});
	
    return false;
});

function disableForm()
{
	$('#subject').attr("disabled", true);
	$('#message').attr("disabled", true);
	$('#contact').attr("disabled", true);
	$('#sendButton').attr("disabled", true);
}
function enableForm()
{
	$('#subject').removeAttr("disabled"); 
	$('#message').removeAttr("disabled"); 
	$('#contact').removeAttr("disabled"); 
	$('#sendButton').removeAttr("disabled"); 
}
function contactForm(name)
{

	/*var generator=window.open('about:blank');
	generator.document.open();
	generator.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">');
	generator.document.write('<head><title>Formularz kontaktowy</title><link rel="stylesheet" href="themes/energa/style/style.css" type="text/css"/></head><body>');
	generator.document.write('<div id="form"><table cellpadding="0" cellspacing="0" class="flat"><tr><td>Wiadomość:</td></tr><tr><td><textarea id="message" rows="5" cols="50">Wpisz tutaj wiadomość...</textarea></td></tr><tr><td>&nbsp;</td></tr><tr><td>E-mail lub telefon kontaktowy:</td></tr><tr><td><input id="contact" type="text" style="width:150px;" /></td></tr><tr><td>&nbsp;</td></tr><tr><td><input type="button" id="sendButton" value="Wyślij" /></td></tr><tr><td>&nbsp;</td></tr><tr><td><img id="loader" src="images/ajax-loader.gif" mce_src="images/ajax-loader.gif" /><div id="info"></div></td></tr></td></tr></table></div>');
	generator.document.write('</body></html>');
	generator.document.close();*/
	//alert(name);
	emailName = name;
	$("#subject").val('');
	$("#message").val('');
	$("#contact").val('');
	$("div#info").html('');
	enableForm();
	$("#contactForm").dialog('open');
}

// -->
