function moveResize(_width, _height)	{
	window.moveTo((window.screen.width - _width)/2, (window.screen.height - _height/2));
	window.resizeTo(_width, _height);
}

 /**
  * Open a window popup
  * @Author: Francesco Rabottini <dev@webzone.it>
  *
  * @param	(String) url	the url to be opened
  * @param	(int) width		the width of the window
  * @param	(int) height	the height of the window
  * @param	(String) mode	"[stlmrS]" default: ""
  *				possible values:
  *				o	s: status
  *				o	t: toolbar
  *				o	l: location
  *				o	m: menubar
  *				o	r: resizable
  *				o	S: scrollbars=yes
  *
  * @return	(Void)	focus the last opened window popup
  */
 function openpopup(url, w, h, mode)
 {
 	_top  = (screen.height - h) / 2
 	_left = (screen.width  - w) / 2;
 	option = "top="+_top+",left="+_left+",width="+w+",height="+h;
 	if (! mode) { mode = ""; }
 	opt = new Array("status","toolbar","menubar","location","resizable", "Scrollbars");
 	for (i=0; i< opt.length;i++) {
 		if (mode.indexOf(opt[i].substring(0,1)) < 0) {
 			option += ","+opt[i]+"=no";
 		} else {
 			option += ","+opt[i]+"=yes";
 		}
 	}
 	win = window.open(url, null, option.toLowerCase());
 	win.focus();
 }

/* * * * * * * * * * * * * * */
function checkAll(btn)	{
	itemId = btn.form['itemId[]'];
	if (itemId.length)	{
		for (i=0; i<itemId.length; i++)	{
			itemId[i].checked = btn.checked;
		}
	} else {
		itemId.checked = btn.checked;
	}
}

function deleteSelected(btn, notConfirmAction)	{
	itemId = btn.form['itemId[]'];
	if (itemId.length == undefined && itemId.checked)	{
		itemChecked = 1;
	} else {
		itemChecked = 0;
		for (i=0; i<itemId.length; i++)	{
			if (itemId[i].checked)	{
				itemChecked++;
			}
		}
	}
	if (itemChecked == 0)	{
		alert('You must select at least one item to be removed');
		return;
	}
	if (notConfirmAction)	{
		btn.form.submit();
		return;
	}
	if (confirm("\n\nHai scelto di Eliminare [ "+itemChecked+" ] elemeto/i\n\nVuoi davvero completare l'operazione?\n\n"))	{
		btn.form.submit();
	}
}

function syncToRole(btn)	{
	itemId = btn.form['itemId[]'];
	if (itemId.length == undefined && itemId.checked)	{
		itemChecked = 1;
	} else {
		itemChecked = 0;
		for (i=0; i<itemId.length; i++)	{
			if (itemId[i].checked)	{
				itemChecked++;
			}
		}
	}
	if (itemChecked == 0)	{
		alert('Devi selezionare almeno un utente da sincronizzare');
		return;
	}
	if (btn.form.role.value == '')	{
		alert('Devi selezionare un ruolo');
		return;
	}
	if (confirm('Vuoi davvero sincronizzare i ['+itemChecked+'] utenti selezionati ?'))	{
		btn.form.action = btn.form.action.replace('Delete','SyncToRole');
		btn.form.submit();
	}
}

function help(id, show)	{
	dhelp = document.getElementById(id);
	if (dhelp)	{
		dhelp.style.display = show ? "block":"none";
	}
	return false;
}




/**
 * YTH SlideShow
 * @Author: Francesco rabottini <dev@webzone.it>
 * @Copyright: 2006 (C) Webzone srl Pescara Italy
 */
var slideShowA = new Array();
var slideShowCounter = 0;
var slideShowCounterNextTime = 0;
var slideShowIsStarted = false;
var slideShowImageIdx = 0;

im0 = new Image();
im0.src = "/img/player_play.png";
im1 = new Image();
im1.src = "/img/player_stop.png";


function starSlideShow() {

	if (slideShowIsStarted)	{
		clearInterval(slideShowIsStarted);
		slideShowIsStarted = false;
		if (document.images['playButton']) {
			//document.images['playButton'].src = '/img/player_play.png';
		}
	} else {
		if (document.images['playButton']) {
			//document.images['playButton'].src = '/img/player_stop.png';
		}
		slideShowIsStarted = setInterval('slideShowNext()', 3000);
	}
}

function slideShowNext() {

	slideShowCounterNextTime++;
	if (slideShowCounterNextTime > 50)	{
		if (slideShowIsStarted)	{
			clearInterval(slideShowIsStarted);
			slideShowIsStarted = false;
		}
		alert("\n\nSlide show loop\n\n");
		slideShowCounterNextTime = 0;
		return;
	}

	if (slideShowA.length == 0)	{
		document.images['slideShowImage'].style.display='none';
		document.getElementById('slideShowTr').style.display='none';
		return;
	}

	if (slideShowA.length == 1 && document.getElementById('slideShowTr'))	{
		document.getElementById('slideShowTr').style.display='none';
	}

	if (++slideShowCounter < slideShowA.length)	{
		document.images['slideShowImage'].src = slideShowA[slideShowCounter][slideShowImageIdx];
	} else {
		slideShowCounter = 0;
		document.images['slideShowImage'].src = slideShowA[slideShowCounter][slideShowImageIdx];
	}
	/**/
	if (document.getElementById('innerCounter'))	{
		document.getElementById('innerCounter').innerHTML = (slideShowCounter +1 ) + "/" + slideShowA.length;
	}
	//*/
}

function slideShowPrev()	{
	if (slideShowA.length == 0)	{ document.images['slideShowImage'].style.display='none'; return; }
	if (--slideShowCounter > -1)	{
		document.images['slideShowImage'].src = slideShowA[slideShowCounter][slideShowImageIdx];
	} else {
		slideShowCounter = slideShowA.length - 1;
		document.images['slideShowImage'].src = slideShowA[slideShowCounter][slideShowImageIdx];
	}
	if (document.getElementById('innerCounter'))	{
		document.getElementById('innerCounter').innerHTML = (slideShowCounter +1 ) + "/" + slideShowA.length;
	}
}


function slideShowUp() {

	openpopup(
		slideShowA[slideShowCounter][1],
		slideShowA[slideShowCounter][2]+20,
		slideShowA[slideShowCounter][3]+20
		);
	return false;
}
/**
 * FCKeditor inizialized
 */
var _FCK_EDITOR_ENABLED_ = true;
//var _FCK_EDITOR_ENABLED_ = false;

function ini_fck(fck_field_name, fck_width, fck_height) {

	if (_FCK_EDITOR_ENABLED_)	{

		var oFCKeditor = new FCKeditor(fck_field_name);
		oFCKeditor.Height = (fck_height) ? fck_height : "300";
		oFCKeditor.Width = (fck_width) ? fck_width : "100%";
		oFCKeditor.BasePath = "/FCK/"
		oFCKeditor.ReplaceTextarea() ;
  }
}
