window.onresize = resizeWindow; 

home_on = new Image(); home_on.src = "../images/button_home_on.png";
home_off = new Image(); home_off.src = "../images/button_home_off.png";

galerien_on = new Image(); galerien_on.src = "../images/button_galerien_on.png";
galerien_off = new Image(); galerien_off.src = "../images/button_galerien_off.png";

zitate_on = new Image(); zitate_on.src = "../images/button_zitate_on.png";
zitate_off = new Image(); zitate_off.src = "../images/button_zitate_off.png";

gaestebuch_on = new Image(); gaestebuch_on.src = "../images/button_gaestebuch_on.png";
gaestebuch_off = new Image(); gaestebuch_off.src = "../images/button_gaestebuch_off.png";

function imageon(bildname) 
{
	document[bildname].src=eval(bildname + "_on.src");
}

function imageoff(bildname) 
{
	document[bildname].src=eval(bildname + "_off.src");
}


function mouseOn(id,className)
{
	document.getElementById(id).className = className + '_on';	
}

function mouseOut(id,className)
{		
	document.getElementById(id).className = className + '_off';		
}


/* Anmerkung: Mozille gibt die Farbwerte als RGB wieder; toll oder? */

function setTableBackgroundGB(theTable, theEvent, theDefaultColor, thePointerColor, theMarkColor)
{
	theTable = document.getElementById(theTable);
	
	var theRows = null;
    var theCells = null;
    
    
    if (typeof(document.getElementsByTagName) != 'undefined') 
    {
        
    	theRows = theTable.getElementsByTagName('tr');
    }
    else if (typeof(theTable.rows) != 'undefined') 
    {
        theRows = theTable.rows;
        
    }
    else 
    {
            return false;
	}

    var rowCnt 		 = theRows.length;
    var newColor     = null;

    var topLeft = null;
    if (typeof(document.getElementsByTagName) != 'undefined') 
    {
        theCells = theRows[0].getElementsByTagName('td');
    }
    else if (typeof( theRows[0].cells) != 'undefined') 
    {
        theCells =  theRows[0].cells;
    }
    else 
    {
            return false;
	}	
	
    
    if(	theEvent=='click' && 
    	( 
    		theCells[0].style.backgroundColor.toLowerCase() != theMarkColor.toLowerCase() &&
    		rgbtohexa(theCells[0].style.backgroundColor.toLowerCase()) !=  theMarkColor.toLowerCase()
    	)
    )
    {
    	newColor=theMarkColor;
    } 
    else if (theEvent=='click' && 
    			(	theCells[0].style.backgroundColor.toLowerCase()==theMarkColor.toLowerCase() ||
    				rgbtohexa(theCells[0].style.backgroundColor.toLowerCase())== theMarkColor.toLowerCase()
    			)
    		) 
    {
    	newColor=thePointerColor;
    } 
    else if(theEvent=='over' && ( 
    		theCells[0].style.backgroundColor.toLowerCase() != theMarkColor.toLowerCase() &&
    		rgbtohexa(theCells[0].style.backgroundColor.toLowerCase()) != theMarkColor.toLowerCase()
    	)
    ) 
    {
        newColor=thePointerColor;
    }
    else if(theEvent=='out' && 
    			( 
    			theCells[0].style.backgroundColor.toLowerCase() != theMarkColor.toLowerCase() &&
    			rgbtohexa(theCells[0].style.backgroundColor.toLowerCase()) != theMarkColor.toLowerCase()
    			)
    )
    {
    	newColor=theDefaultColor;
    }
    
    if (newColor) 
    {
        var c = null;
        var d = null;
        	for(d = 2; d < rowCnt; d++)
        	{
	        	theCells = null;
	        	if (typeof(document.getElementsByTagName) != 'undefined') 
			    {
			        theCells = theRows[d].getElementsByTagName('td');
			    }
			    else if (typeof( theRows[d].cells) != 'undefined') 
			    {
			        theCells =  theRows[d].cells;
			    }
			    else 
			    {
			            return false;
				}	
						
	        	rowCellsCnt = theCells.length; 
        		for (c = 0; c < rowCellsCnt; c++) 
	            {	
	            	theCells[c].style.backgroundColor = newColor;
	            }
        	}
    }     
}


function setPointerWithLink(theRow, theEvent, theDefaultColor, thePointerColor, theMarkColor)
{
 	theRow=document.getElementById(theRow);
    var theCells = null;
    if (typeof(document.getElementsByTagName) != 'undefined') 
    {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') 
    {
        theCells = theRow.cells;
    }
    else 
    {
            return false;
	}

    var rowCellsCnt  = theCells.length;
    var newColor     = null;

    if(	theEvent=='click' && 
    	( 
    		theCells[0].style.backgroundColor.toLowerCase() != theMarkColor.toLowerCase() &&
    		rgbtohexa(theCells[0].style.backgroundColor.toLowerCase()) !=theMarkColor.toLowerCase()
    	)
    )
    {
    	newColor=theMarkColor;
    } 
    else if (theEvent=='click' && 
    			(	theCells[0].style.backgroundColor.toLowerCase()==theMarkColor.toLowerCase() ||
    				rgbtohexa(theCells[0].style.backgroundColor.toLowerCase())==theMarkColor.toLowerCase()
    			)
    		) 
    {
    	newColor=thePointerColor;
    } 
    else if(theEvent=='over' && ( 
    		theCells[0].style.backgroundColor.toLowerCase() != theMarkColor.toLowerCase() &&
    		rgbtohexa(theCells[0].style.backgroundColor.toLowerCase()) !=theMarkColor.toLowerCase()
    	)
    ) 
    {
        newColor=thePointerColor;
    }
    else if(theEvent=='out' && 
    			( 
    			theCells[0].style.backgroundColor.toLowerCase() != theMarkColor.toLowerCase() &&
    			rgbtohexa(theCells[0].style.backgroundColor.toLowerCase()) !=theMarkColor.toLowerCase()
    			)
    )
    {
    	newColor=theDefaultColor;
    }
    
    if (newColor) 
    {
        var c = null;
            for (c = 0; c < rowCellsCnt; c++) 
            {	
					theCells[c].style.backgroundColor = newColor;
            }
    }     
}

function checkLine(theRow, theCheckBox, theEvent, theDefaultColor, thePointerColor, theMarkColor)
{
		theRow=document.getElementById(theRow);
		theCheckBox=document.getElementById(theCheckBox);

        var theCells = null;
        if (typeof(document.getElementsByTagName) != 'undefined') {
            theCells = theRow.getElementsByTagName('td');
        }
        else if (typeof(theRow.cells) != 'undefined') {
            theCells = theRow.cells;
        }
        else {
            return false;
        }

        var rowCellsCnt  = theCells.length;
        var newColor     = null;
         
        if (theCheckBox.checked==true) 
        {
            newColor=theMarkColor;
        } 
        else if(theEvent=='over')
        {
            newColor=thePointerColor;
        }
        else
        {
        	newColor=theDefaultColor;
        }
        
        if (newColor) 
        {
            var c = null;
                for (c = 0; c < rowCellsCnt; c++) 
                {	
						theCells[c].style.backgroundColor = newColor;
                }
        }       
}

function rgbtohexa(string)
{
	var red; 
	var green;
	var blue;
	red = string.substring(4,string.indexOf(','));
	green = string.substring(string.indexOf(',')+1,string.lastIndexOf(','));
	blue = string.substring(string.lastIndexOf(',')+1,string.lastIndexOf(')'));
	
	
	
	var Sred;
	var Sgreen;
	var Sblue;
	var tmp, tmp2;
	
	tmp = Math.floor(red/16);
	tmp2 = red%16;
	
	if(tmp == 10) Sred='a';
	else if(tmp == 11) Sred='b';
	else if(tmp == 12) Sred='c';
	else if(tmp == 13) Sred='d';
	else if(tmp == 14) Sred='e';
	else if(tmp == 15) Sred='f';
	else Sred = "" + tmp;
	
	if(tmp2 == 10) Sred=Sred +'a';
	else if(tmp2 == 11) Sred=Sred +'b';
	else if(tmp2 == 12) Sred=Sred +'c';
	else if(tmp2 == 13) Sred=Sred +'d';
	else if(tmp2 == 14) Sred=Sred +'e';
	else if(tmp2 == 15) Sred=Sred +'f';
	else Sred = Sred + "" + tmp2;

	tmp = Math.floor(green/16);
	tmp2 = green%16;
	
	if(tmp == 10) Sgreen='a';
	else if(tmp == 11) Sgreen='b';
	else if(tmp == 12) Sgreen='c';
	else if(tmp == 13) Sgreen='d';
	else if(tmp == 14) Sgreen='e';
	else if(tmp == 15) Sgreen='f';
	else Sgreen = "" + tmp;
	
	if(tmp2 == 10) Sgreen=Sgreen +'a';
	else if(tmp2 == 11) Sgreen=Sgreen +'b';
	else if(tmp2 == 12) Sgreen=Sgreen +'c';
	else if(tmp2 == 13) Sgreen=Sgreen +'d';
	else if(tmp2 == 14) Sgreen=Sgreen +'e';
	else if(tmp2 == 15) Sgreen=Sgreen +'f';
	else Sgreen = Sgreen + "" + tmp2;
	
	tmp = Math.floor(blue/16);
	tmp2 = blue%16;
	
	if(tmp == 10) Sblue='a';
	else if(tmp == 11) Sblue='b';
	else if(tmp == 12) Sblue='c';
	else if(tmp == 13) Sblue='d';
	else if(tmp == 14) Sblue='e';
	else if(tmp == 15) Sblue='f';
	else Sblue = "" + tmp;
	
	if(tmp2 == 10) Sblue=Sblue +'a';
	else if(tmp2 == 11) Sblue=Sblue +'b';
	else if(tmp2 == 12) Sblue=Sblue +'c';
	else if(tmp2 == 13) Sblue=Sblue +'d';
	else if(tmp2 == 14) Sblue=Sblue +'e';
	else if(tmp2 == 15) Sblue=Sblue +'f';
	else Sblue = Sblue + "" + tmp2;
	
	return "#" + Sred + Sgreen + Sblue;
	
}

function showandhide(id) 
{
	if(document.getElementById)
 	{
 		if( document.getElementById(id).style.display == "none" ) 
 		{
 			document.getElementById(id).style.display = "block";
 		}
 		else 
 		{ 		
	 		document.getElementById(id).style.display = "none";
 		}
 	}
};


function showandhideTwoEl(id1,id2) 
{
	if(document.getElementById)
 	{
 			document.getElementById(id1).style.display = "block";
	 		document.getElementById(id2).style.display = "none";
 	}
}

function resizeWindow()
{
	if (window.innerHeight) {
		size = window.innerHeight - 130;
	} 
	else if (document.body && document.body.offsetHeight) {
		size = document.body.offsetHeight - 130;
	}
	
	if(document.getElementById('table_body'))
	{
		document.getElementById('table_body').style.height = size + '';
	}
	
	if( typeof(myLightbox) != 'undefined')
	{	
		myLightbox.end();  
		initLightbox();
	}
	return false;
}

posX = 0;
posY = 0;
document.onmousemove = updateMousePosition;

function updateMousePosition(e)
{
	posX = (document.all) ? window.event.x : e.pageX;
	posY = (document.all) ? window.event.y : e.pageY;
}
