/*
 * Copyright(c) 2009
 *
 */

// create application
bh.behaviour = function() {

    // do NOT access DOM from here; elements don't exist yet

    // private variables

    // private functions

    // public space
    return {
        // public properties, e.g. strings to translate

        // public methods
        init : function() {
            this.create_flv_players();
            this.create_video_links();
        },

        /*
         * create player instances in page.
         */
        create_flv_players: function(){
            $('.mediaplayer').each(function(cnt){
            	var id = $(this).attr('id');
            	var file = $(this).attr('data-file');
            	var image = $(this).attr('data-preview');
            	var screencolor = $(this).attr('data-screencolor');
            	var width = $(this).attr('data-width');
            	var height = $(this).attr('data-height');
            	createPlayer(id, file, "false", image, screencolor, "450", height);
            	if(window.console) console.log("Player " + id + " found, File " + file + " loaded");
            });
        },
        create_video_links: function(){
        	$('a.videolink').click(function(){
    			var playerID = $(this).attr("data-player");
    			var width = $(this).attr('data-width');
    			var height = $(this).attr('data-height');
    			var preview = $(this).attr('data-preview');
    			var player = document.getElementById(playerID);
    			var file = player.getPlaylist()[0].file;
    			player.sendEvent("STOP");
    			var url = "/live/internet/satellitewin.php?file=" + file + "&width=" + width + "&height=" + height + "&image=" + preview;
    			var popWin = window.open(url, "VIDEO", "width=" + width + ",height=" + height + ",left=100,top=200,resizableno");
    			if(window.popWin) popWin.focus();
        	});
        }
    }
}(); // end of app

// end of file