// tabi objekti 
// rakentaa lomakkeelle tabi navikoinnin 
// tata voi kayttaa ainoastaan jos lomakkeella ei ole pakollisia kenttia 
function wizard_tabs(base){		
	this.addTab = addTab;
	this.initialize = initialize;
	this.left;  
	this.top; 
	this.selectPage = selectPage;
	this.currentPage;
	this.contentCell;		
	this.submitCell;
	this.printCell; 
	this.writeError = writeError; 
	this.errorIsOpen = errorIsOpen;
	this.prevNextTable;
	this.updateButtonTable = updateButtonTable;
	this.closeErrorLabel = closeErrorLabel;
	
	var errorLabel;
	var errorIframe; 
	var tabi = this; 
	var tabs = new Array();
	var tabSpaces = new Array();  
	var opera = false;
	 
	if (navigator.userAgent.indexOf('Opera') != -1)
	    opera = true;
	else if (navigator.userAgent.indexOf('Netscape6') != -1) 
	    opera = true;
	
	
    // initialize tabs code 
    var MainTable = document.createElement("table");
    MainTable.insertRow(MainTable.rows.length);
    MainTable.cellSpacing=0;
    MainTable.cellPadding=0;
    MainTable.border=0;
    MainTable.style.height=base.height;
    MainTable.style.width= base.width;
    MainTable.style.verticalAlign = 'top';
    base.Form.appendChild(MainTable);  
	if (!opera){ 
	    var TabTable = document.createElement("table");
	    TabTable.border=0
	    TabTable.cellSpacing=0;
	    TabTable.cellPadding=0;
	    TabTable.style.width = '100%';
	    TabTable.className = 'TabTop';
	    MainTable.rows[0].insertCell(MainTable.rows[0].cells.length).appendChild(TabTable); 
	    var oObject = document.createElement('div');
	    oObject.style.display = 'inline';
        oObject.style.width = '100%'
	    oObject.style.position = 'relative'; 
	    oObject.style.top = 1
	    TabTable.insertRow(TabTable.rows.length).insertCell(0).appendChild(oObject);
	     
	    tabi.submitCell = addSubmitButton();
	}
	
	
	
	function addSubmitButton(){
	    var oCell; 	
	    oCell = MainTable.rows[0].insertCell(MainTable.rows[0].cells.length); 
	    oCell.className = 'TabTop';
	    oCell.innerHTML = '&nbsp;&nbsp;';
	    oCell.align = 'right'
	    oCell.vAlign = 'bottom'
	    if (!opera){
            oCell.style.position = "static"
	    } else {
	        oCell.style.width = '100%'
	    }
	    return oCell;
	}	
    
	this.top = getAbsoluteTop(MainTable); 
	this.left = getAbsoluteLeft(MainTable); 
	
	function errorIsOpen(){
		if (!errorLabel) return false;
		else return true;
	}
	
	function writeError(message , blanko ,errorTitle){		
		var absTop; 
		var absLeft;
		
		if (message){
			closeErrorLabel();
			if (!blanko)
			{
			    if (!errorTitle)
			    {
			        errorTitle = lanErrortitle;
			    } 
			    message = '<table width="100%" cellpadding=0 cellspacing=0 border=0><tr><td Class="TextCss"><B>' + errorTitle + '</B></td><td align=right><img style="cursor:pointer" src="' + base.virtualDirectory + 'jdm/WebControls/Images/close.gif" height="16" width="16"></td></tr></table><UL>' + message + '</SPAN></UL>';
			} 
            

			errorLabel = document.createElement('div');
			errorLabel.style.position = 'absolute';
			
			if (base.Form.style.position == 'absolute'){// && !window.addEventListener){
				absTop = this.contentCell.offsetTop + base.contentMarginTop; 
				absLeft = this.contentCell.offsetLeft + base.contentMarginLeft; 
			} else {
				absTop = getAbsoluteTop(this.contentCell) + base.contentMarginTop; 
				absLeft = getAbsoluteLeft(this.contentCell) + base.contentMarginLeft; 
			}
			
			errorLabel.style.top = absTop;
			errorLabel.style.left = absLeft;
			
			errorLabel.className = "TabErrorLabel"; 
			errorLabel.innerHTML = message;
			errorLabel.style.zIndex = 2; 
			if (opera) errorLabel.style.width = this.contentCell.offsetWidth - (base.contentMarginLeft + base.contentMarginRight); 
			else if (document.addEventListener) errorLabel.style.width = this.contentCell.offsetWidth - (base.contentMarginLeft + base.contentMarginRight) - 10;
			else errorLabel.style.width = this.contentCell.offsetWidth - (base.contentMarginLeft + base.contentMarginRight); 
			if (!opera){ 
				errorIframe = document.createElement('iframe');
				errorIframe.src = base.virtualDirectory + 'jdm/webcontrols/dummy.htm';
				base.Form.appendChild(errorIframe);
				base.Form.appendChild(errorLabel);
				errorIframe.style.position = 'absolute';
				errorIframe.style.height = errorLabel.offsetHeight - 2;
				errorIframe.style.top = absTop;
				errorIframe.style.left = absLeft;
				errorIframe.style.width = errorLabel.offsetWidth - 2;
				errorIframe.style.borderWidth = 0;
				errorIframe.style.zIndex = 1; 
				
				
			}else {
				base.Form.appendChild(errorLabel);
			}
			if (!blanko){
			    var oImage = errorLabel.getElementsByTagName('img')[0];
			    oImage.onclick = closeErrorLabel;
			    base.oTooltip.initialize('sulje',oImage, true)
			}
		} else {
			closeErrorLabel();
		}	 
	}
	function closeErrorLabel(){
		if (errorLabel){
			base.Form.removeChild(errorLabel);
			if (!opera) base.Form.removeChild(errorIframe);
		} 
		
		errorLabel = null;
		errorIframe = null;
		return true; 
	}	
	// lisaa tabin 
	function addTab(tab){
		if (opera){
		    addTabOpera(tab);
		}else
		{
		    var oCell;
		    var oTable = getTable();
		    oTable.style.display = 'inline';
		    TabTable.rows[0].cells[0].getElementsByTagName('div')[0].appendChild(oTable);
		    label = '<a><nobr>' + tab.header + '</nobr></a>';
		    var cells = fillTable(oTable,label,'&nbsp;&nbsp;')
		    tab.headObject = oTable;
		    cells[0].className = 'Tab';
		    cells[0].onselectstart = new Function('return false;'); 
		    setTabAction(cells[0]);
		    tabs[tabs.length] = cells[0];
		    base.lockedElements[base.lockedElements.length] = cells[0];
		    cells[1].className = 'TabSpace';
		    tabSpaces[tabSpaces.length] = cells[1];
		    
		} 
	}
	function addTabOpera(tab){
          var oCell;  
          oCell = MainTable.rows[0].insertCell(MainTable.rows[0].cells.length); 
          oCell.innerHTML = tab.header  ;
          oCell.className = 'Tab';
          oCell.onselectstart = new Function('return false;'); 
          setTabAction(oCell);
          tab.headObject = oCell;
          tabs[tabs.length] = oCell;
          base.lockedElements[base.lockedElements.length] = oCell;
          oCell = MainTable.rows[0].insertCell(MainTable.rows[0].cells.length); 
          oCell.className = 'TabSpace';
          oCell.innerHTML = '&nbsp;&nbsp;';
          
          tabSpaces[tabSpaces.length] = oCell;
    }

    function setTabAction(oCell){
      oCell.onmouseover=mouseover;
      oCell.onmouseout=mouseout;
      oCell.onclick = mouseclick;
      oCell.tabNum = tabs.length;
    }
	
	 
			
	function initialize(){
		var oCell; 	
	
	    // opera selaimella kasittely on tehtava vasta taalla 
	    if (opera)
	    {
	         // maaritellaan solu jonne painikkeet sijoitetaan    
	         tabi.submitCell = addSubmitButton();
	    }
	
	
	    // kun ei ole wizsrd lomake on kolme vaihtoehtoa tulostaa tulosta painike 
	    if (base.printButtonLabel && base.hideButtons)
	    {
	        // vain pelkka tulosta painike 
	        tabi.submitCell.appendChild(getButtons(base, 'print' ,null)); 		 
	    }
	    else if (base.printButtonLabel && !base.hideButtons)
	    {
	        // tulostetaan tulosta painike ja tallenna painike 
	        var table = getTable();
	        fillTable(table,getButtons(base, 'print' ,null) , getButtons(base, 'submit' ,null));
	        table.rows[0].cells[0].style.paddingRight = '10';
	        tabi.submitCell.appendChild(table);
	    }
	    else if (!base.hideButtons)
	    { 
	        // vain pelkka tallenna painike 
	        tabi.submitCell.appendChild(getButtons(base, 'submit' ,null)); 		
        }
    
		
		var oRow = MainTable.insertRow(MainTable.rows.length);
		oCell = MainTable.rows[1].insertCell(MainTable.rows[1].cells.length); 
		oCell.style.borderTopWidth= 0; // liittyy error riviin 
		oCell.className = "TabContent"; 
		oCell.style.margin = 0;
		oCell.style.padding = 0;
		oCell.style.width="100%";
		oCell.style.height="100%";
		oCell.style.textAlign = "left";
		oCell.style.verticalAlign = "top";
		oCell.colSpan = MainTable.rows[0].cells.length ;
		
		this.contentCell = oCell;	
		if (base.wizard){
		    oRow = MainTable.insertRow(MainTable.rows.length);
		    oCell = oRow.insertCell(0);
		    oCell.style.position = 'static'; 
		    oCell.style.top = oRow.offsetTop;
		    oCell.style.width = oRow.offsetWidth;
            oCell.style.left = getAbsoluteLeft(oRow) + base.contentMarginLeft;
            oCell.style.padding = 5;
		    oCell.colSpan = MainTable.rows[0].cells.length; 
		    var oButtTable = getTable();
		    oButtTable.style.position = 'relative'; 
		    oButtTable.style.top = '-30'; 
		    oButtTable.style.width = '100%';
		    oCell.appendChild(oButtTable);    
		    this.prevNextTable = oButtTable;
		}
		selectPage(0); 
	}
	function updateButtonTable(){
	    var oRow = MainTable.rows[MainTable.rows.length - 1];
	    var oCell = oRow.cells[0];
	    oCell.style.top = oRow.offsetTop;
		  
	}
	function selectPage(tab_num){
		for (var i = 0;i<tabs.length;i++){
			tabs[i].className = 'Tab';
			tabSpaces[i].className = 'TabSpace';
		}
		if (tabs.length > 0){ 
			tabs[tab_num].className = 'TabSelected';
			tabSpaces[tab_num].className = 'TabSelectedSpace';
		}
		this.currentPage = tab_num;
	} 
	function mouseover(){
		if(base.tabs[this.tabNum].enabled){ 
		    if (this.className != 'TabSelected'){
			    var tab_num = this.tabNum;
			    tabs[tab_num].className = 'TabMouseOver';
			    tabSpaces[tab_num].className ='TabMouseOverSpace';
		    }
		}
	}
	function mouseout(){
		if (this.className != 'TabSelected'){
			var tab_num = this.tabNum;
			tabs[tab_num].className = 'Tab';
			tabSpaces[tab_num].className = 'TabSpace';
		}
	}
	function mouseclick(){
		if(base.tabs[this.tabNum].enabled){ 
		    if (base.currentPage != this.tabNum){
		        base.goPage(this.tabNum);
		        if (!base.edit && base.created && base.wizard){base.check.check();} 
		    } 
		}
	}
}



// tabi objekti 
// rakentaa lomakkeelle tabi navikoinnin 
function tabs(base){		
	this.addTab = addTab;
	this.initialize = initialize;
	this.left;  
	this.top; 
	this.selectPage = selectPage;
	//this.currentPage;
	this.contentCell;		
	this.submitCell;
	this.printCell; 
	this.writeError = writeError; 
	this.errorIsOpen = errorIsOpen;
	this.prevNextTable;
	this.updateButtonTable = updateButtonTable;
	this.closeErrorLabel = closeErrorLabel;
	this.removeTab = removeTab;
	
	var errorLabel;
	var errorIframe; 
	var tabi = this; 
	var tabs = new Array();
	var tabSpaces = new Array();  
	var opera = false;
	 
	if (navigator.userAgent.indexOf('Opera') != -1)
	    opera = true;
	else if (navigator.userAgent.indexOf('Netscape6') != -1) 
	    opera = true;
	
	
    // initialize tabs code 
    var MainTable = document.createElement("table");
    MainTable.insertRow(MainTable.rows.length);
    MainTable.cellSpacing=0;
    MainTable.cellPadding=0;
    MainTable.border=0;
    MainTable.style.height=base.height;
    MainTable.style.width= base.width;
    MainTable.style.verticalAlign = 'top';
    base.Form.appendChild(MainTable);  
	if (!opera){ 
	    var TabTable = document.createElement("table");
	    TabTable.border=0
	    TabTable.cellSpacing=0;
	    TabTable.cellPadding=0;
	    TabTable.style.width = '100%';
	    TabTable.className = 'TabTop';
	    MainTable.rows[0].insertCell(MainTable.rows[0].cells.length).appendChild(TabTable); 
	    var oObject = document.createElement('div');
	    oObject.style.display = 'inline';
        oObject.style.width = '100%';
	    oObject.style.position = 'relative'; 
	    oObject.style.top = 1;
	    TabTable.insertRow(TabTable.rows.length).insertCell(0).appendChild(oObject);
	     
	    tabi.submitCell = addSubmitButton();
	}
	
	
	
	function addSubmitButton(){
	    var oCell; 	
	    oCell = MainTable.rows[0].insertCell(MainTable.rows[0].cells.length); 
	    oCell.className = 'TabTop';
	    oCell.innerHTML = '&nbsp;&nbsp;';
	    oCell.align = 'right'
	    oCell.vAlign = 'bottom'
	    if (!opera){
            oCell.style.position = "static"
	    } else {
	        oCell.style.width = '100%'
	    }
	    return oCell;
	}	
    
	this.top = getAbsoluteTop(MainTable); 
	this.left = getAbsoluteLeft(MainTable); 
	
	function errorIsOpen(){
		if (!errorLabel) return false;
		else return true;
	}
	
	function writeError(message , blanko ,errorTitle){		
		var absTop; 
		var absLeft;
		
		if (message){
			closeErrorLabel();
			if (!blanko)
			{
			    if (!errorTitle)
			    {
			        errorTitle = lanErrortitle;
			    } 
			    message = '<table width="100%" cellpadding=0 cellspacing=0 border=0><tr><td Class="TextCss"><B>' + errorTitle + '</B></td><td align=right><img style="cursor:pointer" src="' + base.virtualDirectory + 'jdm/WebControls/Images/close.gif" height="16" width="16"></td></tr></table><UL>' + message + '</SPAN></UL>';
			} 
            

			errorLabel = document.createElement('div');
			errorLabel.style.position = 'absolute';
			
			if (base.Form.style.position == 'absolute'){// && !window.addEventListener){
				absTop = this.contentCell.offsetTop + base.contentMarginTop; 
				absLeft = this.contentCell.offsetLeft + base.contentMarginLeft; 
			} else {
				absTop = getAbsoluteTop(this.contentCell) + base.contentMarginTop; 
				absLeft = getAbsoluteLeft(this.contentCell) + base.contentMarginLeft; 
			}
			
			errorLabel.style.top = absTop;
			errorLabel.style.left = absLeft;
			
			errorLabel.className = "TabErrorLabel"; 
			errorLabel.innerHTML = message;
			errorLabel.style.zIndex = 2; 
			if (opera) errorLabel.style.width = this.contentCell.offsetWidth - (base.contentMarginLeft + base.contentMarginRight); 
			else if (document.addEventListener) errorLabel.style.width = this.contentCell.offsetWidth - (base.contentMarginLeft + base.contentMarginRight) - 10;
			else errorLabel.style.width = this.contentCell.offsetWidth - (base.contentMarginLeft + base.contentMarginRight); 
			if (!opera){ 
				errorIframe = document.createElement('iframe');
				errorIframe.src = base.virtualDirectory + 'jdm/webcontrols/dummy.htm';
				base.Form.appendChild(errorIframe);
				base.Form.appendChild(errorLabel);
				errorIframe.style.position = 'absolute';
				errorIframe.style.height = errorLabel.offsetHeight - 2;
				errorIframe.style.top = absTop;
				errorIframe.style.left = absLeft;
				errorIframe.style.width = errorLabel.offsetWidth - 2;
				errorIframe.style.borderWidth = 0;
				errorIframe.style.zIndex = 1; 
				
				
			}else {
				base.Form.appendChild(errorLabel);
			}
			if (!blanko){
			    var oImage = errorLabel.getElementsByTagName('img')[0];
			    oImage.onclick = closeErrorLabel;
			    base.oTooltip.initialize('sulje',oImage, true)
			}
		} else {
			closeErrorLabel();
		}	 
	}
	function closeErrorLabel(){
		if (errorLabel){
			base.Form.removeChild(errorLabel);
			if (!opera) base.Form.removeChild(errorIframe);
		} 
		
		errorLabel = null;
		errorIframe = null;
		return true; 
	}	
	
	//poistaa tabin ajon aikana 
	function removeTab(index)
	{	    
	    var tabtable = TabTable.rows[0].cells[0].getElementsByTagName('div')[0].getElementsByTagName('table')[index];
	    TabTable.rows[0].cells[0].getElementsByTagName('div')[0].removeChild(tabtable);	    
	    tabs.splice(index,1);
	    tabSpaces.splice(index,1);    
	    
	    // laitetaan taas indeksit paikoilleen
	    for( var i=0;i<tabs.length;i++)
	    {
	        tabs[i].tabNum = i;
	    }
	}
	// lisaa tabin 
	function addTab(tab){
		if (opera){
		    addTabOpera(tab);
		}else
		{
		    var oCell;
		    var oTable = getTable();
		    oTable.style.display = 'inline';
		    TabTable.rows[0].cells[0].getElementsByTagName('div')[0].appendChild(oTable);
		    label = '<a><nobr>' + tab.header + '</nobr></a>';
		    var cells = fillTable(oTable,label,'&nbsp;&nbsp;')
		    tab.headObject = oTable;
		    cells[0].className = 'Tab';
		    cells[0].onselectstart = new Function('return false;'); 
		    setTabAction(cells[0]);
		    tabs[tabs.length] = cells[0];
		    base.lockedElements[base.lockedElements.length] = cells[0];
		    cells[1].className = 'TabSpace';
		    tabSpaces[tabSpaces.length] = cells[1];
		    
		} 
	}
	function addTabOpera(tab){
          var oCell;  
          oCell = MainTable.rows[0].insertCell(MainTable.rows[0].cells.length); 
          oCell.innerHTML = tab.header  ;
          oCell.className = 'Tab';
          oCell.onselectstart = new Function('return false;'); 
          setTabAction(oCell);
          tab.headObject = oCell;
          tabs[tabs.length] = oCell;
          base.lockedElements[base.lockedElements.length] = oCell;
          oCell = MainTable.rows[0].insertCell(MainTable.rows[0].cells.length); 
          oCell.className = 'TabSpace';
          oCell.innerHTML = '&nbsp;&nbsp;';
          
          tabSpaces[tabSpaces.length] = oCell;
    }

    function setTabAction(oCell){
      oCell.onmouseover=mouseover;
      oCell.onmouseout=mouseout;
      oCell.onclick = mouseclick;
      oCell.tabNum = tabs.length;
    }
	
	 
			
	function initialize(){
		var oCell; 	
		
		
		if (!base.wizard )
		{
		    // opera selaimella kasittely on tehtava vasta taalla 
		    if (opera)
		    {
		         // maaritellaan solu jonne painikkeet sijoitetaan    
		         tabi.submitCell = addSubmitButton();
		    }
		
		
		    // kun ei ole wizsrd lomake on kolme vaihtoehtoa tulostaa tulosta painike 
		    if (base.printButtonLabel && base.hideButtons)
		    {
		        // vain pelkka tulosta painike 
		        tabi.submitCell.appendChild(getButtons(base, 'print' ,null)); 		 
		    }
		    else if (base.printButtonLabel && !base.hideButtons)
		    {
		        // tulostetaan tulosta painike ja tallenna painike 
		        var table = getTable();
		        fillTable(table,getButtons(base, 'print' ,null) , getButtons(base, 'submit' ,null));
		        table.rows[0].cells[0].style.paddingRight = '10';
		        tabi.submitCell.appendChild(table);
		    }
		    else if (!base.hideButtons)
		    { 
		        // vain pelkka tallenna painike 
		        tabi.submitCell.appendChild(getButtons(base, 'submit' ,null)); 		
	        }
	    }
	    else if (base.printButtonLabel) 
		{
		        // wizard lomakkeella esitetaan tulosta painike aina ylhaalla oikealla
		        tabi.printCell = addSubmitButton();
		        tabi.printCell.appendChild(getButtons(base, 'print' ,null)); 		 
		}
		
		
		
		var oRow = MainTable.insertRow(MainTable.rows.length);
		oCell = MainTable.rows[1].insertCell(MainTable.rows[1].cells.length); 
		oCell.style.borderTopWidth= 0; // liittyy error riviin 
		oCell.className = "TabContent"; 
		oCell.style.margin = 0;
		oCell.style.padding = 0;
		oCell.style.width="100%";
		oCell.style.height="100%";
		oCell.style.textAlign = "left";
		oCell.style.verticalAlign = "top";
		oCell.colSpan = MainTable.rows[0].cells.length ;
		
		this.contentCell = oCell;	
		if (base.wizard){
		    oRow = MainTable.insertRow(MainTable.rows.length);
		    oCell = oRow.insertCell(0);
		    oCell.style.position = 'static'; 
		    oCell.style.top = oRow.offsetTop;
		    oCell.style.width = oRow.offsetWidth;
            oCell.style.left = getAbsoluteLeft(oRow) + base.contentMarginLeft;
            oCell.style.padding = 5;
		    oCell.colSpan = MainTable.rows[0].cells.length; 
		    var oButtTable = getTable();
		    oButtTable.style.position = 'relative'; 
		    oButtTable.style.top = '-30'; 
		    oButtTable.style.width = '100%';
		    oCell.appendChild(oButtTable);    
		    this.prevNextTable = oButtTable;
		}
		selectPage(0); 
	}
	function updateButtonTable(){
	    var oRow = MainTable.rows[MainTable.rows.length - 1];
	    var oCell = oRow.cells[0];
	    oCell.style.top = oRow.offsetTop;
		  
	}
	function selectPage(tab_num){
		for (var i = 0;i<tabs.length;i++){
			tabs[i].className = 'Tab';
			tabSpaces[i].className = 'TabSpace';
		}
		if (tabs.length > 0){ 
			tabs[tab_num].className = 'TabSelected';
			tabSpaces[tab_num].className = 'TabSelectedSpace';
		}
		//this.currentPage = tab_num;
	} 
	function mouseover(){
		if(base.tabs[this.tabNum].enabled){ 
		    if (this.className != 'TabSelected'){
			    var tab_num = this.tabNum;
			    tabs[tab_num].className = 'TabMouseOver';
			    tabSpaces[tab_num].className ='TabMouseOverSpace';
		    }
		}
	}
	function mouseout(){
		if (this.className != 'TabSelected'){
			var tab_num = this.tabNum;
			tabs[tab_num].className = 'Tab';
			tabSpaces[tab_num].className = 'TabSpace';
		}
	}
	function mouseclick(){
		if(base.tabs[this.tabNum].enabled){ 
		    if (base.currentPage != this.tabNum){
		        base.goPage(this.tabNum);
		        if (!base.edit && base.created && base.wizard){base.check.check();} 
		    } 
		}
	}
}
	





// letter objekti 
// rakentaa lomakkeelle kirje navikoinnin 
function letters(base){		
	this.addPage = addPage;
	this.initialize = initialize;
	this.left; 
	this.top; 
	this.selectPage = selectPage;
	this.contentCell;		
	this.submitCell; 
    this.errorIsOpen = errorIsOpen;
    this.closeErrorLabel = closeErrorLabel;
    
	var pages = new Array();	
	var letterTable = document.createElement("table");
	letterTable.insertRow(letterTable.rows.length);
	letterTable.cellSpacing=0;
	letterTable.cellPadding=0;
	letterTable.border=0;
	letterTable.style.height="100%";
	letterTable.style.width="100%";
	base.Form.appendChild(letterTable);  
	var naviCell = letterTable.rows[0].insertCell(0);  
	naviCell.className = 'letterNaviCss';
	this.top = getAbsoluteTop(letterTable); 
	this.left = getAbsoluteLeft(letterTable); 
		
	// lisaa tabin 
	function addPage(label){
		var oNavi; 	
		oNavi = document.createElement("nobr"); 
		oNavi.innerHTML = '<font class=NaviSeparatorCss>[</font>' + label.header + '<font class=NaviSeparatorCss>]</font>';
		oNavi.className = 'NaviCss';
		oNavi.onclick = mouseclick;
		oNavi.pageNum = pages.length;
		pages[pages.length] = oNavi;
		naviCell.appendChild(oNavi); 
	}
		
	function initialize(){
		var oCell; 	
		
		 this.submitCell = letterTable.rows[0].insertCell(letterTable.rows[0].cells.length ); 
		 this.submitCell.style.textAlign = "right";
		 this.submitCell.appendChild(getButtons(base, 'submit' ,null)); 	
		 
		var oRow = letterTable.insertRow(1);
		oCell = letterTable.rows[1].insertCell(0); 
		oCell.colSpan = 2;
		var content = document.createElement("div"); 
		content.className = "letterContentCss"; 
		content.style.width="97%";
		content.style.height="97%";
		oCell.appendChild(content); 
		oCell.style.height="100%";
		this.contentCell = content;
		var oRow = letterTable.insertRow(letterTable.rows.length);
		oCell = oRow.insertCell(oRow.cells.length); 
		oCell.colSpan = letterTable.rows[0].cells.length;
		
		selectPage(0);
	}
	function selectPage(num){
		for (var i=0;i<pages.length;i++){
			pages[i].className = 'NaviCss';
		} 
		pages[num].className = 'SelectedNaviCss';
		//this.currentPage = num;
	}
	function mouseclick(){
		base.goPage(this.pageNum);
	}
	function errorIsOpen()
	{
	    return false; 
	}
	function closeErrorLabel(){};
	
}	



// simple alusta objekti 
// rakentaa lomakkeelle alustan jossa on vain yksi sivu / ei ole sivunvaihto mahdollisuutta 
function simpleLayer(base){		
	this.addTab = addTab;
	this.initialize = initialize;
	this.left;  
	this.top; 
	this.selectPage = selectPage;
	//this.currentPage;
	this.contentCell;		
	this.submitCell; 
	this.writeError = writeError; 
	this.errorIsOpen = errorIsOpen;
	this.prevNextTable;
	this.updateButtonTable = updateButtonTable;
	this.closeErrorLabel = closeErrorLabel;
	
	var errorLabel;
	var errorIframe; 
	var tabi = this; 
	var tabs = new Array();
	var tabSpaces = new Array();  
    var opera = false; 
		
	if (navigator.userAgent.indexOf('Opera') != -1)
	    opera = true;
	else if (navigator.userAgent.indexOf('Netscape6') != -1) 
	    opera = true;
	    
    // initialize tabs code 
    var MainTable = document.createElement("table");
    MainTable.insertRow(MainTable.rows.length);
    MainTable.cellSpacing=0;
    MainTable.cellPadding=0;
    MainTable.border=0;
    MainTable.style.height = base.height;
    MainTable.style.verticalAlign = 'top';
    base.Form.appendChild(MainTable);  
    window.setTimeout(fix,0);
    function fix(){base.Form.style.height = MainTable.offsetHeight;}
    
	
	function addSubmitButton(){
	    var oCell; 	
	    oCell = MainTable.rows[MainTable.rows.length - 1].insertCell(MainTable.rows[MainTable.rows.length - 1].cells.length); 
	    oCell.align = 'left'
	    oCell.vAlign = 'bottom'
	    oCell.style.padding = 5;
	    tabi.submitCell = oCell;    
	}	
	this.top = getAbsoluteTop(MainTable); 
	this.left = getAbsoluteLeft(MainTable); 
	function errorIsOpen(){
		if (!errorLabel) return false;
		else return true;
	}
	function writeError(message , blanko){		
		var absTop; 
		var absLeft;
		
		if (message){
			closeErrorLabel();
			if (!blanko) 
			    message = '<table width="100%" cellpadding=0 cellspacing=0 border=0><tr><td Class="TextCss"><B>' + lanErrortitle + '</B></td><td align=right><img style="cursor:pointer" src="' + base.virtualDirectory + 'jdm/WebControls/Images/close.gif" height="16" width="16"></td></tr></table><UL>' + message + '</SPAN></UL>';

			errorLabel = document.createElement('div');
			errorLabel.style.position = 'absolute';
			
			if (base.Form.style.position == 'absolute'){// && !window.addEventListener){
				absTop = this.contentCell.offsetTop + base.contentMarginTop; 
				absLeft = this.contentCell.offsetLeft + base.contentMarginLeft; 
			} else {
				absTop = getAbsoluteTop(this.contentCell) + base.contentMarginTop; 
				absLeft = getAbsoluteLeft(this.contentCell) + base.contentMarginLeft; 
			}
			absTop = absTop + 5;
			errorLabel.style.top = absTop ;
			errorLabel.style.left = absLeft;
			
			errorLabel.className = "TabErrorLabel"; 
			errorLabel.innerHTML = message;
			errorLabel.style.zIndex = 2; 
			if (opera) errorLabel.style.width = this.contentCell.offsetWidth - (base.contentMarginLeft + base.contentMarginRight); 
			else if (document.addEventListener) errorLabel.style.width = this.contentCell.offsetWidth - (base.contentMarginLeft + base.contentMarginRight) - 10;
			else errorLabel.style.width = this.contentCell.offsetWidth - (base.contentMarginLeft + base.contentMarginRight); 
			if (!opera){ 
				errorIframe = document.createElement('iframe');
				errorIframe.src = base.virtualDirectory + 'jdm/webcontrols/dummy.htm';
				base.Form.appendChild(errorIframe);
				base.Form.appendChild(errorLabel);
				errorIframe.style.position = 'absolute';
				errorIframe.style.height = errorLabel.offsetHeight - 2;
				errorIframe.style.top = absTop;
				errorIframe.style.left = absLeft;
				errorIframe.style.width = errorLabel.offsetWidth - 2;
				errorIframe.style.borderWidth = 0;
				errorIframe.style.zIndex = 1; 
				
				
			}else {
				base.Form.appendChild(errorLabel);
			}
			if (!blanko){
			    var oImage = errorLabel.getElementsByTagName('img')[0];
			    oImage.onclick = closeErrorLabel;
			    base.oTooltip.initialize('sulje',oImage, true)
			}
		} else {
			closeErrorLabel();
		}
	}
		
    function closeErrorLabel(){
		if (errorLabel){
			base.Form.removeChild(errorLabel);
			if (!opera) base.Form.removeChild(errorIframe);
		} 
		
		errorLabel = null;
		errorIframe = null;
		return true; 
	} 	
	// lisaa tabin 
	function addTab(tab){}
	
	function initialize(){
		var oCell; 	
		var oRow = MainTable.rows[0];
		oCell = MainTable.rows[0].insertCell(MainTable.rows[0].cells.length); 
		
		oCell.style.borderTopWidth = 0; // liittyy error riviin 
		oCell.style.margin = 0;
		oCell.style.padding = 0;
		oCell.style.width="100%";
		oCell.style.height="100%";
		oCell.style.textAlign = "left";
		oCell.style.verticalAlign = "top";
		oCell.colSpan = MainTable.rows[0].cells.length ;
		
		this.contentCell = oCell;	
		addSubmitButton();
		tabi.submitCell.appendChild(getButtons(base, 'search' ,null)); 		
	    MainTable.style.width = base.width + tabi.submitCell.offsetWidth;
	}
	function updateButtonTable(){}
	function selectPage(tab_num){} 
}


// rakentaa lomakkeelle alustan jossa on vain yksi sivu / ei ole sivunvaihto mahdollisuutta 
// kaytetaan esim hakukoneissa 
function simpleSearchLayer(base){		
	this.addTab = addTab;
	this.initialize = initialize;
	this.left;  
	this.top; 
	this.selectPage = selectPage;
	//this.currentPage;
	this.contentCell;		
	this.submitCell; 
	this.writeError = writeError; 
	this.errorIsOpen = errorIsOpen;
	this.prevNextTable;
	this.updateButtonTable = updateButtonTable;
	this.closeErrorLabel = closeErrorLabel;
	
	var errorLabel;
	var errorIframe; 
	var tabi = this; 
	var tabs = new Array();
	var tabSpaces = new Array();  
    var opera = false; 
		
	if (navigator.userAgent.indexOf('Opera') != -1)
	    opera = true;
	else if (navigator.userAgent.indexOf('Netscape6') != -1) 
	    opera = true;
	    
    // initialize tabs code 
    var MainTable = document.createElement("table");
    
    MainTable.insertRow(MainTable.rows.length);
    MainTable.cellSpacing=0;
    MainTable.cellPadding=0;
    MainTable.border=0;
    MainTable.style.height = base.height;
    MainTable.style.width = base.width;
    MainTable.style.verticalAlign = 'top';
    base.Form.appendChild(MainTable);  
	
	function addSubmitButton(){
        var oCell; 	
        oCell = document.createElement('div');

	    if (base.submitButtonTop)
	    {
	        if (base.submitButtonLeft)
	        {
	            if (base.submitButtonLeft == '100%' && base.submitButtonTop == '100%')
	            {
	                base.Form.appendChild(oCell);
	            }
	            else 
	            {
	                oCell.style.position = 'absolute';
	                oCell.style.top = base.submitButtonTop; 
	                oCell.style.left = base.submitButtonLeft; 
	                base.Form.appendChild(oCell);
	            }
	        }
	    }
        tabi.submitCell = oCell;    
	}	
	this.top = getAbsoluteTop(MainTable); 
	this.left = getAbsoluteLeft(MainTable); 
	function errorIsOpen(){
		if (!errorLabel) return false;
		else return true;
	}
	function writeError(message , blanko){		
		var absTop; 
		var absLeft;
		
		if (message){
			closeErrorLabel();
			if (!blanko) 
			    message = '<table width="100%" cellpadding=0 cellspacing=0 border=0><tr><td Class="TextCss"><B>' + lanErrortitle + '</B></td><td align=right><img style="cursor:pointer" src="' + base.virtualDirectory + 'jdm/WebControls/Images/close.gif" height="16" width="16"></td></tr></table><UL>' + message + '</SPAN></UL>';

			errorLabel = document.createElement('div');
			errorLabel.style.position = 'absolute';
			
			if (base.Form.style.position == 'absolute'){// && !window.addEventListener){
				absTop = this.contentCell.offsetTop + base.contentMarginTop; 
				absLeft = this.contentCell.offsetLeft + base.contentMarginLeft; 
			} else {
				absTop = getAbsoluteTop(this.contentCell) + base.contentMarginTop; 
				absLeft = getAbsoluteLeft(this.contentCell) + base.contentMarginLeft; 
			}
			absTop = absTop + 5;
			errorLabel.style.top = absTop ;
			errorLabel.style.left = absLeft;
			
			errorLabel.className = "TabErrorLabel"; 
			errorLabel.innerHTML = message;
			errorLabel.style.zIndex = 2; 
			if (opera) errorLabel.style.width = this.contentCell.offsetWidth - (base.contentMarginLeft + base.contentMarginRight); 
			else if (document.addEventListener) errorLabel.style.width = this.contentCell.offsetWidth - (base.contentMarginLeft + base.contentMarginRight) - 10;
			else errorLabel.style.width = this.contentCell.offsetWidth - (base.contentMarginLeft + base.contentMarginRight); 
			if (!opera){ 
				errorIframe = document.createElement('iframe');
				errorIframe.src = base.virtualDirectory + 'jdm/webcontrols/dummy.htm';
				base.Form.appendChild(errorIframe);
				base.Form.appendChild(errorLabel);
				errorIframe.style.position = 'absolute';
				errorIframe.style.height = errorLabel.offsetHeight - 2;
				errorIframe.style.top = absTop;
				errorIframe.style.left = absLeft;
				errorIframe.style.width = errorLabel.offsetWidth - 2;
				errorIframe.style.borderWidth = 0;
				errorIframe.style.zIndex = 1; 
				
				
			}else {
				base.Form.appendChild(errorLabel);
			}
			if (!blanko){
			    var oImage = errorLabel.getElementsByTagName('img')[0];
			    oImage.onclick = closeErrorLabel;
			    base.oTooltip.initialize('sulje',oImage, true)
			}
		} else {
			closeErrorLabel();
		}
	}
	function closeErrorLabel(){
		if (errorLabel){
			base.Form.removeChild(errorLabel);
			if (!opera) base.Form.removeChild(errorIframe);
		} 
		
		errorLabel = null;
		errorIframe = null;
		return true; 
	} 	
	// lisaa tabin 
	function addTab(tab){}
	
	function initialize(){
		var oCell; 	
		var oRow = MainTable.rows[0];
		oCell = MainTable.rows[0].insertCell(MainTable.rows[0].cells.length); 
		
		oCell.style.borderTopWidth = 0; // liittyy error riviin 
		oCell.style.margin = 0;
		oCell.style.padding = 0;
		oCell.style.width="100%";
		oCell.style.height="100%";
		oCell.style.textAlign = "left";
		oCell.style.verticalAlign = "top";
		oCell.colSpan = MainTable.rows[0].cells.length ;
		
		this.contentCell = oCell;	
		addSubmitButton();
		tabi.submitCell.appendChild(getButtons(base, 'search' ,null)); 		
	    MainTable.style.width = base.width;
	}
	function updateButtonTable(){}
	function selectPage(tab_num){} 
}




// rakentaa lomakkeelle alustan jossa on vain yksi sivu / ei ole sivunvaihto mahdollisuutta 
// käytetään esim lomakkeissa  
function simpleFormLayer(base){		
	this.addTab = addTab;
	this.initialize = initialize;
	this.left;  
	this.top; 
	this.selectPage = selectPage;
	//this.currentPage;
	this.contentCell;		
	this.submitCell; 
	this.writeError = writeError; 
	this.errorIsOpen = errorIsOpen;
	this.prevNextTable;
	this.updateButtonTable = updateButtonTable;
	this.closeErrorLabel = closeErrorLabel;
	
	var errorLabel;
	var errorIframe; 
	var tabi = this; 
	var tabs = new Array();
	var tabSpaces = new Array();  
    var opera = false; 
		
	if (navigator.userAgent.indexOf('Opera') != -1)
	    opera = true;
	else if (navigator.userAgent.indexOf('Netscape6') != -1) 
	    opera = true;
	    
    // initialize tabs code 
    var MainTable = document.createElement("table");
    
    MainTable.insertRow(MainTable.rows.length);
    MainTable.cellSpacing=0;
    MainTable.cellPadding=0;
    MainTable.border=0;
    MainTable.style.height = base.height;
    MainTable.style.width = base.width;
    MainTable.style.verticalAlign = 'top';
    base.Form.appendChild(MainTable);  
	
	function addSubmitButton(){
        var oCell; 	
        oCell = document.createElement('div');

	    if (base.submitButtonTop)
	    {
	        if (base.submitButtonLeft)
	        {
	            if (base.submitButtonLeft == '100%' && base.submitButtonTop == '100%')
	            {
	                base.Form.appendChild(oCell);
	            }
	            else 
	            {
	                oCell.style.position = 'absolute';
	                oCell.style.top = base.submitButtonTop; 
	                oCell.style.left = base.submitButtonLeft; 
	                base.Form.appendChild(oCell);
	            }
	        }
	    }
        tabi.submitCell = oCell;    
	}	
	this.top = getAbsoluteTop(MainTable); 
	this.left = getAbsoluteLeft(MainTable); 
	function errorIsOpen(){
		if (!errorLabel) return false;
		else return true;
	}
	function writeError(message , blanko){		
		var absTop; 
		var absLeft;
		
		if (message){
			closeErrorLabel();
			if (!blanko) 
			    message = '<table width="100%" cellpadding=0 cellspacing=0 border=0><tr><td Class="TextCss"><B>' + lanErrortitle + '</B></td><td align=right><img style="cursor:pointer" src="' + base.virtualDirectory + 'jdm/WebControls/Images/close.gif" height="16" width="16"></td></tr></table><UL>' + message + '</SPAN></UL>';

			errorLabel = document.createElement('div');
			errorLabel.style.position = 'absolute';
			
			if (base.Form.style.position == 'absolute'){// && !window.addEventListener){
				absTop = this.contentCell.offsetTop + base.contentMarginTop; 
				absLeft = this.contentCell.offsetLeft + base.contentMarginLeft; 
			} else {
				absTop = getAbsoluteTop(this.contentCell) + base.contentMarginTop; 
				absLeft = getAbsoluteLeft(this.contentCell) + base.contentMarginLeft; 
			}
			absTop = absTop + 5;
			errorLabel.style.top = absTop ;
			errorLabel.style.left = absLeft;
			
			errorLabel.className = "TabErrorLabel"; 
			errorLabel.innerHTML = message;
			errorLabel.style.zIndex = 2; 
			if (opera) errorLabel.style.width = this.contentCell.offsetWidth - (base.contentMarginLeft + base.contentMarginRight); 
			else if (document.addEventListener) errorLabel.style.width = this.contentCell.offsetWidth - (base.contentMarginLeft + base.contentMarginRight) - 10;
			else errorLabel.style.width = this.contentCell.offsetWidth - (base.contentMarginLeft + base.contentMarginRight); 
			if (!opera){ 
				errorIframe = document.createElement('iframe');
				errorIframe.src = base.virtualDirectory + 'jdm/webcontrols/dummy.htm';
				base.Form.appendChild(errorIframe);
				base.Form.appendChild(errorLabel);
				errorIframe.style.position = 'absolute';
				errorIframe.style.height = errorLabel.offsetHeight - 2;
				errorIframe.style.top = absTop;
				errorIframe.style.left = absLeft;
				errorIframe.style.width = errorLabel.offsetWidth - 2;
				errorIframe.style.borderWidth = 0;
				errorIframe.style.zIndex = 1; 
				
				
			}else {
				base.Form.appendChild(errorLabel);
			}
			if (!blanko){
			    var oImage = errorLabel.getElementsByTagName('img')[0];
			    oImage.onclick = closeErrorLabel;
			    base.oTooltip.initialize('sulje',oImage, true)
			}
		} else {
			closeErrorLabel();
		}
	}
	function closeErrorLabel(){
		if (errorLabel){
			base.Form.removeChild(errorLabel);
			if (!opera) base.Form.removeChild(errorIframe);
		} 
		
		errorLabel = null;
		errorIframe = null;
		return true; 
	} 	
	// lisaa tabin 
	function addTab(tab){}
	
	function initialize(){
		var oCell; 	
		var oRow = MainTable.rows[0];
		oCell = MainTable.rows[0].insertCell(MainTable.rows[0].cells.length); 
		
		oCell.style.borderTopWidth = 0; // liittyy error riviin 
		oCell.style.margin = 0;
		oCell.style.padding = 0;
		oCell.style.width="100%";
		oCell.style.height="100%";
		oCell.style.textAlign = "left";
		oCell.style.verticalAlign = "top";
		oCell.colSpan = MainTable.rows[0].cells.length ;
		
		this.contentCell = oCell;	
		addSubmitButton();
		tabi.submitCell.appendChild(getButtons(base, 'execute' ,null)); 		
	    MainTable.style.width = base.width;
	}
	function updateButtonTable(){}
	function selectPage(tab_num){} 
}


// rakentaa lomakkeelle kirje navikoinnin 
function notes(base){		
	this.addPage = addPage;
	this.initialize = initialize;
	this.left; 
	this.top; 
	this.selectPage = selectPage;
	this.contentCell;		
	this.submitCell; 
    this.errorIsOpen = errorIsOpen;
    this.closeErrorLabel = closeErrorLabel;
    
	var pages = new Array();	
	var letterTable = document.createElement("table");
	letterTable.insertRow(letterTable.rows.length);
	letterTable.cellSpacing=0;
	letterTable.cellPadding=0;
	letterTable.border=0;
	letterTable.style.height="100%";
	letterTable.style.width="100%";
	base.Form.appendChild(letterTable);  
	var naviCell = letterTable.rows[0].insertCell(0);  
	naviCell.className = 'letterNaviCss';
	this.top = getAbsoluteTop(letterTable); 
	this.left = getAbsoluteLeft(letterTable); 
		
	// lisaa tabin 
	function addPage(label){
		var oNavi; 	
		oNavi = document.createElement("nobr"); 
		oNavi.innerHTML = label.header;
		oNavi.className = 'NaviCss';
		oNavi.onclick = mouseclick;
		oNavi.pageNum = pages.length;
		pages[pages.length] = oNavi;
		naviCell.appendChild(oNavi); 
	}
		
	function initialize(){
		var oCell; 	
		
		 this.submitCell = letterTable.rows[0].insertCell(letterTable.rows[0].cells.length ); 
		 this.submitCell.style.textAlign = "right";
		 this.submitCell.appendChild(getButtons(base, 'close' ,null)); 	
		 
		var oRow = letterTable.insertRow(1);
		oCell = letterTable.rows[1].insertCell(0); 
		oCell.colSpan = 2;
		var content = document.createElement("div"); 
		content.className = "letterContentCss"; 
		content.style.width="97%";
		content.style.height="97%";
		oCell.appendChild(content); 
		oCell.style.height="100%";
		this.contentCell = content;
		var oRow = letterTable.insertRow(letterTable.rows.length);
		oCell = oRow.insertCell(oRow.cells.length); 
		oCell.colSpan = letterTable.rows[0].cells.length;
		
		selectPage(0);
	}
	function selectPage(num){
		for (var i=0;i<pages.length;i++){
			pages[i].className = 'NaviCss';
		} 
		pages[num].className = 'SelectedNaviCss';
		//this.currentPage = num;
	}
	function mouseclick(){
		base.goPage(this.pageNum);
	}
	function errorIsOpen()
	{
	    return false; 
	}
	function closeErrorLabel(){}
}	



// notes2 objekti #F9C379
// rakentaa lomakkeelle kirje navikoinnin 
function notes2(base){		
	this.addPage = addPage;
	this.initialize = initialize;
	this.left; 
	this.top; 
	this.selectPage = selectPage;
	this.contentCell;		
	this.submitCell; 
    this.errorIsOpen = errorIsOpen;
    
	var pages = new Array();	
	var letterTable = document.createElement("table");
	letterTable.insertRow(letterTable.rows.length);
	letterTable.cellSpacing=0;
	letterTable.cellPadding=0;
	letterTable.border=0;
	letterTable.style.height="100%";
	letterTable.style.width="100%";
	base.Form.appendChild(letterTable);  
	var naviCell = letterTable.rows[0].insertCell(0);  
	naviCell.className = 'NotesNaviCss';
	this.top = getAbsoluteTop(letterTable); 
	this.left = getAbsoluteLeft(letterTable); 
		
	// lisaa tabin 
	function addPage(label){
		var oNavi; 	
		oNavi = document.createElement("nobr"); 
		oNavi.innerHTML = label.header;
		oNavi.className = 'NaviCss';
		oNavi.onclick = mouseclick;
		oNavi.pageNum = pages.length;
		pages[pages.length] = oNavi;
		naviCell.appendChild(oNavi); 
	}
		
	function initialize(){
		var oCell; 	
		
		this.submitCell = letterTable.rows[0].insertCell(letterTable.rows[0].cells.length ); 
		this.submitCell.style.textAlign = "right";
		this.submitCell.appendChild(getButtons(base, 'close' ,null)); 	
		letterTable.className = "NotesContentCss";  
		letterTable.rows[0].style.paddingTop = 5;
		letterTable.rows[0].style.paddingLeft = 5;
		letterTable.rows[0].style.paddingRight = 5;
		letterTable.rows[0].style.paddingBottom = 5;
		
		
		var oRow = letterTable.insertRow(1);
		oCell = letterTable.rows[1].insertCell(0); 
		oCell.colSpan = 2;
		
		// Luodaan hr ilmio valiin 
		var hr = document.createElement("img");
		oCell.style.borderStyle = 'solid';
		oCell.style.borderWidth = 1;
		oCell.style.borderColor = 'white';
		hr.style.height = 1;
		hr.style.width = '100%';
		hr.src = base.virtualDirectory + 'jdm/webcontrols/images/space.gif';
		oCell.appendChild(hr);
		
		var oRow = letterTable.insertRow(2);
		oCell = letterTable.rows[2].insertCell(0); 
		oCell.colSpan = 2;
		var content = document.createElement("div"); 
		
		content.style.width="97%";
		content.style.height="97%";
		oCell.appendChild(content); 
		oCell.style.height="100%";
		this.contentCell = content;
		var oRow = letterTable.insertRow(letterTable.rows.length);
		oCell = oRow.insertCell(oRow.cells.length); 
		oCell.colSpan = letterTable.rows[0].cells.length;
		
		selectPage(0);
	}
	function selectPage(num){
		for (var i=0;i<pages.length;i++){
			pages[i].className = 'NaviCss';
		} 
		pages[num].className = 'SelectedNaviCss';
		//this.currentPage = num;
	}
	function mouseclick(){
		base.goPage(this.pageNum);
	}
	function errorIsOpen()
	{
	    return false; 
	}
	
}	

// kaytetaan esim kontrolleissa  
function simpleWizardSearchLayer(base){		
	this.addTab = addTab;
	this.initialize = initialize;
	this.left;  
	this.top; 
	this.selectPage = selectPage;
	//this.currentPage;
	this.contentCell;		
	this.submitCell; 
	this.writeError = writeError; 
	this.errorIsOpen = errorIsOpen;
	this.prevNextTable;
	this.updateButtonTable = updateButtonTable;
	this.closeErrorLabel = closeErrorLabel;
	
	var errorLabel;
	var errorIframe; 
	var tabi = this; 
	var tabs = new Array();
	var tabSpaces = new Array();  
    var opera = false; 
		
	if (navigator.userAgent.indexOf('Opera') != -1)
	    opera = true;
	else if (navigator.userAgent.indexOf('Netscape6') != -1) 
	    opera = true;
	    
    // initialize tabs code 
    var MainTable = document.createElement("table");
    
    MainTable.insertRow(MainTable.rows.length);
    MainTable.cellSpacing=0;
    MainTable.cellPadding=0;
    MainTable.border=0;
    MainTable.style.height = base.height;
    MainTable.style.width = base.width;
    MainTable.style.verticalAlign = 'top';
    base.Form.appendChild(MainTable);  
	
	function addSubmitButton(){
        var oCell; 	
        oCell = document.createElement('div');

	    if (base.submitButtonTop)
	    {
	        if (base.submitButtonLeft)
	        {
	            oCell.style.position = 'absolute';
	            oCell.style.top = base.submitButtonTop; 
	            oCell.style.left = base.submitButtonLeft; 
	            base.Form.appendChild(oCell);
	        }
	    }
        tabi.submitCell = oCell;    
	}	
	this.top = getAbsoluteTop(MainTable); 
	this.left = getAbsoluteLeft(MainTable); 
	function errorIsOpen(){
		if (!errorLabel) return false;
		else return true;
	}
	function writeError(message , blanko){		
		var absTop; 
		var absLeft;
		
		if (message){
			closeErrorLabel();
			if (!blanko) 
			    message = '<table width="100%" cellpadding=0 cellspacing=0 border=0><tr><td Class="TextCss"><B>' + lanErrortitle + '</B></td><td align=right><img style="cursor:pointer" src="' + base.virtualDirectory + 'jdm/WebControls/Images/close.gif" height="16" width="16"></td></tr></table><UL>' + message + '</SPAN></UL>';

			errorLabel = document.createElement('div');
			errorLabel.style.position = 'absolute';
			
			if (base.Form.style.position == 'absolute'){// && !window.addEventListener){
				absTop = this.contentCell.offsetTop + base.contentMarginTop; 
				absLeft = this.contentCell.offsetLeft + base.contentMarginLeft; 
			} else {
				absTop = getAbsoluteTop(this.contentCell) + base.contentMarginTop; 
				absLeft = getAbsoluteLeft(this.contentCell) + base.contentMarginLeft; 
			}
			absTop = absTop + 5;
			errorLabel.style.top = absTop ;
			errorLabel.style.left = absLeft;
			
			errorLabel.className = "TabErrorLabel"; 
			errorLabel.innerHTML = message;
			errorLabel.style.zIndex = 2; 
			if (opera) errorLabel.style.width = this.contentCell.offsetWidth - (base.contentMarginLeft + base.contentMarginRight); 
			else if (document.addEventListener) errorLabel.style.width = this.contentCell.offsetWidth - (base.contentMarginLeft + base.contentMarginRight) - 10;
			else errorLabel.style.width = this.contentCell.offsetWidth - (base.contentMarginLeft + base.contentMarginRight); 
			if (!opera){ 
				errorIframe = document.createElement('iframe');
				errorIframe.src = base.virtualDirectory + 'jdm/webcontrols/dummy.htm';
				base.Form.appendChild(errorIframe);
				base.Form.appendChild(errorLabel);
				errorIframe.style.position = 'absolute';
				errorIframe.style.height = errorLabel.offsetHeight - 2;
				errorIframe.style.top = absTop;
				errorIframe.style.left = absLeft;
				errorIframe.style.width = errorLabel.offsetWidth - 2;
				errorIframe.style.borderWidth = 0;
				errorIframe.style.zIndex = 1; 
				
				
			}else {
				base.Form.appendChild(errorLabel);
			}
			if (!blanko){
			    var oImage = errorLabel.getElementsByTagName('img')[0];
			    oImage.onclick = closeErrorLabel;
			    base.oTooltip.initialize('sulje',oImage, true)
			}
		} else {
			closeErrorLabel();
		}
	}
	function closeErrorLabel(){
		if (errorLabel){
			base.Form.removeChild(errorLabel);
			if (!opera) base.Form.removeChild(errorIframe);
		} 
		
		errorLabel = null;
		errorIframe = null;
		return true; 
	} 	
	// lisaa tabin 
	function addTab(tab){}
	
	function initialize(){
		var oCell; 	
		var oRow = MainTable.rows[0];
		oCell = MainTable.rows[0].insertCell(MainTable.rows[0].cells.length); 
		
		oCell.style.borderTopWidth = 0; // liittyy error riviin 
		oCell.style.margin = 0;
		oCell.style.padding = 0;
		oCell.style.width="100%";
		oCell.style.height="100%";
		oCell.style.textAlign = "left";
		oCell.style.verticalAlign = "top";
		oCell.colSpan = MainTable.rows[0].cells.length ;
		
		this.contentCell = oCell;	
		addSubmitButton();
		tabi.submitCell.appendChild(getButtons(base, 'search' ,null)); 		
	    MainTable.style.width = base.width-((base.contentMarginRight + base.contentMarginLeft));
	}
	function updateButtonTable(){}
	function selectPage(tab_num){} 
}

