$(document).ready(function () {
		if($("#koszyk_mini").length)
		{
			$(window).scroll(function () {
				
				mintop=0;
				maxtop=$("#right").height() - $("#koszyk_mini").height()-165-15;
				
				scrolltop=$(window).scrollTop();
				newtop=0;
				//newtop=mintop+scrolltop;
				newtop=scrolltop+$(window).height()-($("#koszyk_mini").height())-$("#center_zkoszykiem").offset().top-15;
				if(newtop>maxtop) newtop=maxtop;
				if(newtop<mintop) newtop=mintop;
				$("#koszyk_mini").stop().animate({top: newtop},500);
			
			});
		}
		$("div.bottom_logo").hover(
			function() { $("#tooltip").html($(this).children("div.bottom_logo_opis").html()).show(); },
			function() { $("#tooltip").hide().empty(); }
		);
		$("div.produkt_loga").hover(
			function() { $("#tooltip").html($(this).children("div.produkt_loga_opis").html()).show(); },
			function() { $("#tooltip").hide().empty(); }
		);
		$("div.bottom2_logo").hover(
			function() { $("#tooltip").html("<b>"+$(this).find("img").attr("alt")+"</b>").show(); },
			function() { $("#tooltip").hide().empty(); }
		);
		$(document).mousemove(function(e) {
			$("#tooltip").css("top",e.pageY+10).css("left",e.pageX+10);
		});
	});


function TopPasswordFocus()
	{
		obj1=document.getElementById("inp_top_logowanie_haslo");
		obj2=document.getElementById("inp_top_logowanie_haslo2");
		obj1.style.display='none';
		obj2.style.display='inline';
        obj2.focus();
	}
function TopPasswordBlur()
	{
		obj1=document.getElementById("inp_top_logowanie_haslo");
		obj2=document.getElementById("inp_top_logowanie_haslo2");
		if(obj2.value=='') {
			obj2.style.display='none';
			obj1.style.display='inline';
        }
	}

function PasswordFocus()
	{
		obj1=document.getElementById("inp_logowanie_haslo");
		obj2=document.getElementById("inp_logowanie_haslo2");
		obj1.style.display='none';
		obj2.style.display='inline';
        obj2.focus();
	}
function PasswordBlur()
	{
		obj1=document.getElementById("inp_logowanie_haslo");
		obj2=document.getElementById("inp_logowanie_haslo2");
		if(obj2.value=='') {
			obj2.style.display='none';
			obj1.style.display='inline';
        }
	}

// -----------------------------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------------
function maskujKlawisze(AEvent, AMaska)
{
    var IE=/*@cc_on!@*/false;
	if (IE) {
        kodKlawisza = AEvent.keyCode;
    } else {
        kodKlawisza = AEvent.which;
    }
	//ff: which, ie8: keycode, ie6: keycode, 
	// 8 - backspace
	// 13 - enter
	// 0 klawisze sterujace
	// 39 , 37 strzalki
    if ( kodKlawisza == 8 || kodKlawisza == 13 || kodKlawisza == 0 ||kodKlawisza == 37 || kodKlawisza == 39)
	{
        return true;  // Enter
    };
	
    klawisz = String.fromCharCode(kodKlawisza);
 
    if (AMaska.indexOf(klawisz) == -1) {
        return false;
    } else {
        return true;
    }
}


// -----------------------------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------------
function displayWindow(url, width, height) 
{
    wleft = (screen.width - width) / 2;
	wtop = (screen.height - height) / 2;
	 
	if (wleft < 0) {
		width = screen.width;
		wleft = 0;
	}
	if (wtop < 0) {
		height = screen.height;
		wtop = 0;
	}
	var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + 'resizable=no,scrollbars=no,menubar=no,left='+wleft+',top='+wtop );
}	




// -----------------------------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------------
// Do rejestracji
// -----------------------------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------------
function walidacja1()
{

    var test=true;
    if (document.regform.imie.value == "") test = false;
    else if (document.regform.nazwisko.value == "") test = false;
    else if (document.regform.telefon.value == "") test = false;
    else if (document.regform.kod.value == "") test = false;
    else if (document.regform.adres.value == "") test = false;
    else if (document.regform.miasto.value == "") test = false;
    else if (document.regform.mail.value == "") test = false;
    else if (document.regform.login.value == "") test = false;
    else if (document.regform.haslo.value == "") test = false;
	else if (document.regform.token.value == "") test = false;
    
	if (test==false) 
	{
		alert('Proszę wypełnić wszystkie pola!');
		return false
	}


	reg = /^[a-zA-Z0-9±ćęłńó¶żĽˇĆĘŁŃÓ¦Ż¬._-]{1,30}@[a-zA-Z0-9±ćęłńó¶żĽˇĆĘŁŃÓ¦Ż¬._-]+(\.[a-zA-Z0-9±ćęłńó¶żĽˇĆĘŁŃÓ¦Ż¬-]+)+$/;
    wyn = document.regform.mail.value.match(reg);
	if (wyn == null)
	{
    	alert("Proszę podać prawidłowy adres e-mail!");
		return false;
	}
                                
	if (document.regform.haslo.value != document.regform.haslo2.value) 
    {
		alert("Podane hasła nie zgadzają się ze sobą!");
		return false;
	}       		    
       
	return true;
}


// -----------------------------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------------
// Do edycji danych
// -----------------------------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------------
function walidacja2()
{

    test=true;
    if (document.regform.imie.value == "") test = false;
    if (document.regform.nazwisko.value == "") test = false;
    if (document.regform.telefon.value == "") test = false;
    if (document.regform.kod.value == "") test = false;
    if (document.regform.adres.value == "") test = false;
    if (document.regform.miasto.value == "") test = false;
    if (document.regform.mail.value == "") test = false;
    if (test==false) 
	{
		alert('Proszę wypełnić wszystkie pola!');
		return false
	}


	reg = /^[a-zA-Z0-9±ćęłńó¶żĽˇĆĘŁŃÓ¦Ż¬._-]{1,30}@[a-zA-Z0-9±ćęłńó¶żĽˇĆĘŁŃÓ¦Ż¬._-]+(\.[a-zA-Z0-9±ćęłńó¶żĽˇĆĘŁŃÓ¦Ż¬-]+)+$/;
    wyn = document.regform.mail.value.match(reg);
	if (wyn == null)
	{
    	alert("Proszę podać prawidłowy adres e-mail!");
		return false;
	}
                                
	if (document.regform.nowehaslo.value != document.regform.nowehaslo2.value) 
    {
		alert("Podane hasła nie zgadzają się ze sobą!");
		return false;
	}
         
       
	return true;

}


// -----------------------------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------------
// DO FAKTURY
// -----------------------------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------------
function walidacja_zamow_zalog_faktura()
{
	if (document.getElementById('faktura').checked == true) 
	{
		document.getElementById('firma').disabled= false;
		document.getElementById('firmaadres').disabled= false;
		document.getElementById('firmamiasto').disabled= false;
		document.getElementById('firmakod').disabled= false;
		document.getElementById('firmanip').disabled= false;
	}
	else
	{
		document.getElementById('firma').disabled= true;
		document.getElementById('firmaadres').disabled= true;
		document.getElementById('firmamiasto').disabled= true;
		document.getElementById('firmakod').disabled= true;
		document.getElementById('firmanip').disabled= true;	
	}	
}

// -----------------------------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------------
// DO ZAMOWIENIA DLA ZALOGOWANEGO
// -----------------------------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------------
function walidacja_zamow_zalogowany()
{
    var test=true;
    var test2=true;
	
    if (document.getElementById('imie').value == "") test = false;
    else if (document.getElementById('nazwisko').value == "") test = false;
    else if (document.getElementById('kod').value == "") test = false;
    else if (document.getElementById('adres').value == "") test = false;
    else if (document.getElementById('miasto').value == "") test = false;
    else if (document.getElementById('telefon').value == "") test = false;
    else if (document.getElementById('mail').value == "") test = false;
	if (test==false) 
	{
		alert('Proszę wypełnić wszystkie pola zaznaczonę gwiazdką!');
		return false
	}

	reg = /^[a-zA-Z0-9±ćęłńó¶żĽˇĆĘŁŃÓ¦Ż¬._-]{1,30}@[a-zA-Z0-9±ćęłńó¶żĽˇĆĘŁŃÓ¦Ż¬._-]+(\.[a-zA-Z0-9±ćęłńó¶żĽˇĆĘŁŃÓ¦Ż¬-]+)+$/;
    mailpoprawny = document.getElementById('mail').value.match(reg);
	if (mailpoprawny == null)
	{
    	alert("Proszę podać poprawny Adres email!");
		return false;
	}	
	
	
	if (document.getElementById('faktura').checked == true) 
	{
	    if (document.getElementById('firma').value == "") test2 = false;
		else if (document.getElementById('firmaadres').value == "") test2 = false;
		else if (document.getElementById('firmamiasto').value == "") test2 = false;
		else if (document.getElementById('firmakod').value == "") test2 = false;
		else if (document.getElementById('firmanip').value == "") test2 = false;
	}	
	else if (test2==false) 
	{
		alert('Proszę wypełnić wszystkie pola związane z firmą!');
		return false
	}
	

	return true;
}


