/**
 * Damn Small Rich Text Editor v0.2.4 for jQuery
 * by Roi Avidan <roi@avidansoft.com>
 * Demo: http://www.avidansoft.com/dsrte/
 * Released under the GPL License
 *
 * Insert Link plugin.
 */

$('.szablon').click( function() {
    alert("09qwe");
 } );

var dsRTE_szablon = function() {

    /**
     * Execute Plugin.
     */
    this.ExecuteCommand = function( dsrte, arguments, panel ) {
    	//alert("12345");
        return true;
    };

    /**
     * Prepare Plugin.
     * Attach a Click handler on the Ok button
     */
    this.PrepareCommand = function( dsrte, arguments, panel, $this ) {
        var args = arguments;
        
        $( '#cmd-'+dsrte.iframe.id+'-szablon' ).change( function() {
        	//$(this).attr("selected","selected");
        	var tmp = $(this).val();
        	//var tmp_val = $(this).html();
        	var cur_id = $(this).attr("id");
        	//$("#"+cur_id+"_span").html(tmp);
        	//$("option[value='"+tmp+"']").attr("selected","selected");
        	//$("option[value='"+tmp+"']").addClass("jakas");
        	var szablon_name = $("option[value='"+tmp+"']").html();
        	//$("#"+cur_id+"_span").html(szablon_name);
        	
        	var tmpcss = tmp.split("-"); 
        	var dodaj = $( '#'+dsrte.iframe.id).contents().find('body')
        	//dodaj.html('<span style="color:#ff0000;">a</span>');
        	//if(tmpcss[0].length) dodaj.css("font",tmpcss[0]);
        	//if(tmpcss[1].length) dodaj.css("color",tmpcss[1]);
        	
        	if ( $.browser.msie )
                dsrte.iframe.rng.select();
        	dsrte.doc.execCommand( 'fontsize', false, tmpcss[0] );
            dsrte.doc.execCommand( 'fontname', false, tmpcss[1] );
            dsrte.doc.execCommand( 'forecolor', false, tmpcss[2] );
        	
            dsrte.frame.focus();
           
           
        } );
        
        // signal callback was successfully processed.
        return true;
    };
};

// Register new plugin with dsRTE
dsRTE.RegisterPlugin( new dsRTE_szablon(), 'szablon' );



