function IncludeJavaScript(jsFile)
{
  document.write('<script type="text/javascript" src="'
    + jsFile + '"></scr' + 'ipt>');
}

function sendDataForm() {
	var orderTitle	 	= $('#ul5 li h5').html();
	var orderText 		= $('#ul5 li p').html();
	var fields = new Array( 'name', 'mail', 'phone', 'firm', 'address', 'city', 'postcode' );
	$('#create').click(function(){
		var nv = false;
		for(var i = 0; i < fields.length; i++ ) {
			if(!$('[name='+fields[i]+']').is('.unfocused')){
				$('[name='+fields[i]+']').addClass('msgxalert');
				$('[name='+fields[i]+']').focus(function(){
					$(this).removeClass('msgxalert');
				});
				nv = true;
			}
		}
		if(nv === true) {
			return;
		}
		else {
			$.post("/lib/sm.php", {
	            name		: $('[name='+fields[0]+']').val(),
				mail		: $('[name='+fields[1]+']').val(),
				phone		: $('[name='+fields[2]+']').val(),
				firm		: $('[name='+fields[3]+']').val(),
				address		: $('[name='+fields[4]+']').val(),
				city		: $('[name='+fields[6]+']').val(),
				postcode	: $('[name='+fields[7]+']').val(),
				packet		: 'Demo'
			},
			function(data){
		        if(data != 0) {}
		        	
		        else {
		        	$('#ul5 li h5').text('Dziękujemy');
		        	$('#ul5 li p').text('Twoje zamówienie zostało wysłane');
		        	var tr = setTimeout(function(){ 
		        		$('#ul5 li h5').html(orderTitle); 
		        		$('#ul5 li p').html(orderText);
		        		$('input, textarea').val('').focus().blur();
		        		clearTimeout(tr); 
		        	}, 5000)
		        }
		    });

		}
		
	});
}

$(document).ready(function() {
    var contactForm = new eform();
    sendDataForm();
});



