var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only


if (document.getElementById){  
document.write('<style type="text/css">\n')
document.write('.menu_1_2{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu_1(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("menu_1").getElementsByTagName("ul");  
		if(el.style.display != "block"){  
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="menu_1_2")  
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}



if (document.getElementById){  
document.write('<style type="text/css">\n')
document.write('.menu_1_2{display: none;}\n')
document.write('</style>\n')
}



function SwitchMenu_1_2(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("menu_1").getElementsByTagName("ul");  
		if(el.style.display != "block"){  
			for (var i=0; i<ar.length; i++){
			//	if (ar[i].className=="sub1_1_1")  
			//	  ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}


if (document.getElementById){  
document.write('<style type="text/css">\n')
document.write('.menu_2_2{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu_2(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("menu_2").getElementsByTagName("ul");  
		if(el.style.display != "block"){  
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="menu_2_2")  
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}


if (document.getElementById){  
document.write('<style type="text/css">\n')
document.write('.menu_2_2{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu_2_2(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("menu_2").getElementsByTagName("ul");  
		if(el.style.display != "block"){  
			for (var i=0; i<ar.length; i++){
			//	if (ar[i].className=="sub1_1_1")  
			//	ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}






function overlay(curobj, subobjstr, opt_position){
if (document.getElementById){
var subobj=document.getElementById(subobjstr)
subobj.style.display=(subobj.style.display!="block")? "block" : "none"
var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
subobj.style.left=xpos+"px"
subobj.style.top=ypos+"px"
return false
}
else
return true
}

function overlayclose(subobj){
document.getElementById(subobj).style.display="none"
}


//////////////// sprawdza czy podana wartosc jest liczba//////////
function sprawdz_liczbe(ilosc) {
 
  
 inputStr=ilosc.toString();
    
    for(var i=0; i<inputStr.length; i++) 
    {
      var oneChar=inputStr.charAt(i);
      if(i==0 && oneChar=="-")
      {
      continue
      }
      if(oneChar < "0" || oneChar > "9")
      {
        alert('Wpisana wartość nie jest liczbą');
        document.getElementById('zamawiana_ilosc').value='';
        return false;
        
      }
    }
}

//////////////// sprawdza czy podana wartosc jest liczba w przeliczaniu koszyka//////////
function sprawdz_liczbe(ilosc,orginal) {
 
  
 inputStr=ilosc.toString();
    
    for(var i=0; i<inputStr.length; i++) 
    {
      var oneChar=inputStr.charAt(i);
      if(i==0 && oneChar=="-")
      {
      continue
      }
      if(oneChar < "0" || oneChar > "9")
      {
        alert('Wpisana wartość nie jest liczbą');
        document.getElementById('ilosc').value=orginal;
        return false;
        
      }
    }
}

function formularz_open(adres) 
  {
  noweOkno = window.open(adres, 'okienko', 'menubar=no, toolbar=no, location=no, scrollbars=no, resizable=no, status=no, width=560, height=260')
  }

//CHMURKA///////////////////////////////////////////////////////////////////////
function wyswietl(T,t){
   T.nextSibling.style.display=t?'block':'none'
}

//POP-UP-ZDJECIA////////////////////////////////////////////////////////////////////////
function ImgWinOpen(file,title,w,h)
{
     look='';
     sbars = 0;
     resize = 0;
     if(w > screen.availWidth)
     {
     		w = screen.availWidth-30;
     		sbars = 1;
     		resize = 1;
     }
     if(h > screen.availHeight)
     {
     		h = screen.availHeight-60;
     		sbars = 1;
     		resize = 1;
     }
     
	  look = 'scrollbars='+sbars+', resizable='+resize+', width='+w+',height='+h+'';
     newWin = window.open(file,'newWindow','toolbar=0,location=0,'+look);
	  newWin.document.write("<html><head><title>"+title+"</title></head>");
	  newWin.document.write("<body leftmargin=0 rightmargin=0 topmargin=0 bottommargin=0 marginwidth=0 marginheight=0 margin=0 onClick='window.close();' style='cursor:pointer;'><img src=" +file+ " / alt='Kliknij, aby zamknąć okno'>");
	  newWin.document.write("</body></html>");
	 
}
 
 

////////////////////////////////////////////////////////////////////////////////  
function subskrypcja_box()
  {
  if (document.getElementById("e_mail").value)
    {
    document.getElementById("formularz_subskrypcja").submit();
    }
  else
    {
    alert("wpisz poprawnie adres e-mail");
    } 
  }


////////////////////////////////////////////////////////////////////////////////  
function szukaj()
  {

  var komunikat="";
	if(document.form_search.fraza.value=="") komunikat="* Wpisz szukaną fraze\n";
	if(document.form_search.fraza.value.length < 3) komunikat+="* Wpisana fraza jest za krótka ( min.3 znaki )";
	if( komunikat!="") {
		alert(komunikat);
		return false;
	}
	document.form_search.submit();
  }
  
//////////////////////////////////////////////////////////////////////////////// 
function  usun_z_koszyka(id) {
  	if ( confirm("Czy na pewno chcesz usunąć z koszyka wybrany produkt?") ) {
  window.location.href='index.php?action=usun_z_koszyka&id_k='+id+'';
  }
}
