function Zoom(xlink, width, height){
	if (width && height) {
		var img = window.open('','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,height=' + height + ',width=' + width);
		if (navigator.userAgent.indexOf("Opera") == -1) {
			img.document.writeln('<html><body bgcolor="#D6D3CE" style="padding: 0px; margin: 0px; border: 0px;"><div id="text" style="width: 100%; height: 100%; text-align: center; padding-top: 40px; font-family: tahoma; font-size: 12px;">Загрузка изображения...</div><div id="image" style="display: none;"><img src="' + xlink + '" alt="" onload="document.getElementById(\'text\').style.display = \'none\'; document.getElementById(\'image\').style.display = \'block\';" /></div></body></html>');
		} else {
			img.document.writeln('<html><body bgcolor="#D6D3CE" style="padding: 0px; margin: 0px; border: 0px;"><div id="image" style="display: block;"><img src="' + xlink + '" alt="" onload="window.resizeTo(this.width+6, this.height+63)" /></div></body></html>');
		}
	} else {
		var img = window.open('','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,height=100,width=200');
		if (navigator.userAgent.indexOf("Opera") == -1) {
			img.document.writeln('<html><body bgcolor="#D6D3CE" style="padding: 0px; margin: 0px; border: 0px;"><div id="text" style="width: 100%; height: 100%; text-align: center; padding-top: 40px; font-family: tahoma; font-size: 12px;">Загрузка изображения...</div><div id="image" style="display: none;"><img src="' + xlink + '" alt="" onload="document.getElementById(\'text\').style.display = \'none\'; document.getElementById(\'image\').style.display = \'block\'; window.resizeTo(this.width+6, this.height+63)" /></div></body></html>');
		} else {
			img.document.writeln('<html><body bgcolor="#D6D3CE" style="padding: 0px; margin: 0px; border: 0px;"><div id="image" style="display: block;"><img src="' + xlink + '" alt="" onload="window.resizeTo(this.width+6, this.height+63)" /></div></body></html>');
		}
	}
}

function zooom(id) {
	var h = document.getElementById(id).innerHTML;
	document.getElementById(id).innerHTML = h ? '' : '<a href="javascript:zooom(' + "'" + id + "'" + ')"><img src="' + id + '" border="0" /></a>';
}

function checkVisibility(id) {
		
		var block = document.getElementById('block' + id);
		var treeimg = document.images('treeimg' + id);
		
		if (block.style.display == 'none') {
			block.style.display = 'block';
			treeimg.src = imgOut.src;
		} else {
			block.style.display = 'none';
			treeimg.src = imgOver.src;
		}
	}
	
	function Check(element, quantity) {

		if (element.value<0) element.value=element.value*-1;
		if (isNaN(element.value) || (element.value=='-') || (element.value>quantity)) {
			element.value = element.getAttribute('last-acceptable-value');
		} else if (element.value=='') {
			element.value = '0';
		} else {
			element.setAttribute('last-acceptable-value', element.value);
		}
		
		return true;
		
	}
	
	function imgPreload(imgOverSrc, imgOutSrc) {
		imgOver = new Image();
		imgOver.src = imgOverSrc;
		imgOut = new Image();
		imgOut.src = imgOutSrc;	
	}
	
	function imgover(imgname) {
		imgname.src = imgOver.src;
	}
	
	function imgout(imgname) {
		imgname.src = imgOut.src;
	} 

	function webimg(i) {
		document.getElementById('webimg').src = 'http://webcam.alpha.by/web' + (cam+1) + '.jpg?i=' + i;
		to = window.setTimeout("webimg(" + (i+1) + ")", 15500);
	}
	
	function nextCam() {
		cam = (!cams[(cam+1)] ? 0 : cam+1);
		var nextCam = (!cams[(cam+1)] ? 0 : cam+1);
		document.getElementById('webname').innerHTML = cams[cam];
		document.getElementById('webhref').innerHTML = cams[nextCam];
		window.clearTimeout(to);
		webimg(d.getTime());
	}
	
	function camOpen() {
		var camWindow = window.open('/web/cam' + (cam+1) + '/', 'webcam', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,height=280,width=350');
		camWindow.focus();
	}

	function scrollUpdate() {
		window.parent.document.getElementById('mrq').innerHTML = document.getElementById('scroll').innerHTML;
	}
