// SmART MeDiA AdvertisinG

function preload(){
		if(document.images){
			Open = new Image(12,12);    
			Closed = new Image(12,12);
			Open.src = "grafika/secms/secms_zwin.gif";
			Closed.src = "grafika/secms/secms_rozwin.gif"
		}
}

function showhide(what_id,what2_id,what3_id)
{
				var what=document.getElementById(what_id);  
				if(what2_id!=''){
					var what2=document.getElementById(what2_id);  
				}
				if(what3_id!='') {
					var what3=document.getElementById(what3_id);  
				}

				if (what.style.display=='none')
				{
					what.style.display='';
					if(what2) what2.src=Open.src;
					if(what3) what3.innerHTML='schowaj';
				}
				else
				{
					what.style.display='none';
					if(what2) what2.src=Closed.src;
					if(what3) what3.innerHTML='pokaż';
				}
}

// funkcja sprawdzajaca poprawnosc numerow telefonow
function ValidPhoneNumber(item1,item2) {
	wzorzec1 = /^\+48\s\(\d\d\)\s[1-9]\d\d\-\d\d\-\d\d$/;
	wzorzec2 = /^\+48\s\(\d\d\d\)\s[1-9]\d\d\-\d\d\d$/;
	
	if( item1 == "" && item2 == ""){
		error(document.przyslij.uz_tel_st,"Proszê podaæ telefon kontaktowy.");  
		return false;
	}
	
	if( item1 == "+48 (00) 000-00-00" && item2 == "+48 (000) 000-000"){ 
		error(document.przyslij.uz_tel_st,"Proszê podaæ przynajmniej jeden numer telefonu.. \nNale¿y zachowaæ wskazane formatowanie numeru");  
		return false;
	}
	
	if( item1 != "+48 (00) 000-00-00" && item1.search(wzorzec1)==-1){ 
		error(document.przyslij.uz_tel_st,"Niepoprawny numer telefonu stacjonarnego.\nPoprawny format numeru to: +48 (XX) XXX-XX-XX");  
		return false;
	}

	if( item2 != "+48 (000) 000-000" && item2.search(wzorzec2)==-1){
		error(document.przyslij.uz_tel_k,"Niepoprawny numer telefonu komórkowego.\nPoprawny format numeru to: +48 (XXX) XXX-XXX");  
	 	return false;
	}
	
	return true;
}

function zaznacz(elem) {
	formElem = document.all["edycja_firma_"+elem];
	var formElVal = document.all["edycja_firma_"+elem+"f"].value;
	if (formElVal != "")
		formElem.checked = 1;
}

/// PRZEJSCIE PO KLIKNIECIU
var adres = "";
function go(adres)
{
location= adres
}


/// PRZEGLADARKI DLA POKAZ/UKRYJ WARSTWE

		ns4 = (document.layers)? true:false
		ie4 = (document.all) && !(document.getElementById)? true:false
		ie5 = (document.getElementById) && (document.all)? true:false
		ns6 = (document.getElementById) && !(document.all)? true:false


/**
* @desc OTWIERANIE OKNA
*/
function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}


/// POKAZ/UKRYJ WARTWE
function pokazWarstwe(nazwaWarstwy) {
   if (ns4) document.layers[nazwaWarstwy].visibility = "show"
   else if (ie4) document.all[nazwaWarstwy].style.visibility = "visible"
   else if (ie5||ns6) document.getElementById(nazwaWarstwy).style.visibility = "visible";
}
function ukryjWarstwe(nazwaWarstwy) {
   if (ns4) document.layers[nazwaWarstwy].visibility = "hide"
   else if (ie4) document.all[nazwaWarstwy].style.visibility = "hidden"
   else if (ie5||ns6) document.getElementById(nazwaWarstwy).style.visibility = "hidden";
}

/**
* @desc SPRAWDZANIE SONDY - CZY ZAZNACZONO ODPOWIEDZ
*/
function SprawdzSonda(form)
{

zaz = false; 
for (i = 0; i < form.sodp_odp.length; i ++) 
	{
	if (form.sodp_odp[i].checked) 
		{zaz = true;}
	}

if (zaz == false)
	{
	alert("Należy zaznaczyć którąś z odpowiedzi");
	form.sodp_odp[0].focus();
	return false;
	}

{return true;}
}


// ZAZNACZ SZUKAJ
function zaznacz_szukaj(elem) {
	formElem = document.all["t_sz_"+elem];
	var formElVal = document.all["sz_"+elem].value;
	if (formElVal != "")
		formElem.checked = 1;
}

/*
* Włącza pole o podanym ID, gdy button radio o podanej wartosci jest zaznaczony
*/
function seFormRadioKlikPoleWlacz(pole_id,pole_wlacz_id,wartosc_wlaczajaca) {

	var pole_wlacz = document.getElementById(pole_wlacz_id);
	var pole_radio = document.getElementsByName(pole_id);
	var wlacz = wartosc_wlaczajaca;
	var wybor = "";

	for (i=0; i<pole_radio.length; i++) {
		if (pole_radio[i].checked) wybor=pole_radio[i].value;
	}

	if (wybor==wartosc_wlaczajaca) {
	pole_wlacz.disabled=false;
	} else {
	pole_wlacz.value="";
	pole_wlacz.disabled=true;
	}
}

/*
* Sprawdzanie formularzy
* @desc Definicje zmiennych
*/
	var error_message = ''; // Przechowuje tresc komunikatu
	var error_validate = 0; // Przechowuje znacznik wystapienia bledu
	var error_focus = ''; // Przechowuje ID pola, na ktore nastapi focus

/*
* Sprawdza i porownuje wartosci pól
*/
function seFormPorownajPola(pole_id,komunikat,pole_id_porownaj) {
	var pole_1 = document.getElementById(pole_id);
	var pole_2 = document.getElementById(pole_id_porownaj);

	if(pole_1.value.length > 0) {
		if(pole_1.value != pole_2.value) {
			error_message = error_message + komunikat + "\n";
			if(error_focus == '') error_focus = pole_id;
			error_validate = 1;
			return false;
		}
	}
}

/*
* Sprawdza pole o podanym ID, aby miało podana dlugosc znakow i zwraca komunikat, gdy nie ma
*/
function seFormSprawdzDlugosc(pole_id,komunikat,dlugosc) {

	if(document.getElementById(pole_id).value.length <= dlugosc) {
		error_message = error_message + komunikat + "\n";
		if(error_focus == '') error_focus = pole_id;
		error_validate = 1;
		return false;
	}
}

/*
* Sprawdza pole o podanym ID, aby miało podany poprawny adres email i zwraca komunikat, gdy nie ma
*/
function seFormSprawdzEmail(pole_id,komunikat) {
	if (!document.getElementById(pole_id).value.match(/^([0-9a-zA-Z_.+-]+)@([0-9a-zA-Z.-]+)\.([a-zA-Z]+)$/)) {
		error_message = error_message + komunikat + "\n";
		if(error_focus == '') error_focus = pole_id;
		error_validate = 1;
		return false;
	}
}

/*
* Sprawdza, czy checkbox zaznaczony
*/
function seFormSprawdzZaznaczenie(pole_id,komunikat) {

	var pole_sprawdz = document.getElementById(pole_id);

	if (!pole_sprawdz.checked) { 
		error_message = error_message + komunikat + "\n";
		if(error_focus == '') error_focus = pole_id;
		error_validate = 1;
		return false;
	}
}

/*
* Sprawdza warunek wypelnienia
*/
function seFormJesliWypelnione(pole_id) {

	var pole_sprawdz = document.getElementById(pole_id);

	if (pole_sprawdz.value != '') { 
		return true;
	} else { return false; }
}

/*
* Sprawdza warunek wypelnienia wartoscia
*/
function seFormJesliWartosc(pole_id,wartosc) {

	var pole_sprawdz = document.getElementById(pole_id);

	if (pole_sprawdz.value == wartosc) { 
		return true;
	} else { return false; }
}

/*
* Sprawdza, czy wymagan ilosc pol z listy zostala zaznaczona
*/
function seFormSprawdzLista(pole_id,komunikat,pole_ilosc) {

	var pole_sprawdz = document.getElementsByName(pole_id);
	var pole_ok=0;

	for (i=0;i<pole_sprawdz.length;i++) {
		if (pole_sprawdz[i].checked) pole_ok ++;
	}

	if (pole_ok<pole_ilosc) { 
		error_message = error_message + komunikat + "\n";
		if(error_focus == '') error_focus = pole_sprawdz[0];
		error_validate = 1;
		return false;
	}
}

/**
* @desc Wlacza pole o wskazanym ID, gdyz w aktualnym polu wartosc = podanej
*/
function seFormPoleWlaczJesli(pole_sprawdz_id,pole_sprawdz_opcja,pole_przelacz_id) { 
	
	var pole_sprawdz=document.getElementById(pole_sprawdz_id);
	var pole_przelacz=document.getElementById(pole_przelacz_id);
	
	if(pole_sprawdz.value == pole_sprawdz_opcja) {
		pole_przelacz.disabled='';
	} else {
		pole_przelacz.disabled='true';
	}
}

/**
* @desc Submituje wskazany formularz
*/
function seFormFormSubmit(form_id) {
	document.getElementById(form_id).submit();
}

/**
* @desc Blokuje zaznaczanei tekstu na stronie
*/
function seBlokadaZaznaczania(element) {
	element.style.cursor = "default";
	if (typeof element.onselectstart!="undefined") { // dla IE:
		element.onselectstart=function() { return false; }
	} else if (typeof element.style.MozUserSelect!="undefined") { // dla FireFox:
		element.style.MozUserSelect="none";
	} else { // dla Opery i innych:
		element.onmousedown=function() { return false; }
	}
}