//=========================================================

function AX_TabbedPanel(sDockPos, sTitlebarPos, hTitlebar) {
	this.base = AX_Panel;
	this.base();

	this.DockParent = null;
	this.isDocked = false;
	this.isMoving = false;
	this.dockPos = sDockPos || 'lefttop';
	this.btnClosePos = 'leftmiddle';
	this.ImgClose = null;
	this.ImgCloseSrc = '';
	this.ImgOpen = null;
	this.ImgOpenSrc = '';
	this.isOpen = true;
	this.DragHandler = null;
	this.BtnClose = null;
	this.TitleBar = null;
	this.TitleBackgroundColor = '';
	this.TitleBackgroundImageSet = '';
	this.TitleBackgroundURL = '';
	this.TBarH = hTitlebar || 16;
	this.TBarPos = sTitlebarPos || 'top';
	this.onPanelClose = null;
	this.OriginalHeight = 0;
	
	this.TabWidth = 180;
	this.TabHeight = this.TBarH - 2;
	this.Overlap = 0;
	this.TabColorNormal = '#D0D0D0';
	this.TabColorSelected = '#E0E0E0';
	this.FontColorNormal = '#808080';
	this.FontColorSelected = '#D0D0D0';
	this.ImgNormal = null;
	this.ImgNormalSrc = '';
	this.ImgSelected = null;
	this.ImgSelectedSrc = '';
	this.selIndex = -1;
	this.Tabs = new Array();
	this.TabNames = new Array();
	this.Panels = new Array();
	this.TabsRAlign = new Array();
}

AX_TabbedPanel.prototype = new AX_Panel;

AX_TabbedPanel.prototype.setDockPosition = function(sDockPos){
	this.dockPos = sDockPos || 'lefttop';
}

AX_TabbedPanel.prototype.setTitlebarHeight = function(hTitlebar){
	this.TBarH = hTitlebar;
}

AX_TabbedPanel.prototype.setParent = function(oParent){
	if (this.Parent) {
		this.Parent.removeChild(this);
		this.Parent = oParent;
		this.DOMContainer = this.Parent.GetDOMContainer();
		this.DOMContainer.appendChild(this.Box);
		this.Parent.addChild(this);
	} else {
		this.DockParent = oParent;
		this.isDocked = true;
		this.dockPos = 'lefttop';
		this.Parent = oParent;
		this.DOMContainer = this.Parent.GetDOMContainer();
		this.agent = this.Parent.agent;
		this.ImagesBasePath = this.Parent.ImagesBasePath;
		
		this.BackgroundColor = this.Parent.BackgroundColor;
		this.TitleBackgroundColor = this.Parent.BackgroundColor;
		this.BorderSize = 0;
		this.InnerBorderSize = this.Parent.BorderSize;
		this.BorderColor = this.Parent.BorderColor;
		this.BorderColorHigh = this.Parent.BorderColorHigh;
		this.BorderColorShadow = this.Parent.BorderColorShadow;
		this.BorderStyle = this.Parent.BorderStyle;

		this.Box = this.Application.getDIV();
		this.Box.style.backgroundColor = this.BackgroundColor;
		this.Box.style.top = (this.Parent.InnerRect['top']) + 'px';
		this.Box.style.left = (this.Parent.InnerRect['left']) + 'px';
		this.Box.style.width = (this.Parent.InnerRect['width']) + 'px';
		this.Box.style.height = (this.Parent.InnerRect['height']) + 'px';
		this.Box.style.overflow = 'hidden';
		this.drawBorder();
		this.DOMContainer.appendChild(this.Box);
	
		this.FontFamily = this.Parent.FontFamily;
		this.FontSize = this.Parent.FontSize;
		this.FontColor = this.Parent.FontColor;
		this.FontBold = this.Parent.FontBold;
		this.FontSmallCaps = this.Parent.FontSmallCaps;

		this.TitleBar = this.Application.getDIV();
		this.TitleBar.owner = this;
		this.TitleBar.style.width = (this.Parent.InnerRect['width']) + 'px';
		this.TitleBar.style.height = this.TBarH + 'px';
		this.TitleBar.style.backgroundColor = this.TitleBackgroundColor;
		this.TitleBar.style.display = 'block';
		this.TitleBar.style.padding = '1px';
		this.TitleBar.style.textAlign = 'center';
		this.TitleBar.style.varticalAlign = 'middle';
		if (this.TBarPos == 'bottom') this.TitleBar.style.top = (this.Parent.InnerRect['height'] - this.TBarH) + 'px';
		this.Box.appendChild(this.TitleBar);
		var sTable = '<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">';
		sTable += '<tr><td>&nbsp;</td></tr>';
		sTable += '</table>';
		this.TitleBar.innerHTML = sTable;
		this.TabStrip = this.TitleBar.getElementsByTagName('TABLE')[0];
		with (this.TabStrip.style) {
			position = 'absolute';
			//backgroundColor = this.BackgroundColor;
			top = (this.Padding) + 'px';
			left = (this.Padding) + 'px';
			width = (this.Width - this.BorderSize * 2) + 'px';
			height = this.TabHeight + 'px';
		}
		this.TabStripRow = this.TabStrip.tBodies[0].rows[0];
		this.TabStripRow.style.position = 'absolute';
		this.SpacerTab1 = this.TabStripRow.cells[0];
		with (this.SpacerTab1.style) {
			position = 'absolute';
			top = '0px';
			left = '0px';
			width = '4px';
			height = this.TabHeight + 'px';
		}
		
		this.ClientBox = this.Application.getDIV();
		with (this.ClientBox.style) {
			backgroundColor = 'transparent';
			if (this.TBarPos == 'bottom') {
				top = '0px';
			} else {
				top = (this.TBarH + 4) + 'px';
			}
			left = '0px';
			width = (this.Parent.InnerRect['width']) + 'px';
			height = (this.Parent.InnerRect['height'] - this.TBarH - 1) + 'px';
			overflow = 'auto';
			display = 'block';
		}
		this.Box.appendChild(this.ClientBox);
	}
}


AX_TabbedPanel.prototype.SetTabsLayout = function(iWidth, iHeight, iOverlap) {
	if (iWidth !== false) this.TabWidth = iWidth;
	if (iHeight !== false) {
		this.TabHeight = iHeight;
		this.TabStrip.style.height = this.TabHeight + 'px';
	}
	if (iOverlap !== false) this.Overlap = iOverlap;
}

AX_TabbedPanel.prototype.SetPanelsLayout = function(iPadding, iBorderSize, sBorderStyle, colBorderColor, colBorderColor2) {
	if (iPadding !== false) this.PanelPadding = iPadding;
	if (iBorderSize !== false) this.PanelBorderSize = iBorderSize;
	if (sBorderStyle !== false) this.PanelBorderStyle = sBorderStyle;
	if (colBorderColor !== false) this.PanelBorderColor = colBorderColor;
	if (colBorderColor !== false) this.PanelBorderColorHigh = colBorderColor;
	if (colBorderColor2 !== false) this.PanelBorderColorShadow = colBorderColor2;
}

AX_TabbedPanel.prototype.SetBackgroundColors = function(bgcolext, bgcoltabnormal, bgcoltabselected) {
	this.BackgroundColor = bgcolext;
	this.Box.style.backgroundColor = this.BackgroundColor;
	this.TabColorNormal = bgcoltabnormal;
	this.TabColorSelected = bgcoltabselected;
}

AX_TabbedPanel.prototype.SetTabImages = function(sImgNormal, sImgSelected) {
	this.ImgNormalSrc = this.Application.ImagesBasePath + sImgNormal;
	this.ImgSelectedSrc = this.Application.ImagesBasePath + sImgSelected;
	if (!this.ImgNormal) {
		this.ImgNormal = new Image();
		this.ImgNormal.src = this.ImgNormalSrc;
		this.ImgSelected = new Image();
		this.ImgSelected.src = this.ImgSelectedSrc;
	}
}

AX_TabbedPanel.prototype.btnCloseHandler = function(){
	this.closePanel();
}

AX_TabbedPanel.prototype.closePanel = function(bClose) {
	if (this.isOpen || bClose) {
		this.isOpen = false;
		this.ClientBox.style.display = 'none';
		this.TitleBar.style.top = '0px';
		this.Height = this.TBarH;
		this.Box.style.height = (this.TBarH + 2) + 'px';
		this.BtnClose.style.backgroundImage = 'url(' + this.ImgOpenSrc + ')';
		this.BtnClose.style.zIndex = this.TitleBar.style.zIndex + 1;
	} else {
		this.isOpen = true;
		this.Height = this.OriginalHeight;
		this.ClientBox.style.display = 'block';
		if (this.TBarPos == 'bottom') this.TitleBar.style.top = (this.Height - this.TBarH) + 'px';
		this.Box.style.height = (this.Height) + 'px';
		this.BtnClose.style.backgroundImage = 'url(' + this.ImgCloseSrc + ')';
		this.BtnClose.style.zIndex = this.TitleBar.style.zIndex + 1;
		this.resize(true);
	}
	if (this.onPanelClose) {
		this.onPanelClose();
	}
}

AX_TabbedPanel.prototype.GetDOMContainer = function() {
	return this.ClientBox;
}

AX_TabbedPanel.prototype.drawBorder = function(bForce) {
	if (this.TitleBar) {
		this.TitleBar.style.border = '0px solid black';
		if (((this.InnerBorderSize == 1) && (this.BorderStyle.indexOf('set') > 0)) || bForce) {
			var lt = '1px solid ' + this.BorderColorHigh;
			var rb = '1px solid ' + this.BorderColorShadow;
			if (this.BorderStyle == 'inset') {
				lt = '1px solid ' + this.BorderColorShadow;
				rb = '1px solid ' + this.BorderColorHigh;
			}
			this.TitleBar.style.borderLeft = lt;
			this.TitleBar.style.borderTop = lt;
			this.TitleBar.style.borderRight = rb;
			this.TitleBar.style.borderBottom = rb;
		} else {
			this.TitleBar.style.border = this.InnerBorderSize + 'px ' + this.BorderStyle + ' ' + this.BorderColor;
			this.TitleBar.style.borderBottom = '1px solid ' + this.BorderColorShadow;
		}
	}
	if (this.ClientBox && this.BackgroundImageSet == '') {
		if (((this.InnerBorderSize == 1) && (this.BorderStyle.indexOf('set') > 0)) || bForce) {
			var lt = '1px solid ' + this.BorderColorHigh;
			var rb = '1px solid ' + this.BorderColorShadow;
			if (this.BorderStyle == 'inset') {
				lt = '1px solid ' + this.BorderColorShadow;
				rb = '1px solid ' + this.BorderColorHigh;
			}
			this.ClientBox.style.border = '0px solid black';
			this.ClientBox.style.borderLeft = lt;
			this.ClientBox.style.borderTop = lt;
			this.ClientBox.style.borderRight = rb;
			this.ClientBox.style.borderBottom = rb;
		} else {
			this.ClientBox.style.border = this.InnerBorderSize + 'px ' + this.BorderStyle + ' ' + this.BorderColor;
		}
	}
}

AX_TabbedPanel.prototype.SetBackgroundColor = function(bgcol, bgcoltitlebar) {
	if (bgcol) {
		this.BackgroundColor = bgcol;
		this.Box.style.backgroundColor = this.BackgroundColor;
	}
	if (bgcoltitlebar) {
		this.TitleBackgroundColor = bgcoltitlebar;
		this.TitleBar.style.backgroundColor = this.TitleBackgroundColor;
	}
}

AX_TabbedPanel.prototype.SetBackgroundImage = function(sUrl, sUrltitlebar) {
	if (sUrl) {
		this.BackgroundImage = this.ImagesBasePath + sUrl;
		this.Box.style.backgroundImage = 'url(' + this.BackgroundImage + ')';
	}
	if (sUrltitlebar) {
		this.TitleBackgroundImage = this.ImagesBasePath + sUrltitlebar;
		this.TitleBar.style.backgroundImage = 'url(' + this.TitleBackgroundImage + ')';
	}
}

AX_TabbedPanel.prototype.SetBackgroundImageSet = function(sUrl, sPrefix, sUrltitlebar, sPrefixtitlebar) {
	if (sUrl) {
		this.BackgroundImageSet = sPrefix;
		this.BackgroundURL = sUrl;
		var w = this.Box.offsetWidth;
		var h = this.Box.offsetHeight;
		if (w > 0 && h > 0) {
			this.Box.style.backgroundImage = 'url(' + this.BackgroundURL + '?basedir=' + this.ImagesBasePath + '&basename=' + this.BackgroundImageSet + '&width=' + w + '&height=' + h + ')';
		}
	}
	if (sUrltitlebar) {
		this.TitleBackgroundImageSet = sPrefixtitlebar;
		this.TitleBackgroundURL = sUrltitlebar;
		var w = this.TitleBar.offsetWidth;
		var h = this.TitleBar.offsetHeight;
		if (w > 0 && h > 0) {
			this.TitleBar.style.backgroundImage = 'url(' + this.TitleBackgroundURL + '?basedir=' + this.ImagesBasePath + '&basename=' + this.TitleBackgroundImageSet + '&width=' + w + '&height=' + h + ')';
		}
	}
}

AX_TabbedPanel.prototype.SetCloseIcon = function(sPos, imgClose, imgOpen, w, h){
	this.BtnClose = this.Application.getDIV();
	this.BtnClose.style.display = 'block';
	this.BtnClose.style.cursor = 'pointer';
	this.BtnClose.style.backgroundRepeat = 'no-repeat';
	this.BtnClose.style.backgroundImage = 'url(' + this.ImagesBasePath + 'blank.gif)';
	this.BtnClose.owner = this;
	this.Application.bindEvent(this.BtnClose, 'click', this, this.btnCloseHandler);
	this.TitleBar.appendChild(this.BtnClose);
	this.ImgCloseSrc = this.ImagesBasePath + imgClose;
	this.ImgOpenSrc = this.ImagesBasePath + imgOpen;
	if (!this.ImgClose) {
		this.ImgClose = new Image();
		this.ImgClose.src = this.ImgCloseSrc;
		this.ImgOpen = new Image();
		this.ImgOpen.src = this.ImgOpenSrc;
	}
	this.BtnClose.style.width = w + 'px';
	this.BtnClose.style.height = h + 'px';
	this.BtnClose.style.backgroundImage = 'url(' + this.ImgCloseSrc + ')';
	this.btnClosePos = sPos;
	switch (this.btnClosePos.substr(0, 4)) {
		case 'cent':
			this.BtnClose.style.left = ((this.Width - w) / 2) + 'px';
			break;
		case 'left':
			this.BtnClose.style.left = (this.InnerBorderSize + 2) + 'px';
			break;
		case 'righ':
			this.BtnClose.style.left = (this.Width - this.InnerBorderSize - w - 2) + 'px';
			break;
	}
	switch (this.btnClosePos.substr(this.btnClosePos.length - 3)) {
		case 'dle':
			this.BtnClose.style.top = ((this.TBarH - h) / 2) + 'px';
			break;
		case 'top':
			this.BtnClose.style.top = this.InnerBorderSize + 'px';
			break;
		case 'tom':
			this.BtnClose.style.top = (this.TBarH - this.InnerBorderSize - h) + 'px';
			break;
	}
}


AX_TabbedPanel.prototype.AddTab = function(sName, sText, fAction, sAlign) {
	var tab = this.Application.getTD();
	tab.vAlign = 'middle';
	tab.style.backgroundImage = 'url(' + this.ImgNormal.src + ')';
	tab.style.backgroundRepeat = 'no-repeat';
	tab.style.position = 'absolute';
	tab.style.top = '0px';
	if (sAlign == 'right') {
		this.TabsRAlign.push(tab);
		for (var i = 0; i < this.TabsRAlign.length; i++) {
			this.TabsRAlign[i].style.left = this.Width - ((this.TabsRAlign.length - i) * (this.TabWidth - this.Overlap)) + 'px';
		}
	} else {
		tab.style.left = (this.Tabs.length * (this.TabWidth - this.Overlap) + 8) + 'px';
	}
	tab.style.width = this.TabWidth + 'px';
	tab.style.height = this.TabHeight + 'px';
	tab.style.textAlign = 'left';
	tab.style.verticalAlign = 'middle';
	tab.style.zIndex = this.Tabs.length;
	tab.style.cursor = 'pointer';
	tab.style.color = this.FontColor;
	tab.style.fontFamily = this.FontFamily;
	tab.style.fontSize = this.FontSize + 'pt';
	tab.style.fontWeight = (this.FontBold ? 'bold' : 'normal');
	tab.innerHTML = sText;
	tab.owner = this;
	tab.idTab = this.Tabs.length;
	if (fAction) tab.funcAction = fAction;
	this.Tabs[tab.idTab] = tab;
	this.TabNames[sName] = tab;
	this.TabStripRow.appendChild(tab);
	
	var panel = new AX_Panel();
	panel.Name = sName;
	panel.Application = this.Application;
	panel.Name = sName;
	panel.setParent(this);
	this.addChild(panel);
	panel.SetBorder(this.PanelBorderSize, this.PanelBorderStyle, this.PanelBorderColorHigh, this.PanelBorderColorShadow);
	panel.SetSize(6, 6, '100%', '100%', true, true);
	panel.Box.style.zIndex = 0;
	this.Panels[tab.idTab] = panel;

	this.Application.bindEvent(tab, 'click', this, this.tabClickHandler);
	if (tab.idTab == 0) {
		this.selectTab(0);
	}
	return panel;
}

AX_TabbedPanel.prototype.selectTab = function(iTab) {
	var tab = null;
	var panel = null;
	tabnew = this.Tabs[iTab];
	if (tabnew.funcAction) {
		tabnew.funcAction(tabnew);
	} else {
		if (this.selIndex > -1) {
			tab = this.Tabs[this.selIndex];
			tab.style.backgroundImage = 'url(' + this.ImgNormal.src + ')';
			tab.style.color = this.FontColor;
			tab.style.zIndex = this.selIndex;
			panel = this.Panels[this.selIndex];
			panel.SetVisible(false);
		}
		this.selIndex = iTab;
		tabnew.style.backgroundImage = 'url(' + this.ImgSelected.src + ')';
		tabnew.style.color = this.FontColorSelected;
		tabnew.style.zIndex = this.Tabs.length + 1;
		panel = this.Panels[this.selIndex];
		panel.Box.style.zIndex = this.Tabs.length;
		panel.SetVisible(true);
		if (!this.isOpen) this.closePanel();
	}
}

AX_TabbedPanel.prototype.tabClickHandler = function(obj, ev) {
	this.selectTab(obj.idTab);
}

AX_TabbedPanel.prototype.resizeContentPanel = function() {
	if (this.TBarPos == 'bottom') {
		this.ClientBox.style.top = '0px';
	} else {
		this.ClientBox.style.top = (this.TBarH + 4) + 'px';
	}
	this.ClientBox.style.width = (this.Width - this.BorderSize * 2) + 'px';
	if (this.isOpen) this.ClientBox.style.height = (this.Height - this.BorderSize * 2 - this.TBarH - 4) + 'px';

	for (var i = 0; i < this.TabsRAlign.length; i++) {
		this.TabsRAlign[i].style.left = this.Width - ((this.TabsRAlign.length - i) * (this.TabWidth - this.Overlap)) + 'px';
	}

  this.InnerRect['left'] = this.Padding;
  this.InnerRect['top'] = this.Padding;
  this.InnerRect['width'] = this.Width - this.BorderSize * 2 - this.Padding * 2 - this.BorderSize * 2;
  this.InnerRect['height'] = this.Height - this.BorderSize * 2 - this.TBarH - 4 - this.Padding * 2 - this.BorderSize * 2;
}






function AX_LoginPanel() {
	this.base = AX_Panel;
	this.base();

	this.loginPage = '';
}

AX_LoginPanel.prototype = new AX_Panel;

AX_LoginPanel.prototype.SetLoginPage = function(sUrl){
	this.loginPage = sUrl;
}

AX_LoginPanel.prototype.XMLGetValue = function(xnode){
	var ret = null;
	if (xnode) {
		if (xnode.firstChild) ret = xnode.firstChild.nodeValue;
		if (!ret) {
			if (this.agent.substr(0, 2) == 'ie') {
				ret = xnode.text;
			} else {
				ret = xnode.nodeValue;
				if (!ret) {
					ret = xnode.textContent;
				}
			}
		}
	}
	return ret;
}

AX_LoginPanel.prototype.setAlreadyLoggedIn = function(username){
	this.MessageLabel.innerHTML = 'User <b>' + username + '</b> logged in';
	this.InputUser.value = '';
	this.InputPwd.value = '';
	this.TblLogin.style.display = 'none';
	this.TblChPwd.style.display = 'none';
	this.TblLogout.style.display = 'block';
}

AX_LoginPanel.prototype.setLoginStatus = function(sStatus, xmlAuth){
	switch(sStatus) {
		case 'in':
			var sessionname = this.XMLGetValue(xmlAuth.getElementsByTagName("SESS_NAME")[0]);
			var sessionid = this.XMLGetValue(xmlAuth.getElementsByTagName("SESSIONID")[0]);
			var sesssioncookie = this.XMLGetValue(xmlAuth.getElementsByTagName("SESSIONCOOKIE")[0]);
			var username = this.XMLGetValue(xmlAuth.getElementsByTagName("USERNAME")[0]);
			document.cookie = escape(sesssioncookie);
			var d = new Date();
			this.MessageLabel.innerHTML = 'User <b>' + username + '</b> logged in at: <b>' + d.getHours() + ':' + d.getMinutes() + '</b>';
			this.InputUser.value = '';
			this.InputPwd.value = '';
			this.TblLogin.style.display = 'none';
			this.TblChPwd.style.display = 'none';
			this.TblLogout.style.display = 'block';
			break;
		case 'out':
			this.MessageLabel.innerHTML = '';
			this.TblLogout.style.display = 'none';
			this.TblChPwd.style.display = 'none';
			this.TblLogin.style.display = 'block';
			break;
		case 'failed':
			this.MessageLabel.innerHTML = 'Login o password errati: riprova.';
			break;
		case 'chpwdfailed':
			this.MessageLabel.innerHTML = 'Password errata: riprova.';
			break;
		case 'chpwdok':
			this.TblLogin.style.display = 'none';
			this.TblChPwd.style.display = 'none';
			this.TblLogout.style.display = 'block';
			this.MessageLabel.innerHTML = 'La tua password e\' stata modificata.';
			break;
	}
}


AX_LoginPanel.prototype.cancelPwd = function() {
	this.TblLogin.style.display = 'none';
	this.TblChPwd.style.display = 'none';
	this.TblLogout.style.display = 'block';
}

AX_LoginPanel.prototype.showChangePwd = function() {
	this.TblLogout.style.display = 'none';
	this.TblLogin.style.display = 'none';
	this.TblChPwd.style.display = 'block';
}


AX_LoginPanel.prototype.sendNewPwd = function(){
	if (this.InputNewPwd.value != this.InputNewPwd2.value) {
		alert('NUOVA PASSWORD e RIPETI PASSWORD devono essere identici!');
		this.InputNewPwd.focus();
		return false;
	}
	var bOk = false;
	var d = new Date();
	var strData = 'action=chpwd&dummy=' + d.getTime();
	strData += '&oldpwd=' + this.InputOldPwd.value + '&newpwd=' + this.InputNewPwd.value;
	var XHttp = new AX_XMLHttpClass();
	if (XHttp != null) {
		var obj = null;
		if (this.agent == 'ie6') {
			obj = XHttp.downloadUrl(this.loginPage + '?' + strData, false, this);
		} else {
			obj = XHttp.sendPOST(this.loginPage, strData, false, this);
		}
		var xmlobj = obj.responseXML;
		if (xmlobj != null) {
			var xnodes = xmlobj.documentElement;
			var auth = this.XMLGetValue(xnodes.getElementsByTagName("AUTH")[0]);
			if (auth == 'OK') {
				bOk = true;
				this.setLoginStatus('chpwdok', xnodes);
			}
		}
	}
	if (!bOk) {
		this.setLoginStatus('chpwdfailed');
	}

}

AX_LoginPanel.prototype.sendLogin = function(){
	var bOk = false;
	var d = new Date();
	var strData = 'action=login&dummy=' + d.getTime();
	strData += '&username=' + this.InputUser.value + '&pwd=' + this.InputPwd.value;
	var XHttp = new AX_XMLHttpClass();
	if (XHttp != null) {
		var obj = null;
		if (this.agent == 'ie6') {
			obj = XHttp.downloadUrl(this.loginPage + '?' + strData, false, this);
		} else {
			obj = XHttp.sendPOST(this.loginPage, strData, false, this);
		}
		var xmlobj = obj.responseXML;
		if (xmlobj != null) {
			var xnodes = xmlobj.documentElement;
			var auth = this.XMLGetValue(xnodes.getElementsByTagName("AUTH")[0]);
			if (auth == 'OK') {
				bOk = true;
				this.setLoginStatus('in', xnodes);
			}
		}
	}
	if (!bOk) {
		this.setLoginStatus('failed');
	}
}

AX_LoginPanel.prototype.sendLogout = function(){
	var d = new Date();
	var strData = 'action=logout&dummy=' + d.getTime();
	var XHttp = new AX_XMLHttpClass();
	if (XHttp != null) {
		var obj = XHttp.sendPOST(this.loginPage, strData, false, this);
	}
	this.setLoginStatus('out');
}

AX_LoginPanel.prototype.setParent = function(oParent){
	this.Parent = oParent;
	this.DOMContainer = this.Parent.GetDOMContainer();
	this.BackgroundColor = this.Parent.BackgroundColor;
	this.BorderSize = this.Parent.BorderSize;
	this.BorderColor = this.Parent.BorderColor;
	this.BorderColorHigh = this.Parent.BorderColorHigh;
	this.BorderColorShadow = this.Parent.BorderColorShadow;
	this.BorderStyle = this.Parent.BorderStyle;
	
	this.FontFamily = this.Parent.FontFamily;
	this.FontSize = this.Parent.FontSize;
	this.FontColor = this.Parent.FontColor;
	this.FontBold = this.Parent.FontBold;
	this.FontSmallCaps = this.Parent.FontSmallCaps;
	
	this.agent = this.Parent.agent;
	this.ImagesBasePath = this.Parent.ImagesBasePath;

	var oStyle = document.styleSheets[0];
	if (this.agent.substr(0, 2) == 'ie') {
		//oStyle.addRule('.logintextbox', 'width: 180px; border: 1px solid black;	font-family: Verdana, Arial, Helvetica, sans-serif; font-variant: normal;	font-size: 8pt; background-color: #F0F0F0;');
		//oStyle.addRule('.loginpulsante', 'width: 180px; height: 17px; border: 1px outset silver; font-family: Verdana, Arial, Helvetica, sans-serif; font-variant: normal; font-size: 8pt; background-color: #F0F0F0;');
		oStyle.addRule('.logintextbox', 'width: 93%; border: 1px solid black;	font-family: Verdana, Arial, Helvetica, sans-serif; font-variant: normal;	font-size: 8pt; background-color: #F0F0F0;');
		oStyle.addRule('.loginpulsante', 'width: 95%; height: 17px; border: 1px outset silver; font-family: Verdana, Arial, Helvetica, sans-serif; font-variant: normal; font-size: 8pt; background-color: #F0F0F0;');
	} else {
		oStyle.insertRule('.logintextbox {width: 93%; border: 1px solid black;	font-family: Verdana, Arial, Helvetica, sans-serif; font-variant: normal;	font-size: 8pt; background-color: #F0F0F0;}', 0);
		oStyle.insertRule('.loginpulsante {width: 95%; height: 17px; border: 1px outset silver; font-family: Verdana, Arial, Helvetica, sans-serif; font-variant: normal; font-size: 8pt; background-color: #F0F0F0;}', 0);
	}

	this.Box = this.Application.getDIV();
	this.Box.style.backgroundColor = this.BackgroundColor;
	this.Box.style.top = (this.Parent.Padding) + 'px';
	this.Box.style.left = (this.Parent.Padding) + 'px';
	this.Box.style.width = (this.Width - this.BorderSize * 2) + 'px';
	this.Box.style.height = (this.Height - this.BorderSize * 2) + 'px';
	this.Box.style.textAlign = 'center';
	this.Box.style.overflow = 'auto';
	this.drawBorder();
	this.DOMContainer.appendChild(this.Box);
	this.fontSize = 8;
	
	var sTable = '<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\">';
	sTable += '<tr><td width=\"50%\" id=\"tbl_login_lbllogin\">login</td><td id=\"tbl_login_lblpwd\">password</td></tr>';
	sTable += '<tr><td id=\"tbl_login_inputlogin\">&nbsp;</td><td id=\"tbl_login_inputpwd\">&nbsp;</td></tr>';
	sTable += '<tr><td id=\"tbl_login_inputsignup\">&nbsp;</td><td id=\"tbl_login_inputsubmit\">&nbsp;</td></tr>';
	sTable += '</table>';
	sTable += '<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\">';
	sTable += '<tr><td id=\"tbl_login_inputchpwd\" width=\"50%\">&nbsp;</td><td id=\"tbl_login_inputlogout\">&nbsp;</td></tr>';
	sTable += '</table>';
	sTable += '<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\">';
	sTable += '<tr><td width=\"50%\" id=\"tbl_login_lbloldpwd\">password attuale</td><td>&nbsp;</td></tr>';
	sTable += '<tr><td id=\"tbl_login_inputoldpwd\">&nbsp;</td><td>&nbsp;</td></tr>';
	sTable += '<tr><td width=\"50%\" id=\"tbl_login_lblnewpwd\" nowrap>nuova password</td><td id=\"tbl_login_lblnewpwd2\" nowrap>ripeti password</td></tr>';
	sTable += '<tr><td id=\"tbl_login_inputnewpwd\">&nbsp;</td><td id=\"tbl_login_inputnewpwd2\">&nbsp;</td></tr>';
	sTable += '<tr><td id=\"tbl_login_inputcancel\">&nbsp;</td><td id=\"tbl_login_inputsubmitnewpwd\">&nbsp;</td></tr>';
	sTable += '</table>';
	this.Box.innerHTML = sTable;
	var tables = this.Box.getElementsByTagName('TABLE');
	this.TblLogin = tables[0];
	with (this.TblLogin.style) {
		position = 'absolute';
		top = '24px';
		left = '10px';
		width = '95%';
		fontFamily = this.font;
		fontSize = (this.fontSize - 1) + 'pt';
		textAlign = 'left';
		verticalAlign = 'top';
	}
	this.TblLogout = tables[1];
	with (this.TblLogout.style) {
		position = 'absolute';
		display = 'none';
		top = '24px';
		left = '10px';
		width = '95%';
		fontFamily = this.font;
		fontSize = (this.fontSize - 1) + 'pt';
		textAlign = 'left';
		verticalAlign = 'top';
	}
	this.TblChPwd = tables[2];
	with (this.TblChPwd.style) {
		position = 'absolute';
		display = 'none';
		top = '24px';
		left = '10px';
		width = '95%';
		fontFamily = this.font;
		fontSize = (this.fontSize - 1) + 'pt';
		textAlign = 'left';
		verticalAlign = 'top';
	}
	this.MessageLabel = this.Application.getDIV();
	with (this.MessageLabel.style) {
		position = 'absolute';
		display = 'block';
		top = '2px';
		left = '10px';
		width = '95%';
		fontFamily = this.font;
		fontSize = this.fontSize + 'pt';
		textAlign = 'left';
	}
	this.Box.appendChild(this.MessageLabel);

	this.InputUser = document.createElement('INPUT');
	with (this.InputUser) {
		type = 'text';
		name = 'username';
	}
	this.InputUser.className = 'logintextbox';
	document.getElementById('tbl_login_inputlogin').appendChild(this.InputUser);
	
	this.InputPwd = document.createElement('INPUT');
	with (this.InputPwd) {
		type = 'password';
		name = 'pwd';
	}
	this.InputPwd.className = 'logintextbox';
	document.getElementById('tbl_login_inputpwd').appendChild(this.InputPwd);
	
	this.InputSubmit = document.createElement('INPUT');
	with (this.InputSubmit) {
		type = 'submit';
		name = 'invia';
		value = 'entra';
	}
	this.InputSubmit.className = 'loginpulsante';
	this.InputSubmit.owner = this;
	this.Application.bindEvent(this.InputSubmit, 'click', this, this.sendLogin);
	document.getElementById('tbl_login_inputsubmit').appendChild(this.InputSubmit);

	this.InputLogout = document.createElement('INPUT');
	with (this.InputLogout) {
		type = 'button';
		name = 'esci';
		value = 'logout';
	}
	this.InputLogout.className = 'loginpulsante';
	this.InputLogout.owner = this;
	this.Application.bindEvent(this.InputLogout, 'click', this, this.sendLogout);
	document.getElementById('tbl_login_inputlogout').appendChild(this.InputLogout);

	this.InputChPwd = document.createElement('INPUT');
	with (this.InputChPwd) {
		type = 'button';
		name = 'cambiapwd';
		value = 'cambia password';
	}
	this.InputChPwd.className = 'loginpulsante';
	this.InputChPwd.owner = this;
	this.Application.bindEvent(this.InputChPwd, 'click', this, this.showChangePwd);
	document.getElementById('tbl_login_inputchpwd').appendChild(this.InputChPwd);
	

	this.InputOldPwd = document.createElement('INPUT');
	with (this.InputOldPwd) {
		type = 'password';
		name = 'oldpwd';
	}
	this.InputOldPwd.className = 'logintextbox';
	document.getElementById('tbl_login_inputoldpwd').appendChild(this.InputOldPwd);

	this.InputNewPwd = document.createElement('INPUT');
	with (this.InputNewPwd) {
		type = 'password';
		name = 'newpwd';
	}
	this.InputNewPwd.className = 'logintextbox';
	document.getElementById('tbl_login_inputnewpwd').appendChild(this.InputNewPwd);

	this.InputNewPwd2 = document.createElement('INPUT');
	with (this.InputNewPwd2) {
		type = 'password';
		name = 'newpwd2';
	}
	this.InputNewPwd2.className = 'logintextbox';
	document.getElementById('tbl_login_inputnewpwd2').appendChild(this.InputNewPwd2);

	
	this.InputSubmitPwd = document.createElement('INPUT');
	with (this.InputSubmitPwd) {
		type = 'submit';
		name = 'inviapwd';
		value = 'invia';
	}
	this.InputSubmitPwd.className = 'loginpulsante';
	this.InputSubmitPwd.owner = this;
	this.Application.bindEvent(this.InputSubmitPwd, 'click', this, this.sendNewPwd);
	document.getElementById('tbl_login_inputsubmitnewpwd').appendChild(this.InputSubmitPwd);
	
	this.InputCancelPwd = document.createElement('INPUT');
	with (this.InputCancelPwd) {
		type = 'button';
		name = 'cancelpwd';
		value = 'annulla';
	}
	this.InputCancelPwd.className = 'loginpulsante';
	this.InputCancelPwd.owner = this;
	this.Application.bindEvent(this.InputCancelPwd, 'click', this, this.cancelPwd);
	document.getElementById('tbl_login_inputcancel').appendChild(this.InputCancelPwd);
	
	
	

}

