﻿
function changeTab(id)
{
	var i=1;
	var zakladek=4;
	for(i=0; i<=zakladek; i++)
	{
		if(document.getElementById('opisy_'+i))
		{
			if(i!=id)
			{
				document.getElementById('opisy_'+i).style.display='none';
				document.getElementById('tabs_'+i).className='tb2';
			}
			else
			{
				document.getElementById('opisy_'+i).style.display='';
				document.getElementById('tabs_'+i).className='tb1';
			}
		}
	}
}

function popup(url_)
{
okno = window.open('about:blank', '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,fullscreen=no,channelmode=no,margin=no,width=200,height=200,top=100,left=100');
okno.document.write('<html><head><title>Powiększenie</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><script type="text/javascript">var w=0; var h=0; var window_width=1; var window_height=1; var wartosc1=1; var wartosc2=1; function resize() {  window_width=document.images[0].width+5;  window_height=document.images[0].height+15;  if (screen.width<=window_width)   {	  wartosc1=screen.width;	  window_width=wartosc1;  }  if (screen.height<=window_height)   {	  wartosc2=screen.height;	  window_height=wartosc2;  }    if (navigator.appName == "Netscape") {w=-5; h=12;} if (document.images[0]) window.resizeTo(window_width+w, window_height+h);  self.focus();} </script><body style="margin:0px; overflow: none;" onload="resize();" bgcolor="#fff">');
okno.document.write('<table border="0" cellspacing="0" cellpadding="0"><tr><td><a href="javascript:window.close()"><img src="'+url_+'" border="0" alt="Zamknij / Close" style="border-color:#000000" /></a></td></tr></table></body></html>');
okno.document.close();
okno.focus();
}


function check(e, regexp) 
{
	if(navigator.userAgent.indexOf('Gecko') != -1) 
	{
		charCode = e.which;
	} 
	else 
	{
		charCode = e.keyCode;
	}
	if(charCode > 31) 
	{
		znak = String.fromCharCode(charCode);
		return regexp.test(znak);
	}
}


function addToBookmarks( sTitle, sHref ) {
	if( window.sidebar && window.sidebar.addPanel ) {
		//Gecko (Netscape 6 etc.) - add to Sidebar
		window.addPanel( sTitle, sHref, '' );
	} else if( window.external && ( navigator.platform == 'Win32' || ( window.ScriptEngine && ScriptEngine().indexOf('InScript') + 1 ) ) ) {
		//IE Win32 or iCab - checking for AddFavorite produces errors for no
		//good reason, so I use a platform and browser detect.
		//adds the current page page as a favourite; if this is unwanted,
		//simply write the desired page in here instead of 'location.href'
		window.external.AddFavorite( window.location.href, document.title );
	} else if( window.opera && window.print ) {
		//Opera 6+ - add as sidebar panel to Hotlist
		return true;
	} else if( document.layers ) {
		//NS4 & Escape - tell them how to add a bookmark quickly (adds current page,
		//not target page)
		window.alert( 'Użyj kombinacji klawiszy Ctrl+D aby dodać do ulubionych' );
	} else {
		//other browsers - tell them to add a bookmark (adds current page, not target page)
		window.alert( 'Please use your browser\'s bookmarking facility to create a bookmark' );
	}
	return false;
}

function setAsHomePage(text)
{
	if (navigator.appName == "Netscape")
	{
		alert(text);
	}
	else
	{
		document.getElementById("homepagebutton").style.behavior='url(#default#homepage)';
		document.getElementById("homepagebutton").setHomePage(urlAF);
	}
}

function getWartoscZamowienia()
{
	var val = document.getElementById('InputWartoscZamowienia').value;
	if(val)
		return parseFloat(val);
	else
		return 0.00;
}

var kosztyDostawy = 0.00;
var kosztyPlatnosci = 0.00;


function przeliczFormaDostawy(cena)
{
	kosztyDostawy = parseFloat(cena);
	var cenaZamowienia = getWartoscZamowienia();
	document.getElementById('DivCalkowityKosztZamowienia').innerHTML = number_format(parseFloat(cenaZamowienia) + parseFloat(kosztyPlatnosci) + parseFloat(kosztyDostawy), 2, ',', '');
	document.getElementById('DivCalkowityKosztZamowienia').innerHTML += '&nbsp;zł';
	return true;
}

function przeliczFormaPlatnosci(cena)
{
	kosztyPlatnosci = parseFloat(cena);
	var cenaZamowienia = getWartoscZamowienia();
	document.getElementById('DivCalkowityKosztZamowienia').innerHTML = number_format(parseFloat(cenaZamowienia) + parseFloat(kosztyPlatnosci) + parseFloat(kosztyDostawy), 2, ',', '');
	document.getElementById('DivCalkowityKosztZamowienia').innerHTML += '&nbsp;zł';
	return true;
}

function /*out: String*/ number_format( /* in: float   */ number,
                                        /* in: integer */ laenge,
                                        /* in: String  */ sep,
                                        /* in: String  */ th_sep ) {

 var pre = "";
 if(number < 0){
  pre = "-";
  number *= (-1)
 }
 number = Math.round( number * Math.pow(10, laenge) ) / Math.pow(10,
laenge);
 str_number = number+"";
 arr_int = str_number.split(".");
 if(!arr_int[0]) arr_int[0] = "0";
 if(!arr_int[1]) arr_int[1] = "";
 if(arr_int[1].length < laenge){
  nachkomma = arr_int[1];
  for(i=arr_int[1].length+1; i <= laenge; i++){ nachkomma += "0"; }
  arr_int[1] = nachkomma;
 }
 if(th_sep != "" && arr_int[0].length > 3){
  Begriff = arr_int[0];
  arr_int[0] = "";
  for(j = 3; j < Begriff.length ; j+=3){
   Extrakt = Begriff.slice(Begriff.length - j, Begriff.length - j + 3);
   arr_int[0] = th_sep + Extrakt +  arr_int[0] + "";
  }
  str_first = Begriff.substr(0, (Begriff.length % 3 == 0)?3:(Begriff.length
% 3));
  arr_int[0] = str_first + arr_int[0];
 } return pre+arr_int[0]+sep+arr_int[1];
}

