function subcategory(id,tekst)
{
    window.open('kategoria,'+id,'_self');
}

function producer(id)
{
    window.open('producent,'+id,'_self');
}

function Okienko(url, width, height) {
    var okienko = window.open(url,"wokienko", 'width=' + width + ',height=' + height + ',resizable=0,scrollbars=no,menubar=no' );
}

function CheckReg()
{
	if (document.rejesrt.reg.checked == true) {
		return true;
	}
	else
	{
		alert("Musisz zaakceptować regulamin");
		return false;
	}
}

function PoliczRate(koszyk) {
    window.open('https://www.zagiel.com.pl/kalkulator/index_smart.php?action=getklientdet_si_rata&shopNo=28011111&goodsValue='+koszyk, 'Policz_rate', 'width=630,height=500,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
}

function nowe_okno() {
    window.open('https://www.zagiel.com.pl/kalkulator/jak_kupic.html', 'nowe_okno', 'width=600,height=500,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
}

function validate_Zagiel() {
    if (document.getElementById('validate_zagiel').checked == false) {
        alert ("Zanim złożysz zamówienie, zapoznaj się z procedurą udzielenia kredytu ratalnego E-kredyt Żagiel.");
        return false;
    } else {
        return true;
    }
}

function CheckData() {
	var problem = true;
	var problem1 = true;
	for (i=0;i<document.zamowienie1.pay.length;i++) {
		if (document.zamowienie1.pay[i].checked == true) {
			var problem = false;
		}
	}
	for (i=0;i<document.zamowienie1.del.length;i++) {
		if (document.zamowienie1.del[i].checked == true) {
			var problem1 = false;
		}
	}
	if (problem == true||problem1 == true) {
		return false;
	} else{
		return true;
	}
}

$.fn.centerImage = function() {
	
	
	
	return this.each(function () {
		
		containerHeight = $(this).height();
		img = $(this).find("img");
		
		imgHeight = img.height();
		
		//alert(img.attr("src")+": "+containerHeight+"-"+imgHeight);
		
		if(imgHeight < containerHeight) {
			
			ch = Math.round(containerHeight/2);
			ih = Math.round(imgHeight/2);
			
			xtop = ch - ih;
			//alert(xtop);
			
			img.css({
				position: "relative",
				top: xtop + "px"
			});
			
		}
		
	});
	
};


/*$(function() {
        $('.product-details-photo a').lightBox();
        
    });*/

$(window).load(function(){
	//$('.productImg').centerImage();
});

function showpopup(msg,time,type){
    var ss = "";
    if(type=="ok"){
        ss = "<img src=\"public/images/accept.png\" align=\"absmiddle\" alt=\"Poprawnie wykonana czynność\" />";
    }
    else if (type=="loading") {
        ss = "<img src=\"public/images/loader.gif\" align=\"absmiddle\" alt=\"Trwa ładowanie\" />";
    }
    else {
        ss = "<img src=\"public/images/exclamation.png\" align=\"absmiddle\" alt=\"Błąd\" />";
    }
    document.getElementById("infoDiv").innerHTML = ss+'&nbsp;&nbsp;'+msg;
    $("div#infoDiv").fadeIn("slow");
    document.getElementById("infoDiv").style.top= (screen.availHeight/2)-(50)+"px";
    document.getElementById("infoDiv").style.left= ((screen.availWidth/2)-150)+"px";
    var t=setTimeout('$("div#infoDiv").fadeOut("slow")',time);
}

function appendLetter(letter) {
	cur = $("#searchPhrase").val();
	$("#searchPhrase").val(cur+letter);
	$("#searchPhrase").focus();
}
