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 = 'recomend';
	}
		
	if (jQuery('.foto-path').length > 0) {
		var fotoblog = 1;
	}else {
		var fotoblog = 0;
	}
	
	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 +'&fotoblog=' + fotoblog, 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() {
	var cdays = 1;
	var CVal = readCookie('anketa22');
	if (CVal) return;
	if (genrandom(3) == 3) {
		w = window.open("/anketa1/start.html", "anketa", "width=790,height=500,scrollbars=1,resizable=1,status=0,toolbar=0,location=0,menubar=0,directories=0");
	}
	createCookie('anketa22', '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 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 = 'filterMenuActive';
		} else {
			tabs[i].className = '';
		}
	}
	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 if(vote == '!') {
		intvote = 'r';
	} else {
		return false;
	}
	
	jQuery('#msgid' + msgid + ' .votePlus, #msgid' + msgid + ' .voteMinus').hide();
	jQuery('#msgid' + msgid + ' .votesWait').show();

	http_request.onreadystatechange = function() { 
		voteForMsgResponse(http_request,msgid, commentHolderId, intvote);
	};
	
	http_request.open('GET', '/voteform.php?msg=' + msgid + '&vote=' + intvote, true);
	http_request.send(null);
	return false;
}

function voteForMsgResponse(p, msgid, commentHolderId, reported) {
	if(p.readyState != 4 || p.status != 200) {
		return false;
	}
	
	var rateHolder = document.getElementById('rate_' + msgid);
	if(reported == 'r') {
		rateHolder.innerHTML = '<em>Коментарът бе докладван на модераторите.</em>';
	} else {
		var split = p.responseText.split("/");
		var rate = split[0]; 
		var vote = split[1];
		
		if ((typeof(rate) != "undefined") && (typeof(vote) != "undefined")) {
			if(vote == 1) {
				votestr = ' глас';
			} else {
				votestr = ' гласа';
			}
			rateHolder.innerHTML = '<span>оценка ' + '<strong>' + rate + '</strong></span><span> ' + vote + votestr + '</span>';
		}
	}
	
	jQuery('#msgid' + msgid + ' a.voteMinus').hide();
	jQuery('#msgid' + msgid + ' a.votePlus').hide();
	jQuery('#' + commentHolderId + ' .report a').hide();
	jQuery('#msgid' + msgid + ' .votesWait').hide();
	
	return false;
}

function setVisibility(id, visibility) {
	document.getElementById(id).style.display = visibility;
}

function buzzdashvote(pformname) {
	var bbpansid;
	
	var pfrm = document.forms[pformname];
	
	if (!pfrm) return false;
	var els = pfrm.elements["anketaans[]"];
	
	if (!els) return false;
	for (var i = 0; i < els.length; i++) {
		if (els[i].checked) {
			bbpansid = els[i].attributes['bbpansid'];
			if (!bbpansid) {
				return false;
			}
		}
	}
	
	if (!bbpansid) return false;
	if (!bbpansid.value) return false;
	
	var vals = bbpansid.value.split('_');
	if (!vals || !vals[0] || !vals[1]) return false;
	jQuery(document.body).append('<iframe src="http://www.buzzdash.bg/vote/?BB_id=' + vals[0] + '&BBO_id=' + vals[1] + '" border="0" frameborder="0" width="1" height="1"></iframe>');
	
	return true;
}

jQuery(document).ready(function() {
	jQuery(".blogyear a").click(function () {
		jQuery(".blogyear" + jQuery(this).text()).toggle();	
    });    

	var bigGalleryStory = jQuery('.gallShow');
	if(bigGalleryStory.length) { //koda da se izpulnqva samo ako ima takuv div
		jQuery('#msg').focus(function(e) {
			if(typeof(galKeyPressHandler) == 'function') {
				jQuery(document).unbind('keyup', galKeyPressHandler);
			}
		});
		
		jQuery('#msg').change(function(e) {
			if(typeof(galKeyPressHandler) == 'function') {
				jQuery(document).unbind('keyup', galKeyPressHandler);
			}
		});
		
		jQuery('#msg').blur(function(e) {
			jQuery(document).bind('keyup', galKeyPressHandler);
		});
		
		function galKeyPressHandler(e) {
			if(e.keyCode == 39) { //next ->
				var nextlnk = jQuery('.wrapMImage:visible .rightNav a');
				if(nextlnk.length) {
					nextlnk.click();
				}
			} else if(e.keyCode == 37) { //prev <-
				var prevlnk = jQuery('.wrapMImage:visible .leftNav a');
				if(prevlnk.length) {
					prevlnk.click();
				}
			} else {
				return false;
			}
		};
		
		jQuery(document).bind('keyup',galKeyPressHandler);
	}

	jQuery("a[rel*='lightbox[roadtrip]']").lightBox({
		txtImage: 'Снимка',
		txtOf: 'от',
		imageLoading: 'lib/lightbox2.04/images/loading.gif',
		imageBtnClose: 'lib/lightbox2.04/images/closelabel.gif',
		imageBtnPrev: 'lib/lightbox2.04/images/prevlabel.gif',
		imageBtnNext: 'lib/lightbox2.04/images/nextlabel.gif'
	});

	jQuery('.accentMenu li').hover(
		function(){
			jQuery('.accentContentNew').stop(true, true);
			jQuery('.accentMenu li').removeClass("active");
			jQuery(this).addClass("active");
			jQuery('#accentStory').append(jQuery(this).attr('content'));
			jQuery('.accentContentNew').fadeIn(500, function () {
				jQuery('.accentContentActive').remove();
				jQuery('.accentContentNew').addClass('accentContentActive');
				jQuery('.accentContentActive').removeClass('accentContentNew');
			});
		}, function(){
	});
	
	jQuery('.sectionMenuRight li').hover(
		function(){
			jQuery('.accentContentNew').stop(true, true);
			jQuery('.sectionMenuRight li').removeClass("sectionMenuActive");
			jQuery(this).addClass("sectionMenuActive");
			jQuery('#accentStory').append(jQuery(this).attr('content'));
			jQuery('.accentContentNew').fadeIn(500, function () {
				jQuery('.accentContentActive').remove();
				jQuery('.accentContentNew').addClass('accentContentActive');
				jQuery('.accentContentActive').removeClass('accentContentNew');
			});
		}, function(){
	});
	
	jQuery('#blogCalendar a').click(
		function(){
			jQuery(this).parent().siblings('li').removeClass('today'); 
			jQuery(this).parent().addClass('today');
		}
	);
	
	//~ jQuery('.filterMenu a').click(
		//~ function(){
			//~ jQuery('#filter').load('./?ajaxobj=' + (jQuery(this).attr('ajaxobj'))); 
			//~ jQuery(this).parent().siblings().children('a .filterMenuActive').removeClass('filterMenuActive'); 
			//~ jQuery(this).parent().children().addClass('filterMenuActive');
		//~ }
	//~ );
	
	jQuery('.buttresOff').click (
		function(){
			jQuery.get('/ajaxpoll.php?formname=anketa&type=1&posid=' + jQuery(this).attr('posid') + '&pollid=' + jQuery(this).attr('pollid') + '&pollpage=&anketaans[]=' + jQuery(this).attr('ansid') + '&votenow=1', null, function(data, textstatus){
				jQuery('.content #pollres').html(data);
			});
			jQuery('.showResults a, .showResults i').hide();
		}
	);
	
	jQuery('.answer a').click (
		function(){
			jQuery.get('/ajaxpoll.php?formname=anketa&type=1&posid=' + jQuery(this).attr('posid') + '&pollid=' + jQuery(this).attr('pollid') + '&pollpage=&anketaans[]=' + jQuery(this).attr('ansid') + '&votenow=1', null, function(data, textstatus){
				jQuery('.content #pollres').html(data);
			});
			jQuery('.showResults a, .showResults i').hide();
		}
	);
	
	jQuery('.answer a').hover (
		function(){
			jQuery(this).parent().siblings().addClass('buttresOffactive');
			jQuery(this).parent().siblings().removeClass('buttresOff');
		},
		function(){
			jQuery(this).parent().siblings().removeClass('buttresOffactive');
			jQuery(this).parent().siblings().addClass('buttresOff');
		}
	);
	
	jQuery('.showResults a').click (
		function(){
			jQuery.get('/ajaxpoll.php?formname=anketa&type=1&pollid=' + jQuery(this).attr('pollid') + '&viewtype=резултати', null, function(data, textstatus){
				jQuery('.content #pollres').html(data);
			});
			jQuery('.showResults').hide();
			jQuery('.pollBack').show();
		}
	);
	
	jQuery('.pollBack a').click (
		function(){
			jQuery.get('/ajaxpoll.php?type=1&formname=anketa&pollid='+ jQuery(this).attr('pollid') + '&posid='+ jQuery(this).attr('posid') + '', null, function(data, textstatus){
				jQuery('.content #pollres').html(data);
				jQuery('.buttresOff').click (
					function(){
						jQuery.get('/ajaxpoll.php?formname=anketa&type=1&posid=' + jQuery(this).attr('posid') + '&pollid=' + jQuery(this).attr('pollid') + '&pollpage=&anketaans[]=' + jQuery(this).attr('ansid') + '&votenow=1', null, function(data, textstatus){
							jQuery('.content #pollres').html(data);
						});
					}
				);
	
				jQuery('.answer a').click (
					function(){
						jQuery.get('/ajaxpoll.php?formname=anketa&type=1&posid=' + jQuery(this).attr('posid') + '&pollid=' + jQuery(this).attr('pollid') + '&pollpage=&anketaans[]=' + jQuery(this).attr('ansid') + '&votenow=1', null, function(data, textstatus){
							jQuery('.content #pollres').html(data);
						});
					}
				);
			});	
				
			jQuery('.pollBack').hide();
			jQuery('.showResults').show();
		}
	);
	
	
	jQuery('.grafikNaviHeader a').click(
		function(){
			jQuery(this).parent().siblings().children('a').removeClass('active'); 
			jQuery(this).parent().children().addClass('active');
		}
	);
	
	jQuery('.grafikNaviFooter a').click(
		function(){
			jQuery(this).parent().siblings().children('a').removeClass('active'); 
			jQuery(this).parent().children().addClass('active');
		}
	);
	
	jQuery('.expand a').click (
		function(){
			jQuery(this).parent().parent().hide().siblings('.expandable').show();
		}
	);
	
	jQuery('.expandContent a').click (
		function(){
			jQuery(this).parent().hide().siblings('.expandable').show();
			//~ jQuery(this).parent().parent().parent().parent().parent().parent().parent().css('float', 'none');
			//~ jQuery(this).parent().parent().parent().parent().parent().parent().parent().addClass('iemargin');

		}
	);
	
	jQuery('.shrink a').click (
		function(){			
			jQuery(this).parent().parent().parent().hide().siblings().show();
			jQuery(this).parent().parent().parent().siblings().children('.expand').show();
			jQuery(this).parent().parent().parent().parent().parent().parent().parent().parent().css('float', 'left');
			jQuery(this).parent().parent().parent().parent().parent().parent().parent().css('float', 'left');
			jQuery(this).parent().parent().parent().parent().parent().parent().parent().parent().removeClass('iemargin');
		}
	);
	
	jQuery('.shrinkvideo a').click (
		function(){			
			jQuery(this).parent().parent().parent().siblings().show().siblings('.expandable').hide();
		}
	);
	
	jQuery('.fSize').click(function() {
		var txtHolder = jQuery('#ourStoryContent'); 
		if(txtHolder.hasClass('fontSize0')) {
			txtHolder.removeClass('fontSize0').addClass('fontSize5 lineHeight1_3');
			jQuery(this).removeClass('txtBig').addClass('txtMini');
			jQuery(this).children('a').attr('title', 'Намаляване на шрифта');
		} else {
			txtHolder.removeClass('fontSize5 lineHeight1_3').addClass('fontSize0');
			jQuery(this).removeClass('txtMini').addClass('txtBig');
			jQuery(this).children('a').attr('title', 'Увеличаване на шрифта');
		}
		
		return false;
	});
	
	jQuery('.filterLightPhoto a').click(
		function(){
			jQuery(this).parent().siblings().children('a').removeClass('activePhoto'); 
			jQuery(this).parent().children().addClass('activePhoto');
			jQuery('.lightPhotoProp p').html(jQuery(this).attr('alt'));
		}
	);
	
	jQuery('.innerK1').click(function() {
		jQuery('html,body').animate({scrollTop: jQuery('#k1').offset().top},500);
		return false;
	});
	
	jQuery('.innerK2').click(function() {
		jQuery('html,body').animate({scrollTop: jQuery('#k2').offset().top},500);
		return false;
	});
	
	jQuery('.innerK3').click(function() {
		jQuery('html,body').animate({scrollTop: jQuery('#k3').offset().top},500);
		return false;
	});
	
	jQuery('.innerLight').click(function() {
		jQuery('html,body').animate({scrollTop: jQuery('#LIGHT').offset().top},500);
		return false;
	});
	
	jQuery('.modLnk a').click(function(){
		jQuery('html,body').animate({scrollTop: jQuery('#mod').offset().top},500);
		return false;
	});
	
	jQuery('.proLnk a').click(function(){
		jQuery('html,body').animate({scrollTop: jQuery('#pro').offset().top},500);
		return false;
	});
	
	jQuery('.conLnk a').click(function(){
		jQuery('html,body').animate({scrollTop: jQuery('#con').offset().top},500);
		return false;
	});
	
	jQuery('.morebrowse').click(function() {
		jQuery('html,body').animate({scrollTop: jQuery('#clndrbox').offset().top},500);
		return false;
	});
	
	jQuery("#cmntsbscr").click(function () {
		if (jQuery('input[name=cmntsbscr]:checked').val() == 1) {
		//zapisva
			jQuery.get('/forumalerts.php?itemid=' + jQuery(this).attr('itemid') + '&uid=' + jQuery(this).attr('uid') + '&a=1', null, function(data, textstatus){
				jQuery('#cmntsbscrtxt').html(data);
			});
		} else {
		//otpisva
			jQuery.get('/forumalerts.php?itemid=' + jQuery(this).attr('itemid') + '&uid=' + jQuery(this).attr('uid') + '&a=0', null, function(data, textstatus){
				jQuery('#cmntsbscrtxt').html(data);
			});
		}	
	});
	
	jQuery("#debatsbscr").click(function () {
		if (jQuery('input[name=debatsbscr]:checked').val() == 1) {
			if(!jQuery(this).attr('uid')){ //proverka dali e registriran potrebitel
				jQuery('.debSubscr p').html('За да се абонирате за известия за дебатите, моля <a title="влезте в профила си" href="javascript:openloginthickbox();">влезте в профила си</a> или се <a title="Регистрация" href="javascript:openregthickbox();">регистрирайте</a>');
			}else {
				//zapisva
				jQuery.get('/debatialerts.php?itemid=' + jQuery(this).attr('itemid') + '&uid=' + jQuery(this).attr('uid') + '&a=1', null, function(data, textstatus){
					jQuery('.debSubscr p').html(data);
				});
			}
		}else {
		//otpisva
			if(!jQuery(this).attr('uid')){ //proverka dali e registriran potrebitel
				jQuery('.debSubscr p').html('За да се абонирате за известия за дебатите, моля <a title="влезте в профила си" href="javascript:openloginthickbox();">влезте в профила си</a> или се <a title="Регистрация" href="javascript:openregthickbox();">регистрирайте</a>');
			}else {
				jQuery.get('/debatialerts.php?itemid=' + jQuery(this).attr('itemid') + '&uid=' + jQuery(this).attr('uid') + '&a=0', null, function(data, textstatus){
					jQuery('.debSubscr p').html(data);
				});
			}	
		}	
	});
	
	
	if ((jQuery('input[name=debatsbscr]:checked').val() == 1) && !jQuery('input[name=debatsbscr]').attr('uid')) {
		jQuery('input[name=debatsbscr]').attr('checked', false);
	}

	loadFilterComments();
	
	
	var commentForm = jQuery('#forumPost');
	if(commentForm.length) {
		commentForm.submit(function() {
			if((forumSpamTest(jQuery('#forumPost #msg').val(), false) || (forumSpamTest(jQuery('#forumPost #author').val(), true)) ) && !jQuery('#captcha').val()) {
				
				if(!jQuery('.captchaHolder #captchaInp').length) {
					jQuery('.captchaHolder').html('<div class="captcha"><div id="captchaInp" style="width: 461px; display: block; overflow: hidden; margin-bottom: -35px; _height: 70px; _margin-bottom: 0;">				<span class="L" style="overflow: hidden; line-height: auto; height: auto;">					<img src="/frmcaptcha.php" id="cappic" /><br/>					<a title="Генериране на нов код" href="javascript: void(0);" onclick="return reloadCaptcha();">Генериране на нов код</a>				</span>				<div class="captchaInpDiv">				<label>Моля, въведете кода от изображението в полето по-долу, за да докажете, че не сте спам-робот.</label>					<input type="text" name="captcha" id="captcha">				</div>			</div></div>');
				}
				return false;
			}
			jQuery('.capSendBut').hide(); 
			jQuery('.thanksSubmit').show();
		});
	}
	
	
	
	
});


function filterLoad(obj, holder, p) {
	jQuery(holder).load('./?ajaxobj=' + obj);
	jQuery(p).parent().siblings().children('a.filterMenuActive').removeClass('filterMenuActive'); 
	jQuery(p).parent().children().addClass('filterMenuActive');
	createCookie('CapitalFilterTabObj',obj,0);	
	return false;
}

function filterLoadPage(obj, holder, p) {
	jQuery(holder).load('./?ajaxobj=' + obj);
	jQuery(p).parent().siblings().children('a.filterMenuActive').removeClass('filterMenuActive'); 
	jQuery(p).parent().children().addClass('filterMenuActive');
	createCookie('CapitalStoryTabObj',obj,0);	
	return false;
}

function replyTo(postNum, postAuthor) {
	var curVal = jQuery('#msg').val();
	var repStr;
	if(curVal.length > 0) {
		repStr = curVal + '\nДо коментар [#' + postNum + '] от "' + postAuthor + '":\n\n';
	} else {
		repStr = 'До коментар [#' + postNum + '] от "' + postAuthor + '":\n\n';
	}
	jQuery('#msg').val(repStr).focus();
	jQuery('html,body').animate({scrollTop: jQuery('#addcomment').offset().top},500);
	return false;
}


function getTdContent (){	

}

function toggle(id) {
	var hold = document.getElementById(id);
	
	if(hold.style.display == 'block') {
		hold.style.display = 'none';
	} else if(hold.style.display == 'none') {
		hold.style.display = 'block';
	}
	
	return false;
}

function setGraphIndex(holderId, idx, period, dataStore, w, h, dataType) {
	if(!idx) {
		idx = 'dn20';
	}
	if(!period) {
		period = '1d';
	}

	
	if(!w) {
		w = 300;
	}
	
	if(!h) {
		h = 250;
	}
	
	if(dataType) {
		varType = 'c';
	} else {
		varType = 'i';
	}
	
	var flashvars = {
		dataFeederURL: escape('/biznes/flashgraph.php?' + varType + '=' + idx + '&p=' + period)
	};
	
	swfobject.embedSWF('/biznes/graphs.swf', holderId, w, h, '9.0.0', null, flashvars);
	dataStore.activeIdxGraph = idx;
	dataStore.activeIdxPeriod = period;
	
	return false;
}


function calendarChangeMonth(m,y,rn) {
	var http_request = getxmlhttp();
	if (!http_request) return true;
	
	http_request.onreadystatechange = function() { hndsubmit(http_request, 'clndrbox'); };

	http_request.open('GET', './?ajaxobj=calendar&m=' + m + '&y=' + y + '&rubrikaname=' + rn, true);
	http_request.send(null);
	return false;
}

function uraganCal(rubrname) {
	var month = document.getElementById('calm');
	var year = document.getElementById('caly');
	
	calendarChangeMonth(month.value,year.value,rubrname);
	return false;
}

function debVote(pollid, ansid) {
	if(pollid && ansid) {
		jQuery.get('/ajaxpoll.php', { 'type': 3, 'formname': 'anketa', 'pollid': pollid, 'anketaans': ansid, 'votenow': 1 },
		  function(data){
			jQuery('.debVoteHldr').html(data);
		  });
	}
	return false;
}



function filterComments() {
	var cVal = readCookie('capitalForumFilter');

	if (jQuery('#forumFilter option:selected').val() == 1) {
		jQuery('.singleComment').show();
		jQuery('#commentpreviewbox').hide();
		jQuery('#commentpreviewtitle').hide();
	}
	if (jQuery('#forumFilter option:selected').val() == 2) {
		jQuery('.singleComment').hide();
		jQuery('.singleComment1').hide();
		jQuery('.singleCommentBlue').show();
		jQuery('#commentpreviewbox').hide();
		jQuery('#commentpreviewtitle').hide();
	}
	if (jQuery('#forumFilter option:selected').val() == 3) {
		jQuery('.singleComment').show();
		jQuery('.singleComment1').hide();
		jQuery('.singleCommentBlue').show();
		jQuery('#commentpreviewbox').hide();
		jQuery('#commentpreviewtitle').hide();
	}
	if (jQuery('#forumFilter option:selected').val() == 4) {
		jQuery('.singleComment').hide();
		jQuery('#commentpreviewbox').hide();
		jQuery('#commentpreviewtitle').hide();
	}
	
	if (jQuery('#forumFilter option:selected').val()) {
		createCookie('capitalForumFilter',jQuery('#forumFilter option:selected').val(),1);
	}
}

function loadFilterComments(){
	var cVal = readCookie('capitalForumFilter');
	if (cVal) {
		jQuery('#forumFilter').val(cVal);
		filterComments();
	}
}

function deleteComment(postNum, msgId) {
	var answer = confirm("Наистина ли желаете да изтриете този коментар? ")
	if (answer){
		jQuery.get('/decomments.php?msgid=' + msgId + '', null, function(data, textstatus){
		jQuery('#comment-' + postNum + ' .rightCol').html(data);
		
			});
	}
}

function modAction(id) {
	var actionStr = '';
	
	var action = jQuery('#candp' + id).val();
	if(action != '') {
		var customtxt = '';
		if(action == 15) {
			customtxt = prompt('Моля въведете името на фирмата');
			if(customtxt == '' || customtxt == null) {
				jQuery('#msg'+id).html('Грешка! Невалидно име.').show();
				setTimeout( 'hideMsg('+ id +');', 5000); 
				return false;
			}
			customtxt = '&custext=' + escape(customtxt);
		}
		
		
		//~ if(topic) {
			//~ actionStr = '&action='+action+'&topic=1' + customtxt;
		//~ } else {
			actionStr = '&action='+action + customtxt;
		//~ }
	}
	
	//~ jQuery('#msg'+id).load('modAct.php?msgid='+id+actionStr,null,function (responseText, textStatus, XMLHttpRequest) {
		//~ jQuery('#msg'+id).show();
		//~ setTimeout( 'hideMsg('+ id +');', 5000); 
	//~ });
	
	 window.open('http://cms.economedia.bg/forums/search/singleModAct.php?msgid=' + id+actionStr + '', null, function(data, textstatus){
		jQuery('cmntTxt').html(data);
	
	});
	
	
	return false;
}

function reloadCaptcha() {
	var img = document.getElementById('cappic');
	img.src = '/frmcaptcha.php?rld=' + Math.random();
	return false;
}


function forumSpamTest(strVal, skipCyrTest) {
	var ret 
	ret = false;
	
	if(strVal) {
		if(strVal.search(/https?:\/\/|www\.\w+/i) !== -1) {
			ret = true;
		} else if(!skipCyrTest && (strVal.search(/[а-я]/i) == -1)) {
			ret = true;
		} else if(strVal.search(/[ёыэ]/i) !== -1) {
			ret = true;
		}
	}
	
	return ret;
}

function scrollPic(pId){
	jQuery('html,body').animate({scrollTop: jQuery('#photo'+ pId +'').offset().top},500);
	return false;
}