function addMyBookmark(url,title){
	if((typeof window.external == "object") && !(typeof window.sidebar == "object")){//IE
		wext = window.external;
		wext.addFavorite(url, title);
		return false;
	}else//Other
		return true;

}

function loadSpinner(oDiv,img){
	oDiv.innerHTML = '<div style="width:100%;heigth:100%;text-align:center;"><img style="vertical-align:center;" src="'+img+'" /></div>';
	return true;
}

function subscribe(oInput,action,oDiv,img){
	var email = oInput.value;
	var mail = chekMail(email);
	if(mail){
		loadSpinner(oDiv,img);
		post='email='+mail;
		submitIt(post, action, oDiv);
	}else{
		oInput.style.border = '1px solid red';
		return false;
	}
}

function unsubscribe(obj, action, oDiv, img){
	var email = obj.innerHTML;
	var mail = chekMail(email);
	if(mail){
		loadSpinner(oDiv,img);
		post='email='+mail;
		submitIt(post, action, oDiv);
	}else{
		obj.style.border = '1px solid red';
		return false;
	};
}

function refresh(o){
	if(o.value == o.title) o.value = '';
}

function display(o){
	if(o.style.display == 'block') o.style.display = 'none';
	else o.style.display = 'block';
}

function comment(o,id_item,img){
	var name = o.previousSibling.previousSibling.previousSibling.previousSibling.previousSibling.previousSibling.value;
	var comment = o.previousSibling.previousSibling.value;
	var email = o.previousSibling.previousSibling.previousSibling.previousSibling.value;
	
	var error = '';
	if(email == 'e-mail')
		email = '';
	if(email != ''){
		var check_email = chekMail(email);
		if(!check_email)
			error += 'Поле &laquo;e-mail&raquo; заполнено неверно.';
		else
			check_email = true;
	}
	else
		var check_email = true;
	
	if(comment != '' && comment != 'комментарий')
		check_comment = true;
	else{
		check_comment = false;
		error += '<br />Заполните поле &laquo;комментарий&raquo;.';
	}
	
	if(name != '' && name != 'имя')
		check_name = true;
	else{
		check_name = false;
		error += '<br />Заполните поле &laquo;имя&raquo;.';
	}

	if(check_email===true && check_comment===true && check_name===true){
		oDiv = document.getElementById('add_comments_block');
		loadSpinner(oDiv,img);
		post='email='+email+'&name='+name+'&comment='+comment+'&id_item2cat='+id_item;
		var request = new httpRequest();
		var func = function(){
			var res = request.responseText;
			if(res == 1)
				text = 'Comment is successfully added.';
			else if(res == 2)
				text = 'Спасибо! Комментарий успешно добавлен.';
			else if(res == 3)
				text = 'Wrong e-mail, update page and enter the correct address.';
			else if(res == 4)
				text = 'Неправильный формат e-mail, обновите страницу и введите правильный адрес.';
			else if(res == 5)
				text = 'Error, repeat attempt or address in technical support service.';
			else if(res == 6)
				text = 'Ошибка, повторите попытку или обратитесь в службу техподдержки.';
			else if(res == 7)
				text = 'This comment is already added.';
			else if(res == 8)
				text = 'Этот комментарий уже добавлен.';
			else if(res == 9)
				text = 'The comment will be added after check by a moderator.';
			else if(res == 10)
				text = 'Комментарий будет добавлен после проверки модератором.';
			if(res == 1 || res == 2){
				if(document.getElementById('nocomment'))
					document.getElementById('nocomment').style.display = 'none';
				document.getElementById('new_comment_block').style.display = 'block';
				document.getElementById('new_comment').innerHTML = comment;
				document.getElementById('new_comment_name').innerHTML = name;
			}
			oDiv.innerHTML = text;
		}
		makeRequest(request, func, '/comments/', 'POST', post);
	}else{
		errorDiv = document.getElementById('comment_error');
		errorDiv.style.display = 'block';
		errorDiv.innerHTML = error;
		return false;
	}
}

function showScreenshot(num, id, path, dir){
	if(!path)
		path = '640-480';
	if(!dir)
		dir = 'gamehappy';
	oMsgForm = new ModalWindow('modal1', 650, 490);
	HTML = '<img class="screenshot" onclick="oMsgForm.close()" src="/f/i/'+dir+'/games/'+id+'/'+path+'_screenshot_'+num+'.jpg" alt="Загрузка скриншота '+num+'..."/>';
	oMsgForm.setContent(HTML);
	oMsgForm.show();
}

