

function check_input_len(str,maxv) {
  
  var field = document.getElementById(str);
  var val = field.value;
  
  if(maxv) {
    if(val.length >= maxv) {
      field.value = val.substring(0,(maxv-1));
    }
  }
  
  var max = document.getElementById(str+"_max");
  max.innerHTML = val.length;
}

function ajax_uniqueCmsField(fvalue,fname,colname,tabname) {
  
  targetDiv = 'div_'+fname;
     advAJAX.post({ url: "/cms/scripts/script.parts/ajax_unique.php?fvalue="+fvalue+"&colname="+colname+"&tabname="+tabname,
       // onLoading : function(obj) {document.getElementById(targetDiv).innerHTML = "<div class=\"comm_status\">Trwa ładowanie danych<br><img src=\"/images/lightbox-ico-loading.gif\" alt=\"\" border=\"0\"></div>";}, 
	onSuccess : function(obj) { document.getElementById(targetDiv).innerHTML = obj.responseText; }
       
	// onError : function(obj) { alert("Error: " + obj.status); }
    });
  
  //advAJAX.download('div_'+fname, '/cms/scripts/script.parts/ajax_unique.php?fvalue='+fvalue+'&colname='+colname+'&tabname='+tabname);
}



function check_MainForm(f) {
  
  var e=0;
     for(i=0; i<f.elements.length; i++){
      if(f.elements[i].type == 'text') {
        if(f.elements[i].value == '-- wpisz dowolną frazę --' || f.elements[i].value == '') {
          e++;
          }       
      }
     }
     if(e>1){
      alert('Uzupełnij przynajmniej jedno pole.');
      return true;
     }
  
}

function spr_domene_znaki(domena){
  if (/^[a-z]+$/.test(domena)){
    wart = 1;
  }else{
    wart = 0;
  }
  return wart;
}


function highlight(div) {
  
  if(div.style.backgroundColor == '' || div.style.backgroundColor == '#FAFAFA') {
    div.style.backgroundColor = '#F5F5F5';
  } else {
    div.style.backgroundColor = '';
  }
  
}

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();
   // document.location.href='/index.php';
}




function zielone(zdjecie) {
            
              
                $(".produkt_akcja").hover(
                function(){
                    $(this).addClass("hover");
                    $(this).children("img").attr("src","/cms/site.files/Image/marelplus_new/" + zdjecie + "_z.jpg");
                }
                ,
                function(){
                    $(this).removeClass("hover");
                    $(this).children("img").attr("src","/cms/site.files/Image/marelplus_new/" + zdjecie + ".jpg");
                }
                );
            
}



function spr_domene(domena){
  wart=1;
  if (domena==''){
    alert('Proszę wpisać interesującą Państwa domenę');
    wart=0;
  }
  //wart = pr_domene_znaki(domena);

    domenaarray = domena.split('.');
    domlen = domenaarray.length;
    if (domlen>1){
      //wpisana domena
    }else{
      //ciag znakow
    }
    for (var i=0; i < domlen; i++) {

    }
  return wart;
}

function sprawdz_popr_domeny(pkt){

  var domena = document.getElementById('domena').value;
  var dform = document.getElementById('Domeny_form');
 
  // do dorobienia funkcja sprawdzająca
   wart = spr_domene(domena);
   
  if (wart==1){
    if (pkt==2){
      var actionf = 'http://'+window.location.hostname+'/mod-forms/path-3/wr-1/';
      //var actionf = 'http://'+window.location.hostname+'/index.php?mod=forms&path=3&wr=1';
    dform.action = actionf;
    dform.submit();
    }else{
      var actionf = 'http://'+window.location.hostname+'/mod-forms/path-3/';
      //var actionf = 'http://'+window.location.hostname+'/index.php?mod=forms&path=3';
      dform.action = actionf;      
    }
  }

}
//powiela dane w formularzu rejestracyjnym
function powiel(id) {
  var pole = document.getElementById(id).value;
    if(id!="imie" && id!="nazwisko")
        document.getElementById(id+'_f').value = pole;
    if(id!="tel_kom")
        document.getElementById(id+'_a').value = pole;  
}
function sprawdz_dost_domen(ktora, pocz){
  tag = document.getElementById('ret_'+ktora);
  jaka = document.getElementById('wybdomeny_'+ktora).value;
  pocz = document.getElementById('prefixdom').value;
  domena = pocz+jaka;
  tag.innerHTML = '<img src="/cms/pix/klepsydra.gif" width=25>';    
  advAJAX.download(tag, '/cms/mod_forms/site.mod/ajax_domeny.php?check=4&domena='+domena);
}
function sprawdz_dost_domen_old(szukana){
        spr = document.getElementById('sprawdzane_domeny').value;
        
        var domainarray = Array();
        var checkarray = Array();
        a=spr.split(';');
        for (var i=0; i < a.length; i++) {
          if (a[i]!=''){
            b=a[i].split(':');
            ch = b[0];
            domain = b[1];
            if ((ch!='') && (domain!='')){
              domainarray[i] = domain;
              checkarray[i]= ch;
            }
          }
        }
        for (var iz=0; iz < domainarray.length; iz++) {
          document.getElementById('ret_'+checkarray[iz]).innerHTML = '<img src="/cms/pix/klepsydra.gif" width=25>';
          advAJAX.download('ret_'+checkarray[iz], '/cms/mod_forms/site.mod/ajax_domeny.php?check=4&pole='+checkarray[iz]+'&caladomena='+szukana+domainarray[iz]+'&domena='+szukana);
        }
        document.getElementById('sprawdzane_domeny').value='';
        document.getElementById('klikniecia').value='0';
}
function check_domain(tag,str){
	advAJAX.download(tag, '/cms/mod_forms/site.mod/ajax_domeny.php?'+str);
}
function pokaz_wymiary(wybrane){
  var dostepne = Array('tower','rack');
    for (var i=0; i < dostepne.length; i++) {
      if (wybrane==dostepne[i]){
        document.getElementById('Wymiary_'+dostepne[i]).style.display = 'block';
      }else{
        document.getElementById('Wymiary_'+dostepne[i]).style.display = 'none';        
      }
    }
}
function display_style(divnone,divblock){
  document.getElementById(divblock).style.display = 'block';
  document.getElementById(divnone).style.display = 'none';  
}


function sprawdz_klikniecia(h,str,domena){
        ile = document.getElementById('klikniecia').value;
        spr = document.getElementById('sprawdzane_domeny').value;
        znacznik = h+':'+domena+';';        
        ile = parseFloat(ile);
        check = document.getElementById('wybdomeny_'+h);
        if (check.checked==true){
          if (ile<5){
            mat = ile+1;
            dom = spr+znacznik;            
          } else{
            check.checked = false;
            alert(str);
          }
        }else{
            dom = dom.replace(znacznik, '');          
            mat = ile-1;               
        }
        document.getElementById('sprawdzane_domeny').value = dom;          
        document.getElementById('klikniecia').value = mat;
}

//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 zmien_przycisk(ktory, jaki){
     var gdzie = document.getElementById('menu_center_td_'+ktory);
    var link = document.getElementById('menu_center_a_'+ktory);
     if (jaki==1){
      link.style.color = "#000000";      
      gdzie.style.background = "url(/cms/pix/przycisk_menu.gif)";
     }else{
      link.style.color = "#ffffff";        
      gdzie.style.background = "url(/cms/pix/przycisk_menu_pod.gif)";
     }
}


function powiel_wysylka(id) {
    var pole = document.getElementById(id).value;
    
    document.getElementById(id+'_a').value = pole;  
}

function powiel_vat(id) {
    var pole = document.getElementById(id).value;
    
    document.getElementById(id+'_f').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");
}





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 = '';
        }
    }
    
}




/*
function checkbox_os() {
    if(document.getElementById("os_fiz").checked==true) {
        document.getElementById("os").innerHTML = "<input style=\"background-color:#D4D3D2\" type=\"text\" size=\"25\" name=\"firma\" DISABLED id=\"firma\"  onkeyup=\"powiel(\'firma\');\" />";
        document.getElementById("os_f").innerHTML = "<input style=\"background-color:#D4D3D2\" type=\"text\" size=\"25\" name=\"firma_f\" DISABLED id=\"firma_f\"  />";
        document.getElementById("os_a").innerHTML = "<input style=\"background-color:#D4D3D2\" type=\"text\" size=\"25\" name=\"firma_a\" DISABLED id=\"firma_a\"   />";
        document.getElementById("os_nip").innerHTML = "<input style=\"background-color:#D4D3D2\" type=\"text\" size=\"25\" name=\"nip\" DISABLED id=\"nip\"  />";
    }
    else {
        document.getElementById("os").innerHTML = "<input  type=\"text\" size=\"25\" name=\"firma\" id=\"firma\"  onkeyup=\"powiel(\'firma\');\" />";
        document.getElementById("os_f").innerHTML = "<input  type=\"text\" size=\"25\" name=\"firma_f\" id=\"firma_f\"  />";
        document.getElementById("os_a").innerHTML = "<input  type=\"text\" size=\"25\" name=\"firma_a\" id=\"firma_a\"   />";
        document.getElementById("os_nip").innerHTML = "<input  type=\"text\" size=\"25\" name=\"nip\" id=\"nip\"  />";          
    }
    
}
*/
//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 rejestracji
function sprawdz(){
  
  if(  document.form_rej.imie.value=="" || document.form_rej.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.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.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.imie_a.value=="" || document.form_rej.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=="")
   {
        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 , 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 open_close(div){

  var d = document.getElementById(div);
  if (d.style.display=="block"){
    d.style.display="none";
  }else{
    d.style.display="block";
  }
}
function checkEmail2(myForm,txt) {
  
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.newsletterEmail.value)){
return (true)
}
alert(txt)
return (false)
}
function show_poczta(stan){
  var trp = document.getElementById("faktura_poczta");
  if (stan=="1"){
    trp.style.display = "";
  }else{
    trp.style.display = "none";    
  }
 }
function show_firma(stan,domena){
  var trn = document.getElementById("trnip");
  var trp = document.getElementById("trpesel");
  var trr = document.getElementById("trregon");  
  if (domena=="eu"){
   if (stan==1){
    trr.style.display = "block";
    trn.style.display = "block";
    trp.style.display = "none";     
   }else{
    
    trr.style.display = "none";
    trn.style.display = "none";      
    trp.style.display = "block";    
   }
  }else{
    trr.style.display = "none";
    trn.style.display = "block";      
    trp.style.display = "none";    
    }  
}

function show_danek(stan){

  var trp = document.getElementById("fieldset_danek");
  if (stan=="1"){
    trp.style.display = "block";
  }else{
    trp.style.display = "none";    
  }
 }
 
function logowanie_check() {
  var login = document.getElementById("login").value;
  var haslo = document.getElementById("haslo").value;
  if(login=="" || haslo=="") {
    alert("Wypełnij oba pola!!");
    return false;
  }
  return true;
}


/* PLYWAJACA CHMURKA */

showHintBox=showHintBoxForVar=function( S,T,W, d,E,b ) {
  d=document;E=d.documentElement;b=d.body;if(!E)return;
  //check if hintBox appears somwhere in code
  if( ! ( S.h=document.getElementById( 'hintBox' ) ) ) {
  	//if not create new element
  	S.h=d.createElement('div');
  	//and add some looks
  	S.h.id='hintbox';
  } //here's IE bug fix - if hintBox appears within table tag it won't
  //accept table as inner html, so to preserve user defined formatting we clone node and add it in
  //the beginning of document
 	//do not remove !!!!
	else S.h=S.h.cloneNode(true);
	//if T string was not sent look for title tag and if it's not found give it default string
	S.h.innerHTML = !T ? (S.title?S.title:'&nbsp;value not defined&nbsp;'):unescape( T );
	//set properties essential for div positioning
	with( S.h.style ) { position='absolute'; zIndex=2; top=left=0;}
	//the heart of the script - enable onmousemove event
	S.onmousemove=function(e,l,t,mX, mY,c,h,w){
		e=e||event;
		var di=15; friction=.3;
		with( this.h.style ) {
			//show div
			display='block'; visibility='visible';
			mX = e.clientX+( E.scrollLeft || b.scrollLeft );
			mY = e.clientY+( E.scrollTop  || b.scrollTop  );
			c = clientSize();
			l=parseInt(left),	t=parseInt(top),	h=this.h.offsetHeight,	w=this.h.offsetWidth
			if( c[0]-mX-w < di )
				left=(l > mX-di-w?l+(mX-di-w-l)*friction:mX-di-w)+'px';
			else
				left= (l > mX-w-di && l < mX+di?l+(mX+di-l)*friction: mX+di)+'px';

			if( c[1]-mY-h < di )
				top=(t>mY-di-h?t+(mY-di-h-t)*friction:mY-di-h)+'px';
			else
				top=(t > mY-h-di && t < mY+di?t+(mY+di-t)*friction:mY+di)+'px';
		} return!1;
	}
	//add hiding
	S.onmouseout=function(){
		with( this ) {
			//remove div from document's node tree
	  	if(h)b.removeChild( h );
	  	//stop catching mouse position
			onmousemove=h=null;
		}
		return!1;
  }
  //add div to the document
	b.appendChild(S.h);
}

function clientSize() {
	if (window.innerHeight >= 0) {
		return [window.innerWidth, window.innerHeight];
	} else if (document.documentElement) {
		return [document.documentElement.clientWidth,		document.documentElement.clientHeight]
	} else if (document.body.clientHeight >= 0) {
		return [document.body.clientWidth,document.body.clientHeight]
	} else {
		return [0, 0]
	}
}


//GALERIA ZDJEC W SZCZEGOLACH PRODUKTU
function pokaz_zdjecie(zdjecie) {
    document.getElementById("zdjecie").innerHTML = '<img onclick="window.open(\'/cms/site.files/Image/Products/origs/' + zdjecie + '\')" style="cursor:pointer" title="powiększ" alt="powiększ" width="250" src="/cms/site.files/Image/Products/images_250xY/' + zdjecie + '" />';
    document.getElementById("actual_photo").value = zdjecie;
}

function print_pdf(url) {
    foto = document.getElementById("actual_photo").value;
    window.open(url+'&photo='+foto);
}
function print_pdf2(url) {
    //foto = document.getElementById("actual_photo").value;
    window.open(url);
}

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 load(wsp1,wsp2, opis) {
                if (GBrowserIsCompatible()) {
                        var map = new GMap2(document.getElementById("map"));
             
                
                        map.addControl(new GSmallMapControl());
                        map.addControl(new GMapTypeControl());
                        map.setCenter(new GLatLng(wsp1,wsp2), 14);
                        map.setMapType(G_NORMAL_MAP);
                        // Create a base icon for all of our markers that specifies the
                        // shadow, icon dimensions, etc.
                        var baseIcon = new GIcon();
                        baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
                        baseIcon.iconSize = new GSize(20, 34);
                        baseIcon.shadowSize = new GSize(37, 34);
                        baseIcon.iconAnchor = new GPoint(9, 34);
                        baseIcon.infoWindowAnchor = new GPoint(9, 2);
                        baseIcon.infoShadowAnchor = new GPoint(18, 25);
        
                        // Creates a marker whose info window displays the letter corresponding
                        // to the given index.
                        function createMarker(point, index, litera, lokal) {
                                // Create a lettered icon for this point using our icon class
                                var letter = String.fromCharCode("A".charCodeAt(0) + index);
                                var icon = new GIcon(baseIcon);
                                icon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
                                var marker = new GMarker(point, icon);
                          
                                GEvent.addListener(marker, "mouseover", function() { 	marker.openInfoWindowHtml(lokal);});
              
                                return marker;
                        }

                        // Add 10 markers to the map at random locations
                        var bounds = map.getBounds();
                        var southWest = bounds.getSouthWest();
                        var northEast = bounds.getNorthEast();
                        var lngSpan = northEast.lng() - southWest.lng();
                        var latSpan = northEast.lat() - southWest.lat();
        
                        //var point = new GLatLng(53.748305,18.820953);
                        // map.addOverlay(createMarker(point, 0));
                
                        var morska = new GLatLng(wsp1,wsp2);
                        map.addOverlay(createMarker(morska, 0, "A",opis));
        
                        map.setCenter(new GLatLng(wsp1,wsp2), 15);  
                }
      
        }
        
        
        function zapytanie_sprawdz() {
            if(!$("input[@name=nazwisko]").val() || !$("input[@name=telefon]").val() || !$("input[@name=email]").val() || !$("textarea[@name=pytanie]").val()) {
              alert("Wypełnij wszystkie pola oznaczone gwiazdką.");
              return false;
            }
            if (!checkEmail($("input[@name=email]").val())) {
                return false;
            }
            return true;
          
          
          
        }
				
function rozwin(id) {
	element = document.getElementById(id);
	if (element.style.display=="none") element.style.display="";
	else element.style.display="none";
}

function showSubMenu(id) {
  menuElement = document.getElementById('menuLevel1');
  topElement = document.getElementById('top');
  if (id!="21") {
    menuElement.style.height = "30px";
    topElement.style.height = "237px";
  }
  else {
    menuElement.style.height = "60px";
    topElement.style.height = "267px";
  }
  menuElement.style.display = "block";
  menuElement.innerHTML = "";
  advAJAX.download('menuLevel1', '/cms/scripts/php/getSubmenu.php?id='+id);
}

function highlightActiveMenu(id) {
  section = document.getElementById('menuLevel0');
  divs = section.getElementsByTagName('div');
  for (i=0; i<divs.length; i++) {
    if (divs[i].getAttribute('name') == id) {
      if (divs[i-1].getAttribute('class') == 'menuSeparatorFirst') {
	divs[i-1].setAttribute('class', 'menuSeparatorActiveFirst');
      }
      else
	divs[i-1].setAttribute('class', 'menuSeparatorActive');
      
      divs[i].setAttribute('class', 'menuActive');
      
      if (i+1<divs.length) {
	divs[i+1].setAttribute('class', 'menuSeparatorActiveClose');
	i++;
      }
    }
    else if (divs[i].getAttribute('class') == 'menuActive') {
      divs[i].setAttribute('class', 'menuNormal');
    }
    else if (divs[i].getAttribute('class') == 'menuSeparatorActive') {
      divs[i].setAttribute('class', 'menuSeparatorNormal');
    }
    else if (divs[i].getAttribute('class') == 'menuSeparatorActiveFirst') {
      divs[i].setAttribute('class', 'menuSeparatorFirst');
    }
    else if (divs[i].getAttribute('class') == 'menuSeparatorNormal') {
      divs[i].setAttribute('class', 'menuSeparatorNormal');
    }
    else if (divs[i].getAttribute('class') == 'menuSeparatorActiveClose') {
      divs[i].setAttribute('class', 'menuSeparatorNormal');
    }
    else if (divs[i].getAttribute('class') == 'menuSeparatorFirst') {
      divs[i].setAttribute('class', 'menuSeparatorFirst');
    }
  }
}

