function setCookie(c_name,value,exdays)
{
value = polskieNaKrzaki(value);

var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

function polskieNaKrzaki(a)
{
	a = a.replace(/¹/gi,"aAaA");
	a = a.replace(/æ/gi,"cCcC");
	a = a.replace(/ê/gi,"eEeE");
	a = a.replace(/³/gi,"lLlL");
	a = a.replace(/ñ/gi,"nNnN");
	a = a.replace(/ó/gi,"oOoO");
	a = a.replace(/œ/gi,"sSsS");
	a = a.replace(/Ÿ/gi,"xXxX");
	a = a.replace(/¿/gi,"zZzZ");

	a = a.replace(/¥/gi,"AaAa");
	a = a.replace(/Æ/gi,"CcCc");
	a = a.replace(/Ê/gi,"EeEe");
	a = a.replace(/£/gi,"LlLl");
	a = a.replace(/Ñ/gi,"NnNn");
	a = a.replace(/Ó/gi,"OoOo");
	a = a.replace(/Œ/gi,"SsSs");
	a = a.replace(//gi,"XxXx");
	a = a.replace(/¯/gi,"ZzZz");

	return(a);
}


//


function nop()
{
	return(0);
}

function textBarOn(txt,hoff,voff)
{
	txtbartimer = setTimeout("textBarShow('"+txt+"',"+hoff+","+voff+")",500);
}

function textBarShow(txt,hoff,voff)
{
	textBar = document.getElementById("textBar");
	textBar.style.display = "";
	textBar.style.top = ""+parseInt(document.forms['mysz'].elements['cursorY'].value)-parseInt(voff)+"px";
	textBar.style.left = ""+parseInt(document.forms['mysz'].elements['cursorX'].value)-parseInt(hoff)+"px";
	textBar.innerHTML = ""+txt;
}

function textBarOff()
{
	clearTimeout(txtbartimer);
	document.getElementById("textBar").style.display = "none";
}

function rozwin_opis()
{
	document.getElementById("div_opiskrotki").style.display = "none";
	document.getElementById("div_opisdlugi").style.display = "";	
}

function zwin_opis()
{
	document.getElementById("div_opisdlugi").style.display = "none";	
	document.getElementById("div_opiskrotki").style.display = "";
}

function rozwin_spis()
{
	document.getElementById("div_spiskrotki").style.display = "none";
	document.getElementById("div_spisdlugi").style.display = "";	
}

function zwin_spis()
{
	document.getElementById("div_spisdlugi").style.display = "none";	
	document.getElementById("div_spiskrotki").style.display = "";
}


// start, mysz

function init()
{
	marginesy();

	if (window.Event)
	{
		document.captureEvents(Event.MOUSEMOVE);
	}
	document.onmousemove = getCursorXY;
}

function getCursorXY(e)
{
	document.forms['mysz'].elements['cursorX'].value = (window.Event) ? e.pageX : event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
	document.forms['mysz'].elements['cursorY'].value = (window.Event) ? e.pageY : event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
}

function marginesy()
{
	w = document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
	h = document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
	document.getElementById("strona").style.marginLeft = ""+(parseInt(w-750)/2)+"px";
}

function oplata_pocztowa()
{
	pobranie = (document.wysylka.sposob_zaplaty[1].checked + (document.wysylka.sposob_zaplaty[0].checked*2) + (document.wysylka.sposob_zaplaty[2].checked*4));
	// 1 - przelew, 2 - pobranie
	
	typ = (document.wysylka.typ_przesylki[0].checked + (document.wysylka.typ_przesylki[1].checked*2));
	// 1 - ekonomiczna, 2 - priorytetowa

	nr = 0;
	if (pobranie == 1 && typ == 1)
	{
		nr = 0;
		document.getElementById('div_typprzesylki').style.display = "inline";
	}
	if (pobranie == 1 && typ == 2)
	{
		nr = 1;
		document.getElementById('div_typprzesylki').style.display = "inline";
	}
	if (pobranie == 2 && typ == 1)
	{
		nr = 2;
		document.getElementById('div_typprzesylki').style.display = "inline";
	}
	if (pobranie == 2 && typ == 2)
	{
		nr = 3;
		document.getElementById('div_typprzesylki').style.display = "inline";
	}
	if (pobranie == 4)
	{
		nr = 4;
		document.getElementById('div_typprzesylki').style.display = "none";
	}

	for (i = 0; i <= 4; i++)
	{
		a = "oplata"+i;
		document.getElementById(a).style.display = "none";
	}
	document.getElementById("oplata"+nr).style.display = "inline";
	document.wysylka.oplata_za_wysylke.value = document.getElementById("oplata"+nr).innerHTML;
}

function zamawiam(formularz)
{
	//cena_poczta  = parseFloat(formularz.oplata_za_wysylke.value);
	//cena_ksiazki = parseFloat(formularz.oplata_za_ksiazki.value);
	//cena_razem = cena_poczta + cena_ksiazki;
	//document.wysylka.oplata_razem.value = ""+cena_razem+" z³";
}
