var browser=navigator.appName; //Microsoft Internet Explorer - Netscape
var b_version=navigator.appVersion; //4 - <
var version=parseFloat(b_version);
var match = /MSIE\s+(\d+\.\d+)/i.exec(b_version);

var ad_file = false;

    function createAdd(id, urlflv, adfile, img){
        if(initFile && initImage && initTitle){
            if(browser == 'Microsoft Internet Explorer' && parseFloat(match[1]) == 6){
                createIEPlayer(id, initFile, initImage);
            }else{
                createPlayer(id, initFile, initImage);
            }
            setTimeout(resetText, 100);
            return;
        }
        var f = function() {createPlayer(id, urlflv, img); };
        file_to_play = adfile;
        if(adfile == ''){
            ad_file = true;
            f = '';
        }
        if(ad_file == true){
            file_to_play = urlflv;
            if(browser == 'Microsoft Internet Explorer' && parseFloat(match[1]) == 6){
                playIEVideo(id, file_to_play, img);
            }else{
                playVideo(id, file_to_play, img);
            }
        }else{
            if(browser == 'Microsoft Internet Explorer' && parseFloat(match[1]) == 6){
                playAdIE(id, urlflv, file_to_play, img);
            }else{
                playAd(id, urlflv, file_to_play, img);
            }
        }
    }
    
    function recreateAdd(id, urlflv, adfile, img, title, description){
        file_to_play = adfile;
        if(adfile == ''){
            ad_file = true;
        }
        if(ad_file == true){
            //document.getElementById('VideoTitle').innerHTML=title;
            //document.getElementById('VideoDescription').innerHTML=description;
            file_to_play = urlflv;
            if(browser == 'Microsoft Internet Explorer' && parseFloat(match[1]) == 6){
                playIEVideo(id, file_to_play, img); 
            }else{
                playVideo(id, file_to_play, img);
            }
        }else{
            if(browser == 'Microsoft Internet Explorer' && parseFloat(match[1]) == 6){
                playAdIE(id, urlflv, file_to_play, img);
            }else{
                playAd(id, urlflv, file_to_play, img);
            }
        }
        initTitle = title;
        initDescription = description;
        setTimeout(resetText, 100);
    }
    
    function recreateAddDelo(id, urlflv, adfile, img, title, description){
        file_to_play = adfile;
        if(ad_file == true){
            file_to_play = urlflv;
            if(browser == 'Microsoft Internet Explorer' && parseFloat(match[1]) == 6){
                playIEVideo(id, file_to_play, img);
            }else{
                playVideo(id, file_to_play, img);
            }
        }else{
            if(browser == 'Microsoft Internet Explorer' && parseFloat(match[1]) == 6){
                playAdIE(id, urlflv, file_to_play, img);
            }else{
                playAd(id, urlflv, file_to_play, img);
            }
        }
    }
    
    function createPlayer(id, urlflv, img ){
        $f(id, "/assets/delo/plugins/news/flowplayer/flowplayer.commercial-3.1.5.swf",  {
        wmode: 'transparent',
        key: '#$5cd154c320fea027705',
        logo: { 
            url: "/assets/delo/images/new/logo_small.png",
            top: 10, 
            right: 10, 
            fullscreenOnly: false,
            linkUrl: 'http://www.delo.si'
        },
        plugins: { 
            controls: {
                all: false,
                next: false,
                previous: false, 
                volume: true,
                time:true, 
                scrubber:true,
                fullscreen: true,
                play: true,
                pause: true,
                tooltips: { 
                    buttons: true,
                    play: 'Predvajaj',
                    previous: 'Prejšni',
                    next: 'Naslednji', 
                    pause: 'Pavza', 
                    fullscreen: 'Celozaslonski način' 
              }, 
              durationColor: '#ffffff',
              timeBgColor: '#212e36',
              backgroundColor: '#0c5ba0',
              volumeSliderGradient: 'none',
              sliderGradient: 'none',
              bufferColor: '#212e36',
              sliderColor: '#212e36',
              progressGradient: 'none',
              volumeSliderColor: '#212e36',
              progressColor: '#cccccc',
              buttonColor: '#212e36',
              backgroundGradient: 'high',
              tooltipColor: '#0c5ba0',
              buttonOverColor: '#0c5ba0',
              borderRadius: '0px',
              bufferGradient: 'none',
              tooltipTextColor: '#FFFFFF',
              timeColor: '#FFFFFF',
              height: 24,
              opacity: 1.0
          } 
        },
        playlist: [ 
         
            { 
                url: img, 
                scaling: 'orig' 
            }, 
            { 
                url: urlflv,  
                autoPlay: true,  
                autoBuffering: false,
                scaling: 'orig',
                
                onFinish: function () { this.getPlugin("play").css({opacity: 0});} 
            } 
            ] 
        });
    }
    
    function playAd(id, urlflv, file_to_play, img){
        var f = function() {createPlayer(id, urlflv, img); };
        $f(id, "/assets/delo/plugins/news/flowplayer/flowplayer.commercial-3.1.5.swf",  {
        wmode: 'transparent',
        key: '#$5cd154c320fea027705',
        logo: { 
            url: "/assets/delo/images/new/logo_small.png",
            top: 10, 
            right: 10, 
            fullscreenOnly: false,
            linkUrl: 'http://www.delo.si'
        },
        plugins: { 
            controls: {
                all: false,
                volume: true,
                time:false, 
                scrubber:false,
                durationColor: '#ffffff',
          timeBgColor: '#0c5ba0',
          backgroundColor: '#0c5ba0',
          volumeSliderGradient: 'none',
          sliderGradient: 'none',
          bufferColor: '#0c5ba0',
          sliderColor: '#0c5ba0',
          progressGradient: 'none',
          volumeSliderColor: '#212e36',
          progressColor: '#0c5ba0',
          buttonColor: '#212e36',
          backgroundGradient: 'high',
          tooltipColor: '#0c5ba0',
          buttonOverColor: '#0c5ba0',
          borderRadius: '0px',
          bufferGradient: 'none',
          tooltipTextColor: '#FFFFFF',
          timeColor: '#FFFFFF',
          height: 24,
          opacity: 1.0
            }         
        },
        playlist: [{ 
                url: img, 
                scaling: 'orig' 
            }, 
            { 
                url: file_to_play,  
                autoPlay: true,  
                autoBuffering: false,
                scaling: 'orig',
                
                onFinish: function () { 
                    setTimeout(f,100);
                    ad_file = true;
                } 
            }] 
        }); 
    }
    
    function playVideo(id, file_to_play, img){
        $f(id, "/assets/delo/plugins/news/flowplayer/flowplayer.commercial-3.1.5.swf",  {
        wmode: 'transparent',
        key: '#$5cd154c320fea027705',
        logo: { 
            url: "/assets/delo/images/new/logo_small.png",
            top: 10, 
            right: 10, 
            fullscreenOnly: false,
            linkUrl: 'http://www.delo.si'
        },
        plugins: { 
            controls: {
                all: false,
                next: false,
                previous: false, 
                volume: true,
                time:true, 
                scrubber:true,
                fullscreen: true,
                play: true,
                pause: true,
                tooltips: { 
                    buttons: true,
                    play: 'Predvajaj',
                    previous: 'Prejšni',
                    next: 'Naslednji', 
                    pause: 'Pavza', 
                    fullscreen: 'Celozaslonski način' 
              }, 
              durationColor: '#ffffff',
              timeBgColor: '#212e36',
              backgroundColor: '#0c5ba0',
              volumeSliderGradient: 'none',
              sliderGradient: 'none',
              bufferColor: '#212e36',
              sliderColor: '#212e36',
              progressGradient: 'none',
              volumeSliderColor: '#212e36',
              progressColor: '#cccccc',
              buttonColor: '#212e36',
              backgroundGradient: 'high',
              tooltipColor: '#0c5ba0',
              buttonOverColor: '#0c5ba0',
              borderRadius: '0px',
              bufferGradient: 'none',
              tooltipTextColor: '#FFFFFF',
              timeColor: '#FFFFFF',
              height: 24,
              opacity: 1.0
            }
            },
            playlist: [{ 
                url: img, 
                scaling: 'orig' 
            }, 
            { 
                url: file_to_play,  
                autoPlay: true,  
                autoBuffering: false,
                scaling: 'orig',
                
                onFinish: function () { 
                    this.getPlugin("play").css({opacity: 0});
                } 
            }]
        });
    }
    
    //IE 6 Issues
    function createIEPlayer(id, urlflv, img ){
        flowplayer(id, "/assets/delo/plugins/news/flowplayer/flowplayer.commercial-3.1.5.swf",  {
        wmode: 'transparent',
        key: '#$5cd154c320fea027705',
        logo: { 
            url: "/assets/delo/images/new/logo_small.png",
            top: 10, 
            right: 10, 
            fullscreenOnly: false,
            linkUrl: 'http://www.delo.si'
        },
        plugins: { 
            controls: {
                all: false,
                next: false,
                previous: false, 
                volume: true,
                time:true, 
                scrubber:true,
                fullscreen: true,
                play: true,
                pause: true,
                tooltips: { 
                    buttons: true,
                    play: 'Predvajaj',
                    previous: 'Prejšni',
                    next: 'Naslednji', 
                    pause: 'Pavza', 
                    fullscreen: 'Celozaslonski način' 
              }, 
              durationColor: '#ffffff',
              timeBgColor: '#212e36',
              backgroundColor: '#0c5ba0',
              volumeSliderGradient: 'none',
              sliderGradient: 'none',
              bufferColor: '#212e36',
              sliderColor: '#212e36',
              progressGradient: 'none',
              volumeSliderColor: '#212e36',
              progressColor: '#cccccc',
              buttonColor: '#212e36',
              backgroundGradient: 'high',
              tooltipColor: '#0c5ba0',
              buttonOverColor: '#0c5ba0',
              borderRadius: '0px',
              bufferGradient: 'none',
              tooltipTextColor: '#FFFFFF',
              timeColor: '#FFFFFF',
              height: 24,
              opacity: 1.0
          } 
        },
        clip:
            { 
                url: urlflv,  
                autoPlay: true,  
                autoBuffering: false,
                scaling: 'orig',
                
                onFinish: function () { this.getPlugin("play").css({opacity: 0});} 
            } 
        });
    }
    
    function playAdIE(id, urlflv, file_to_play, img){
        var f = function() {createIEPlayer(id, urlflv, img); };
        flowplayer(id, "/assets/delo/plugins/news/flowplayer/flowplayer.commercial-3.1.5.swf",  {
        wmode: 'transparent',
        key: '#$5cd154c320fea027705',
        logo: { 
            url: "/assets/delo/images/new/logo_small.png",
            top: 10, 
            right: 10, 
            fullscreenOnly: false,
            linkUrl: 'http://www.delo.si'
        },
        plugins: { 
            controls: {
                all: false,
                volume: true,
                time:false, 
                scrubber:false,
                durationColor: '#ffffff',
          timeBgColor: '#0c5ba0',
          backgroundColor: '#0c5ba0',
          volumeSliderGradient: 'none',
          sliderGradient: 'none',
          bufferColor: '#0c5ba0',
          sliderColor: '#0c5ba0',
          progressGradient: 'none',
          volumeSliderColor: '#212e36',
          progressColor: '#0c5ba0',
          buttonColor: '#212e36',
          backgroundGradient: 'high',
          tooltipColor: '#0c5ba0',
          buttonOverColor: '#0c5ba0',
          borderRadius: '0px',
          bufferGradient: 'none',
          tooltipTextColor: '#FFFFFF',
          timeColor: '#FFFFFF',
          height: 24,
          opacity: 1.0
            }         
        },
       clip:{ 
                url: file_to_play,  
                autoPlay: true,  
                autoBuffering: false,
                scaling: 'orig',
                
                onFinish: function () { 
                    setTimeout(f,100);
                    ad_file = true;
                } 
            } 
        }); 
    }
    
    function playIEVideo(id, file_to_play, img){
        flowplayer(id, "/assets/delo/plugins/news/flowplayer/flowplayer.commercial-3.1.5.swf",  {
        wmode: 'transparent',
        key: '#$5cd154c320fea027705',
        logo: { 
            url: "/assets/delo/images/new/logo_small.png",
            top: 10, 
            right: 10, 
            fullscreenOnly: false,
            linkUrl: 'http://www.delo.si'
        },
        plugins: { 
            controls: {
                all: false,
                next: false,
                previous: false, 
                volume: true,
                time:true, 
                scrubber:true,
                fullscreen: true,
                play: true,
                pause: true,
                tooltips: { 
                    buttons: true,
                    play: 'Predvajaj',
                    previous: 'Prejšni',
                    next: 'Naslednji', 
                    pause: 'Pavza', 
                    fullscreen: 'Celozaslonski način' 
              }, 
              durationColor: '#ffffff',
              timeBgColor: '#212e36',
              backgroundColor: '#0c5ba0',
              volumeSliderGradient: 'none',
              sliderGradient: 'none',
              bufferColor: '#212e36',
              sliderColor: '#212e36',
              progressGradient: 'none',
              volumeSliderColor: '#212e36',
              progressColor: '#cccccc',
              buttonColor: '#212e36',
              backgroundGradient: 'high',
              tooltipColor: '#0c5ba0',
              buttonOverColor: '#0c5ba0',
              borderRadius: '0px',
              bufferGradient: 'none',
              tooltipTextColor: '#FFFFFF',
              timeColor: '#FFFFFF',
              height: 24,
              opacity: 1.0
            }
            },
            clip:{ 
                url: file_to_play,  
                autoPlay: true,  
                autoBuffering: false,
                scaling: 'orig',
                
                onFinish: function () { 
                    this.getPlugin("play").css({opacity: 0});
                } 
            } 
        });
    }
    //IE6 Issues
    
    var objTimer;
    var objNavigation;
    var scrollStep = 50;
    var scrollWidth;
    var step = 0.1;
    
            function moveLeft(){
                if(objNavigation.scrollLeft > 0) {
                    objNavigation.scrollLeft = objNavigation.scrollLeft - Math.round(step++);
                    objTimer = setTimeout('moveLeft();', scrollStep);
                }
            }
    
            function moveRight(){
                if(objNavigation.scrollLeft < (scrollWidth - 490)) {
                    objNavigation.scrollLeft = objNavigation.scrollLeft + Math.round(step++);
                    objTimer = setTimeout('moveRight();', scrollStep);
                }
            }
    
            function moveStop() { 
                step = 1;
                window.clearTimeout(objTimer); 
            }
    
            $(function() 
            {
                // left
                $("a#pageNavigationLeft").mouseover(moveLeft);
                $("a#pageNavigationLeft").mouseout(moveStop);
    
                // right
                $("a#pageNavigationRight").mouseover(moveRight);
                $("a#pageNavigationRight").mouseout(moveStop);
    
                // init
                objNavigation = document.getElementById("NMWCCategoriesNames");
                if ( objNavigation ) scrollWidth = objNavigation.scrollWidth;
            });
            
    var prevColor;
    
            function hoverCnameIn(obj) {
                prevColor = document.getElementById(obj).style.backgroundColor;
                document.getElementById(obj).style.backgroundColor='#064e88';
            }
            
            function hoverCnameOut(obj) { 
                document.getElementById(obj).style.backgroundColor=prevColor; 
            }
    
            function changeVideo(num) {
    
                url = videos[num];
                preview = previews[num];
                
                recreateAdd('playerFlow', url, adfile, preview, titles[num],descriptions[num])
                
                //for( var i=0; i < videos.length; i++) {document.getElementById('Cname'+i).style.backgroundColor='#36719b'; }
                //document.getElementById('Cname'+num).style.backgroundColor='#064e88';
                //prevColor = '#064e88';
           }
           
            function resetText(){
            	if(document.getElementById('VideoTitle')){
                	document.getElementById('VideoTitle').innerHTML=initTitle;
            	}
            	if(document.getElementById('VideoDescription')){
                	document.getElementById('VideoDescription').innerHTML=initDescription;
            	}  
            }
            
            function switchTab(obj, wrapper){
        if(document.getElementById){
            divs=document.getElementById(wrapper).getElementsByTagName("DIV");
            for(i=0;i<divs.length;i++){
                if (divs[i].className=="tab"){
                    divs[i].style.display = "none";
                    document.getElementById(divs[i].id+'_nav').className = divs[i].id+"Tab";
                }
            }
            document.getElementById(obj).style.display = "block";
            document.getElementById(obj+'_nav').className = obj+"TabSelected";
        }
    }
    
    function toggleDiv(id,flagit) {
        if (flagit=="1"){
            if (document.layers) 
                document.layers[''+id+''].visibility = "show"
            else if (document.all) 
                document.all[''+id+''].style.visibility = "visible"
            else if (document.getElementById) 
                document.getElementById(''+id+'').style.visibility = "visible"
        }
        else
        if (flagit=="0"){
            if (document.layers) 
                document.layers[''+id+''].visibility = "hide"
            else if (document.all) 
                document.all[''+id+''].style.visibility = "hidden"
            else if (document.getElementById) 
                document.getElementById(''+id+'').style.visibility = "hidden"
        }
    }
