function result_vkladka_1()
{
	document.getElementById('result_vkladka').style.background="url('/img/result_vkladka_1.gif')";

	document.getElementById('result_vkladka_1_div').style.display="block";
	document.getElementById('result_vkladka_1').className="black";

	document.getElementById('result_vkladka_2_div').style.display="none";
	document.getElementById('result_vkladka_2').className="blue";
}
function result_vkladka_2()
{
	document.getElementById('result_vkladka').style.background="url('/img/result_vkladka_2.gif')";

	document.getElementById('result_vkladka_1_div').style.display="none";
	document.getElementById('result_vkladka_1').className="blue";

	document.getElementById('result_vkladka_2_div').style.display="block";
	document.getElementById('result_vkladka_2').className="black";
}
function nextmatches_vkladka_1()
{
	document.getElementById('nextmatches_vkladka').style.background="url('/img/result_vkladka_1.gif')";

	document.getElementById('nextmatches_vkladka_1_div').style.display="block";
	document.getElementById('nextmatches_vkladka_1').className="black";

	document.getElementById('nextmatches_vkladka_2_div').style.display="none";
	document.getElementById('nextmatches_vkladka_2').className="blue";
}
function nextmatches_vkladka_2()
{
	document.getElementById('nextmatches_vkladka').style.background="url('/img/result_vkladka_2.gif')";

	document.getElementById('nextmatches_vkladka_1_div').style.display="none";
	document.getElementById('nextmatches_vkladka_1').className="blue";

	document.getElementById('nextmatches_vkladka_2_div').style.display="block";
	document.getElementById('nextmatches_vkladka_2').className="black";
}

function anons_vkladka_1(type)
{
	document.getElementById('anons_vkladka').style.background="url('/img/anons_"+type+"vkladka_1.gif')";

	document.getElementById('anons_vkladka_1_div').style.display="block";
	document.getElementById('anons_vkladka_1').className="black";

	document.getElementById('anons_vkladka_2_div').style.display="none";
	document.getElementById('anons_vkladka_2').className="blue";
}
function anons_vkladka_2(type)
{
	document.getElementById('anons_vkladka').style.background="url('/img/anons_"+type+"vkladka_2.gif')";

	document.getElementById('anons_vkladka_1_div').style.display="none";
	document.getElementById('anons_vkladka_1').className="blue";

	document.getElementById('anons_vkladka_2_div').style.display="block";
	document.getElementById('anons_vkladka_2').className="black";
}


function video_vkladka()
{
	document.getElementById('media_vkladka').style.background="url('/img/media_vkladka_1.gif')";

	document.getElementById('video_vkladka_div').style.display="block";
	document.getElementById('video_vkladka_link').className="black";

	document.getElementById('audio_vkladka_div').style.display="none";
	document.getElementById('audio_vkladka_link').className="blue";
}
function audio_vkladka()
{
	document.getElementById('media_vkladka').style.background="url('/img/media_vkladka_2.gif')";

	document.getElementById('video_vkladka_div').style.display="none";
	document.getElementById('video_vkladka_link').className="blue";

	document.getElementById('audio_vkladka_div').style.display="block";
	document.getElementById('audio_vkladka_link').className="black";
}


function competitions_men(id)
{
	document.getElementById('competitions_vkladka_'+id+'').style.background="url('/img/competition_vkladka_1.gif')";

	document.getElementById('men_leagues_'+id+'').style.display="block";
	document.getElementById('competitions_vkladka_link_men_'+id+'').className="competitions_vkladka_link_black";

	document.getElementById('women_leagues_'+id+'').style.display="none";
	document.getElementById('competitions_vkladka_link_women_'+id+'').className="competitions_vkladka_link_blue";
}
function competitions_women(id)
{
	document.getElementById('competitions_vkladka_'+id+'').style.background="url('/img/competition_vkladka_2.gif')";

	document.getElementById('men_leagues_'+id+'').style.display="none";
	document.getElementById('competitions_vkladka_link_men_'+id+'').className="competitions_vkladka_link_blue";

	document.getElementById('women_leagues_'+id+'').style.display="block";
	document.getElementById('competitions_vkladka_link_women_'+id+'').className="competitions_vkladka_link_black";
}


function competition_men()
{
	document.getElementById('competition_vkladka').style.background="url('/img/competition_vkladka_1.gif')";

	document.getElementById('men_league').style.display="block";
	document.getElementById('competition_vkladka_link_men').className="competitions_vkladka_link_black";

	document.getElementById('women_league').style.display="none";
	document.getElementById('competition_vkladka_link_women').className="competitions_vkladka_link_blue";
}
function competition_women()
{
	document.getElementById('competition_vkladka').style.background="url('/img/competition_vkladka_2.gif')";

	document.getElementById('men_league').style.display="none";
	document.getElementById('competition_vkladka_link_men').className="competitions_vkladka_link_blue";

	document.getElementById('women_league').style.display="block";
	document.getElementById('competition_vkladka_link_women').className="competitions_vkladka_link_black";
}


function compcalend_men_vkladka()
{
	document.getElementById('compcalend_vkladka').style.background="url('/img/compcalend_vkladka_1.gif')";

	document.getElementById('compcalend_men_vkladka_div').style.display="block";
	document.getElementById('compcalend_men_vkladka_link').className="black";

	document.getElementById('compcalend_women_vkladka_div').style.display="none";
	document.getElementById('compcalend_women_vkladka_link').className="blue";
	
	document.getElementById('compcalend_type').value="men";
}
function compcalend_women_vkladka()
{
	document.getElementById('compcalend_vkladka').style.background="url('/img/compcalend_vkladka_2.gif')";

	document.getElementById('compcalend_men_vkladka_div').style.display="none";
	document.getElementById('compcalend_men_vkladka_link').className="blue";

	document.getElementById('compcalend_women_vkladka_div').style.display="block";
	document.getElementById('compcalend_women_vkladka_link').className="black";
	
	document.getElementById('compcalend_type').value="women";
}


function compcalend_rounds_down(type,id)
{
	document.getElementById('compcalend_other_'+type+'rounds_'+id+'').style.display="block";
	document.getElementById('compcalend_'+type+'rounds_display_'+id+'').className="compcalend_rounds_up";
	document.getElementById('compcalend_'+type+'rounds_display_'+id+'').title="Скрыть события";
	document.getElementById('compcalend_'+type+'rounds_display_'+id+'').href="javascript:compcalend_rounds_up('"+type+"','"+id+"');";
}
function compcalend_rounds_up(type,id)
{
	document.getElementById('compcalend_other_'+type+'rounds_'+id+'').style.display="none";
	document.getElementById('compcalend_'+type+'rounds_display_'+id+'').className="compcalend_rounds_down";
	document.getElementById('compcalend_'+type+'rounds_display_'+id+'').title="Все события дня";
	document.getElementById('compcalend_'+type+'rounds_display_'+id+'').href="javascript:compcalend_rounds_down('"+type+"','"+id+"');";
}

/**
* Функция для создания элементов HTMLElement
* @param {String} tag - имя элемента, которые нужно создать (div, input и т.д.)
* @param {Object} attr - объект, содержащий аттрибуты элемента
* @param {Object} vars - объект, содержащий переменные элемента
*/
function ce(tag, attr, vars){
       if(tag){
               var elem = document.createElement(tag);

               if (attr){
                       for (var name in attr){
                               var value = attr[name];
                               if ( typeof value != "undefined" ) {
                                       if(name == 'class' || name == 'for'){
                                               name = { "for": "htmlFor", "class": "className" }[name] || name;
                                               elem[name] = value;
                                       } else {
                                               elem.setAttribute(name, value);
                                       }
                               }
                       }
               }

               if (vars){
                       for (var i in vars)
                               elem[i] = vars[i];
               }

               return elem;
       }
       return null;
}

//добавляет недостающие пустые ячейки во вкладку М или Ж (результаты, ближайшие матчи)
function AddEmptyDiv(num,parentclass,childclass,htmltext,idelem)
{
		var i;
		for (i=0;i<num;i++)
		{
			var parentDiv = ce("div", null, {className:parentclass});
			var childDiv = ce("div", null, {className:childclass});
			childDiv.innerHTML = htmltext;
    		parentDiv.appendChild(childDiv);
			document.getElementById(idelem).appendChild(parentDiv);
		}
}
