/**
 * Funkcije in ostalo za delo z videi.
 *
 * 'detect.js' mora biti tudi includana na pagu.
 *
 * Na strani morata biti definriani spremenljivki:
 *      - url_rm,
 *      - url_wmv
 *
 * (c) PRO PLUS, 2005
 */


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Procesiranje in izbira videa
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/**
 * Glavna funkcija za VIDEO. V HTML-ju klices to.
 */
function video_show( video_size, zoneid ) {
        document.write( video_get_html( video_size, zoneid ) );
}

/**
 * Funkcija vrne HTML za prikaz videa
 */
function video_get_html( video_size, zoneid ) {
        // kaksen size se mora prikazat?
        if ( !video_size )
                video_size = get_cookie('video_size');

        // kaksen tip?
        video_type = get_cookie('video_type');

        // is this zone connected?
        if ( !zoneid )
                zoneid = "" + section_id + "41";

        connected_banner = banner_zone_is_connected( zoneid );

        if ( connected_banner ) {
                url_rm += "&bannerid=" + connected_banner;
                url_wmv += "&bannerid=" + connected_banner;
        }

        // dobim html
        if (video_type == 'rm') {
                switch ( video_size ) {
                        case 'small':
                                html = video_rm_small(url_rm); break;
                        case 'extra':
//                                html = video_rm_extra(url_rm); break;
                        default:
                                html = video_rm_normal(url_rm);
                }
        } else {
                switch ( video_size ) {
                        case 'small':
                                html = video_wmv_small(url_wmv); break;
                        case 'extra':
//                                html = video_wmv_extra(url_wmv); break;
                        default:
                                html = video_wmv_normal(url_wmv);
                }
        }

	return html;
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Procesiranje in izbira videa
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/**
 * Glavna funkcija za VIDEO. V HTML-ju klices to.
 */
function video_flash_show( video_size, zoneid ) {

        // kaksen size se mora prikazat?
        if ( !video_size )
                video_size = get_cookie('video_size');

        // kaksen tip?
        video_type = get_cookie('video_type');

        // is this zone connected?
        if ( !zoneid )
                zoneid = "" + section_id + "41";


        // dobim html

        switch ( video_size ) {
            case 'small':
                html = video_fl_small(url_fl_small); break;
            case 'extra':
                html = video_fl_extra(url_fl_extra); break;
            default:
                html = video_fl_normal(url_fl_normal);
        }

        // prikazem html
        document.write(html);
}


/**
 * Glavna funkcija za BAR VIDEO. V HTML-ju klices to.
 */
function video_bar_show( video_size, zoneid ) {

        // kaksen size se mora prikazat?
        if ( !video_size )
                video_size = get_cookie('video_size');

        // kaksen tip?
        video_type = get_cookie('video_type');

        // is this zone connected?
        if ( !zoneid )
                zoneid = "" + section_id + "41";


        // dobim html
        switch ( video_size ) {
            case 'small':
                html = video_bar(url_fl, '1', '176', '144'); break;
            case 'extra':
                html = video_bar(url_fl, '3', '600', '480'); break;
            default:
                html = video_bar(url_fl, '2', '320', '256'); break;
        }

        // prikazem html
        document.write(html);
}

/**
 * Glavna funkcija za AUDIO. V HTML-ju klices to.
 */
function audio_show() {

        // kaksen tip?
        audio_type = get_cookie('audio_type');
        // dobim html
        if (audio_type == 'rm')
                html = audio_rm_normal(url_rm);
        else
                html = audio_wma_normal(url_wmv);

        // prikazem html
        document.write(html);
}


/**
 * Spremeni velikost video okna
 */
function video_change_size( change_to ) {

        if ( typeof(change_to) == "undefined" ) {
                video_size = get_cookie('video_size');

                if (video_size == 'small')
                        set_cookie('video_size', 'normal');
                else
                        set_cookie('video_size', 'small');
        } else {
                set_cookie('video_size', change_to);
        }

        window.location.reload();
}

/**
 * Spremeni velikost video okna v BAR2
 */
function bar2_video_change_size( change_to, media_id, subtype ) {

        if ( typeof(change_to) == "undefined" ) {
                video_size = get_cookie('video_size');

                if (video_size == 'small')
                        set_cookie('video_size', 'normal');
                else
                        set_cookie('video_size', 'small');
        } else {
                set_cookie('video_size', change_to);
        }

        window.location.href = 'bar_video_show.php?media_id=' + media_id + '&subtype=' + subtype;
}


/**
 * Spremeni tip video okna
 */
function video_change_type() {
        video_type = get_cookie('video_type');

        if (video_type == 'rm')
                set_cookie('video_type', 'wmv');
        else
                set_cookie('video_type', 'rm');

        window.location.reload();
}


/**
 * Spremeni tip audio okna
 */
function audio_change_type() {
        audio_type = get_cookie('audio_type');

        if (audio_type == 'rm')
                set_cookie('audio_type', 'wmv');
        else
                set_cookie('audio_type', 'rm');
        window.location.reload();
}


/**
 * VIDEO PRI CLANKU: Naredi redirect na stran s prikazom videa z večjim formatom
 */
function video_show_extra( media_id, article_id ) {

        var url = '/video_extra/' + media_id + '_' + article_id + '.html';
        var params = 'width=710,height=600,directories=no,fullscreen=no,location=no,menubar=no,status=no,toolbar=no,top=100,left=100';

        var video_hiq = window.open( url, 'video_extra', params );

        if (window.focus)
                video_hiq.focus();
}

/**
 * ODDAJA: Naredi redirect na stran s prikazom videa z večjim formatom
 */
function video_show_extra_clip( media_id, article_id ) {

        var url = '/video_extra/clip_' + media_id + '.html';
        var params = 'width=710,height=600,directories=no,fullscreen=no,location=no,menubar=no,status=no,toolbar=no,top=100,left=100';

        var video_hiq = window.open( url, 'video_extra', params );

        if (window.focus)
                video_hiq.focus();
}

/**
 * LIVE: Naredi redirect na stran s prikazom videa z večjim formatom
 */
function video_show_extra_live( media_id, article_id ) {

        var url = '/video_extra/live_' + media_id + '.html';
        var params = 'width=710,height=600,directories=no,fullscreen=no,location=no,menubar=no,status=no,toolbar=no,top=100,left=100';

        var video_hiq = window.open( url, 'video_extra', params );

        if (window.focus)
                video_hiq.focus();
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Funkcije za prikaz HTML-jev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/**
 * Prikaz REALMEDIA - SMALL videa
 *
 * @param string url URL, ki se klice, da se prikaze video
 */
function video_rm_small(url) {

        if (url == '')
                return '';

        html  = '<object id="rp_object" name="rp_object" height="144" width="176" classid="clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa" viewastext>';
        html += '\n<param name="autostart" value="-1">';
        html += '\n<param name="src" value="' + url + '&size=-2">';
        html += '\n<param name="controls" value="imagewindow">';
        html += '\n<param name="console" value="clip1">';
        html += '\n<param name="backgroundcolor" value="#000000">';
        html += '\n<embed id="rp_embed" name="rp_embed" type="audio/x-pn-realaudio-plugin" src="' + url + '&size=-2" width="176" height="144" controls="imagewindow" autostart="true" console="clip1" nolabels="true" />';
        html += '\n</object><br />';
        html += '\n<object id="rp2" height="30" width="176" classid="clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa" viewastext>';
        html += '\n<param name="autostart" value="-1">';
        html += '\n<param name="src" value="' + url + '&size=-2">';
        html += '\n<param name="controls" value="controlpanel">';
        html += '\n<param name="console" value="clip1">';
        html += '\n<param name="backgroundcolor" value="#000000">';
        html += '\n<embed type="audio/x-pn-realaudio-plugin" src="' + url + '&size=-2" width="176" height="30" controls="controlpanel" autostart="true" console="clip1" nolabels="true" />';
        html += '\n</object>';

        return html;
}


/**
 * Prikaz REALMEDIA - NORMAL videa
 *
 * @param string url URL, ki se klice, da se prikaze video
 */
function video_rm_normal(url) {

        if (url == '')
                return '';

        html  = '<object id="rp_object" name="rp_object" height="256" width="320" classid="clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa" viewastext>';
        html += '\n<param name="autostart" value="-1">';
        html += '\n<param name="src" value="' + url + '&size=-1">';
        html += '\n<param name="controls" value="imagewindow">';
        html += '\n<param name="console" value="clip1">';
        html += '\n<param name="backgroundcolor" value="#000000">';
        html += '\n<embed id="rp_embed" name="rp_embed" type="audio/x-pn-realaudio-plugin" src="' + url + '&size=-1" width="320" height="256" controls="imagewindow" autostart="true" console="clip1" nolabels="true" />';
        html += '\n</object><br />';
        html += '\n<object id="rp2" height="30" width="320" classid="clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa" viewastext>';
        html += '\n<param name="autostart" value="-1">';
        html += '\n<param name="src" value="' + url + '&size=-1">';
        html += '\n<param name="controls" value="controlpanel">';
        html += '\n<param name="console" value="clip1">';
        html += '\n<param name="backgroundcolor" value="#000000">';
        html += '\n<embed type="audio/x-pn-realaudio-plugin" src="' + url + '&size=-1" width="320" height="30" controls="controlpanel" autostart="true" console="clip1" nolabels="true" />';
        html += '\n</object>';

        return html;
}


/**
 * Prikaz REALMEDIA - EXTRA velik video
 *
 * @param string url URL, ki se klice, da se prikaze video
 */
function video_rm_extra(url) {

        if (url == '')
                return '';

        html  = '<object id="rp_object" name="rp_object" height="480" width="640" classid="clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa" viewastext>';
        html += '\n<param name="autostart" value="-1">';
        html += '\n<param name="src" value="' + url + '&size=-1">';
        html += '\n<param name="controls" value="imagewindow">';
        html += '\n<param name="console" value="clip1">';
        html += '\n<param name="backgroundcolor" value="#000000">';
        html += '\n<embed id="rp_embed" name="rp_embed" type="audio/x-pn-realaudio-plugin" src="' + url + '&size=-1" width="640" height="480" controls="imagewindow" autostart="true" console="clip1" nolabels="true" />';
        html += '\n</object><br />';
        html += '\n<object id="rp2" height="30" width="640" classid="clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa" viewastext>';
        html += '\n<param name="autostart" value="-1">';
        html += '\n<param name="src" value="' + url + '&size=-1">';
        html += '\n<param name="controls" value="controlpanel">';
        html += '\n<param name="console" value="clip1">';
        html += '\n<param name="backgroundcolor" value="#000000">';
        html += '\n<embed type="audio/x-pn-realaudio-plugin" src="' + url + '&size=-1" width="640" height="30" controls="controlpanel" autostart="true" console="clip1" nolabels="true" />';
        html += '\n</object>';

        return html;
}


/**
 * Prikaz WINDOWSMEDIA - SMALL videa
 *
 * @param string url URL, ki se klice, da se prikaze video
 */
function video_wmv_small(url) {

        if (url == '')
                return '';

        html  = '<OBJECT id="mp_object" name="mp_object" width="176" height="214" classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">';
        html += '\n<param NAME="filename" value="' + url + '&size=-2">';
        html += '\n<param NAME="autoStart" value="true">';
        html += '\n<param NAME="showControls" value="true">';
        html += '\n<param name="ShowStatusBar" value="true">';
        html += '\n<param NAME="Autorewind" value="true">';
        html += '\n<param NAME="ShowDisplay" value="false">';
        html += '\n<param NAME="uiMode" value="mini">';
        html += '\n<EMBED id="mp_embed" name="mp_embed" type="application/x-mplayer2" ';
        html += '\npluginspage="http://www.microsoft.com/Windows/MediaPlayer/" ';
        html += '\nsrc="' + url + '&size=-2" ';
        html += '\nname="MediaPlayer1" ';
        html += '\nautostart=1 showcontrols=1 showstatusbar=1 autorewind=1 showdisplay=0 uiMode="mini" ';
        html += '\nwidth=176 ';
        html += '\nheight=214 ';
        html += '\nautostart=1 ';
        html += '\nshowcontrols=1> ';
        html += '\n</OBJECT>';

        return html;
}


/**
 * Prikaz WINDOWSMEDIA - NORMAL videa
 *
 * @param string url URL, ki se klice, da se prikaze video
 */
function video_wmv_normal(url) {

        if (url == '')
                return '';

        html  = '<object id="mp_object" name="mp_object" width="320" height="326" classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">';
        html += '\n<param NAME="filename" value="' + url + '&size=-1">';
        html += '\n<param NAME="autoStart" value="true">';
        html += '\n<param NAME="showControls" value="true">';
        html += '\n<param name="ShowStatusBar" value="true">';
        html += '\n<param NAME="Autorewind" value="true">';
        //html += '\n<param NAME="FullScreen" value="true">';
        html += '\n<param NAME="ShowDisplay" value="false"> ';
        html += '\n<param NAME="uiMode" value="mini">';
        html += '\n<embed id="mp_embed" name="mp_embed" type="application/x-mplayer2"';
        html += '\nsrc="' + url + '&size=-1" ';
        html += '\nautostart=1 showcontrols=1 showstatusbar=1 autorewind=1 showdisplay=0 uiMode="mini" ';
        html += '\nname="MediaPlayer" fullscreen=1 ';
        html += '\nwidth="320" ';
        html += '\nheight="326"> ';
        html += '\n</embed>';
        html += '\n</object>';

        return html;
}


/**
 * Prikaz WINDOWSMEDIA - NORMAL videa
 *
 * @param string url URL, ki se klice, da se prikaze video
 */
function video_wmv_extra(url) {

        if (url == '')
                return '';

        html  = '<object id="mp_object" name="mp_object" width="640" height="500" classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">';
        html += '\n<param NAME="filename" value="' + url + '&size=-1">';
        html += '\n<param NAME="autoStart" value="true">';
        html += '\n<param NAME="showControls" value="true">';
        html += '\n<param name="ShowStatusBar" value="true">';
        html += '\n<param NAME="Autorewind" value="true">';
        //html += '\n<param NAME="FullScreen" value="true">';
        html += '\n<param NAME="ShowDisplay" value="false"> ';
        html += '\n<param NAME="uiMode" value="mini">';
        html += '\n<embed id="mp_embed" name="mp_embed" type="application/x-mplayer2"';
        html += '\nsrc="' + url + '&size=-1" ';
        html += '\nautostart=1 showcontrols=1 showstatusbar=1 autorewind=1 showdisplay=0 uiMode="mini" ';
        html += '\nname="MediaPlayer" fullscreen=1 ';
        html += '\nwidth="640" ';
        html += '\nheight="500"> ';
        html += '\n</embed>';
        html += '\n</object>';

        return html;
}


/**
 * Prikaz REALMEDIA - NORMAL audio
 *
 * @param string url URL, ki se klice, da se prikaze audio
 */
function audio_rm_normal(url) {

        if (url == '')
                return '';

        html  = '<object id="RP2" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="176" height="30">';
        html += '\n<param name="src" value="' + url + '&size=-1">';
        html += '\n<param name="controls" value="ControlPanel">';
        html += '\n<param name="autostart" value="true">';
        html += '\n<param name="nolabels" value="true">';
        html += '\n<param name="reset" value="false">';
        html += '\n<param name="console" value="clip1">';
        html += '\n<embed type="audio/x-pn-realaudio-plugin" src="' + url + '&size=-1" width="176" height="30" controls="ControlPanel" autostart="true" console="Clip1" nolabels="true" />';
        html += '\n</object>';

        return html;
}


/**
 * Prikaz WINDOWSMEDIA - NORMAL audio
 *
 * @param string url URL, ki se klice, da se prikaze audio
 */
function audio_wma_normal(url) {

        if (url == '')
                return '';

        html  = '<OBJECT id="MediaPlayer" width="176" height="144" classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">';
        html += '\n<param NAME="filename" value="' + url + '&size=-1">';
        html += '\n<param NAME="autoStart" value="true">';
        html += '\n<param NAME="showControls" value="true">';
        html += '\n<param name="ShowStatusBar" value="true">';
        html += '\n<param NAME="Autorewind" value="true">';
        html += '\n<param NAME="ShowDisplay" value="false">';
        html += '\n<embed type="application/x-mplayer2"';
        html += '\nsrc="' + url + '&size=-1"';
        html += '\nautostart=1 showcontrols=0 showstatusbar=1 autorewind=1 showdisplay=0';
        html += '\nname="MediaPlayer"';
        html += '\nwidth="176"';
        html += '\nheight="144">';
        html += '\n</EMBED>';
        html += '\n</OBJECT>';

        return html;
}

/**
 * Prikaz FLASHa za BAR2
 *
 * @param string url URL, ki se klice, da se prikaze video
 */
function video_bar(url, f_size, f_width, f_height) {
        html = '<object type="application/x-shockwave-flash" ';
        html += 'data="/furniture/system/flvplayer_bar2.swf?autostart=true&file=' + url + '-' + f_size + '.flv" width="' + f_width + '" height="' + f_height + '" wmode="transparent"> ';
        html += '<param name="movie" value="/furniture/system/flvplayer_bar2.swf?autostart=true&file=' + url + '-' + f_size + '.flv" /> ';
        html += '<param name="wmode" value="transparent" /> ';
        html += '</object>';

        return html;
}

/**
 * Prikaz FLASH - SMALL videa
 *
 * @param string url URL, ki se klice, da se prikaze video
 */

function video_fl_small(url) {
    if (url == '')
        return '';

    html = '<object id="video_player" type="application/x-shockwave-flash"';
    html +='\ndata="/furniture/system/flvplayer.swf?autostart=true&file=' + url + '" width="176" height="144" wmode="transparent">';
    html +='\n<param name="movie" value="/furniture/system/flvplayer.swf?autostart=true&file=' + url + '" />';
    html +='\n<param name="wmode" value="transparent" />';
    html +='\n</object>';

    return html;
}

/**
 * Prikaz FLASH - normal videa
 *
 * @param string url URL, ki se klice, da se prikaze video
 */
function video_fl_normal(url) {
    if (url == '')
        return '';

    html = '<object id="video_player" type="application/x-shockwave-flash"';
    html +='\ndata="/furniture/system/flvplayer.swf?autostart=true&file=' + url + '" width="352" height="288" wmode="transparent">';
    html +='\n<param name="movie" value="/furniture/system/flvplayer.swf?autostart=true&file=' + url + '" />';
    html +='\n<param name="wmode" value="transparent" />';
    html +='\n</object>';

    return html;
}

/**
 * Prikaz FLASH - EXTRA videa
 *
 * @param string url URL, ki se klice, da se prikaze video
 */
function video_fl_extra(url) {
    if (url == '')
        return '';

    html = '<object id="video_extra" type="application/x-shockwave-flash"';
    html +='\ndata="/furniture/system/flvplayer.swf?autostart=true&file=' + url + '" width="704" height="576" wmode="transparent">';
    html +='\n<param name="movie" value="/furniture/system/flvplayer.swf?autostart=true&file=' + url + '" />';
    html +='\n<param name="wmode" value="transparent" />';
    html +='\n</object>';

    return html;
}


/**
 * Closes video playback
 */
function video_close( url ) {
        document.location.href = url;
}
