﻿var currentOpenItem="";

function CleanPdfDirectory() 
{
    // call server side method     
    //if (window.event.clientX < 0 && window.event.clientY < 0)
    if (window.event.clientY < 0) 
    {
        PageMethods.RemoveTempDirectory();
    }
}
 
//
//Show hide divs
//
function ShowHideDiv(inDivId)
{
    var selectedDiv;
    selectedDiv = document.getElementById(inDivId); 
    
    if(selectedDiv)
    {
        if(selectedDiv.style) 
        {
            if(selectedDiv.style.display == 'none')
            {
                selectedDiv.style.display = 'block';
            }
            else
            {
                selectedDiv.style.display = 'none';
            }
        } 
        else if( selectedDiv.display ) 
        {   
            if(selectedDiv.display == 'none')
            {
                selectedDiv.display = 'block';
            }
            else
            {
                selectedDiv.display = 'none';
            }
        }
    }
}

//
//Show hide divs
//
function ShowHide(inDivId, inURL, inUrl)
{
    var selectedDiv;
    selectedDiv = document.getElementById(inDivId); 
    
    if(selectedDiv)
    {
        if(selectedDiv.style) 
        {
            if(selectedDiv.style.display == 'none')
            {
                selectedDiv.style.display = 'block';
            }
            else
            {
                selectedDiv.style.display = 'none';
            }
        } 
        else if( selectedDiv.display ) 
        {   
            if(selectedDiv.display == 'none')
            {
                selectedDiv.display = 'block';
            }
            else
            {
                selectedDiv.display = 'none';
            }
        }
    }    
    
    ShowContent(inURL);
}

//
// Show content
//
function ShowContent(inURL)
{
    //Show content in the iFrame.
    var contentFrame = document.getElementById("ctl00_ContentPlaceHolder_ContentFrame");
    if(contentFrame)
    {
        //Resize iframe
        resizeIFrame();
        
        //resizeMenu
        resizeMenu();
        
        //Show content        
        contentFrame.src = inURL;
    }
}

function resizeIFrame()
{
    var contentFrame = null;
    
    if(document.getElementById("ctl00_ContentPlaceHolder_ContentFrame"))
    {
        contentFrame = document.getElementById("ctl00_ContentPlaceHolder_ContentFrame"); //Used by Catalog Manager (thema , subject ..)
    }
    
    if(contentFrame)
    {
        var height=window.innerWidth;//Firefox
        var offset = 242;
        if (document.body.clientHeight)
        {
            height=document.body.clientHeight;//IE
        }
        if(height > offset)
        {
            if(contentFrame.style)
            {
                contentFrame.style.height=parseInt(height-offset)+"px";
            }
            else if(contentFrame.height)
            {
                contentFrame.height=parseInt(height-offset)+"px";
            } 
        }
    }        
}

function resizeContentDiv()
{
    var contentDiv = null;
    
    if(document.getElementById("ContentDiv"))
    {
        contentDiv = document.getElementById("ContentDiv"); //Used by Content Manager (FAQ ..)
    }
    
    if(contentDiv)
    {
        var height=window.innerWidth;//Firefox
        var offset = 224;
        if (document.body.clientHeight)
        {
            height=document.body.clientHeight;//IE
        }
        if(height > offset)
        {
            if(contentDiv.style)
            {
                contentDiv.style.height=parseInt(height-offset)+"px";
            }
            else if(contentFrame.height)
            {
                contentDiv.height=parseInt(height-offset)+"px";
            } 
        }
    }        
}

function resizeMenu()
{
    var menu = document.getElementById("Menu");
    if(menu)
    {
        var height=window.innerWidth;//Firefox
        var offset = 228;
        if (document.body.clientHeight)
        {
            height=document.body.clientHeight;//IE
        }
        
        if(height > offset)
        {
            if(menu.style)
            {                
                menu.style.height=parseInt(height-offset)+"px";                
            }
            else if(menu.height)
            {
                menu.height=parseInt(height-offset)+"px";
            } 
        }
    }        
}

function ConfirmDelete(inURL)
{
    var isOk =window.confirm("Weet u dat zeker?")
    if (isOk)
    {
        //Show content
        ShowContent(inURL);
    }
}

function RefreshParent(inSelectedItems)
{
    //window.parent.location.href = window.parent.location.href;
    window.parent.location.href = "Catalog.aspx?selectedItems="+inSelectedItems+"";
}

//function resize_iframe()
//{
//   alert("test")
//            
//    var height=window.innerWidth;//Firefox
//    if (document.body.clientHeight)
//    {
//        height=document.body.clientHeight;//IE
//    }
//    //resize the iframe according to the size of the
//    //window (all these should be on the same line)
//    document.getElementById("ctl00_ContentPlaceHolder_ContentFrame").style.height=parseInt(height-
//    document.getElementById("ctl00_ContentPlaceHolder_ContentFrame").offsetTop-8)+"px";
//}


menu_status = new Array();
var currentOpenItemName=""; 
function ShowHide_old(theid, inURL)
{
    if(currentOpenItemName!="" && theid!=currentOpenItemName) ShowHide(currentOpenItemName);
    if (document.getElementById) 
    {
       var switch_id = document.getElementById(theid);
        if(menu_status[theid] != 'block') 
        {
           switch_id.style.display = 'block';
           menu_status[theid] = 'block';
           currentOpenItemName = theid;
        }
        else
        {
           switch_id.style.display = 'none';
           menu_status[theid] = 'none';
           currentOpenItemName = "";
        }
    }
    
    var contentFrame = document.getElementById("ContentFrame");
    contentFrame.src = inURL;
}


