function aitc_edit_onload() {
	var a=document.getElementsByTagName("Input");
	var dis = new Array();
	var i = 0;
	for (c=0;c<a.length;c++)
	  {
	  if (a[c].type == 'text') {
		var fld = eval("document.all."+a[c].name);
		if (fld.value.length > 2) fld.value = unescape(fld.value);
	  }
	  if (a[c].type == 'hidden') {
		var fld = eval("document.all."+a[c].name);
		if ((a[c].name.length > 7) && (a[c].name.substr(a[c].name.length - 7,7) == "_onblur")){
		if (fld.value != "") aitc_edit_onload_exec(fld.name);
		}
		}
	  }
	return true;
}

function aitc_check_mandatory(path) {
if (path != '') path = path+".document"
else path = "document";
var doc = eval(path);
var a=doc.getElementsByTagName("Input");
var ta=doc.getElementsByTagName("Textarea");
var dis = new Array();
var i = 0;
for (c=0;c<a.length;c++)
{
var b = a[c].id;
  if (b.substr(0,3)=='man') {
  if (a[c].type=='text' || a[c].type=='password') {
	var fld = eval(path+".all."+a[c].name)
  	if (fld.style.visibility != 'hidden')
	if (fld.disabled == 0)
	if (fld.value == "") { 
		var label = eval(path+".all.label"+b.substr(3,b.length-3))
		try {
			if (label.innerHTML != "")
				throw "0";
			else
				throw "1";
			}
		catch(e) {
			if (e == "0")	
				alert(CON_FIELD + ' - '+label.innerHTML+' - ' + CON_EMPTY);
			else
				alert(CON_FIELD + ' - '+fld.title+' - ' + CON_EMPTY);
			}
		fld.focus();
		return false;
		}
	 }
	}
}

for (c=0;c<ta.length;c++)
{
var b = ta[c].id;
  if (b.substr(0,3)=='man') {
	var fld = eval(path+".all."+ta[c].name)
  	if (fld.style.visibility != 'hidden')
	if (fld.disabled == 0)
	if (fld.value == "") { 
		var label = eval(path+".all.label"+b.substr(3,b.length-3))
		try {
			if (label.innerHTML != "")
				throw "0";
			else
				throw "1";
			}
		catch(e) {
			if (e == "0")	
				alert(CON_FIELD + ' - '+label.innerHTML+' - ' + CON_EMPTY);
			else
				alert(CON_FIELD + ' - '+fld.title+' - ' + CON_EMPTY);
			}
		fld.focus();
		return false;
	}
  }
}
return -1;
}

function Aitc_controls_enable(path, name, action, type) {
	var class1 = 'normal';
	/* type		1 - edit control and textarea
				2 - chooser(also date and time)
				3 - datetime 
				4 - button
				5 - tabstrip button (write only tab number, exp: 2)
				6 - menu item
				7 - radio button
	  action	0 - disabled
	  			1 - enabled		*/
	if (action == false) {
			action = true;
			class1 = 'aitc_button_disabled';
	}	else action = false;
	if (path =='') path = 'window';
	var a = eval(path);
	if (type < 4){
		a.document.all[name+'_td'].disabled=action;
		if (a.document.all[name+'_display']) a.document.all[name+'_display'].disabled=action
		else a.document.all[name].disabled=action;
		if (parseInt(type) == 2) {
			a.document.all[name+'_td1'].disabled=action; 
			a.document.all[name+'_td1'].className = class1; 
		}
		if (parseInt(type) == 3) {
			a.document.all[name+'_time'].disabled=action; 
			a.document.all[name+'_td1'].disabled=action; 
			a.document.all[name+'_td1'].className = class1; 
			a.document.all[name+'_td2'].disabled=action; 
			a.document.all[name+'_td2'].className = class1; 
		}
	} else if (parseInt(type) == 6){
		if (a.document.all['aitc_menu_item_'+name+'_m'])
			a.document.all['aitc_menu_item_'+name+'_m'].disabled=action;
	} else if (parseInt(type) == 4){
		if (a.document.all[name+'_anchor']) {
		if(action) a.document.all[name+'_anchor'].className = "aitc_button_normal";
		a.document.all[name+'_anchor'].disabled = action;
		a.document.all[name+'_image'].className = class1;
		}
	} else if (parseInt(type) == 7){
		var aq=a.document.getElementsByName(name);
			for (i=0;i<aq.length;i++) {
				aq[i].parentNode.parentNode.parentNode.disabled = action;
				aq[i].parentNode.parentNode.disabled = action;
				aq[i].parentNode.disabled = action;
				if (action == true) aq[i].className = "aitc_button_disabled";
				else aq[i].className = "none";
			}
	} else {
			var b = eval(path + ".aitc_tabstrip_button_" + name);
			b.disabled = action;
			
	}
}

function aitc_button_display(path, name, action) {
	if (path =='') path = 'window';
	var a = eval(path);
	if (parseInt(action) == 0) {
		a.document.all[name+'_anchor'].style.display = 'none';
	} else {
		a.document.all[name+'_anchor'].style.display = 'inline';
	}
}


function aitc_edit_changevalue(name, value1) {
var adisp = eval('document.all.'+name+'_display');
var ahidd = eval('document.all.'+name);
  //if (adisp.type=='text') {
	if (value1 != "") {
		if (adisp) adisp.value = aitc_format_editchange(value1);
		if (adisp) ahidd.value = aitc_format_hiddchange(value1);
		else ahidd.value = aitc_format_editchange(value1);
	} else {
		if (adisp) adisp.value = "";
		if (adisp) ahidd.value = "";
		else ahidd.value = "";
	}
//}
}

function aitc_edit_getvalue(name) {
var ahidd = eval('document.all.'+name);
if (ahidd) { 
	return ahidd.value
} else {
	var adisp = eval('document.all.'+name+'_display');
	return adisp.value
} }

function aitc_new_window(width, height, src) {
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;
	var myWin = open(src, "_blank", "width="+width+",height="+height+",status=no,toolbar=no,menubar=no,titlebar=false,top="+top+",left="+left);
}

function aitc_SearchInGrid(path) {
	var frm = eval(path);
	var viewID, viewFilter, viewFilter1, searchString;
	
	if (frm.document.all.viewID) viewID = frm.document.all.viewID
	else if (frm.frames(0)) {
		frm = eval(path + ".frames(0)"); }
	if (frm.document.all.viewID) {
		if (frm.searchDIV.style.display == 'none') {
			frm.searchDIV.style.display = 'inline';
			frm.document.all.f_search.focus();
		} else {
			window.focus();
			frm.searchDIV.style.display = 'none';
		}
	}
}

function aitc_get_xml(src){
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.open("GET", src, false);
	xmlhttp.send();
	return xmlhttp.responseText;
}
