
/*

basic functions that may be used by anything within a <fulton:container>

*/



/**
page init - may be called by body.onload
*/
function init() {
	jQuery.noConflict();
	
	// call to updateSysdate function every 500 milliseconds
	setInterval('updateSysdate()', 500);
	
	// enableSimpleMCE();
	
}


function enableSimpleMCE() {
	tinyMCE.init({
		theme_advanced_fonts : "Arial=arial",
		mode : "textareas",
		theme : "simple"
	});
}

function enableAdvancedMCE() {
	tinyMCE.init({
	
		// general options
		mode: "textareas",
		theme: "advanced",
		plugins: "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
		
		// theme options
		theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,|,insertdate,inserttime,preview,|,forecolor,backcolor",
		theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,ltr,rtl,|,fullscreen",
		theme_advanced_buttons4: ",styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
		
		theme_advanced_toolbar_location: "top",
		theme_advanced_toolbar_align: "left",
		theme_advanced_statusbar_location: "bottom",
		theme_advanced_resizing: true,
		
		// Drop lists for link/image/media/template dialogs
		template_external_list_url: "lists/template_list.js",
		external_link_list_url: "lists/link_list.js",
		external_image_list_url: "lists/image_list.js",
		media_external_list_url: "lists/media_list.js"
		
	});
	
	
}

/**
update the system time at the top left of the page using an ajax call
*/
function updateSysdate() {

/*
	var request= new XmlRpcRequest(CONTEXT +'/ajax', 'native.sysdate');
	var response= request.send();
	var element= doc.getElementById('sysdate');
	element.innerHTML= response.parseXML();
	
	// supposed to help with garbage collection
	request= null;
	response= null;
	element= null;
*/
	
	jQuery.get(CONTEXT +'/ajax.native.sysdate',
	function jquery_pp(data) {
		jQuery('#sysdate').html(data);
		/*
		var element= document.getElementById('sysdate');
		element.innerHTML= data;
		element= null;
		*/
	}, 'html'
	);
	
	
}


function sortAsc(rpt, hash, col) {
	//document.body.style.cursor='wait'
	/*
	var request = new XmlRpcRequest(CONTEXT +'/ajax', 'dg.is.oss.fulton.tagex.XmlReport.sortAsc');
	request.addParam('{ServletShell}');
	request.addParam(rpt);
	request.addParam(col);
	var response = request.send();
	renderReport(rpt, hash, response.parseXML());
	request= null;
	response= null;
	*/
	
	jQuery.get(
		CONTEXT +'/ajax.dg.is.oss.fulton.tagex.XmlReport.sortAsc',
		{ shell: "{ServletShell}", report: rpt, column: col },
		function jquery_pp(data) {
			jQuery('#'+ hash).html(data);
			/*
			var element= document.getElementById(hash);
			element.innerHTML= data;
			element= null;
			*/
		},
		'html'
	);
	
	document.getElementById(hash +"_"+ col +"a").className= 'invisible';
	document.getElementById(hash +"_"+ col +"d").className= 'visible';
}
		
function sortDesc(rpt, hash, col) {
	//document.body.style.cursor='wait'
	/*
	var request = new XmlRpcRequest(CONTEXT +'/ajax', 'dg.is.oss.fulton.tagex.XmlReport.sortDesc');
	request.addParam('{ServletShell}');
	request.addParam(rpt);
	request.addParam(col);
	var response = request.send();
	renderReport(rpt, hash, response.parseXML());
	request= null;
	response= null;
	*/
	
	jQuery.get(
		CONTEXT +'/ajax.dg.is.oss.fulton.tagex.XmlReport.sortDesc',
		{ shell: "{ServletShell}", report: rpt, column: col },
		function jquery_pp(data) {
			jQuery('#'+ hash).html(data);
			/*
			var element= document.getElementById(hash);
			element.innerHTML= data;
			element= null;
			*/
		},
		'html'
	);
	
	document.getElementById(hash +"_"+ col +"a").className= 'visible';
	document.getElementById(hash +"_"+ col +"d").className= 'invisible';
	
}
		
/*
function renderReport(rpt, hash, html) {
	//document.body.style.cursor='default'
	var element = document.getElementById(hash);
	element.innerHTML= html;
	element= null;
}
*/


/**** main ****/
enableSimpleMCE();

