﻿//ogloszenie
//usunięcie całej galerii
function galdel(id)
{
	//var ob1;
	//ob1=getParent(ob,"form");
	//\"$_SESSION[REQUEST_URI]&type=galdel&gal_id=
	href='index.php?m=admin&a=index&s=adm_templates_run&t=galeria&type=galdel&gal_id='+id;
	//alert(href);
	x=confirm("Czy napewno chcesz usunąc całą galerię?.\n\nKontynuować?");
	if(x)document.location=href;
	
}

//zapisanie zmian w szczegółach galerii - elemantach
function galdsave(id){
	var ob1,form;
	
	form=_d.forms['galeriaform'+id];
	//form = getParent(ob,'form');
	ob1 = form.elements['type'];
	ob1.value='galdsave';
	
	form.action+="#gal_d"+id;
	//alert(form.action+"\n\n"+ob1.value);
	form.submit();	
}

//usunięcie elementu galerii
function galddel(id){
	var ob1,form;
	
	form=_d.forms['galeriaform'+id];
	ob1 = form.elements['type'];
	ob1.value='galddel';
	
	form.action+="#gal_d"+id;
	//alert(ob1.value);
	form.submit();	
}


function galdpreview(ob){
	pic=navigator.appName == "Netscape"?ob.files.item(0).getAsDataURL():ob.value;
	//alert(navigator.appName);
	var w1,h1,x=1;
	var w=120;
	var h=120;
	
	var Img=new Image;
	Img.onload=function(){				
		var iWidth;
		var iHeight;
	
		iWidth=Img.width; 
		iHeight=Img.height;
	
		//alert("w: "+iWidth+" | h: "+iHeight);
	
		w1=Math.round((iWidth/w)*100)/100;
		h1=Math.round((iHeight/h)*100)/100;
	
		//alert("w1: "+w1+" | h1: "+h1);
	
		if(w1>1 || h1>1){
			x=(w1>=h1)?w1:h1;
			//alert("x: "+x);
			iWidth=Math.round(iWidth/x);
			iHeight=Math.round(iHeight/x);
		}
		//alert("w: "+iWidth+" | h: "+iHeight);
		preview=$c("gal_d_preview");
		//preview.style.backgroundImage="url("+src+")";
		preview.width=iWidth;
		preview.height=iHeight;
		preview.src=pic;
		//alert(src);
    }
	Img.src=pic;
}

function galdaddvalidate(){
	pathField=$c("file");
	form=_d.forms['galeriaform'];
	
	if(pathField.value.length==0){
		alert("Proszę wybrać zdjęcie.");
	}else{
		form.submit();	
	}
	
}
