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('Devi selezionare almeno un elemento da eliminare');
		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
 */
var slideShowA = new Array();
var slideShowCounter = 0;

function slideShowNext()	{

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

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

	if (++slideShowCounter < slideShowA.length)	{
		document.images['slideShowImage'].src = slideShowA[slideShowCounter].src;
	} else {
		slideShowCounter = 0;
		document.images['slideShowImage'].src = slideShowA[slideShowCounter].src;
	}
	document.getElementById('innerCounter').innerText = (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].src;
	} else {
		slideShowCounter = slideShowA.length - 1;
		document.images['slideShowImage'].src = slideShowA[slideShowCounter].src;
	}
	document.getElementById('innerCounter').innerText = (slideShowCounter +1 ) + " / " + slideShowA.length;
}

/**
 * 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() ;
  }
}



/**
 * Make IE's XMLHTTP object accessible through XMLHttpRequest()
 */
if (typeof XMLHttpRequest == 'undefined') {
  XMLHttpRequest = function () {
    var msxmls = ['MSXML3', 'MSXML2', 'Microsoft']
    for (var i=0; i < msxmls.length; i++) {
      try {
        return new ActiveXObject(msxmls[i]+'.XMLHTTP')
      }
      catch (e) { }
    }
    throw new Error("No XML component installed!");
  }
}


/**
 * Creates an HTTP GET request and sends the response to the callback function.
 *
 * Note that dynamic arguments in the URI should be escaped with encodeURIComponent().
 */
function HTTPGet(uri, callbackFunction, callbackParameter) {
  var xmlHttp = new XMLHttpRequest();
  var bAsync = true;
  if (!callbackFunction) {
    bAsync = false;
  }
  xmlHttp.open('GET', uri, bAsync);
  xmlHttp.send(null);

  if (bAsync) {
    if (callbackFunction) {
      xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4) {
          callbackFunction(xmlHttp.responseText, xmlHttp, callbackParameter);
        }
      }
    }
    return xmlHttp;
  } else {
    return xmlHttp.responseText;
  }
}

var arImages=new Array();
function imagesPreload() {
 var temp = imagesPreload.arguments;
 for(x=0; x < temp.length; x++) {
  arImages[x]=new Image();
  arImages[x].src=imagesPreload.arguments[x];
 }
}


var aNewsTimeoutLnk = false;

function readnews() {
	response = HTTPGet("http://www.piccolisrl.com/demo.php/Events/News/View/type/2");
	aNews = eval(response);
	if (aNews.length == 0) return;
	newsItem = aNews[0];
	news = document.getElementById('newsbox');
	image = newsItem.imagefilename ? "<img src=\"/files/News/thumb_"+newsItem.imagefilename+"\" align=\"right\" border=\"0\" vspace=\"3\" hspace=\"3\">":"";
	body = "<div>"+image+"<p><strong>"+newsItem.name+"</strong><p>"+newsItem.descr+"</div>";
	news.style.display = "none";
	news.innerHTML = body;

	Effect.BlindDown(news);
	aNewsTimeoutLnk = setTimeout('readnews()', 5000);
}









