/*global window, document, navigator*/
var flashinstalled = 0,
	flashversion = 0,
	MSDetect = "false";


function M(){
		var D = "undefined",
			S = "Shockwave Flash",
			W = "ShockwaveFlash.ShockwaveFlash",
			q = "application/x-shockwave-flash",
			R = "SWFObjectExprInst",
			x = "onreadystatechange",
			O = window,
			r = "object",
			aa = typeof document.getElementById != D && typeof document.getElementsByTagName != D && typeof document.createElement != D, 
			ah = navigator.userAgent.toLowerCase(), 
			Y = navigator.platform.toLowerCase(), 
			ae = Y ? /win/.test(Y) : /win/.test(ah), 
			ac = Y ? /mac/.test(Y) : /mac/.test(ah), 
			af = /webkit/.test(ah) ? parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, 
			X = !+"\v1", T,
			ag = [0, 0, 0], 
			ab = null;
		
        if (typeof navigator.plugins != D && typeof navigator.plugins[S] == r) {
            ab = navigator.plugins[S].description;
            if (ab && !(typeof navigator.mimeTypes != D && navigator.mimeTypes[q] && !navigator.mimeTypes[q].enabledPlugin)) {
                T = true;
                X = false;
                ab = ab.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
                ag[0] = parseInt(ab.replace(/^(.*)\..*$/, "$1"), 10);
                ag[1] = parseInt(ab.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
                ag[2] = /[a-zA-Z]/.test(ab) ? parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
            }
        }
        else {
            if (typeof O.ActiveXObject != D) {
                try {
                    var ad = new ActiveXObject(W);
                    if (ad) {
                        ab = ad.GetVariable("$version");
                        if (ab) {
                            X = true;
                            ab = ab.split(" ")[1].split(",");
                            ag = [parseInt(ab[0], 10), parseInt(ab[1], 10), parseInt(ab[2], 10)];
                        }
                    }
                } 
                catch (Z) {
                }
            }
        }
        return {
            pv: ag,
            ie: X
        }
    }
    function F(Z){	
        var Y = M().pv,
			X = Z.toString().split(".");
        X[0] = parseInt(X[0], 10);
        X[1] = parseInt(X[1], 10) || 0;
        X[2] = parseInt(X[2], 10) || 0;
        return (Y[0] > X[0] || (Y[0] == X[0] && Y[1] > X[1]) || (Y[0] == X[0] && Y[1] == X[1] && Y[2] >= X[2])) ? true : false;
    }

function insFl(v,fl,gif,lnk,w,h,flash_vars) {	
	var d=' width='+w+' height='+h,
		flash;
	if (F(v)) {
		flash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+d+'><param name="wmode" value="transparent"/><param name="movie" value="'+fl+'"/>';
		 if(flash_vars){
			flash += '<param name="flashvars" value="'+flash_vars+'"/>';
		 }
		flash += '<embed src="'+fl+'" quality=high'+d+' wmode="transparent"';
		if(flash_vars){
			flash += ' flashvars="'+flash_vars+'" ';
		}
		flash += '></embed></object>';
		
		document.write(flash);
	} else {	
		if (gif != '') {
			document.write('<a href='+lnk+'><img src='+gif+d+' border=0></a>')
		}
		else if(M().pv[0]>6){
			document.write("<div id='noFlash'></div>");
			var txt;
			if(M().ie){
				txt = '<object width="310" height="137" id="SWFObjectExprInst" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="flashvars" value="MMplayerType=ActiveX"/><param name="movie" value="/images/expressInstall.swf"/></object>';
			}else{
				txt = '<object width=300 height=120 type="application/x-shockwave-flash" data="/images/expressInstall.swf" id="SWFObjectExprInst"><param name="flashvars" value=""/></object>';
			}
				document.write(txt);
		}
		else{
			document.write(noFlash)
		}
	}
}

var swfobject = {
	expressInstallCallback: function(){
		document.getElementById("SWFObjectExprInst").parentNode.removeChild(document.getElementById("SWFObjectExprInst"));
		document.getElementById("noFlash").innerHTML = noFlash;
		}
	}

var noFlash = "<div style='text-align:center;padding:10px'><noindex><div style='width:400px;margin:0 auto;'><h2 style='text-decoration:none'><img width='16' height='16' alt='Внимание' src='/images/alert.gif'/> Внимание</h2><p>Чтобы посмотреть содержимое страницы, должен быть включен JavaScript, и установлена последняя версия Adobe Flash Player.</p><p class='caption'><a target='_blank' href='http://get.adobe.com/flashplayer/'>Скачать Flash Player!</a></p><a target='_blank' href='http://get.adobe.com/flashplayer/'><img  alt='Скачать Flash Player' src='/images/get_flash_player.gif'/></a></div></noindex></div>";

function ShowPhoto(url, width, height) {
	var scroll = (screen.width < 1000) ? "yes" : "no";
	
	var left = (self.screen.width >> 1) - (width >> 1);
	var top = (self.screen.height >> 1) - (height >> 1);
	var param = 'left='+left+',top='+top+',width='+width+',height='+height+',';
	
	window.open(url, '_blank', param+'menubar=no, scrollbars=' + scroll + ', status=no');
}

function emoticon(theSmilie)
{
	doInsert(" " + theSmilie + " ", "", false);
}

function doInsert(ibTag, ibClsTag, isSingle)
{
	var isClose = false;
	var obj_ta = document.post.message;
	
	//----------------------------------------
	// It's IE!
	//----------------------------------------
	if ( (ua_vers >= 4) && is_ie && is_win){
		if (obj_ta.isTextEdit){
			obj_ta.focus();
			var sel = document.selection;
			var rng = sel.createRange();
			rng.colapse;
			if((sel.type == "Text" || sel.type == "None") && rng != null){
				if(ibClsTag != "" && rng.text.length > 0)
					ibTag += rng.text + ibClsTag;
				else if(isSingle)
					isClose = true;
	
				rng.text = ibTag;
			}
		}
		else{
			if(isSingle){
				isClose = true;
			}			
			obj_ta.value += ibTag;
		}
	}
	//----------------------------------------
	// It's MOZZY!
	//----------------------------------------
	
	else if ( obj_ta.selectionEnd ){ 
		var ss = obj_ta.selectionStart,
			st = obj_ta.scrollTop,
			es = obj_ta.selectionEnd;
		
		if (es <= 2){
			es = obj_ta.textLength;
		}
		
		var start  = (obj_ta.value).substring(0, ss);
		var middle = (obj_ta.value).substring(ss, es);
		var end    = (obj_ta.value).substring(es, obj_ta.textLength);
		
		//-----------------------------------
		// text range?
		//-----------------------------------
		
		if (obj_ta.selectionEnd - obj_ta.selectionStart > 0){
			middle = ibTag + middle + ibClsTag;
		}
		else{
			middle = ibTag + middle;
			
			if (isSingle){
				isClose = true;
			}
		}
		
		obj_ta.value = start + middle + end;
		
		var cpos = ss + (middle.length);
		
		obj_ta.selectionStart = cpos;
		obj_ta.selectionEnd   = cpos;
		obj_ta.scrollTop      = st;
	}
	//----------------------------------------
	// It's CRAPPY!
	//----------------------------------------
	else{
		if (isSingle){
			isClose = true;
		}		
		obj_ta.value += ibTag;
	}
	
	obj_ta.focus();

	return isClose;
}	
function getBodyScrollTop() {
  return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function getlnsideWindowHeight() {
	if (window.innerHeight) {
		return window.innerHeight;
	} else {
		return document.body.parentElement.clientHeight;
	}
	return 0;
}

function ShowPhotoHere(url, alt, width, height) {
var fragment = document.createDocumentFragment(),
		scrolling = getBodyScrollTop(body),
		body = document.getElementsByTagName("body")[0],
	    over = document.createElement('div'),
		h,
		conteiner = document.createElement('div'),
		inside = document.createElement('div'),
		style,
		image = document.createElement('img'),
		descr = document.createElement('p'),
		close = document.createElement('input');
	
 	over.id = "over";
 	conteiner.id = "conteinerimg";
	inside.id = "inside"; 
	inside.style.width = width+"px";
	inside.style.height = height+"px";
	inside.style.margin = scrolling + getlnsideWindowHeight()/2 - height/2 + "px auto 0 auto";    
	
	h = document.getElementById("conteiner").offsetHeight;
	h = (scrolling + height>h)?(scrolling + height+ 20):h;
	over.style.height = h+30+"px";       
	
	image.width=width;
	image.height=height;
	image.title="Закрыть";
	image.src = "/"+url;
	
	descr.appendChild(document.createElement('span')).innerHTML = alt;
	
	close.id = "window-close";
	close.type = "button";
	close.title = "Закрыть";
	close.style.top = -height-10 +"px";
	close.style.right = -width-5 +"px";
	
	inside.appendChild(image);
	inside.appendChild(descr);
	
	inside.appendChild(close);
	
    conteiner.appendChild(inside);
	fragment.appendChild(over);
	fragment.appendChild(conteiner); 
	//////////////////////////////////////////
	image.onclick = function() {
		over.parentNode.removeChild(over);
		conteiner.parentNode.removeChild(conteiner);
	}
	close.onclick = function(){
		over.parentNode.removeChild(over);
		conteiner.parentNode.removeChild(conteiner);
	}
	
	body.appendChild(fragment);
}

function getBrowserInfo() {
	var t,v = undefined;
	if (window.opera) t = 'Opera';
	else if (document.all) {
		t = 'IE';
		var nv = navigator.appVersion;
		var s = nv.indexOf('MSIE')+5;
		v = nv.substring(s,s+1);
	}
	else if (navigator.appName) t = 'Netscape';
	return {type:t,version:v};
}
 
function bookmark(a){
	var url = window.document.location;
	var title = window.document.title;
	var b = getBrowserInfo();
	if (b.type == 'IE' && 8 > b.version && b.version >= 4) window.external.AddFavorite(url,title);
	else if (b.type == 'Opera') {
		a.href = url;
		a.rel = "sidebar";
		a.title = url+','+title;
		return true;
	}
	else if (b.type == "Netscape" && window.sidebar) window.sidebar.addPanel(title,url,"");
	else alert("Нажмите CTRL-D, чтобы добавить страницу в закладки.");
	return false;
}

var jsReady = false;
function isReady() {
 return jsReady;
}
function pageInit() {
 jsReady = true;
 document.forms["form1"].output.value += "\n" + "JavaScript is ready.\n";
}
function thisMovie(movieName) {
 if (navigator.appName.indexOf("Microsoft") != -1) {
     return window[movieName];
 } else {
     return document[movieName];
 }
}
function getXY(value) {
 document.getElementById("coords").value = value;
}

function getNoFlash(){
	if(!F("9.1.15")){
		document.getElementById("noflashhead").style.display = "block";
	}
}

function GetXmlHttpObject(){
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}
var semaphor = true;

function addCompare(node){
	var url = node.href + "&ajax";
	
	if(!semaphor)
	{
		return false;
	}
	semaphor = false;
	xmlHttp = GetXmlHttpObject(); 
	if (xmlHttp==null)  
	{
		return true;
	}
	xmlHttp.onreadystatechange = function()
	{
		 if (xmlHttp.readyState == 4) 
		 {
			semaphor = true;
			if(xmlHttp.responseText.substr(0,2)=='OK')
			{
				result = xmlHttp.responseText.split('#');
				node.parentNode.innerHTML = result[1];
				button = document.getElementById('CompareCount');
				if(button){
					if(button.tagName == 'INPUT'){
						text = button.value;
						pos = text.indexOf("(", 0);
						if(pos != -1){
							button.value = text.substr(0, pos) + "(" + result[2] + ")";
						}else{
							button.value = text + " (" + result[2] + ")";
						}
					}else{
						text = button.innerHTML;
						pos = text.indexOf("(", 0);
						if(pos != -1){
							button.innerHTML = text.substr(0, pos) + "(" + result[2] + ")";
						}else{
							button.innerHTML = text + " (" + result[2] + ")";
						}
					}
					button.className = button.className.replace(" disabled", "");
					button.className = (parseInt(result[2]) < 2) ? button.className + " disabled" : button.className.replace(" disabled", "");
					button.onclick = (parseInt(result[2]) < 2) ? function(){return false} : function(){return true} ;
				}
			}
			else
			{
				
			}
			return false;
		}
	};
	xmlHttp.open("GET", url, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=windows-1251'");
	xmlHttp.setRequestHeader("Cache-Control", " no-cache");
	xmlHttp.send();
	return false;
}

/**
 * Example: inputPlaceholder( document.getElementById('my_input_element') )
 * @param {Element} input
 * @param {String} color
 * @return {Element} input
 */
function inputPlaceholder (input, color) {

  if (!input) return null;

  /**
   * Webkit browsers already implemented placeholder attribute.
   * This function useless for them.
   */
  if (input.placeholder && 'placeholder' in document.createElement(input.tagName)) return input;

  var placeholder_color = color || '#AAA';
  var default_color = input.style.color;
  var placeholder = input.getAttribute('placeholder');

  if (input.value === '' || input.value == placeholder) {
    input.value = placeholder;
    input.style.color = placeholder_color;
    input.type = "text";
  }

  var add_event = /*@cc_on'attachEvent'||@*/'addEventListener';

  input[add_event](/*@cc_on'on'+@*/'focus', function(){
    input.style.color = default_color;
    if (input.value == placeholder) {
      input.value = '';
      input.type = "text";
    }
    if(input.name.match("pass")) {
        input.type = "password";
    }
  }, false);

  input[add_event](/*@cc_on'on'+@*/'blur', function(){
    if (input.value === '') {
      input.value = placeholder;
      input.style.color = placeholder_color;
      input.type = "text";
    } else {
      input.style.color = default_color;
    }
  }, false);

  input.form && input.form[add_event](/*@cc_on'on'+@*/'submit', function(){
    if (input.value == placeholder) {
      input.value = '';
    }
  }, false);

  return input;
}





function addEvent(el, event, func){
	if(el.addEventListener)
		el.addEventListener(event,func,false);
	else
		el.attachEvent("on"+event, func)
}


/**
 * 
 * @param {Object} id 		Id реального комбобокса
 * @param {Object} opts		опции
 * 
 * 		Варианты опций:
 * 		"hover" : true - открытие при наведении
 * 		"input" : true - с текстовым полем, авто-подстановкой
 * 		
 * 		Поддерживаемые события: 
 * 		- onMouseOver
 * 		- onMouseOut
 * 		- onFocus
 * 		- onOpen
 * 		- onClose
 * 		- onChange
 * 
 * 		Запись обработчиков событий в опции:
 * 		"onFocus" : testFocus		(testFocus - внешняя функция)
 * 		"onMouseOver" : function
 * 		
 * 		
 */
function mySelect(id, opts){
	
		var nums,					///кол-во видимых эл-тов списка
		actElements = [],		///массив видимых эл-тов 
		actIndex = -1,			///индекс выбранного эл-та списка
		num,
		actLi = null;
	
		var instance = this;
		var select = document.getElementById(id);
		if(!select)
			return;
		var data = select.children;  
		var myList = [];
		
		if(!opts)
			this.opts = {"click":true};
		else
			this.opts = opts;
		
		this.opened = false;
		
		var myselect = document.createElement("div");
		
		myselect.id = id+"_alko";
		myselect.className = "mySelect";
		var but = document.createElement("div");		
		var list =  document.createElement("ul");
		
		var text;
		if (this.opts.input) {
			text = document.createElement("input");
			text.type = "text";
		}
		else 
			text = document.createElement("div");
		

		
		this.init = function(){	    
				myselect.style.width = select.offsetWidth+"px";				
				list.style.width = select.offsetWidth+"px";
			  //	myselect.style.height = select.offsetHeight+"px";
				myselect.style.overflow = "visible";
				myselect.style.position = "relative";
								
				but.className = "mySelectBut";
				
				this.setOptions();
				
				text.className = "mySelectText";
				

				myselect.appendChild(text);
				
				list.className = "mySelectList";				
				myselect.appendChild(instance.getList(list));
				
				actElements = myList;
				
				select.parentNode.insertBefore( myselect, select.nextSibling );
				select.style.display = "none";
				

				addEvent(myselect, "mouseover", 	instance.onMouseOver);	
				addEvent(myselect, "mouseout", instance.onMouseOut);
				
				if (this.opts.input) 
	 				addEvent(text, "focus", instance.onFocus);
				
				text.style.color = (select.value && select.value != 0) ? "black" : "gray";
		}
		/**
		 * Перевод value значения в соотв innerHTML значение
		 * @param {Object} val
		 */	
		this.getTextValue = function(val){
				for(var i=0; i<data.length; i++){
						if (val == data[i].value) {
							if(data[i].innerHTML=="&nbsp;")
								return "";
							else
								return data[i].innerHTML;
						}
				}
		}
		/**
		 * Поиск innerHTML по номеру в списке
		 * @param {Object} index
		 */
		this.getIndexTextValue = function(index){
				if(data[index].innerHTML=="&nbsp;")
					return "";
				else
					return data[index].innerHTML;
		}
		
		/**
		 * Перевод innerHTML значения в соотв value значение
		 * @param {Object} val
		 */
		this.getValue = function(val){
				if(val=="")
					val="&nbsp;";
				for(var i=0; i<data.length; i++){
						if(val==data[i].innerHTML)
							return data[i].value
				}
		}
		
		/**
		 * Создание списка из значений реального комбо
		 * @param {Object} ul
		 */
		this.getList = function(ul, arr){
				if(!arr)
					arr = data;

				var parents = [];
				var parent;
			   
				for(var i=0; i<arr.length; i++){           			   
						var li = document.createElement("li");
						
						if(arr[i].tagName == "OPTION"){ 
							li.innerHTML = arr[i].innerHTML;
							this.initLi(li, arr[i].value);
						}
						else {         //log(arr[i].label)  							
							
							var span = document.createElement("span");
							span.className = "optLi";
							span.innerHTML = arr[i].label;
							li.appendChild(span)
							
						 	if(arr[i].children.length > 0){
								var subUl = document.createElement("ul");
								li.appendChild(instance.getList(subUl, arr[i].children)); 
							}    
						   //	log(parseInt(arr[i].getAttribute("rel")));
						   	if(arr[i].getAttribute("rel")!=null && parseInt(arr[i].getAttribute("rel"))>0){ 
						   		var subGroup = document.createElement("ul");
								subGroup.appendChild(li)
								//log(parent.innerHTML+" "+ li.innerHTML) 
							   	parents[parseInt(arr[i].getAttribute("rel")) - 1].appendChild(subGroup);
								parents[parseInt(arr[i].getAttribute("rel"))] = li;
								continue;
							}                    
						}
						parents[0] = li;
						ul.appendChild(li)
						
				}	
				return ul;			
		}
		
		/**
		 * Инит элементов списка
		 * @param {Object} li
		 * @param {Object} val текущее значение реального комбо
		 */
		this.initLi = function(li, val){
				li.setAttribute("rel", val);        	
				addEvent(li, "mouseover", function(){if(li.className!="actS")li.className += " hoverLi"})
				addEvent(li, "mouseout", function(){if(li.className!="actS")li.className=li.className.replace(new RegExp(" hoverLi\\b"), "");})
			  //	addEvent(li, "mouseout", function(){if(li.className!="actS")li.className = ""})
				addEvent(li, "click", function(){instance.setValue(li)})
				myList.push(li);				
				
				//alert(li.innerHTML) 
				if(val == select.value){
				   	li.className = "actS";
					
					if (this.opts.input) {
						if(li.innerHTML=="&nbsp;")
							text.value = "";
						else
							text.value = li.innerHTML;
					}else 
						text.innerHTML = li.innerHTML;  
						                
						
				}			
		}
		
		/**
		 * Установка значения списка в реальный комбобокс
		 * @param {Object} li
		 */
		this.setValue = function(li){	
				actLi = li;
				if (this.opts.input) {
					if(li.innerHTML=="&nbsp;")
						text.value = "";
					else
						text.value = li.innerHTML;
				}
				else 
					text.innerHTML = li.innerHTML;       
					
				//select.value = this.getValue(li.innerHTML)
				select.value = li.getAttribute("rel");
				text.style.backgroundColor = "white";
				text.style.color = (select.value && select.value != 0) ? "black" : "gray";
				this.onChange();
		}
		
		/**
		 * Установка опциональных свойств
		 */
		this.setOptions = function(){	
		
				addEvent(document, "click", instance.close);		
		
				if (!this.opts.hover && !this.opts.input) {				
					addEvent(myselect, "click", instance.open);
					text.innerHTML = instance.getTextValue(select.value);
					myselect.appendChild(but);
					this.setWidthText();
					return;
				}
				
				if(this.opts.hover){
						addEvent(myselect, "mouseover", 	instance.open);	
						addEvent(myselect, "mouseout", instance.close);			
						text.innerHTML = instance.getTextValue(select.value);
				}
				if(this.opts.input){
						addEvent(but, "click", instance.open);
						addEvent(text, "click", 	instance.open);		
						text.onkeyup = this.reloadList;
						text.onkeydown = this.keys;
						text.value = instance.getTextValue(select.value);
						myselect.appendChild(but);
						this.setWidthText();
				}
				
		}
		
		/**
		 * Установка длины текстового поля
		 */
		this.setWidthText = function(){				
				if(this.opts.input)
					text.style.width = 220 + "px";
				else
					text.style.width = 200 + "px";
		}
		
		/**
		 * Открытие списка
		 */
		this.open = function(){
				if (!instance.opened) {
					list.style.display = "block";
					myselect.style.zIndex = 1000;
					setTimeout(function(){instance.opened = true}, 100);
					if(actLi!==null){
						actLi.className = "actS";
					}
					instance.onOpen();
				}		
		}
		
		/**
		 * Закрытие списка
		 */
		this.close = function(){
				if (instance.opened) {
					list.style.display = "none";
					myselect.style.zIndex = 1;
					instance.opened = false;
					actElements = myList;
					for(i=0; i<myList.length; i++){
						myList[i].className = '';
					}
					instance.onClose();
				}		
		}
	/**
	 * Обновление списка при ручном вводе
	 * @param {Object} e
	 */				
	this.reloadList = function(e){
		var key = null,
			i,reg;
		try { 
			key = e.keyCode;
			}
		catch(err){
			key = window.event.keyCode;
		}
		if(key==8 || (key>44 && key<91) || (key>95 && key<112)/* key!=40 && key!=38 && key!=13*/){	
			actIndex = -1;
			instance.nums = myList.length-1;
			actElements = [];//.length = 0;			
			
			reg = new RegExp("^ ?"+text.value,"i");
			for (i=0; i<myList.length; i++){
				if(text.value!='' && !reg.test(myList[i].innerHTML)){	
					myList[i].style.display = "none";
					instance.nums--;

				}else if(text.value!='') {
					instance.nums++;
					myList[i].style.display = "block";
				}else{
					instance.nums++;				
					myList[i].style.display = "block";
				}
				if (myList[i].style.display == "block") {
					actElements.push(myList[i]);
				}
			}	
			if(instance.nums>0){				
				text.style.backgroundColor = "white";
				text.style.color = "black";
				instance.open();
			}
			else{	
				text.style.backgroundColor = "red";
				text.style.color = "white";
				for(k=0; k<myList.length; k++){
	                myList[k].style.display = "block";
				}
				instance.open();
			}	
		}
	};
	/**
	 * Обработка ввода с клавиатуры
	 * @param {Object} e
	 */
	this.keys = function(e){ 
		var key = null, i, k;       
		try { 
			key = e.keyCode;
		}
		catch(err){
			key = window.event.keyCode;
		}
		for(i=0; i<actElements.length; i++){
			actElements[i].className="";
		}
		if(key==40){
			if (actIndex < actElements.length - 1) {
				actIndex++;
			}	
			if (actElements[actIndex] !== null) {
				actElements[actIndex].className = "actS";
			}	
		}
		else if(key==38){
			if (actIndex > 0) {
				actIndex--;
			}	
			if (actElements[actIndex] !== null) {
				actElements[actIndex].className = "actS";
			}
		}
		if(actIndex>=0){
			text.value = instance.getIndexTextValue(actIndex)//actElements[actIndex].innerHTML;
			select.value = instance.getValue(text.value)
		}
		if((key==13 || key==9) && text.value!='' && instance.opened && actIndex>=0){        
			                           
			text.value = instance.getIndexTextValue(actIndex)//actElements[actIndex].innerHTML; 
			text.focus();
			select.value = instance.getValue(text.value)
			actLi = actElements[actIndex];
			instance.close();
			for(k=0; k<myList.length; k++){
                myList[k].style.display = "block";
			}
			return false;
		}		
	};	
		
		
		
		
		
		this.onMouseOver = function(){
			if(instance.opts.onMouseOver)
				instance.opts.onMouseOver();
		}
		this.onMouseOut = function(){
			if(instance.opts.onMouseOut)
				instance.opts.onMouseOut();
		}
		this.onFocus = function(){
			if(instance.opts.onFocus)
				instance.opts.onFocus();
		}
		this.onOpen = function(){
			if(instance.opts.onOpen)
				instance.opts.onOpen()
		}
		this.onClose = function(){
			if(instance.opts.onClose)
				instance.opts.onClose()
		}
		this.onChange = function(){
			if(instance.opts.onChange)
				instance.opts.onChange(instance);
		}
	
		
		instance.init();
}



