/*
Script: kap_flashFunctions.js
    KickApps Flash Functions (used throughout the platform)

General Information:
    Company - <http://www.kickapps.com>
    Created - Wednesday, April 05, 2007 | 8:55 AM

Author:
    Oliver Nassar - onassar@kickapps.com

Editing:
    onassar - Wednesday, April 05, 2007 | 9:13 AM

Notes:
    - This file handles the creating of new SWF objects
    - Should only be used/included on pages with any sort of flash 
    - kap_mootools.js *dependent*
    - kap_swfobject.js *dependent*
*/

    // if the JS file dealing with swf objects isn't yet in the page
    if(!$('ka_swfObjectFile'))
    {
        //new Asset.javascript('swfobject.js',{id:'kap_swfObjectFile'});
    }

/*
Function: kap_kickRecordSwf
    Creates the new swf object (and returns it to the call) for recording media

Arguments:
    flashConnectString - the rtmp path to the flash server (normally)
    affiliateSiteId - the id of the affiliate (used for file writing I'm guessing?)
    userId - the id of the user who is viewing the recorder
    uniqueTimestamp - a unique timestamp that is used for file creating and storage
    mediaType - what type of media is being recorded (video or audio)
    options - an options object which allows more options to be specified that control the look and behaviour of the recorder

Options Object Properties:
    messageBoard - whether the recorder is being used specifically on the message board page
    height - the desired height of the recorder

Notes:
    - This function is/will be used throughout the platform; therefore _careful_ with any changes or additions
    - Any modifications to handle new options properties is fine, but should ideally be tested wherever else the recorder is used to ensure no bugs
*/

    // function to intiate the recording swf
    function kap_kickRecordSwf(flashConnectString,affiliateSiteId,userId,uniqueKey,mediaType,options)
    {
        // if the set of optional paramters is empty (object has not been set), create an empty object
        var options      =    typeof options=='undefined' ? new Object() : options;

        // create an instance of the open source swf object
        var swfObject    =    new SWFObject
                              (
                                  /*'http://staging.kickapps.com*/'/flash/kickapps_record.swf?blog_connect_string='+flashConnectString+'&affiliateSiteId='+affiliateSiteId+'&userId='+userId+
                                  '&timestamp='+uniqueKey+'&blogMode=_'+mediaType+'&status=new&messageBoard='+(!options.messageBoard ? false : options.messageBoard),'kickappsblogform',
                                  (!options.height ? '450' : options.height),(mediaType=='audio' ? '150' : '250'), '8','#000000'
                              );
        // add the required paramters (for the recorder)
        swfObject.addParam('bgcolor','#000000');
        swfObject.addParam('quality','high');
        swfObject.addParam('swLiveConnect','true');
        swfObject.addParam('wmode','transparent');

        // return the object
        return swfObject;
    }

/*
Function: kap_flashMiniPlayer
    Creates the new swf object (and returns it to the call) for viewing/playing media in a mini player

Arguments:
    flvLoc - the location of the flash file
    imgLog - the location of any associated image to the flash player (dimensions are important)
    options - *optional*; the options object which allows for further control of the mini player

Options Object Properties:
    isAutoloading - whether or not the player should auto load (aka auto play) the media when it loads
    messageBoard - whether the mini player is being shown/used/played on the message board application
    width - the desired width of the mini player (defaults to 150)
    height - the desired height of the mini player (defaults to 100)

Notes:
    - This function is/will be used throughout the platform; therefore _careful_ with any changes or additions
    - Any modifications to handle new options properties is fine, but should ideally be tested wherever else the recorder is used to ensure no bugs
    - Yes these are the same notes as the function above; not lazy, they just happen to apply
*/

    // function to initiate the mini player swf
    function kap_flashMiniPlayer(flvLoc,imgLoc,options)
    {
        // if the set of optional paramters is empty (object has not been set), create an empty object
        var options      =    typeof options=='undefined' ? new Object() : options;
        // create an instance of the open source swf object
        var swfObject    =    new SWFObject
                              (
                                  /*'http://staging.kickapps.com*/'/flash/mediaPlayerMini.swf?imagePath='+imgLoc+'&isAutoloading='+
                                  (!options.isAutoloading ? false : options.isAutoloading)+'&messageBoard='+
                                  (!options.messageBoard ? false : options.messageBoard)+'&mediaPath='+flvLoc,'mediaplayer',
                                  (!options.width ? true : 150),(!options.height ? true : 100),'8','#000000'
                              );
        // add the required paramters
    	swfObject.addParam('allowScriptAccess','true');
    	swfObject.addParam('swLiveConnect','true');
        swfObject.addParam('bgcolor','#000000');
        swfObject.addParam('quality','high');
        swfObject.addParam('wmode','transparent');
        swfObject.write(options.id);
    }