var ilosci = new Array();
var ilosci1 = new Array(108, 216, 504, 1008, 2520, 5000, 10000, 20000);
var ilosci2 = new Array(100, 200, 500, 1000, 2500, 5000, 10000, 20000);

function initDesc()
{
	sep = ', ';
	html = '(Dostępne ilości produkcyjne: ';
	for(i=0; i<ilosci.length; i++)
	{
		if(i == ilosci.length-1) { sep = ''; }
		html += ilosci[i]+sep;
	}
	html += ' szt.)';
	return html;
}

function initIlosc()
{
	if(document.getElementById('Ilosci'))
	{
		document.getElementById('Ilosci').innerHTML = initDesc();
	}
}

function showPhoto(id, foto)
{
	advAJAX.setDefaultParameters({
              onInitialization : function(obj) { document.getElementById(obj.tag).innerHTML = "Preparing..."; },
              onLoading : function(obj) { document.getElementById(obj.tag).innerHTML = '<div class=\"ajax_loader\"><img src="templates/acadia/images/loader.gif"><br>Loading ...</div>'; },
              onSuccess : function(obj) { 
			  
			  	//var re = new RegExp('[^<]*<!', "gi");
	//var atxt = obj.responseText.match(re);
	//var conv = atxt.substring(0,-2);
	//var temp = new Array();
	//temp = atxt.split('@');
	//alert(temp[0]);
			  
			  //document.getElementById(obj.tag).innerHTML = '<img src="?mod=prod&act=generate&f='+foto+'_midi.jpg" border="0" style="padding: 2px; border: 1px solid #ffffff;"><br><br>';
			  document.getElementById(obj.tag).innerHTML = obj.responseText;
			  },
              onError : function(obj) { document.getElementById(obj.tag).innerHTML = "Error..."; }
            });
            advAJAX.get({ url: "/page,prod,id,"+id+",photo,"+foto+".html" , tag: "PhotoBox" });
            advAJAX.setDefaultParameters({});
}


function in_array(needle, haystack, strict)
{
	var found = false, key, strict = !!strict;
 
    for (key in haystack) {
        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
            found = true;
            break;
        }
    }
    return found;
}

function checkIlosc()
{
	if(!in_array(document.getElementById('ilosc_kubkow').value, ilosci))
	{
		alert(initDesc());
		document.getElementById('ilosc_kubkow').value = null;
	}
	else
	{
		return 1;
	}
}

function showKubki(no)
{
	switch(no)
	{
		case 1:
			document.getElementById('grupa_1').style.display = 'block';
			//document.getElementById('grupa_5').style.display = 'none';
			document.getElementById('Ilosci').innerHTML = '(Dostępne ilości produkcyjne: '+ilosci2+' szt.)';
			ilosci = ilosci2;
		break;
		case 5:
			//document.getElementById('grupa_5').style.display = 'block';
			document.getElementById('grupa_1').style.display = 'none';
			document.getElementById('Ilosci').innerHTML = '(Dostępne ilości produkcyjne: '+ilosci1+' szt.)';
			ilosci = ilosci1;
		break;
	}
}
function isNumberKey(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;
	return true;
}

