/*
* Sitewide JS functions go here
*/
$(window).ready( function()
{
	/*
	* Clear google search box
	*/
	$("#magellen-search-field").click(function(e)
	{
		$("#magellen-search-field").val('');
		return false;
	});		
		
    
    //replace Player with flowplayer
    
    $("param[value='/manager/wysiwygPro/media/player.swf']").each(function()
    {
        // skip IE 6 entirely.
        if($.browser.msie && $.browser.version=="6.0")
        {
            return;
        }


        // Get OBJECT
        var $this = $(this).parents('object');

        var width = $this.attr('width');
        var height = $this.attr('height');
        
        // create DIV container
        var $div = $('<div class="flowplayer">');

        $div.width(width);
        $div.height(height);
        
        var $img = $('<img src="/manager/wysiwygPro/media/flowplayer/play_large.png" alt="Play this video" />');
        $div.append($img);
                
        // Extract+apply URL
        var url = $this.find('param[name=flashvars]').attr('value');
        url = url.substring(url.indexOf('/'), url.indexOf('&'));      
        $div.attr('href', url);
        
        var background = url+'.jpg';
        $div.css('background', 'url('+background+')');
                
        // Insert and remove
        $this.before( $div );
		$this.before( $('<br class="clear" />') );
        $this.remove();        
    });

	// Insitgate player
    flowplayer("div.flowplayer", "/manager/wysiwygPro/media/flowplayer/flowplayer-3.2.7.swf");
});
