browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);

isNN = false;
isIE = false;
isNN4 = false;
isIE4 = false;

var doc = document.all ? document.all : document;

if (browserName == "Netscape" && browserVer >= 3) {
	isNN = true;
	isNN4 = (document.layers)?true:false;
}

if (browserName == "Microsoft Internet Explorer" && browserVer >= 4) {
	isIE = true;
	isIE4 = (document.all)?true:false;
}

//
// sprawdzenie czy przy płatności kartą wybrano fakturę VAT
//
function karta_kredytowa_check_faktvat() {

	if ( formularz['useradres[useradres_formaplatnosci]'] ) {
		if ( formularz['useradres[useradres_formaplatnosci]'].value == 2 && formularz['useradres[useradres_dokument]'].value != 2) {
			formularz['useradres[useradres_dokument]'].value = 2;
			alert('Przy płatności kartą kredytową on-line konieczne jest wystawienie faktury VAT.')
		}
	}
	else if ( formularz['danefakt[useradres_formaplatnosci]'] ) {
		if ( formularz['danefakt[useradres_formaplatnosci]'].value == 2 && formularz['danefakt[useradres_dokument]'].value != 2) {
			formularz['danefakt[useradres_dokument]'].value = 2;
			alert('Przy płatności kartą kredytową on-line konieczne jest wystawienie faktury VAT.')
		}
	}

}

//
// sprawdzenie czy przy płatności kartą dane dostawy są identyczne jak dane płatnika
//
function karta_kredytowa_check_dane_wysylki_and_platnika() {

	if (
			formularz['danefakt[useradres_formaplatnosci]'].value == 2
			&& (
				formularz['danewysl[useradres_firma]'].value != formularz['danefakt[useradres_firma]'].value
				|| formularz['danewysl[useradres_ulica]'].value != formularz['danefakt[useradres_ulica]'].value
				|| formularz['danewysl[useradres_kodpocztowy]'].value != formularz['danefakt[useradres_kodpocztowy]'].value
				|| formularz['danewysl[useradres_miasto]'].value != formularz['danefakt[useradres_miasto]'].value
			)
		) {
			formularz['danewysl[useradres_firma]'].value = formularz['danefakt[useradres_firma]'].value;
			formularz['danewysl[useradres_ulica]'].value = formularz['danefakt[useradres_ulica]'].value;
			formularz['danewysl[useradres_kodpocztowy]'].value = formularz['danefakt[useradres_kodpocztowy]'].value;
			formularz['danewysl[useradres_miasto]'].value = formularz['danefakt[useradres_miasto]'].value;
			alert('Przy płatności kartą kredytową dane do wysyłki muszą być identyczne z danymi do faktury.');
	}
	else if ( formularz['danefakt[useradres_formaplatnosci]'].value == 0 ) {
		formularz['danefakt[useradres_formaplatnosci]'].value = 1;
	}
}

//
// powiększenie obrazka
//
function showimage(adres, szer, wys, opis) {
	szer += 10;
	wys  += 55;
	zdjecie = window.open ("",'zdjecie','directories=no,width=' + szer + ',height=' + wys + ',left=100,top=50,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no');
	zdjecie.document.write ("<html><head><title>Zdjęcie</title>");
	zdjecie.document.write ("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-2\">");
	zdjecie.document.write ("<link rel=stylesheet type=\"text/css\" href=\"/styles/staff.css\" title=style></head>");
	zdjecie.document.write ("<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>");
	zdjecie.document.write ("<table width=\"100%\" cellspacing=3 cellpadding=0 border=0 bgcolor=\"#333333\"></tr><td class=\"tool_name\">");
	zdjecie.document.write ("&nbsp;&nbsp;&nbsp;ABITECH<br></td></tr></table>");
	zdjecie.document.write ("<div align=center><img src=" + adres + "></div>");
	zdjecie.document.write ("<table width=\"100%\" cellspacing=3 cellpadding=0 border=0 bgcolor=\"#333333\"></tr><td align=right class=\"tool_name\">");
	zdjecie.document.write (opis + "&nbsp;&nbsp;&nbsp;</td></tr></table>");
	zdjecie.document.write ("<table width=\"100%\" cellspacing=3 cellpadding=0 border=0 bgcolor=\"#eeeeee\"></tr><td align=right>");
	zdjecie.document.write ("<a href=\"javascript:window.close()\">zamknij okno</a>&nbsp;&nbsp;&nbsp;<br><br><br></td></tr></table>");
	zdjecie.document.write ("</body></html>");
	zdjecie.focus();

}

//
// okienko z tekstem
//
function showtext( typ ) {
	szer = 500;
	wys  = 500;
	if (typ == 'lead') {
		tresc = formularz["dane[towar_opiskrotki]"].value;
	}
	else if (typ == 'opis') {
		tresc = formularz["dane[towar_opisdlugi]"].value;
	}
	tresc = tresc.replace( /\n/ig, "<br>");
	text = window.open ("",'text','directories=no,width=' + szer + ',height=' + wys + ',left=100,top=50,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
	text.document.write ("<html><head><title>Treść</title>");
	text.document.write ("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-2\">");
	text.document.write ("<link rel=stylesheet type=\"text/css\" href=\"/styles/staff.css\" title=style></head>");
	text.document.write ("<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>");
	text.document.write ("<table width=\"100%\" cellspacing=3 cellpadding=0 border=0 bgcolor=\"#333333\"></tr><td class=\"tool_name\">");
	text.document.write ("&nbsp;&nbsp;&nbsp;ABITECH<br></td></tr></table>");
	text.document.write ("<br>" + tresc + "<br><br>");
	text.document.write ("<table width=\"100%\" cellspacing=3 cellpadding=0 border=0 bgcolor=\"#eeeeee\"></tr><td align=right>");
	text.document.write ("<a href=\"javascript:window.close()\">zamknij okno</a>&nbsp;&nbsp;&nbsp;<br><br><br></td></tr></table>");
	text.document.write ("</body></html>");
}

// move
function goto_producent( id ) {
	window.location = "producent.html?id_producent=" + id;
}
function goto_dostawca( id ) {
	window.location = "dostawca.html?id_dostawca=" + id;
}
function browse_by_producent( id ) {
	window.location = "towar.html?id_towar=&id_producent=" + id;
}
function browse_by_dostawca( id ) {
	window.location = "towar.html?id_towar=&id_dostawca=" + id;
}

// windows
function window_towarmail(idt,sid) {
	towarmail = window.open(
			"/shop/towarmail/idt="+idt+"/?SID="+sid,
			"towarmail",
			"directories=no,width=468,height=465,left=100,top=50,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no");
}
function window_towaropinia(idt,sid) {
	towaropinia = window.open(
			"/shop/towaropinia/idt="+idt+"/?SID="+sid,
			"towaropinia",
			"directories=no,width=468,height=345,left=100,top=50,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no");
}
function window_compare(sid) {
	towarcompare = window.open(
			"/shop/towarcompare/?SID="+sid,
			"towarcompare",
			"directories=no,width='100%',height='100%',left=1,top=1,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no");
	towarcompare.focus();
}
function window_ulubione(idt,sid) {
	towarulubione = window.open(
			"/shop/towarulubione/idt="+idt+"?SID="+sid,
			"towarulubione",
			"directories=no,width=468,height=345,left=100,top=50,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no");
	towarulubione.focus();
}

