﻿function getSelectedValFromListbox(id) {
    var returnValue = "selected item not found";
    $("#"+id+" option").each(function() {
    if ($(this).attr('selected')) {
            returnValue = $(this).val();
        }
    });
    return returnValue;
}
function MailerBeheerder(fr, po) {
    instruction = "mailto:";
    yoow = GetStr(fr) + "@" + GetStr(po);
    window.open(instruction+yoow); return false; 
}
function GetStr(UniChars) {
    var ReturnValue = "";
    arr_values = UniChars.split(":");
    for (var i = 0; i < arr_values.length; i++) {
        ReturnValue = ReturnValue + String.fromCharCode("" + arr_values[i] + "");
    }
    return ReturnValue;
}

/**
* Delay for a number of milliseconds
*/
function sleep(delay) {
    var start = new Date().getTime();
    while (new Date().getTime() < start + delay);
}

function escapeApostrophe(value) {
    var val = value + ''; // make sure to cast all vals to string type ( lame Jscript ;)
    var retval = val.replace(/\'/g, "\\'");

    return retval;
}

// ------------------------------------------------------------------------------------------------
// object relativePathFromRoot
// Purpose      :
// Parameters   :    
// Example : relativePathFromRoot("/Pages/ProcessingPages/HTMLContentProvider.aspx")
function relativePathFromRoot(strRelativePathFromRoot) {

    var path = '';
    if (strRelativePathFromRoot.toString().substring(0, 1) == "/") {
        // in this case, this 'root slash' points to full domain name, making it a absolute pointer from the slash on..

        //alert(" 1 " + path + strRelativePathFromRoot);
        return path + strRelativePathFromRoot;
    }

    for (var i = 0; i < document.location.pathname.split('/').length - 2; i++) {
        path += '../';
    }

    //alert(" 2 " + path + strRelativePathFromRoot);

    return path + strRelativePathFromRoot;
}
