var end_opacity;  
    var increase_opacity_by;  
   var timeout;  
    var win;  
    var winbackground;  
   var wincontent;  
   var cur_opacity;   
     
 function load() {  
end_opacity = 90; //end opacity, 25 = 25%, 50 = 50%, 100 = 100%, etc.  
increase_opacity_by = 10; //how much to increase by each time the timeout ends  
timeout = 30; //timeout in miliseconds, 0 = instant fade-out  


 cur_opacity = 0;  
}  

function showWindow(id) {
if (id == 1) {
win = document.getElementById('regwindow');  
winbackground = document.getElementById('regwindowbackground');  
wincontent = document.getElementById('regwindowcontent');
}
if (id == 2) {
win = document.getElementById('emwindow');  
winbackground = document.getElementById('emwindowbackground');  
wincontent = document.getElementById('emwindowcontent'); 
}
if (id == 3) {

win = document.getElementById('modwindow');  
winbackground = document.getElementById('modwindowbackground');  
wincontent = document.getElementById('modwindowcontent'); 
}


if(timeout > 0) {
cur_opacity = 0;
winbackground.style.opacity = cur_opacity / 100;
winbackground.style.filter = "alpha(opacity=" + cur_opacity + ")";
win.style.display = 'block';
wincontent.style.display = 'none';

timer = setTimeout("increase_opacity()",timeout);
} else {
winbackground.style.opacity = end_opacity / 100;
winbackground.style.filter = "alpha(opacity=" + end_opacity + ")";
win.style.display = 'block';
wincontent.style.display = 'block';
}

if (document.getElementById('banner1swf') != null) {
	document.getElementById('banner1swf').style.display='none';
}
if (document.getElementById('banner2swf') != null) {
	document.getElementById('banner2swf').style.display='none';
}
if (document.getElementById('banner3swf') != null) {
	document.getElementById('banner3swf').style.display='none';
}
if (document.getElementById('jatek') != null) {
	document.getElementById('jatek').style.display='none';
}
if (document.getElementById('fless') != null) {
	document.getElementById('fless').style.display='none';
}
 
}

function increase_opacity() {
cur_opacity += increase_opacity_by;

winbackground.style.opacity = cur_opacity / 100;
winbackground.style.filter = "alpha(opacity=" + cur_opacity + ")";

if(cur_opacity < end_opacity) {
timer = setTimeout("increase_opacity()",timeout);
}
else {
wincontent.style.display = 'block';
}
}

function hideWindow() {
win.style.display = 'none';
document.getElementById('fless').style.display='';
//document.getElementById('banner').style.display='';

if (document.getElementById('banner1swf') != null) {
	document.getElementById('banner1swf').style.display='';
}
if (document.getElementById('banner2swf') != null) {
	document.getElementById('banner2swf').style.display='';
}
if (document.getElementById('banner3swf') != null) {
	document.getElementById('banner3swf').style.display='';
}
document.getElementById('gamewin').style.display='';
}

function beszur(mit){
	var str=mit.split("#");
	document.getElementById('message').value += ' A játék('+str[1]+') linkje: http://www.playme.hu/games.php?g='+str[0]+'&jatek='+encodeURIComponent(str[1])+' ';
}

function CalcKeyCode(aChar) {
  var character = aChar.substring(0,1);
  var code = aChar.charCodeAt(0);
  return code;
}

function checkNumber(val,ossz) {
  var strPass = val.value;
  var strLength = strPass.length;
  var lchar = val.value.charAt((strLength) - 1);
  var cCode = CalcKeyCode(lchar);

  if (cCode < 48 || cCode > 57 ) {
    var myNumber = val.value.substring(0, (strLength) - 1);
    val.value = myNumber;
  }
  if (val.value>ossz){
	var myNumber = val.value.substring(0, (strLength) - 1);
    val.value = myNumber;
  }
  
  return false;
}