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 ddlistHeaders = [];
		var ddlistItems = [];
		var _ddlistHeaders = document.getElementById('ddlist').getElementsByTagName('dt');
		var _ddlistItems = document.getElementById('ddlist').getElementsByTagName('dd');
		for (var i=0; i<_ddlistHeaders.length; i++) {
			//alert(_ddlistHeaders[i].parentNode.className)
			if(_ddlistHeaders[i].parentNode.className!='list2') {
				ddlistHeaders.push(_ddlistHeaders[i]);
				ddlistItems.push(_ddlistItems[i]);
			}
		}

		for (var i=0; i<ddlistHeaders.length; i++) {
			ddlistHeaders[i].count = i;
			ddlistHeaders[i].onclick = function() {
				if (this.className!='active') {
					this.className='active';
					ddlistItems[this.count].style.display = 'block';
					for (var j=0; j<ddlistHeaders.length; j++) {
						if (this.count!=j) {
							ddlistHeaders[j].className="";
							ddlistItems[j].style.display = 'none';
						}
					}
				}
			}
		}
	}
	catch (error) {
//		alert (error)
	}
}

/*--/init--*/

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 popupPhoto(item) {
	_photo = window.open(
		item,
		'blank',
		'toolbar=0,location=0,statusbar=0,menubar=0, width=625,scrollbars=yes'
	);
	_photo.document.write('<html><body style="padding: 0; margin: 0;">');
	_photo.document.write('<img src="' + item + '" alt="" />');
	_photo.document.write('</body></html>');
	_photo.document.close();
}
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;
}
window.onload = init;