function initialiseCSLite() {
    $("input.csladd").click(function() {
        transferElements($(this).parent().parent().find(".cslLeft select option:selected").attr("selected",false), $(this).parent().parent().find(".cslRight select"));
    });

    $("input.csladdall").click(function() {
        transferElements($(this).parent().parent().find(".cslLeft select option"), $(this).parent().parent().find(".cslRight select"));
    });

    $("input.cslremove").click(function() {
    transferElements($(this).parent().parent().find(".cslRight select option:selected").attr("selected", false), $(this).parent().parent().find(".cslLeft select"));
    });

    $("input.cslremoveall").click(function() {
        transferElements($(this).parent().parent().find(".cslRight select option"), $(this).parent().parent().find(".cslLeft select"));
    });


    $(".cslLeft select").dblclick(function() {
    transferElements($(this).find("option:selected").attr("selected", false), $(this).parent().parent().find(".cslRight select"));
    });

    $(".cslRight select").dblclick(function() {
    transferElements($(this).find("option:selected").attr("selected", false), $(this).parent().parent().find(".cslLeft select"));
});

$(".cslRight").parent("form").submit(function() {
    $(".cslRight option").attr("selected", true);
    alert('boing');
});
}

function transferElements($fromOptions, $toSelect) { //xfer
    $fromSelect = $fromOptions.parent();
    arrExistingOptionObjects = $toSelect[0].options;
    arrNewOptionObjects = new Array();
    arrNewOptionObjects = jQuery.makeArray($fromOptions);
    intFromLength = arrNewOptionObjects.length;
    intExistingLength = arrExistingOptionObjects.length;
    iFrom = 0;
    iTo = 0;
    while (iFrom < intFromLength && iTo < intExistingLength) { //integrate the two sets of elements
        if (arrNewOptionObjects[iFrom].text.toLowerCase() < arrExistingOptionObjects[iTo+iFrom].text.toLowerCase()) {
            $toSelect[0].insertBefore(arrNewOptionObjects[iFrom], arrExistingOptionObjects[iTo+iFrom]);
            iFrom++
        }
        else {
            iTo++
        }
    }
    if (iFrom != intFromLength) { //insert any remaining stuff
        var fragment = document.createDocumentFragment(); //consolidating doc fragments gives performance boost
        for (j = iFrom; j < intFromLength; j++) {
            fragment.appendChild(arrNewOptionObjects[j]);
        }
        $toSelect[0].appendChild(fragment);
    }
    arrExistingOptionObjects = null;
    arrNewOptionObjects = null;
    //ie7 needs the following two lines to redraw the select elements properly, otherwise resizes incorrectly.
    $fromSelect.css("visibility", "hidden").css("visibility", ""); 
    $toSelect.css("visibility", "hidden").css("visibility", "");
}
