//--------------------------------------------просто кнопка, всем кнопкам кнопка
 function mainButton(container){
 this.container=container;//место куда поместяться кнопки
 this.Name='&nbsp;';//название кнопки (отобразиться у пользователя) Любой хтмл код
 this.onclick="";//функция которая выполниться если кликнуть на кнопку
 this.Id='';//уникальный идентификатор. если он задан можно с кнопкой делать что угодно
 this.radio='0';// если 1 то при нажатии на кнопку все кнопки в этом же контейнере становятся отжатыми
 this.Action='1';// может ли вообще нажиматься и меняться
 this.Active='0'; //если 1 - кнопка залипает и так остается. если 0 кнопка "отлипает"
 this.firstStat='1'; //статус загрузки кнопки 1. не активная не нажата. 2. активная не нажатая 3. активная нажатая. 4. не активная нажатая
 this.Stat= new Array();//стили кнопки.
 this.Stat['1']='button'; 
 this.Stat['2']='abutton';
 this.Stat['3']='dbutton';
 this.Stat['4']='ubutton';
 this.Attribute= new Array();
 this.attributeSet = function (name, value) //добавляет дополнительные атрибуты в кнопку. вызвать ДО создания кнопки
  {
    this.Attribute.push(name+"~"+value)
  }
 this.onmouseover= function (Stat){
 		 if(this.className==Stat['1']){this.className=Stat['2'];}
		 if(this.className==Stat['4']){this.className=Stat['3'];}
 }
if (this.Active=='1')
 { 
  this.onmouseout= function (Stat){
	 if(this.className==Stat['2']){this.className=Stat['1'];}
	 if(this.className=Stat['3']){this.className=Stat['4'];}	 
     }
  this.onmouseup= function (Stat, radio){
 			if(navigator.appVersion.indexOf('MSIE')!=-1){var parent=this.parentNode;}else{var parent=this.parentElement;}
			if(radio==1){for(var i=0; i<parent.childNodes.length; i++){parent.childNodes[i].className=Stat['1'];}}
	        this.className=Stat['3'];
			}
 }else{

  this.onmouseout= function (Stat){
		if(this.className==Stat['2']){this.className=Stat['1'];}
		if(this.className==Stat['3']){this.className=Stat['1'];}
        }

  this.onmouseup= function (Stat){this.className=Stat['2'];}

  }
 this.onmousedown= function (Stat){this.className=Stat['3'];}

 this.CreateButton = function (container) 
  {
	this.a=document.createElement("a");
	this.a.className=this.Stat[this.firstStat];
	this.a.id=this.Id;
    for (var i = 0; i < Attribute.length; i++)
	 {
	  var m = Attribute[i].split('~');
	  eval("this.a."+m[0]+"='"+m[1]+"';");
	 }
    this.span=document.createElement("span");
	this.span.onselectstart=function(){event.returnValue=false;};
	if(this.Action=='1')
	{
	 this.a.onmouseover=this.onmouseover(this.Stat);
	 this.a.onmouseout=this.onmouseout(this.Stat);
     this.a.onmouseup=this.onmouseup(this.Stat, this.radio);
	 this.a.onmousedown=this.onmousedown(this.Stat);
	 this.a.onclick=this.onclick;
    }	
   this.a.appendChild(this.span);
   this.span.innerHTML=this.Name;
   this.span.onselectstart=function(){return false;}
   this.container.appendChild(this.a);
  }
 }



//--------------------------------------------/просто кнопка, всем кнопкам кнопка

//--------------------------------------------кнопка на рабочей панеле

function WorkPanelButton(container){
 this.container=container;//место куда поместяться кнопки
 this.Name='button';//название кнопки (отобразиться у пользователя)
 
this.onclick=function()
	{
			ButtonsWorkPanelOnClick(this.firstChild.innerHTML);
		}
//функция которая выполниться если кликнуть на кнопку
 this.Id='';//уникальный идентификатор. если он задан можно с кнопкой делать что угодно
 this.Action='1';// может ли вообще нажиматься и меняться
 this.Active='1'; //если 1 - кнопка залипает и так остается. если 0 кнопка "отлипает"
 Attribute= new Array();
 this.setAttribute = function (name, value) //добавляет дополнительные атрибуты в кнопку. вызвать ДО создания кнопки
  {
   Attribute.push(name+"~"+value);   
  }
 this.CreateButton = function (container) 
  {
	this.a=document.createElement("div");
	this.a.className='wbutton';
    for (var i = 0; i < Attribute.length; i++)
	 {
	  var m = Attribute[i].split('~');
      eval("this.a."+m[0]+"='"+m[1]+"';");
	  this.a.setAttribute(m[0], m[1]);
	 }
    this.span=document.createElement("span");
	this.span.onselectstart=function(){event.returnValue=false;};
	if(this.Action=='1')
	{
	 this.a.onmouseover=function()
	 {
		 if(this.className=="wbutton")
		 {
		 this.className="wabutton";
		 }
		 if(this.className=="wpcbutton")
		 {
		 this.className="wcbutton";
		 }
	 } 
     this.a.onmouseout=function()
	 {
		 if(this.className=="wabutton")
		 {
		 this.className="wbutton";
		 }
		 if(this.className=="wcbutton")
		 {
		 this.className="wpcbutton";
		 }
	  } 
	
	 this.a.onclick=this.onclick;

 	 this.a.onmousedown=function()
	 {  
 		WorkPanel.resetButton();
		this.className="wcbutton";
	 };
	 if (this.Active!=1)
	 {

     this.a.onmouseup=function()
	 {  
 		WorkPanel.resetButton();
		this.className="wabutton";
	 };
	 }
	}
    this.a.appendChild(this.span);
	this.span.innerHTML=this.Name;
    this.span.onselectstart=function(){return false;}
   this.container.appendChild(this.a);
  }
 }

//--------------------------------------------кнопка ОК на рабочей панеле и переключатели режимов на верхней панели
function buttonOK(container){
 this.container=container;//место куда поместяться кнопки
 this.Name='OK';//название кнопки (отобразиться у пользователя) Любой хтмл код
 this.onclick="";//функция которая выполниться если кликнуть на кнопку
 this.Id='';//уникальный идентификатор. если он задан можно с кнопкой делать что угодно
 this.Action='1';// может ли вообще нажиматься и меняться
 this.firstStat='1'; //статус загрузки кнопки 1. не активная не нажата. 2. активная не нажатая 3. активная нажатая. 4. не активная нажатая
 this.Active='0'; //если 1 - кнопка залипает и так остается. если 0 кнопка "отлипает"
 this.Stat=new Array();
 this.Stat['1']='button';
 this.Stat['2']='abutton';
 this.Stat['3']='dbutton';
 this.Stat['4']='ubutton';
 Attribute= new Array();
 this.attributeSet = function (name, value) //добавляет дополнительные атрибуты в кнопку. вызвать ДО создания кнопки
  {
   Attribute.push(name+"~"+value)
  }
 this.CreateButton = function (container) 
  {
	this.a=document.createElement("a");
	this.a.className=this.Stat[this.firstStat];
	this.a.id=this.Id;
    for (var i = 0; i < Attribute.length; i++)
	 {
	  var m = Attribute[i].split('~');
	  eval("this.a."+m[0]+"='"+m[1]+"';");
	 }
    this.span=document.createElement("span");
	this.span.onselectstart=function(){event.returnValue=false;};
	if(this.Action=='1')
	{
	 
	 this.a.onmouseover=function()
	   {
		 if(this.className=="button")
		  {
		   this.className="abutton";
		  }
		 if(this.className=="ubutton")
		  {
		   this.className="dbutton";
		  }
	   } 

	 if (this.Active=='1')
	   { 
	  
	   this.a.onmouseout=function()
	     {
		  if(this.className=="abutton")
		   {
			 this.className="button";
		   }
		 if(this.className=="dbutton")
		   {
		    this.className="ubutton";
	       }	 
	     } 
	  
	  this.a.onmouseup=function()
		  {  
			 topPanel.resetModeButton();
	         this.className="dbutton";
		  }
	   
	   }else
	   {
	   
		this.a.onmouseout=function()
		 {
		 if(this.className=="abutton")
		   {
		   this.className="button";
		   }
		 if(this.className=="dbutton")
		   {
		   this.className="button";
	       }
		 }
 		 
		 this.a.onmouseup=function()
		  {  
			 this.className="abutton";
 	 	  }		
	   }
   
     this.a.onclick=this.onclick;
 	 this.a.onmousedown=function()
	 {  
		this.className="dbutton";
	 };
   }	
   this.a.appendChild(this.span);
   this.span.innerHTML=this.Name;
   this.span.onselectstart=function(){return false;}
   this.container.appendChild(this.a);
  }
 }
///-------------------------------точно такая же кнопка как и предыдущая, только мааааленькая
function mbuttonOK(container){
 this.container=container;//место куда поместяться кнопки
 this.Name='OK';//название кнопки (отобразиться у пользователя) Любой хтмл код
 this.onclick="";//функция которая выполниться если кликнуть на кнопку
 this.Id='';//уникальный идентификатор. если он задан можно с кнопкой делать что угодно
 this.Action='1';// может ли вообще нажиматься и меняться
 this.firstStat='1'; //статус загрузки кнопки 1. не активная не нажата. 2. активная не нажатая 3. активная нажатая. 4. не активная нажатая
 this.Active='0'; //если 1 - кнопка залипает и так остается. если 0 кнопка "отлипает"
 this.Stat=new Array();
 this.Stat['1']='mbutton';
 this.Stat['2']='mabutton';
 this.Stat['3']='mdbutton';
 this.Stat['4']='mubutton';
 Attribute= new Array();
 this.attributeSet = function (name, value) //добавляет дополнительные атрибуты в кнопку. вызвать ДО создания кнопки
  {
   Attribute.push(name+"~"+value)
  }
 this.CreateButton = function (container) 
  {
	this.a=document.createElement("a");
	this.a.className=this.Stat[this.firstStat];
	this.a.id=this.Id;
    for (var i = 0; i < Attribute.length; i++)
	 {
	  var m = Attribute[i].split('~');
	  eval("this.a."+m[0]+"='"+m[1]+"';");
	 }
    this.span=document.createElement("span");
	this.span.onselectstart=function(){event.returnValue=false;};
	if(this.Action=='1')
	{
	 
	 this.a.onmouseover=function()
	   {
		 if(this.className=="mbutton")
		  {
		   this.className="mabutton";
		  }
		 if(this.className=="mubutton")
		  {
		   this.className="mdbutton";
		  }
	   } 

	 if (this.Active=='1')
	   { 
	  
	   this.a.onmouseout=function()
	     {
		  if(this.className=="mabutton")
		   {
			 this.className="mbutton";
		   }
		 if(this.className=="mdbutton")
		   {
		    this.className="mubutton";
	       }	 
	     } 
	  
	  this.a.onmouseup=function()
		  {  
			 topPanel.resetModeButton();
	         this.className="mdbutton";
		  }
	   
	   }else
	   {
	   
		this.a.onmouseout=function()
		 {
		 if(this.className=="mabutton")
		   {
		   this.className="mbutton";
		   }
		 if(this.className=="mdbutton")
		   {
		   this.className="mbutton";
	       }
		 }
 		 
		 this.a.onmouseup=function()
		  {  
			 this.className="mabutton";
 	 	  }		
	   }
   
     this.a.onclick=this.onclick;
 	 this.a.onmousedown=function()
	 {  
		this.className="mdbutton";
	 };
   }	
   this.a.appendChild(this.span);
   this.span.innerHTML=this.Name;
   this.span.onselectstart=function(){return false;}
   this.container.appendChild(this.a);
  }
 }
//--------------------------------------------кнопки из трех частей--------------

function VButtonFrom3Part(container){
	this.container=container;
	this.Name='button';
	this.LeftPart='img/leftnonactivebutton.gif';
	this.FonPart='url(img/fonnonactivebutton.gif)';
	this.RightPart='img/rightnonactivebutton.gif';
	this.Id='r';
	this.mainId='r';
	this.onclick='';
	this.onmousemove='';
	this.onmouseout='';
	this.cursor='';
    this.width='100%';
	this.txtcolor='rgb(255,255,255)';
	this.CreateButton = function (container) {
	this.ButtonTable= document.createElement("table");
	this.ButtonTable.style.zIndex='50';
	this.ButtonTable.style.width=this.width;
	this.ButtonTable.id=this.Id;
    this.ButtonTable.style.cellSpacing='0';
    this.ButtonTable.cellSpacing='0';
    this.ButtonTable.cellPadding='0';
    this.ButtonTable.style.cellPadding='0';
	this.ButtonTable.insertRow(0);
	this.ButtonTable.rows[0].insertCell(0);	
	this.ButtonTable.rows[0].insertCell(1);
	this.ButtonTable.rows[0].insertCell(2);
	if(navigator.appName!='Netscape'){this.ButtonTable.style.tableLayout='fixed';}
	this.ButtonTable.rows[0].cells[0].style.width='10px';
	this.ButtonTable.rows[0].cells[0].style.textAlign='right';
	this.ButtonTable.rows[0].cells[0].style.verticalAlign='top';
	this.ButtonTable.rows[0].cells[2].style.verticalAlign='top';
	this.ButtonTable.rows[0].cells[1].style.textAlign='center';
	this.ButtonTable.rows[0].cells[1].id=this.mainId;
	this.ButtonTable.rows[0].cells[2].style.width='14px';
	this.ButtonTable.rows[0].cells[1].style.paddingTop='0px';	
	this.ButtonTable.rows[0].cells[1].style.paddingBottom='0px';	
	this.ButtonTable.rows[0].cells[1].style.color=this.txtcolor;	
	this.ButtonTable.rows[0].cells[0].style.backgroundRepeat='repeat-x';
	this.ButtonTable.style.backgroundRepeat='repeat-x';
	this.ButtonTable.rows[0].cells[2].style.backgroundRepeat='repeat-x';
	this.ButtonTable.rows[0].cells[1].style.cursor=this.cursor;
	this.LeftImg=document.createElement("img");
	this.LeftImg.src=this.LeftPart;
	this.ButtonTable.rows[0].cells[0].appendChild(this.LeftImg);
	this.RightImg=document.createElement("img");
	this.RightImg.src=this.RightPart;
	this.ButtonTable.rows[0].cells[2].appendChild(this.RightImg);
	this.ButtonTable.rows[0].cells[1].innerHTML=this.Name;
	this.ButtonTable.Name=this.Name;
	this.ButtonTable.rows[0].cells[1].style.background=this.FonPart;
	this.ButtonTable.rows[0].cells[1].style.backgroundRepeat='repeat-x';		
	this.ButtonTable.rows[0].cells[1].backgroundRepeat='repeat-x';		
	this.ButtonTable.onclick=this.onclick;	
	this.container.appendChild(this.ButtonTable);
	this.ButtonTable.onclick=this.onclick;
	this.ButtonTable.onmousemove=this.onmousemove;
	this.ButtonTable.onmouseout=this.onmouseout;}}
//-------------------------------------------------------------------------------------------------
//--------------------------------------------кнопки для верхней панельки--------------

function buttonTop(container){
 this.container=container;//место куда поместяться кнопки
 this.Name='работа';//название кнопки (отобразиться у пользователя) Любой хтмл код
 this.onclick="";//функция которая выполниться если кликнуть на кнопку
 this.Id='';//уникальный идентификатор. если он задан можно с кнопкой делать что угодно
 this.Action='1';// может ли вообще нажиматься и меняться
 this.Active='1'; //если 1 - кнопка залипает и так остается. если 0 кнопка "отлипает"
 this.radio='1';
 Attribute= new Array();
 this.attributeSet = function (name, value) //добавляет дополнительные атрибуты в кнопку. вызвать ДО создания кнопки
  {
   Attribute.push(name+"~"+value)
  }
 this.CreateButton = function (container) 
  {
	this.a=document.createElement("a");
	this.a.className='tbutton';
	this.a.id=this.Id;
    for (var i = 0; i < Attribute.length; i++)
	 {
	  var m = Attribute[i].split('~');
	  eval("this.a."+m[0]+"='"+m[1]+"';");
	 }
	this.a.radio=this.radio;
    this.span=document.createElement("span");
	this.span.onselectstart=function(){event.returnValue=false;};
	this.span.innerHTML=this.Name;
	if(this.Action=='1')
	{
	 this.a.onmouseover=function()
	 {
		 if(this.className=="tbutton")
		 {
		 this.className="tabutton";
		 }
		 if(this.className=="tubutton")
		 {
		 this.className="tdbutton";
		 }

	 } 

	  if (this.Active=='1')
	   { 
	   this.a.onmouseout=function()
	 {
		 if(this.className=="tabutton")
		 {
			 this.className="tbutton";
		 }
		
		 if(this.className=="tdbutton")
		 {
		     this.className="tubutton";
	     }	 
	  } 
	  
	  this.a.onmouseup=function()
		  {  
			 if(navigator.appVersion.indexOf('MSIE')!=-1){var parent=this.parentElement;}else{var parent=this.parentNode;}			
			 if(this.radio==1){for(var i=0; i<parent.childNodes.length; i++){parent.childNodes[i].className='tbutton';}}
	         this.className="tdbutton";
		  }
	   }
	   else
	   {
	    this.a.onmouseout=function()
		 {
		 if(this.className=="tabutton")
		 {
		 this.className="tbutton";
		 }
		
		 if(this.className=="tdbutton")
		 {
		   this.className="tbutton";
	     }	
		 this.a.onmouseup=function()
		  {  
			 this.className="tabutton";
 	 	  }
	  } 
   }
	 this.a.onclick=this.onclick;
 	 this.a.onmousedown=function()
	 {  
		this.className="tdbutton";
	 };
   }
   this.a.appendChild(this.span);
   this.container.appendChild(this.a);
  }
 }


//--------------------------------------------кнопки для списков--------------

function buttonList(container){

 this.container=container;//место куда поместяться кнопки
 this.Name='';//название кнопки (отобразиться у пользователя) Любой хтмл код
 this.onclick="";//функция которая выполниться если кликнуть на кнопку
 this.Id='';//уникальный идентификатор. если он задан можно с кнопкой делать что угодно
 this.firstStat='1'; //статус загрузки кнопки 1. не активная не нажата. 2. активная не нажатая 3. активная нажатая. 4. не активная нажатая
 this.Action='1';// может ли вообще нажиматься и меняться
 this.Active='1'; //если 1 - кнопка залипает и так остается. если 0 кнопка "отлипает"
 this.radio='1';
 this.Attribute= new Array();
 this.Stat=new Array();
 this.Stat['1']='tbuttonBlack';
 this.Stat['2']='tabuttonBlack';
 this.Stat['3']='tdbuttonBlack';
 this.Stat['4']='tubuttonBlack';
 this.attributeSet = function (name, value) //добавляет дополнительные атрибуты в кнопку. вызвать ДО создания кнопки
  {
    this.Attribute.push(name+"~"+value)
  }
 this.CreateButton = function (container) 
  {

	this.a=document.createElement("a");
	this.a.className=this.Stat[this.firstStat];
this.a.setAttribute('stat1',  this.Stat['1']);
this.a.setAttribute('stat2',  this.Stat['2']);
this.a.setAttribute('stat3',  this.Stat['4']);
for (var i = 0; i < this.Attribute.length; i++)
	 {
	  var m = this.Attribute[i].split('~');
	  eval("this.a."+m[0]+"='"+m[1]+"';");
	 }
	this.a.radio=this.radio;
this.a.id=this.Id;
this.span=document.createElement("span");
this.span.innerHTML=this.Name;
	 this.a.unselectable="no";
	if(this.Action=='1')
	{
	 this.a.onmouseover=function()
	 {
		 if(this.className=="tbuttonBlack")
		 {
		 this.className="tabuttonBlack";
		 }
		 if(this.className=="tubuttonBlack")
		 {
		 this.className="tdbuttonBlack";
		 }
	 } 
	  if (this.Active=='1')
	   { 
	   this.a.onmouseout=function()
	 {
		 if(this.className=="tabuttonBlack")
		 {
			 this.className="tbuttonBlack";
		 }
		
		 if(this.className=="tdbuttonBlack")
		 {
		     this.className="tubuttonBlack";
	     }	 
	  } 

	  this.a.onmouseup=function()
		  {  
			if(navigator.appVersion.indexOf('MSIE')!=-1){var parent=this.parentElement;}else{var parent=this.parentNode;}			
			if(this.radio=='1'){
				for(var i=0; i<parent.childNodes.length; i++){parent.childNodes[i].className='tbuttonBlack';}
				this.className="tdbuttonBlack";
				}
			
		  }
	   }
	   else
	   {
	    this.a.onmouseout=function()
		 {
		 if(this.className=="tabuttonBlack")
		 {
		 this.className="tbuttonBlack";
		 }
		
		 if(this.className=="tdbuttonBlack")
		 {
		   this.className="tbuttonBlack";
	     }	
		 }	
		 this.a.onmouseup=function()
		  {  
    if(navigator.appVersion.indexOf('MSIE')!=-1){var parent=this.parentElement;}else{var parent=this.parentNode;}			
			 if(this.radio==1){for(var i=0; i<parent.childNodes.length; i++){parent.childNodes[i].className='tbuttonBlack';}}
			 this.className="tabuttonBlack";
 	 	  }
	   
   }
	 this.a.onclick=this.onclick;
 	this.a.onmousedown=function()
	 {  
			if(this.className=="tdbuttonBlack")
			{
			this.className="tabuttonBlack";
			}
			else
			{
			this.className="tdbuttonBlack";
			}
	 }
  }
   this.a.appendChild(this.span);
   this.span.onselectstart=function(){return false;}
//alert(D(this.container));
 this.container.appendChild(this.a);
  }
 }
//-------------------------------------------------------------------------------------------------
//--------------------------------------------кнопка ОК на рабочей панеле и переключатели режимов на верхней панели
function buttonOKBlack(container){
 this.container=container;//место куда поместяться кнопки
 this.Name='OK';//название кнопки (отобразиться у пользователя) Любой хтмл код
 this.onclick="";//функция которая выполниться если кликнуть на кнопку
 this.Id='';//уникальный идентификатор. если он задан можно с кнопкой делать что угодно
 this.Action='1';// может ли вообще нажиматься и меняться
 this.firstStat='1'; //статус загрузки кнопки 1. не активная не нажата. 2. активная не нажатая 3. активная нажатая. 4. не активная нажатая
 this.Active='0'; //если 1 - кнопка залипает и так остается. если 0 кнопка "отлипает"
 this.Stat=new Array();
 this.Stat['1']='buttonBlack';
 this.Stat['2']='abuttonBlack';
 this.Stat['3']='dbuttonBlack';
 this.Stat['4']='ubuttonBlack';
 Attribute= new Array();
 this.attributeSet = function (name, value) //добавляет дополнительные атрибуты в кнопку. вызвать ДО создания кнопки
  {
   Attribute.push(name+"~"+value)
  }
 this.CreateButton = function (container) 
  {
	this.a=container.ownerDocument.createElement("a");
	this.a.className=this.Stat[this.firstStat];
	this.a.id=this.Id;
    for (var i = 0; i < Attribute.length; i++)
	 {
	  var m = Attribute[i].split('~');
	  eval("this.a."+m[0]+"='"+m[1]+"';");
	 }
    this.span=container.ownerDocument.createElement("span");
	this.span.onselectstart=function(){event.returnValue=false;};
	if(this.Action=='1')
	{
	 
	 this.a.onmouseover=function()
	   {
		 if(this.className=="buttonBlack")
		  {
		   this.className="abuttonBlack";
		  }
		 if(this.className=="ubuttonBlack")
		  {
		   this.className="dbuttonBlack";
		  }
	   } 

	 if (this.Active=='1')
	   { 
	  
	   this.a.onmouseout=function()
	     {
		  if(this.className=="abuttonBlack")
		   {
			 this.className="buttonBlack";
		   }
		 if(this.className=="dbuttonBlack")
		   {
		    this.className="ubuttonBlack";
	       }	 
	     } 
	  
	  this.a.onmouseup=function()
		  {  
			 topPanel.resetModeButton();
	         this.className="dbuttonBlack";
		  }
	   
	   }else
	   {
	   
		this.a.onmouseout=function()
		 {
		 if(this.className=="abuttonBlack")
		   {
		   this.className="buttonBlack";
		   }
		 if(this.className=="dbuttonBlack")
		   {
		   this.className="buttonBlack";
	       }
		 }
 		 
		 this.a.onmouseup=function()
		  {  
			 this.className="abuttonBlack";
 	 	  }		
	   }
   
     this.a.onclick=this.onclick;
 	 this.a.onmousedown=function()
	 {  
		this.className="dbuttonBlack";
	 };
   }	
   this.a.appendChild(this.span);
   this.span.innerHTML=this.Name;
   this.span.onselectstart=function(){return false;}
   this.container.appendChild(this.a);
  }
 }
