
try{
	if (!top._modalDialogs)	top._modalDialogs = new Array();
}catch(e){}

try{
	if (!top._zIndex) top._zIndex = 5000;
}catch(e){}


var xg = new xg_coreInterface();
var win = new xg_windowInterface();
var _xg_hasMenuBar = false;


function xg_coreInterface(){
	this.coreLocation = "/";
	this.serverLocation = "/";
	this.version = 1.0;
	this.document = new xgDocumentInterface;
	this.event = new xgEventsInterface;
	this.browser = new xgBrowserInterface;
	this.tabs = new xgTabsInterface;
	this.util = new xgUtilInterface;
	this.window = new xg_windowInterface;
	this.internal	=new xg_InternalInterface;
	this.setVar = xg_setInternalVar;
	this.error		= new xgErrorInterface;
	this.closeApp = xg_closeApp;
	this.app = new xg_appInterface;
	this.alert = xgi_alert;
	this.confirm = xgi_confirm;
	this.playSound = xgi_playSound;
	this._soundObject = null;
	this.setValue =xgi_setValue;
	this.setClassName = xgi_setClassName;
	this.setFocus = xgi_setFocus;
	this.getValue = xgi_getValue;
	this.getSelected = xgi_getSelected;
	this.setSelected = xgi_setSelected;
	this.setVisible = xgi_setVisible;
	this.getVisible = xgi_getVisible;
	this.setPos = xgi_setPos;
	this.setSize = xgi_setSize;
	this.setWidth = xgi_setWidth;
	this.setDisplay = xgi_setDisplay;
	this.setReadOnly = xgi_setReadOnly;
	this.getChild	= xgi_getChild;
}

function xg_closeApp(){
	try{
	window.external.closeApp();
	}catch(e){
		window.close();
	}
}

function xg_appInterface(){
		this.showAbout = xg_appInterface_showabout;
}

function xg_appInterface_showabout(av){
		try{
			window.external.showAbout(av);
		}catch(e){}
}

function xg_windowInterface(){
	this.showModal = _xgWIShowModal;
	this.showInner = _xgWIShowInner;
	this.open	=_xgWIOpen;
	this.close	= _xgWIClose;
	this.setReturnValue = _xgWIsetReturnValue;
	this.setReturnSecondValue = _xgWIsetReturnSecondValue;
	this.resizeCurrentModalWindow = _xgWIResizeModalWindow;
	this.moveCurrentModalWindow	= _xgWIMoveModalWindow;
}

function Dimension(){
	this.width = -1;
	this.height = -1;
}

function xgDocumentInterface(){
	this.currentTab = 0;
	this.screenWidth = 0;
	this.screenHeight = 0;
	this.createElement = _xgDICreateElement;
	this.createPopup   = _xgDICreatePopup;
}

function xgEventsInterface(){
	this.button							= null;
	this.srcElement					= null;
	this.srcElementId				= null;
	this.keyCode						=null;
	this.currentX						=null;
	this.currentY						=null;
}

function xgTabsInterface(){
	this.currentTab = 0;
	this.currentObject ;
	this.objLength = 0;
	this.add	 = xgTabsInterface_addElement;
	this.elems = new Array();
}

function xg_InternalInterface(){
	this.getTagFile	= xg_IIgetTagFile;

}

function xg_IIgetTagFile(){
	var url = window.location.href;
	var res = xg.util.url.getFile(url);
	if (res.indexOf("?")>-1){
		res= res.substring(0,res.indexOf("?"));	
		}
	res = replaceStr(res,".","_");
	return res;
}
function xgBrowserInterface(){

	this.sName = new String();
	this.Name = new String();
	this.Version = new String();
	this.Platform= new String();
	this.OS = new String();

	internal_detectBrowser(this);

	function internal_detectBrowser(_browser){
		_browser.Name=window.navigator.appName;
		_browser.Version=window.navigator.appVersion;
		_browser.Platform=window.navigator.platform;
		_browserUA=window.navigator.userAgent;
		
		if ((_browserUA.indexOf("Netscape")>=0)&&(parseFloat(_browser.Version)>4)){
			_browser.sName="ns";
            _browser.Name="Netscape";
          }
		
		if (_browserUA.indexOf("Apple")>-1){
			_browser.sName = "sf";
			_browser.Name = "Safari";
		}else
        if ((_browserUA.indexOf("Gecko")>=0)&&(_browserUA.indexOf("Netscape")==-1)&&(parseFloat(_browser.Version)>4)){
			_browser.sName="mo";       
            _browser.Name="Mozilla";
         }else
        if ((_browserUA.indexOf("Gecko")>=0)&&(_browserUA.indexOf("Firefox")>-1)&&(parseFloat(_browser.Version)>4)){
			_browser.sName="ff";       
            _browser.Name="FireFox";
          }
          if ((_browser.Name.indexOf("Internet Explorer")>=0)&&(_browser.Version.indexOf("5."))){
			  _browser.sName="ie";
          }
		  if ((_browser.Name.indexOf("Konqueror")>=0)){
			  _browser.sName="q";
          }
          if ((_browserUA.indexOf("Opera")>=0)){
			  _browser.sName="opera";
          }
		  if (_browser.Platform=="Win32"){
              _browser.OperatingSystem="Windows";
          }
          if ((_browser.Platform.indexOf("X")>=0)||(_browser.Platform.indexOf("x")>=0)){
			  _browser.OperatingSystem="linux";
          }
	}

}

function xgTabsInterface_addElement(elem){
	this.elems[this.elems.length] =elem;
}

//document.onmousewheel=function(){
	//return false;
//}

document.onmousedown = function(evt){
	if (xg.browser.sName == "sf"){
			//checkforopen 
	}
	try{
			xg.document.onmousedown(evt);
	}catch(ex){
	}
}

document.onmouseup = function(e){

	try{
		xg.document.onmouseup(e);
	}catch(ex){
	}
}

document.onmousemove = function(e){

	try{
		xg.document.onmousemove(e);
	}catch(ex){
	}
}

document.onkeydown = function(evt){
	if (xg.browser.sName == "ie")	{
		xg.event.keyCode = event.keyCode;
		xg.event.srcElement = event.srcElement;
	}else{
		xg.event.keyCode = evt.keyCode;
		xg.event.srcElement = evt.target;
	}
	if ((xg.event.keyCode == 27) || (xg.event.keyCode == 9)){
		VerifyOpenObjectsOnKey();
	}
}



function xgURLInterface(){
	this.get						=xgURLInterface_get;
	this.getFile					= xgURLInterface_getFile;
	this.getFileName		=xgURLInterface_getFileName;
	this.getFileExtension = xgURLInterface_getFileExtension;
}

function xgURLInterface_getFile(url){
	url = replaceStr(url,"\\","/");
	while (url.indexOf("/")>-1)	{
		url = url.substring(url.indexOf("/")+1);
	}
	return url;
}

function xgURLInterface_get(url){
	var name = xg.util.url.getFile(url);
	url = url.substring(0,url.indexOf(name));
	return url;
}

function xgURLInterface_getFileExtension(url){
	url = xg.util.url.getFile(url);
	url = url.substring(url.indexOf(".")+1);
	return url;
}

function xgURLInterface_getFileName(url){
	url = xg.util.url.getFile(url);
	url = url.substring(0,url.indexOf("."));
	return url;
}

function xgUtilInterface(){
	this.setOpacity = xgUtilInterface_setOpacity;
	this.setDisable = xgUtilInterface_setDisable;
	this.setEnable = xgUtilInterface_setEnable;
	this.getLeft		= xgUtilInterface_getLeft;
	this.getTop = xgUtilInterface_getTop;
	this.removeFromArray			=xgUtilInterface_removeFromArray;
	this.showBlackScreen = xgUtilInterface_showbs;
	this.hideBlackScreen = xgUtilInterface_hidebs;
	this.calculateTextSize = xgUtilInterface_calculateTextSize;
	this.setTextWidth = xgUtilInterface_setTextWidth;
	this.generateContainer = xgUtilInterface_generateContainer;
	this.convertDate = xgUtilInterface_convertDate;
	this.getDateFromFormat = xgUtilInterface_getDateFromFormat;
	this.getSQLDate		=xgUtilInterface_getSQLDate;
	this.getTime				=xgUtilInterface_getTime;
	this.url				= new xgURLInterface;
	this.parse2HTML = xgUtilInterface_parse2HTML;
	this.parse2Text	=xgUtilInterface_parse2Text;
	this.hasParent			=xgUtilInterface_hasparent;
	this.isNumber			=xgUtilInterface_isNumber;
	this.isLetter				=xgUtilInterface_isLetter;
	this.formatLong		=xgUtilInterface_formatLong;
	this._blackScreen		;
	
	this.v_scrollWidth = 20;
	this.h_scrollHeight = 20;

}

function xgUtilInterface_showbs(){
	if (!this._blackScreen){
		_xgcreateBs();
	}
	this._blackScreen.style.visibility = "visible";
}

function xgUtilInterface_hidebs(){
	if (this._blackScreen){
		this._blackScreen.style.visibility = "hidden";
	}else{
		try{
			top._bs.style.visibility = "hidden";
		}catch(e){}
	}
}

function xgUtilInterface_setOpacity(_surface,opacityProcent){
	if (xg.browser.sName == "ie"){
		_surface.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity="+opacityProcent+")";
		return false;
	}
		_surface.style.MozOpacity ="0."+opacityProcent;
		//filter: alpha(opacity=70);
		_surface.style.opacity = "0.5";
}

function xgUtilInterface_setDisable(_surface){
	if (xg.browser.sName == "ie"){
		_surface.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=40)";
		return false;
	}
	if (xg.browser.sName == "opera")
	{
		_surface.style.visibility = "hidden";
		return false;
	}
		_surface.style.MozOpacity="0.40";

}

function xgUtilInterface_setEnable(_surface){
	if (xg.browser.sName == "ie"){
		_surface.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
		return false;
	}
	if (xg.browser.sName == "opera")
	{
		_surface.style.visibility = "visible";
		return false;
	}
		_surface.style.MozOpacity="0.99";

}

function xgUtilInterface_getLeft(_object){
	var nLeft = 0;
	while (_object.offsetParent)
	{
		nLeft += _object.offsetLeft;
		_object = _object.offsetParent;
	}
	return nLeft;
}

function xgUtilInterface_getTop(_object){
 	var nTop = 0;
 	while (_object.offsetParent)
 	{
 		nTop += _object.offsetTop;
 		_object = _object.offsetParent;
 	}
 	return nTop;
	}

function xgUtilInterface_generateContainer(obj){
	var temphtml = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" height=\"100%\">";
	temphtml+="<tr><td valign=\"middle\">";
	temphtml+="<span class=\""+obj.LabelClassName+"\">";
	temphtml+=obj.Label;
	temphtml+="</span>";
	temphtml+="</td></tr>";
	temphtml+="</table>";
	return temphtml;
}

function xgUtilInterface_setTextWidth(text,cclass,width){
		if (width < 5){
			return "";
		}
		while (xg.util.calculateTextSize(text,cclass).Width > width){
			text = text.substring(0,text.length-4)+"...";
		}
		return text;
}

function xgUtilInterface_calculateTextSize(text,textclass){
	try{
		text=replaceStr(text,"-","a");
		text=replaceStr(text,"[","a");
		text=replaceStr(text,"]","a");
		text=replaceStr(text,"@","a");
		text=replaceStr(text," ","&nbsp;");

		var textcont = document.createElement("DIV");
		if (xg.browser.sName == "ie"){
			document.body.insertBefore(textcont);
		}else{
			document.body.appendChild(textcont);
		}
		textcont.className = textclass;
		textcont.style.position ="absolute";
		textcont.style.left = 30;
		textcont.style.top = 30;
		textcont.style.width =0;
		textcont.style.height =0;
		textcont.style.overflow = "hidden";
		textcont.style.border = "solid black 1px";
		textcont.innerHTML = text;
		var dims = new xgUtilInterface_Dimensions();
			dims.Width = textcont.scrollWidth;
			dims.Height = textcont.scrollHeight;
		document.body.removeChild(textcont);
	}catch(e){
		
	}
		return dims;
}

function xgUtilInterface_Dimensions(){
		this.Width  = -1;
		this.Height = -1;
}
if (xg.browser.sName == "ie"){
		xg.util.v_scrollWidth =19;
}
if (xg.browser.sName =="ns"){
		xg.util.v_scrollWidth = 16;
}
if (xg.browser.sName == "ff")
{
	xg.util.v_scrollWidth = 20;
}

function xgUtilInterface_hasparent(object,parentId){

	if (!object) return false;

	var parent = object.parentNode;
	while (parent){
		if (parent.id == parentId){
			return true;
		}
		parent = parent.parentNode;
	}

	return false;
}

function xgUtilInterface_isNumber(kc){
	if ( (kc>47) && (kc<58) ) return true;
	if ( (kc>95) && (kc<106) ) return true;
	return false;
}
function xgUtilInterface_isLetter(kc){
	if (((kc<48) || (kc>57)) && ((kc<94) || (kc>105))) return true;
	return false;
}
function xgUtilInterface_formatLong(value,type){
	var nv = value;
	var _type = type;
	if (_type.indexOf("[")>-1){
		_format = _type.substring(_type.indexOf("[")+1,_type.indexOf("]"));
		_type = _type.substring(0,_type.indexOf("["));
	}
	if (_type == "long")	{
		var ni = _format.substring(0,_format.indexOf("."));
		var nz = _format.substring(_format.indexOf(".")+1);

	}
	return nv;
}

function xgUtilInterface_removeFromArray(arr,index){
		var na = new Array();
		var k=0;
		for (var i=0;i<arr.length ;i++ ){
			if (i != index){
				na[k] = arr[i];
				k++
			}
		}
	return na;
}

function _xgWIShowInner(title,_url,xWidth,xHeight,xL,xT,_skin){
		var _win = new xgWindow2();
		top.window._activeModal = _win;
		top.window._activeModal.returnValue = "-1";
		_win.showInner(_url,xWidth,xHeight,xL,xT,_skin);
		
		return _win;
}

function _xgWIShowModal(title,_url,xWidth,xHeight,xL,xT,_skin){

		var _win = new xgWindow2();
		top.window._activeModal = _win;
		top.window._activeModal.returnValue = "-1";
		_win.showModal(_url,xWidth,xHeight,xL,xT,_skin);
		
		return _win;
}




function moveActiveModalWindow(x,y){
		var frm = xg.util._blackScreen._iframe;
		frm.style.left = x;
		frm.style.top =y;
}

function setReturnValueForModalWindow(val){
	try{
	xg.util._blackScreen._iframe.returnValue = val;
	}catch(e){
		top._bs._iframe.returnValue = val;
	}
}


function resizeActiveModalWindow(w,h){
		var frm = xg.util._blackScreen._iframe;
		frm.style.width = w;
		frm.style.height = h;
}







function _xgWIsetReturnValue(val){
		if (top._modalDialogs){
				for (var i=0;i<top._modalDialogs.length ;i++ ){
					var obj = top._modalDialogs[i];
					if (obj.src == window.location){
							obj.returnValue = val;
							break;
					}
				}
		}
}

function _xgWIsetReturnSecondValue(val){
		if (top._modalDialogs){
				for (var i=0;i<top._modalDialogs.length ;i++ ){
					var obj = top._modalDialogs[i];
					if (obj.src == window.location){
							obj.returnSecondValue = val;
							break;
					}
				}
		}
}
function _xgWIResizeModalWindow(w,h){
	window.parent.resizeActiveModalWindow(w,h);
}

function _xgWIMoveModalWindow(x,y){
	window.parent.moveActiveModalWindow(x,y);
}

function _xgWIClose(){
		var _html = "";
		if (top._modalDialogs){
				for (var i=0;i<top._modalDialogs.length ;i++ ){
					var obj = top._modalDialogs[i];
					_html+=window.location+"" + "-"+obj.src+"\n";
					if (obj.src == window.location){
							obj.close();
							break;
					}
				}
		}
	//		alert(_html);
}

function getDialogWithID(_id){
		if (top._modalDialogs){
				for (var i=0;i<top._modalDialogs.length ;i++ ){
					var obj = top._modalDialogs[i];
					if (obj.fid ==_id){
						return obj;
					}
				}
		}
	return null;
}

function _xgWIOpen(str,target,info,method){

	if (!info) info = "";
	if (!method)  method = "GET";
	if (method.toLowerCase() == "get"){
			var xw = window.open(str,target,info);
			xw.focus();	 

	}else{
		//extracting parameters
		var paramstr;
		var webpage = "";
		var _form = document.createElement("FORM");

		if (xg.browser.sName == "ie"){
				document.body.insertBefore(_form);
		}else{
			document.body.appendChild(_form);
			}
			_form.style.border="none";
			_form.style.backgroundColor = "transparent";
//			_form.style.overflow="hidden";
			_form.style.position = "absolute";
			_form.style.left = 0;
			_form.style.top=0;
//			_form.style.width=1;
//			_form.style.height =1;
			
		if (str.indexOf("?")>-1){
			webpage = str.substring(0,str.indexOf("?"));
			paramstr = str.substring(str.indexOf("?")+1);
			var params = new Array();
			var params_value = new Array();

			var i=0;
			while (paramstr.indexOf("&")>-1){
				try{
				var tempstr = paramstr.substring(0,paramstr.indexOf("&"));
				params[i]=tempstr.substring(0,tempstr.indexOf("="));
				params_value[i] = tempstr.substring(tempstr.indexOf("=")+1);
				paramstr = paramstr.substring(paramstr.indexOf("&")+1);
				}catch(e){
					alert(e);
					return;
				}
				i++;
			}//while
			params[i]=paramstr.substring(0,paramstr.indexOf("="));
			params_value[i] = paramstr.substring(paramstr.indexOf("=")+1);
			var _html = "";
		for (i=0;i<params.length ;i++ ){
			_html+="<input type=\"text\" name=\""+params[i]+"\" value=\""+params_value[i]+"\">";
		}
		_form.innerHTML=_html;
		}else{
			webpage = str;
		}
		_form.action = webpage;
		_form.target = target;
		_form.method = "POST";
		_form.submit();
		document.body.removeChild(_form);
	}
	return xw;
}

function xg_setInternalVar(varname,varvalue,actionFunction){
		if ((!varname) || (!varvalue))
		{
			alert("setVar() Error!   insufficient parameters!");
			return;
		}
		alert(varname+";"+varvalue+";"+actionFunction);

}

function xgUtilInterface_parse2Text(str){
	str = repaceStr(str,"<b>"," ");
	str = replaceStr(str,"</b>"," ");
	str =replaceStr(str,"<br>","\n");
	return str;
}
function xgUtilInterface_parse2HTML(str){
	str = replaceStr(str,"&lt;","<");
	str = replaceStr(str,"&gt;",">");
	str = replaceStr(str,"$lt;","&lt;");
	str = replaceStr(str,"$gt;","&gt;");
	str = replaceStr(str,"$qout;","&quot;");
	return str;
}

function fDate(){
		this.Day = 1;
		this.Month = 1;
		this.Year = 1900;
		this.Mins = 0;
		this.Secs = 0;
		this.Hours = 0;
}



function xgUtilInterface_getTime(){
	var result ="";
	var d= new Date();
	result = d.getHours()+":"+d.getMinutes();
	return result;

}


function xgUtilInterface_getSQLDate(){
	var result ="";
	var d= new Date();
	result = d.getFullYear()+"-"+(parseInt(d.getMonth())+1)+"-"+d.getDate()+" "+d.getHours()+":"+d.getMinutes()+":00";
	return result;
}

function xgUtilInterface_getDateFromFormat(value,_f){
	var result = new fDate();
		var _y=-1;var _m=-1;var _d=-1;var _h="00";var _M="00";var _s="00";
		if (_f == "date"){
			try{_y=value.substring(0,4);}catch(e){}
			try{_m=value.substring(5,7);}catch(e){}
			try{_d=value.substring(8,10);}catch(e){}
			result.Day = _d;
			result.Month = _m;
			result.Year = _y;
		} // 'date'
		else	if (_f == "datetime"){
				try{_y=value.substring(0,4);}catch(e){}
				try{_m=value.substring(5,7);}catch(e){}
				try{_d=value.substring(8,10);}catch(e){}
				try{
					var tmp = value;
					if (value.indexOf(":")>-1){
						_h=value.substring(value.indexOf(" "),value.indexOf(":"));
						tmp = tmp.substring(tmp.indexOf(":")+1);
						_M = tmp.substring(0,tmp.indexOf(":"));
						_s = tmp.substring(tmp.indexOf(":")+1);
					}else{
						_h = 0;_s=0;_M=0;
					}
					result.Day = _d;
					result.Month = _m;
					result.Year = _y;
					result.Secs = _s;
					result.Mins = _M;
					result.Hours = _h;
				}
				catch(e){}
		}// 'datetime'
		else if (_f == "xgdate"){
				try{_y=value.substring(0,4);}catch(e){}
				try{_m=value.substring(5,7);}catch(e){}
				try{_d=value.substring(8,10);}catch(e){}
				try{
					var tmp = value;
					if (value.indexOf(":")>-1){
						_h=value.substring(value.indexOf(" "),value.indexOf(":"));
						tmp = tmp.substring(tmp.indexOf(":")+1);
						_M = tmp.substring(0,tmp.indexOf(":"));
						_s = tmp.substring(tmp.indexOf(":")+1);
					}else{
						_h = 0;_s=0;_M=0;
					}
					result.Day = _d;
					result.Month = _m;
					result.Year = _y;
					result.Secs = _s;
					result.Mins = _M;
					result.Hours = _h;
				}
				catch(e){}
		}//xgdate
		else if (_f == "foxdate"){
			try{_m = value.substring(4,7)}catch(e){}
			if(_m == "Dec") _m = 12;
			else 
				if (_m == "Nov") _m = 11;
			else 
				if (_m =="Oct") _m = 10;
			else 
				if (_m == "Sep") _m = 9;
			else 
				if (_m == "Aug") _m = 8;
			else 
				if (_m == "Jul") _m = 7;
			else 
				if (_m=="Jun") _m = 6;
			else 
				if (_m == "May") _m = 5;
			else 
				if (_m == "Apr") _m = 4;
			else 
				if (_m == "Mar") _m = 3;
			else 
				if (_m == "Feb") _m = 2;
			else  _m =1;

			try{_d = value.substring(8,10);}catch(e){}
			try{_y = value.substring(25,29);}catch(e){}
					result.Day = parseInt(_d);
					result.Month = _m;
					result.Year = parseInt(_y);
					result.Secs = _s;
					result.Mins = _M;
					result.Hours = _h;

		}		
		if (result.Day == "00"){
				result.Day = "01";
		}
		if (result.Month == "00"){
				result.Month = "01";
		}
		if (result.Year == "0000"){
			result.Year = "1900";
		}
		return result;

}

function xgUtilInterface_convertDate(value,_f){
	var result = "";
	var daysName = new Array("Duminica","Luni","Marti","Miercuri","Joi","Vineri","Sambata");
	 var monthName =	new Array("Ian","Feb","Mar","Apr","Mai","Iun","Iul","Aug","Sept","Oct","Nov","Dec");
		
		if (_f == "foxdate") _f = "datetime";
		var _y=-1;var _m=-1;var _d=-1;var _h="00";var _M="00";var _s="00";
		if (_f == "date"){
			try{_y=value.substring(0,4);}catch(e){}
			try{_m=value.substring(5,7);}catch(e){}
			try{_d=value.substring(8,10);}catch(e){}
			result = _y+"-"+_m+"-"+_d;
		} // 'date'
		else	if (_f == "datetime"){
				try{
					myDate = new Date(value);
					_y = myDate.getYear();
					_m = myDate.getMonth();
					_d = myDate.getDate();
					_h = myDate.getHours();
					_M = myDate.getMinutes();
					_s = myDate.getSeconds();
					if (_m < 10){ _m = "0"+_m}
					if (_d < 10){ _d = "0"+_d}
					if (_h < 10){ _h = "0"+_h}
					if (_M < 10){ _M = "0"+_M}
					if (_s < 10){ _s = "0"+_s}
					result = _y+"-"+_m+"-"+_d+" "+_h+":"+_M+":"+_s;	
					return result;
				}catch(e){
				}
				try{_y=value.substring(0,4);}catch(e){}
				try{_m=value.substring(5,7);}catch(e){}
				try{_d=value.substring(8,10);}catch(e){}
				try{
					var tmp = value;
					if (value.indexOf(":")>-1){
						_h=value.substring(value.indexOf(" "),value.indexOf(":"));
						tmp = tmp.substring(tmp.indexOf(":")+1);
						_M = tmp.substring(0,tmp.indexOf(":"));
						_s = tmp.substring(tmp.indexOf(":")+1);
					}else{
						_h = 0;_s=0;_M=0;
					}
					result = _y+"-"+_m+"-"+_d+" "+_h+":"+_M+":"+_s;	
				}
				catch(e){}
		}// 'datetime'
		else if (_f == "xgdate"){
				try{_y=value.substring(0,4);}catch(e){}
				try{_m=value.substring(5,7);}catch(e){}
				try{_d=value.substring(8,10);}catch(e){}
				try{
					var tmp = value;
					if (value.indexOf(":")>-1){
						_h=value.substring(value.indexOf(" "),value.indexOf(":"));
						tmp = tmp.substring(tmp.indexOf(":")+1);
						_M = tmp.substring(0,tmp.indexOf(":"));
						_s = tmp.substring(tmp.indexOf(":")+1);
					}else{
						_h = 0;_s=0;_M=0;
					}
					result = _d+"/"+_m+"/"+_y;
				}
				catch(e){}
		}
		else { // user defined format
			try{ _y=value.substring(0,4);}catch(e){}
			try{_m=value.substring(5,7);}catch(e){}
			try{_d=value.substring(8,10);}catch(e){}
			result = _f;
			var _Mo = 0;
			if (_m){
				_Mo = monthName[parseFloat(_m)-1];
			}else{
			}
			result = result.replace("%d",_d);
			result = result.replace("%m",_m);
			result = result.replace("%M",_Mo);
			result = result.replace("%y",_y);
		}//format prdefinit
	

		return result;
}

function code_clickOn(obj){
	var parent = obj.parentNode.parentNode.parentNode.parentNode.parentNode;
	parent.style.overflow = "hidden";
	if (obj.innerText == "-")	{
			parent.normalHeight = parent.offsetHeight;
			parent.normalWidth = parent.offsetWidth;
			parent.style.height = 25;
			parent.style.width = 200;
			obj.innerText = "+";
	}else{
		  parent.style.height = parent.normalHeight;
		  parent.style.width = parent.normalWidth;
		  obj.innerText = "-";
	}
}

function code_mouseOn(obj){
	obj.className = "xg_code_plus_on";
}

function code_mouseOff(obj){
	obj.className = "xg_code_plus";
}

function xgErrorInterface(){
	this.add				= xgei_add;
	this.errStr			=new Array();
	this.errNo			=new Array();
	this.errStarter	=new Array();
	this.check			=xgei_check;
}

function xgei_add(errorStarter,errorNo,errorString){
	this.errStarter[this.errStarter.length] = errorStarter;
	this.errNo[this.errNo.length] = errorNo;
	this.errStr[this.errStr.length] = errorString;
	if ( document.readyState == "complete"){
		this.check();
	}
}

function xgei_check(){
	if (this.errStr.length>0){
		window.status =  "Error on Page";
		var errorurl = xg.coreLocation+"error.xgs";
		var x = screen.availWidth/2-200;
		var y = screen.availHeight/2-100 ;
		var win = xg.window.showModal('Consola de erori',errorurl,450,320,x,100);
		if (r=="@logs"){
			var loc = window.location.href;
			var toploc = top.location.href;
			var site="";
			if (loc!=toploc){
				site = toploc+"@subpage="+loc+"@target="+window.name;
			}else{
				site=loc;
			}
			xg.window.open(xg.serverLocation+"xam/admin/logs.xgs?site="+site,"_parent","","_POST");
		}
	}
}


//***************************** document interface ***************

function _xgDICreateElement(parent,element,dleft,dtop,dwidth,dheight,dCN){
	var obj = document.createElement(element);
	if (xg.browser.sName == "ie"){
		parent.insertBefore(obj);
	}else{
		parent.appendChild(obj);
	}
	obj.style.position = "absolute";
	obj.style.left = dleft;
	obj.style.top = dtop;
	obj.style.width = dwidth;
	obj.style.height = dheight;
	obj.className = dCN;
	return obj;
}	

function _xgDICreatePopup(left,top,width,height){
	var popup = new xgDIPopup();
	popup.Draw(left,top,width,height);
	return popup;
}


function _xgcreateBs(){
	var bs = top.window.document.createElement("DIV");
	top.window.document.body.appendChild(bs);
	var _height = top.window.document.body.clientHeight;
	var _width = top.window.document.body.clientWidth;
	
	if (parseInt(top.window.document.body.scrollWidth) > _width) _width = top.window.document.body.scrollWidth;
	if (parseInt(top.window.document.body.scrollHeight) > _height) _height = top.window.document.body.scrollHeight;


	bs.style.position = "absolute";bs.style.left = 0;bs.style.top=0;bs.style.width=_width;
	bs.style.height=_height;
	bs.style.backgroundImage="url("+xg.coreLocation+"/imgs/shadows/25white.png)";
	bs.style.zIndex = 10000;
	bs.style.visibility = "hidden";
	bs.style.overflow = "hidden";
	top._bs[top._bs.length] = bs;
	alert(top._bs.length);
	xg.util._blackScreen = top._bs;
}


function convertToRo(str){
	str = replaceStr(str,"S~","&#x15E;");
	str = replaceStr(str,"s~","&#x15F;");
	str = replaceStr(str,"t~","&#x163;");
	str = replaceStr(str,"a^","&acirc;");
	str = replaceStr(str,"a~","&#x103;");
	str = replaceStr(str,"A~"," &#x102;");
	str = replaceStr(str,"I^"," &Icirc;");
	str = replaceStr(str,"i^","&icirc;");

	return str;
}

function convertFromRo(str){
		str = replaceStr(str,"&#254;","t~");
		str = replaceStr(str,"\u0163","t~");
		str = replaceStr(str,"\u00fe","t~");
		str = replaceStr(str,"&#355;","t~");
		str = replaceStr(str,"\u0103","a~");
		str = replaceStr(str,"%CE","I^");
		str = replaceStr(str,"\u015F","s~");
		str = replaceStr(str,"\u015E","S~");
		str = replaceStr(str,"\u0162","T~");
		str = replaceStr(str,"%E2","a^");
		str = replaceStr(str,"%C2","A^");
		str = replaceStr(str,"%EE","i^");
		str = replaceStr(str,"\0102","A~");
	str = replaceStr(str,"&#x15E;","S");
	str = replaceStr(str,"&#x15F;","s");
	str = replaceStr(str,"&#x163;","t");
	str = replaceStr(str,"&acirc;","â");
	str = replaceStr(str,"&#x103;","a");
	str = replaceStr(str," &#x102;","A");
	str = replaceStr(str," &Icirc;","î");
	str = replaceStr(str,"&icirc;","Î");
	str = replaceStr(str,"&nbsp;"," ");
	var v = str;
for (var i=0;i<v.length ;i++ )	{
			var chr = String(v.substring(i,i+1));
			if (v.charCodeAt(i) == 355){
					//am t~
					str = replaceStr(str,v.charAt(i),"t~");
			}else
			if (v.charCodeAt(i)==354){
					//am T~
					str = replaceStr(str,v.charAt(i),"T~");
			}else
			if (v.charCodeAt(i) == 351){
				//am s~
					str = replaceStr(str,v.charAt(i),"s~");
			}else
			if (v.charCodeAt(i) == 350){
				//am S~
				str = replaceStr(str,v.charAt(i),"S~");
			}else
			if (v.charCodeAt(i) == 259){
				//am a~
				str = replaceStr(str,v.charAt(i),"a~");
			}else
			if (v.charCodeAt(i) == 258){
				//am A~
				str = replaceStr(str,v.charAt(i),"A~");
			}else
			if (v.charCodeAt(i) == 238){
				//am i^
				str = replaceStr(str,v.charAt(i),"i^");
			}else
			if (v.charCodeAt(i) == 206){
				//am I^
				str = replaceStr(str,v.charAt(i),"I^");
			}else
			if (v.charCodeAt(i) == 226){
				//am a^
				str = replaceStr(str,v.charAt(i),"a^");
			}else
			if (v.charCodeAt(i) == 206){
				//am A^
				str = replaceStr(str,v.charAt(i),"A^");
			}
		}
	return str;
}

function removeAllTags(str){
	//caut inainte
	var mystr = "";
	var k =0;
	while (str.indexOf("<")>-1){
	
	if (str.indexOf("<")>-1){
		 mystr += str.substring(0,str.indexOf("<"));
		str = str.substring(str.indexOf("<")+1);
		if (str.indexOf("/>")>-1){
			str = str.substring(str.indexOf("/>")+2);
		}else
		if (str.indexOf(">")>-1){
			str = str.substring(str.indexOf(">")+1);
		}
	}
	k++;	
}
	if (k==0 && mystr.length == 0) mystr = str;
	return mystr;
}



//xg interface

function xgi_createSoundObject(){
}

function xgi_playSound(_url){
}

function xgi_alert(mess){
	var y = document.body.clientHeight;
	y = y/2-150;
	var win = xg.window.showModal("",xg.coreLocation+"alert.xgs?txt="+mess,300,150,0,y,"black");
}

function xgi_confirm(mess){
	var y = document.body.clientHeight;
	y = y/2-150;
	var win = xg.window.showModal("",xg.coreLocation +"confirm.xgs?txt="+mess,400,150,0,y,"black");
	return win;
}

Array.prototype.removeAt = function(){
	
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function verifyForAcceptedChars(str){
		var myChars = "qwertyuiopasdfghjklzxcvbnm1234567890-._";
		for (var i=0;i<str.length ;i++ ){
				var chr = str.substring(i,i+1);
				if (myChars.indexOf(chr)==-1){
						return false;
				}
		}

		return true;
}


function xgi_setClassName(objid,value){
	var obj =document.getElementById(objid);
	obj.className = value;
}

function xgi_setValue(objid,value,color){
		var obj = document.getElementById(objid);
		if (obj == null) return;
		if (obj.tagName == "INPUT"){
				obj.value = value;
				if (color){
					obj.style.color = color;
				}
		}else
		if (obj.tagName == "DIV" || obj.tagName == "SPAN"){
			obj.innerHTML = value;
		}else
			if (obj.tagName == "SELECT"){
				for (var i = 0;i<obj.length ;i++ ){
					if (obj[i].value == value){
							obj[i].selected = true;
							break;
					}
				}
			}else
				if (obj.tagName == "IMG"){
					obj.src = value;
		}else
			if (obj.tagName == "TEXTAREA"){
				obj.value = value;
			}

}


function xgi_setSelected(objid,value){
		var obj = document.getElementById(objid);
		if (obj.tagName == "SELECT"){
	for (var i = 0;i<obj.length ;i++ ){
					if (obj[i].innerHTML == value){
							obj[i].selected = true;
							break;
					}
	}
		}

}

function xgi_getSelected(objid){
		var obj = document.getElementById(objid);
		if (obj.tagName == "INPUT"){
			 return obj.value;
		}else
		if (obj.tagName == "DIV" || obj.tagName == "SPAN"){
			return obj.innerHTML;
		}else
			if (obj.tagName == "SELECT"){
				for (var i = 0;i<obj.length ;i++ ){
					if (obj[i].selected == true){
							return obj[i].innerHTML;
					}
				}
			}

}

function xgi_setFocus(objid){
	var obj = document.getElementById(objid);
	obj.focus();
}


function xgi_getValue(objid,value){
		var obj = document.getElementById(objid);
		if (obj == null){
				alert("not found "+objid);
			return -1;
		}
		
		if (obj.tagName == "TEXTAREA"){
				return obj.value;
		}
	
		if (obj.tagName == "INPUT"){	
			if (obj.type == "text" || obj.type == "hidden"){
					return obj.value;
			}else
				if (obj.type == "checkbox"){
					if (obj.checked) return 1;
					else return 0;
				}else{
				return obj.value;
				}
		}else
			if (obj.tagName == "DIV" || obj.tagName == "SPAN")
			{
				return obj.innerHTML;
			}
		else if (obj.tagName == "SELECT"){
				return obj.value;
		}
}


function xgi_setPos(objid,x,y){
	var obj = document.getElementById(objid);
	obj.style.left = parseInt(x);
	obj.style.top = parseInt(y);
}

function xgi_setSize(objid,w,h){
	var obj = document.getElementById(objid);
	obj.style.width = parseInt(w);
	obj.style.height = parseInt(h);
}


function xgi_setWidth(objid,w){
	var obj = document.getElementById(objid);
	obj.style.width = parseInt(w);
}

function xgi_setVisible(objid,vis){
	var obj = document.getElementById(objid);
	if (vis){
			obj.style.visibility = "visible";
	}else{
		obj.style.visibility = "hidden";
	}
}

function xgi_getVisible(objid){
	var obj = document.getElementById(objid);
	if (obj.style.visibility == "visible"){
			return true;
	}else{
			return false;
	}
}

function xgi_setDisplay(objid,dis){
	var obj = document.getElementById(objid);
			obj.style.display = dis;
}

function xgi_setReadOnly(objid,ro){
	var obj = document.getElementById(objid);
	if (obj.tagName == "INPUT"){
			obj.readOnly = ro;
	}
}

function xgi_getChild(parent,tagName){
	for (var i=0;i<parent.childNodes.length ;i++ ){
		if(parent.childNodes.item(i).tagName == tagName){
			return parent.childNodes.item(i);
		}
	}
	return -1;
}