/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function splitURL(s) {
    s.match( /^([^\/]+\/\/)?([^\/]+)([^\?#]+)(.*$)/ );

    return {
        protocol: RegExp.$1,
        hostname: RegExp.$2,
        pathname: RegExp.$3
    };
}


$(document).ready(function() {
    var prevLink = '';
    var nextLink = '';
    var videoURL = '';

    $('.nextprev').each(function(index) {
        if ($(this).text() == 'Prev') {
            prevLink = splitURL($(this).attr('href')).pathname;
        } else if ($(this).text() == 'Next') {
            nextLink = splitURL($(this).attr('href')).pathname;
        }
    });

    videoURL = $('#psvideo').text();
    
    if (videoURL != '') {
        $('table.abBorder').hide();
    }

    videoSrc = videoURL + '&prevID=' + prevLink + '&nextID=' + nextLink + '&allowFullScreen=true';

    var output = '';
    output += '<embed height="497" width="620" menu="true" allowFullScreen="true" loop="false"';
    output += ' play="false" src="' + videoSrc + '"';
    output += ' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>';

    $('#psvideo').html(output);
});

