<!--
  // vi:foldmethod=marker foldclose=all
  //czas przechowywania koszyka (cookie) - w sekundach
  var nBasketExpire = 3600;

/* function checkBrowser() {{{ */  
function checkBrowser()
{
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	
	return this
}
/* }}} */

var bw=new checkBrowser();
/* function b_gbChange(color) {{{ */
function b_bgChange(color)
{
	if(bw.dom || bw.ie4)
		this.css.backgroundColor=color;
	else if(bw.ns4)
		this.css.bgColor=color;
}
/* }}} */
/* function rowOn(e,styleTo,styleFrom) {{{ */
  function rowOn(e,styleTo,styleFrom)
  {
  	this.bgChange = b_bgChange;
	  //this.css=bw.dom? document.getElementById(e.id.substr(1)).style:bw.ie4?document.all[e.id.substr(1)].style:bw.ns4?eval("document.layers." +e.id.substr(1)):0;
    //var a;
	//var b = document.getElementById(e.id.substr(1));
	  var b = bw.dom? document.getElementById(e.id.substr(1)):bw.ie4?document.all[e.id.substr(1)]:bw.ns4?eval(nest+"document.layers." +e.id.substr(1)):0;
	if(b==0) return;
	if ((styleFrom==null) || (b.className==styleFrom))
    {
	    b.className = styleTo;
		  b.style.cursor = 'hand';
    }
	
    //e.style.cursor = 'hand';
    //a = e.all;
    //if(a==null) return;
    //if(a.length==null) return;
    /*for(i=0;i<a.length;i++)
	{
      with(a(i))
	  {
        if((tagName=='TD') || (tagName=='A'))
		{
          if ((styleFrom==null) || (className==styleFrom))
		  {
		  	className = styleTo;
		  }
		}
	  }
	}*/
  }
/* }}} */
/* function setCookie(name, value, expire) {{{ */
  function setCookie(name, value, expire)
  {
  	today=new Date(); 
  	today.setTime(exp_time = (expire*1000) + today.getTime()); 
  	exp_time= (today.toGMTString()); 
  	document.cookie= name+"=" + escape(value) + "; expires="+exp_time; 
  }
/* }}} */
/* function getCookie(Name) {{{ */
  function getCookie(Name)
  {
     var search = Name + "=";
     if (document.cookie.length > 0)
	 {
        offset = document.cookie.indexOf(search) 
        if (offset != -1)
		{
           offset += search.length;
           // set index of beginning of value
           end = document.cookie.indexOf(";", offset);
           // set index of end of cookie value
           if (end == -1) 
              end = document.cookie.length
           return unescape(document.cookie.substring(offset, end))
        } 
		else
		{
			return null;
		}
     }
	 else
	 {
	 	return null;
	 }
  }
  /* }}} */
/* function CreateCookieStr( theForm ) {{{ */
  function CreateCookieStr( theForm )
  {
  
  	var str = "";

  	for( k = 0; k < theForm.elements.length; k++ )
			{
				if( theForm.elements[k].name == "att1" 
					|| theForm.elements[k].name == "att2"
					|| theForm.elements[k].name == "att3"
					|| theForm.elements[k].name == "pk_products"
					|| theForm.elements[k].name == "id_basket"
					|| theForm.elements[k].name == "p_price"
					|| theForm.elements[k].name == "p_count")
				{
					str += theForm.elements[k].name + "=" + theForm.elements[k].value + "#";
				}
			}
			
	return str;
  }
/* }}} */
/* fuction addProduct( aForm, noSubmit ) {{{ */
  function addProduct( aForm, noSubmit )
  {
   theForm = eval("document.formAdd_"+aForm);
	 if( !isNaN(parseInt(theForm.p_count.value)))
	 {
	 	if( parseInt( theForm.p_count.value ) >= 1 )
		{
			theForm.p_count.value = parseInt(theForm.p_count.value);
			str = "";
			dat = new Date();
			theForm.id_basket.value = theForm.pk_products.value+"_"+((theForm.att1 != null)?theForm.att1.value:"")+((theForm.att2 != null)?theForm.att2.value:"")+((theForm.att3 != null)?theForm.att3.value:"");
			

			str = CreateCookieStr( theForm );
			setCookie("basket[dummy]", 0, nBasketExpire);
			//setCookie("basket["+theForm.pk_products.value+"]", str, nBasketExpire);
			setCookie("basket["+theForm.id_basket.value+"]", str, nBasketExpire);
			theForm.prod_result.value = str;
			if( noSubmit == null )
			{
				eval("document.formAdd_"+aForm+".submit()");
			}
		}
		else
		{
			alert("Wartość w polu 'Ilość' musi być większa od 0");
		}
	 }
	 else
	 {
	 	alert("Wartość w polu 'Ilość' musi być liczbą");
	 }
  }
/* }}} */
/* function delProduct {{{ */
  function delProduct( aForm )
  {
   theForm = eval("document.formAdd_"+aForm);
	 str = "";
	 for( i = 0; i < theForm.elements.length; i++ )
	 {
	 	if( theForm.elements[i].name == "att1" 
			|| theForm.elements[i].name == "att2"
			|| theForm.elements[i].name == "att3"
			|| theForm.elements[i].name == "pk_products")
		{
			str += theForm.elements[i].name + "=" + theForm.elements[i].value + "#";
		}
	 }
	 setCookie("basket[dummy]", 0, nBasketExpire);
	 setCookie("basket["+aForm+"]", "", -1);
	 //theForm.prod_result.value = str;
     eval("document.formAdd_"+aForm+".submit()");
  }
/* }}} */
/* function delAllProducts() {{{ */
  function delAllProducts()
  {
  	bDelAll = false;
  	for( i = 0; i < document.forms.length; i++ )
	{
		aForm = document.forms[ i ];
		if( aForm.name.indexOf("formAdd_") > -1 )
		{
			bDelAll = true;
			aElem = aForm.id_basket;
			setCookie("basket["+aElem.value+"]", "", -1);
		}
	}
	if( bDelAll == true )
	{
		setCookie("basket[dummy]", 0, -1);
		document.formDellAllProduct.submit();
	}
  }
/* }}} */
/* fucntion abortShoppine() {{{ */
  function abortShopping()
  {
  	bDelAll = false;
  	myArray = document.formAbortShopping.elems.value.match(/\d+/g);
	for(i=0; i<myArray.length; i++)
	{
		bDelAll = true;
		setCookie("basket["+myArray[i]+"]", "", -1);
	}
	if( bDelAll == true )
	{
		setCookie("basket[dummy]", 0, -1);
		document.formAbortShopping.submit();
	}
  }
/* }}} */
/* function sendZam( aLogin ) {{{ */
  function sendZam( aLogin )
    {
        if( checkFormZam( document.formSendZam, aLogin ) )
        {
          if( aLogin != true )
          {
            bDelAll = false;
            myArray = document.formAbortShopping.elems.value.match(/\d+/g);
            for(i=0; i<myArray.length; i++)
            {
                bDelAll = true;
                setCookie("basket["+myArray[i]+"]", "", -1);
            }
            if( bDelAll == true )
            {
                setCookie("basket[dummy]", 0, -1);
                document.formSendZam.submit();
            }
          }
          else
          {
            document.formSendZam.submit();
          }
        }
    }
/* }}} */
/* function calcZam() {{{ */
  function calcZam()
    {
        tForms = document.forms;
        var sumPrice = 0;
        var subSumPrice = 0;
        var sumProd = 0;
        var itsOK = true;
        var firstIsDeleted = false;

        for( i=0; i < tForms.length; i++ )
        {
            if( tForms[ i ].name.search("formAdd_") != -1 )
            {
                aForm = tForms[ i ];
                if(isNaN(parseInt(aForm.p_count.value)))
                {
                    alert("W polu 'Ilość' powinna być wartość liczbowa.");
                    aForm.p_count.focus();
                    itsOK = false;
                    break;
                }
                if(parseInt(aForm.p_count.value)<0)
                {
                    alert("Wartość w polu 'Ilość' powinna być liczbą dodatnią.");
                    aForm.p_count.focus();
                    itsOK = false;
                    break;
                }

                if( parseInt( aForm.p_count.value ) > 0 )
                {
                    aForm.p_count.value = parseInt(aForm.p_count.value);

                    subSumPrice=parseInt(aForm.p_price.value*100) * parseInt(aForm.p_count.value);
                    sumProd += parseInt(aForm.p_count.value);
                    sumPrice += subSumPrice;

                    str = CreateCookieStr( aForm );

                    setCookie("basket[dummy]", 0, nBasketExpire);
                    setCookie("basket["+aForm.id_basket.value+"]", str, nBasketExpire);
                    aForm.prod_result.value = str;
                    
                    if( firstIsDeleted )
                    {
                        document.getElementById( "pr_head_"+aForm.id_basket.value ).style.visibility = 'hidden';
                        document.getElementById( "pr_head_"+aForm.id_basket.value ).style.position = 'absolute';
                        firstIsDeleted = false;
                    }
                }
                else
                {
                    if( i == 0 )
                    {
                        firstIsDeleted = true;
                    }
                        
                    document.getElementById( "pr_"+aForm.id_basket.value ).style.visibility = 'hidden';
                    document.getElementById( "pr_"+aForm.id_basket.value ).style.position = 'absolute';
                    setCookie("basket["+aForm.id_basket.value+"]", "", -1);
                }
            }
        }
        if( itsOK )
        {
            if( sumProd == 0 )
            {
                document.getElementById("basket_body").innerHTML = '<table cellspacing="0" cellpadding="0"><tr><td class="graybold">Twój&nbsp;koszyk:</td><td class="gray">&nbsp;&nbsp;Jest&nbsp;pusty</td></tr></table>';
                document.getElementById("basket_summary").innerHTML = "ilość&nbsp;:&nbsp;"+sumProd+"&nbsp;szt.&nbsp|&nbsp;suma&nbsp;:&nbsp;"+sumPrice/100+"&nbsp;PLN";
                document.getElementById("basket_summary_body").style.visibility = 'hidden';
                document.getElementById("basket_summary_body").style.position = 'absolute';
                document.getElementById("order_buttons").style.visibility = 'hidden';
                document.getElementById("order_buttons").style.position = 'absolute';
                document.getElementById("empty_basket").innerHTML = '<br><br><br><br><br><br>Koszyk&nbsp;jest&nbsp;pusty';

            }
            else
            {
                ss = "";
                ss += '<table cellspacing="0" cellpadding="0">';
                ss += '<tr><td class="graybold">Twój&nbsp;koszyk:</td></tr>';
								ss += '<tr><td class="gray">towarów:&nbsp;'+sumProd+';&nbsp;na sumę:&nbsp;'+sumPrice/100+'&nbsp;PLN</td></tr>';
                ss += '</table>';
                
                document.getElementById("basket_body").innerHTML = ss;
                document.getElementById("basket_summary").innerHTML = "ilość&nbsp;:&nbsp;"+sumProd+"&nbsp;szt.&nbsp|&nbsp;suma&nbsp;:&nbsp;"+sumPrice/100+"&nbsp;PLN";
            }
        }
    }
/* }}} */
/* function actDelivery( aCheck ) {{{ */
  function actDelivery( aCheck )
  {
    if( aCheck.checked )
    {
      aCheck.form.delivery_address.disabled = false;
      aCheck.form.delivery_city.disabled = false;
      aCheck.form.delivery_zip.disabled = false;
    }
    else
    {
      aCheck.form.delivery_address.disabled = true;
      aCheck.form.delivery_city.disabled = true;
      aCheck.form.delivery_zip.disabled = true;
      aCheck.form.delivery_address.value = "";
      aCheck.form.delivery_city.value = "";
      aCheck.form.delivery_zip.value = "";
    }
  }
/* }}} */
/* function checkFormZam( aForm, aLogin ) {{{ */
    function checkFormZam( aForm, aLogin )
    {
      if( aLogin == true )
      {
        if(aForm.u_login.value.length == 0)
        {
          alert("Podaj login");
          aForm.u_login.focus();
          return false;
        }
        if(aForm.u_pass_confirm.value != aForm.u_pass.value)
        {
          alert("Podaj dwa identyczne hasła w celu weryfikacji.");
          aForm.u_pass_confirm.focus();
          return false;
        }
        if(aForm.u_pass.value.length == 0)
        {
          alert("Podaj hasło");
          aForm.u_pass.focus();
          return false;
        }
      }
      if(aForm.firstname.value.length == 0)
      {
        alert("Podaj imie");
        aForm.firstname.focus();
        return false;
      }
      if(aForm.surname.value.length == 0)
      {
        alert("Podaj nazwisko");
        aForm.surname.focus();
        return false;
      }
      if(aForm.address.value.length == 0)
      {
        alert("Podaj adres");
        aForm.address.focus();
        return false;
      }
      if(aForm.zip.value.length == 0)
      {
        alert("Podaj kod pocztowy");
        aForm.zip.focus();
        return false;
      }
      if(aForm.city.value.length == 0)
      {
        alert("Podaj nazwe miasta");
        aForm.city.focus();
        return false;
      }
      if( aLogin != true )
      {
        if(aForm.pay_document.value == "faktura" && aForm.nip.value.length == 0 )
        {
         alert("Podaj nr NIP");
         aForm.nip.focus();
         return false;
        }
      }
      if(aForm.email.value.length == 0 && aForm.telephone.value.length == 0)
      {
        alert("Podaj telefon lub e-mail");
        aForm.email.focus();
        return false;
      }
      if(aForm.delivery.checked)
      {
              if(aForm.delivery_address.value.length == 0)
              {
                alert("Podaj adres dostawy");
                aForm.delivery_address.focus();
                return false;
              }
              if(aForm.delivery_zip.value.length == 0)
              {
                alert("Podaj kod pocztowy");
                aForm.delivery_zip.focus();
                return false;
              }
              if(aForm.delivery_city.value.length == 0)
              {
                alert("Podaj miasto");
                aForm.delivery_city.focus();
                return false;
              }
      }
      return true;
    }
/* }}} */
/*function checkLogin( aForm ) {{{ */
function checkLogin( aForm )
{
  if( aForm.u_pass.value == '' || aForm.u_nick.value == '' )
  {
    alert("Musisz podać login i hasło.");
    return false;
  }
  else
  {
    return true;
  }
}
/* }}} */
  var wnd, JSFSplashWin;
  var theImage;
  var theName;
  var theBorderless;
  var theUrl;

function popupPhoto2()
{
  
  width = theImage.width;
  height = theImage.height;
	ScrWidth = 640; ScrHeight = 480;
	if (window.screen) {ScrWidth = window.screen.width; ScrHeight = window.screen.height}

	if (JSFSplashWin != null && !document.layers) {JSFSplashWin.close();}
	if (theBorderless && !document.layers) {
		JSFSplashWin = window.open("", "splash", "fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");
		JSFSplashWin.resizeTo(width, height);
		//JSFSplashWin.moveTo(PosX, PosY);
	}
	else
		JSFSplashWin = window.open("", "splash", "menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=" + width + ",height=" + height );//+ ",left=" + PosX + ",top=" + PosY);

	JSFSplashWin.document.open();
	JSFSplashWin.document.clear();
	JSFSplashWin.document.write("<html><head><title>"+theName+" - kliknij aby zamknąć...</title><style><!-- body{background: #FFFFFF url(" + theUrl + ") no-repeat;} --></style></head><body title='kliknij aby zamknąć...' scroll='no'><script>function closeMe(e){window.close();} document.onclick = closeMe;</script></body></html>");
	JSFSplashWin.document.close();
	JSFSplashWin.focus();	
  /*
if( wnd != null )
  {
    wnd.close();
  }
  if( aPhoto.length > "upload/".length )
  {
  img = new Image();
  img.src = aPhoto;
  wnd = window.open("","photo","menubar=no,status=no,width="+((img.width>screen.availWidth)?(screen.availWidth-17):(img.width+17))+",height="+((img.height>screen.availHeight)?(screen.availHeight-17):(img.height+17))+",scrollbars=yes,resizable");
  wnd.document.write('<html><head><title>'+aName+'</title></head><body style="background: #FFFFFF url('+aPhoto+') no-repeat" rightmargin="0" topmargin="0" leftmargin="0" bottommargin="0">');
//  wnd.document.write('<img width="'+img.width+'" height="'+img.height+'" src="'+aPhoto+'" border="0">');
  wnd.document.write('</body></html>');
  wnd.resizeTo(img.width, img.height);
  }*/
}
function popupPhoto( aName, url, borderless )
{
  theImage = new Image();
  theImage.src = url;
  theUrl = url;
  theName = aName;
  theBorderless = borderless;
  setTimeout("popupPhoto2()",500);
}
-->
