function checkFlash() {
	window.setTimeout("appearFlash()",1000);
}

function appearFlash() {
	if($('flash').innerHtml != '') {
		Effect.Appear('flash', { duration: 1.0 });
		window.setTimeout("disapearFlash()",4000);
	}
}
function disapearFlash() {
	Effect.Fade('flash', { duration: 1.0 });
}
var lastId;

  function hideMenuOverlay(left,position) {
        $('matrixOverlay').hide();
	if(left == 1) {
	  $('left'+parseInt(position)+'_on').hide();
	  $('left'+parseInt(position)+'_off').show();
	  $('left'+parseInt(position)).removeClassName('selected');
	} else {
	  $('top'+parseInt(position)+'_on').hide();
	  $('top'+parseInt(position)+'_off').show();
	  $('top'+parseInt(position)).removeClassName('selected');
	}
	Element.getElementsByClassName('matrix','selected').each(function(item) {
	  item.removeClassName('selected');
	  item.setStyle({ 'border-right-color': '#C4C9BE','border-left-color': '#C4C9BE', 'border-bottom-color': '#C4C9BE','border-top-color': '#C4C9BE'});
	 
	  $(item.id+'_on').hide();
	  $(item.id+'_off').show();
	});
  }
  function showMenuOverlay(left, rows, cols,imageId) {
		if(!lastId) {
			lastId  = $('matrix_image').descendants()[0];
		}
		if($(imageId) || imageId == '') {
			$('matrixOverlay').hide();
			$('matrixOverlay').setStyle({
				opacity:1
			});
			if(left == 1) {
				hideMenuOverlay(left,rows[0]);
			} else {
				hideMenuOverlay(left,cols[0]);
			}
			var iColWidth = 105;
			var iRowHeight = 32;
			var iRowOffset = 26;
			var iColOffset = 0;

			var iMaxRow = 1;
			var iMaxCol = 1;
			$('matrixOverlay').update();
			for(var index=0; index < rows.length; index++) { 
				if(parseInt(rows[index]) > iMaxRow) {
					iMaxRow = parseInt(rows[index]);
				}
				if(left == 0) {
				   $('left'+rows[index]).addClassName('selected');
				   $('left'+rows[index]+'_on').show();
				   $('left'+rows[index]+'_off').hide();
				}
			}

			for(var index=0; index < cols.length; index++) {
				if(parseInt(cols[index]) > iMaxCol) {
					iMaxCol = parseInt(cols[index]);
				}
				if(left == 1) {
				   $('top'+cols[index]).addClassName('selected');
				   $('top'+cols[index]+'_on').show();
				   $('top'+cols[index]+'_off').hide();
				}
			}	
		
		        if(left == 1) {
			        $('left'+parseInt(rows[0])+'_on').show();
			        $('left'+parseInt(rows[0])+'_off').hide();
				$('left'+parseInt(rows[0])).addClassName('selected');
			        lastSelected = 0;
				maxCols = $('matrix_top').immediateDescendants().length;
		                for(var index=1; index <= maxCols; index++) {
				   if($('top'+index).hasClassName('selected')) {
				      if(lastSelected == 1) {
				         $('top'+index).setStyle({'border-left-color':'white'});
				      }
				      if((index+1) <= maxCols) {
				         if($('top'+(index+1)).hasClassName('selected')) {
					    $('top'+index).setStyle({'border-right-color':'white'});
					 }
				      }
				      lastSelected = 1;
				   } else {
				      lastSelected = 0;
				   }
				}
			} else {
			        $('top'+parseInt(cols[0])+'_on').show();
			        $('top'+parseInt(cols[0])+'_off').hide();
				$('top'+parseInt(cols[0])).addClassName('selected');
			        lastSelected = 0;
				maxRows = $('matrix_left').immediateDescendants().length;
		                for(var index=1; index <= maxRows; index++) {
				   if($('left'+index).hasClassName('selected')) {
				      if(lastSelected == 1) {
				         $('left'+index).setStyle({'border-top-color':'white'});
				      }
				      if((index+1) <= maxRows) {
				         if($('left'+(index+1)).hasClassName('selected')) {
					    $('left'+index).setStyle({'border-bottom-color':'white'});
					 }
				      }
				      lastSelected = 1;
				   } else {
				      lastSelected = 0;
				   }
				}

			}

			for(var index=0; index < rows.length; index++) {
				$('matrixOverlay').update($('matrixOverlay').innerHTML+'<div class="matrix_bars" style="opacity:0.5; filter:Alpha(opacity=50);width:'+(iMaxCol*iColWidth+iColOffset)+'px;top:'+(iRowHeight*(rows[index]-1)+iRowOffset)+'px;"></div>');
			}
			for(var index=0; index < cols.length; index++) {
				$('matrixOverlay').update($('matrixOverlay').innerHTML+'<div class="matrix_rows" style="opacity:0.5; filter:Alpha(opacity=50);height:'+(iMaxRow*iRowHeight+iRowOffset)+'px;left:'+(iColWidth*(cols[index]-1)+iColOffset)+'px;"></div>');
			}	
			if(imageId != '' && lastId != imageId) {
			        $(lastId).addClassName('ztop');
                                $(lastId).hide();
				$(imageId).show();
				$(lastId).removeClassName('ztop');
				lastId = imageId;
			}
			// Matrix vorŸbergehend ausgeschaltet $('matrixOverlay').show();

			//Effect.Appear('matrixOverlay',{duration: 0.2, to: 0.5});
			//$('matrixOverlay').setStyle({opacity:0.5});
		}

	}

