/****
Description : JS for registrar

@created    : 2008-08-20
@Author     : Mario Diaz (4fb)
****/



// for preloading images:
var aTmpPreload = new Array();


/**
 * preloads images:
 * @param aImgArr
 * @return void
 */
function preloadImages (aImgArr) {
    iStart = aTmpPreload.length;
    for (i = 0; i < aImgArr.length; i++) {
        aTmpPreload[iStart + i] = new Image();
        aTmpPreload[iStart + i].src = aImgArr[i];
    }
}


var iCurrHeaderImg = 0;
/**
 * change Header img
 * about every 30 secs
 * @return void
 */
function changeHeaderImg () {
    if (!aHeaderImages) {
        // ignore
    } else if (aHeaderImages.length > 1) {
        iCurrHeaderImg = ((iCurrHeaderImg + 1) % aHeaderImages.length);
        document.getElementById('header_img').src = aHeaderImages[iCurrHeaderImg];
        setTimeout("changeHeaderImg ()", iHeaderMilliSecs);
    }
}


/**
 * changes img (mouse over)
 * @param string sXhtmlId
 * @param int iImg
 * @param int iState
 * @return void
 */
function changeImg (sXhtmlId, iImg, iState) {
    if (document.getElementById(sXhtmlId)) {
        sImg = (iState == 0) ? aImagesOver[iImg] : aImagesOut[iImg];
        document.getElementById(sXhtmlId).src = sImg;
    }
}



/**
 * changes display of news (main site) and changes styles of buttons
 * @param int iNo
 * @return void
 */
function changeNewsDisplay (iNo) {
    if (iNo == 0) {
        document.getElementById('news_further').style.display = 'none';
        document.getElementById('news_main').style.display = 'block';
        document.getElementById('a_news_main').className = 'a_active';
        document.getElementById('a_news_further').className = 'a_inactive';
    } else {
        document.getElementById('news_further').style.display = 'inline';
        document.getElementById('news_main').style.display = 'none';
        document.getElementById('a_news_main').className = 'a_inactive';
        document.getElementById('a_news_further').className = 'a_active';
    }
}


/**
 * handles mouseover/out effects for product teaser (could have been in html-tpl)
 * @param int iState
 * @return void
 */
function changeDisplayProductTeaser (iState) {
    oLayer = document.getElementById('product_teaser');
    if (iState == 0) {  // mouse over
        oLayer.style.backgroundColor = '#F0A95B';
        oLayer.style.cursor = 'pointer';
        document.getElementById('img_product_teaser').src = 'upload/zimages/button_produkt.gif';
    } else {            // mouse out
        oLayer.style.backgroundColor = '#CFD5D6';
        document.getElementById('img_product_teaser').src = 'upload/zimages/button_produkt_2.gif';
    }
}



/* *** business meetings start site *** */
// save states to array
var aBmStates = new Array();
// how many are displayed yet:
var iBmCount = 7;

/**
 * shows further 7 meetings
 * @return void
 */
function showFurtherBMs () {
    // document.getElementById('bm_default').style.display = 'none';
    document.getElementById('a_bm_default').className = '';
    document.getElementById('a_bm_further').className = 'a_active';
    document.getElementById('bm_link_show_all').style.display = 'block';
    iTmp = iBmCount;
    iScrollBy = 0;
    for (i = iTmp; i < iTmp + 7; i++) {
        if (!document.getElementById('bm_item_' + i)) {
            break;
        }
        document.getElementById('bm_item_' + i).style.display = 'inline';
        iBmCount++;
        iScrollBy++;
    }
    window.scrollBy(0, (iScrollBy * 25));
}


/**
 * shows 7 meetings less
 * @return void
 */
function showLessBMs () {
    document.getElementById('a_bm_default').className = 'a_active';
    document.getElementById('a_bm_further').className = '';
    document.getElementById('bm_link_show_all').style.display = 'none';
    for (i = 7; i < 14; i++) {
        if (!document.getElementById('bm_item_' + i)) {
            break;
        }
        document.getElementById('bm_item_' + i).style.display = 'none';
        iBmCount--;
    }
}


// which one is opened (see showBmDetails (iNo))
var iBmOpened = -1;

/**
 * shows details for one bm
 * @param int iNo
 * @return void
 */
function showBmDetails (iNo) {
    // new: hide other not closed:
    if (iBmOpened != -1 && iBmOpened != iNo) {
        aBmStates[iBmOpened] = !aBmStates[iBmOpened];
        document.getElementById('img_bm_details_' + iBmOpened).src = (aBmStates[iBmOpened]) ? 'upload/zimages/button_link_to_bottom.gif' : 'upload/zimages/button_link.gif';
        document.getElementById('bm_details_' + iBmOpened).style.display = (aBmStates[iBmOpened]) ? 'block' : 'none';
        document.getElementById('bm_row_' + iBmOpened).style.backgroundColor = (aBmStates[iBmOpened]) ? '#c5cccd' : '#FFFFFF';
        document.getElementById('img_bm_details_' + iBmOpened).style.backgroundColor = (aBmStates[iBmOpened]) ? '#c5cccd' : '#FFFFFF';
    } else if (iBmOpened == iNo) {
        iBmOpened = -1;
    }
    if (!aBmStates[iNo]) {
        aBmStates[iNo] = true;
    } else {
        aBmStates[iNo] = !aBmStates[iNo];
    }
    if (aBmStates[iNo]) {
        iBmOpened = iNo;
    }
    document.getElementById('img_bm_details_' + iNo).src = (aBmStates[iNo]) ? 'upload/zimages/button_link_to_bottom.gif' : 'upload/zimages/button_link.gif';
    document.getElementById('bm_details_' + iNo).style.display = (aBmStates[iNo]) ? 'block' : 'none';
    document.getElementById('bm_row_' + iNo).style.backgroundColor = (aBmStates[iNo]) ? '#c5cccd' : '#FFFFFF';
    document.getElementById('img_bm_details_' + iNo).style.backgroundColor = (aBmStates[iNo]) ? '#c5cccd' : '#FFFFFF';
    if (aBmStates[iNo] && iNo != 0) {   // a trick
        document.getElementById('bm_row_' + iNo).style.borderTop = "1px solid #EDEFEE";
    }
}


/**
 * handles mouseover/mouseout for show details link
 * @param int iState (over/out)
 * @param int iNo
 * @return void
 */
function handleMouseBmDetailsLink (iState, iNo) {
    if (iState == 0) {  // over 
        document.getElementById('img_bm_details_' + iNo).src = 'upload/zimages/button_link_over.gif';
    } else {
        sImg = (aBmStates[iNo]) ? 'upload/zimages/button_link_to_bottom.gif' : 'upload/zimages/button_link.gif';
        document.getElementById('img_bm_details_' + iNo).src = sImg;
    }
}


/** 
 * mouseover/out effect for rows: two layers
 * @param sId1
 * @param sId2
 * @param bool bOver
 * @return void
 */
function lightBlueEffect (sId1, sId2, bOver) {
/*
    if (bOver) {
        document.getElementById(sId1).style.backgroundColor = '#cce8ff';
        document.getElementById(sId2).style.backgroundColor = '#cce8ff';
    } else {
        //if (!aBmStates[iNo]) {
            document.getElementById(sId1).style.backgroundColor = '#FFFFFF';
            document.getElementById(sId2).style.backgroundColor = '#FFFFFF';
        //}
    }
    */
}



