(function($)
{
    $(function()
    {
        ZeroClipboard.moviePath = wpSyntaxPath + 'flashcopy/ZeroClipboard.swf';
        wp_syntax_clip = new ZeroClipboard.Client();
        wp_syntax_clip.setHandCursor( true );
        wp_syntax_clip.addEventListener( 'complete', function()
        {
            alert( 'code copied~' );
        });
        $( 'a.wp-syntax-copy' ).mouseover(function()
        {
            var v = this.parentNode.getElementsByTagName('textarea')[0].value;

            wp_syntax_clip.setText( v );
            
            if (wp_syntax_clip.div)
            {
                wp_syntax_clip.receiveEvent('mouseout', null);
                wp_syntax_clip.reposition(this);
            }
            else wp_syntax_clip.glue(this);
            
            wp_syntax_clip.receiveEvent('mouseover', null);
        });
        $( 'a.wp-syntax-run').click(function()
        {
            var c = this.parentNode.getElementsByTagName('textarea')[0].value;
            var w = window.open('','_blank','');
            w.document.write(c);
            w.document.close();
        });
    });
})( jQuery );
