function reloadchcks(elname, frmname) {
	if (!frmname) frmname = "def1";
	
	var p = document.forms[frmname].elements[elname];
	
	if (p.checked) {
			document.getElementById('divtype_1').style.display="";
	}
	if (!p.checked) {
		document.getElementById('divtype_1').style.display="none";
			
	}		
}

function galPicNextImg(p) {
	var hold = document.getElementById('nextBut');
	if(hold) {
		document.location.href= hold.href;
	} 
	
	return false;
}


function hideGalPic(n) {
	if (document.getElementById) {
		document.getElementById('picNoScript_' + n).style.display = 'none';
	}
}

function doNext() {
	if(currentPic < (NUM_PICS)) {
		document.getElementById(NDIV).style.textDecoration='none';
		document.getElementById(NDIV).style.color='';
	} else {
		document.getElementById(NDIV).style.color=DISABLECOLOR;
		document.getElementById(NDIV).style.textDecoration='line-through';
	}
}

function doBack(){
	if(currentPic > 1) {
		document.getElementById(BDIV).style.textDecoration='none';
		document.getElementById(BDIV).style.color='';
	} else {
		document.getElementById(BDIV).style.color=DISABLECOLOR;
		document.getElementById(BDIV).style.textDecoration='line-through';
	}
}



function showDiv(nDiv) {	
	for(var i = 1; i <= NUM_PICS; i++) {
		
		if (NUM_PICS > 1) {
			document.getElementById(LINKID_PREF + i).style.background= unselectedColor;
			document.getElementById(LINKID_PREF + i).style.color= currentPicColor;
		}
		
		var buttonid = i;
		var id = PICID_PREF + i;
		var node = document.getElementById(id);
		if(node && i==nDiv) {
			node.style.display='block';
			node.style.visibility='visible';
			currentPic = i;
			document.getElementById(LINKID_PREF + currentPic).style.background= currentPicColor;
			document.getElementById(LINKID_PREF + currentPic).style.color= unselectedColor;
		} else if(node) {
			node.style.display='none';
			node.style.visibility='hidden';
		}
	}
	doBack();
	doNext();
}

function showRelDiv(nDiv) {
	for(var i = 1; i <= NUM_PICS; i++) {
		
		var buttonid = i;
		var id = PICID_PREF + i;
		var node = document.getElementById(id);
		if(node && i==nDiv) {
			node.style.display='block';
			node.style.visibility='visible';
			currentPic = i;
		} else if(node) {
			node.style.display='none';
			node.style.visibility='hidden';
		}
	}
	doBack();
	doNext();		
}

function showDivPrev() {
	if(currentPic > 1) {
		if (!RelGall) {
			showDiv(currentPic - 1);
		} else {
			showRelDiv(currentPic - 1);
		}
	}
}

function showDivNext() {
	if(currentPic < NUM_PICS) {
		if (!RelGall) {
			showDiv(currentPic + 1);
		} else {
			showRelDiv(currentPic + 1);
		}				
	}
}


function GallInit(galpic) {
	var i;

	for (i = 1; i < 20; i ++) {
		if (document.getElementById(NAV_DIV + i)) {
			document.getElementById(NAV_DIV + i).style.display='block';
		}
	}
	if (!galpic) {
		showDiv(1);
	} else {
		showDiv(galpic);
	}
}


//~ function GallInit() {
	//~ showDiv(1);
	//~ document.getElementById(NAV_DIV).style.display='block';
	//~ document.getElementById(NAV_DIV).style.visibility='visible';
//~ }


function RelGallInit() {
	showRelDiv(1);
	document.getElementById(NAV_DIV).style.display='block';
	document.getElementById(NAV_DIV).style.visibility='visible';
}


function openw(url, title, options) {
	var newwin = window.open(url, title, options);
	newwin.focus();
}

function showNextFileForm() {
	var form = document.forms['def1'];
	var currfiles = form.numfiles.value;
	var nextfileind = currfiles*1 + 1;
	var nextfile = document.getElementById('file' + nextfileind + 'cont');
	nextfile.style.display = 'block';
	form.numfiles.value = currfiles*1 + 1;
	return true;
}

var kumulatsize = 0;
function resize(oper) {
	var elem = document.getElementById("ourStoryContent");
	if (oper == '+' && kumulatsize < 5) kumulatsize = kumulatsize + 1;
	if (oper == '-' && kumulatsize > -5) kumulatsize = kumulatsize - 1;
	
	elem.className = 'fontSize' + kumulatsize;
}

function vbaneri2(section, htmlstart, htmlend) {
	if (typeof(banners) == 'undefined') return false;
	if (!banners[section]) return false;
	if (showban1==1) {
		document.write(htmlstart);
		vbaneri(section);
		document.write(htmlend);
	}
}

function vbanericapital2(section, htmlstart, htmlend, antstart, antend) {
	if (typeof(banners) == 'undefined') return false;
	if (!banners[section]) return false;
	if (showban1==1) {
		document.write(htmlstart);
		if (banners[section][6] == 2) { //ako e razlichen ot textov link da si se writeva normalno
			document.write("<h5>Спонсорирани връзки</h5><div class=\"splinks\">");
		} else {
			document.write(antstart + "<a href=\"http://economedia.bg/onlineads/\">Реклама</a>" + antend);
		}
		document.write(singleBanner(banners[section][0], banners[section][8], banners[section][2], banners[section][3], banners[section][1], banners[section][4], banners[section][5], banners[section][6], banners[section][7], banners[section][9], banners[section][10]));
		if (banners[section][6] == 2) { //ako e razlichen ot textov link da si se writeva normalno
			document.write("</div>");
		}
		document.write(htmlend);
	}
}

function setClass( hEl, sClass ) {
	hEl.className = sClass
}

function rate(r, t, i, s) {
	if (!r) return;			// nepodaden rating
	if (t && !i) return;	// type = 1 (msg) i nqma podadeno msgid
	var form;
	var contid;
	if (t) {	// forum msg
		form = document.forms['voteform_' + i];
		contid = 'ratemsg' + i;
	} else {	// story
		form = document.forms['voteform'];
		contid = '42';
	}
	form.elements['rating'].value = r;
	
	var http_request = getxmlhttp();
	if (!http_request) { 
		form.submit();
		return true;
	}
	http_request.open('GET', '/voteform2.php?storyid=' + s + '&type='+ t + '&itemid=' + i +'&rating=' + r, true);
	http_request.onreadystatechange = function() { voteformload(http_request, contid); };
	http_request.send(null);
}

function fptopkareChageShow(p) {
	if (p == 0) return false;

	var http_request = getxmlhttp();
	if (!http_request) return true;
	
	http_request.onreadystatechange = function() { hndsubmit(http_request, 'tlT' + opt + 'content'); };
	
	var f = document.forms['filter'];
	var opt = f.elements['topfilter'].value;
	if (!opt) return;
	
	var contents = document.getElementById('best').childNodes;
	for (var i = 0; i < contents.length; i ++) {
		if (contents[i].nodeName.toUpperCase() == 'DIV') {
			contents[i].style.display = 'none';
			if (contents[i].id == ('tlT' + opt + 'content')) {
				contents[i].style.display = '';
				http_request.open('GET', './?cache=no&ajaxobj=' + contents[i].className.substring(3), true);
				http_request.send(null);
			}
		}
	}
	
}

function showBizkit(p) {
	var mShowMe;
	var mHideMe;
	
	if(p == 1) {
		mShowMe = document.getElementById('bizkit1');
		mHideMe = document.getElementById('bizkit2');
		document.getElementById('BizkitBG').style.fontWeight = 'bold';
		document.getElementById('BizkitEU').style.fontWeight = 'normal';
	} else {
		mShowMe = document.getElementById('bizkit2');
		mHideMe = document.getElementById('bizkit1');
		document.getElementById('BizkitBG').style.fontWeight = 'normal';
		document.getElementById('BizkitEU').style.fontWeight = 'bold';
	}
	
	mShowMe.style.display = 'block';
	mHideMe.style.display = 'none';
}

function createCookie(name, value, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		var expires = "; expires=" + date.toGMTString();
	} else 
		var expires = "";
	document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
	var ca = document.cookie.split(';');
	var nameEQ = name + "=";
	for(var i=0; i < ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name, "", -1);
}

// anketata

function genrandom(i) {
	return Math.floor(Math.random()*i+1)
}

function anketatest() {
	return;
	var CVal = readCookie('anketa1');
	var cdays = 1;
	if (CVal) return;
	if(genrandom(10) == 10) {
		if (confirm('Желаете ли да участвате в анкета на KARIERI.bg?')) {
			cdays = 300;
			window.open('/anketa/');
		}
	}
	createCookie('anketa1', '1', cdays);
}

function anketapopup() {
	return;
	var cdays = 1;
	var CVal = readCookie('anketa1');
	if (CVal) return;
	if(genrandom(8) == 8) {
		w = window.open("/anketa/", "anketa", "width=790,height=500,scrollbars=1,resizable=1,status=0,toolbar=0,location=0,menubar=0,directories=0");
	}
	createCookie('anketa1', '1', cdays);
}

function anketaok(p) {
	return;
	cdays = 300;
	createCookie('anketa1', '1', cdays);
	window.open(p, 'anketareal', 'width=1024,height=700,scrollbars=1,resizable=1,status=1,toolbar=1,location=1,menubar=1,directories=1');
	window.close();
	return false;
}

function anketacancel() {
	window.close();
}

// novini ot dnevnik

function dnevnikChageTab2(t) {
	var tabs = t.parentNode.getElementsByTagName('li');
	for (var i = 0; i < tabs.length; i ++) {
		if (i == 4) {
			tabs[i].className = 'l';
		} else {
			tabs[i].className = '';
		}
		if (tabs[i].id == t.id) {
			tabs[i].className += ' sel';
		}
	}
	
}

function dnevnikChageTab(t) {
	var http_request = getxmlhttp();
	if (!http_request) return true;
	
	http_request.onreadystatechange = function() { hndsubmit(http_request, t.id + 'content'); };

	var tabs = t.parentNode.getElementsByTagName('a');
	for (var i = 0; i < tabs.length; i ++) {
		tabs[i].className = '';
		if (tabs[i].id == t.id) {
			tabs[i].className = 'sel';
		}
	}
	var contents = document.getElementById('maindiv').childNodes;
	for (var i = 0; i < contents.length; i ++) {
		if (contents[i].nodeName.toUpperCase() == 'DIV') {
			contents[i].style.display = 'none';
			if (contents[i].id == (t.id + 'content')) {
				contents[i].style.display = '';
				
				http_request.open('GET', './?ajaxobj=' + contents[i].className.substring(3), true);
				http_request.send(null);
			}
		}
	}
}



//~ function dnevnikChageTab(t) {
	//~ t.blur();
	//~ var http_request = getxmlhttp();
	//~ if (!http_request) return true;
	
	//~ http_request.onreadystatechange = function() { hndsubmit(http_request, t.id + 'content'); };

	//~ var tabs = t.parentNode.parentNode.parentNode.getElementsByTagName('span');
	//~ for (var i = 0; i < tabs.length; i ++) {
		//~ tabs[i].className = '';
		//~ if (tabs[i].id == t.id) {
			//~ tabs[i].className = 'sel';
		//~ }
	//~ }
	//~ var contents = document.getElementById('tfMainDiv').childNodes;
	//~ for (var i = 0; i < contents.length; i ++) {
		//~ if (contents[i].nodeName.toUpperCase() == 'DIV') {
			//~ contents[i].style.display = 'none';
			//~ if (contents[i].id == (t.id + 'content')) {
				//~ contents[i].style.display = '';

				//~ http_request.open('GET', './?ajaxobj=' + contents[i].className.substring(3), true);
				//~ http_request.send(null);
			//~ }
		//~ }
	//~ }
//~ }

//menudropdown


function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as Netscape 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}

var browser = new Browser();

//----------------------------------------------------------------------------
// Code for handling the menu bar and active button.
//----------------------------------------------------------------------------

var activeButton = null;

/* [MODIFIED] This code commented out, not needed for activate/deactivate
   on mouseover.

// Capture mouse clicks on the page so any active button can be
// deactivated.

if (browser.isIE)
  document.onmousedown = pageMousedown;
else
  document.addEventListener("mousedown", pageMousedown, true);

function pageMousedown(event) {

  var el;

  // If there is no active button, exit.

  if (activeButton == null)
    return;

  // Find the element that was clicked on.

  if (browser.isIE)
    el = window.event.srcElement;
  else
    el = (event.target.tagName ? event.target : event.target.parentNode);

  // If the active button was clicked on, exit.

  if (el == activeButton)
    return;

  // If the element is not part of a menu, reset and clear the active
  // button.

  if (getContainerWith(el, "DIV", "menu") == null) {
    resetButton(activeButton);
    activeButton = null;
  }
}

[END MODIFIED] */

function buttonClick(event, menuId) {

  var button;

  // Get the target button element.

  if (browser.isIE)
    button = window.event.srcElement;
  else
    button = event.currentTarget;

  // Blur focus from the link to remove that annoying outline.

  button.blur();

  // Associate the named menu to this button if not already done.
  // Additionally, initialize menu display.

  if (button.menu == null) {
    button.menu = document.getElementById(menuId);
    if (button.menu.isInitialized == null)
      menuInit(button.menu);
  }

  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Set mouseout event handler for the button, if not already done.

  if (button.onmouseout == null)
    button.onmouseout = buttonOrMenuMouseout;

  // Exit if this button is the currently active one.

  if (button == activeButton)
    return false;

  // [END MODIFIED]

  // Reset the currently active button, if any.

  if (activeButton != null)
    resetButton(activeButton);

  // Activate this button, unless it was the currently active one.

  if (button != activeButton) {
    depressButton(button);
    activeButton = button;
  }
  else
    activeButton = null;

  return false;
}

function buttonMouseover(event, menuId) {

  var button;

  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Activates this button's menu if no other is currently active.

  if (activeButton == null) {
    buttonClick(event, menuId);
    return;
  }

  // [END MODIFIED]

  // Find the target button element.

  if (browser.isIE)
    button = window.event.srcElement;
  else
    button = event.currentTarget;

  // If any other button menu is active, make this one active instead.

  if (activeButton != null && activeButton != button)
    buttonClick(event, menuId);
}

function depressButton(button) {

  var x, y;

  // Update the button's style class to make it look like it's
  // depressed.

  button.className += " menuButtonActive";

  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Set mouseout event handler for the button, if not already done.

  if (button.onmouseout == null)
    button.onmouseout = buttonOrMenuMouseout;
  if (button.menu.onmouseout == null)
    button.menu.onmouseout = buttonOrMenuMouseout;

  // [END MODIFIED]

  // Position the associated drop down menu under the button and
  // show it.

  x = getPageOffsetLeft(button) + (button.offsetWidth - button.menu.offsetWidth);
  y = getPageOffsetTop(button) + button.offsetHeight;

  // For IE, adjust position.

  if (browser.isIE) {
    x += button.offsetParent.clientLeft;
    y += button.offsetParent.clientTop;
  }

  button.menu.style.left = x + "px";
  button.menu.style.top  = y + "px";

  // For IE; size, position and show the menu's IFRAME as well.

  if (button.menu.iframeEl != null)
  {
    button.menu.iframeEl.style.left = button.menu.style.left;
    button.menu.iframeEl.style.top  = button.menu.style.top;
    button.menu.iframeEl.style.width  = button.menu.offsetWidth + "px";
    button.menu.iframeEl.style.height = button.menu.offsetHeight + "px";
    button.menu.iframeEl.style.display = "";
  }
  
  button.menu.style.visibility = "visible";
}

function resetButton(button) {

  // Restore the button's style class.

  removeClassName(button, "menuButtonActive");

  // Hide the button's menu, first closing any sub menus.

  if (button.menu != null) {
    closeSubMenu(button.menu);
    button.menu.style.visibility = "hidden";

    // For IE, hide menu's IFRAME as well.

    if (button.menu.iframeEl != null)
      button.menu.iframeEl.style.display = "none";
  }
}

//----------------------------------------------------------------------------
// Code to handle the menus and sub menus.
//----------------------------------------------------------------------------

function menuMouseover(event) {

  var menu;

  // Find the target menu element.

  if (browser.isIE)
    menu = getContainerWith(window.event.srcElement, "DIV", "menu");
  else
    menu = event.currentTarget;

  // Close any active sub menu.

  if (menu.activeItem != null)
    closeSubMenu(menu);
}

function menuItemMouseover(event, menuId) {

  var item, menu, x, y;

  // Find the target item element and its parent menu element.

  if (browser.isIE)
    item = getContainerWith(window.event.srcElement, "A", "menuItem");
  else
    item = event.currentTarget;
  menu = getContainerWith(item, "DIV", "menu");

  // Close any active sub menu and mark this one as active.

  if (menu.activeItem != null)
    closeSubMenu(menu);
  menu.activeItem = item;

  // Highlight the item element.

  item.className += " menuItemHighlight";

  // Initialize the sub menu, if not already done.

  if (item.subMenu == null) {
    item.subMenu = document.getElementById(menuId);
    if (item.subMenu.isInitialized == null)
      menuInit(item.subMenu);
  }

  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Set mouseout event handler for the sub menu, if not already done.

  if (item.subMenu.onmouseout == null)
    item.subMenu.onmouseout = buttonOrMenuMouseout;

  // [END MODIFIED]

  // Get position for submenu based on the menu item.

  x = getPageOffsetLeft(item) + item.offsetWidth;
  y = getPageOffsetTop(item);

  // Adjust position to fit in view.

  var maxX, maxY;

  if (browser.isIE) {
    maxX = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) +
      (document.documentElement.clientWidth != 0 ? document.documentElement.clientWidth : document.body.clientWidth);
    maxY = Math.max(document.documentElement.scrollTop, document.body.scrollTop) +
      (document.documentElement.clientHeight != 0 ? document.documentElement.clientHeight : document.body.clientHeight);
  }
  if (browser.isOP) {
    maxX = document.documentElement.scrollLeft + window.innerWidth;
    maxY = document.documentElement.scrollTop  + window.innerHeight;
  }
  if (browser.isNS) {
    maxX = window.scrollX + window.innerWidth;
    maxY = window.scrollY + window.innerHeight;
  }
  maxX -= item.subMenu.offsetWidth;
  maxY -= item.subMenu.offsetHeight;

  if (x > maxX)
    x = Math.max(0, x - item.offsetWidth - item.subMenu.offsetWidth
      + (menu.offsetWidth - item.offsetWidth));
  y = Math.max(0, Math.min(y, maxY));

  // Position and show the sub menu.

  item.subMenu.style.left       = x + "px";
  item.subMenu.style.top        = y + "px";
  item.subMenu.style.visibility = "visible";

  // For IE; size, position and display the menu's IFRAME as well.

  if (item.subMenu.iframeEl != null)
  {
    item.subMenu.iframeEl.style.left    = item.subMenu.style.left;
    item.subMenu.iframeEl.style.top     = item.subMenu.style.top;
    item.subMenu.iframeEl.style.width   = item.subMenu.offsetWidth + "px";
    item.subMenu.iframeEl.style.height  = item.subMenu.offsetHeight + "px";
    item.subMenu.iframeEl.style.display = "";
  }

  // Stop the event from bubbling.

  if (browser.isIE)
    window.event.cancelBubble = true;
  else
    event.stopPropagation();
}

function closeSubMenu(menu) {

  if (menu == null || menu.activeItem == null)
    return;

  // Recursively close any sub menus.

  if (menu.activeItem.subMenu != null) {
    closeSubMenu(menu.activeItem.subMenu);
    menu.activeItem.subMenu.style.visibility = "hidden";

    // For IE, hide the sub menu's IFRAME as well.

    if (menu.activeItem.subMenu.iframeEl != null)
      menu.activeItem.subMenu.iframeEl.style.display = "none";

    menu.activeItem.subMenu = null;
  }

  // Deactivate the active menu item.

  removeClassName(menu.activeItem, "menuItemHighlight");
  menu.activeItem = null;
}

// [MODIFIED] Added for activate/deactivate on mouseover. Handler for mouseout
// event on buttons and menus.

function buttonOrMenuMouseout(event) {

  var el;

  // If there is no active button, exit.

  if (activeButton == null)
    return;

  // Find the element the mouse is moving to.

  if (browser.isIE)
    el = window.event.toElement;
  else if (event.relatedTarget != null)
      el = (event.relatedTarget.tagName ? event.relatedTarget : event.relatedTarget.parentNode);

  // If the element is not part of a menu, reset the active button.

  if (getContainerWith(el, "DIV", "menu") == null) {
    resetButton(activeButton);
    activeButton = null;
  }
}

// [END MODIFIED]

//----------------------------------------------------------------------------
// Code to initialize menus.
//----------------------------------------------------------------------------

function menuInit(menu) {

  var itemList, spanList;
  var textEl, arrowEl;
  var itemWidth;
  var w, dw;
  var i, j;

  // For IE, replace arrow characters.

  if (browser.isIE) {
    menu.style.lineHeight = "2.5ex";
    spanList = menu.getElementsByTagName("SPAN");
    for (i = 0; i < spanList.length; i++)
      if (hasClassName(spanList[i], "menuItemArrow")) {
        spanList[i].style.fontFamily = "Webdings";
        spanList[i].firstChild.nodeValue = "4";
      }
  }

  // Find the width of a menu item.

  itemList = menu.getElementsByTagName("A");
  if (itemList.length > 0)
    itemWidth = itemList[0].offsetWidth;
  else
    return;

  // For items with arrows, add padding to item text to make the
  // arrows flush right.

  for (i = 0; i < itemList.length; i++) {
    spanList = itemList[i].getElementsByTagName("SPAN");
    textEl  = null;
    arrowEl = null;
    for (j = 0; j < spanList.length; j++) {
      if (hasClassName(spanList[j], "menuItemText"))
        textEl = spanList[j];
      if (hasClassName(spanList[j], "menuItemArrow"))
        arrowEl = spanList[j];
    }
    if (textEl != null && arrowEl != null) {
      textEl.style.paddingRight = (itemWidth 
        - (textEl.offsetWidth + arrowEl.offsetWidth)) + "px";
      // For Opera, remove the negative right margin to fix a display bug.
      if (browser.isOP)
        arrowEl.style.marginRight = "0px";
    }
  }

  // Fix IE hover problem by setting an explicit width on first item of
  // the menu.

  if (browser.isIE) {
    w = itemList[0].offsetWidth;
    itemList[0].style.width = w + "px";
    dw = itemList[0].offsetWidth - w;
    w -= dw;
    itemList[0].style.width = w + "px";
  }

  // Fix the IE display problem (SELECT elements and other windowed controls
  // overlaying the menu) by adding an IFRAME under the menu.

  //~ if (browser.isIE) {
    var iframeEl = document.createElement("IFRAME");
    iframeEl.frameBorder = 0;
    iframeEl.src = "javascript:;";
    iframeEl.style.display = "none";
    iframeEl.style.position = "absolute";
    iframeEl.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
    menu.iframeEl = menu.parentNode.insertBefore(iframeEl, menu);
  //~ }

  // Mark menu as initialized.

  menu.isInitialized = true;
}

//----------------------------------------------------------------------------
// General utility functions.
//----------------------------------------------------------------------------

function getContainerWith(node, tagName, className) {

  // Starting with the given node, find the nearest containing element
  // with the specified tag name and style class.

  while (node != null) {
    if (node.tagName != null && node.tagName == tagName &&
        hasClassName(node, className))
      return node;
    node = node.parentNode;
  }

  return node;
}

function hasClassName(el, name) {

  var i, list;

  // Return true if the given element currently has the given class
  // name.

  list = el.className.split(" ");
  for (i = 0; i < list.length; i++)
    if (list[i] == name)
      return true;

  return false;
}

function removeClassName(el, name) {

  var i, curList, newList;

  if (el.className == null)
    return;

  // Remove the given class name from the element's className property.

  newList = new Array();
  curList = el.className.split(" ");
  for (i = 0; i < curList.length; i++)
    if (curList[i] != name)
      newList.push(curList[i]);
  el.className = newList.join(" ");
}

function getPageOffsetLeft(el) {

  var x;

  // Return the x coordinate of an element relative to the page.

  x = el.offsetLeft;
  if (el.offsetParent != null)
    x += getPageOffsetLeft(el.offsetParent);

  return x;
}

function getPageOffsetTop(el) {

  var y;

  // Return the x coordinate of an element relative to the page.

  y = el.offsetTop;
  if (el.offsetParent != null)
    y += getPageOffsetTop(el.offsetParent);

  return y;
}


function vbaneritxtcapital(section,prefixhtml,suffixhtml,prefixelem,suffixelem) {
	var ret = '';
	//~ for(var i=0; i<section.length(); i++) {
	for(i in section) {
		if (showban1==1 && banners[section[i]]) {
			ret += prefixelem + singleBanner(banners[section[i]][0], banners[section[i]][8], banners[section[i]][2], banners[section[i]][3], banners[section[i]][1], banners[section[i]][4], banners[section[i]][5], banners[section[i]][6], banners[section[i]][7], banners[section[i]][9], banners[section[i]][10]) + suffixelem;
		}
		
	}
	
	if(ret) {
		document.write(prefixhtml);
		document.write(ret);
		document.write(suffixhtml);
	}
}

function voteForMsg(msgid, vote, commentHolderId) {
	var intvote;
	var http_request = getxmlhttp();
	if (!http_request) return true;
	if (!msgid || !vote) return false;
	
	if(vote == '+') {
		intvote = 'u';
	} else if(vote == '-') {
		intvote = 'd';
	} else {
		return false;
	}
	
	http_request.onreadystatechange = function() { 
		voteForMsgResponse(http_request,msgid, commentHolderId);
	};
	
	http_request.open('GET', '/voteform.php?msg=' + msgid + '&vote=' + intvote, true);
	http_request.send(null);
	return false;
}

function voteForMsgResponse(p, msgid, commentHolderId) {
	
	var split = p.responseText.split("/");
	var rate = split[0]; 
	var vote = split[1];

	//tuk pravim proverka dali ne sa undefined, zashtoto v edin moment sa
	if ((typeof(rate) != "undefined") && (typeof(vote) != "undefined")) {
		var rateHolder = document.getElementById('rate_' + msgid);
		rateHolder.innerHTML = '<em>Оценка:</em>' + '<strong>' + rate + '</strong>, <em>гласували:</em>' + '<strong>' + vote + '</strong>';
	}
	
	jQuery('#msgid' + msgid + ' li.eMinus').toggle();
	jQuery('#msgid' + msgid + ' li.ePlus').toggle();
	
	return false;
}