// closure to avoid namespace collision
/*
 * ALERT BUTTON
 */
(function() {
    tinymce.create('tinymce.plugins.alert', {
        init: function(ed, url) {
            ed.addButton('alert', {
                title: 'Alert',
                image: url + '/alert-ico.png',
                onclick: function() {

                    alert_form();
                	jQuery('.wpb_bootstrap_modals').css('z-index', '100');
                    jQuery('div.modal').css('z-index', '101');
                    jQuery('.modal-backdrop').css('z-index', '100');

                    tb_show('Alert | Webnus theme shortcode manager', '#TB_inline?width=900&inlineId=alert-form');
                    jQuery('#TB_window').center();
                    jQuery('#TB_window').css('height', '250');
                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('alert', tinymce.plugins.alert);



    function alert_form()
    {

        // creates a form to be displayed everytime the button is clicked
        // you should achieve this using AJAX instead of direct html code like this

        /*
         * 
         * <tr>\
         <th><label for="testimonial-form-title">Title</label></th>\
         <td><input type="text" name="testimonial-form-title" id="testimonial-form-title" value="Title"  /><br />\
         <small>Specify the Testimonial Title.</small>\
         </tr>\
         */

        var form = jQuery('<div id="alert-form"><table id="alert-table" class="form-table">\
				<tr>\
				<th><label for="alert-form-type">Type</label></th>\
				<td><select  name="alert-form-type" id="alert-form-type">\
				<option value="info">Info</option><option value="success">Success</option><option value="warning">Warning</option><option value="danger">Danger</option></select><br />\
				<small>Alert Type</small>\
				</tr>\
				<tr>\
				<th><label for="alert-form-close">Close Button</label></th>\
				<td><input type="checkbox" name="alert-form-close" id="alert-form-close" value="yes"   /><br />\
				<small>Has Close Button?</small>\
				</tr>\
				</table>\
				<p class="submit">\
				<input type="button" id="alert-form-submit" class="button-primary" value="Insert Shortcode" name="submit" />\
				</p>\
				</div>');

        var table = form.find('table');
        form.appendTo('body').hide();


        form.find('#alert-form-submit').click(function() {
            var type = table.find("#alert-form-type").val();
            if(table.find("#alert-form-close:checked").attr('checked'))
			var close = 'true';
			else
			var close = 'false';
			

            var shortcode = '[alert type="' + type + '" close="' + close + '"]Content Text[/alert]';



            tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);

            // closes Thickbox
            tb_remove();
        });

    }
})(jQuery);

/*
 * BUTTON
 */
(function() {
    tinymce.create('tinymce.plugins.webnus_button', {
        init: function(ed, url) {
            ed.addButton('webnus_button', {
                title: 'Button',
                image: url + '/button-ico.png',
                onclick: function() {
                	jQuery('.wpb_bootstrap_modals').css('z-index', '100');
                    jQuery('div.modal').css('z-index', '101');
                    jQuery('.modal-backdrop').css('z-index', '100');


                    button_form();
                    tb_show('Button | Webnus theme shortcode manager', '#TB_inline?width=700&inlineId=button-form');

                    jQuery('#TB_ajaxContent').css('height', 660);
                    jQuery('#TB_window').css('height', 660);
                    jQuery('#TB_window').center();

                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('webnus_button', tinymce.plugins.webnus_button);


    function button_form()
    {

        // creates a form to be displayed everytime the button is clicked
        // you should achieve this using AJAX instead of direct html code like this
        var form = jQuery('<div id="button-form"><table id="button-table" class="form-table">\
				<tr>\
					<th><label for="button-form-url">URL</label></th>\
					<td><input type="text" name="button-form-url" id="button-form-url" value="http://"  /><br />\
					<small>Specify the Button URL.</small>\
				</tr>\
				<tr>\
					<th><label for="button-form-target">Target</label></th>\
					<td><select id="button-form-target"><option value="_blank">Blank</option><option value="_self">Self</option><option value="_parent">Parent</option><option value="_top">Top</option></select><br />\
					<small>Specify the Button Target.</small></td>\
				</tr>\
				<tr>\
					<th><label for="button-form-color">Color</label></th>\
					<td><select id="button-form-color"><option value="green">Green</option><option value="red">Red</option><option value="blue">Blue</option><option value="gray">Gray</option><option value="cherry">Cherry</option><option value="orchid">Orchid</option><option value="pink">Pink</option><option value="orange">Orange</option><option value="teal">Teal</option><option value="skyblue">Skyblue</option><option value="jade">Jade</option></select><br />\
					<small>Specify the Button Color.</small></td>\
				</tr>\
				<tr>\
					<th><label for="button-form-size">Size</label></th>\
					<td><select id="button-form-size"><option value="medium">Medium</option><option value="small">Small</option><option value="large">Large</option></select><br />\
					<small>Specify the Button Target.</small></td>\
				</tr>\
				<tr>\
					<th><label for="button-form-border">Border</label></th>\
					<td><select id="button-form-border"><option value="false">Normal</option><option value="true">Bordered</option><br />\
					<small>Specify the Border Type.</small></td>\
				</tr>\
				<tr>\
					<th><label for="button-form-icon">Icon</label></th>\
					<td><input type="text" name="button-form-icon" id="button-form-icon" value=""  /><br />\
					<small>Specify the Button Icon.</small>\
				</tr>\
				<tr>\
					<th><label for="button-form-text">Text</label></th>\
					<td><input type="text" name="button-form-text" id="button-form-text" value="Button Text"  /><br />\
					<small>Specify the Button Target.</small></td>\
				</tr>\
				</table>\
				<p class="submit">\
				<input type="button" id="button-form-submit" class="button-primary" value="Insert Shortcode" name="submit" />\
				</p>\
				</div>');

        var table = form.find('table');
        form.appendTo('body').hide();

        // handles the click event of the submit button
        form.find('#button-form-submit').click(function() {
            // defines the options and their default values
            // again, this is not the most elegant way to do this
            // but well, this gets the job done nonetheless
            var button_form_url = table.find("#button-form-url").val();
            var button_form_target = table.find("#button-form-target option:selected").val();
            var button_form_color = table.find("#button-form-color option:selected").val();
            var button_form_size = table.find("#button-form-size option:selected").val();
            var button_form_text = table.find("#button-form-text").val();
			var button_form_border = table.find("#button-form-border").val();
			var button_form_icon = table.find("#button-form-icon").val();





            var shortcode = '[button url="' + button_form_url + '" target="' + button_form_target + '" color="' + button_form_color + '" size="' + button_form_size + '" border="' + button_form_border + '" icon="' + button_form_icon +  '"]'+button_form_text+'[/button]';
            // inserts the shortcode into the active editor

            if (tinyMCE.activeEditor.selection.getContent() != '') {
                tinyMCE.activeEditor.selection.setContent('[button url="' + button_form_url + '" target="' + button_form_target + '" color="' + button_form_color + '" size="' + button_form_size + '" border="' + button_form_border + '" icon="' + button_form_icon + '"]' + tinyMCE.activeEditor.selection.getContent() + '[/button]');
            } else
                tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);

            // closes Thickbox
            tb_remove();
        });

    }


})(jQuery);





/*
 * Highlight
 */
(function() {
    tinymce.create('tinymce.plugins.highlight', {
        init: function(ed, url) {
            ed.addButton('highlight', {
                title: 'Highlight',
                image: url + '/highlight-ico.png',
                onclick: function() {
                	jQuery('.wpb_bootstrap_modals').css('z-index', '100');
                    jQuery('div.modal').css('z-index', '101');
                    jQuery('.modal-backdrop').css('z-index', '100');


                    highlight_form();
                    tb_show('Highlight | Webnus theme shortcode manager', '#TB_inline?width=700&inlineId=highlight-form');
                    jQuery('#TB_window').css('height', 150);
                    jQuery('#TB_window').center();

                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('highlight', tinymce.plugins.highlight);



    function highlight_form()
    {

        // creates a form to be displayed everytime the button is clicked
        // you should achieve this using AJAX instead of direct html code like this
        var form = jQuery('<div id="highlight-form"><table id="highlight-table" class="form-table">\
				<tr>\
					<th><label for="highlight-form-no">Highlight</label></th>\
					<td><select id="highlight-form-no"><option value="highlight1">Highlight 1</option><option value="highlight2">Highlight 2</option><option value="highlight3">Highlight 3</option><option value="highlight4">Highlight 4</option></select><br />\
					<small>Specify the Highlight.</small></td>\
				</tr>\
				</table>\
				<p class="submit">\
				<input type="button" id="highlight-form-submit" class="button-primary" value="Insert Shortcode" name="submit" />\
				</p>\
				</div>');

        var table = form.find('table');
        form.appendTo('body').hide();


        form.find('#highlight-form-submit').click(function() {
            var highlight_form_no = table.find("#highlight-form-no option:selected").val();

            var shortcode = '[' + highlight_form_no + ']Default Highlight Text[/' + highlight_form_no + ']';


            if (tinyMCE.activeEditor.selection.getContent() != '') {
                tinyMCE.activeEditor.selection.setContent('[' + highlight_form_no + ']' + tinyMCE.activeEditor.selection.getContent() + '[/' + highlight_form_no + ']');
            } else
                tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);

            // closes Thickbox
            tb_remove();
        });

    }



})(jQuery);




/*
 * Dropcap
 */
(function() {
    tinymce.create('tinymce.plugins.dropcap', {
        init: function(ed, url) {
            ed.addButton('dropcap', {
                title: 'Dropcap',
                image: url + '/dropcap-ico.png',
                onclick: function() {
                	jQuery('.wpb_bootstrap_modals').css('z-index', '100');
                    jQuery('div.modal').css('z-index', '101');
                    jQuery('.modal-backdrop').css('z-index', '100');


                    dropcap_form();
                    tb_show('Dropcap | Webnus theme shortcode manager', '#TB_inline?width=700&inlineId=dropcap-form');
                    jQuery('#TB_window').css('height', 150);
                    jQuery('#TB_window').center();

                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('dropcap', tinymce.plugins.dropcap);

    function dropcap_form()
    {

        // creates a form to be displayed everytime the button is clicked
        // you should achieve this using AJAX instead of direct html code like this
        var form = jQuery('<div id="dropcap-form"><table id="dropcap-table" class="form-table">\
				<tr>\
					<th><label for="dropcap-form-no">Dropcap</label></th>\
					<td><select id="dropcap-form-no"><option value="dropcap1">Dropcap 1</option><option value="dropcap2">Dropcap 2</option><option value="dropcap3">Dropcap 3</option></select><br />\
					<small>Specify the Dropcap.</small></td>\
				</tr>\
				</table>\
				<p class="submit">\
				<input type="button" id="dropcap-form-submit" class="button-primary" value="Insert Shortcode" name="submit" />\
				</p>\
				</div>');

        var table = form.find('table');
        form.appendTo('body').hide();


        form.find('#dropcap-form-submit').click(function() {
            var dropcap_form_no = table.find("#dropcap-form-no option:selected").val();

            var shortcode = '[' + dropcap_form_no + ']Default Dropcap Text[/' + dropcap_form_no + ']';


            if (tinyMCE.activeEditor.selection.getContent() != '') {
                tinyMCE.activeEditor.selection.setContent('[' + dropcap_form_no + ']' + tinyMCE.activeEditor.selection.getContent() + '[/' + dropcap_form_no + ']');
            } else
                tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);

            // closes Thickbox
            tb_remove();
        });

    }



})(jQuery);




/*
 * List
 */
(function() {
    tinymce.create('tinymce.plugins.list', {
        init: function(ed, url) {
            ed.addButton('list', {
                title: 'List',
                image: url + '/list-ico.png',
                onclick: function() {
                	jQuery('.wpb_bootstrap_modals').css('z-index', '100');
                    jQuery('div.modal').css('z-index', '101');
                    jQuery('.modal-backdrop').css('z-index', '100');


                    list_form();
                    tb_show('List | Webnus theme shortcode manager', '#TB_inline?width=700&inlineId=list-form');
                    jQuery('#TB_window').css('height', 150);
                    jQuery('#TB_window').center();

                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('list', tinymce.plugins.list);

    function list_form()
    {

        // creates a form to be displayed everytime the button is clicked
        // you should achieve this using AJAX instead of direct html code like this
        var form = jQuery('<div id="list-form"><table id="list-table" class="form-table">\
				<tr>\
					<th><label for="list-form-type">List Types</label></th>\
					<td><select id="list-form-type"><option value="check">Check</option><option value="plus">Plus</option><option value="minus">Minus</option><option value="star">Star</option><option value="arrow">Arrow</option><option value="arrow2">Arrow 2</option><option value="square">Square</option><option value="circle">Circle</option><option value="cross">Cross</option></select><br />\
					<small>List type attributes.</small></td>\
				</tr>\
				</table>\
				<p class="submit">\
				<input type="button" id="list-form-submit" class="button-primary" value="Insert Shortcode" name="submit" />\
				</p>\
				</div>');

        var table = form.find('table');
        form.appendTo('body').hide();


        form.find('#list-form-submit').click(function() {
            var list_form_type = table.find("#list-form-type option:selected").val();

            var shortcode = '[list-ul type="' + list_form_type + '"][li-row]Defalt List Item 1[/li-row][li-row]Defalt List Item 2[/li-row][/list-ul]';


            if (tinyMCE.activeEditor.selection.getContent() != '') {
                tinyMCE.activeEditor.selection.setContent('[list-ul type="' + list_form_type + '"][li-row]' + tinyMCE.activeEditor.selection.getContent() + '[/li-row][/list-ul]');
            } else
                tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);

            // closes Thickbox
            tb_remove();
        });

    }



})(jQuery);

/*
 * Clear Shortcode
 */

(function() {
    tinymce.create('tinymce.plugins.clear', {
        init: function(ed, url) {
            ed.addButton('clear', {
                title: 'Clear',
                image: url + '/clear-ico.png',
                onclick: function() {

                    tinyMCE.activeEditor.execCommand('mceInsertContent', 0, '[clear]');

                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('clear', tinymce.plugins.clear);
})(jQuery);




/*
 * Line Shortcode
 */

(function() {
    tinymce.create('tinymce.plugins.line', {
        init: function(ed, url) {
            ed.addButton('line', {
                title: 'Line',
                image: url + '/separator-ico.png',
                onclick: function() {
                	jQuery('.wpb_bootstrap_modals').css('z-index', '100');
                    jQuery('div.modal').css('z-index', '101');
                    jQuery('.modal-backdrop').css('z-index', '100');


                     line_form();
					
					tb_show('Line | Webnus theme shortcode manager', '#TB_inline?width=700&inlineId=line-form');

                    jQuery('#TB_window').css('height', 150);
					jQuery('#TB_window').css('width', 400);
					
                    jQuery('#TB_window').center();

                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('line', tinymce.plugins.line);


 function line_form() //Line
    {

        // creates a form to be displayed everytime the button is clicked
        // you should achieve this using AJAX instead of direct html code like this
        var form = jQuery('<div id="line-form"><table id="line-table" class="form-table">\
				<tr>\
					<th><label for="line-type">Type</label></th>\
					<td><select id="line-type"><option value="1">Line</option><option value="2">Thick Line</option></select><br />\
					<small>Line Type</small>\
					</tr></table>\
				<p class="submit">\
				<input type="button" id="line-submit" class="button-primary" value="Insert Shortcode" name="submit" />\
				</p>\
				</div>');

        var table = form.find('table');
        form.appendTo('body').hide();

        // handles the click event of the submit button
        form.find('#line-submit').click(function() {

            var line_type = table.find("#line-type option:selected").val();
            
			var shortcode='';
			if(line_type==1)
				shortcode = '[line]';
			else
				shortcode = '[tline]';
			

            
            // inserts the shortcode into the active editor


            tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);

            // closes Thickbox
            tb_remove();
        });

    }

	
})(jQuery);





/*
 * Tab
 */
(function() {
    tinymce.create('tinymce.plugins.tab', {
        init: function(ed, url) {
            ed.addButton('tab', {
                title: 'Tab',
                image: url + '/tab-ico.png',
                onclick: function() {
                	jQuery('.wpb_bootstrap_modals').css('z-index', '100');
                    jQuery('div.modal').css('z-index', '101');
                    jQuery('.modal-backdrop').css('z-index', '100');


                    tab_form();
                    tb_show('Tab | Webnus theme shortcode manager', '#TB_inline?width=700&inlineId=tab-form');

                    jQuery('#TB_window').center();

                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('tab', tinymce.plugins.tab);

    function tab_form()
    {

        // creates a form to be displayed everytime the button is clicked
        // you should achieve this using AJAX instead of direct html code like this
        var form = jQuery('<div id="tab-form"><table id="tab-table" class="form-table">\
				<tr>\
					<td><label for="tab-form-title">Tab ID</label></td>\
					<td><input type="text" id[]="tab-form-title" name[]="tab-form-title" value="Tab1" class="tab-form-title"/>Is default? &nbsp; <input type="checkbox" id="tab-form-active[]" name="tab-form_active[]" value="1" class="tab-form-active"/><br />\
					<small>Tab title attribute.</small></td>\
				</tr>\
				<tr>\
					<td><input type="button" id="add-tab" class="button-primary" value="Add Tab" name="submit" /></td>\
					<td></td>\
				</tr>\
				</table>\
				<p class="submit">\
				<input type="button" id="tab-form-submit" class="button-primary" value="Insert Shortcode" name="submit" />\
				</p>\
				</div>');

        var table = form.find('table');
        form.appendTo('body').hide();

        var new_tr = '<tr><td><label for="tab-form-title">Tab ID</label></td>\
					<td><input type="text" id[]="tab-form-title" name[]="tab-form-title" value="Tab ID" class="tab-form-title"/>Is default? &nbsp; <input type="checkbox" id="tab-form-active[]" name="tab-form_active[]" value="1" class="tab-form-active"/><br />\
					<small>Tab ID attribute.</small></td>\
				</tr>\ ';


        form.find('#add-tab').click(function() {


            table.find("tr:last").before(new_tr);

        });


        form.find('#tab-form-submit').click(function() {

            var tab_title = [];
            var tab_active = [];
            table.find('input[type=text]').each(function(i, e) {

                tab_title.push(this.value);

                if (jQuery(this).closest('tr').find(':checkbox').attr('checked'))
                    tab_active.push(true);
                else
                    tab_active.push(false);

            });

            var tabgroup = "[tabgroup]";
            for (i = 0; i < tab_title.length; i++)
            {

                if (tab_active[i])
                    tabgroup += '[tab title="' + tab_title[i] + '" state="active"] Content of Tab  [/tab]';
                else
                    tabgroup += '[tab title="' + tab_title[i] + '"] Content of Tab  [/tab]';
            }
            tabgroup += "[/tabgroup]";



            tinyMCE.activeEditor.execCommand('mceInsertContent', 0, tabgroup);



            //alert(tabgroup);
            // closes Thickbox
            tb_remove();
        });


        jQuery('.tab-form-active').live("click", function() {

            //table.find('input[type=text]').each(function(i,e){
            jQuery('.tab-form-active').removeAttr('checked');

            jQuery(this).attr('checked', 'checked');


            // closes Thickbox
            //tb_remove();
        });
        //end live

    }



})(jQuery);



/*
 * Left Tab
 */
(function() {
    tinymce.create('tinymce.plugins.lefttab', {
        init: function(ed, url) {
            ed.addButton('lefttab', {
                title: 'Left Tab',
                image: url + '/leftnav-ico.png',
                onclick: function() {
                	jQuery('.wpb_bootstrap_modals').css('z-index', '100');
                    jQuery('div.modal').css('z-index', '101');
                    jQuery('.modal-backdrop').css('z-index', '100');


                    navtab_form();
                    tb_show('Left Tab | Webnus theme shortcode manager', '#TB_inline?width=700&inlineId=navtab-form');

                    jQuery('#TB_window').center();


                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('lefttab', tinymce.plugins.lefttab);



    function navtab_form()
    {

        // creates a form to be displayed everytime the button is clicked
        // you should achieve this using AJAX instead of direct html code like this
        var form = jQuery('<div id="navtab-form"><table id="navtab-table" class="form-table">\
				<tr>\
					<td><label for="tab-form-title">Tab ID</label></td>\
					<td><input type="text" id[]="tab-form-title" name[]="tab-form-title" value="Tab1" class="tab-form-title"/>Is default? &nbsp; <input type="checkbox" id="tab-form-active[]" name="tab-form_active[]" value="1" class="tab-form-active"/><br />\
					<small>Tab title attribute.</small></td>\
				</tr>\
				<tr>\
					<td><input type="button" id="add-tab" class="button-primary" value="Add Tab" name="submit" /></td>\
					<td></td>\
				</tr>\
				</table>\
				<p class="submit">\
				<input type="button" id="tab-form-submit" class="button-primary" value="Insert Shortcode" name="submit" />\
				</p>\
				</div>');

        var table = form.find('table');
        form.appendTo('body').hide();

        var new_tr = '<tr><td><label for="tab-form-title">Tab ID</label></td>\
					<td><input type="text" id[]="tab-form-title" name[]="tab-form-title" value="Tab1" class="tab-form-title"/>Is default? &nbsp; <input type="checkbox" id="tab-form-active[]" name="tab-form_active[]" value="1" class="tab-form-active"/><br />\
					<small>Tab ID attribute.</small></td>\
				</tr>\ ';


        form.find('#add-tab').click(function() {


            table.find("tr:last").before(new_tr);

        });


        form.find('#tab-form-submit').click(function() {

            var tab_title = [];
            var tab_active = [];
            table.find('input[type=text]').each(function(i, e) {

                tab_title.push(this.value);

                if (jQuery(this).closest('tr').find(':checkbox').attr('checked'))
                    tab_active.push(true);
                else
                    tab_active.push(false);

            });

            var tabgroup = "[lefttab]";
            for (i = 0; i < tab_title.length; i++)
            {

                if (tab_active[i])
                    tabgroup += '[tab title="' + tab_title[i] + '" state="active"] Content of Tab  [/tab]';
                else
                    tabgroup += '[tab title="' + tab_title[i] + '"] Content of Tab  [/tab]';
            }
            tabgroup += "[/lefttab]";



            tinyMCE.activeEditor.execCommand('mceInsertContent', 0, tabgroup);



            //alert(tabgroup);
            // closes Thickbox
            tb_remove();
        });


        jQuery('.tab-form-active').live("click", function() {

            //table.find('input[type=text]').each(function(i,e){
            jQuery('.tab-form-active').removeAttr('checked');

            jQuery(this).attr('checked', 'checked');


            // closes Thickbox
            //tb_remove();
        });
        //end live

    }




})(jQuery);



/*
 * Accordion Shortcode
 */

(function() {
    tinymce.create('tinymce.plugins.accordion', {
        init: function(ed, url) {
            ed.addButton('accordion', {
                title: 'Accordion',
                image: url + '/accordion-ico.png',
                onclick: function() {

                    tinyMCE.activeEditor.selection.setContent('[accordion title="Accordion title"]' + tinyMCE.activeEditor.selection.getContent() + '[/accordion]');

                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('accordion', tinymce.plugins.accordion);
})(jQuery);



/*
 * RecentWorks
 */
(function() {
    tinymce.create('tinymce.plugins.homerecentworks', {
        init: function(ed, url) {
            ed.addButton('homerecentworks', {
                title: 'Recent Works',
                image: url + '/latestprojets-ico.png',
                onclick: function() {
                    tinyMCE.activeEditor.execCommand('mceInsertContent', 0, '[recentworks]');
                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('homerecentworks', tinymce.plugins.homerecentworks);

})(jQuery);





/*
 * Progress Bar
 */
(function() {
    tinymce.create('tinymce.plugins.progressbar', {
        init: function(ed, url) {
            ed.addButton('progressbar', {
                title: 'ProgressBar',
                image: url + '/progress-ico.png',
                onclick: function() {
                	jQuery('.wpb_bootstrap_modals').css('z-index', '100');
                    jQuery('div.modal').css('z-index', '101');
                    jQuery('.modal-backdrop').css('z-index', '100');


                    progressbar_form();
                    tb_show('ProgressBar | Webnus theme shortcode manager', '#TB_inline?width=900&inlineId=progressbar-form');
                    jQuery('#TB_window').center();
                    jQuery('#TB_window').css('height', '280');
                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('progressbar', tinymce.plugins.progressbar);



    function progressbar_form()
    {

        // creates a form to be displayed everytime the button is clicked
        // you should achieve this using AJAX instead of direct html code like this

        /*
         * 
         * <tr>\
         <th><label for="testimonial-form-title">Title</label></th>\
         <td><input type="text" name="testimonial-form-title" id="testimonial-form-title" value="Title"  /><br />\
         <small>Specify the Testimonial Title.</small>\
         </tr>\
         */

        var form = jQuery('<div id="progressbar-form"><table id="progressbar-table" class="form-table">\
				<tr>\
				<th><label for="progressbar-form-type">Type</label></th>\
				<td><select  name="progressbar-form-type" id="progressbar-form-type">\
				<option value="info">Blue</option><option value="success">Green</option><option value="warning">Orange</option><option value="danger">Red</option></select><br />\
				<small>Progressbar Type</small>\
				</tr>\
				<tr>\
				<th><label for="progressbar-form-percent">Percent</label></th>\
				<td><input type="text" name="progressbar-form-percent" id="progressbar-form-percent" value="50"  /><br />\
				<small>Progressbar Percent.</small>\
				</tr>\
				<tr>\
				<th><label for="progressbar-form-text">Text</label></th>\
				<td><input type="text" name="progressbar-form-text" id="progressbar-form-text" value="Sample"  /><br />\
				<small>Progressbar Text.</small>\
				</tr>\
				</table>\
				<p class="submit">\
				<input type="button" id="progressbar-form-submit" class="button-primary" value="Insert Shortcode" name="submit" />\
				</p>\
				</div>');

        var table = form.find('table');
        form.appendTo('body').hide();


        form.find('#progressbar-form-submit').click(function() {
            var progressbar_type = table.find("#progressbar-form-type").val();
            var progressbar_percent = table.find("#progressbar-form-percent").val();
			var progressbar_text = table.find("#progressbar-form-text").val();

            var shortcode = '[progress type="' + progressbar_type + '" percent="' + progressbar_percent + '" text="'+progressbar_text +'"]';



            tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);

            // closes Thickbox
            tb_remove();
        });

    }
})(jQuery);


/*
 * Flex
 */
(function() {
    tinymce.create('tinymce.plugins.flex', {
        init: function(ed, url) {
            ed.addButton('flex', {
                title: 'Flex Slider',
                image: url + '/flexslider-ico.png',
                onclick: function() {

                    tinyMCE.activeEditor.selection.setContent('[flexslider][flexitem img="" alt=""][flexitem img="" alt=""][/flexslider]');
                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('flex', tinymce.plugins.flex);


})(jQuery);




/*
 * CallOut
 */
(function() {
    tinymce.create('tinymce.plugins.callout', {
        init: function(ed, url) {
            ed.addButton('callout', {
                title: 'Callout (promobox)',
                image: url + '/callout-ico.png',
                onclick: function() {

                    callout_form();
                    tb_show('Callout | Webnus theme shortcode manager', '#TB_inline?width=700&inlineId=callout-form');

                    jQuery('#TB_window').css('height', 350);
                    jQuery('#TB_window').center();
                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('callout', tinymce.plugins.callout);

    function callout_form() //otype [ourteam 1 or ourteam 2]
    {

        // creates a form to be displayed everytime the button is clicked
        // you should achieve this using AJAX instead of direct html code like this
        var form = jQuery('<div id="callout-form"><table id="callout-table" class="form-table">\
				<tr>\
					<th><label for="callout-title">Title</label></th>\
					<td><input type="text" name="callout-title" id="callout-title" value=""  /><br />\
					<small>CallOut Title</small>\
				</tr>\
				<tr>\
					<th><label for="callout-text">Text</label></th>\
					<td><input type="text" name="callout-text" id="callout-text" value=""  /><br />\
					<small>CallOut Text</small>\
				</tr>\
                                <tr>\
					<th><label for="callout-buttontext">Button Text</label></th>\
					<td><input type="text" name="callout-buttontext" id="callout-buttontext" value=""  /><br />\
					<small>CallOut Button Text</small>\
				</tr>\
                                <tr>\
					<th><label for="callout-buttonlink">Button Link</label></th>\
					<td><input type="text" name="callout-buttonlink" id="callout-buttonlink" value=""  /><br />\
					<small>CallOut Button Link</small>\
				</tr>\
                                </table>\
				<p class="submit">\
				<input type="button" id="callout-submit" class="button-primary" value="Insert Shortcode" name="submit" />\
				</p>\
				</div>');

        var table = form.find('table');
        form.appendTo('body').hide();

        // handles the click event of the submit button
        form.find('#callout-submit').click(function() {

            var callout_title = table.find("#callout-title").val();
            var callout_text = table.find("#callout-text").val();
            var callout_buttontext = table.find("#callout-buttontext").val();
            var callout_buttonlink = table.find("#callout-buttonlink").val();





            var shortcode = "[callout title='" + callout_title + "' text='" + callout_text + "' button_text='" + callout_buttontext + "'  button_link='" + callout_buttonlink + "']";
            // inserts the shortcode into the active editor


            tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);

            // closes Thickbox
            tb_remove();
        });

    }

})(jQuery);




/*
 * 1/3
 */
(function() {
    tinymce.create('tinymce.plugins.testimonial', {
        init: function(ed, url) {
            ed.addButton('testimonial', {
                title: 'Testimonial',
                image: url + '/testimonial-ico.png',
                onclick: function() {

                    tinyMCE.activeEditor.selection.setContent('[testimonial name="" img="" subtitle=""] Contents [/testimonial]');
                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('testimonial', tinymce.plugins.testimonial);

   

})(jQuery);




/*
 * 1/3
 */
(function() {
    tinymce.create('tinymce.plugins.one_third', {
        init: function(ed, url) {
            ed.addButton('one_third', {
                title: '1/3 Columns',
                image: url + '/column13-ico.png',
                onclick: function() {

                    tinyMCE.activeEditor.selection.setContent('[one_third] Contents [/one_third]');
                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('one_third', tinymce.plugins.one_third);

   

})(jQuery);



/*
 * 2/3
 */
(function() {
    tinymce.create('tinymce.plugins.two_third', {
        init: function(ed, url) {
            ed.addButton('two_third', {
                title: '2/3 Columns',
                image: url + '/colimn23-ico.png',
                onclick: function() {

                    tinyMCE.activeEditor.selection.setContent('[two_third] Contents [/two_third]');
                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('two_third', tinymce.plugins.two_third);

   

})(jQuery);



/*
 * 1/2
 */
(function() {
    tinymce.create('tinymce.plugins.one_half', {
        init: function(ed, url) {
            ed.addButton('one_half', {
                title: '1/2 Columns',
                image: url + '/column12-ico.png',
                onclick: function() {

                    tinyMCE.activeEditor.selection.setContent('[one_half] Contents [/one_half]');
                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('one_half', tinymce.plugins.one_half);

   

})(jQuery);



/*
 * 1/4
 */
(function() {
    tinymce.create('tinymce.plugins.one_fourth', {
        init: function(ed, url) {
            ed.addButton('one_fourth', {
                title: '1/4 Columns',
                image: url + '/column14-ico.png',
                onclick: function() {

                    tinyMCE.activeEditor.selection.setContent('[one_fourth] Contents [/one_fourth]');
                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('one_fourth', tinymce.plugins.one_fourth);

   

})(jQuery);




/*
 * 1/6
 */
(function() {
    tinymce.create('tinymce.plugins.one_sixth', {
        init: function(ed, url) {
            ed.addButton('one_sixth', {
                title: '1/6 Columns',
                image: url + '/column16-ico.png',
                onclick: function() {

                    tinyMCE.activeEditor.selection.setContent('[one_sixth] Contents [/one_sixth]');
                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('one_sixth', tinymce.plugins.one_sixth);

   

})(jQuery);

/*
 * 1/12
 */
(function() {
    tinymce.create('tinymce.plugins.one_twelfth', {
        init: function(ed, url) {
            ed.addButton('one_twelfth', {
                title: '1/12 Columns',
                image: url + '/column112-ico.png',
                onclick: function() {

                    tinyMCE.activeEditor.selection.setContent('[one_twelfth] Contents [/one_twelfth]');
                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('one_twelfth', tinymce.plugins.one_twelfth);

   

})(jQuery);


/*
 * Row
 */
(function() {
    tinymce.create('tinymce.plugins.row', {
        init: function(ed, url) {
            ed.addButton('row', {
                title: 'Row',
                image: url + '/row-ico.png',
                onclick: function() {

                    tinyMCE.activeEditor.selection.setContent('[row] Contents [/row]');
                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('row', tinymce.plugins.row);

   

})(jQuery);



/*
 * Blox
 */
(function() {
    tinymce.create('tinymce.plugins.blox', {
        init: function(ed, url) {
            ed.addButton('blox', {
                title: 'Blox',
                image: url + '/bloxgray-ico.png',
                onclick: function() {

                    tinyMCE.activeEditor.selection.setContent('[blox img="http://" height="380" nomargin="false" fixed="false"] Contents [/blox]');
                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('blox', tinymce.plugins.blox);

   

})(jQuery);

/*
 * parallax
 */
(function() {
    tinymce.create('tinymce.plugins.parallax', {
        init: function(ed, url) {
            ed.addButton('parallax', {
                title: 'parallax',
                image: url + '/parallax-ico.png',
                onclick: function() {

                    tinyMCE.activeEditor.selection.setContent('[parallax img="http://" height="380" height="420" speed="5" class="dark"] Contents [/parallax]');
                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('parallax', tinymce.plugins.parallax);

   

})(jQuery);


/*
 * BloxDark
 */
(function() {
    tinymce.create('tinymce.plugins.bloxdark', {
        init: function(ed, url) {
            ed.addButton('bloxdark', {
                title: 'BloxDrak',
                image: url + '/bloxdark-ico.png',
                onclick: function() {

                    tinyMCE.activeEditor.selection.setContent('[bloxdark img="http://" height="380" nomargin="false" fixed="false"] Contents [/bloxdark]');
                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('bloxdark', tinymce.plugins.bloxdark);

   

})(jQuery);




/*
 * FAQ
 */
(function() {
    tinymce.create('tinymce.plugins.faq', {
        init: function(ed, url) {
            ed.addButton('faq', {
                title: 'FAQ',
                image: url + '/faq-ico.png',
                onclick: function() {

                    tinyMCE.activeEditor.selection.setContent('[faq]');
                }
            });
        },
        createControl: function(n, cm) {
            return null;
        }
    });
    tinymce.PluginManager.add('faq', tinymce.plugins.faq);

   

})(jQuery);






/*
 * Big Title1
 */
(function() {
    tinymce.create('tinymce.plugins.bigtitle1', {
        init: function(ed, url) {
            ed.addButton('bigtitle1', {
                title: 'Big Title 1',
                image: url + '/bigtitle-ico.png',
                onclick: function() {
                    tinyMCE.activeEditor.execCommand('mceInsertContent', 0, '[big_title]Title[/big_title]');

                }
            });
        },
        createControl: function(n, cm) {
            return null;
        },
    });
    tinymce.PluginManager.add('bigtitle1', tinymce.plugins.bigtitle1);
})(jQuery);


/*
 * Big Title2
 */
(function() {
    tinymce.create('tinymce.plugins.bigtitle2', {
        init: function(ed, url) {
            ed.addButton('bigtitle2', {
                title: 'Big Title 2',
                image: url + '/bigtitle2-ico.png',
                onclick: function() {
                    tinyMCE.activeEditor.execCommand('mceInsertContent', 0, '[big_title2]Title[/big_title2]');

                }
            });
        },
        createControl: function(n, cm) {
            return null;
        },
    });
    tinymce.PluginManager.add('bigtitle2', tinymce.plugins.bigtitle2);
})(jQuery);



/*
 * Box Link
 */
(function() {
    tinymce.create('tinymce.plugins.boxlink', {
        init: function(ed, url) {
            ed.addButton('boxlink', {
                title: 'Box Link',
                image: url + '/boxlink-ico.png',
                onclick: function() {
                    tinyMCE.activeEditor.execCommand('mceInsertContent', 0, '[boxlink url="http://"]Content[/boxlink]');

                }
            });
        },
        createControl: function(n, cm) {
            return null;
        },
    });
    tinymce.PluginManager.add('boxlink', tinymce.plugins.boxlink);
	
	
	
	

	
	
})(jQuery);



/*
 * Distance
 */
(function() {
    tinymce.create('tinymce.plugins.distance', {
        init: function(ed, url) {
            ed.addButton('distance', {
                title: 'Distance',
                image: url + '/distance-ico.png',
                onclick: function() {
                 	jQuery('.wpb_bootstrap_modals').css('z-index', '100');
                    jQuery('div.modal').css('z-index', '101');
                    jQuery('.modal-backdrop').css('z-index', '100');

                   
					distance_form();
					
					tb_show('Distance | Webnus theme shortcode manager', '#TB_inline?width=700&inlineId=distance-form');

                    jQuery('#TB_window').css('height', 150);
					jQuery('#TB_window').css('width', 400);
					jQuery('#TB_window').css('width', 400);
                    jQuery('#TB_window').center();

                }
            });
        },
        createControl: function(n, cm) {
            return null;
        },
    });
    tinymce.PluginManager.add('distance', tinymce.plugins.distance);
	
	
	
 function distance_form() //distance
    {

        // creates a form to be displayed everytime the button is clicked
        // you should achieve this using AJAX instead of direct html code like this
        var form = jQuery('<div id="distance-form"><table id="distance-table" class="form-table">\
				<tr>\
					<th><label for="distance-title">Type</label></th>\
					<td><select id="distance-type"><option value="1">Distance 1</option><option value="2">Distance 2</option><option value="3">Distance 3</option><option value="4">Distance 4</option></select><br />\
					<small>Distance Type</small>\
					</tr></table>\
				<p class="submit">\
				<input type="button" id="distance-submit" class="button-primary" value="Insert Shortcode" name="submit" />\
				</p>\
				</div>');

        var table = form.find('table');
        form.appendTo('body').hide();

        // handles the click event of the submit button
        form.find('#distance-submit').click(function() {

            var distance_type = table.find("#distance-type option:selected").val();
            



            var shortcode = '[distance'+ distance_type +']';
            // inserts the shortcode into the active editor


            tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);

            // closes Thickbox
            tb_remove();
        });

    }

	
})(jQuery);





/*
 * Link
 */
(function() {
    tinymce.create('tinymce.plugins.link1', {
        init: function(ed, url) {
            ed.addButton('link1', {
                title: 'Link (Learn more)',
                image: url + '/link-ico.png',
                onclick: function() {
                    tinyMCE.activeEditor.execCommand('mceInsertContent', 0, '[link url="http://"]Content[/link]');

                }
            });
        },
        createControl: function(n, cm) {
            return null;
        },
    });
    tinymce.PluginManager.add('link1', tinymce.plugins.link1);
})(jQuery);





/*
 * Paragraph
 */
(function() {
    tinymce.create('tinymce.plugins.paragraph', {
        init: function(ed, url) {
            ed.addButton('paragraph', {
                title: 'Paragraph',
                image: url + '/paragraph-ico.png',
                onclick: function() {
                    tinyMCE.activeEditor.execCommand('mceInsertContent', 0, '[p]Content[/p]');

                }
            });
        },
        createControl: function(n, cm) {
            return null;
        },
    });
    tinymce.PluginManager.add('paragraph', tinymce.plugins.paragraph);
})(jQuery);



/*
 * Retina Icon
 */
(function() {
    tinymce.create('tinymce.plugins.retinaicon', {
        init: function(ed, url) {
            ed.addButton('retinaicon', {
                title: 'Retina Icon',
                image: url + '/retinaicon-ico.png',
                onclick: function() {
                	jQuery('.wpb_bootstrap_modals').css('z-index', '100');
                    jQuery('div.modal').css('z-index', '101');
                    jQuery('.modal-backdrop').css('z-index', '100');


                    retinaicon_form();
                    tb_show('Retina Icon | Webnus theme shortcode manager', '#TB_inline?width=700&height=550&inlineId=retinaicon-form');

                    jQuery('#TB_window').css('height', 600);
                    jQuery('#TB_window').css('width', 700);
                    
                    
                    jQuery('#TB_window').center();

                }
            });
        },
        createControl: function(n, cm) {
            return null;
        },
    });
    tinymce.PluginManager.add('retinaicon', tinymce.plugins.retinaicon);
    
    
    jQuery('#TB_window').live("tb_unload", function(){
        jQuery('.webnus-iconfonts-wrapper').remove();
    });
    
    function retinaicon_form() 
    {
		
        // creates a form to be displayed everytime the button is clicked
        // you should achieve this using AJAX instead of direct html code like this
        var form = jQuery(jQuery.base64.decode('[encoded data, 109660 characters]'));
		form.find("#webnus-icons-colorpicker").wpColorPicker();
        var table = form.find('table');
        form.appendTo('body').hide();

        // handles the click event of the submit button
        form.find('#webnus-icons-getcode').click(function() {

            var icomoon_color = table.find("#webnus-icons-colorpicker").val();
            var icomoon_url = ' link="'+table.find("#webnus-icons-url").val()+'"';
            var icomoon_size = table.find("#webnus-icons-size").val();
            
			var icomoon_class =jQuery('input[name="iconfonts_name"]:checked').val();
			

			if(icomoon_color)
			 tinyMCE.activeEditor.execCommand('mceInsertContent', 0, '[icon name="'+icomoon_class+'" size="'+icomoon_size+'" color="'+icomoon_color+'"'+ icomoon_url +']');
			else
			 tinyMCE.activeEditor.execCommand('mceInsertContent', 0, '[icon name="'+icomoon_class+'" size="'+icomoon_size+'"'+ icomoon_url +']');


          

            // closes Thickbox
            tb_remove();
        });

    }
    
    
})(jQuery);


/**
		PictureBox
**/


(function() {
    tinymce.create('tinymce.plugins.doublepromo', {
        init: function(ed, url) {
            ed.addButton('doublepromo', {
                title: 'Double Promo',
                image: url + '/doublepromo-ico.png',
                onclick: function() {
                    
					tinyMCE.activeEditor.execCommand('mceInsertContent', 0, '[doublepromo title="Title Goes Here" Text="Sample Text" link_text="Read More" link_link="#" img="" img_alt="" last="false"][doublepromo title="Title Goes Here" Text="Sample Text" link_text="Read More" link_link="#" img="" img_alt="" last="true"]');

                }
            });
        },
        createControl: function(n, cm) {
            return null;
        },
    });
    tinymce.PluginManager.add('doublepromo', tinymce.plugins.doublepromo);
})(jQuery);



/*
		QUOTE
*/

(function() {
    tinymce.create('tinymce.plugins.quote', {
        init: function(ed, url) {
            ed.addButton('quote', {
                title: 'Quote of the Week',
                image: url + '/qotofweek-ico.png',
                onclick: function() {
                    
					tinyMCE.activeEditor.execCommand('mceInsertContent', 0, '[quote title="Title" Text="text" name="Name" name_sub="Name Sub"]');

                }
            });
        },
        createControl: function(n, cm) {
            return null;
        },
    });
    tinymce.PluginManager.add('quote', tinymce.plugins.quote);
})(jQuery);





(function($) {
    $.fn.extend({
        center: function() {
            return this.each(function() {
                var top = ($(window).height() - $(this).outerHeight()) / 2;
                var left = ($(window).width() - $(this).outerWidth()) / 2;
                $(this).css({position: 'absolute', margin: 0, top: (top > 0 ? top : 0) + 'px', left: (left > 0 ? left : 0) + 'px'});
            });
        }
    });
})(jQuery);
