var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var newsYears = [];

function init () {
	try {
		var newsYear = getElementsByClassName("allnews")[0].getElementsByTagName("a");

		for (i=0; i<newsYear.length; i++) {
			if (newsYear[i].parentNode.parentNode.parentNode.className=="allnews") {
				newsYears.push(newsYear[i]);
			}
		}

		for (i=0; i<newsYears.length; i++) {
			newsYears[i].onclick = function () {
				//tmpClassName = this.className;
				for (j=0; j<newsYears.length; j++) {
					newsYears[j].parentNode.className = "";
				}
				this.parentNode.className = "active";

				return false;
			}
		}
	}
	catch (error) {
//		alert (error)
	}
	try {
		var supbt = document.getElementById('support').getElementsByTagName('a');
		var supitems = document.getElementById('support').getElementsByTagName('ul');
		for ( i = 0; i < supbt.length; i++ ) {
			supbt[i].count = i;
			supbt[i].onclick = function() {
				for ( j = 0; j<supbt.length; j++ ) {
					supitems[j].style.display = "none";
				}
				supitems[this.count].style.display = "block";
				return false;
			}
		}
	}
	catch (error) {
//		alert (error)
	}
	try {
		var pbt = document.getElementById('provs').getElementsByTagName('h1');
		var pitems = document.getElementById('provs').getElementsByTagName('table');
		for ( i = 0; i < pbt.length; i++ ) {
			pbt[i].count = i;
			pbt[i].onclick = function() {
				if (pitems[this.count].style.display != "block") {
					for ( j = 0; j<pbt.length; j++ ) {
						pitems[j].style.display = "none";
					}
					pitems[this.count].style.display = "block";
					return false;
				}
				else {
					pitems[this.count].style.display = "none";
				}
			}
		}
	}
	catch (error) {
//		alert (error)
	}
	try {
		var pbt = document.getElementById('provs6').getElementsByTagName('h6');
		var pitems = document.getElementById('provs6').getElementsByTagName('table');
		for ( i = 0; i < pbt.length; i++ ) {
			pbt[i].count = i;
			pbt[i].onclick = function() {
				if (pitems[this.count].style.display != "block") {
					for ( j = 0; j<pbt.length; j++ ) {
						pitems[j].style.display = "none";
					}
					pitems[this.count].style.display = "block";
					return false;
				}
				else {
					pitems[this.count].style.display = "none";
				}
			}
		}
	}
	catch (error) {
//		alert (error)
	}
}

function getElementsByClassName(classname, node) {
	if(!node) node = document.getElementsByTagName("body")[0];
	var a = [];
	var re = new RegExp('\\b' + classname + '\\b');
	var els = node.getElementsByTagName("*");
	for(var i=0,j=els.length; i<j; i++)
	if(re.test(els[i].className)) a.push(els[i]);
	return a;
}

/*function _event (evt) {
	if (!evt) {
		evt = event;
	}
	var ev = (evt.srcElement) ? evt.srcElement : evt.target;
	return ev;
}*/

/*function mouseXY(e) {
	var x = 0, y = 0;

	if (!e) e = window.event;

	if (e.pageX || e.pageY) {
		x = e.pageX;
		y = e.pageY;
	}
	else if (e.clientX || e.clientY) {
		x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
		y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
	}
	return {"x": x, "y": y};
}*/
function main_DoFSCommand(command, args) {
	var mainObj = isInternetExplorer ? document.all.main : document.main;
	if (command.indexOf("popup")!=-1) {
		popupItem("/terminals/" + args + "/");
	}
}
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language="VBScript">\n');
	document.write('On Error Resume Next\n');
	document.write('Sub main_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call main_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}

function popupItem(item) {
	window.open(
		item,
		'_blank',
		'toolbar=0,location=0,statusbar=0,menubar=0,width=500,left=20,top=20,scrollbars=yes'
	);
}
function color(pic) {
	document.getElementById('image').src='/imgs/terminals/'+pic;
}

validContacts=function(){
if(document.form1.name.value.length<1){
alert("Введите имя");
return false;
}
if(document.form1.email.value.length<1){
alert("Введите e-mail");
return false;
}
if(document.form1.phone.value.length<1){
alert("Введите контактный телефон");
return false;
}
if(document.form1.company.value.length<1){
alert("Введите название компании");
return false;
}
return true;
}

validConnect=function(){
if(document.form1.company.value.length<1){
alert("Введите название компании");
return false;
}
if(document.form1.company.value.length<1){
alert("Введите профиль деятельности");
return false;
}
if(document.form1.name.value.length<1){
alert("Введите контактное лицо");
return false;
}
if(document.form1.email.value.length<1){
alert("Введите e-mail");
return false;
}
if(document.form1.phone.value.length<1){
alert("Введите контактный телефон");
return false;
}
return true;
}

function checkPaymentQuestion(form) {
	if (form.name.value == "") {
		form.name.focus();
		return false;
	}
	if (form.email.value == "") {
		form.email.focus();
		return false;
	}
	if (form.payment.value == "") {
		form.payment.focus();
		return false;
	}
	if (form.terminal.value == "") {
		form.terminal.focus();
		return false;
	}
	if (form.date.value == "") {
		form.date.focus();
		return false;
	}
	if (form.account.value == "") {
		form.account.focus();
		return false;
	}
	if (form.question.value == "") {
		form.question.focus();
		return false;
	}

	return true;
}


window.onload = init;