/* отображает список трекеров*/
function Vtraklist(){
 this.type='chois'; //chois выбор одного варианта, multi выбор нескольких вариантов, filter - формирование фильтра 
 this.chois; //переменная в которой храниться выбор пользователя
 this.multi = new Array; //массив в котором храниться выбор пользователя 
 this.filter = new XMLDocument; //в этой переменной должен быть сфомирован xml документ фильтра 
 this.width='90%';
 this.height='100px';
 this.forxmlMenu = new XMLDocument; //а тут будет храниться то что потом в xml документ вставиться
 
 this.t=top.xmlTrakFilter.XMLDocument.documentElement.childNodes;		
 this.traks = new XMLDocument; // xml- список трекеров

 if(isFF){
  this.aColor="background:rgb(0,255,255); color: rgb(0,0,0); cursor:pointer;";
  this.Color="background:rgb(0,0,0);  color: #00FFFF; cursor:pointer;";
  }else{
  this.aColor="background:#00FFFF;  color: #000000; cursor:pointer;";
  this.Color="background:#000000; color: #00FFFF; cursor:pointer;";  
  }
 this.xmlIsLoad=function(){
  	this.box=this.forxmlMenu.XMLDocument.createElement('div'); 
  	this.box.setAttribute("style", "overflow:auto; cursor:pointer; height: "+this.height+"; top: 0px; position: relative; width:"+this.width+";");
  	this.table=this.forxmlMenu.XMLDocument.createElement('table');
		 this.table.setAttribute("cellpadding", "2");
		 this.table.setAttribute("cellspacing", "1");
		 this.table.setAttribute("align", "center");
		 this.table.setAttribute("valign", "top");
		 this.table.setAttribute("id", "TrackListTable");
//--------------свойство выбрать все, убрать все		 
		 if((this.type=='multi')||(this.type=='filter')){
		  this.tr=this.forxmlMenu.XMLDocument.createElement('tr');
		  this.td=this.forxmlMenu.XMLDocument.createElement('td');
		  this.td.setAttribute("align", "center");
		  this.td.setAttribute("colspan", "2");
		  this.slectall=this.forxmlMenu.XMLDocument.createElement('div'); 
		  this.slectall.setAttribute("onclick", "selectAll()");  		
		  this.slectall.setAttribute("style", this.Color);  		
		  this.slectall.setAttribute("id", 'selectallid');  		
		  this.slectall.setAttribute("height", '10px');  		
  		if(this.t.length!=1&this.t[0].getAttribute('id')!=''){var text=getWordLang('selectall');}else{var text=getWordLang('hideall');};
  		this.b=this.forxmlMenu.XMLDocument.createElement('b');
  		if(isFF==1){this.slectall.textContent=text;}else{this.slectall.text=text;}	
  		
  		//this.forxmlMenu.XMLDocument.documentElement.appendChild(this.slectall);	
  		this.td.appendChild(this.slectall);	
  		this.tr.appendChild(this.td);	
  		this.table.appendChild(this.tr);	
  		  		
		 }
		 this.trak=this.traks.XMLDocument.documentElement.getElementsByTagName('trak');	 
		 for(i=0; i<this.trak.length; i++){
		  this.tr=this.forxmlMenu.XMLDocument.createElement('tr');
		  this.td=this.forxmlMenu.XMLDocument.createElement('td');
		  this.td2=this.forxmlMenu.XMLDocument.createElement('td');
    this.td.setAttribute("align", "right");
		  this.td2.setAttribute("align", "left");
		  this.tr.setAttribute("id", this.trak[i].getAttribute('IMEI'));
    this.tr.setAttribute("active", 1);
		  if(this.type=='filter'){
   
 		  for(f=0; f<this.t.length; f++){
 		  // alert(this.t[f].getAttribute('id')+this.trak[i].getAttribute('IMEI'))
 		   if(this.t[f].getAttribute('id')==this.trak[i].getAttribute('IMEI')){
 		   this.tr.setAttribute("active", 0);
 		   }		 
     }
   
    }
    if(this.type=='chois'){
		  if(this.chois!=this.trak[i].getAttribute('IMEI')){
		   this.tr.setAttribute("active", 0);
		  } 
    }    
    this.img=this.forxmlMenu.XMLDocument.createElement('img');
		  this.img.setAttribute("src", this.trak[i].getAttribute('pointer'));
		  this.img.setAttribute("height", "15px");
		  this.td.appendChild(this.img);
		  this.b=xmlMenu.XMLDocument.createElement('b');		
		  if(isFF==1){this.b.textContent=this.trak[i].getAttribute('name');}else{this.b.text=this.trak[i].getAttribute('name');}
		  this.td2.appendChild(this.b);
		 //   alert(this.tr.getAttribute('active'));
		  if(this.tr.getAttribute('active')==1){
		   this.td.setAttribute("style", this.aColor);	
		   this.td2.setAttribute("style", this.aColor);	
		  }else{
		   this.td.setAttribute("style", this.Color);	
		   this.td2.setAttribute("style", this.Color);	
		  }
		  this.tr.setAttribute("onclick", "ontrackclick(this);");
		  this.tr.setAttribute("type", this.type);
		  this.tr.appendChild(this.td);
		  this.tr.appendChild(this.td2);
		  this.table.appendChild(this.tr);		  
		 }
		 this.box.appendChild(this.table);		 
		// alert(D(this.forxmlMenu.XMLDocument.documentElement));
			this.forxmlMenu.XMLDocument.documentElement.appendChild(this.box);				
 }
}

function selectAll(){
 var t=top.xmlTrakFilter.XMLDocument.documentElement.childNodes;	
 obj=e('TrackListTable');
//alert(t.length);
 if(obj.childNodes[0].childNodes[1].getAttribute('type')=='filter'){
 	if(t.length!=1&t[0].getAttribute('id')!=''){	 	
 	 for(var i=1; i<obj.childNodes[0].childNodes.length; i++){
 			if(obj.childNodes[0].childNodes[i].getAttribute('active')==0){
 				ontrackclick(obj.childNodes[0].childNodes[i]);
 			}
 		}
 	}else{
 	 
 		for(i=1; i<obj.childNodes[0].childNodes.length; i++){	
 		if(obj.childNodes[0].childNodes[i].getAttribute('active')==1){
 				ontrackclick(obj.childNodes[0].childNodes[i]);
 			}
 		}
 	}
 }else if(obj.childNodes[0].childNodes[1].getAttribute('type')=='multi'){  
  for(i=1; i<obj.childNodes[0].childNodes.length; i++){	
 		if(e('selectallid').innerHTML==getWordLang('selectall')){
   if(obj.childNodes[0].childNodes[i].getAttribute('active')==0){
 	 ontrackclick(obj.childNodes[0].childNodes[i]);
 			}
 		}else{
 		 if(obj.childNodes[0].childNodes[i].getAttribute('active')==1){
 	 ontrackclick(obj.childNodes[0].childNodes[i]);
 			} 		 
 		}
	 }
  if(e('selectallid').innerHTML==getWordLang('selectall')){
 	 e('selectallid').innerHTML=getWordLang('hideall'); 
 	}else{
 	 e('selectallid').innerHTML=getWordLang('selectall');
 	}
 }
}


function ontrackclick(track){
if(isFF){
 var parentTrack=track.parentNode;
 var color="rgb(0,0,0)";
 var acolor="rgb(0,255,255)";
}else{
 var parentTrack=track.parentElement;
 var color="#000000";
 var acolor="#00FFFF";
}
 //alert('nen');
if(track.getAttribute('type')=='filter'){
 if(track.getAttribute("active")=='1'){
 	track.childNodes[0].style.backgroundColor=color;	
 	track.childNodes[1].style.backgroundColor=color;	
 	track.childNodes[1].style.color=acolor;	
 	newFilt=xmlTrakFilter.XMLDocument.documentElement.firstChild.cloneNode(true);
 	newFilt.setAttribute('id', track.id);
 	newFilt.setAttribute('IMEI', track.id);
 	newFilt.setAttribute('show', '0');		
 	xmlTrakFilter.XMLDocument.documentElement.appendChild(newFilt); 	
 	track.setAttribute("active", '0');	
  if(e('selectallid')){e('selectallid').innerHTML=getWordLang('selectall');}
 }else{	
 	track.childNodes[0].style.backgroundColor=acolor;	
 	track.childNodes[1].style.backgroundColor=acolor;
 	track.childNodes[1].style.color=color;			
 	track.setAttribute("active", '1');
 	var t=xmlTrakFilter.XMLDocument.documentElement.childNodes;
 	for(i=0; i<t.length; i++){			
 	  if(t[i].getAttribute('id')==track.id){
 	   	
 	    xmlTrakFilter.XMLDocument.documentElement.removeChild(t[i]);
 	   
 	    if(xmlTrakFilter.XMLDocument.documentElement.childNodes.length=='1'){			
 	      if(e('selectallid')){e('selectallid').innerHTML=getWordLang('hideall');	}	
 	   	} 		
 	  }
 	}
 }
}else if(track.getAttribute('type')=='chois') {
 	idselectTrack=track.id;
 	for(var i=0;  i<parentTrack.childNodes.length;i++){		
 		if(parentTrack.childNodes[i].id!=track.id){
   	parentTrack.childNodes[i].setAttribute("active", '0'); 			
 			parentTrack.childNodes[i].childNodes[0].style.backgroundColor=color;
 			parentTrack.childNodes[i].childNodes[1].style.backgroundColor=color;
 			parentTrack.childNodes[i].childNodes[1].style.color=acolor;
 		}else{
 		 parentTrack.childNodes[i].setAttribute("active", '1'); 			
 			parentTrack.childNodes[i].childNodes[0].style.backgroundColor=acolor;
 			parentTrack.childNodes[i].childNodes[1].style.backgroundColor=acolor;
 			parentTrack.childNodes[i].childNodes[1].style.color=color;
 		}		
 	}  
 }else if(track.getAttribute('type')=='multi'){
  if(track.getAttribute("active")=='1'){
 	track.childNodes[0].style.backgroundColor=color;	
 	track.childNodes[1].style.backgroundColor=color;	
 	track.childNodes[1].style.color=acolor;	
  track.setAttribute("active", '0');	
  }else{	
 	track.childNodes[0].style.backgroundColor=acolor;	
 	track.childNodes[1].style.backgroundColor=acolor;
 	track.childNodes[1].style.color=color;			
 	track.setAttribute("active", '1');
  }
 }
}