function openUrl(url) {
	var Win = window.open(url);
}

function showStats(){
	var mon = $("#StatsMonth").val();
	var year = $("#StatsYear").val();
	
	$("#DataStats").html('<div style="text-align:center; margin-top:100px; margin-bottom:100px;"><img src="template/img/preloader.gif" /></div>');
	  
	$.post("getstats,Stats.html", { mon:mon, year:year },
	  function(data){		
		$("#DataStats").html(data).hide();
		$("#DataStats").fadeIn("slow");

	  });
}

function ShowNickForm() {
	
	$("#formMessTxt").hide();
	
	$("#formMessNick").html('<p style="text-align:center; margin-top:70px; margin-bottom:70px;"><img src="template/img/preloader.gif" /></p>');
 		
 		var value = document.getElementById('MessLit').value;
 		
        $.post("getmessagform,dane.html", { value: value, part: 2 },
		  function(data){ 
		    $("#formMessNick").html(data);
		  });
}

function ShowTxtForm() {

	$("#formMessTxt").show().html('<p style="text-align:center; margin-top:70px; margin-bottom:70px;"><img src="template/img/preloader.gif" /></p>');
 		
 		var value = document.getElementById('MessLog').value;
 		
        $.post("getmessagform,dane.html", { value: value, part: 3 },
		  function(data){ 
		    $("#formMessTxt").html(data);
		  }); 
}

function ShowMessages() {
	
	$("#view").html('<p style="text-align:center; margin-top:70px; margin-bottom:70px;"><img src="template/img/preloader.gif" /></p>');
 	
	$.post("getmessagform,dane.html", { part: 5 },
		  function(data){ 
		    $("#view").html(data);
		  }); 
}

function showMessg(idw) {

	$("#view").html('<p style="text-align:center; margin-top:70px; margin-bottom:70px;"><img src="template/img/preloader.gif" /></p>');
 	
	$.post("getmessagform,dane.html", { part: 6, idw: idw },
		  function(data){ 
		    $("#view").html(data);
		  }); 
}

function delMessg(idw) {

	var x=window.confirm("Are you sure?");
	
	if (x) {
	$("#view").html('<p style="text-align:center; margin-top:70px; margin-bottom:70px;"><img src="template/img/preloader.gif" /></p>');
 	
	$.post("getmessagform,dane.html", { exec: 'del', idw: idw },
		  function(data){ 
		    $("#view").html(data);
		  }); 
	}
}

function showTypsSelect() {
	
	$("#TypSelOdds").hide();

	$("#TypSelTyps").html('<div style="text-align:center; margin-top:100px; margin-bottom:100px;"><img src="template/img/preloader.gif" /></div>');
	var value = document.getElementById('typsel_iddys').value;
 		
        $.post("gettypselect,dane.html", { value: value, part: 2 },
		  function(data){ 
		    $("#TypSelTyps").html(data);
		  });
}

function showTypsOdds() {
	
	var value = document.getElementById('typsel_nr').value;
 	
 	$("#TypSelOdds").html('<div style="text-align:center; margin-top:100px; margin-bottom:100px;"><img src="template/img/preloader.gif" /></div>');
	 
 	
        $.post("gettypselect,dane.html", { value: value, part: 3 },
		  function(data){ 
		    $("#TypSelOdds").html(data);
		  });
		  
	$("#TypSelOdds").show();	  
}


$(function () {
    $('div.tabs ul.tabNavigation a').click(function () {
        var warstwa = this.href; 
       
 		$("#view").html('<p style="text-align:center; margin-top:100px; margin-bottom:100px;"><img src="template/img/preloader.gif" /></p>');
 		
        $.post("getkonto,dane.html", { warstwa: warstwa },
		  function(data){ 
		    $("#view").html(data);
		  });  
		  
		$('div.tabs ul.tabNavigation a').removeClass('selected');
        $(this).addClass('selected');
		  
    });
});


$().ready(function() {
		
	$(".toolTypek").wTooltip({content: POSTAW }); 
	
		$("#kontaktForm").validate({
				rules: {
					KONimie: "required",
					KONmail: "required",
					KONtresc: "required",
					KONkod: "required",
					
					KONmail: {
					required: true,
					email: true
					}
				}
			});
		
		$("#typujForm").validate({
				rules: {
					TYPspotkanie: "required",
					TYPtypek: "required",
					TYPstawka: "required",
					TYPkurs: "required",
					TYPczas: "required",
					TYPdzien: "required",
					
				
					TYPstawka: {
						required: true,
						max: 30
					},
					TYPkurs: {
						required: true,
						min: 1.40,
						number: true	
					},
					TYPdzien: {
						required: true,
						date: true
					}	
				}
			});
		
		
		$("#registerForm").validate({
			rules: {
				REGlogin: "required",
				REGpassword: "required",
				REGrepassword: "required",
				REGmail: "required",
				
				REGlogin: {
					required: true,
					minlength: 2,
					maxlength: 10,
					remote: {
						 url: "checkRegister,Register.html",
        				type: "post"
					}
				},
				REGpassword: {
					required: true,
					minlength: 4
				},
				REGrepassword: {
					required: true,
					minlength: 4,
					equalTo: "#REGpassword"
				},
				REGmail: {
					required: true,
					email: true,
					remote: {
						 url: "checkRegister,Register.html",
        				type: "post"
					}
				}
			}
		});
});
