var	iStartHeight;

function deMelkerResize(e) {
    try {
        var frame = document.getElementById('contentIframe');
        var iHeight;
        var wnd;

        if (e == null) e = event;

        if (e == null || e.srcElement == null || e.srcElement.contentWindow == null)
            wnd = frame.contentWindow;
        else
            wnd = e.srcElement.contentWindow;

        frame.style.height = '300px';
        iHeight = wnd.document.body.scrollHeight + 40;
        if (iHeight < (document.body.clientHeight - 160))
            iHeight = document.body.clientHeight - 160;
        if (frame.clientHeight != iHeight) {
            frame.style.height = iHeight + 'px';
        }
    }
    catch (exception) {
    }
}


function frameResize(e)
{
	try
	{
		var	oTD			= document.getElementById('tdContentCol0');
		var	oTdLeftMenu		= document.getElementById('tdLeftMenu');
		var	iHeight;
		var	wnd;
		
		if (e == null) e = event;
		
		if (e == null || e.srcElement == null || e.srcElement.contentWindow == null)
			wnd = document.getElementById('contentIframe').contentWindow;
		else
			wnd = e.srcElement.contentWindow;

		oTD.style.height=300;
		iHeight			= wnd.document.body.scrollHeight - 112;
		if (iHeight < oTdLeftMenu.scrollHeight)
			iHeight = oTdLeftMenu.scrollHeight;
		if (oTD.clientHeight != iHeight)
		{
			if (iHeight > 300)
				oTD.style.height	= iHeight + 'px';
			else
				oTD.style.height	= '100%';
		}
	}
	catch (e)
	{
	}
}


function j_firstChild(oElem, tagName)
{
	oChild	= oElem.firstChild;
	while (oChild.nodeName != tagName && (oChild.nextSibling))
		oChild	= oChild.nextSibling;
	return oChild;
}

function j_firstSibling(oElem, tagName)
{
	oSibling	= oElem.nextSibling;
	while (oSibling.nodeName != tagName && (oSibling.nextSibling))
		oSibling	= oSibling.nextSibling;
	return oSibling;
}


function j_itemSearch()
{
	var searchText = document.getElementById('sbItemSearchText');
	var searchProvider = document.getElementById('SearchProviderDocument');

	if (searchText != null &&  searchText.value != null && searchText.value.length > 0)
	{
		if (searchProvider != null && searchProvider.checked)
			contentIframe.location.href = "../Zoek%20in%20document/" + searchText.value + ".aspx";
		else
			contentIframe.location.href = "../e-Catalogus/MELKER/Zoek/" + searchText.value + ".aspx";
	}
}

function j_changeSearchProvider(radioButton)
{
	var searchText = document.getElementById('sbItemSearchText');
	
	if (searchText)
		searchText.SearchProvider = radioButton.value;
}

var oLastNode	= null;
			
function jm_openSubNodes(oDiv)
{
	var	oA;
	var	oChildDiv;

	if (oLastNode != oDiv)
	{
		oDiv.style.borderTopWidth		= '0px';
		oDiv.style.height						= '15px';
		oDiv.style.backgroundColor	= '#F76C22';
		
		oA			= j_firstChild(oDiv, "A");
		oChildDiv	= j_firstSibling(oDiv, "DIV");
		
		oA.style.color							= '#FFFFFF';
		oA.style.textDecoration			= 'none';
		oA.style.fontWeight				= 'bold';
		
		if (oChildDiv != null)
		{
			oChildDiv.style.display		= 'block';
			frameResize(null);
			if (oChildDiv.offsetHeight > 400)
			{
				oChildDiv.style.height = '400px';
				oChildDiv.style.overflow = 'auto';
			}
		}	

		if (oLastNode != null)
			jm_closeSubNodes(oLastNode)

		if (window.event)
			event.cancelBubble = true;

		oLastNode	= oDiv;
	}
}

function jm_closeSubNodes(oDiv)
{
	var	oA			= j_firstChild(oDiv, "A");
	var	oChildDiv	= j_firstSibling(oDiv, "DIV");

	oDiv.style.borderTopWidth		= '';
	oDiv.style.height						= '100%';
	oDiv.style.backgroundColor	= '';
		
	oA.style.color							= '';
	oA.style.textDecoration			= '';
	oA.style.fontWeight				= '';

	if (oChildDiv != null)
		oChildDiv.style.display		= 'none';
}

var lastTabAnchor	= null;
var lastLeftMenu	= null;
function j_clickTab(anchor)
{
	try
	{
		if (anchor != null && anchor != lastTabAnchor)
		{
			if (lastTabAnchor != null)
				lastTabAnchor.parentNode.className	= "TABNOTSELECTED";
			if (lastLeftMenu != null)
				lastLeftMenu.parentNode.className	= "MENUNOTSELECTED";
			anchor.parentNode.className	= "TABSELECTED";
			
			lastLeftMenu	= null;
			lastTabAnchor	= anchor;
		}
	} catch (e) {}
		
	return true;
}

function j_closeSubMenu()
{
	if (lastLeftMenu != null)
		lastLeftMenu.style.display	= 'none';
}
function j_clickSubMenu(leftMenu)
{
	lastLeftMenu = j_firstChild(j_firstSibling(leftMenu.parentNode.parentNode, "TR"), "TD");
	lastLeftMenu.style.display	= 'block';
}

var Unselectable = {

    enable: function(e) {
        var e = e ? e : window.event;

        if (e.button != 1) {
            if (e.target) {
                var targer = e.target;
            } else if (e.srcElement) {
                var targer = e.srcElement;
            }

            var targetTag = targer.tagName.toLowerCase();
            if ((targetTag != "input") && (targetTag != "textarea")) {
                return false;
            }
        }
    },

    disable: function() {
        return true;
    }

}

var backgroundImages = ["/images/FotoKikkerQuote.png", "/images/FotoLieveheersbeestjeQuote.png", "/images/FotoVlindersQuote.png"];

var backgroundIndex = 0;
var opacity = 0.0;
var fadeOut = true;
var step = 1 / 20;
var fadeTimer;

function startFade() {
    fadeTimer = window.setInterval(fade, 7 * 100 * step);
}

function fade() {
    var element = document.getElementById("header");

    if (fadeOut) {
        opacity = opacity - step;
        if (opacity <= 0.0) {
            opacity = 0.0;
            fadeOut = false;

            backgroundIndex++;
            if (backgroundIndex > 2)
                backgroundIndex = 0;

            element.style.backgroundImage = 'url(' + backgroundImages[backgroundIndex] + ')';
        }
    }
    else {
        opacity = opacity + step;
        if (opacity >= 1.0) {
            window.clearTimeout(fadeTimer);
            window.setTimeout(startFade, 5000);

            opacity = 1.0;
            fadeOut = true;
        }
    }

    element.style.opacity = opacity;
    element.style.filter = 'alpha(opacity = ' + (opacity * 100) + ')';
}
    
