$(document).ready(function() {
    $('#imgsembed').click(function() {
        var html = $('#plplayer').html();
        if (html.indexOf('</embed>') == -1) {
            html += '</embed>';
        }
        html = $.trim(html);
        html = html.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');

        $('.plsharecontent').html('<input type="text" style="width:466px;" onmouseover="$(this).select()" value="' + html + '" />');
    });

    $('#ph_imgsembed').click(function() {
        var html = $('#ph2_video').html();
        if (html.indexOf('</embed>') == -1) {
            html += '</embed>';
        }
        html = $.trim(html);
        html = html.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');

        $('.plsharecontent').html('<input type="text" style="width:360px;" onmouseover="$(this).select()" value="' + html + '" />');
    });

    $('#imgsemail').click(function() {
        var html = 'Email: <input type="text" id="txtEmail" style="width:180px;"  class="text" /> <input type="button" id="btnSendEmail" onclick="SendEmail()" value="Send this page" />';
        $('.plsharecontent').html(html);
        $('#txtEmail').focus();
    });
});


function SendEmail() {
    var email = $('#txtEmail').val();
    var id = $('#imgsemail').attr('alt').split(' ')[0];
    var vid = $('#imgsemail').attr('alt').split(' ')[1];

  
    if (email.length > 0) {
        $('#btnSendEmail').val('Sending ...');
        $('#btnSendEmail').attr('disabled', 'disabled');
        var url = '/video.asp?email=' + email + '&id=' + id + '&vid=' + vid;
     
        $('.plsharecontent').load(url);
    }
}
