//	убийца фреймов
if(window != top) { top.location.href = location.href; }

//	функция выбора User-Agent
function change_ua() {
	var usag = document.getElementById('usag').value;
	var ua = [[navigator.userAgent],
	['Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)'],
	['Opera/9.80 (Windows NT 6.1; U; ru) Presto/2.7.62 Version/11.00'],
	['Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13'],
	['Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.6 (KHTML, like Gecko) Chrome/7.0.503.0 Safari/534.6'],
	['Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)'],
	['Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'],
	['StackRambler/2.0 (MSIE incompatible)'],
	['Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)'],
	['WebAlta Crawler/1.3.25 (http://www.webalta.net/ru/about_webmaster.html) (Windows; U; Windows NT 5.1; ru-RU)'],
	['Msnbot/1.0 (+http://search.msn.com/msnbot.htm)'],
	['Wget/1.9'],
	['']];
	if(!ua[usag]) { ua[usag] = ''; }
	if(ua[usag] == '') { document.getElementById('ua').focus(); }
	document.getElementById('ua').value = ua[usag];
}
function sp_usag(selected) {
	document.write('<select name="usag" id="usag" onChange="javascript:change_ua();">'+
	'<option value="0">Мой браузер</option>'+
	'<option value="1">Internet Explorer</option>'+
	'<option value="2">Opera</option>'+
	'<option value="3">Mozilla Firefox</option>'+
	'<option value="4">Google Chrome</option>'+
	'<option value="5">Yandex</option>'+
	'<option value="6">Googlebot</option>'+
	'<option value="7">Rambler</option>'+
	'<option value="8">Yahoo! Slurp</option>'+
	'<option value="9">WebAlta Crawler</option>'+
	'<option value="10">Msnbot</option>'+
	'<option value="11">wget</option>'+
	'<option value="12">Отсутствует (другой)</option>'+
	'</select><br />');
	document.getElementById('usag').value = selected;
	document.getElementById('url').focus();
	if(selected == 0 && document.getElementById('ua').value == '') { change_ua(); }
}

//	функция выбора If-Modified-Since
function change_ims(time) {
	var ms = document.getElementById('spims').value;

	var time = new Date(time);

	if(ms == 1) { }
	else if(ms == 2) { time.setHours(time.getHours() - 1); }
	else if(ms == 3) { time.setHours(time.getHours() - 6); }
	else if(ms == 4) { time.setDate(time.getDate() - 1); }
	else if(ms == 5) { time.setDate(time.getDate() - 7); }
	else if(ms == 6) { time.setMonth(time.getMonth() - 1); }
	else if(ms == 7) { time.setFullYear(time.getFullYear() - 1); }
	else if(ms == 8) { var time = new Date(0); }
	else { var time = false; }

	if(time) { var time = time.toUTCString(); }
	else { var time = ''; }

	document.getElementById('ims').value = time;
}
function sp_ims(selected) {
	var time = new Date();
	var time = time.getTime();
	document.write('<select name="spims" id="spims" onChange="javascript:change_ims('+time+');">'+
	'<option value="0">Отсутствует</option>'+
	'<option value="1">Текущее время</option>'+
	'<option value="2">Час</option>'+
	'<option value="3">6 часов</option>'+
	'<option value="4">Сутки</option>'+
	'<option value="5">Неделя</option>'+
	'<option value="6">Месяц</option>'+
	'<option value="7">Год</option>'+
	'<option value="8">1 января 1970 года</option>'+
	'</select><br />');
	document.getElementById('spims').value = selected;
}

//	функция скрытия поля выбора кодировки
function cod_pr() {
	if(document.getElementById('ph').checked) {
		document.getElementById('kd').style.color = '#111';
		document.getElementById('cod').style.color = '#111';
		document.getElementById('cod').disabled = false;
	}
	else {
		document.getElementById('kd').style.color = '#BBB';
		document.getElementById('cod').style.color = '#BBB';
		document.getElementById('cod').disabled = true;
	}
}

//	функция дописывает значение поля 'url' в значение 'action' формы
function sm_url(ex) {
	var uri = document.getElementById('url').value;
	if(uri) {
		//document.getElementById('f1').action = 'http://www.bertal.ru/index.php?url='+encodeURIComponent(uri)+'&ex='+ex+'&rb=m#h';
		return true;
	}
	else {
		alert('Заполните поле «URL»');
		document.getElementById('url').focus();
		return false;
	}
}

//	функция обновления копирайта
function copy() {
	if(document.getElementById('cod')) { cod_pr(); }
	var today = new Date();
	var year = today.getFullYear();
	document.write('-'+year+'<script type="text/javascript" src="//yandex.st/share/share.js" charset="utf-8"></script><div class="yashare-auto-init" data-yashareType="link" data-yashareQuickServices="vkontakte,facebook,odnoklassniki,moimir,twitter,lj"></div>');
}
