$(document).ready(function() {

//deklaracja formularza
var panel = document.createElement('div');
	panel.setAttribute('id', 'panel');
	
var dialog = document.createElement('div');
	dialog.setAttribute('id', 'dialog');
	
var formul = document.createElement('form');
	formul.setAttribute('id', 'formul');
	formul.setAttribute('name', 'formularz');
	formul.setAttribute('method', 'post');
	formul.setAttribute('action', 'email2.php');
	
	
var fieldset = document.createElement('fieldset');
	
		
var labelnazwa = document.createElement('label');
	labelnazwa.setAttribute('for', 'nazwa');
	labelnazwa.innerHTML="Imię i nazwisko:";
	
var inputnazwa = document.createElement('input');
	inputnazwa.setAttribute('type', 'text');
	inputnazwa.setAttribute('id', 'nazwa');
	inputnazwa.setAttribute('name', 'nazwa');
	inputnazwa.setAttribute('autocomplete', 'off');
	

var labelmiasto = document.createElement('label');
	labelmiasto.setAttribute('for', 'miasto');
	labelmiasto.innerHTML="Miasto:";
	
var inputmiasto = document.createElement('input');
	inputmiasto.setAttribute('type', 'text');
	inputmiasto.setAttribute('id', 'miasto');
	inputmiasto.setAttribute('name', 'miasto');
	inputmiasto.setAttribute('autocomplete', 'off');
	
var labeladres = document.createElement('label');
	labeladres.setAttribute('for', 'adres');
	labeladres.innerHTML="Adres e-mail:";
	
var inputadres = document.createElement('input');
	inputadres.setAttribute('type', 'text');
	inputadres.setAttribute('id', 'adres');
	inputadres.setAttribute('name', 'adres');
	inputadres.setAttribute('autocomplete', 'off');

var labeltelefon = document.createElement('label');
	labeltelefon.setAttribute('for', 'telefon');
	labeltelefon.innerHTML="Telefon:";
	
var inputtelefon = document.createElement('input');
	inputtelefon.setAttribute('type', 'text');
	inputtelefon.setAttribute('id', 'telefon');
	inputtelefon.setAttribute('name', 'telefon');
	inputtelefon.setAttribute('autocomplete', 'off');

var labelopis = document.createElement('label');
	labelopis.setAttribute('for', 'opis');
	labelopis.innerHTML="Opis zdarzenia:";
	
var textarea = document.createElement('textarea');
	textarea.setAttribute('name', 'opis');
	textarea.setAttribute('rows', '4');
	textarea.setAttribute('cols', '50');
	textarea.setAttribute('id', 'opis');
	textarea.setAttribute('width', '100');
	textarea.setAttribute('height', '20');
	textarea.setAttribute('autocomplete', 'off');
	
var submit = document.createElement('input');
	submit.setAttribute('type', 'submit');
	submit.setAttribute('value', 'wy¶lij');
	submit.setAttribute('id', 'submit');

	
var labelosw1 = document.createElement('label');
	labelosw1.setAttribute('for', 'osw1');
	labelosw1.setAttribute('id', 'labelosw1');
	labelosw1.innerHTML="O¶wiadczam, że jestem użytkownikiem lub wła¶cicielem wskazanego telefonu i poczty mailowej";
	
var inputosw1 = document.createElement('input');
	inputosw1.setAttribute('type', 'checkbox');
	inputosw1.setAttribute('value', 'tak');
	inputosw1.setAttribute('id', 'osw1');
	inputosw1.setAttribute('name', 'osw1');
	
var labelosw2 = document.createElement('label');
	labelosw2.setAttribute('for', 'osw2');
	labelosw2.setAttribute('id', 'labelosw2');
	labelosw2.innerHTML="Wyrażam zgodę na wykorzystywanie wskazanego telefonu i adresu mailowego dla celów informacyjnych o usługach Mediator sp.j.";
	
var inputosw2 = document.createElement('input');
	inputosw2.setAttribute('type', 'checkbox');
	inputosw2.setAttribute('value', 'tak');
	inputosw2.setAttribute('id', 'osw2');
	inputosw2.setAttribute('name', 'osw2');
	

var oswdiv1 = document.createElement('div');
	oswdiv1.setAttribute('class', 'oswdiv');
	oswdiv1.setAttribute('id', 'oswdiv1');
	
var oswdiv2 = document.createElement('div');
	oswdiv2.setAttribute('class', 'oswdiv');
	oswdiv2.setAttribute('id', 'oswdiv2');
	
var klik = document.createElement('a');
	klik.setAttribute('href', '#');
	klik.setAttribute('onClick', '_gaq.push([\'_trackPageview\',\'mini\']);');
	klik.setAttribute('class', 'slide_button');
	klik.setAttribute('id', 'butek');
	klik.innerHTML="Menu";

var labelwybor = document.createElement('label');
	labelwybor.setAttribute('for', 'selekcja');
	labelwybor.setAttribute('id', 'labelwybor');
	labelwybor.innerHTML="Temat problemu:";	

var wybor = document.createElement('select');
	wybor.setAttribute('name', 'selekcja');
	wybor.setAttribute('id', 'selekcja');
	
var option = document.createElement('option');
	option.setAttribute('value', 'wybierz temat');
	option.setAttribute('selected', 'selected');
	option.innerHTML="--wybierz temat--";
	
var option1 = document.createElement('option');
	option1.setAttribute('value', 'Wypadek w pracy');
	option1.innerHTML="Wypadek w pracy";
	
var option2 = document.createElement('option');
	option2.setAttribute('value', 'Wypadek rolniczy');
	option2.innerHTML="Wypadek rolniczy";
	
var option3 = document.createElement('option');
	option3.setAttribute('value', 'Wypadek z zaniedbania');
	option3.innerHTML="Wypadek z zaniedbania";
	
var option4 = document.createElement('option');
	option4.setAttribute('value', 'Wypadek komunikacyjny');
	option4.innerHTML="Wypadek komunikacyjny";

var option5 = document.createElement('option');
	option5.setAttribute('value', 'Szkoda komunikacyjna - osobowa');
	option5.innerHTML="Szkoda komunikacyjna - osobowa";
	
var option6 = document.createElement('option');
	option6.setAttribute('value', 'Polisy na życie, NW');
	option6.innerHTML="Polisy na życie, NW";
	
var option7 = document.createElement('option');
	option7.setAttribute('value', 'Wypadek na stoku');
	option7.innerHTML="Wypadek na stoku";
	
var option8 = document.createElement('option');
	option8.setAttribute('value', 'Szkoda budowlana');
	option8.innerHTML="Szkoda budowlana";
	
var option9 = document.createElement('option');
	option9.setAttribute('value', 'Błąd medyczny');
	option9.innerHTML="Błąd medyczny";
	
var option10 = document.createElement('option');
	option10.setAttribute('value', 'Inne');
	option10.innerHTML="Inne";
	


//ustawienie formularza	- dodawanie kolejnych pól
$('body').append(panel);
$('#panel').append(dialog);
$('#dialog').append(formul);
$('#formul').append(fieldset);
$('fieldset').append(labelnazwa);
$('fieldset').append(inputnazwa);
$('fieldset').append(labelmiasto);
$('fieldset').append(inputmiasto);
$('fieldset').append(labeladres);
$('fieldset').append(inputadres);
$('fieldset').append(labeltelefon);
$('fieldset').append(inputtelefon);
$('fieldset').append(labelwybor);
$('fieldset').append(wybor);
$('#selekcja').append(option);
$('#selekcja').append(option1);
$('#selekcja').append(option2);
$('#selekcja').append(option3);
$('#selekcja').append(option4);
$('#selekcja').append(option6);
$('#selekcja').append(option7);
$('#selekcja').append(option8);
$('#selekcja').append(option9);
$('#selekcja').append(option10);
$('fieldset').append(labelopis);
$('fieldset').append(textarea);
$('fieldset').append(oswdiv1);
$('#oswdiv1').append(labelosw1);
$('#oswdiv1').append(inputosw1);
$('fieldset').append(oswdiv2);
$('#oswdiv2').append(labelosw2);
$('#oswdiv2').append(inputosw2);
$('fieldset').append(submit);

$('#panel').append(klik);



$(function(){
	 
		$("#panel").css("right","-220px");
	 
		$("#panel").hover(function(){
			window.location.hash=('#mini');
			$("#panel").animate({right: "0px"}, {queue:false,duration:500} );
			$(this).addClass("index"); 
			$(this).addClass("zamknij"); 
			return false;
		},
		function(){	
			$("#panel").animate({right: "-220px"}, {queue:false,duration:500} );
			$(this).removeClass("index"); 
			$(this).removeClass("zamknij"); 
			return false;
		});
	 
	});
	
	$("#commentForm").validate();
	
	$("#formul").validate({
		rules: {
			
			nazwa: "required",
			miasto: "required",
			adres: {
				required: true,
				email: true
			},
			selekcja: "required",
			opis: "required",
			telefon: "required",
			osw1: "required",
			osw2: "required"
			},
		messages: {
			nazwa: "Proszę wpisać imię i nazwisko",
			miasto: "Proszę wspisać nazwę miasta",
			adres: "Proszę wpisać adres e-mail",
			selekcja: "Proszę określić temat",
			opis: "Proszę wpisać minimum 10 znaków",
			telefon:"Proszę wpisać numer telefonu",
			osw1: "Akceptacja jest warunkiem wysłania formularza",
			osw2: "Akceptacja jest warunkiem wysłania formularza"
		}
		
	});	
	
});
