<!-- 
//Author: Rafał Bernaczek vel VRB
//Date: 9.09.2004

var nn = (document.layers)? true:false;
var ms = (document.all)? true:false;
var n6 = (document.getElementById) ? true:false;
var zmall = (ms)?('document.all.'):('document.layers');
var zmstyle = (ms)?('.style'):('');
if(n6){
	//objTopLayer = document.getElementById(id).style;
	var zmall = "document.getElementById('";
	var zmstyle = "').style";
}

function dodajDoUlubionych(){
	if (ms && window.external){
		window.external.AddFavorite('http://www.integrity.com.pl', 'Integrity');
	} else {
		alert("Aby dodać stronę do ulubionych naciśnij CTRL+D");
	}
}

function sciagajDoc(docName){
	openWindow("doc_download.xml?plik=" + docName, 600, 200, false);
}

function openWindow(file,szer,wys,scrollec){
	wys = (!wys)?(300):(wys);
	szer = (!szer)?(400):(szer);
	scrollec = (!scrollec)?('no'):('yes');
	if (ms) var xMax = screen.width, yMax = screen.height
	else if (nn) var xMax = window.outerWidth, yMax = window.outerHeight
	var xOffset = (xMax - szer)/2, yOffset = (yMax - wys)/2; 
	okienko = window.open(file,'PopupPanadol2004','scrollbars='+scrollec+',height='+wys+',width='+szer+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset);
}

//-----------------------------------------------------------------------------------
function createObject(divID) {
	if(document.layers){
		return document.layers[divID+'C'].document.layers[divID];
	}
	if(document.getElementById) {
		return document.getElementById(divID);
	}
	if(document.all) {
		return document.all[divID];
	}
	if(document[divID+'C']) {
		return document[divID+'C'].document[divID];
	}
	return false;
}

//Włącza lub wyłącza warstwę o podanej nazwie.
//Zwraca true lub false
function setVisible(ddivName, ddivStan){
	obj = createObject(ddivName);
	if (obj.style){
		obj.style.visibility = ddivStan;
	} else {
		if (obj){
			obj.visibility = ddivStan;
		} else {
			alert("Twoja przegladarka nie obsługuje tej funkcji!");
			return false;
		}
	}
	return true;
}

function srodek(){
	if (document.all) 
		return parseInt(document.body.clientWidth / 2);
	else 
		return parseInt(window.innerWidth / 2);
}


//Usuwa białe znaki
function trim(lancuch){
	while (lancuch.charAt(0) == " ") 
		lancuch = lancuch.substring(1,lancuch.length);
	while (lancuch.charAt(lancuch.length-1) == " ") 
		lancuch = lancuch.substring(0,lancuch.length-2);
	return lancuch;	
}

//Sprawdza, czy dada jest podana w formacie dd-mm-rrrr
function sprDate(txt) {
	if (txt.length != 10){
		return false;
	} else
		if (txt.indexOf("-") == -1 || txt.indexOf(".") > -1 || txt.indexOf(",") > -1 || txt.indexOf("-") != 2 || txt.substr(3,10).indexOf("-") != 2) {
			return false;
		} else
			if (!IsNum(txt.substr(0,2)) || !IsNum(txt.substr(3,2)) || !IsNum(txt.substr(6,4))){
				return false;
			} else
				if (txt.substr(3,2)>12 || txt.substr(3,2)<1 || txt.substr(0,2)>31 || txt.substr(0,2)<1)
					return false
				else
					return true
}

//Sprawdza poprawność maila
function CheckEMail(email){
	if (trim(email) == '')
		return false;
	if (email.indexOf('@') == -1)
		return false;
	if (email.length < 4)
		return false;
	if (email.indexOf('@') != email.lastIndexOf('@'))
		return false;
	if (email.indexOf(' ') != -1)
		return false;
	return true;
}

//Czy puste
function IsNum(txt){
	if (txt=='')
		return false;
		
	first=true;
	dot=false;
	for( i=0; i < txt.length; i++){
		switch (txt.charAt(i)){
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
			case '0':
				first=false;
				continue;
			case ',': 
			case '.':
				if (dot) return false;
				dot=true;
				first=false;
				continue;
			default:
				return false;
		}
	}
	return true;
}

function alertObowiazkowe(pole){
	alert("Pole '" + pole + "' jest obowiązkowe. Proszę je uzupełnić.");
}


//-----------------------------------------------------------
//AJAX
var req;

//Zapisanie danych
function loadXMLDoc(url) {
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = parsowanie;
		req.open("GET", url, true);
		req.send(null);
	//IE
	} else 
		if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
			if (req) {
				req.onreadystatechange = parsowanie;
				req.open("GET", url, true);
				req.send();
			}
		}
}

//Funkcja uruchamiana w momencie odpowiedzi serwera
function parsowanie() {
	//readyState = 
	//0 = niezainicjowane
	//1 = w trakcie pobierania
	//2 = pobrano
	//3 = interaktywne
	//4 = gotowe
	if (req.readyState == 4) {
		//status
		//200 = OK
		//404 = Nie odnaleziono
		//500 = Wewnętrzny błąd serwera
		if (req.status == 200) {
			odbieranie(req.responseXML);
		} else {
			if (req.status == 404)
				htmlAlert("404", blad404 + "<br><br><i>" + req.statusText + "</i>", true);
			else
				htmlAlert(req.status, bladInny + "<br><br><i>" + req.statusText + "</i>", true);
		}
	}
}

//Z podanego formularza spisywane są wszystkie pola do stringa
function parametryFormularza(form){
	if (form){
		doc = "?";
		for (q=0; q<form.length; q++){
			if (form[q].type == "checkbox"){
				doc = doc + form[q].name + "=";
				if (form[q].checked){
					doc = doc + form[q].value;
				}
				doc = doc + "&";
			} else {
				if (form[q].type == "radio"){
					if (form[q].checked){
						doc = doc + form[q].name + "=" + form[q].value + "&";
					}
				} else {
					doc = doc + form[q].name + "=" + form[q].value + "&";
				}
			}
		}
		return doc;
	} else {
		return false;
	}
}

//Funkcja dezaktywuje lub aktywuje wybrany formularz
function blokadaForma(form, stan){
	if (form){
		visibleStan = (stan)?('hidden'):('visible');
		for (q=0; q<form.length; q++){
			form[q].disabled = stan;
			if (form[q].type == "submit" || form[q].type == "reset"){
				form[q].style.visibility = visibleStan;
			}
		}
		return true;
	} else
		return false
}

//funkcja wyświetla w formularzu alert HTML
function htmlAlert(znaczek, opis, stan){
	stan = (stan)?('block'):('none');
	obj = createObject('trAlert');
	obj.style.display = stan;
	
	obj = createObject('opisAlertu');
	obj.innerHTML = opis;
	
	obj = createObject('znaczekAlertu');
	obj.innerHTML = znaczek;
}


function logoutPage(page){
	if (confirm("Ta strona znajduje się w sekcji dla klientów. Przejście na nią spowoduje automatyczne wylogowanie\nz części serwisu przeznaczonej dla firm partnerskich.\n\nCzy chcesz mimo to przejść na tą stronę?")){
		document.location.href = '/logout.xml?logout=1&page=' + page;
	}
}


//-->