(function( $ ) {

	var shortcode = '';
	var inner = '';
	
	$('#shortcode-dropdown').live('change', function() {
		var $currentShortcode = $(this).val();
		$('#shortcode').empty();
		if( $currentShortcode === 'googlemap' ) {
			ktz_show_option('.googlemap');
		} else if( $currentShortcode === 'soundcloud' ) {
			ktz_show_option('.soundcloud');
		} else if( $currentShortcode === 'video' ) {
			ktz_show_option('.video');
		} else {
			$('.option').hide();
			shortcode = '';
		}
		$('#shortcode').html( shortcode );
	});
	$('#insert-shortcode').live('click', function() {
		var $currentShortcode = $('#shortcode-dropdown').val();
		if( $currentShortcode === 'googlemap' ) {				
			var googlemap_width = $('#googlemap-width').val();
			var googlemap_height = $('#googlemap-height').val();
			var googlemap_url = $('#googlemap-url').val();
				shortcode = '[googlemap width="' + googlemap_width + '" height="' + googlemap_height + '" src="' + googlemap_url + '"][/googlemap]';				
		} else if( $currentShortcode === 'soundcloud' ) {	
			var soundcloud_url = $('#soundcloud-url').val();
				shortcode = '[soundcloud url="' + soundcloud_url + '"][/soundcloud]';	
		} else if( $currentShortcode === 'video' ) {	
			var video_choice = $('#video-choice').val();
			var video_width = $('#video-width').val();
			var video_height = $('#video-height').val();
			var video_url = $('#video-url').val();
				shortcode = '[' + video_choice + ' width="' + video_width + '" height="' + video_height + '" src="' + video_url + '"][/' + video_choice + ']';
		}
		tinyMCE.activeEditor.execCommand('mceInsertContent', false, shortcode);
		tb_remove();

	});
	function ktz_show_option( option ) {$('.option').hide();$( option ).show();}
})( jQuery );