function showHTML(){
	if (document.getElementById('textareaHTML').style.display == 'inline'){
		document.getElementById('textareaHTML').style.display = 'none';
	}else{
		document.getElementById('textareaHTML').style.display = 'inline';
	}			
}

function showBBCODE(){
	if (document.getElementById('textareaBBCODE').style.display == 'inline'){
		document.getElementById('textareaBBCODE').style.display = 'none';
	}else{
		document.getElementById('textareaBBCODE').style.display = 'inline';
	}	
}

function showBigImg3(imgOb, width_min, width_max, border, mode, dop_param){
	if (mode){
		imgOb.style.position = 'absolute';
		imgOb.style.zIndex = '100';
		imgOb.parentNode.style.zIndex = '50';
		imgOb.style.border = border;
		imgOb.alt = '';
		imgOb.title = '';
		imgOb.width = width_max;
		imgOb.style.left = -1 * Math.round(imgOb.width / 4);
		if(dop_param)
			imgOb.style.top = -1 * Math.round(imgOb.height / 4);
		else imgOb.style.top = -1 * Math.round(imgOb.height - 30);
	}else{
		if(dop_param)
			imgOb.style.position = 'absolute';
		else imgOb.style.position = 'relative';
		imgOb.style.zIndex = '1';
		imgOb.parentNode.style.zIndex = '0';
		imgOb.style.border = border;
		imgOb.width = width_min;
		if(navigator.appName == 'Microsoft Internet Explorer'){
			imgOb.style.left = -1 * Math.round(imgOb.width / 800);
			imgOb.style.top = -1 * Math.round(imgOb.width / 800);	
		}else{
			imgOb.style.left = '';
			imgOb.style.top = '';
		}
	}
}

function gameGetVotes(id){
	arrayPar = Array(Array(),Array());
	arrayPar[0][0] = 'id';
	arrayPar[1][0] = id;
	loadUrl(forAll.game_domen + 'hint/getVotes/', 'showHintHelp', arrayPar);
};

function gameSetReiting(v, r1, r2){
	getEl('bigreitingid'+'one').innerHTML = r1;
	if(r1 == 10 && r2 == 0){
		r2 = '';
		r1 = r1.substr(0, r1.length - 1);
	}
	getEl('smallreitingid'+'one').innerHTML = r2;
	getEl('totalvotes').innerHTML = v;
}

function gameSetReitingMulti(id, v, r1, r2, co, cd){
	getEl('bigreitingid'+id).innerHTML = r1;
	getEl('smallreitingid'+id).innerHTML = r2;
	getEl('golosov'+id).innerHTML = v;
	getEl("game_prosmotreno_skachano_"+id).innerHTML = "Просмотрено:&nbsp;"+co+"&nbsp;|&nbsp;Популярность:&nbsp;"+cd+"&nbsp;";
}

function voteZaProtiv(id, zaprotiv){
	arrayPar = Array(Array(),Array());
	arrayPar[0][0] = 'id';
	arrayPar[1][0] = id;
	arrayPar[0][1] = 'zaprotiv';
	arrayPar[1][1] = zaprotiv;
	loadUrl(forAll.game_domen + 'hint/golosGame/', 'showHintHelp', arrayPar);
}

function fillRV(listid){
	arrayPar = Array(Array(),Array());
	arrayPar[0][0] = 'listid';
	arrayPar[1][0] = implode(',', listid);
	loadUrl(forAll.game_domen + 'hint/getManyVotes/', 'showHintHelp', arrayPar);
}

function gameDownloadList(id, phone){
//	alert(phone);
	arrayPar = Array(Array(),Array());
	arrayPar[0][0] = 'id';
	arrayPar[1][0] = id;
	arrayPar[0][1] = 'phone';
	arrayPar[1][1] = phone;
	loadUrl(forAll.game_domen + 'hint/getDownloadList/', 'showHintHelp', arrayPar);
//	if(phone == 0){
//		getEl('werecom').style.display = 'inline';
//	}else{
//		getEl('werecom').style.display = 'none';
//	}
}

function gameVotesFirst(id){
	arrayPar = Array(Array(),Array());
	arrayPar[0][0] = 'id';
	arrayPar[1][0] = id;
//	alert('1');
	loadUrl(forAll.game_domen + 'hint/getVotes/', 'showHintHelp', arrayPar);
};

function setDownloadList(list){
	getEl('downloadlist').innerHTML = list;
}

function gameGetModels(select){
/*	h = '';
	for (i in select.options[select.selectedIndex]){
		h += ' ' + i;
	};
	alert(select.options[select.selectedIndex].text);
	return;*/
	arrayPar = Array(Array(),Array());
	arrayPar[0][0] = 'brand';
	arrayPar[1][0] = select.options[select.selectedIndex].innerHTML;
	loadUrl(forAll.game_domen + 'hint/getGameModels/', 'showHintHelp', arrayPar);
}

function gameGetModels2(select){
	arrayPar = [[],[]];
	arrayPar[0][0] = 'brand';
	arrayPar[1][0] = select.options[select.selectedIndex].innerHTML;
	loadUrl('/hint/getGameModels2/', 'showHintHelp', arrayPar);
};

function gameSetModels(optionlist){
	getEl('spanmodellist').innerHTML = "<select id='modellist' name='modellist' style='width: 100%;' OnChange=setCookie('gamephone',this.options[this.selectedIndex].value,7776000);window.location=window.location;><option class='gameSelectOption0' value='0'>Выберите Модель</option>" + optionlist + "</select>";
}

function gameSetModels2(optionlist){
	getEl('spanmodellist2').innerHTML = "<select id='modellist2' name='modellist2' style='width: 100%;' OnChange=setCookie('gamephone',this.options[this.selectedIndex].value,7776000);window.location=window.location;><option class='gameSelectOption0' value='0'>Выберите Модель</option>" + optionlist + "</select>";
}

//страница загрузки, отправка вопроса

function edit_click(obj, id, text_){	// ф-ция нажатия на поле ввода поиска
	if (obj.value == text_) {
		obj.value = '';
	}else if((obj.value.length == 0) && (id == 0)){
		obj.value = text_;
	};
};

function get_kapcha_sms(do_, obj_1){
	if (do_){
		load_text_post(location.href, 3, kapcha_array);
	}else{
		if (get_el(obj_1) != null){
			get_el(obj_1).style.top = d.body.scrollTop + Math.ceil((d.body.clientHeight-80)/2);
			get_el(obj_1).style.left = Math.ceil((d.body.clientWidth-240)/2);
			get_el(obj_1).style.display = '';
		}else{
			load_text_post(location.href, 3, kapcha_array);
		};
	};
};
/*
function set_question(obj, obj_1){
	forms_el = obj.form.elements;
	j = 0;
	array_query = Array(Array(), Array());
	mail = null;
	question = null;
	for (i=0; i<forms_el.length; i++){
		if (forms_el[i].name != ''){
			array_query[0][j] = forms_el[i].name;
			array_query[1][j] = forms_el[i].value;
			if (forms_el[i].name == 'email_vopros'){
				mail = forms_el[i].value
			};
			if (forms_el[i].name == 'text_vopros'){
				question = forms_el[i].value
			};
			j++;
		};
	};
	if (/^\w+([\.-]\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(mail)){
		if (question.length < 11){
			alert('Что это за вопрос??? Задавай по существу.');
		}else{
			kapcha_array = Array(Array(), Array());
			kapcha_array = array_query;
			get_kapcha_sms(false, obj_1);
		};
	}else{
		alert('Вы не верно указали свой e-mail');
	};
};
*/

function set_question(obj, obj_1){
	forms_el = obj.form.elements;
	j = 0;
	array_query = Array(Array(), Array());
	mail = null;
	question = null;
	for (i=0; i<forms_el.length; i++){
		if (forms_el[i].name != ''){
			array_query[0][j] = forms_el[i].name;
			array_query[1][j] = forms_el[i].value;
			if (forms_el[i].name == 'email_vopros'){
				mail = forms_el[i].value
			};
			if (forms_el[i].name == 'text_vopros'){
				question = forms_el[i].value
			};
			j++;
		};
	};
	if (/^\w+([\.-]\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(mail)){
		if (question.length < 11){
			alert('Что это за вопрос??? Задавай по существу.');
		}else{
			kapcha_array = Array(Array(), Array());
			kapcha_array = array_query;
//			get_kapcha_sms(false, obj_1);
			document.forms['qform'].submit();
		};
	}else{
		alert('Вы не верно указали свой e-mail');
	};
};

function set_question_now(){
	mail = null;
	question = null;
	mail = getEl('email_vopros').value;
	question = getEl('text_vopros').value;

	if (question.length < 11){
		alert('Что это за вопрос??? Задавай по существу.');
	}else{
		document.forms['qform'].submit();
	};
};

function submit_form(obj){	// Ф-ция нажатия поиска в game.mob.ua
	form_el = obj.form.elements;
	for (i=0; i<form_el.length; i++){
		if (form_el[i].name == 'search_text') {
			text = form_el[i].value;
			while(text.indexOf('"') != -1){
				text = text.replace('"', '');
			};
			while(text.indexOf("'") != -1){
				text = text.replace("'", '');
			};
			if (text != 'Поиск игр'){
				location.href = '/search/'+text+'/';
			}else{
				alert('Укажите что искать.');
			};
			break;
		};
	};
};

function edit_13(obj, id){	// нажатие Enter в поле ввода
	e = window.event;
	var k = e.keyCode;
	if (k == 13) {
		switch(id){
			case 1:
				submit_form(obj);
			break;
			case 2:
			break;
			case 3:
				set_question(obj, 'question_kapcha');
			break;
		};
	};
};

function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}


function gameDisplayCap(){
	getEl('question_kapcha').style.display = 'block';
	getEl('question_kapcha').style.left = getClientWidth() / 2 - 120;
}

function gameCloseCap(){
	getEl('question_kapcha').style.display = 'none';
	getEl('hideDiv').style.display = 'none';
}

function gameShowAutor(){
	getEl('question_kapcha').style.display = 'none';
	getEl('question_kapcha_autor').style.display = 'block';
}

function gameIEisBUSTER(id){
	alert('Ready');
	if(navigator.appName == 'Microsoft Internet Explorer'){
		id.style.width = '98%';
	}
}
/*
function createSearchSelectGame(){	// создание выпадающего списка выбора зоны поиска
	insertIn = getEl('forAllHide');
	newElem = d.createElement('div');
	newElem.className = 'siteSelectSearchGame';
	newElem.id = 'divSiteSelectSearchGame';
	newElem.style.display = 'none';
	newElem.onmouseover = function(){keepSearchSelect()};
	newElem.onmouseout = function(){forAll.searchSelectTimeClose = setTimeout("closeSearchSelect()", forAll.timeCloseHint);};
	insertIn.appendChild(newElem);
	newElem = d.createElement('div');
	newElem.className = 'siteSelectSearchShadowGame';
	newElem.id = 'divSiteSelectSearchShadowGame';
	newElem.style.display = 'none';
	insertIn.appendChild(newElem);
	indexSelect = 0;
	for (i=0; i<forAll.searchRazdels.length; i++){
		if (location.href.indexOf(forAll.searchRazdels[i].src) != -1){
			if (forAll.searchRazdels[i].razdel != 'terms'){
				indexSelect = i;
			}else{
				indexSelect = 0;
			};
		};
	};
	setZonSiteSearchGame(indexSelect);
};*/

function beginSearchSiteGame(){
	chLocation(getEl('searchSrcGame').value + getEl('searchSizteTextGame').value + '/');
};

/*
function setZonSiteSearchGame(indexSelect){	// определение зоны поиска
	var searchRazdel = getEl('searchRazdelGame');
	searchRazdel.value = forAll.searchRazdels[indexSelect].razdel;
	var searchSrc = getEl('searchSrcGame');
	searchSrc.value = forAll.searchRazdels[indexSelect].src + forAll.searchRazdels[indexSelect].search;
	forAll.serachSpan.innerHTML = forAll.searchRazdels[indexSelect].title + ' ';
	var searchRazdel = getEl('searchSiteAllGame');
	searchSiteAll.style.display = (indexSelect == 0 ? 'none' : '');
};
*/

function show_rozdel(id){
	d.getElementById('skrut_'+id).style.display = (d.getElementById('skrut_'+id).style.display != '' ? '' : 'none');
};

function gameGetTopReiting(ids){
	arrayPar = Array(Array(),Array());
	arrayPar[0][0] = 'ids';
	arrayPar[1][0] = ids;
	loadUrlStream(forAll.game_domen + 'hint/getTopReiting/', 'evalU', arrayPar);
}

function gameSetTopReiting(id, r1, r2){
	getEl('topreitingbig' + id).innerHTML = r1;
	getEl('topreitingsmall' + id).innerHTML = r2;
}
