function cloud_main(){
	 
	jQuery(document).trigger('destroyTheFG');

	jQuery('.delete_image_button').bind('click',function(){
														 
				var wthis = jQuery(this);
				jQuery('#container_meta_'+wthis.attr("name")).html('Please Wait...<br/><br/>');
	jQuery.ajax({

				url: wthis.attr('rel'),
				cache: false,
				type: "POST",
				data: ({
					   
						meta_id : wthis.attr('id'),
						meta_name : wthis.attr('name') 
						
					}),
				success: function(msg) {
				
				jQuery('#container_meta_'+wthis.attr("name")).html(msg);
			}  
		});
	});
	
						
	jQuery('.delete_button').click(function(){
		var id = jQuery(this).attr("name");
		jQuery('#'+id).slideDown();
		return false;
	});


	jQuery('.delete_imnotsure').click(function(){
		var id = jQuery(this).attr("href");
		jQuery(id).slideUp();
		return false;
	});

						
	function add_live_img(img,full,where, thumb_path){
		var cloudfw_blogid = jQuery("meta[name=cloudfw_blogid]").attr('content');
		
		if (cloudfw_blogid !='' && typeof cloudfw_blogid != 'undefined'){
			if (cloudfw_blogid > 0) {
				
				img_parts = img.split('/files/');
				
				if (img_parts[1]) {
					
					the_image_src = '/blogs.dir/' + cloudfw_blogid + '/files/' + img_parts[1];
					img = thumb_path + '/wp-content' + the_image_src;
					
				}
			}
		}
		
		jQuery(where).html('<div class="preview_img"><a href="'+full+'"><img src="'+img+'"/></a></div>');
		formfield = false;
	};
	
	

	var formfield;
	var thumb_path;
	var id;
	var where;
	
	
	jQuery('.upload_image_button').click(function() {
		where=""; id=""; thumb_path="";
		
		jQuery('html').addClass('Image');
		
		id = "#"+jQuery(this).attr('name');
		formfield = true;
		thumb_path = jQuery(this).attr('rel');
		where = "#"+jQuery(this).attr('title');
		editortext = jQuery(this).attr('data-editortext') || textSendTheEditor;
		
		
		sender(id,thumb_path,where);

		tb_show('Upload An Image', 'media-upload.php?post_id='+jQuery(this).attr("alt")+'&type=image&TB_iframe=true');
		
		var refresh_editortext = setInterval(function(){jQuery('#TB_iframeContent').contents().find('.savesend').find("[id^='send']").val(editortext);}, 200);
		   
		return false;
	});


	function sender(id,thumb_path,where){

		window.original_send_to_editor = window.send_to_editor;
		window.send_to_editor = function(html){
	
			if (formfield) {
				fileurl = jQuery('img',html).attr('src');
	
				jQuery(id).val(fileurl);
				tb_remove();
				
				if (!where=="") add_live_img(thumb_path+""+fileurl+"",fileurl,where, thumb_path);
				
				jQuery('html').removeClass('Image');
	
			} else {
				window.original_send_to_editor(html);
			}
		
		clearInterval(refresh_editortext);
			
		};
				
};
	
	
	
	
	
	jQuery('.select_page').click(function() {
		ex_url=''; id=''; thumb_path=''; hideparent='';
		
		
		id = jQuery(this).attr('rel');
		adress = jQuery(this).attr('lang');
		preview = jQuery(this).attr('preview');
		cases = jQuery(this).attr('cases');
		hideparent = jQuery(this).attr('hideparent');
		whichin = jQuery(this).attr('whichin');
		cond = jQuery(this).attr('cond');
			
			ex_url ='id='+id;
			if (preview) ex_url+='&pid='+preview;
			if (cases) ex_url+='&case='+cases;
			if (hideparent) ex_url+='&hideparent=true';
			if (whichin) ex_url+='&whichin='+whichin;
			if (cond) ex_url+='&cond='+cond;
			
		tb_show('Select A Page', ''+adress+'?'+ex_url+'&TB_iframe=false');
		return false;
	});

	
		var refreshId = setInterval(function() {
			  
		    jQuery('.timer_hide').fadeOut(function(){jQuery(this).remove();});
			  
		   }, 8000);
		
		
if( jQuery.isFunction(jQuery.fn.draggable) ) {
	
	jQuery(".grown").draggable();
	jQuery(document).keydown(function(e) {
	  if (e.keyCode == 27) { jQuery('.grown').fadeOut(function(){jQuery(this).remove();}); }   // esc
	});
}


shortcut.remove("Ctrl+S");
shortcut.add("Ctrl+S",function() {jQuery('.ctrl_s_form').submit();},{'type':'keydown','propagate':false,'target':document});


jQuery('.color').ColorPicker({
	onSubmit: function(hsb, hex, rgb, el) {
		jQuery(el).val(hex);
		jQuery(el).ColorPickerHide();
		jQuery('#'+jQuery(el).attr("title")).css('backgroundColor', '#' + hex);
		jQuery(el).parents('.wrap-color').first().removeClass('empty');
	},
	onBeforeShow: function () {
		jQuery(this).ColorPickerSetColor(this.value);
	},
	onChange: function (hsb, hex, rgb, el) {
		jQuery(el).val(hex);
		jQuery('#'+jQuery(el).attr("title")).css('backgroundColor', '#' + hex);
		jQuery(el).parents('.wrap-color').first().removeClass('empty');
	}
	})
	.bind('keyup', function(){
		jQuery(this).ColorPickerSetColor(this.value);
		if (this.value !='') {
			jQuery('#'+jQuery(this).attr("title")).css('backgroundColor', '#' + this.value);
			jQuery(this).parents('.wrap-color').removeClass('empty');
		} else{
			jQuery('#'+jQuery(this).attr("title")).css('backgroundColor', '');
			jQuery(this).parents('.wrap-color').addClass('empty');
		};
	}).next('.remove-color').click(function(){
		var input = jQuery(this).prev('input');
		input.val('');
		jQuery('#'+input.attr("title")).css('backgroundColor', '');
		jQuery(this).parents('.wrap-color').addClass('empty');
		return false;
	});
	
jQuery('.color').each(function(){jQuery('#'+jQuery(this).attr("title")).css('backgroundColor', '#' + jQuery(this).val());})


function setupLabel() {
        if (jQuery('.label_check input').length) {
            jQuery('.label_check').each(function(){ 
												 
												 
       if (jQuery(this).children("input").attr("checked")) jQuery(this).addClass('c_on');else jQuery(this).removeClass('c_on');
				
            });
            jQuery('.label_check input:checked').each(function(){ 
                jQuery(this).parent('label').addClass('c_on');
            });                
        };
        if (jQuery('.label_radio input').length) {
            jQuery('.label_radio').each(function(){ 
                jQuery(this).removeClass('r_on');
            });
            jQuery('.label_radio input:checked').each(function(){ 
                jQuery(this).parent('label').addClass('r_on');
            });
        };
    };
jQuery('.label_check, .label_radio').click(function(){
		   setupLabel();
        });
        setupLabel(); 
		
jQuery(document).bind('ajaxSuccess',function(){setupLabel();});


jQuery('.cl_nav').hover(function(){
						 
		 jQuery('#cloud_nav_desc span').html(jQuery(this).children("span").html());
		 jQuery('#cloud_nav_desc').show();},
		 
		 function(){
		 
		 jQuery('#cloud_nav_desc span').html('');
		 jQuery('#cloud_nav_desc').hide();}
				  );

jQuery('.framework_container').hover(function(){
		jQuery(this).children().find(".submit_button").show();
				  },
		 function(){
		jQuery(this).children().find(".submit_button").hide();
					 });
					 
jQuery(".setSlider").live("click", function(){
		var el = jQuery(this);
		var sliderVal = el.attr("data-val");
		var sliderId = el.attr("data-to");
		var sliderInputId = el.attr("rel");
		var sliderPreId = el.attr("data-to-pre");
		
		var value = jQuery(sliderId).slider( "option", "value" );
		jQuery(sliderId).slider( "option", "value", sliderVal );
		jQuery(sliderInputId).val(sliderVal);
		if (typeof sliderPreId != "undefined") jQuery(sliderPreId).html(sliderVal);
		
		return false;
	
	});
	

jQuery(".show_menu_options").toggle(
	function(){
		var el = jQuery(this);
		el.parent().parent('.menu-item-settings').find('.cloudfw_menu_options').slideDown();
		return false;
			
	},
	function(){
		var el = jQuery(this);
		el.parent().parent('.menu-item-settings').find('.cloudfw_menu_options').slideUp();
		return false;
			
	}
	
	);
		
		
if( jQuery.isFunction(jQuery.fn.tipsy) ) {

	jQuery('.tooltip').tipsy({gravity: jQuery.fn.tipsy.autoNS, fade: true, offset: 20, live: true, delayOut: 0, trigger: 'manual'});

}

jQuery(document).unbind('ajaxStart');
jQuery(document).ajaxStart(function(event,request, settings){
	
	jQuery('.tipsy').remove();

});

jQuery(".help").live('click',function(){
					  
		var el = "#"+jQuery(this).attr("rel");
		var width = jQuery(this).attr("width");
		var tit = jQuery(this).attr("title");
		
		if (width=="s" || width =="") {var width = 300}else if (width=="m") {var width = 600} else if (width=="l") {var width = 900};
		if (tit =='') tit = 'Help';
		
		jQuery("*").dialog( "destroy" );

		jQuery(el).dialog({
													
			dialogClass	: 'help_dialog',
			modal		: true,
			title		: tit,
			width		: width,
			maxWidth	: 1600,
			position	: 'center'
			
			});
		return false;
});





jQuery(".theThisConfirm").click(function(){
	jQuery("*").dialog( "destroy" );
	
	var the_el = jQuery( this );
	var the_title = the_el.attr('data-title') || 'Are you sure to delete?';
	var the_content = the_el.attr('data-content') || 'Do you want to delete the item?';
	var the_deleting_buttons = '\
		<div class="clear" style="margin-top: 15px;"></div>\
		<div style="float:left;"><a id="run-the-proceed" href="'+the_el.attr('href')+'" class="small-button small-red"><span>Delete</span></a></div>\
		<div style="float:right;  margin-right: -15px;"><a id="cancel-the-form" href="#" class="small-button small-grey"><span>Cancel</span></a></div>\
		<div class="clear"></div>\
			';
	
	jQuery('<span style="display:block; padding: 0 20px;">'+the_content+the_deleting_buttons+'</span>').dialog({
			resizable: false,
			dialogClass	: 'delete_dialog',
			modal		: true,
			title		: 'Are You Sure?'
	});

jQuery('#cancel-the-form').live('click',function(){
		jQuery("*").dialog( "close" );
		return false;
	});
jQuery('#run-the-proceed').focus();
return false;

});





jQuery('.fg-button').hover(
	function(){ jQuery(this).removeClass('ui-state-default').addClass('ui-state-focus'); },
	function(){ jQuery(this).removeClass('ui-state-focus').addClass('ui-state-default'); }
);
    	
jQuery('.fg-button').each(function(i){
		var this_el = jQuery(this);		
		var m_width = this_el.attr("data-width") || 245;
		
		this_el.menu({ 
			content: jQuery(this).prev().html(), // grab content from this page
			showSpeed: 100,
			width: m_width
		});
});

jQuery('.cloud_sub_nav_items a').click(function(){
	jQuery(document).trigger('click');
	jQuery(document).trigger('destroyTheFG');
	cloudfw_get_icon_list_close();
});

jQuery('.tabs').find("ul").first().find("a").click(function(){
	jQuery(document).trigger('destroyTheFG');
});

jQuery('.ajax_form').unbind('submit');
jQuery('.ajax_form').submit(function(){
		
		var the_form = jQuery(this);
		
		if (the_form.hasClass("disabled")) return false;
			
		the_form.find('#update_identifier').remove();
		
		cloudfw_global_loading('show');
		
		the_form.addClass('disabled');
		
		the_form.find(':submit').each(function(){
			jQuery(this).attr('data-old-val',jQuery(this).val()).val(textSending).parent('div').fadeTo(200,.5).fadeTo(200,1);
		});
		
		the_form.find('#save_apply').parent('div').hide();
		
		jQuery(the_form).trigger('ajaxPreSend', [the_form]);
						
		var ajaxForm_vars = {
			action: 'cloudfw_save_changes',
			_wpnonce: cloudfw_nonce
		};

		jQuery.ajax({

			url: ajaxurl,
			cache: false,
			type: "POST",
			data: (jQuery.param(ajaxForm_vars, true) + "&" + the_form.serialize()),
			success: function(data) {
				try {
					jQuery(the_form).trigger('ajaxCallback', [the_form, data]);
					
					var obj = jQuery.parseJSON(data);			
					
					cloudfw_get_back_form(the_form);
					fw_dialog(obj.messageText,obj.messageCase);
					
					if (obj.slider_id) {
						if (the_form.find('input#slider_id').length > 0)
							the_form.find('input#slider_id').val(obj.slider_id);
						else
							the_form.prepend("<input type=\"hidden\" id=\"slider_id\" name=\"slider_id\" value=\""+obj.slider_id+"\" />")
							
						the_form.find(':submit').val(textUpdate).attr('data-old-val',textUpdate);
					}
					
					
				} catch (e) {
					alert(data);
					cloudfw_get_back_form(the_form);
					fw_dialog("An error occurred when saving changes","cancel");
					
				}
				
				//alert(data);
				cloudfw_global_loading('hide');
				
			}  
													
		});
		
		
	return false;

	});
	

jQuery('.showAllOption').click(function(){
	
	var ua = jQuery.browser;
	
	var parent_el = jQuery(this).parents('.framework_container');
	var this_el = parent_el.find('.showAllOption');
	var hidden_content = parent_el.find('.hidden-content');
		
		hidden_content.each(function(){
			if (jQuery(this).hasClass("hidden")) {
				//Show
				if (!ua.safari)	jQuery(this).slideDown(500); else jQuery(this).show();
				jQuery(this).removeClass('hidden');
				
				this_el.addClass("active");
				jQuery.scrollTo( jQuery(this), {duration: 1000, offset:{top:-20 } } );
				
				}else{
				//Hide
				if (!ua.safari)	jQuery(this).slideUp(500); else jQuery(this).hide();
				jQuery(this).addClass('hidden');
				this_el.removeClass("active");

			}
			
		});
	jQuery(document).trigger('destroyTheFG');
	return false;
	
});


//jQuery("body").append("<div id=\"debugger\"></div>");


jQuery('.select-icon').die('click');
jQuery('.select-icon').live('click',function(e) {
	
	var icon_list = jQuery('#cloudfw-icon-list');
	var el = jQuery(this);
	
	if (icon_list.length > 0) {
		
		cloudfw_get_icon_list(e,el);
		
	}else{
		
		el.append('<div class="loading_black"></div>');
		el.find('.loading_black').fadeTo(300,.7);
		
		jQuery.get(url + '/ajax/get_icons.php', function(data){
			jQuery('body').append('<div id="cloudfw-icon-list" class="hidden"></div>');
			jQuery('#cloudfw-icon-list').html(data);
			cloudfw_get_icon_list(e,el);
		});
				
	}

	jQuery(document).trigger('destroyTheFG');
	
	return false;
});

jQuery('.remove-icon').die('click');
jQuery('.remove-icon').live('click',function() {
	var par_el = jQuery(this).parent("div");
	par_el.addClass('empty');
	par_el.find('input').val('');
	par_el.find('img').remove();
	jQuery(document).trigger('destroyTheFG');
	
	return false;
});

// cloudfw_get_icon_list function
function cloudfw_get_icon_list(e,element){
	cloudfw_get_icon_list_close();
	var icon_list = jQuery('#cloudfw-icon-list');
	icon_list.draggable({ handle: "#icon-box-title" });
	
	var from_top = element.offset().top;
	var from_left = element.offset().left;
	icon_list.attr('data-width', icon_list.outerWidth()).attr('data-height', icon_list.outerHeight());
	
	icon_list.css({
		'top' : from_top - 3,
		'left': from_left - 3,
		'width' : 0,
		'height': 0
	}).animate({
		'width' : icon_list.attr('data-width'),
		'height': icon_list.attr('data-height')
	},function(){element.find('.loading_black').remove();}).show();
	
	jQuery(".icon-cat-title").click(function(){
		jQuery('#icon-box-append').text("/ " +jQuery(this).text());
		jQuery(this).next('.grouped').show();
		jQuery(".icon-cat-title").hide();
		jQuery("#icon-box-back").show();
		return false;
	});
	
	jQuery("#icon-box-close").click(function(){
		cloudfw_get_icon_list_close();
		return false;
	});
	
	jQuery("#icon-box-back").click(function(){
		cloudfw_get_icon_list_close(true);
		return false;
	});
	
	jQuery(".the-icon").click(function(){
		var item_id = jQuery(this).attr('data-id');
		element.find("input").val(item_id);
		element.find("img").remove();
		element.append(jQuery(this).find("img").clone());
		element.parent("div").removeClass("empty");
		
		cloudfw_get_icon_list_close();
		return false;
	});

}
// end of cloudfw_get_icon_list function



if (jQuery("#appandtohere-nags").length > 0){
	jQuery(".cloudfw-update-messages").each(function(){
		jQuery(this).appendTo('#appandtohere-nags');	
	});
}


	
};// End of Main Script


function cloudfw_get_icon_list_close(noclose){
	if (!noclose) {
		jQuery("#cloudfw-icon-list").hide();
		jQuery("#icon-box-close, #icon-box-back, .the-icon").unbind('click');
	}else{
		jQuery("#cloudfw-icon-list .icon-cat-title").show();
		jQuery('#icon-box-append').text("");
		jQuery('.grouped, #icon-box-back').hide();
	}
}



//-----------------------

function slider_management(){
var isie = (jQuery.browser.msie);
var isie7 = (jQuery.browser.msie && jQuery.browser.version.substr(0,1)<8);

jQuery('#slider_form, .slider_forms').unbind('submit');
jQuery('#slider_form, .slider_forms').submit(function(){
									   
	var slider_form = jQuery(this);
	if (slider_form.hasClass("disabled")) return false;
	slider_form.addClass('disabled');
	
	var slider_image = slider_form.find('input[name="slider_image"]').val();
	var slider_video = slider_form.find('input[name="slider_video"]').val();
	slider_form.find(':submit').val(textSending).parent('div').fadeTo(500,.5);
	
});
	


jQuery('.toggle').click(function(){
		var el = jQuery(this);
		
		if (typeof el != 'undefined') {
		
		var id = el.attr('rel');
		var relation = jQuery(id);
		
		if (el.hasClass("active")) 
			{el.removeClass("active"); 	if (isie7) relation.hide(); else relation.slideUp(400);}
			else
			{el.addClass("active");		if (isie7) relation.show(); else relation.slideDown(400);};
		
		
		return false;
		}
		
});


if (isie) sortable_sliders_opacity = 0; else sortable_sliders_opacity = 0.6;
var i = 0;
jQuery(".sortable_sliders").sortable({
		opacity:  sortable_sliders_opacity,	axis: 'y', containment: 'parent', placeholder: 'sortable-placeholder', scroll:true, delay: 200,
		start: function(event, ui) {
		
		ui.item.addClass("removeBorder");
		
		},	 
		update: function(event, ui) {
		jQuery(this).children('li').each(function(i,element){jQuery(this).find('.sort_input').val(i);i++;});
		jQuery('#apply-sorting').show();
		},
		stop: function(event, ui) {

		ui.item.removeClass("removeBorder");
		
		}
	});


}

function slider_edit(){
jQuery(".slider_ajax .edit, #add_new_slider").die('click');
jQuery(".slider_ajax .edit, #add_new_slider").live('click',function() {

	var el = jQuery(this);
	var form = jQuery('#slider_form_action').val();
	var slider = jQuery('#slider_form_option_main_slider_id').val();
		
	//jQuery.scrollTo( jQuery('#add-update-form'), {duration: 500, offset:{top:-20 } } );
	
	jQuery("#sliderforms").addClass("loading").slideDown(300).html('');
	
	jQuery.ajax({
		url: jQuery('#slider_form_option_getform').val(),
		cache: false,
		type: "POST",
		dataType: "html",
		data: ({
			   
			id : el.attr("rel"),
			action : 'edit',
			type: jQuery('#slider_form_type').val(),
			lastID : jQuery('#slider_form_option_lastid').val(),
			thispage : jQuery('#slider_form_option_thispage').val(),
			main_slider_id : jQuery('#slider_form_option_main_slider_id').val()
				
			}),
		success: function(data) {
		jQuery("#sliderforms").removeClass("loading").html(data).slideDown(300);
		
		cloud_main();
		slider_management();
		jQuery(".tabs").tabs();
		toggle_goback_slider();
		
		}  
						
						
	});

	return false;
																  
	});


jQuery("#backtoAllSliders").die('click');
jQuery("#backtoAllSliders").live('click',function() {
		
	jQuery.scrollTo( jQuery('#add-update-form'), {duration: 500, offset:{top:-20 } } );
	
	jQuery("#sliderforms").addClass("loading").slideDown(300).html('');
	
	jQuery.ajax({
		url: jQuery('#slider_form_option_getform').val(),
		cache: false,
		type: "POST",
		dataType: "html",
		data: ({
			action : 'loop',
			lastID : jQuery('#slider_form_option_lastid').val(),
			thispage : jQuery('#slider_form_option_thispage').val(),
			type: jQuery('#slider_form_type').val(),
			main_slider_id : jQuery('#slider_form_option_main_slider_id').val()
		}),
		success: function(data) {
			
			jQuery("#sliderforms").removeClass("loading").html(data).slideDown(300);
				cloud_main();
				slider_management();
				jQuery(".tabs").tabs();
				toggle_goback_slider();
			}  
							
						
	});

	return false;
																  
	});


};//End Edit Function

function toggle_goback_slider(){
	var el_goback = jQuery("#goback-toggle");
	var el_createnew_slider = jQuery("#createnew-toggle");

	if (el_goback.is(":visible")){
		el_goback.hide();
		el_createnew_slider.show();
	}else{
		el_goback.show();
		el_createnew_slider.hide();
	}
}


function slider_remove(){
jQuery(".slider_ajax").find(".remove").die('click');
jQuery(".slider_ajax").find(".remove").live('click', function(event) {
	var el = jQuery(this);
	var form = jQuery('#slider_form_option_case').val();

 	 if(event.ctrlKey) {
    //Ctrl+Click
		
		if (!el.hasClass("remove-active")){
			
			el.parent().parent("li").find(".delete_input").val("true");
			el.addClass("remove-active");
			
			}else{
				
			el.parent().parent("li").find(".delete_input").val("");
			el.removeClass("remove-active");
	}
		
		
	
	jQuery('#apply-sorting').show().find("input").val("Save Changes");
	
 	 }else {
		 
	jQuery("#small-loading").show();	
	
	
	jQuery.ajax({
		url: jQuery('#slider_form_option_getform').val(),
		cache: false,
		type: "POST",
		data: ({				
				id : el.attr("rel"),
				action : 'delete',
				type: jQuery('#slider_form_type').val(),
				lastID : jQuery('#slider_form_option_lastid').val(),
				thispage : jQuery('#slider_form_option_thispage').val(),
				main_slider_id : jQuery('#slider_form_option_main_slider_id').val()
				
			}),
		success: function(data) {
		
		jQuery("#slider_items").html(data);
		
		cloud_main();
		slider_management();
		jQuery("#small-loading").hide();
		jQuery("#removed_message").fadeIn(500).delay(300).fadeOut(700);
		
												
					}  
						
		});
	
	}
	 
	 return false;

	});//Slider Item Del End

}//End Remove Function
	
	
	
		
function shortcodes_generator_tabs(){
	

	var tab_inprogress;
	var el = jQuery('#cloudfw_shortcode_tab_div');
	var titles = el.children('#cloudfw_shortcode_content-tabs').find('li').not('.notab');
	var items = jQuery('#cloudfw_shortcode_content-tabs-contents').find('li');
	var selection;
	
		var i = 1;
		
	titles.children('a').click(function(){
			thisel = jQuery(this);
			isie = jQuery.browser.msie;
			
			if (tab_inprogress == true || thisel.parent('li').hasClass('actived')) return false;
			tab_inprogress = true;
			 
			var id = thisel.attr("href");			
			var section = thisel.attr('rel');
			
				jQuery('#cloudfw_shortcode_content-tabs-contents').find('.currentTab').slideUp(function(){jQuery(this).removeClass('currentTab').addClass('hidden');});
				jQuery('#cloudfw_shortcode_content-tabs-contents').find(id).css('display','none').removeClass('hidden').slideDown(function(){tab_inprogress = false;}).addClass('currentTab');
			
			
			if (section !== ''){
						
			loaded_tab_c = jQuery(id);		
			if (loaded_tab_c.html() == '' && section !== '') {
			
						loaded_tab_c.addClass('loading');
						var url = jQuery("meta[name=tmpurl]").attr('content');
						
							jQuery.ajax({
				
								url: url + '/js/cloudfw_shortcodes.php',
								cache: false,
								type: "POST",
								data: ({selection: selection, section: section }),
								success: function(data) {
								
									loaded_tab_c.removeClass('loading').html(data);
									cloud_main();
									shortcodes_generator_tabs();
								
								}  
																		
							});
				
				}
			}
			
			
			el.find('.actived').removeClass('actived');
			thisel.parent('li').addClass('actived');
			
			cloudfw_get_icon_list_close();
			
			return false;
		
		});
	}	
	

		!window.tinyMCE
function shortcodes_tabs(){
	
	function shortcodes_tabs_setup(){
			jQuery('.shortcodes_tabs, #cloudfw_shortcode_main_container').remove();

			jQuery('#media-buttons').before('<a class="hide-if-no-js shortcodes_tabs" id="cloudfw_shortcode_tab">Shortcodes</a><span class="shortcodes_tabs" id="cloudfw_shortcode_tab_loading"></span>');
			jQuery('#postdivrich').before('<div id="cloudfw_shortcode_main_container"></div>');
			shortcodes_tabs = jQuery('#cloudfw_shortcode_tab');
	
			shortcodes_tabs.bind('click',function(){call_shortcodes();});
			
	}
	
	shortcodes_tabs_setup();
	//jQuery('#edButtonPreview, #edButtonHTML').bind('click',function(){shortcodes_tabs_setup();});

}


function edButton(id, display, tagStart, tagEnd, access, open) {
		this.id = id;     // used to name the toolbar button
		this.display = display;    // label on button
		this.tagStart = tagStart;    // open tag
		this.tagEnd = tagEnd;    // close tag
		this.access = access;    // access key
		this.open = open;    // set to -1 if tag does not need to be closed
}


function cloudfw_get_back_form(the_form) {
				
	the_form.find(':submit').each(function(){
		jQuery(this).val(textSaved).parent('div').removeClass("small-sky").addClass("small-green");
	});
	
	 var getBackTheForm = setInterval(function() {
		the_form.find(':submit').val('Finish');
		
		the_form.removeClass('disabled');
		
		the_form.find(':submit').each(function(){
			jQuery(this).val(jQuery(this).attr('data-old-val')).attr('data-old-val','').parent('div').removeClass("small-green").addClass("small-sky");
		});
		the_form.find('#save_apply').parent('div').show();
		clearInterval(getBackTheForm);
		
	   }, 2000);

} // end cloudfw_get_back_form

function cloudfw_global_loading(action) {
	
	var spinner = jQuery('#spinner');
	if (action == 'show')
		spinner.fadeIn();
	else
		spinner.fadeOut();
		

} // end cloudfw_global_loading



function fw_dialog(msg, $case) {
	
	clearInterval(refreshId_Grown);
	
	out = '<div class="grown grown-'+$case+'" style="display:none;">\
														\
			<a href="#" class="grown-close" onclick="jQuery(this).parent(\'.grown\').remove(); return false;"></a> \
														\
			<div class="icon-div box-div" style="margin:10px 20px 10px; width:auto;">'+msg+'	\
			\
			</div>\
					\
		</div>';	
	
	if (jQuery('.grown').length > 0) {
		
		jQuery('.grown').fadeOut(function(){
			jQuery(this).remove();
			jQuery('#framework').after(out);
			jQuery('.grown').hide().fadeIn(1000);
		});
	
	}else{
			jQuery('#framework').after(out);
			jQuery('.grown').hide().fadeIn(1000);	
	}
	
	var refreshId_Grown = setInterval(function() {
			  
		    jQuery('.grown').fadeOut(function(){jQuery(this).remove();});
			clearInterval(refreshId_Grown);
			
	}, 3000);
	
}


function cloudfw_check_the_post_when_submiting(){
	/*
	 *	Check The Post Form Before Being Sent
	 *
	 *	@since 1.0
	**/
	jQuery('#post').live('submit', function(e){
		if (typenow == 'page')
			return true;

		jQuery(this).removeClass('sending');
		jQuery('.err').removeClass('err');


		/* Is Set Thumbnail? */
		if ( typenow == 'portfolio' && ! (jQuery('.attachment-post-thumbnail').length > 0) ) {
			
			jQuery('#postimagediv').addClass('err');
			cloudfwError('Please Set A Featured Image for the Post')
			stopForm(e);

			return false;
			
		}

		if ( typenow == 'portfolio' && jQuery('#' + pfix + '_port_lightbox').val() == '' ) {
			jQuery('#cloud_page_portfolio_settings').addClass('err');
			cloudfwError('Please set "When Click The Link Of The Post" option from the Portfolio Settings area on this page')
			stopForm(e);

			return false;

		}
		


	});


}


jQuery(document).ready(function() {
	
	url = jQuery("meta[name=tmpurl]").attr('content');
	pfix = jQuery("meta[name=pfix]").attr('content');
	cloudfw_nonce = jQuery("meta[name=_wpnonce]").attr('content');
	textSending = jQuery("meta[name=textSending]").attr('content') ? jQuery("meta[name=textSending]").attr('content') : 'Sending...';
	textSaved = jQuery("meta[name=textSaved]").attr('content') ? jQuery("meta[name=textSaved]").attr('content') : 'Saved';
	textUpdate = jQuery("meta[name=textUpdate]").attr('content') ? jQuery("meta[name=textUpdate]").attr('content') : 'Update';
	textSendTheEditor = jQuery("meta[name=textSendTheEditor]").attr('content') ? jQuery("meta[name=textSendTheEditor]").attr('content') : 'Insert Into The Input';

	cloud_main();
	slider_management();
	slider_edit();
	slider_remove();
	shortcodes_tabs();
	cloudfw_check_the_post_when_submiting();

});
