var urlStart = window.location.protocol+'//'+window.location.hostname+'/';

function confirm_delete(url, message){
	if(confirm(message)){
		document.location.href=url;
	}
}

function openw(theURL,winName,features) {
	if (features == "") features = "width=500,height=500,scrollbars,resizable";
	window.open(theURL,winName,features);
}

//In case browser does nt support 'getElementById'
if(!document.getElementById && document.all){
	document.getElementById=function(id){
		return document.all[id];
	}
}

function toggleElement(strElement, blnVisible) {
	var objStyle = document.getElementById(strElement).style;
	if (objStyle) {
		objStyle.display = (blnVisible == 1) ? 'block' : 'none';
	}
}
///////////////////////////////////////////
//Programmer convinience functions

//Shortcut to document.getElementById
function el(id){
	return document.getElementById(id);
}

//Toggle visibility
function toggle(o){
	obj = el(o);
	obj.style.display = obj.style.display == 'none' ? 'block' : 'none';
}
function toggleInline(o){
	obj = el(o);
	if(!obj) return;
	obj.style.display = obj.style.display == 'none' ? 'inline' : 'none';
}

function show(obj){
	if(!el(obj)) return;
	el(obj).style.display = 'block';
}
function hide(obj){
	if(!el(obj)) return;
	el(obj).style.display = 'none';
}
function showHide(obj1,obj2){
	if(!el(obj1) || !el(obj2)) return;
	el(obj1).style.display = 'block';
	el(obj2).style.display = 'none';
}
function inline(obj){
	if(!el(obj)) return;
	el(obj).style.display = "inline";
}

//To see if given value exists in array (like in PHP)
function inArray(value, array){
	if(typeof(array) != 'object') return false;
	for(var i=0;i<array.length;i++){
		if(array[i]	== value) return true;
	}
	return false;
}

function getBrowser() {
	var sBrowser = navigator.userAgent;
	if (sBrowser.toLowerCase().indexOf('msie') > -1) return 'ie';
	if (sBrowser.toLowerCase().indexOf('firefox') > -1) return 'firefox';
	if (sBrowser.toLowerCase().indexOf('opera') > -1) return 'opera';
	if (sBrowser.toLowerCase().indexOf('safari') > -1) return 'safari';
	if (sBrowser.toLowerCase().indexOf('chrome') > -1) return 'chrome';
  	return 'other';
}

function strReplace(inputString, fromString, toString) {
   // Goes through the inputString and replaces every occurrence of fromString with toString
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
}

function substrReplace(string, replacement, start, length){
	if(!length) length = string.length;
	var end = length-start;
	var fp = string.substr(0,start);
	var sp = string.substr(start,end);	
	return fp+replacement+sp;
}

///////////////////////////////////////////

function confirm_loc(url,msg){
	if(confirm(msg)) window.location.href = url;
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}

//IE is stupid
Array.prototype.remove = function(s, dC) {
	for(var i = 0, n = this.length; i < dC; ++i) {
		this[s + i] = this[s + i + dC];
	}
	this.length = n - dC;
};

function createNode(id, tag, attributes){
	var newnode = document.createElement(tag);
	for (var i in attributes){
		if(i == 'innerHTML'){
			newnode.innerHTML = attributes[i];
		}else if(i == 'value'){
			newnode.value = attributes[i];
		} else {
			newnode.setAttribute(i, attributes[i]);
		}
	}
	el(id).appendChild(newnode);	
}

function addZero(num){
	if(num.toString().length == 1) return "0"+num;
	return num;
}
function remZero(num){
	if(num.toString().substr(0,1) == '0') return num.substr(1);
	return num;
}

function preloadImages() { //v3.0
	var d = document; 
	if(d.images){ 
  		if(!d.p) d.p=new Array();
    	var i, j = d.p.length, a = preloadImages.arguments; 
		for(i = 0; i < a.length; i++){
			if (a[i].indexOf("#")!=0){ 
				d.p[j]=new Image; 
				d.p[j++].src=a[i];
			}
		}
	}
}

function getDocumentHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

function getElementHeight(elm){
	var docHt = 0, sh, oh;
	if(elm.clientHeight) docHt = elm.clientHeight;
	else {
    	if (elm.scrollHeight) docHt = sh = elm.scrollHeight;
	    if (elm.offsetHeight) docHt = oh = elm.offsetHeight;
    	if (sh && oh) docHt = Math.max(sh, oh);
	}
	return docHt;
}

	
///////////////////
var regemail = /^[+]?[_a-z0-9-]+(\.[_a-z0-9-]+)*@([0-9a-z][0-9a-z-]*\.)+[a-z]{2,4}$/i;
var regphone = /^[+ 0-9]+$/;
//var regzip = /^[LTlt 0-9-]+$/;
var regzip = /^[A-Za-z 0-9-]+$/;
var regnum = /^[0-9]{1,2}$/;
var regpernr = /^[0-9]+$/;

function Is() {
  var agt=navigator.userAgent.toLowerCase();
  this.ie=((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1))?1:0;
  this.dom=el?1:0;
  this.ie4=(document.all && !this.dom)?1:0;
  this.ns4=(document.layers && !this.dom)?1:0;
  return this;
}
var is=new Is();
if(is.ns4) {
	var regSurnames = /^[ ]*[a-z]+[ ]*[a-z]+[ a-z]*$/i;
	var regNames = /^[ ]*[a-z]+[ a-z]*$/i;                             
	var regInfSurnames = /^[ ]*[a-z]{2,}[ ]*$/i;
	var regInfNames = /^[ ]*[a-z]{1,}[ ]*$/i;
	var regContact = /^[ ]*[a-z0-9,.:_"\'()&#*+\/-]+[ a-z0-9,.:_"\'()&#*+\/-]*$/i;
} else {
	var charAllowed = ',ąčęėįšųūžĄČĘĖĮŠŲŪŽ';
	var regSurnames = new RegExp("^[ ]*[a-z" + charAllowed + "]+[ ]*[a-z" + charAllowed + "]+[ a-z" + charAllowed + "]*$", "i");
	var regNames = new RegExp("^[ ]*[a-z" + charAllowed + "]+[ a-z" + charAllowed + "]*$", "i");
	var regInfSurnames = new RegExp("^[ ]*[a-z" + charAllowed + "]{2,}[ ]*$", "i");
	var regInfNames = new RegExp("^[ ]*[a-z" + charAllowed + "]{1,}[ ]*", "i");
	var regContact = new RegExp("^[ ]*[a-z" + charAllowed + "0-9,.:_\"'()&#\/*+-]+[ a-z" + charAllowed + "0-9,.:_\"'()&#\/*+-]*$", "i");
}

function emailcheck(str) {
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str)) return true;
	else return false;
}

////////////////////////////////////////////////////////////////
function LAT(s) {
    for (i=0; i<s.length; i++) {
        if (((s.charAt(i)<'a') || (s.charAt(i)>'z')) && ((s.charAt(i)<'A') || (s.charAt(i)>'Z')) && (s.charAt(i) != '-'))
            return false
    }
    return true;
}
function ReplaceChar(s1,tt){
    s2 ="";
    for (i=0; i<s1.length; i++) {
        if (((s1.charAt(i)<'a') || (s1.charAt(i)>'z')) && ((s1.charAt(i)<'A') || (s1.charAt(i)>'Z')) && ((s1.charAt(i)<'0') || (s1.charAt(i)>'9')))
            s2=s2+"_";
        else
            s2=s2+s1.charAt(i);
    }
    eval(tt+" = '" + s2 + "'");
}
function Translate(s1,tt) {
	var charcode;
    EnglishEquivalent1 = new Array('A','A','','','S','S','','','C','C','','','','','U','U','','','E','E','E','E','U','U','','','','','','','','','','Z','Z','','','','I','I','','','I','I','','','','','','','','','','','','','I','','','', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');
    EnglishEquivalent2 = new Array('A','A','','','S','S','','','C','C','','','','','E','E','','','E','E','E','E','U','U','','','','','','','G','G','','Z','Z','35','36','37','I','I','','','I','I','','','','','','','K','K','','','','I','I','','','', '', '', '', '', '', 'N', 'N', '', '', '', '', '');
    EnglishEquivalent_ru = new Array('A','B','V','G','D','E','ZH','Z','I','J','K','L','M','N','O','P','R','S','T','U','F','H','C','SH','SHT','CH','','','J','Z','JU','JA','','','');
    
    s2 ='';
    for (j=0; j<s1.length; j++) {
    	//s1 = s1.toUpperCase();
    	charcode = s1.charCodeAt(j);
    	//alert(s1[j] + ' ' + s1.charCodeAt(j) + '[' + ((s1.charCodeAt(j)>350)?(s1.charCodeAt(j) - 348):(s1.charCodeAt(j) - 260)) + ']');
        if ((s1.charCodeAt(j)>259) && (s1.charCodeAt(j)<383))
            if (s1.charCodeAt(j)>350) {
            	s2 = s2 + EnglishEquivalent1[(s1.charCodeAt(j) - 348)];
            }
            else {
            	s2 = s2 + EnglishEquivalent2[(s1.charCodeAt(j) - 260)];
            }
        else
			if ((s1.charCodeAt(j)>1039) && (s1.charCodeAt(j)<1104)) {
           		 s2 = s2 + EnglishEquivalent_ru[(s1.charCodeAt(j)>1071)?(s1.charCodeAt(j) - 1072):(s1.charCodeAt(j) - 1040)];
            }
        		else
        			if ( (charcode == 256) || (charcode == 257) ) {
        				s2 = s2 + 'A';
        			}
        			else
            			s2 = s2 + s1.charAt(j);
        				eval(tt+" = '" + trim(s2) + "'");
    }
    return false;
}
function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}
function TranslateName(s1,tt){
    if (LAT(s1)) return true;
    Translate(s1,tt);
    return false;
}
function TranslateAll(s1,tt){
    Translate(s1,tt);
    s3="";
    eval("s3="+tt);
    ReplaceChar(s3,tt);
}

var NS4a = (document.layers) ? true : false;

function getServerNow() {
    return new Date(serverNow.getFullYear(), serverNow.getMonth(), serverNow.getDate(), 
                    serverNow.getHours(), serverNow.getMinutes(), serverNow.getSeconds());
}
function IsLeapYear(y) {
   return (0 == y%4 && ((y%100 != 0) || (y%400 == 0)));
}
function DayEnd(month, year) {
   month -= 1;
   days = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
   return ((IsLeapYear(year)) && (month == 1)) ? 29 : days[month];
}

function in_array(prvek,pole) {
	for (i=0;i<pole.length;i++) if (prvek==pole[i]) return true;
	return false;    
}

function switchVisibility(elem, status) {
  var elm;
  if(!is.dom) return;
  elm = el(elem);
  if(elm) elm.style.display = (status) ? "" : "none";
}

function setCssClass(elem, cssClassName){
	var elm;
	if(!is.dom) return;
	elm = el(elem);
	if(elm) elm.className = cssClassName;
}

function getRadio(formName, elName){
	var Ctrl = document.forms[formName];
	var elm;
	if(!Ctrl) return false;
	eval("elm = Ctrl." + elName);
	if(!elm) return false;
  	if(!elm.length && elm.checked == 1) return elm.value
	else for(var z=0; z<elm.length; z++) if(elm[z].checked) return elm[z].value;
	return false;
}

function setRadio(name, wanted, unwanted){
	elm = document.getElementsByName(name);
	if(!elm || !elm.length) return;
	if(unwanted && unwanted.length) {
		for(var k = 0; k < elm.length; k++) {
			if(elm[k].value == unwanted && elm[k].checked) {
				if(wanted && wanted.length) {
					return setRadio(name, wanted);
				} else {
					elm[k].checked = false;
					return true;
				}
			}
		}
	} else {
		for(var k = 0; k < elm.length; k++) {
			if(elm[k].value == wanted) {
				elm[k].checked = true;
				return true;
		    }
		}
	}
	return false;
}

function setRadio2(form, name, val){
	var radio = el(form)[name];
	for(var k = 0; k < radio.length; k++){
		if(radio[k].value == val){
			radio[k].checked = true;			
			return true;
	    }
	}
	return false;
}

function stripLeadZero(val){
	if(val.substr(0,1) == 0) return val.substr(1);
	else return val;
}

function addLeadZero(val){
	val = val.toString();
	if(val.length == 1) return "0"+val;
	else return val;
}

function checkDay(value) {
  return (value.search(regnum) == -1) ? false : true;
}
function checkMonth(field) {
  return (value.search(regnum) == -1) ? false : true;
}

function dummy(){}

function getSelectText(obj){
	for(var i=0; i< obj.options.length; i++){
		if(obj.options[i].value == obj.value){
			return obj.options[i].text;
		}
	}
}

function switchTab(id){
	if(selected){
		el("tab_"+selected).className = "tab_normal";
		inline("link_"+selected);
		el("tab_corner_left"+selected).src = urlStart+'images/tabs/tab_corner_g_left.gif';
		el("tab_corner_right"+selected).src = urlStart+'images/tabs/tab_corner_g_right.gif';
		hide("txt_"+selected);
		hide("page_"+selected);
	}
	
	el("tab_"+id).className = "tab_selected";
	hide("link_"+id);
	//alert('http://www.avia.lt/imgs/tab_corner_left'+color+'.gif');
	el("tab_corner_left"+id).src = urlStart+"images/tabs/tab_corner_left.gif";
	el("tab_corner_right"+id).src = urlStart+"images/tabs/tab_corner_right.gif";
	inline("txt_"+id);
	show("page_"+id);	
	selected = id;
}

if(typeof(window.external) != 'undefined' && navigator.appName.indexOf('Microsoft') != -1){
	document.getElementsByName = function(name, tag){
		if(!tag) tag = '*';
		var elems = document.getElementsByTagName(tag);
		var res = [];
		for(var i=0;i<elems.length;i++){
			att = elems[i].getAttribute('name');			
			if(att == name) res.push(elems[i]);
		}
		return res;
	}
}

var Today = new Date();
var currYear = Today.getFullYear();

var invl;
var nn = 0;

//Smooth window srolling
function scrollWindow(scramount,dest) {
	//IE again... it won't clear interval for some reason
	if(nn > 0) {		
		clearInterval(invl);
		delete invl;
		return;
	}
	wascypos = getCurrentYPos();
    isAbove = (wascypos < dest);
    scrollTo(0,wascypos + scramount);
	//parent.document.body.scrollTop = wascypos + scramount;
    iscypos = getCurrentYPos();
    isAboveNow = (iscypos < dest);
    if ((isAbove != isAboveNow) || (wascypos == iscypos)) {
		// cancel the repeating timer
		clearInterval(invl);
		// if we've just scrolled past the destination, or
		// we haven't moved from the last scroll (i.e., we're at the
		// bottom of the page) then scroll exactly to the link
		window.scrollTo(0,dest);
		nn++;
    }
}

function getCurrentYPos() {
    if (top.document.body && top.document.body.scrollTop)
      return top.document.body.scrollTop;
    if (top.document.documentElement && top.document.documentElement.scrollTop)
      return top.document.documentElement.scrollTop;
    if (top.window.pageYOffset)
      return top.window.pageYOffset;
    return 0;
}

//Loads JavaScript file
function loadScript(src,leaveOld) {
	if(!leaveOld){
		var old = el('uploadScript');
		if (old) {
			old.parentNode.removeChild(old);
			delete old;
		}
		var id = 'uploadScript';
	} else {
		var id = leaveOld;
	}
	var head = document.getElementsByTagName("head")[0];
	var script = document.createElement('script');
	script.id = id;
	script.type = 'text/javascript';
	script.src = src;
	head.appendChild(script);
}

function createScript(str,obj) {
	var old = el('createdScript'+obj);
	if (old) {
		old.parentNode.removeChild(old);
		delete old;
	}
	var elm = el(obj);
	var script = document.createElement('script');
	script.type = 'text/javascript';
	script.text = str;
	//script.id = 'script'+Math.floor(Math.random()*111111);
	script.id = 'createdScript'+obj;
	elm.appendChild(script);
}

var scriptRegExp = /<script[\s\S]*?\/script>/ig;
var regex1 = /<script[\s\S]*?>/i;
var regex2 = /<\/script>/i;

//Getting the JavaScript from a string
function getJScript(str,obj){
	var scriptStrArr = str.match(scriptRegExp);
	if(scriptStrArr){
		var str = '';
		for(var i=0;i<scriptStrArr.length;i++){				
			var f = scriptStrArr[i].match(/<script[\s\S]+?>/i);
			f = f.toString();
			//Checking if this is included script
			if(/<script[\s\S]*? src=/i.test(f)){
				var t = f.match(/src=("|')([\s\S]+?)("|')/ig);
				t = t.toString();					
				var src = t.substr(5, t.length-6);
				loadScript(src);
			} else {
				var str = str+scriptStrArr[i].replace(regex2,'').replace(regex1,'');				
			}
		}
		createScript(str,obj);
		//To do the onload function (redefined in each case)
		/*if(doOnLoad) {
			doOnLoad();
			doOnLoad = null;
		}*/
	}
}



function loadContent(url,obj,showHG){
	//if(obj == "contentDiv") showHide(obj,"idDiv");
	if(showHG) el(showHG).innerHTML = '<img src="'+urlStart+'images/loading.gif">';
	var func = function(req){
		el(obj).innerHTML = req.responseText.replace(scriptRegExp,'');
		getJScript(req.responseText,obj);
	};
	AjaxRequest.post({'onSuccess':func,'url':url});
}

function AjaxSubmitForm(form,obj,showHG){
	//if(obj == "contentDiv") showHide(obj,"idDiv");
	if(showHG.length) el(showHG).innerHTML = '<img src="'+urlStart+'images/loading.gif">';
	var action = el(form).action;
	var func = function(req){
		el(obj).innerHTML = req.responseText.replace(scriptRegExp,'');
		getJScript(req.responseText,obj);
	};
	AjaxRequest.submit(el(form),{'onSuccess':func});
}

function formParamsToStr(theform) {
	theform = el(theform);
	var els = theform.elements;
	var len = els.length;
	var queryString = "";
	this.addField = 
	function(name,value) { 
		if (queryString.length>0) queryString += "&";
		queryString += encodeURIComponent(name) + "=" + encodeURIComponent(value);
	};
	for (var i=0; i<len; i++) {
		var elem = els[i];
		if (!elem.disabled) {
			switch(elem.type) {
				case 'text': case 'password': case 'hidden': case 'textarea': 
					this.addField(elem.name,elem.value); break;
				case 'select-one':
					if (elem.selectedIndex>=0) this.addField(elem.name,elem.options[elem.selectedIndex].value);
					break;
				case 'select-multiple':
					for (var j=0; j<elem.options.length; j++) {
						if (elem.options[j].selected) this.addField(elem.name,elem.options[j].value);
					}
					break;
				case 'checkbox': case 'radio':
				  if (elem.checked) this.addField(elem.name,elem.value);
				  break;
			}
		}
	}
	return queryString;
}

function showToolTip(e,str,obj, isUrl){
	obj.onmouseout = function(){
		document.body.removeChild(el('toolTipInst'));
		document.onmousemove = null;
		obj.onmouseout = null;
	};
	var tt = document.createElement('div');
	tt.className = 'toolTip';
	tt.id = 'toolTipInst';
	document.body.appendChild(tt);	
	if (!e) var e = window.event;
	el('toolTipInst').style.top = (e.clientY+22)+'px';
	el('toolTipInst').style.left = (e.clientX+11)+'px';	
	
	//tt.style.width = '150px';
	//tt.style.height = '100px';
	document.onmousemove = function(){
		el('toolTipInst').style.top = (e.clientY+22)+'px';
		el('toolTipInst').style.left = (e.clientX+11)+'px';
	}
	if(isUrl) loadContent(url,'toolTipInst','toolTipInst');
	else el('toolTipInst').innerHTML = str;
	setTimeout(function(){
		show('toolTipInst');
		if(el('toolTipInst').clientWidth > 220) el('toolTipInst').style.width = 220+'px';				   
	},750);
}

//////////////////////////////////////////////////////////////////////////////
//Cities autofill

function showCitiesList(e, id, url, ename){
	if(window.event) var keynum = event.keyCode;
	else if(e.which) var keynum = e.which;
	keychar = String.fromCharCode(keynum);
	var elm = el('citiesList'+id+'Frame'+ename);
	var v = el('city'+id+'Field'+ename).value;	
	if(keynum == 8) var val = v.substr(0,v.length-1); //Backspace
	else if(keynum != 40 && keynum != 38 && keynum != 13) var val = v;
	
	var func = function(req){
		eval(req.responseText);
		if(showList){			
			var n = -1;
			donthide = true;
				document.onkeydown = function(e){
				if(window.event) keynum = event.keyCode;
				else if(e.which) keynum = e.which;				
				switch(keynum){
					//Down key
					case 40:
						if(n<(foundCities-1)){
							changeColor(n,n+1,id,ename);
							n++;
						}else{//going back to the top
							changeColor(n,0,id,ename);
							n = 0;
						}
					break;
					//Up key
					case 38:
						if(n>-1){
							changeColor(n,n-1,id,ename);
							n--;
						} 
						if(n == -1){//going to the bottom of the list
							changeColor(n,foundCities-1,id,ename);
							n = foundCities-1;
						}
					break;
					//Enter key
					case 13:
						selectCity(n,id,ename);
						elm.style.display = 'none';
					break;
				}
			};			
		} else {
			document.onkeydown = null;
			//elm.innerHTML = '';
			elm.style.display = 'none';
		}
	};
	var args = new Object();
	args['url'] = urlStart+'includes/'+url+'.php?sm='+ename+'&query='+val+'&id='+id;
	args['onSuccess'] = func;
	if(keynum != 40 && keynum != 38 && keynum != 13) {
		AjaxRequest.post(args);		
	}
}


function changeColor(oldId,newId,id,ename){
	var e = window['citiesList'+id+'Frame'+ename].document.getElementById('cityItem'+oldId);
	if(e){
		e.className = "";
		window['citiesList'+id+'Frame'+ename].document.getElementById('cityItemLink'+oldId).className = "";
	}
	e = window['citiesList'+id+'Frame'+ename].document.getElementById('cityItem'+newId);
	if(e) {
		e.className = "selectedInList";	
		window['citiesList'+id+'Frame'+ename].document.getElementById('cityItemLink'+newId).className = "selectedInList";
	}
}

function hideCitiesList(id,ename){
	if(hideCities) hide('citiesList'+id+'Frame'+ename); //hideCities is in iframe file to prevent it from closing on mouse clicks
}

function enter_pressed(e){
	var keycode;
	if (window.event) keycode = window.event.keyCode; 
	else if (e) keycode = e.which; 
	else return false;
	return (keycode == 13);
}

function tabOver(overItem){
	if(sel != overItem) {
		el('menuSelBg_'+overItem).style.backgroundImage = 'url(imgs/tabs/'+overItem+'_over.gif)';
	}
}

function tabOut(overItem){
	if(sel != overItem){
		el('menuSelBg_'+overItem).style.backgroundImage = 'url(imgs/tabs/'+overItem+'.gif)';
	}
}
//For ajax login to change attributes in other windows if necassery
function loginDisplay(){
	toggleInline("loginPlace");
}

//Update the height of the iframe under the login popup
//so that IE wouldn't put dropdown over it (oh, that stupid IE...)
function underLoginFrameHeight(){
	var loginDivHeight = el("loginDiv").clientHeight;
	el("underLoginFrame").style.height = loginDivHeight;
}

function setWaitSize(){	
	el("waitCover").style.height = getDocumentHeight()+'px';
}

//Standard AjaxRequest onSuccess function
var func = function(req){eval(req.responseText)};