var win = null;

function ApriPopUp(id, w, h)
{
    var mh = 220 + parseInt(h);
    var mw =  80 + parseInt(w);
	if(win!=null)
		win.close();
    var url = 'popupImg.php?ID=' + id;
	param = 'status=no, location=no, toolbar=no, height=' + mh + ', width=' + mw + ', resizable=yes';

    win = window.open(url, 'win_img', param);
	win.focus();
}

function chiudi()
{
    window.close();
}

function scorri(idx)
{
   document.forms.frm.elements['idx'].value=idx;
   document.forms.frm.submit();
}

function Anteprima(img)
{

    var ImgAnte          = document.getElementById('ImgAnte');
    var ImgAnteContainer = document.getElementById('ImgAnteContainer');

    if(img.length==0){
        alert('Nessuna immagine disponibile');
        return;
    }
    ImgAnte.style.display = (ImgAnte.style.display=='block')?'none':'block';
    if(ImgAnteContainer.src != img )
    ImgAnte.style.display='block'
    ImgAnteContainer.src = img;


}

function Immagini_Nuova()
{

    document.forms.frm.action = 'galleriaschedaalt.php';
	document.forms.frm.elements['azione'].value = 'INS'
	document.forms.frm.elements['id'].value = '';
    document.forms.frm.submit();
}

function Immagini_Modifica()
{
   document.forms.frm.action = '';
   document.forms.frm.submit();
}

function Immagini_Cancella(id)
{
	if(!confirm('Si sta per cancellare definitivamente l\'immagine.\nContinuare?')){
		return;
	}
    document.forms.frm.elements['azione'].value = 'DEL';
	document.forms.frm.elements['id'].value = id;
    document.forms.frm.submit();	
}
