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;
	}
}

$(function() {
        $('#productImg a').lightBox({
	        			txtImage: 'Zdjęcie',
						txtOf: 'z'
	        		});
        $('#user-skins a').lightBox({
	        			txtImage: 'Zdjęcie',
						txtOf: 'z'
	        		});
	    $('.cart_art_pict a').lightBox({
	        			txtImage: 'Zdjęcie',
						txtOf: 'z'
	        		});
	        		
       	$('.scroll-pane').jScrollPane({scrollbarWidth: "7", dragMinHeight: 23, dragMaxHeight: 23 });
        $("#mfp1 .menuFlashCategory").bind("click", function(){showIndexCat(1);});
    });

function reinitialiseScrollPane(id)	{
	$('#'+id+' .scroll-pane').jScrollPaneRemove();
	$('#'+id+' .scroll-pane').jScrollPane({scrollbarWidth: "7", dragMinHeight: 23, dragMaxHeight: 23 });
}

function showIndexCat (what) {

	if (what == 1 ) {
		$("#mfp2 .menuFlashCategory").removeClass("orange");
		$("#mfp1 .menuFlashCategory").addClass("orange");
		$("#mfp1 .menuFlashCategory").unbind("click");
		$("#mfp2 .menuFlashCategory").bind("click", function(){showIndexCat(2);});
		$("#mfp2 .menuFlashContent").slideToggle("slow",function(){$("#mfp1 .menuFlashContent").slideToggle("slow",function(){reinitialiseScrollPane('mfp1');});})
	}
	else if (what == 2 ) {
		$("#mfp1 .menuFlashCategory").removeClass("orange");
		$("#mfp2 .menuFlashCategory").addClass("orange");
		$("#mfp2 .menuFlashCategory").unbind("click");
		$("#mfp1 .menuFlashCategory").bind("click", function(){showIndexCat(1);});
		$("#mfp1 .menuFlashContent").slideToggle("slow",function(){$("#mfp2 .menuFlashContent").slideToggle("slow",function(){reinitialiseScrollPane('mfp2');});})		
	}
	
}

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 check(id) {
    $.ajax({
        type: "POST",
        url: "public/ajax/ajax.php",
        data: "action=check&kod="+$("#kodval"+id).val()+"&num="+id,
        success: function(msg){
            if(msg=="ok"){
                $("#kod"+id).html("Kod zatwiedzony");
            }

            else {
                alert( msg );
            }
        }
    });
}

function send(order) {
    $.ajax({
        type: "POST",
        url: "public/ajax/ajax.php",
        data: "action=send",
        success: function(msg){
            if(msg=="ok"){
                document.location="orders,sms,"+order;
            }
            else {
                alert( msg );
            }
        }
    });
}


function sendAgain(order) {
    $.ajax({
        type: "POST",
        url: "public/ajax/ajax.php",
        data: "action=sendAgain&oid="+order,
        success: function(msg){
            if(msg=="ok"){
                alert( msg );
            }
            else {
                alert( msg );
            }
        }
    });
}


function checkZdrapka(id) {
    $.ajax({
        type: "POST",
        url: "public/ajax/ajax.php",
        data: "action=checkZdrapka&kod="+$("#kodval"+id).val()+"&num="+id,
        success: function(msg){
            if(msg=="ok"){
                $("#kod"+id).html("Kod zatwiedzony");
            }

            else {
                alert( msg );
            }
        }
    });
}

function sendZdrapka(order) {
    $.ajax({
        type: "POST",
        url: "public/ajax/ajax.php",
        data: "action=sendZdrapka",
        success: function(msg){
            if(msg=="ok"){
                document.location="orders,zdrapka,"+order;
            }
            else {
                alert( msg );
            }
        }
    });
}