/**
 * @author Mike
 */

$(document).ready(function(){


    $('ul#single_tabs').idTabs(function(id){
        var showBlock = $(id);
        switch(id){
            case "#related-post":
                $('#underpost-content')
                    .css({'min-height':'15em'})
                    .append(showBlock);
                break;
            case "#tags":  
                $('#underpost-content')
                    .css({'min-height':'5em'})
                    .append(showBlock);
                break;
            case "#send-to-friend":
                $('#underpost-content')
                    .append(showBlock)
                    .css({'min-height':'30em'});
                getAjaxContent(id);
                break;
            case "#bookmarks":  
                $('#underpost-content')
                    .css({'min-height':'15em'})
                    .append(showBlock);
                break;
        } return true;
    }); 

	
});

function getAjaxContent(blockID){
    var postUrlPath = window.location.pathname;
    var postUrlProtocol = window.location.protocol;
    var postUrlHos = window.location.host;
    $.ajax({
        type: "GET",
        url: postUrlProtocol+'//'+postUrlHos+postUrlPath+'/email',
        cache: true,
        beforeSend: function(){
            $('#underpost-content')
                .block({
                    message:'<img src="/ajax-bar.gif"><br><h1>Загружаю форму…</h1>',
                    css:{ cursor:'wait', color:'#CCC', backgroundColor:'#333', border:'1px solid #000', padding:'.5em', margin:'.5em 0', width:'50%', top:'1%'},
                    overlayCSS:{ background:'#000', opacity:'0.8' }
                })
        },
        success: function(data){
            var sendToFriendBlock = $('#wp-email-content', data);
            $(blockID).html(sendToFriendBlock);
            $('#underpost-content').unblock();
        }
    });
};