
	//
	// funzioni generiche Flex
	//

/*
	// imposta in un controllo data la data corrente
	
function SetTodayDate(elName) {

	var now = new Date();

	var el;	
	el = document.getElementById(elName + '_D')
	if (el)
		el.value = now.getDate();

	el = document.getElementById(elName + '_M')
	if (el)
		el.value = now.getMonth() + 1;	// Jan = 0

	el = document.getElementById(elName + '_Y')
	if (el)
		el.value = now.getYear();

}

function DumpElement(el) {

	var t = '';
	for (i in el)
		t += i + " - " + el[i] + "\n";

	alert(t);
}
*/

	//
	// hides/shows elements in the page based on CSS class
	//

function HideShowJSElements() {

/*
	$('input,img,div,a,textarea,label').each(function () {

		if (FlexJS.CSSUtils.HasClassName(this, 'jsHide'))
			this.style.display = 'none';

		if (FlexJS.CSSUtils.HasClassName(this, 'jsShow'))
			this.style.display = 'inline';

		if (FlexJS.CSSUtils.HasClassName(this, 'jsShowB'))
			this.style.display = 'block';
	});
*/

/*

	$('.jsHide').each(function () { this.style.display = 'none'; });
	$('.jsShow').each(function () { this.style.display = 'inline'; });
	$('.jsShowB').each(function () { this.style.display = 'block'; });
*/

/*

	var p = ClassNames(el);

	var l = p.length;
	for (var i = 0; i < l; i++) {
//	alert(p[i] + ' - ' + sClassName);
		if (p[i] == sClassName)
			return true;
	}
	
	return false;

			if (HasClassName(els[i], 'jsHide'))
				els[i].style.display = 'none';

			if (HasClassName(els[i], 'jsShow'))
				els[i].style.display = 'inline';

			if (HasClassName(els[i], 'jsShowB'))
				els[i].style.display = 'block';

*/

	var tags = ['input', 'img', 'div', 'a', 'textarea', 'label'];
	for (var j = 0, m = tags.length; j < m; j++) {

		for (var i = 0; (el = document.getElementsByTagName(tags[ j ])[i]); i++) {

			var p = ClassNames(el);
			for (var ii = 0, mmm = p.length; ii < mmm; ii++) {

				if (p[ii] === 'jsHide')
					el.style.display = 'none';
				else if (p[ii] === 'jsShow')
					el.style.display = 'inline';
				else if (p[ii] === 'jsShowB')
					el.style.display = 'block';
			}
		}
	}
}

// $().ready(HideShowJSElements);

	//

function OpenWinScroll(winURL, winName, w, h, top, left) {

	var winOptions = 'scrollbars=yes,resizable=yes,width=' + w + ',height=' + h + ',top=' + top + ',left=' + left + ',status=no,location=no,toolbar=no,titlebar=no';
	var wnd = window.open('', winName, winOptions);
	if (wnd != null) {

		wnd = window.open(
			winURL,
			winName,
			winOptions
		);
	}

	wnd.window.focus();
	//      setTimeout('wnd.window.focus();', 1000);

	return false;
}

	//
	// siccome se chiamato a mano in explorer il submit del form non invoca l'onsubmit()
	// bisogna farlo a mano
	//

function SubmitForm(idForm) {

	var f = document.getElementById(idForm);
	if (f) {

			// invoca l'handler solamente se definito

		if (f.onsubmit)
			f.onsubmit();

		f.submit();
	}
}

	//
	// Toggle DIV visibility
	//
	
function TV(id, controller) {

	el = document.getElementById(id);
	if (el) {

			// al primo giro verifica se l'oggetto ha il salvataggio della label
			// TBD: 'Mostra' è hardcodeed
			
		if (controller && ! controller.flexLabel)
			controller.flexLabel = controller.alt.replace('Mostra', '');

		shouldShow = (el.style.display == 'none');
		el.style.display = shouldShow ? 'block' : 'none';

		label = (shouldShow ? 'Nascondi' : 'Mostra');
		
		if (controller)
			controller.alt = label + ' ' + controller.flexLabel;
	}

		// per l'abilitazione degli iframe all'editing

	if (window.onToggleDIV) window.onToggleDIV(el);

	return false;
}

/*
	// jump del focus sui div editabili
	
function FlipFocus(id1, id2) {

	if (HasFocus(id1)) {
//alert('flip');	


window.status = 'Taking focus from ' + id1 + ' - Giving focus to ' + id2;
alert('Taking focus from ' + id1 + ' - Giving focus to ' + id2);

		ResetFocus(id1);
		GiveFocus(id2);
	

	} else {
//alert('flop');


window.status = 'Taking focus from ' + id2 + ' - Giving focus to ' + id1;
alert('Taking focus from ' + id2 + ' - Giving focus to ' + id1);

		ResetFocus(id2);
		GiveFocus(id1);
	}
}

function GiveFocus(id) {

	var el = document.getElementById(id);
	if (el) {

//alert(HasFocus(id) ? 'Has focus' : 'not have focus');
		el.focus();
		
		el.flexFocus = true;
	} else
		alert("GiveFocus: Element " + id + " non trovato");
}

function ResetFocus(id) {

	var el = document.getElementById(id);
	if (el) {
	
		el.flexFocus = null;
	} else
		alert("ResetFocus: Element " + id + " non trovato");
}

function HasFocus(id) {

	var el = document.getElementById(id);
	if (el) {

		return (el.flexFocus == true);

	} else
		alert("HasFocus: Element " + id + " non trovato");
	
	return false;
}
*/
