function setcurmenu(i,menuid)
{

	document.getElementById('bottommenu').innerHTML=document.getElementById('bottommenu'+menuid).innerHTML;

	document.getElementById('menuitem'+i).className='curmenu';

	

	document.getElementById('border'+i).className='noborder';


	var cur=document.forms.vars.curmenu.value;

	if(cur!=i)
	{

		document.forms.vars.curmenu.value=i;

if(cur>0)
{
		document.getElementById('menuitem'+cur).className='upmenu';

		document.getElementById('border'+cur).className='border';

		document.getElementById('header'+cur).innerHTML="<div class='lightgrayline'></div><div class='grayborder2-top-left' style='background-color:#F3F3F3'><div class='grayborder2-top-right'></div></div>";
}
		document.getElementById('header'+i).innerHTML="<div class='darkgreenline'></div><div class='greenborder-top-left' style='background-color:#56B945'><div class='greenborder-top-right'></div></div>";


	}


}






function checknumeric()
{
  var key = window.event.keyCode; 
  if (key <48 || key >57) 
    window.event.returnValue = false; 
}



function FocusIN(obj)
{
  obj.style.backgroundColor="#F1F4F7";
}
function FocusOUT(obj)
{
  obj.style.backgroundColor="#FFFFFF";
}

function getElementsBySelector(selector) {
  var i;
  var s = [];
  var selid = "";
  var selclass = "";
  var tag = selector;
  var objlist = [];
  if (selector.indexOf(" ") > 0) {  //descendant selector like "tag#id tag"
    s = selector.split(" ");
    var fs = s[0].split("#");
    if (fs.length == 1) {
      return objlist;
    }
    return document.getElementById(fs[1]).getElementsByTagName(s[1]);
  }
  if (selector.indexOf("#") > 0) { //id selector like "tag#id"
    s = selector.split("#");
    tag = s[0];
    selid = s[1];
  }
  if (selid != "") {
    objlist.push(document.getElementById(selid));
    return objlist;
  }
  if (selector.indexOf(".") > 0) {  //class selector like "tag.class"
    s = selector.split(".");
    tag = s[0];
    selclass = s[1];
  }
  var v = document.getElementsByTagName(tag);  // tag selector like "tag"
  if (selclass == "") {
    return v;
  }
  for (i = 0; i < v.length; i++) {
    if (v[i].className == selclass) {
      objlist.push(v[i]);
    }
  }
  return objlist;
}

function saveGameVote() {
	var mark = 0;
	
	if (typeof mode == "undefined") mode = 'game';
	
	if($('input[name="gameVote"]:checked').length)
		mark = $('input[name="gameVote"]:checked').val();
	
	if(!mark) {
		$('div.gameVoteRadio').animate({'backgroundColor': '#ff8a00'}, 200).animate({'backgroundColor': '#f3f3f3'}, 400);
		return
	}
	
	JsHttpRequest.query('/ajax_functions.php', {
			'function': 'saveGameVote',
			'mark': mark,
			'gameId': gameId,
			'mode': mode
		},
		function(result, answer) {
			if(result['success'])
				$('div.gameVotePanel').html('<div class="mark">' + result['mark'] + '</div>');
		},
		true
	);
}

function savePollAnswer(pollId) {

	if(!pollId) return;

	var answerId = null;
	if($('input[name="poll_' + pollId + '"][checked]').length)
		answerId = $('input[name="poll_' + pollId + '"][checked]').val();
	
	if(!answerId) {
		alert('Выберите ответ!');
		return;
	}
	
	JsHttpRequest.query('/ajax_functions.php', {
			'function': 'savePollAnswer',
			'answerId': answerId,
			'pollId': pollId
		},
		function(result, answer) {
			var answerTitle = $('label[for=' + result['answerId'] + ']').text();
			$('.poll .answer, .poll div.submit').remove();
			$('.poll').append('<div class="answer"><span>Ваш ответ: ' + answerTitle + '</span></div>');
		},
		true
	);
}
