/* ----------------------------------------------------------- */
/* ----------    YouJizz Peel AD jQuery Plug In    ----------- */
/* ----------      by M.Franck - jul. 25, 2011     ----------- */
/* ----------------------------------------------------------- */

$(document).ready(function() {
    $("#pageflip").mouseenter(function() { //On hover...
        $(this)
            .mouseleave(function() {
                $(this).clearQueue('events');
                closeFlip();
            })
            .clearQueue('events')
            .delay(3000, 'events')
            .queue('events', function() {
                $(this).mouseleave(function() {
                        $(this).unbind('mouseleave');
                        closeFlip(true);
                    });
            })
            .dequeue('events');
        
        openFlip();
    });
});

function openFlip() {
    $("#pageflip")
        .stop(true)
        .animate({width: '307px',height: '319px'}, 500, function() {
            $(".msg_block")
                .stop(true, true)
                .delay(3000) // Time for frame view
                .fadeOut(1000);
        });
}

function closeFlip(hide) {
    $("#pageflip, .msg_block, .sec_msg_block").stop(true);
    
    $("#pageflip")
        .animate({width: '50px',height: '52px'}, 220);
    
    if(hide)
        //$("#pageflip").fadeOut(1000);
        $("#pageflip").hide();
}
