function open_galery(co, id, typ, img, mod_id, id2)
{
	try{
	document.body.scrollTop=0;
	document.documentElement.scrollTop=0;
	if(!id2) { id2=""; }
	if(typ==1) { var page=link_glowny+"modules/galery_standard.php"; }
	else if(typ==2) { var page=link_glowny+"modules/galery_classic.php"; }
	else if(typ==3) { var page=link_glowny+"modules/galery_ring.php"; }
	else if(typ==4) { var page=link_glowny+"modules/galery_vista.php"; }
	page+="?action="+co+"&prod_id="+id+"&mod_id=a"+mod_id+"&id="+id2+"&img="+escape(img);
	
	
	//utworzenie diva głównego
	var layers=document.createElement("div");
	layers.className="galeria_overlay";
	layers.onClick=function() { galery_close(mod_id); };
	layers.id="poles_ba"+mod_id;
	document.body.appendChild(layers);
	var layer=document.createElement("div");
	layer.className="galery_master";
	layer.id="pole_ba"+mod_id;
	document.body.appendChild(layer);
	
	var req = mint.Request();
	req.evalScripts=true;
	req.Send(page,"pole_ba"+mod_id);
	
	}catch(err){alert(err);}
}
function open_galery2a(co, id, typ, img, mod_id, id2)
{
	try{
	if(!id2) { id2=""; }
	if(typ==1) { var page=link_glowny+"modules/galery_standard.php"; }
	else if(typ==2) { var page=link_glowny+"modules/galery_classic.php"; }
	else if(typ==3) { var page=link_glowny+"modules/galery_ring.php"; }
	else if(typ==4) { var page=link_glowny+"modules/galery_vista.php"; }
	page+="?action="+co+"&prod_id="+id+"&mod_id=a"+mod_id+"&id="+id2+"&img="+escape(img);
	//utworzenie diva głównego
	var layer=document.createElement("div");
	layer.className="galery_master";
	layer.id="pole_ba"+mod_id;
	document.body.appendChild(layer);
	
	var req = mint.Request();
	req.OnSuccess = function()
	{
		//doczytanie rozmiarów i określenie pozycji
		var tmp=get_window_size();
		var h_width=document.getElementById("layer_head").clientWidth;
		var h_height=tmp[1];
		var l_width=document.getElementById("pole_ba"+mod_id).clientWidth;
		var l_height=document.getElementById("pole_ba"+mod_id).clientHeight;
		document.getElementById("pole_ba"+mod_id).style.left=((h_width-l_width)/2)+"px";
		document.getElementById("pole_ba"+mod_id).style.top=((h_height-l_height)/2)+"px";
	}
	req.evalScripts=true;
	req.Send(page,"pole_ba"+mod_id);
	
	}catch(err){alert(err);}
}
function galery_close(mod_id)
{ document.body.removeChild(document.getElementById("pole_b"+mod_id)); document.body.removeChild(document.getElementById("poles_b"+mod_id)); }
//przewijanie w lewo
function przewin_lewo(id,ile,mod_id)
{
	var max=document.getElementById(id).value;
	var page=document.getElementById(id+'_page').value-1;
	for(var a=0; a<max; a++)
	{
		if(a>=page*ile && a<(page+1)*ile) { document.getElementById(id+'_'+a).style.display="block"; }
		else { document.getElementById(id+'_'+a).style.display="none"; }
	}
	document.getElementById(id+'_page').value=page;
	if(page==0) { document.getElementById(id+'_prev').style.visibility="hidden"; }
	if(page<max/ile) { document.getElementById(id+'_next').style.visibility="visible"; }
	//przepisanie wartości do licznika
	if(document.getElementById('licznik_'+mod_id)) { document.getElementById('licznik_'+mod_id).innerHTML=((page+1)*ile)+"/"+max; }
}
function przewin_prawo(id,ile,mod_id)
{
	var max=document.getElementById(id).value;
	var page=document.getElementById(id+'_page').value*1+1;
	for(var a=0; a<max; a++)
	{
		if(a>=page*ile && a<(page+1)*ile) { document.getElementById(id+'_'+a).style.display="block"; }
		else { document.getElementById(id+'_'+a).style.display="none"; }
	}
	document.getElementById(id+'_page').value=page;
	if(page>0) { document.getElementById(id+'_prev').style.visibility="visible"; }
	if((page+1)>=max/ile) { document.getElementById(id+'_next').style.visibility="hidden"; }
	//przepisanie wartości do licznika
	var sm=(page+1)*ile;
	if(sm>max) { sm=max; }
	if(document.getElementById('licznik_'+mod_id)) { document.getElementById('licznik_'+mod_id).innerHTML=sm+"/"+max; }
}
//zaznaczanie wybranego
function zaznacz_aktywne(id, act, class1, class2)
{
	var max=document.getElementById(id).value;
	for(var a=0; a<max; a++)
	{
		if(act==id+'_'+a) { document.getElementById(id+'_'+a).className=class1; }
		else { document.getElementById(id+'_'+a).className=class2; }
	}
}
//przewijanie do wybranego
function galery_przewin_st(id,ile,mod_id,o_ile)
{
	if(o_ile>0) { for(var a=0; a<o_ile; a++) { przewin_prawo(id,ile,mod_id); } }
	else if(o_ile<0) { for(var a=o_ile*(-1); a>0; a--) { przewin_lewo(id,ile,mod_id); } }
}
//wyświetlanie poprzedniego zdjęcia
function galery_st_prev(mod, ile)
{
	try{
	//popranie aktualnego id i ostatniego
	var img_ac=parseInt(document.getElementById('ac_img_'+mod).value);
	var img_max=parseInt(document.getElementById('przewin_'+mod).value);
	document.getElementById('ac_img_'+mod).value=img_ac-1;
	if(img_ac-1==0) { document.getElementById('prev_one_'+mod).style.visibility="hidden"; }
	document.getElementById('next_one_'+mod).style.visibility="visible";
	//zaznaczenie poprzedniego
	document.getElementById("przewin_"+mod+"_"+(img_ac-1)).onclick();
	var tmp=document.getElementById("przewin_"+mod+"_"+(img_ac-1)).childNodes;
	for(var a=0; a<tmp.length; a++)
	{ if(tmp[a].id) { if(tmp[a].id.substring(0,5)=="pimg_") { tmp[a].onclick(); } } }
	var ile_r=Math.floor(((img_ac)/ile)-1);
	var ile_r2=Math.floor(((img_ac-1)/ile)-1);
	if(ile_r!=ile_r2) { galery_przewin_st("przewin_"+mod,ile,mod,-1); }
	
	}catch(err){alert(err);}
}
//wyświetlanie następnego zdjęcia
function galery_st_next(mod, ile)
{
	try{
	//popranie aktualnego id i ostatniego
	var img_ac=parseInt(document.getElementById('ac_img_'+mod).value);
	var img_max=parseInt(document.getElementById('przewin_'+mod).value);
	document.getElementById('ac_img_'+mod).value=img_ac+1;
	if(img_ac+1==img_max-1) { document.getElementById('next_one_'+mod).style.visibility="hidden"; }
	document.getElementById('prev_one_'+mod).style.visibility="visible";
	//zaznaczenie poprzedniego
	document.getElementById("przewin_"+mod+"_"+(img_ac+1)).onclick();
	var tmp=document.getElementById("przewin_"+mod+"_"+(img_ac+1)).childNodes;
	for(var a=0; a<tmp.length; a++)
	{ if(tmp[a].id) { if(tmp[a].id.substring(0,5)=="pimg_") { tmp[a].onclick(); } } }
	var ile_r=Math.ceil(((img_ac+2)/ile)-1);
	var ile_r2=Math.ceil(((img_ac+1)/ile)-1);
	if(ile_r!=ile_r2) { galery_przewin_st("przewin_"+mod,ile,mod,1); }
	}catch(err){alert(err);}
}
/* galeria typu ring */
function galery_rg_next(mod, time, ram_a, ram_b, img_w, img_h, sx, sy)
{
	img_w=Math.round(img_w/1.5);
	img_h=Math.round(img_h/1.5);
	var krok=100;
	var time_j=Math.round(time/krok);
	//odczytanie zmiennych
	var img_ac=parseInt(document.getElementById('ac_'+mod).value);
	var img_max=parseInt(document.getElementById('przewin_'+mod).value);
	if(img_ac-1<0) { var prev=img_max-1; } else { var prev=img_ac-1; }
	if(img_ac+1==img_max) { var next=0; } else { var next=img_ac+1; }
	//określenie zmiennych
	var ilosc=img_max+2;
	var kat=360/ilosc;
	var kat_min=kat/krok;
	var licznik=0;
	var tab_k=new Array();
	for(var a=0; a<ilosc; a++) { if(a!=1 && a!=ilosc-1) { tab_k[licznik]=a; licznik++; } }
	for(var a=0; a<img_max; a++)
	{
		var poz=(a+img_ac)%img_max;
		
		if(tab_k[poz]==0) { setTimeout('galery_rg_przesun('+a+',"'+mod+'",0,'+kat+','+(kat_min*(-2))+',1,'+krok+','+time_j+','+ram_a+','+ram_b+','+img_w+','+img_h+','+sx+','+sy+');',time_j); }
		else if(tab_k[poz]==2) { setTimeout('galery_rg_przesun('+a+',"'+mod+'",2,'+kat+','+(kat_min*(-2))+',1,'+krok+','+time_j+','+ram_a+','+ram_b+','+img_w+','+img_h+','+sx+','+sy+');',time_j); }
		else
		{
			setTimeout('galery_rg_przesun('+a+',"'+mod+'",'+tab_k[poz]+','+kat+','+(kat_min*(-1))+',1,'+krok+','+time_j+','+ram_a+','+ram_b+','+img_w+','+img_h+','+sx+','+sy+');',time_j);
		}
		//document.getElementById('kat_'+a).value=a+"_"+poz+"|"+tab_k[poz];
	}
	
	if(img_ac-1<0) { document.getElementById('ac_'+mod).value=img_max-1; }
	else { document.getElementById('ac_'+mod).value=img_ac-1; }
	//document.getElementById('acd').value=document.getElementById('ac_'+mod).value;
}
function galery_rg_prev(mod, time, ram_a, ram_b, img_w, img_h, sx, sy)
{
	img_w=Math.round(img_w/1.5);
	img_h=Math.round(img_h/1.5);
	var krok=100;
	var time_j=Math.round(time/krok);
	//odczytanie zmiennych
	var img_ac=parseInt(document.getElementById('ac_'+mod).value);
	var img_max=parseInt(document.getElementById('przewin_'+mod).value);
	if(img_ac-1<0) { var prev=img_max-1; } else { var prev=img_ac-1; }
	if(img_ac+1==img_max) { var next=0; } else { var next=img_ac+1; }
	//określenie zmiennych
	var ilosc=img_max+2;
	var kat=360/ilosc;
	var kat_min=kat/krok;
	var licznik=0;
	var tab_k=new Array();
	for(var a=0; a<ilosc; a++) { if(a!=1 && a!=ilosc-1) { tab_k[licznik]=a; licznik++; } }
	for(var a=0; a<img_max; a++)
	{
		var poz=(a+img_ac)%img_max;
		
		if(tab_k[poz]==0) { setTimeout('galery_rg_przesun('+a+',"'+mod+'",0,'+kat+','+(kat_min*2)+',1,'+krok+','+time_j+','+ram_a+','+ram_b+','+img_w+','+img_h+','+sx+','+sy+');',time_j); }
		else if(tab_k[poz]==img_max) { setTimeout('galery_rg_przesun('+a+',"'+mod+'",'+img_max+','+kat+','+(kat_min*2)+',1,'+krok+','+time_j+','+ram_a+','+ram_b+','+img_w+','+img_h+','+sx+','+sy+');',time_j); }
		else
		{
			setTimeout('galery_rg_przesun('+a+',"'+mod+'",'+tab_k[poz]+','+kat+','+kat_min+',1,'+krok+','+time_j+','+ram_a+','+ram_b+','+img_w+','+img_h+','+sx+','+sy+');',time_j);
		}
		//document.getElementById('kat_'+a).value=a+"_"+poz+"|"+tab_k[poz];
	}
	
	if(img_ac+1>=img_max) { document.getElementById('ac_'+mod).value=0; }
	else { document.getElementById('ac_'+mod).value=img_ac+1; }
	//document.getElementById('acd').value=document.getElementById('ac_'+mod).value;
}
function galery_rg_przesun(id, mod, poz, kat, kat_min, kolej, krok, time, ram_a, ram_b, img_w, img_h, sx, sy)
{
	var img_max=parseInt(document.getElementById('przewin_'+mod).value);
	var el=document.getElementById('pole_img_'+mod+'_'+id);
	//document.getElementById('kat_'+id).value=poz;
	//obliczenie następnej pozycji
	var kat_c=poz*kat+kolej*kat_min;
	if(kat_c<0) { kat_c=360+kat_c; }
	var sin=Math.abs(Math.sin(deg2rad(kat_c)));
	var cos=Math.abs(Math.cos(deg2rad(kat_c)));
	//document.getElementById('kat_'+id).value=kat_c;
	var wid=Math.round(ram_a*sin);
	var hei=Math.round(ram_b*cos);
	//określenie znaku
	if(kat_c<90) { var z1=-1; var z2=1; }
	else if(kat_c<180) { var z1=-1; var z2=-1; }
	else if(kat_c<270) { var z1=1; var z2=-1; }
	else if(kat_c<360) { var z1=1; var z2=1; }
	//określenie rozmiaru grafiki
	if(kat_c>90 && kat_c<270) { var z3=-1; } else { var z3=1; }
	if(kat_c<90 || (kat_c>=180 && kat_c<270)) { var tmp_c=90-(kat_c%90); }
	else { var tmp_c=kat_c%90; }
	var tmp_c=((tmp_c*z3)*(5/9))+100;
	var width=Math.round(img_w*tmp_c/100);
	var height=Math.round(img_h*tmp_c/100);
	if(poz==img_max && kat_min>0)
	{
		var nwidth=parseInt(document.getElementById('nwidth_'+mod).value);
		var nheight=parseInt(document.getElementById('nheight_'+mod).value);
		var mwidth=parseInt(document.getElementById('mwidth_'+mod).value);
		var mheight=parseInt(document.getElementById('mheight_'+mod).value);
		width=nwidth+((mwidth-nwidth)*kolej/krok);
		height=nheight+((mheight-nheight)*kolej/krok);
	}
	else if(poz==0 && kat_min>0)
	{
		var nwidth=parseInt(document.getElementById('nwidth_'+mod).value);
		var nheight=parseInt(document.getElementById('nheight_'+mod).value);
		var mwidth=parseInt(document.getElementById('mwidth_'+mod).value);
		var mheight=parseInt(document.getElementById('mheight_'+mod).value);
		width=mwidth-((mwidth-nwidth)*kolej/krok);
		height=mheight-((mheight-nheight)*kolej/krok);
	}
	else if(poz==2 && kat_min<0)
	{
		var nwidth=parseInt(document.getElementById('nwidth_'+mod).value);
		var nheight=parseInt(document.getElementById('nheight_'+mod).value);
		var mwidth=parseInt(document.getElementById('mwidth_'+mod).value);
		var mheight=parseInt(document.getElementById('mheight_'+mod).value);
		width=nwidth+((mwidth-nwidth)*kolej/krok);
		height=nheight+((mheight-nheight)*kolej/krok);
	}
	else if(poz==0 && kat_min<0)
	{
		var nwidth=parseInt(document.getElementById('nwidth_'+mod).value);
		var nheight=parseInt(document.getElementById('nheight_'+mod).value);
		var mwidth=parseInt(document.getElementById('mwidth_'+mod).value);
		var mheight=parseInt(document.getElementById('mheight_'+mod).value);
		width=mwidth-((mwidth-nwidth)*kolej/krok);
		height=mheight-((mheight-nheight)*kolej/krok);
	}
	//określenie indexu
	if(kat_min>0) { var poz_next=poz+1; }
	else { var poz_next=poz-1; }
	if(poz_next<0) { poz_next=img_max; }
	else if(poz_next==img_max) { poz_next=0; }
	if(poz_next<img_max/2) { tmp_i=50+img_max-poz_next; }
	else { tmp_i=50+poz_next; }
	//przepisanie wartości
	el.style.left=Math.round(sx+wid*z1-Math.round(width/2))+"px";
	el.style.top=Math.round(sy+hei*z2)+"px";
	el.style.zIndex=tmp_i;
	galery_rg_size(el, width, height);
	//wywołanie ponowne lub zakończenie
	if(kolej<krok) { setTimeout('galery_rg_przesun('+id+',"'+mod+'",'+poz+','+kat+','+kat_min+','+(kolej+1)+','+krok+','+time+','+ram_a+','+ram_b+','+img_w+','+img_h+','+sx+','+sy+');',time); }
	else if(poz==img_max && kat_min>0)
	{
		var mwidth=parseInt(document.getElementById('mwidth_'+mod).value);
		var mheight=parseInt(document.getElementById('mheight_'+mod).value);
		galery_rg_size(el, mwidth, mheight);
		document.getElementById('change_'+mod+'_'+id).onclick();
		el.style.zIndex=parseInt(el.style.zIndex)+2;
	}
	else if(poz==2 && kat_min<0)
	{
		var mwidth=parseInt(document.getElementById('mwidth_'+mod).value);
		var mheight=parseInt(document.getElementById('mheight_'+mod).value);
		galery_rg_size(el, mwidth, mheight);
		document.getElementById('change_'+mod+'_'+id).onclick();
		el.style.zIndex=parseInt(el.style.zIndex)+2;
	}
}
function deg2rad(deg)
{ return deg/180*Math.PI; }
function galery_rg_size(el, width, height)
{
	el.style.width=width+"px";
	el.style.height=height+"px";
	var tmp=el.childNodes;
	var div_z;
	for(var a=0; a<tmp.length; a++)
	{ if(tmp[a].id) { if(tmp[a].id.substring(0,5)=="pimg_") { div_z=tmp[a]; } } }
	var tmp=div_z.childNodes;
	var img;
	for(var a=0; a<tmp.length; a++)
	{ if(tmp[a].id) { if(tmp[a].id.substring(0,4)=="img_") { img=tmp[a]; } } }
	img.style.width=width+"px";
	img.style.height=height+"px";
}
//przewijanie galeria vista
function galery_vs_next(mod, time)
{
	var krok=20;
	var time_j=Math.round(time/krok);
	//odczytanie zmiennych
	var img_ac=parseInt(document.getElementById('ac_'+mod).value);
	var img_max=parseInt(document.getElementById('przewin_'+mod).value);
	var skok_x=parseInt(document.getElementById('width_'+mod).value);
	var skok_y=parseInt(document.getElementById('height_'+mod).value);
	
	galery_vs_przesun(img_ac, mod, skok_x*(-img_max), skok_y*(-img_max), 0, 1, 1);
	for(var a=0; a<img_max; a++)
	{
		var index=(img_ac+img_max-a)%img_max*2+50;
		document.getElementById('pole_img_'+mod+'_'+a).style.zIndex=index;
		galery_vs_przesun(a, mod, (skok_x/krok), (skok_y/krok), time_j, 1, krok);
	}
	if(img_ac+1==img_max) { document.getElementById('ac_'+mod).value=0; }
	else { document.getElementById('ac_'+mod).value=img_ac+1; }
}
function galery_vs_prev(mod, time)
{
	var krok=20;
	var time_j=Math.round(time/krok);
	//odczytanie zmiennych
	var img_ac=parseInt(document.getElementById('ac_'+mod).value);
	var img_max=parseInt(document.getElementById('przewin_'+mod).value);
	var skok_x=parseInt(document.getElementById('width_'+mod).value);
	var skok_y=parseInt(document.getElementById('height_'+mod).value);
	
	//galery_vs_przesun(img_ac, mod, skok_x*(-img_max), skok_y*(-img_max), 0, 1, 1);
	for(var a=0; a<img_max; a++)
	{
		//var index=(img_ac+img_max-a)%img_max*2+50;
		//document.getElementById('pole_img_'+mod+'_'+a).style.zIndex=index;
		galery_vs_przesun(a, mod, (skok_x/krok)*(-1), (skok_y/krok)*(-1), time_j, 1, krok);
	}
	if(img_ac==0) { document.getElementById('ac_'+mod).value=img_max-1; }
	else { document.getElementById('ac_'+mod).value=img_ac-1; }
}
function galery_vs_przesun(id, mod, skok_x, skok_y, time, kolej, krok)
{
	var el=document.getElementById('pole_img_'+mod+'_'+id);
	var poz_x=parseFloat(el.style.left);
	var poz_y=parseFloat(el.style.top);
	el.style.left=(poz_x+skok_x)+"px";
	el.style.top=(poz_y+skok_y)+"px";
	//alert(el.style.left+" x "+el.style.top);
	if(kolej<krok) { setTimeout('galery_vs_przesun('+id+',"'+mod+'",'+skok_x+','+skok_y+','+time+','+(kolej+1)+','+krok+');',time); }
	else if(skok_x<0 && time>0)
	{
		var img_ac=parseInt(document.getElementById('ac_'+mod).value);
		var img_max=parseInt(document.getElementById('przewin_'+mod).value);
		if(id==img_ac)
		{ galery_vs_przesun(id, mod, skok_x*img_max*(-krok), skok_y*img_max*(-krok), 0, 1, 1); document.getElementById('change_'+mod+'_'+id).onclick(); }
		//określenie nowej pozycji
		var index=(img_ac+img_max-id-1)%img_max*2+50;
		document.getElementById('pole_img_'+mod+'_'+id).style.zIndex=index;
	}
	else if(time>0)
	{
		var img_ac=parseInt(document.getElementById('ac_'+mod).value);
		if(id==img_ac)
		{ document.getElementById('change_'+mod+'_'+id).onclick(); }
	}
}
//przesunięcie do wybranego - Vista
function galery_vs_skok(mod, skok, time)
{
	//odczyt zmiennych
	var img_ac=parseInt(document.getElementById('ac_'+mod).value);
	var img_max=parseInt(document.getElementById('przewin_'+mod).value);
	var skok_x=parseInt(document.getElementById('width_'+mod).value);
	var skok_y=parseInt(document.getElementById('height_'+mod).value);
	var ilosc=skok-img_ac;
	if(ilosc<0) { ilosc+=img_max; }
	//alert(ilosc);
	if(ilosc>0)
	{
		for(var b=0; b<ilosc; b++)
		{
			var new_ac=(img_ac+b)%img_max;
			galery_vs_przesun(new_ac, mod, skok_x*(-img_max), skok_y*(-img_max), 0, 1, 1);
			for(var a=0; a<img_max; a++)
			{
				var index=(new_ac+img_max-a)%img_max*2+50;
				document.getElementById('pole_img_'+mod+'_'+a).style.zIndex=index;
				galery_vs_przesun(a, mod, skok_x, skok_y, 0, 1, 1);
			}
		}
		document.getElementById('change_'+mod+'_'+skok).onclick();
		document.getElementById('ac_'+mod).value=skok;
	}
}
//przesunięcie do wybranego - pierścień
function galery_rg_skok(skok, mod, ram_a, ram_b, img_w, img_h, sx, sy)
{
	try{
	img_w=Math.round(img_w/1.5);
	img_h=Math.round(img_h/1.5);
	var time_j=1;
	var img_ac=parseInt(document.getElementById('ac_'+mod).value);
	var img_max=parseInt(document.getElementById('przewin_'+mod).value);
	var ilosc=skok-img_ac;
	if(ilosc<0) { ilosc+=img_max; }
	//określenie zmiennych
	var ilosc2=img_max+2;
	var kat=360/ilosc2;
	var licznik=0;
	var tab_k=new Array();
	for(var a=0; a<ilosc2; a++) { if(a!=1 && a!=ilosc2-1) { tab_k[licznik]=a; licznik++; } }
	//alert(ilosc);
	if(ilosc>0)
	{
		for(var b=0; b<ilosc; b++)
		{
			for(var a=0; a<img_max; a++)
			{
				var new_ac=(img_ac-b)%img_max;
				if(new_ac<0) { new_ac+=img_max; }
				var poz=(a+new_ac)%img_max;
				if(tab_k[poz]==0) { setTimeout('galery_rg_przesun('+a+',"'+mod+'",0,'+kat+','+(kat*(-2))+',1,1,'+time_j+','+ram_a+','+ram_b+','+img_w+','+img_h+','+sx+','+sy+');',time_j); }
				else if(tab_k[poz]==2) { setTimeout('galery_rg_przesun('+a+',"'+mod+'",2,'+kat+','+(kat*(-2))+',1,1,'+time_j+','+ram_a+','+ram_b+','+img_w+','+img_h+','+sx+','+sy+');',time_j); }
				else
				{ setTimeout('galery_rg_przesun('+a+',"'+mod+'",'+tab_k[poz]+','+kat+','+(kat*(-1))+',1,1,'+time_j+','+ram_a+','+ram_b+','+img_w+','+img_h+','+sx+','+sy+');',time_j); }
			}
			var new_ac=(img_ac-b-1)%img_max;
			if(new_ac<0) { new_ac+=img_max; }
			document.getElementById('ac_'+mod).value=new_ac;
		}
	}
	}catch(err){alert(err);}
}

function galery_news(ac, ile, mod_id)
{
	try{
	//rozmiar okna
	var tmp=get_window_size();
	var h_width=document.getElementById("layer_head").clientWidth;
	var h_height=tmp[1];
	//określenie rozmiarów
	var l_width=0.75*h_width;
	var l_height=0.75*h_height;
	var i_width=Math.round(l_width-20);
	var i_height=Math.round(l_height-50);
	
	if(!document.getElementById("pole_ga"+mod_id))
	{
	//utworzenie powłoki
	var layer=document.createElement("div");
	layer.className="galery_master";
	layer.id="pole_ga"+mod_id;
	layer.style.width=l_width+"px";
	layer.style.height=l_height+"px";
	//pasek górny
	var head=document.createElement("div");
	head.className="row_auto";
	head.style.height="40px";
	//dodanie poprzedni/następny i numeru
	var cel1=document.createElement("div");
	cel1.className="col_20r";
	cel1.innerHTML="&nbsp;";
	cel1.id="pole_pr"+mod_id;
	var cel2=document.createElement("div");
	cel2.className="col_20c";
	cel2.innerHTML="&nbsp;";
	cel2.id="pole_nu"+mod_id;
	var cel3=document.createElement("div");
	cel3.className="col_20l";
	cel3.innerHTML="&nbsp;";
	cel3.id="pole_nx"+mod_id;
	//dodanie zamknij
	var cel4=document.createElement("div");
	cel4.className="col_40c";
	cel4.innerHTML=close_item;
	cel4.onclick=function() { document.body.removeChild(document.getElementById("pole_ga"+mod_id)); };
	head.appendChild(cel1);
	head.appendChild(cel2);
	head.appendChild(cel3);
	head.appendChild(cel4);
	//utworzenie obrazka
	var img=document.createElement("div");
	img.className="row_auto";
	//główny
	var imgg=document.createElement("img");
	imgg.id="pole_im"+mod_id;
	imgg.style.width=i_width+"px";
	imgg.style.height=i_height+"px";
	if(document.getElementById("preloader_img")) { imgg.src=document.getElementById("preloader_img").src; }
	//poboczne
	var imgp=document.createElement("img");
	imgp.id="pole_ip"+mod_id;
	imgp.style.width="0px";
	imgp.style.height="0px";
	var imgn=document.createElement("img");
	imgn.id="pole_in"+mod_id;
	imgn.style.width="0px";
	imgn.style.height="0px";
	img.appendChild(imgg);
	img.appendChild(imgp);
	img.appendChild(imgn);
	layer.appendChild(head);
	layer.appendChild(img);
	document.body.appendChild(layer);
	//określenie pozycji
	document.getElementById("pole_ga"+mod_id).style.left=((h_width-l_width)/2)+"px";
	document.getElementById("pole_ga"+mod_id).style.top=((h_height-l_height)/2)+"px";
	//alert(h_width+' '+h_height);
	}
	//ustawienie poprzeni
	if(ac<=0) { document.getElementById("pole_pr"+mod_id).innerHTML="&nbsp;"; document.getElementById("pole_pr"+mod_id).onclick=function() {}; }
	else { document.getElementById("pole_pr"+mod_id).innerHTML="&lArr;"; document.getElementById("pole_pr"+mod_id).onclick=function() { galery_news(ac-1, ile, mod_id) }; }
	//ustawienie następny
	if(ac>=(ile-1)) { document.getElementById("pole_nx"+mod_id).innerHTML="&nbsp;"; document.getElementById("pole_nx"+mod_id).onclick=function() {}; }
	else { document.getElementById("pole_nx"+mod_id).innerHTML="&rArr;"; document.getElementById("pole_nx"+mod_id).onclick=function() { galery_news(ac+1, ile, mod_id) }; }
	//ustawienie numeru
	document.getElementById("pole_nu"+mod_id).innerHTML=(parseInt(ac)+1)+"/"+ile;
	//ustawienie głównego
	var img_src=document.getElementById("img_src_"+ac+"_"+mod_id).value;
	var img_log=document.getElementById("img_log_"+ac+"_"+mod_id).value;
	document.getElementById("pole_im"+mod_id).src="image.php?img=images/news//"+img_src+"&action=news&znak="+img_log+"&w="+i_width+"&h="+i_height;
	
	if(ac>=0 && ac<ile)
	{
		document.getElementById("pole_im"+mod_id).onload=function()
		{
			var img_src=document.getElementById("img_src_"+(parseInt(ac)-1)+"_"+mod_id).value;
			var img_log=document.getElementById("img_log_"+(parseInt(ac)-1)+"_"+mod_id).value;
			document.getElementById("pole_ip"+mod_id).src="image.php?img=images/news//"+img_src+"&action=news&znak="+img_log+"&w="+i_width+"&h="+i_height;
			var img_src=document.getElementById("img_src_"+(parseInt(ac)+1)+"_"+mod_id).value;
			var img_log=document.getElementById("img_log_"+(parseInt(ac)+1)+"_"+mod_id).value;
			document.getElementById("pole_in"+mod_id).src="image.php?img=images/news//"+img_src+"&action=news&znak="+img_log+"&w="+i_width+"&h="+i_height;
		}
	}
	else if(ac>=0)
	{
		document.getElementById("pole_im"+mod_id).onload=function()
		{
			var img_src=document.getElementById("img_src_"+(parseInt(ac)-1)+"_"+mod_id).value;
			var img_log=document.getElementById("img_log_"+(parseInt(ac)-1)+"_"+mod_id).value;
			document.getElementById("pole_ip"+mod_id).src="image.php?img=images/news//"+img_src+"&action=news&znak="+img_log+"&w="+i_width+"&h="+i_height;
		}
	}
	else if(ac<ile)
	{
		document.getElementById("pole_im"+mod_id).onload=function()
		{
			var img_src=document.getElementById("img_src_"+(parseInt(ac)+1)+"_"+mod_id).value;
			var img_log=document.getElementById("img_log_"+(parseInt(ac)+1)+"_"+mod_id).value;
			document.getElementById("pole_in"+mod_id).src="image.php?img=images/news//"+img_src+"&action=news&znak="+img_log+"&w="+i_width+"&h="+i_height;
		}
	}
	
	}catch(err){alert(err);}
}


