﻿// id - id Контейнера div
// arrName - массив имен (список)
// globalName - глобальное имя эксепляра класса
// funcSelect - в какую функцию возвращать событие selected
function dropBox(id,arrName,globalName,funcSelect){
	this.intervalobj;
	this.isshow=false;
	this.cnt=arrName.length;
	this.dropid=id+'_drop';
	this.dropelid=id+'_drop_el_';
	this.showelid=id+'_show_el_';
	this.generateHTML=function(){
		var s='';
		for (var i=0;i<this.cnt;i++){
			s+='<a href="#" id="'+this.showelid+i+'" onclick="'+globalName+'.show();return false;" style="display:';
			if (i==0)s+='block;">';
			else s+='none;">';
			s+='<table cellspacing="0" cellpadding="0" width="100%"><tr><td align="left">'
			s+=arrName[i]+'</td><td align="right"><img style="margin: 3px 7px 0 5px;"src="/img/design/icon_arrow_down.png"/></td></tr></table></a>';
		}
		s+='';
		
		s+='<div class="el_dropbox" id="'+this.dropid+'">';
		for (var i=0;i<this.cnt;i++)s+='<a href="#" id="'+this.dropelid+i+'" onclick="'+globalName+'.select(\''+i+'\');'+funcSelect+'('+i+');return false;">'+arrName[i]+'</a>';
		s+='</div>';
		$('#'+id).html(s);
	};
	this.init=function(){
		this.generateHTML();
	};
	this.show=function(){
		if(this.isshow){
			$('#'+this.dropid).hide();
			this.isshow=false;
		}else{
			$('#'+this.dropid).show();
			this.isshow=true;
		}
	};
	this.hide=function(){
		$('#'+this.dropid).hide();
	};
	this.select=function(i){
		for(var j=0;j<this.cnt;j++){
			if (j==i) $('#'+this.showelid+j).css('display','block');
			else $('#'+this.showelid+j).css('display','none');
		}
		this.show();
	};
	this.init();
}

function popUpTip(id,text){
	this.isshow=false;
	this.init=function(){
		this.generateHTML();
	};
	this.show=function(){
		if(this.isshow){
			$('#'+id).hide('slow');
			this.isshow=false;
		}else{
			$('#'+id).show('slow');
			this.isshow=true;
		}
	};
	this.generateHTML=function(){
		var s='<div class="el_topuptip">'+text+'</div>';
		$('#'+id).html(s);
	};
	this.init();
}
