/*
Funktionen zum auf- und zuklappen von Elementen

Autor      : Joachim Ruf
Erstellt am: 2008.03.23
*/



// === Globale Variablen ===
//var globUrl = 'http://localhost/loresoft/';
var globUrl = 'http://www.loresoft.de/';




/**
* Öffnet einen Tooltip-Text
* @param secId Id-Name des Elements
*/
function expandTooltip( secId )
{
	var isExpand = document.getElementById(secId).style.visibility;

	if(isExpand == "hidden")
		document.getElementById( secId ).style.visibility = 'visible';


    //alert("wird geöffnet");
    return true;
}





/**
* Schließt einen Tooltip-Text
* @param secId Id-Name des Elements
*/	
function collapseTooltip( secId )
{
	var isExpand = document.getElementById( secId ).style.visibility;

	if(isExpand == "visible")
		document.getElementById( secId ).style.visibility = 'hidden';


    //alert("wird geschlossen");
    return true;
}








var globLastChild = ''; //Definition des zuletzt angeklickten Elements
var globIntervalId = 0; //Globale Timeout-Id

/**
* Öffnet eine Profilbox
* @param secId Id-Name des Elements
*/
function expandProfileBox( secId, picPath, maxWidth, maxHeight )
{
    var isExpand = document.getElementById('bodyBoarder' + secId ).style.visibility;
    globLastChild = 0;
    
    if(isExpand == "hidden")
    {
	    //Prüfe beim expandieren ob eine Box mit Id größer oder kleiner 1 als die gegenwärtige Id geöffnet ist und schließe diese
        if( document.getElementById('bodyBoarder' + parseInt(secId + 1) ) != null )
            collapseProfileBox( parseInt(secId + 1) );
		
        if( document.getElementById('bodyBoarder' + parseInt(secId - 1) ) != null )
            collapseProfileBox( parseInt(secId - 1) );
            
            
		
	    //Öffne gegenwärtige Box
        document.getElementById('profileBoxBorderClose' + secId ).style.visibility = 'visible';
        document.getElementById('profileBoxBorder' + secId ).style.visibility = 'visible';
	    document.getElementById('bodyBoarder' + secId ).style.visibility = 'visible';
    	

	    //alert(globUrl + 'thumbnail.php?image=' + picPath + '&amp;maxWidth=' + maxWidth + '&amp;maxHeight=' + maxHeight);	
	    if( document.getElementById('pic' + secId ).src != picPath )
		    document.getElementById('pic' + secId ).src = globUrl + 'thumbnail.php?image=' + picPath + '&maxWidth=' + maxWidth + '&maxHeight=' + maxHeight;
    }
	
	
    return true;
}



function collapseProfileBox( child, secId )
{
    if( globLastChild == 'profileBoxBorder' + secId && child.id == 'profileBoxBorderClose' + secId ) //Schließe ProfileBox
    {
	    globIntervalId = window.setInterval("doCollapseProfileBox(" + secId + ")", 500);
    }			
    globLastChild = child.id; //Speichere das zuletzt besuchte Element um die Richtung innen nach außen ermittlen zu können
	
    return true;
}


/**
* Schließt eine Profilbox
* @param secId Id-Name des Elements
*/		

function doCollapseProfileBox( secId)
{
    if( globLastChild == 'profileBoxBorderClose' + secId ) //Schließe ProfileBox
    {
	    document.getElementById('profileBoxBorderClose' + secId ).style.visibility = 'hidden';
	    document.getElementById('profileBoxBorder' + secId ).style.visibility = 'hidden';


	    var isExpand = document.getElementById('bodyBoarder' + secId ).style.visibility;
	
	    if(isExpand == "visible")
		    document.getElementById('bodyBoarder' + secId ).style.visibility = 'hidden';
    }
    if( globIntervalId )
	    window.clearInterval(globIntervalId);
	
    return true
}


