﻿function stickToTable() {
    var moodDiv = document.getElementById('moodImageDiv');
    var mainTable = document.getElementById('mainTable');

    if (moodDiv && mainTable) {
        moodDiv.style.left = (mainTable.clientWidth - moodDiv.clientWidth);
    }
}
function stickToTableKinder() {
    var moodDiv = document.getElementById('moodImageDiv');
    var mainTable = document.getElementById('mainTable');

    if (moodDiv && mainTable) {
        moodDiv.style.left = (mainTable.clientWidth - moodDiv.clientWidth - 1);
    }
}

function readspeaker_start() {
    var currentCookies = document.cookie;
    
    if (currentCookies.indexOf('readspeaker') == -1 && parent.location.href == window.location.href) {

        var expireDate = new Date(2050, 0, 10);

        var cookieString = "readspeaker=1; expires=" + expireDate.toGMTString() + "; path=/";
        document.cookie = cookieString;

        document.write('<embed src="/SiteCollectionDocuments/readspeaker.mp3" autostart="true" hidden="true" loop="false">');
    }
}

function doSubmit(inpField) {
    var strSearchValue = inpField.value;
    var frmForm = document.getElementsByTagName("form")[0];
    
    // Remove all double white spaces
    strSearchValue = strSearchValue.replace(/\s+/g, ' ');
    // Remove front whitespace
    strSearchValue = strSearchValue.replace(/^ /, '');
    // Remove trailing whitespace
    strSearchValue = strSearchValue.replace(/ $/, '');

    if (strSearchValue.length > 2) {
        inpField.value = strSearchValue;
        window.location = '/zoeken/pages/default.aspx?k=' + strSearchValue;
    }
    else if (strSearchValue.length > 0 && strSearchValue.length <= 2) {
        alert("De zoekterm moet minimaal uit 3 tekens bestaan.");
        inpField.value = strSearchValue;
    }
    else {
        alert("De door u gebruikte zoekterm is niet correct.");
        inpField.value = strSearchValue;
    }

}

function doSubmit_en(inpField) {
    var strSearchValue = inpField.value;

    // Remove all double white spaces
    strSearchValue = strSearchValue.replace(/\s+/g, ' ');
    // Remove front whitespace
    strSearchValue = strSearchValue.replace(/^ /, '');
    // Remove trailing whitespace
    strSearchValue = strSearchValue.replace(/ $/, '');

    if (strSearchValue.length > 2) {
        inpField.value = strSearchValue;
        window.location = '/english/search/pages/default.aspx?k=' + strSearchValue;
    }
    else if (strSearchValue.length > 0 && strSearchValue.length <= 2) {
        alert("The word must have at leat 3 characters");
        inpField.value = strSearchValue;
    }
    else {
        alert("The word you used is not correct.");
        inpField.value = strSearchValue;
    }
}


/* override the default function to retrieve the blockNames for the html editor */
function RTE_GetBlockFormatNames() {
    var rgstrItemNamesRet = new Array();
    var dh = RTE_GetDialogHelper();
    if ((null != dh) && (null != dh.blockFormats) && (0 < dh.blockFormats.count)) {
        var iItem;
        for (iItem = 1; iItem < dh.blockFormats.count; iItem++) {
            if (dh.blockFormats(iItem) != "Heading 1" && dh.blockFormats(iItem) != "Heading 2" && dh.blockFormats(iItem) != "Heading 6") {
                RTE_InsertIntoSortedArrayIfValid(dh.blockFormats(iItem), rgstrItemNamesRet);
            }
        }
    }
    return rgstrItemNamesRet;
}