/* START SHOW FLASH VIDEO */

/* GLOBAL VARS */

// flowplayer files location
var fpsrc = '/visage/static/flowplayer-3.1.1.swf' ;
var fpcsrc = '/visage/static/flowplayer.controls-3.1.1.swf';
var fpctsrc = '/visage/static/flowplayer.controls-tube-3.1.1.swf';
var fpasrc = '/visage/static/flowplayer.audio-3.1.0.swf';

// visage multimedia files base urls
var vurl = '/visage/flv/';
var aurl = '/visage/pod/';

// Flowplayer 3.1.1 configuration object
// flowplayer("player", Flash configuration, Player configuration);
var conf = { 

	// default flash configuration
	defflash: {
		
		src: fpsrc,
		// we need at least this Flash version 
		version: [9, 115], 
	 
		// older versions will see a custom message 
		onFail: function()  { 
			document.getElementById("info").innerHTML = 
				"You need the latest Flash version to see MP4 movies. " + 
				"Your version is " + this.getVersion(); 
		} 
	
	},

	// default player configuration - 3rd arg
	defplay: {
		
		buffering : true,	// rotating buffer animation
		debug : false
		
	},
	
    // default video clips configuration 
    defclip: { 
        
		url: '',
		scaling: 'scale',
		autoPlay: false, 
		autoBuffering: true, 
		splashImageFile : 'http://forourfuture.aptsolutions.net/atwone/flv/angelo_welcome.mov.jpg',
		baseUrl: vurl, 	// base path for flv vids in visage
		
        // functions are also supported 
        onBegin: function() { 
             
            // make controlbar visible in 4000 seconds 
            this.getControls().fadeIn(4000); 
        } 
         
    }, 

	// default control configuration
    defcntrl : { 
        url: fpctsrc,

        // display properties 

        backgroundColor: '#2d3e46', 
        backgroundGradient: 'low', 

        // controlbar-specific configuration 
        fontColor: '#ffffff',
        timeFontColor: '#333333', 
        autoHide: 'never', 
 		
        // which buttons are visible and which are not? 
        play:true, 
        volume:true, 
        mute:true, 
        time:true, 
        stop:false, 
        playlist:false, 
        fullscreen:true, 
		
         // scrubber is a well-known nickname for the timeline/playhead combination 
        scrubber: true 
    },
	
	// audio control configuration
	aucntrl: {
        url: fpctsrc,

        // display properties 
        backgroundColor: '#2d3e46', 
        backgroundGradient: 'low', 
		
		fullscreen: false, 
        height: 30 
	},
	
    // my skins 
    skins: {         
        gray:  { 
            backgroundColor: '#666666', 
            buttonColor: '#333333', 
            opacity: 0, 
            time: false 
        } 
         
        // setup additional skins here ...         
    } 
     
}

// play video with default configuration
var playVideo = function (id){
	
	var fUrl = document.getElementById(id).getAttribute('href');
	var vUrl = fUrl.substring(fUrl.lastIndexOf('/')+1,fUrl.length);

	//console.log('base filename:'+conf.defclip.baseUrl);
	
	// set video url to video configuration JSON
	conf.defclip.url = vUrl;

	$f( id , conf.defflash ,  { 
			 
		// default configuration for a clip 
		clip: conf.defclip, 
		 
		// setup controlbar to use tube skin
		plugins: {         
			controls: conf.defcntrl         
		} 
		 
	}); 
}

// play audio with default configuration
var playAudio = function (id,onload){

	$f( id , conf.defflash, { 
	
		clip: { 
			autoPlay: onload, 
			baseUrl: aurl 	// base path for podcasts in visage
		},
		// fullscreen button not needed here 
		plugins: { 
			controls: conf.aucntrl
		}
	 
	});
}

 /* UTILITIES */


var getFileExtension = function(file){
    var dotPos = -1;
    if (-1 != (dotPos = file.lastIndexOf("."))){
        return file.substring(dotPos + 1); 
    }
    return "";
}

