

function decToHex(n){
	
	var hexChars = "0123456789ABCDEF";

	if (n < 0) return "00";
	if (n > 255) return "FF";

	var h = Math.floor(n / 16)
	var l = n % 16

	return hexChars.charAt(h) + hexChars.charAt(l);
}




var per_opacity = 10;

function temno(message) {
	
	myOpacity = setInterval("opacity_temno()", 20);
	
}



function svetlo(){
	
	document.getElementById('window').style.display = 'none';
	
	myOpacity = setInterval("opacity_svetlo()", 20);	
	
}



function opacity_temno(){
	
	if(per_opacity > 4) per_opacity--;
		
	document.getElementById('layer').style.opacity = per_opacity/10;
	document.getElementById('layer').style.filter = 'alpha(opacity=' + per_opacity*10 + ')';

	if (per_opacity == 4){
		
		clearInterval(myOpacity);
		document.getElementById('window').style.display = 'block';
		
	}
	
}


function opacity_svetlo(){
	
	if(per_opacity < 10) per_opacity++;
		
	document.getElementById('layer').style.opacity = per_opacity/10;
	document.getElementById('layer').style.filter = 'alpha(opacity=' + per_opacity*10 + ')';

	if (per_opacity >= 10){
		
		clearInterval(myOpacity);
		document.getElementById('window').style.display = 'none';			
		
	}
	
}
