
var dv1;
var oft;

function design_ajaxDivModule(inId) {
    target = 'content_design';
    pam_id = inId;
	advAJAX.post({ url: "cms/_actions/ajaxDivModule.php",
		parameters : {
		"id" : pam_id
		},
		onLoading : function(obj) {document.getElementById(target).innerHTML = "<img src=\"/cms/site.files/Image/loading.gif\" alt=\"\">";},
		onSuccess : function(obj) { document.getElementById(target).innerHTML = obj.responseText; $(function() { $('#architekt_div a.photo').lightBox(); });  },
		onError : function(obj) { alert("Error: " + obj.status); }
	});
}

function add_cookie() {
    var d = new Date();
    //d.setMinutes(d.getMinutes() + 1);
    d.setDate(d.getDate() + 1);
    //alert(d.toGMTString());
    var div = document.getElementById("div_swieta");
    div.style.display = "none";
    document.cookie = "name=swieta; expires=" + d.toGMTString();
}

function polec_close() {
    div = document.getElementById('polec_ziomalowi');
    div.style.display = 'none';
}
function polec() {

    div = document.getElementById('polec_ziomalowi');
    div.style.display = 'block';

    return true;
}

function ShowHideDiv(id,li) {

    div = document.getElementById('sub_menu_'+id);


    if(div.style.display == 'block') {
        div.style.display = 'none'
        li.style.backgroundImage = 'url(/cms/site.files/Image/klart_pixs/menu-arrow.gif)';
    } else {
        div.style.display = 'block'
        li.style.backgroundImage = 'url(/cms/site.files/Image/menu-arrow5.gif)';

    }

}

function ajax_getKarta(div,kondygnacja,lokalizacja) {
		advAJAX.get({

			url : 'cms/_actions/printKarta.php?kondygnacja='+kondygnacja+'&lokalizacja='+lokalizacja,
			onSuccess : function(obj) {
					document.getElementById(div).innerHTML = obj.responseText;
				}
		    });


}


function OpenImage2(l,m)
{

	window.open('/cms/openimage.php?lokalizacja='+l+'&mieszkanie='+m, 'obrazek', 'toolbar=no , menubar=0, status=no, top=250, left=225');
}

function highlightRow(k) {

    document.getElementById('row'+k).style.backgroundColor = 'pink';
}
function unhighlightRow(k) {

    if(k%2==1)
	document.getElementById('row'+k).style.backgroundColor = '#ded4d5';
    else
	document.getElementById('row'+k).style.backgroundColor = '#f4f0f1';
}
function wylicz_koszta(dest,netto,brutto,forma){

        str = 'netto='+netto+'&brutto='+brutto+'&forma='+forma;
	var tmp = advAJAX.download(dest, '/cms/mod_shop/site.mod/kosztatransportu.php?'+str);
}
function menu_hide_show(id,level) {

    if(level==1) {
        s = document.getElementById('menu_list_'+id).style;
    }
    if(level==2){
        s = document.getElementById('sub_menu_list_'+id).style;
    }

        if(s.display == 'none') {
            s.display = 'block';
        } else {
            s.display = 'none';
        }
    }





function powiel_vat(id) {
    var pole = document.getElementById(id).value;

    document.getElementById(id+'_f').value = pole;

}


//GALERIA ZDJEC W SZCZEGOLACH PRODUKTU
function pokaz_zdjecie(zdjecie) {
    document.getElementById("zdjecie").innerHTML = '<img onclick="window.open(\'/cms/site.files/Image/Products/' + zdjecie + '\')" style="cursor:pointer" title="powiększ" alt="powiększ" width="250" src="/cms/site.files/Image/Products/images_250xY/' + zdjecie + '" />';
}



function powiel_wysylka(id) {
    var pole = document.getElementById(id).value;

    document.getElementById(id+'_a').value = pole;
}


//przepisuje z dane klienta do VAT
function przepisz_vat() {
    powiel_vat("firma");
    powiel_vat("ulica");
    powiel_vat("nr_domu");
    powiel_vat("kod");
    powiel_vat("miejscowosc");
    powiel_vat("kraj");
}


//przepisuje z dane klienta do wysyłki
function przepisz_wysylka() {
    powiel_wysylka("firma");
    powiel_wysylka("imie_nazwisko");
    powiel_wysylka("ulica");
    powiel_wysylka("nr_domu");
    powiel_wysylka("kod");
    powiel_wysylka("miejscowosc");
    powiel_wysylka("kraj");
}


//mapa polski - pokazuje wybrany adres
function pokaz_adres (div) {
    ukryj_all();
    var gdzie = document.getElementById(div);
    gdzie.style.display = "block";
}

function ukryj_adres(div) {
    var gdzie = document.getElementById(div);
   // gdzie.style.visibility = "hidden";
    gdzie.style.display = "none";
}


function checkbox_os() {

    var pola = new Array('firma','firma_f','firma_a','nip');

    if(document.getElementById("os_fiz").checked==true) {
        for(i=0;i<pola.length;i++) {
            var v = document.getElementById(pola[i]);
            v.disabled = true;
            v.style.backgroundColor = '#D4D3D2';
        }
    }
    else {
        for(i=0;i<pola.length;i++) {
            var v = document.getElementById(pola[i]);
            v.disabled = false;
            v.style.backgroundColor = '';
        }
    }

}

//UKRYWA WSZYSZYSTKIE DIVY Z ADRESAMI
function ukryj_all() {
    document.getElementById("adr1").style.display = "none";
    document.getElementById("adr2").style.display = "none";
    document.getElementById("adr3").style.display = "none";
    document.getElementById("adr4").style.display = "none";
    document.getElementById("adr5").style.display = "none";
    document.getElementById("adr6").style.display = "none";
    document.getElementById("adr7").style.display = "none";
}

//sprawdza czy login jest wolny czy zajety
function przetwarzajDane(src, dest)
{
    //if(dest!="")
        document.getElementById(dest).style.display = "block";
    var tfValue = document.getElementById(src).value;
    var str = "tekst="+tfValue;
    var tmp = advAJAX.download(dest, '/cms/scripts/php/login.php?'+str);
}


//sprawdza czy wpisana liczba do form
function IsDigit( e )
{
	if ( !e )
		e = event ;

	var iCode = ( e.keyCode || e.charCode ) ;

	return (
			( iCode >= 48 && iCode <= 57 )		// Numbers
			|| (iCode >= 37 && iCode <= 40)		// Arrows
			|| iCode == 8						// Backspace
			|| iCode == 46						// Delete
	) ;
}


//sprawdza poprawnosc pola 'ilosc osob' w zamowieniu wycieczki
function check(arg) {

        var input = document.getElementById(arg).value;
        if(input=="") {
                alert("Wypełnij pole 'Ilość'");
                return false;
        }

        else if(input.substr(0,1)==0) {
                alert("Pole 'Ilość' nie może być równe 0!");
                return false;
        }
        else
                return true;
}


//sprawdza poprawnosc formularza rejestracji
function sprawdz_rej(){
  if(  document.form_rej.imie_nazwisko.value=="" || document.form_rej.ulica.value=="" || document.form_rej.nr_domu.value=="" || document.form_rej.kod.value=="" || document.form_rej.miejscowosc.value=="" || document.form_rej.kraj.value==""  || document.form_rej.email.value=="" || document.form_rej.login.value=="" || document.form_rej.haslo.value=="" || document.form_rej.tel_kom.value=="" || (document.form_rej.firma.value=="" && document.form_rej.os_fiz.checked==false) || (document.form_rej.firma_f.value=="" && document.form_rej.os_fiz.checked==false) || (document.form_rej.nip.value=="" && document.form_rej.os_fiz.checked==false) ||  document.form_rej.obrtext.value=="" || document.form_rej.ulica_f.value=="" || document.form_rej.nr_domu_f.value=="" || document.form_rej.kod_f.value=="" || document.form_rej.miejscowosc_f.value=="" || document.form_rej.kraj_f.value=="" )
   {
        alert("Wypełnij wszystkie pola oznaczone gwiazdką!");
        return false;
   }
  if (!checkEmail(document.form_rej.email.value)) {
        return false;
  }
  if(document.form_rej.obr.value!=document.form_rej.obrtxt.value) {
        alert("Niepoprawny kod z obrazka");
        return false;
  }

  przetwarzajDane('login', 'div1');
  var spr = document.getElementById("spr").value;

  if (spr == 0) {
        alert("Podany login jest zajęty!");
        return false;
  }

  return true;
}

//sprawdza poprawnosc formularza przy dokonywaniu zakupu
function sprawdz(){
  if(  document.form_rej.imie_nazwisko.value=="" || document.form_rej.ulica.value=="" || document.form_rej.nr_domu.value=="" || document.form_rej.kod.value=="" || document.form_rej.miejscowosc.value=="" || document.form_rej.kraj.value=="" || document.form_rej.email.value=="" || document.form_rej.login.value=="" || document.form_rej.haslo.value=="" || document.form_rej.tel_kom.value=="" || (document.form_rej.firma.value=="" && document.form_rej.os_fiz.checked==false) || (document.form_rej.firma_f.value=="" && document.form_rej.os_fiz.checked==false) || (document.form_rej.firma_a.value=="" && document.form_rej.os_fiz.checked==false) || (document.form_rej.nip.value=="" && document.form_rej.os_fiz.checked==false) || document.form_rej.ulica_f.value=="" || document.form_rej.nr_domu_f.value=="" || document.form_rej.kod_f.value=="" || document.form_rej.miejscowosc_f.value=="" || document.form_rej.kraj_f.value=="" || document.form_rej.imie_nazwisko_a.value=="" || document.form_rej.ulica_a.value=="" || document.form_rej.nr_domu_a.value=="" || document.form_rej.kod_a.value=="" || document.form_rej.miejscowosc_a.value==""  || document.form_rej.kraj_a.value=="")
   {
        alert("Wypełnij wszystkie pola oznaczone gwiazdką!");
        return false;
   }
  if (!checkEmail(document.form_rej.email.value)) {
        return false;
  }
  if(document.form_rej.obr.value!=document.form_rej.obrtxt.value) {
        alert("Niepoprawny kod z obrazka");
        return false;
  }

  przetwarzajDane('login', 'div1');
  var spr = document.getElementById("spr").value;

  if (spr == 0) {
        alert("Podany login jest zajęty!");
        return false;
  }

  return true;
}







function OpenImage(file)
{
	window.open("/cms/openimage.php?id="+file, "obrazek", "toolbar=no , resizable=1, menubar=0, status=no, top=250, left=225" );
}
function get_akt(id,title){
	window.open('/cms/mod_news/aktualnosci_popup.php?path='+id, 'title'+id, 'height=540, width=660, status=no, toolbar=no, menubar=yes, location=no, scrollbars=yes');
}
function get_content(id,title){
	window.open('/cms/mod_content/content_popup.php?path='+id, 'title'+id, 'height=540, width=660, status=no, toolbar=no, menubar=no, location=no, scrollbars=yes');
}
function swap(dv) {
	var d = document.getElementById(dv);
	if (dv=="libraries") {
		var b = document.getElementById('tdlibs');

	}



	if (d.style.display=="none") {
		d.style.display = "block";
		if (dv=="libraries") {
			b.style.height="200";
		}
		foldifr.location.href="_actions/setfold.php?code=" + dv + "&foldtype=show";
	} else {
		if (dv=="libraries") {
			b.style.height="0";
		}
		d.style.display = "none";
		foldifr.location.href="_actions/setfold.php?code=" + dv + "&foldtype=hide";
	}
}

function show(dv) {
	var d = document.getElementById(dv);
		if (dv=="libraries") {
		var b = document.getElementById('tdlibs');
	}
	d.style.display = "block";
		if (dv=="libraries") {
		b.style.height="200";
	}


}
function hide(dv) {
	var d = document.getElementById(dv);
		if (dv=="libraries") {
		var b = document.getElementById('tdlibs');
	}
	d.style.display = "none";
		if (dv=="libraries") {
		b.style.height="0";
	}
}


function set(dv, val) {
	if (val=="1") {
		show(dv);
	} else {
		hide(dv);
	}
}

function ONWHelp(Url, nazwa, wys, szer) {
   window.open(Url, nazwa, "height=" + wys + ",width=" + szer + ",status=no,resizable=no,scrollbars=yes,menubar=no,location=no");
}


function HideSearch(){
	parent.document.getElementById('cms-wyszuk').style.display='none';
}
function HideStats(){
	parent.document.getElementById('cms-stats').style.display='none';
}

//funkcja do ustawiania praw dostepu
function swapbtns(id) {

	var vl = document.getElementById('cms-rights-value-'+id);


	if (vl.value==1) {
		newval = 3;
	} else if (vl.value==2) {
		newval = 2;
	} else if (vl.value==3) {
		newval=1;
	}

	var im = document.getElementById('cms-rights-image-'+id);

	im.src='/cms/pix/ico.rights.'+newval+'.gif';
	vl.value = newval;

}

function swapbtnswv(id,val) {

	var vl = document.getElementById('cms-rights-value-'+id);

	if (vl.value!=2) {
		newval = val;



	var im = document.getElementById('cms-rights-image-'+id);

	im.src='/cms/pix/ico.rights.'+newval+'.gif';
	vl.value = newval;
	}

}

function ONWGal(Url, nazwa, wys, szer) {
   window.open(Url, nazwa, "height=" + wys + ",width=" + szer + ",status=no,resizable=no,scrollbars=yes,menubar=no,location=no");
}
function set_cars_od_ilosc(val) {
	f = document.getElementById('select_cars');
	f.target='ifr_cars';
	f.action='cms/_actions/select_cars.php';
	f.od_ilosc.value=val;
	f.submit();
}
function set_cars_orderby(val) {
	f = document.getElementById('select_cars');
	f.target='ifr_cars';
	f.action='cms/_actions/select_cars.php';
	f.orderby.value=val;
	f.submit();
}
function set_cars_desc(val) {
	f = document.getElementById('select_cars');
	f.target='ifr_cars';
	f.action='cms/_actions/select_cars.php';
	f.desc.value=val;
	f.submit();
}
function set_cars_sort(val) {
	f = document.getElementById('select_cars');
	f.target='ifr_cars';
	f.action='cms/_actions/select_cars.php';
	f.sort.value=val;
	f.submit();
}
function set_cars_demo(val) {
	f = document.getElementById('select_cars');
	f.target='ifr_cars';
	f.action='cms/_actions/select_cars.php';
	f.demo.value=val;
	//f.g2.value='';
	f.submit();
}
function set_cars_g2(val) {
	f = document.getElementById('select_cars');
	f.target='ifr_cars';
	f.action='cms/_actions/select_cars.php';
	f.g2.value=val;
	//f.demo.value='';
	f.submit();
}
function updateSubCat(tag,mark) {
	advAJAX.download(tag, 'cms/_actions/cars_model.php?mark='+mark);
}
function checkEmail(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.newsletterEmail.value)){
return (true)
}
alert("Niepoprawny adres e-mail.Proszę wpisac ponownie")
return (false)
}

