/* ------------------------------------------------------------------------------- */
/* Nasconde/mostra un elemento */
/* ------------------------------------------------------------------------------- */
function switch_el(el)
{
	if (document.getElementById(el).style.display == 'none') { document.getElementById(el).style.display = ''; } 
	else { document.getElementById(el).style.display = 'none'; }
}

/* ------------------------------------------------------------------------------- */
/* Cambia l'icona */
/* ------------------------------------------------------------------------------- */
function switch_icon(el, iconID, open_icon, close_icon)
{
	if (document.getElementById(el).style.display == 'none') { document[iconID].src = '../img/admin/'+open_icon; }
	else { document[iconID].src = '../img/admin/'+close_icon; }
} 

/* ------------------------------------------------------------------------------- */
/* Sulla base della risoluzione dello schermo ritorna la larghezza di un popup sulla base della grandezza specificata */
/* ------------------------------------------------------------------------------- */
function GetPopUpWidth(size)
{
scr_width = screen.width;
if (size == "verysmall") {reduct = 0.2;}	
if (size == "small") {reduct = 0.3;}	
if (size == "smallmedium") {reduct = 0.4;}	
if (size == "medium") {reduct = 0.5;}	
if (size == "mediumlarge") {reduct = 0.6;}	
if (size == "large") {reduct = 0.7;}	
if (size == "verylarge") {reduct = 0.8;}	
popup_width = scr_width * reduct;
popup_width = Math.round(popup_width);
return popup_width;
}

/* ------------------------------------------------------------------------------- */
/* Sulla base della larghezza del popup ritorna la sua altezza */
/* ------------------------------------------------------------------------------- */
function GetPopUpHeight(width)
{
popup_height = width * 0.77;
popup_height = Math.round(popup_height);
return popup_height;
}

/* ------------------------------------------------------------------------------- */
/* Apre un popup centrato nello schermo */
/* ------------------------------------------------------------------------------- */
function OpenPopUp(mypage, myname, w, h, scroll)
{
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height='+h+', width='+w+', top='+TopPosition+', left='+LeftPosition+', scrollbars='+scroll+', resizable'
return window.open(mypage, myname, settings)
}

/* ------------------------------------------------------------------------------- */
/* Chiude il popup e ricarica la pagina padre */
/* ------------------------------------------------------------------------------- */

function ClosePopUpAndReloadParent()
{
	window.opener.focus();
	window.opener.location.reload();
	window.close();
}


/* ------------------------------------------------------------------------------- */
/* Chiude il popup ma non ricarica la pagina padre */
/* ------------------------------------------------------------------------------- */

function ClosePopUp()
{
	window.close();
}


/* ------------------------------------------------------------------------------- */
/* Redirect alla pagina passata come parametro */
/* ------------------------------------------------------------------------------- */

function RedirectToPage(page)
{
	window.location = page;
}
