
function ShowHide(node_or_nodename, srcnode) {
	if (node_or_nodename.constructor.toString().indexOf("String") != -1) {
		node = $(node_or_nodename);
	} else {
		node = node_or_nodename;
	}
	if (!node) return;
	if (node.style.display == 'none') {
		node.style.display = '';

		if (this.oldnode && this.oldnode != node)
			this.oldnode.style.display = 'none';
		this.oldnode = node;

		if (srcnode) {
			srcnode.style.fontSize = '138%';
			srcnode.className = 'href';

			if (this.oldnode2 && this.oldnode2 != srcnode) {
				this.oldnode2.style.border = this.oldnode2.style.fontSize = '';
				this.oldnode2.className = 'cat';
			}
			this.oldnode2 = srcnode;
		}
	} else {
		node.style.display = 'none';
		if (srcnode) {
			srcnode.className = 'cat';
			srcnode.style.border = srcnode.style.fontSize = '';
		}
	}
	this.oldnode = node;
	RedrawIE();
	return false;
}
function $(id) {
	if (!this.cache) this.cache = new Array();
	if (this.cache[id]) return this.cache[id];
	return (this.cache[id] = document.getElementById(id));
}

function ColoriseTRs(parent_id, odd_class, unite_rows_with_class, exclude_table_with_class) {
	if (!odd_class) odd_class = "odd";
	if (!(tm = document.getElementById(parent_id))) return;
	var tables = tm.getElementsByTagName('table');

	for (var i = 0; i < tables.length; i++) {
		if (!tables[i].className.match(/tech/)) continue;

		var TRs = tables[i].getElementsByTagName('tr');
		var z = 1;
		for (var j = 1; j < TRs.length; j++) {
			if (TRs[j].className == 'header' || TRs[j].parentNode.parentNode != tables[i]) continue;
			if (TRs[j] && z % 2 && !TRs[j].className) {
				TRs[j].className = odd_class;
			}
			z++;
		}
	}
}

function OpenPic(node, width, height) {
	ur = node.href;
	str = '';
	title = node.title;
	if (!title)
		title = node.firstChild.title;

	if (width) {
		str += ',width=' + (width + 53);
		str += ',left=' + parseInt((screen.availWidth - (width + 53)) / 2)
	}
	if (height) {
		str += ',height=' + (height + 66);
		str += ',top=' + parseInt((screen.availHeight - (height + 66)) / 2)
	}

	resWidth = 61;
	resHeight = 115;
	if (navigator.userAgent.toLowerCase().indexOf("msie 6.") != -1) {
		resWidth = 65;
		resHeight = 117;
	} else if (navigator.userAgent.toLowerCase().indexOf("msie 7.") != -1) {
		resWidth = 67;
		resHeight = 130;
	}

	opts = 'resizable=yes,location=no,menubar=no,titlebar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=yes'+str;
	var a = window.open('about:blank','imagDetail',opts);
	var html = "<html><head><link type='text/css' rel='stylesheet' href='/css/main.css' /><\/head>";
	html += "<body style='margin:0px; text-align: center; vertical-align: middle'><div style='padding: 10px'>";
	html += "<img onclick='window.close()' ";
	html += "onload=\"window.resizeTo(Math.min(screen.availWidth+"+resWidth+",this.width+"+resWidth+"),Math.min(screen.availHeight+"+resHeight+",this.height+"+resHeight+"))\" ";
	html += "style='cursor:pointer; padding-bottom:10px' src='"+ur+"' alt='Закрыть' title='Закрыть' \/>";
	html += "<div>"+title+"<\/div>";
	html += "<\/div><\/body><\/html>";
	a.document.write(html);
	a.document.close();
	return false;
}

function SetOpenPic_item() {
	return OpenPic(this, 800, 600);
}
function SetOpenPic(id) {
	col = document.getElementById(id).getElementsByTagName('img');
	for (i = 0, len = col.length; i < len; i++) {
		var ch = new RegExp('\.(jpe?g|gif|png|bmp)$', 'i');
		if (col[i].parentNode.nodeName == 'A' && col[i].parentNode.href.match(ch) && !col[i].parentNode.onclick)
			col[i].parentNode.onclick = SetOpenPic_item;
	}

}

var agent = navigator.userAgent.toLowerCase();
var ie6 = (agent.indexOf("msie 6.")!=-1);
var ie7 = (agent.indexOf("msie 7.")!=-1);
var ie = (agent.indexOf('msie')!=-1);
var ienot7 = (ie && !ie7);
var ff = !ie && (agent.indexOf('mozilla') != -1);
var opera = !!window.opera;

function RedrawIE() {
	if (!ie6) return;
	if (!this.wr)
		this.wr = document.getElementById('wrap');

	this.wr.style.height = 'auto';
	this.wr.style.height = '';
	this.wr.style.width = '99%';
	this.wr.style.width = '';
	return true;
}

function HoverIt(node, hovertrue) {
	if (hovertrue)
		node.className += ' hover';
	else
		node.className = node.className.replace(/\s?hover/g, '');
}

imgnode = null;
function RollPics() {
	if (!this.v) {
		this.v = 1;
		curn = nagrad_current;
	}
	if (curn + this.v == nagrad.length) {
		nagrad_current = -1;
	}
	curn = nagrad_current + this.v;

	//while ( (curn = Math.floor(Math.random() * nagrad.length) ) == nagrad_current) {}
	cur = nagrad[curn];
	nagrad_current = curn;

	tmp = new Image;
	tmp.src = imgnode.src;
	tmp.style.position = 'absolute';
	imgnode.parentNode.insertBefore(tmp, imgnode);

	imgnode.src = imgnode.src.replace(/thumb_.*/, 'thumb_' + cur.file);
	imgnode.fullWidth = cur.width;
	imgnode.fullHeight = cur.height;
	imgnode.parentNode.href = imgnode.src.replace(/thumb_/, '');
	imgnode.style.position = 'relative';
	imgnode.zopacity = 0.00;
	imgnode.style.filter = 'alpha(opacity=0)'



	if (imgnode.complete) {
		RollPics_trans();
	} else
		imgnode.onload = RollPics_trans;

}
function RollPics_trans() {

	imgnode.zopacity += 0.03;
	imgnode.style.opacity = imgnode.zopacity;
	imgnode.style.filter = 'alpha(opacity=' + (Math.round(imgnode.zopacity * 100)) + ')';

	if (imgnode.style.opacity > 0.999) {
		imgnode.style.opacity = 1;
		imgnode.style.position = '';
		imgnode.parentNode.removeChild(imgnode.previousSibling);
		setTimeout("RollPics()", 2000);
	} else
		setTimeout("RollPics_trans()", 50);
}

function CheckCont(node) {
	if (!this.doc)
		this.doc = document.getElementById('cont_file');

	if (node.value == 3 || node.value == 2)
		this.doc.style.display = '';
	else
		this.doc.style.display = 'none';




}


function initNewItems(node) {
	node = document.getElementById(node);

	for (i=0; i < node.childNodes.length; i++) {
		cur = node.childNodes[i];
		if (cur.firstChild) {
			cur.firstChild.onmouseover = function() {
				this.parentNode.className += ' hover';
			}
			cur.firstChild.onmouseout = function() {
				this.parentNode.className = this.className.replace(/\s?hover/g, '');
			}
		}
	}

}

