function show_popup(head, text){
    var pane = $('#error-popup').children('div.hold').children('div.bg-cen');
    pane.children('h2').html(head);
    pane.children('p').html(text);
    $('a#open-error-popup').simpleLightbox({autoShow:true});
}

function show_preview(head, imgurl){
    var pane = $('#preview-popup').find('div.content-holder').children('span').children('span');
    pane.css({width: null});
    //pane.children('h2').html(head);
    html = '<img src="' + imgurl + '" />';
    pane.html(html);
    $('a#open-preview-popup').simpleLightbox({autoShow:true});
}

function show_private_message(){
    var pane = $('#private-message-popup').children('div.hold').children('div.bg-cen');
    $('a#open-private-message').simpleLightbox({autoShow:true});
}

function message_form_to_ajax(formobj, backend){
    out = {};
    for (i=0; i < formobj.elements.length; i++){
        out[formobj.elements[i].name] = formobj.elements[i].value;
        formobj.elements[i].blur();
    }
    $.post(backend,
            out,
            function(json){
                eval("var data = " + json);
                if (data){
                    if (data['errors']){
                        for (li in data['errors'])
                            $('#id_' + li).parent('div').before('<div class="hint error-hint"><img src="/media/img/img-hint-error.gif" alt=""/><div class="tip"><div class="bg-bottom"><div class="bg-top">' + data['errors'][li] + '</div></div></div></div>');
                    }
                }
            });
}

function show_dates_picker(){
    var pane = $('#dates-popup').children('div.hold').children('div.bg-cen');
    $('a#open-dates-popup').simpleLightbox({autoShow:true});
}

