	function vote_screen (formular) {
		if( !formular.sc ) {
			var input = document.createElement('input');
			input.setAttribute('type', 'hidden');
			input.setAttribute('name', 'sc');
			//input.setAttribute('value', screen.width+"."+screen.height+"."+screen.colorDepth );
			input.setAttribute('value', screen.width+(screen.height/2)+(screen.colorDepth/16) );
			
			formular.appendChild(input);
		}
	}
	
var keypressed = false;

	function keypress(e) {
	
		if(navigator.userAgent.indexOf("Opera") >-1 )
			e = event.keyCode;

		if( keypressed == false ) {
			keypressed = true;

			if( document.getElementById('canvas_all') && document.getElementById('canvas_all').style.display != 'none' ) {
				if(e == 37)
					canvas_prev();
				else if(e == 39)
					canvas_next();
				else if(e == 27)
					canvas_hide();
				else if(e == 32) {
					if( presentation )
						canvas_autos();
					else
						canvas_auto();
				}
			}
		}
	}

//========================== GALERIE - CANVAS show ==========================================

	function canvas_center() {
		
		if( document.getElementById('canvas') && document.getElementById('canvas').style.display != 'none' ) {
			var canvas = document.getElementById('canvas');
			canvas.style.marginLeft = (document.body.clientWidth-canvas.offsetWidth)/2+'px';
		
		}
	}

	function canvas_show(tento) {
		if( document.getElementById('canvas_all') )
		{
			var canvas_all = document.getElementById('canvas_all');
			var canvas = document.getElementById('canvas');
			var canvas_nacit = document.getElementById('canvas_nacit');
			var canvas_photo = document.getElementById('canvas_photo');
			var canvas_actual = document.getElementById('canvas_actual');
			
			canvas_all.style.display = 'block';
			canvas_nacit.style.backgroundImage = canvas_nacit.style.backgroundImage;
			
			var a = tento.getElementsByTagName('img');
			a = explode('ę', a[0].alt);

			canvas.style.width = a[1]+'px';
			canvas_photo.style.width = a[1]+'px';
			canvas_photo.style.height = a[2]+'px';
			//canvas.style.marginLeft = (screen.availWidth-canvas.offsetWidth)/2+'px';
			//canvas.style.marginLeft = (document.body.clientWidth-canvas.offsetWidth)/2+'px';
			canvas_center();

			canvas_photo.style.backgroundImage = "url('"+a[3]+"')";
	
			var thumbnails = tento.parentNode.getElementsByTagName('img');
			for(i = 0; i < thumbnails.length; i++ ) {
				a = explode('ę', thumbnails[i].alt);
				if(tento.id == 'foto'+a[0])
					tento_num = i;
			}	
			if( canvas_actual )
				canvas_actual.innerHTML = tento_num+1;

			dalsi = tento_num + 1;
			if( dalsi > thumbnails.length-1 )
				dalsi = 0;
			predchozi = tento_num - 1;
			if( predchozi < 0 )
				predchozi = thumbnails.length-1;
			
			//a = dalsi.getElementsByTagName('img');
			a = explode('ę', thumbnails[dalsi].alt);
			path = a[3];
			//a = predchozi.getElementsByTagName('img');
			a = explode('ę', thumbnails[predchozi].alt);
			preload_images(path, a[3]);
			
			dalsi = thumbnails[dalsi].parentNode.parentNode;
			predchozi = thumbnails[predchozi].parentNode.parentNode;
		}
	}
	var preloaded = new Array();
	function preload_images() {
		for (var i = 0; i < arguments.length; i++){
			preloaded[i] = document.createElement('img');
			preloaded[i].setAttribute('src',arguments[i]);
		}
	}
	

	function canvas_next() {
		if( presentation ){
			canvas_autos();
			canvas_auto();
		}
		canvas_show(dalsi);
	}
	function canvas_prev() {
		if( presentation ){
			canvas_autos();
			canvas_auto();
		}
		canvas_show(predchozi);
	}
	function canvas_hide() {
		if( document.getElementById('canvas_all').style.display != 'none' ) {
			if( presentation )
				canvas_autos();
			document.getElementById('canvas_all').style.display = 'none';
			
		}
	}

	var canvas_timeri;
	var presentation_interval = 2500;
	var presentation_timer = presentation_interval;
	var presentation_speed = 100;
	var presentation = false;

	function canvas_auto() {
		if( document.getElementById('canvas_start') || document.getElementById('canvas_stop') ) {
	
			document.getElementById('canvas_time').style.width = '100%';
			document.getElementById('canvas_start').style.display = 'none';
			document.getElementById('canvas_stop').style.display = 'block';
			document.getElementById('canvas_timeline').style.visibility = 'visible';
			presentation = true;
			presentation_timer = presentation_interval;
			canvas_timeri = window.setInterval('canvas_timer()', presentation_speed);
		}
	}
	function canvas_autos() {
		clearInterval(canvas_timeri);
		document.getElementById('canvas_stop').style.display = 'none';
		document.getElementById('canvas_start').style.display = 'block';
		document.getElementById('canvas_timeline').style.visibility = 'hidden';
		presentation = false;
	}
	function canvas_timer() {
		if(presentation_timer > 0 ) {
			presentation_timer -= presentation_speed;

			step = presentation_interval / presentation_speed;
			document.getElementById('canvas_time').style.width = presentation_timer/step +'%';
			
			/*
			if( navigator.appName == 'Microsoft Internet Explorer' ) {
				document.getElementById('navig').style.display = 'none';
				document.getElementById('navig').style.display = 'block';
			}*/
		}
		else {
			presentation_timer = presentation_interval;
			canvas_next();
		}
	}



//======================= smile =========================================

	function smile(val) {
		insertAtCaret(document.getElementById('zprava'), val);
	}
	
	function insertAtCaret(obj, text) {
		if(document.selection) {
			obj.focus();
			var orig = obj.value.replace(/\r\n/g, "\n");
			var range = document.selection.createRange();

			if(range.parentElement() != obj) {
				return false;
			}

			range.text = text;
			
			var actual = tmp = obj.value.replace(/\r\n/g, "\n");

			for(var diff = 0; diff < orig.length; diff++) {
				if(orig.charAt(diff) != actual.charAt(diff)) break;
			}

			for(var index = 0, start = 0; 
				tmp.match(text) 
					&& (tmp = tmp.replace(text, "")) 
					&& index <= diff; 
				index = start + text.length
			) {
				start = actual.indexOf(text, index);
			}
		} else if(obj.selectionStart) {
			var start = obj.selectionStart;
			var end   = obj.selectionEnd;

			obj.value = obj.value.substr(0, start) 
				+ text 
				+ obj.value.substr(end, obj.value.length);
		}
		
		if(start != null) {
			setCaretTo(obj, start + text.length);
		} else {
			obj.value += text;
		}
	}
	function setCaretTo(obj, pos) {
		if(obj.createTextRange) {
			var range = obj.createTextRange();
			range.move('character', pos);
			range.select();
		} else if(obj.selectionStart) {
			obj.focus();
			obj.setSelectionRange(pos, pos);
		}
	}

	function book(id,type) {
		document.getElementById('stranky').value = type+':'+id;
	}