function apekop(source, arguments)
{
      arguments.IsValid=false;
}
function Over()
{
    window.event.srcElement.style.borderColor = "#000000";
}
function Out()
{
    window.event.srcElement.style.borderColor = "#d0d0d0";
}

function Format(strCommand_IN)
{
    //alert(document.selection.type);
    document.execCommand(strCommand_IN);
}

function MaakLink(strUCClientId, strLink)
{
    var strLink;
//"javascript:__doPostBack('ucAllContent$ucPaginaLinks$P" + strPnaId_IN + "','') " + "class=\"content\""    
    strLink = "javascript:__doPostBack('" + strUCClientId + '$' + strLink + "','')"

    if (document.selection.type != "None") 
    {
        //document.execCommand('CreateLink', false, 'javascript:alert(\'ddd\'); ');
        document.execCommand('CreateLink', false, strLink);
    }
}

function InsertLinkExtern()
{
    var objSelected = document.selection.createRange();
    if (!objSelected=="")
    {
        
        //Replace text with URL
        if (objSelected.parentElement().tagName == "A")
        {
            document.execCommand("Unlink");
        }    
        else
        {
            //Create link
            document.execCommand("CreateLink");

            if (objSelected.parentElement().tagName == "A")
            {
                //objSelected.parentElement().innerText=sText.parentElement().href;
                objSelected.parentElement().setAttribute("className", "content");
                objSelected.parentElement().setAttribute("target", "_blank");
                //document.execCommand("ForeColor","false","#FF0033");
            }
        }

    }
    else
    {
        // geen aktie!
    }   

}
 
    
    
/*    
    if (document.selection.type != "None") 
    {
        document.execCommand('CreateLink');
        alert(document.queryCommandValue('CreateLink'));

    }
}
*/

function InsertLinkIntern()
{
    var strLink;
    var strPagina;
    var objSelected = document.selection.createRange();

    // Link samenstellen op basis van geselecteerde pagina    
    if (!objSelected=="") 
    {
    // alert(objSelected.parentElement().tagName);
    
        if (objSelected.parentElement().tagName == "A")
        {
            // alert('link!');
            document.execCommand("Unlink");
        }    
        else
        {

            // Toon window met te kiezen pagina's
            strPagina = window.showModalDialog("/pages/beheer/selectpagelink.aspx","","dialogHeight: 120px; dialogWidth: 700px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; resizable: No; status: No;");

            if (strPagina=="-1")
            {
                // Geen aktie!
            }
            else
            {

                strLink = "javascript:__doPostBack('ucAllContent$ucPaginaLinks$P" + strPagina + "','')"
                document.execCommand('CreateLink', false, strLink);
                if (objSelected.parentElement().tagName == "A")
                {
                    objSelected.parentElement().setAttribute("className", "content");
                }
            
            }

        }
    }
    else
    {
        // geen aktie!        
    }
}

function LaatsteMIM(strMelding_IN)
{
    alert(strMelding_IN);
    return false;
}

function SetFocus(objControl)
{
    var strControl;

    // Samenstellen volledige naam van de Control
    strControl = "document.forms[0]." + objControl;

    // zet de focus
    eval(strControl).focus();

    return true;
}

function ToonImage(strDetailControl_IN
                  ,strControl_IN)
{
    document.all.item(strDetailControl_IN).src = document.all.item(strControl_IN).src;
    return true;
}

function SetFocus(objControl)
{
    var strControl;

    // Samenstellen volledige naam van de Control
    strControl = "document.forms[0]." + objControl;

    // zet de focus
    eval(strControl).focus();

    return true;
}

function SelPageOK(strControlNaam_IN)
{
    var lstPaginas;
    var strPnaId;
    
    lstPaginas=document.getElementById(strControlNaam_IN);
    strPnaId=lstPaginas.options[lstPaginas.selectedIndex].value;
    window.returnValue=strPnaId;
    window.close();
}

function SelPageCancel()
{
    strPnaId="-1";
    window.returnValue=strPnaId;
    window.close();
}

function ShowUploadWindow(strUploadDir_IN)
{
    var strURL;
    var strUploadedFile;

    // Samenstellen URL
    strURL = "/pages/beheer/UploadFilePage.aspx?dir=" + strUploadDir_IN;
       
    // Toon window t.b.v. upload
    strUploadedFile = window.showModalDialog(strURL,"","dialogHeight: 140px; dialogWidth: 600px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; resizable: No; status: No;");

    if (strUploadedFile=="")
    {
        // Geen upload => Geen aktie!
        // alert('geen file');
    }
    else
    {
        // alert(strUploadedFile);

        // Forceer een submit in de parent
        // alert(document.location.href);
        document.forms[0].submit();
    }
}

function Sluit()
{
    window.returnValue="succes";
    window.close();
}

function Cancel()
{
    window.returnValue="";
    window.close();
}
function SaveContent(strDivFrom_IN
                    ,strHiddenTo_IN)
{
    // Kopieer de HTML-content van editable DIV naar hidden field

    // Declaraties
    var hidTo;
    var divFrom;
    
    // Bepaal Div
    divFrom = document.getElementById(strDivFrom_IN);
    
    // Bepaal hidden field
    hidTo = document.getElementById(strHiddenTo_IN);
    
    // Kopieer HTML-inhoud
    hidTo.value = divFrom.innerHTML;
    
}

function RestoreContent(strDivFrom_IN
                       ,strHiddenTo_IN)
{
    // Kopieer de HTML-content van hidden field naar editable DIV

    // Declaraties
    var hidTo;
    var divFrom;
    
    // Bepaal Div
    divFrom = document.getElementById(strDivFrom_IN);
    
    // Bepaal hidden field
    hidTo = document.getElementById(strHiddenTo_IN);
    
    // Kopieer HTML-inhoud
    divFrom.innerHTML = hidTo.value;
}
