function UmowaTermin(){

	dateVar = new Date(document.getElementById('rokid').value, document.getElementById('miesiacid').value, 30, 23, 59, 0);
	dateVar1 = new Date(document.getElementById('endrok').value, document.getElementById('endmies').value, document.getElementById('enddzien').value, 23, 59, 0);
	dateVar2 = new Date(document.getElementById('startrok').value, document.getElementById('startmies').value, document.getElementById('startdzien').value, 00, 00, 0);
if (dateVar > dateVar1 || dateVar < dateVar2) {
	
	
		alert("Okres przyznania punktów poza okresem trwania umowy");
		
		return false;
	} 
	
	
	return true;
}






function error(tekst) {
	if (errfound) return;
		window.alert(tekst);
errfound = true;
}

function zgloseminariumwer() {
	errfound = false;
	
	var bledy = "";
		if (document.formzgloszenie.polityka.checked != true)  bledy += "Proszę zaznaczyć pole z \"Akceptuje polityke prywatności\" . \n";
		
		
		if (bledy != "")  error(bledy); 

return !errfound;
}



function akceptacjapolityki() {
	errfound = false;
	var bledy = "";
		if (document.polit.regulamin.checked == "")  bledy += "Proszę zaznaczyć pole z \"Akceptuje regulamin\" .";
		if (bledy != "")  error(bledy); 

return !errfound;
}



function addnewuser() {
	errfound = false;
	var bledy = "";
		if (document.getElementById('email').value == "")  bledy += "Pole e-mail jest puste. \n";
		if (!email_validate(document.getElementById('email').value))  bledy += "Adres e-mail jest nieprawidłowy. \n";
		if (document.getElementById('imie').value=="")  bledy += "Proszę podać imię. \n";
	
		if (document.getElementById('firma').checked==true){
			
		if (document.getElementById('nazwa').value=="")  bledy += "Proszę podać nazwe firmy. \n";
		}  
		
		
		if (document.getElementById('umowa').checked==true){
			
		if (document.getElementById('nrumowaid').value=="")  bledy += "Proszę podać numer umowy. \n";
		if (document.getElementById('nazwaumowaid').value=="")  bledy += "Proszę podać imię i nazwisko klienta na którego jest podpisana umowa. \n";
		if (document.getElementById('produkt').value=="")  bledy += "Proszę produkt którego dotyczy umowa. \n";
		if (document.getElementById('kwotaumowaid').value=="")  bledy += "Proszę produkt składke roczną umowy. \n";
		} 
		
		if (bledy != "")  error(bledy); 

return !errfound;
}


function addumowapolecenie() {
	errfound = false;
	var bledy = "";
	
	if (document.getElementById('zaproszenie').checked==true){
		if (document.getElementById('email').value == "")  bledy += "Pole e-mail jest puste. \n";
		if (!email_validate(document.getElementById('email').value))  bledy += "Adres e-mail jest nieprawidłowy. \n";
		if (document.getElementById('imie').value=="")  bledy += "Proszę podać imię. \n";
	}
	
	
		if (document.getElementById('nrumowaid').value=="")  bledy += "Proszę podać numer umowy. \n";
		if (document.getElementById('nazwaumowaid').value=="")  bledy += "Proszę podać imię i nazwisko klienta na którego jest podpisana umowa. \n";
		if (document.getElementById('produkt').value=="")  bledy += "Proszę produkt którego dotyczy umowa. \n";
		if (document.getElementById('kwotaumowaid').value=="")  bledy += "Proszę produkt składke roczną umowy. \n";

		
		if (bledy != "")  error(bledy); 

return !errfound;
}


function addumowasuper() {
	errfound = false;
	var bledy = "";

	
	
		if (document.getElementById('nrumowaid').value=="")  bledy += "Proszę podać numer umowy. \n";
		if (document.getElementById('nazwaumowaid').value=="")  bledy += "Proszę podać imię i nazwisko klienta na którego jest podpisana umowa. \n";
		if (document.getElementById('produkt').value=="")  bledy += "Proszę produkt którego dotyczy umowa. \n";
		if (document.getElementById('kwotaumowaid').value=="")  bledy += "Proszę produkt składke roczną umowy. \n";

		
		if (bledy != "")  error(bledy); 

return !errfound;
}





















function kalkulacja(){
var wynik	
var wspolczynnik = document.getElementById('wspolczynnik').value	
var skladka = document.getElementById('skladka').value		
var skladkamin = document.getElementById('stawkamin').value

		if(skladka==0){
		
		return document.getElementById('punkty').innerHTML = 0;
		
	}
	
	wynik = skladka/wspolczynnik;

	
	return document.getElementById('punkty').innerHTML =  wynik.toFixed(2);
	
}














function showwindows(width, height){
var Win = window.open("print.php","displayWindow",'width=' + width + ',height=' + height +  ',resizable=0,scrollbars=yes,menubar=no' );
}


function showwin(id,width, height){
var Win = window.open("windows.php?id="+id,"displayWindow",'width=' + width + ',height=' + height +  ',resizable=0,scrollbars=yes,menubar=no' );
}


function show_hiden_div(identyfikator) { 
	
if(document.getElementById(identyfikator).style.display == "none"){
	
document.getElementById(identyfikator).style.display = "inline";
	
}else{
document.getElementById(identyfikator).style.display = "none";	

	
}
}



function TrackCount(fieldObj,countFieldName,maxChars)
{
	var countField = eval("fieldObj.form."+countFieldName);
	var diff = maxChars - fieldObj.value.length;

	if (diff < 0)
	{
		fieldObj.value = fieldObj.value.substring(0,maxChars);
		diff = maxChars - fieldObj.value.length;
	}
	document.getElementById(countFieldName).innerHTML = diff;
}

function LimitText(fieldObj,maxChars)
{
	var result = true;
	if (fieldObj.value.length >= maxChars)
	result = false;

	if (window.event)
	window.event.returnValue = result;
	return result;
}

function liczby(x){
x.value=x.value.replace(/\D/g,'')
}

function doublelicz(x){
var x;	

	x.value = x.value.replace(',','.');
	
		x.value = x.value.replace(/[^\d\.\,]+/g, '')
		

}





function email_validate(src) 
{
  var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
  return regex.test(src);
}




function error_nul(element) {
	
document.getElementById(element).className = 'error_null';

        }

function ok_elemnt(element) {
	
document.getElementById(element).className = 'inputform';

        } 



function readfile(val,val1,file,target){
advAJAX.get({
  url: file,
	parameters : {
    "par" : val,
    "par1" : val1
  },
  onSuccess : function(obj) { 
  	document.getElementById(target).innerHTML = obj.responseText;
  },
onLoading : function(obj) {
document.getElementById(target).innerHTML= '<img src="img/loading.gif"/>';
},
  onError : function(obj) { 
    alert("Error: " + obj.status); 
  }
});
}




function CheckEditMail(e1,e2,target){
	
	if(e1!=e2.value){
		
		if(email_validate(e2)){
			
			document.getElementById(target).innerHTML = 'Adres email jest nie prawidłowy!!!'
			
		}else{
			
		readfile(e2.value,'','inc/ajax/checkeditmail.php',target)	
			
			
		}
		
		
	}else{
		
		document.getElementById(target).innerHTML = ''
		
	}

}




function CheckMailSeminarium(e,target){
	
	if(e.value!=""){	readfile(e.value,'','inc/ajax/mailzap.php',target)	}
}







/***********************************************
* Cool DHTML tooltip script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="img/arrow2.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip      


