/**
 * @author		Salvatore Miceli
 * @copyright	Copyright 2007 - Retomi - www.retomi.it
 */
function displayMessage(url) {	
	messageObj.setSource(url);
	messageObj.setCssClassMessageBox(false);
	messageObj.setSize(400,200);
	messageObj.setShadowDivVisible(true);	// Enable shadow for these boxes
	messageObj.display();
}

function closeMessage() {
	messageObj.close();	
}

function getInnerHTML(idTarget) {
	var oEditor = FCKeditorAPI.GetInstance(idTarget) ;
	var content =  oEditor.EditorDocument.body.innerHTML;
	return content;
}

function getContents(idTarget) {
	var oEditor = FCKeditorAPI.GetInstance(idTarget) ;
	var content =  oEditor.GetXHTML();
	return content;
}

function changeTab(url) {
	return callRemoteFile('content', url);
}

function callRemoteFile(idTarget, url) {
	callRemoteFileSync(idTarget, url, true);
}

function callRemoteFileSync(idTarget, url, sync) {
	var opt = {
		// Handle successful response
		onSuccess: function(t) {			
			if(idTarget != null) {
				$(idTarget).innerHTML = t.responseText;
			}
		}	
		// Handle complete response
		, onComplete: function(t) {
			
		}
		// Handle loading response
		, onLoading: function(t) {
			$(idTarget).innerHTML = '<img src="/widgets/indicator.gif" width="16" height="16" alt="Loading" title="Loading" />';
		}		
		// Handle 404
		, on404: function(t) {
			$(idTarget).innerHTML = 'Error 404: location "'+t.statusText+'" was not found.';
		}
		// Handle other errors
		, onFailure: function(t) {
			$(idTarget).innerHTML = 'Error '+t.status+' -- '+t.statusText;
		}
		, method:'get'
		, asynchronous: sync
	}
	new Ajax.Request(url, opt);
}

function submitAjaxForm(idForm, url) {
	var opt = {
		// Handle successful response
		onSuccess: function(t) {
			$('ajaxResponse').style.display = 'none';
		}	
		// Handle complete response
		, onComplete: function(t) {
		}
		// Handle loading response
		, onLoading: function(t) {
			$('ajaxResponse').style.display = 'none';
		}		
		// Handle 404
		, on404: function(t) {
			$('ajaxResponse').style.display = 'block';
			$('ajaxResponse').innerHTML = 'Error 404: location "'+t.statusText+'" was not found.';
		}
		// Handle other errors
		, onFailure: function(t) {
			$('ajaxResponse').style.display = 'block';		
			$('ajaxResponse').innerHTML = 'Error '+t.status+' -- '+t.statusText;
		}
		, method:'post'
		, asynchronous: false
		, parameters: $(idForm).serialize(true)		
	}
	new Ajax.Request(url, opt);
}

function submitForm(idSession) {
	document.forms[idSession][idSession+'[restartPag]'].value = 1;
	document.forms[idSession][idSession+'[numPag]'].value 	 = 1;
	document.forms[idSession].submit();
}

function orderFilter(url) {
	/*
	document.forms[idSession][idSession+'[orderField]'].value  = field;
	document.forms[idSession][idSession+'[order]'].value 	   = direction;
	document.forms[idSession][idSession+'[restartPag]'].value = 1;
	document.forms[idSession].submit();
	*/
	window.location.href = url+'&restartPag=1';	
}

function changePage(url) {
	window.location.href = url;
}

function MM_openBrWindow(theURL,winName,width,heigth,features) { //v2.0
	winName = winName || 'subwindow';
	width = width || 300;
	heigth = heigth || 300;
	features = features || 'scrollbars=auto,resizable=no,status=no,location=no,toolbar=no';
	features += ',width='+width+',height='+heigth;
	window.open(theURL,winName,features);
}