$(function() {
        $('.lightbox a').lightBox();

	$('a[rel^=lightbox]').lightBox(); // Select all links that contains lightbox in the attribute rel

});

function showPlayer(video, container, preview)
{
        var fo = new SWFObject("player.swf", "sc_player", "512", "304", 9, "#F4F4F4", true);

        fo.addParam('allowFullScreen', 'true');
        fo.addParam("allowScriptAccess", "always");
        fo.addParam("flashvars","file=" + video + "&image=" + preview + "&autostart=false");

        fo.write(container);
}


function makeSublist(parent,child,isSubselectOptional,childVal)
{
        $("body").append("<select style='display:none' id='"+parent+child+"'></select>");
        $('#'+parent+child).html($("#"+child+" option"));

        var parentValue = $('#'+parent).attr('value');
        $('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());

        childVal = (typeof childVal == "undefined")? "" : childVal ;
        $("#"+child).val(childVal).attr('selected','selected');

        $('#'+parent).change(function(){
                var parentValue = $('#'+parent).attr('value');
                $('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());
                if(isSubselectOptional) $('#'+child).prepend("<option value='none' selected='selected'> -- Select -- </option>");
                $('#'+child).trigger("change");
                $('#'+child).focus();
        });
}


function insert_text(field, open, close)
{
        msgfield = document.getElementById(field);

        // IE support
        if (document.selection && document.selection.createRange)
        {
                msgfield.focus();
                sel = document.selection.createRange();
                sel.text = open + sel.text + close;
                msgfield.focus();
        }
        // Moz support
        else if (msgfield.selectionStart || msgfield.selectionStart == '0')
        {
                var startPos = msgfield.selectionStart;
                var endPos = msgfield.selectionEnd;

                msgfield.value = msgfield.value.substring(0, startPos) + open + msgfield.value.substring(startPos, endPos) + close + msgfield.value.substring(endPos, msgfield.value.length);
                msgfield.selectionStart = msgfield.selectionEnd = endPos + open.length + close.length;
                msgfield.focus();
        }
        // Fallback support for other browsers
        else
        {
                msgfield.value += open + close;
                msgfield.focus();
        }

        return;
}

