{% load i18n %}

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>{#stormeimage_dlg.dialog_title}</title>

	<link href="{{ STATIC_URL }}tinymce/plugins/stormeimage/css/stormeimage.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}tinymce/plugins/stormeimage/css/swfupload.visual.css">

	<!-- tinymce -->
	<script type="text/javascript" src="{{ STATIC_URL }}tinymce/tiny_mce_popup.js"></script>
	<script type="text/javascript" src="{{ STATIC_URL }}tinymce/utils/mctabs.js"></script>
	<script type="text/javascript" src="{{ STATIC_URL }}tinymce/utils/form_utils.js"></script>
	<script type="text/javascript" src="{{ STATIC_URL }}tinymce/utils/validate.js"></script>
	<script type="text/javascript" src="{{ STATIC_URL }}tinymce/utils/editable_selects.js"></script>
	<script type="text/javascript" src="{{ STATIC_URL }}tinymce/plugins/stormeimage/js/image.js"></script>
    <script type="text/javascript" src="{{ STATIC_URL }}tinymce/plugins/stormeimage/js/json2.min.packed.js"></script>

	<!-- swfupload (and jquery) -->
	<script src="{{ STATIC_URL }}js/jquery-1.4.2.min.js" type="text/javascript"></script>
	<script src="{{ STATIC_URL }}swfupload/swfupload.js" type="text/javascript"></script>
	<script src="{{ STATIC_URL }}swfupload/swfupload.cookies.js" type="text/javascript"></script>
	<script src="{{ STATIC_URL }}tinymce/plugins/stormeimage/js/swfupload.handlers.js" type="text/javascript"></script>
	<script src="{{ STATIC_URL }}swfupload/swfupload.swfobject.js" type="text/javascript"></script>
</head>
<body id="stormeimage" style="display: none">
    <form onsubmit="ImageDialog.insert();return false;" action="#"> 
		<div class="tabs">
			<ul>
				<li id="fromcomputer_tab" class="current"><span><a href="javascript:mcTabs.displayTab('fromcomputer_tab','fromcomputer_panel');" onmousedown="return false;">{#stormeimage_dlg.tab_fromcomputer}</a></span></li>
				<li id="gallery_tab"><span><a href="javascript:mcTabs.displayTab('gallery_tab','gallery_panel');" onmousedown="return false;">{#stormeimage_dlg.tab_gallery}</a></span></li>
                <li id="imageedit_tab"><span><a href="javascript:mcTabs.displayTab('imageedit_tab','imageedit_panel');" onmousedown="return false;">{#stormeimage_dlg.tab_imageedit}</a></span></li>
			</ul>
		</div>

		<div class="panel_wrapper">
			<div id="fromcomputer_panel" class="panel current">

					<div id="flashUI">
					
						<div>
							<span class="select-photos">
							<span id="spanButtonPlaceholder"></span>
							<a id="choose-photos" href="javascript:;">{% trans "Upload Media" %}</a>
							</span>
						</div>
						<div style="clear:both;"></div>

						<fieldset id="chosen-photos">
							<legend><span id="photo-queue">{{ media.count }}</span>&nbsp;{% trans "Files" %}</legend>
							<div class="flash" id="fsUploadProgress">
                                {% for file in media %}
                                	<div class="progressWrapper">
                                    <div class="progressContainer blue">
                                    {% include 'files/templates/tinymce_upload.html' with delete='True'%}
                                    </div> <!-- END progressContainer -->
                                    </div> <!-- END progressWrapper -->
                                {% endfor %}
							</div> <!-- END fsUploadProgress -->
						</fieldset>

					</div> <!-- flash uploader -->
					<div id="degradedUI"></div>
					<div id="stop-upload"></div>
			</div>

			<div id="gallery_panel" class="panel">

					<div id="flashUI">
					
						<fieldset id="chosen-photos">
							<legend><span id="photo-queue">{{ all_media.count }}</span>&nbsp;{% trans "Files" %}</legend>
							<div class="flash" id="fsUploadProgress">
                                {% for file in all_media %}
                                	<div class="progressWrapper">
                                    <div class="progressContainer blue">
                                    {% include 'files/templates/tinymce_upload.html' %}
                                    </div> <!-- END progressContainer -->
                                    </div> <!-- END progressWrapper -->
                                {% endfor %}
							</div> <!-- END fsUploadProgress -->
						</fieldset>

					</div> <!-- flash uploader -->
					<div id="degradedUI"></div>
					<div id="stop-upload"></div>
			</div>

			<div id="imageedit_panel" class="panel">
                <div class="photo-wrapper">
                    <input type="hidden" name="image-id" value="" />
					<input type="hidden" name="orig_width" value="" />
					<input type="hidden" name="orig_height" value="" />
                    <div class="info">
                        <div style="width:100%;" class="title"></div>
                    </div>
                    <div style="clear:both;"></div>
                    <div class="options">
                        <table cellpadding=5 style="width:100%;" border="0">
                        	<tr>
                        		<td>Title Text &amp; Alt Text:</td>
                        	</tr>
                            <tr>
                                <td><input style="width:100%;" type="text" name="edit_title" value="" /></td>
                            </tr>
							<tr>
								<td>
									<table cellpadding=5 style="width:100%" border="0">
										<tr>
											<td>
												<table cellpadding=5 style="width:120px;" border="0">
													<tr>
														<td colspan="3" style="text-align: center;"><input style="width:30px;" type="text" size="3" name="edit_top_margin" value="" /></td>
													<tr>
													<tr>
														<td><input style="width:30px;" type="text" size="3" name="edit_left_margin" value="" /></td>
														<td>
										                    <div class="photo">
										                        <img class="edit_src" style="width:75px; height:75px;" src="" />
										                    </div>
														</td>
														<td><input style="width:30px;" type="text" size="3" name="edit_right_margin" value="" /></td>
													</tr>
													<tr>
														<td colspan="3" style="text-align: center;"><input style="width:30px;" type="text" size="3" name="edit_bottom_margin" value="" /></td>
													</tr>		
												</table>
											</td>
											<td>
												<table cellpadding=5 style="width:120px;" border="0">
													<tr>
														<td>{% trans "Width" %}:<input style="width:40px;" type="text" name="edit_width" /></td>
													</tr>
													<tr>
														<td>{% trans "Height" %}: <input style="width:40px;" type="text" name="edit_height" /></td>
													</tr>
                                                    <tr>
                                                        <td>{% trans "Maintain Proportions" %}: <input style="width:15px;" type="checkbox" name="edit_ratio" /></td>
                                                    </tr>
													<tr>
														<td>
						                                    <select name="edit_float">
						                                        <option value="">-- {% trans "Alignment (Float) "%} --</option>
						                                        <option value="left">{% trans "Left" %}</option>
						                                        <option value="right">{% trans "Right" %}</option>
						                                    </select>&nbsp;
														</td>
													</tr>
												</table>									
											</td>
										</tr>
									</table>
								</td>
							</tr>
							<input style="width:30px" type="hidden" name="edit_vspace" value="0" />
							<input style="width:30px" type="hidden" name="edit_hspace" value="0" />
							<input style="width:30px" type="hidden" name="edit_align" value="-- not set --" />			
                        </table>
                        <div class="actions">
                            <a class="update-btn" onclick="ImageDialog.update();" href="javascript:;">{% trans "Update Image" %}</a>  
                            <a class="delete-btn" onclick="ImageDialog.remove_image();" href="javascript:;">{% trans "Remove Image" %}</a> 
                        </div>
                    </div>
                </div>

			</div><!-- imageedit_panel -->

			<div id="general_panel" class="panel">
				<fieldset>
						<legend>{#stormeimage_dlg.general}</legend>

						<table class="properties">
							<tr>
								<td class="column1"><label id="srclabel" for="src">{#stormeimage_dlg.src}</label></td>
								<td colspan="2"><table border="0" cellspacing="0" cellpadding="0">
									<tr> 
									  <td><input name="src" type="text" id="src" value="" onchange="ImageDialog.showPreviewImage(this.value);" /></td> 
									  <td id="srcbrowsercontainer">&nbsp;</td>
									</tr>
								  </table></td>
							</tr>
							<tr>
								<td><label for="src_list">{#stormeimage_dlg.image_list}</label></td>
								<td><select id="src_list" name="src_list" onchange="document.getElementById('src').value=this.options[this.selectedIndex].value;document.getElementById('alt').value=this.options[this.selectedIndex].text;document.getElementById('title').value=this.options[this.selectedIndex].text;ImageDialog.showPreviewImage(this.options[this.selectedIndex].value);"><option value=""></option></select></td>
							</tr>
							<tr> 
								<td class="column1"><label id="altlabel" for="alt">{#stormeimage_dlg.alt}</label></td> 
								<td colspan="2"><input id="alt" name="alt" type="text" value="" /></td> 
							</tr> 
							<tr> 
								<td class="column1"><label id="titlelabel" for="title">{#stormeimage_dlg.title}</label></td> 
								<td colspan="2"><input id="title" name="title" type="text" value="" /></td> 
							</tr>
						</table>
				</fieldset>

				<fieldset>
					<legend>{#stormeimage_dlg.preview}</legend>
					<div id="prev"></div>
				</fieldset>
			</div>

			<div id="appearance_panel" class="panel">
				<fieldset>
					<legend>{#stormeimage_dlg.tab_appearance}</legend>

					<table border="0" cellpadding="4" cellspacing="0">
						<tr> 
							<td class="column1"><label id="alignlabel" for="align">{#stormeimage_dlg.align}</label></td> 
							<td><select id="align" name="align" onchange="ImageDialog.updateStyle('align');ImageDialog.changeAppearance();"> 
									<option value="">{#not_set}</option> 
									<option value="baseline">{#stormeimage_dlg.align_baseline}</option>
									<option value="top">{#stormeimage_dlg.align_top}</option>
									<option value="middle">{#stormeimage_dlg.align_middle}</option>
									<option value="bottom">{#stormeimage_dlg.align_bottom}</option>
									<option value="text-top">{#stormeimage_dlg.align_texttop}</option>
									<option value="text-bottom">{#stormeimage_dlg.align_textbottom}</option>
									<option value="left">{#stormeimage_dlg.align_left}</option>
									<option value="right">{#stormeimage_dlg.align_right}</option>
								</select> 
							</td>
							<td rowspan="6" valign="top">
								<div class="alignPreview">
									<img id="alignSampleImg" src="img/sample.gif" alt="{#stormeimage_dlg.example_img}" />
									Lorem ipsum, Dolor sit amet, consectetuer adipiscing loreum ipsum edipiscing elit, sed diam
									nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.Loreum ipsum
									edipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam
									erat volutpat.
								</div>
							</td>
						</tr>

						<tr>
							<td class="column1"><label id="widthlabel" for="width">{#stormeimage_dlg.dimensions}</label></td>
							<td class="nowrap">
								<input name="width" type="text" id="width" value="" size="5" maxlength="5" class="size" onchange="ImageDialog.changeHeight();" /> x 
								<input name="height" type="text" id="height" value="" size="5" maxlength="5" class="size" onchange="ImageDialog.changeWidth();" /> px
							</td>
						</tr>

						<tr>
							<td>&nbsp;</td>
							<td><table border="0" cellpadding="0" cellspacing="0">
									<tr>
										<td><input id="constrain" type="checkbox" name="constrain" class="checkbox" /></td>
										<td><label id="constrainlabel" for="constrain">{#stormeimage_dlg.constrain_proportions}</label></td>
									</tr>
								</table></td>
						</tr>

						<tr>
							<td class="column1"><label id="vspacelabel" for="vspace">{#stormeimage_dlg.vspace}</label></td> 
							<td><input name="vspace" type="text" id="vspace" value="" size="3" maxlength="3" class="number" onchange="ImageDialog.updateStyle('vspace');ImageDialog.changeAppearance();" onblur="ImageDialog.updateStyle('vspace');ImageDialog.changeAppearance();" />
							</td>
						</tr>

						<tr> 
							<td class="column1"><label id="hspacelabel" for="hspace">{#stormeimage_dlg.hspace}</label></td> 
							<td><input name="hspace" type="text" id="hspace" value="" size="3" maxlength="3" class="number" onchange="ImageDialog.updateStyle('hspace');ImageDialog.changeAppearance();" onblur="ImageDialog.updateStyle('hspace');ImageDialog.changeAppearance();" /></td> 
						</tr>

						<tr>
							<td class="column1"><label id="borderlabel" for="border">{#stormeimage_dlg.border}</label></td> 
							<td><input id="border" name="border" type="text" value="" size="3" maxlength="3" class="number" onchange="ImageDialog.updateStyle('border');ImageDialog.changeAppearance();" onblur="ImageDialog.updateStyle('border');ImageDialog.changeAppearance();" /></td> 
						</tr>

						<tr>
							<td><label for="class_list">{#class_name}</label></td>
							<td colspan="2"><select id="class_list" name="class_list" class="mceEditableSelect"><option value=""></option></select></td>
						</tr>

						<tr>
							<td class="column1"><label id="stylelabel" for="style">{#stormeimage_dlg.style}</label></td> 
							<td colspan="2"><input id="style" name="style" type="text" value="" onchange="ImageDialog.changeAppearance();" /></td> 
						</tr>

						<!-- <tr>
							<td class="column1"><label id="classeslabel" for="classes">{#stormeimage_dlg.classes}</label></td> 
							<td colspan="2"><input id="classes" name="classes" type="text" value="" onchange="selectByValue(this.form,'classlist',this.value,true);" /></td> 
						</tr> -->
					</table>
				</fieldset>
			</div>

			<div id="advanced_panel" class="panel">
				<fieldset>
					<legend>{#stormeimage_dlg.swap_image}</legend>

					<input type="checkbox" id="onmousemovecheck" name="onmousemovecheck" class="checkbox" onclick="ImageDialog.setSwapImage(this.checked);" />
					<label id="onmousemovechecklabel" for="onmousemovecheck">{#stormeimage_dlg.alt_image}</label>

					<table border="0" cellpadding="4" cellspacing="0" width="100%">
							<tr>
								<td class="column1"><label id="onmouseoversrclabel" for="onmouseoversrc">{#stormeimage_dlg.mouseover}</label></td> 
								<td><table border="0" cellspacing="0" cellpadding="0"> 
									<tr> 
									  <td><input id="onmouseoversrc" name="onmouseoversrc" type="text" value="" /></td> 
									  <td id="onmouseoversrccontainer">&nbsp;</td>
									</tr>
								  </table></td>
							</tr>
							<tr>
								<td><label for="over_list">{#stormeimage_dlg.image_list}</label></td>
								<td><select id="over_list" name="over_list" onchange="document.getElementById('onmouseoversrc').value=this.options[this.selectedIndex].value;"><option value=""></option></select></td>
							</tr>
							<tr> 
								<td class="column1"><label id="onmouseoutsrclabel" for="onmouseoutsrc">{#stormeimage_dlg.mouseout}</label></td> 
								<td class="column2"><table border="0" cellspacing="0" cellpadding="0"> 
									<tr> 
									  <td><input id="onmouseoutsrc" name="onmouseoutsrc" type="text" value="" /></td> 
									  <td id="onmouseoutsrccontainer">&nbsp;</td>
									</tr> 
								  </table></td> 
							</tr>
							<tr>
								<td><label for="out_list">{#stormeimage_dlg.image_list}</label></td>
								<td><select id="out_list" name="out_list" onchange="document.getElementById('onmouseoutsrc').value=this.options[this.selectedIndex].value;"><option value=""></option></select></td>
							</tr>
					</table>
				</fieldset>

				<fieldset>
					<legend>{#stormeimage_dlg.misc}</legend>

					<table border="0" cellpadding="4" cellspacing="0">
						<tr>
							<td class="column1"><label id="idlabel" for="id">{#stormeimage_dlg.id}</label></td> 
							<td><input id="id" name="id" type="text" value="" /></td> 
						</tr>

						<tr>
							<td class="column1"><label id="dirlabel" for="dir">{#stormeimage_dlg.langdir}</label></td> 
							<td>
								<select id="dir" name="dir" onchange="ImageDialog.changeAppearance();"> 
										<option value="">{#not_set}</option> 
										<option value="ltr">{#stormeimage_dlg.ltr}</option> 
										<option value="rtl">{#stormeimage_dlg.rtl}</option> 
								</select>
							</td> 
						</tr>

						<tr>
							<td class="column1"><label id="langlabel" for="lang">{#stormeimage_dlg.langcode}</label></td> 
							<td>
								<input id="lang" name="lang" type="text" value="" />
							</td> 
						</tr>

						<tr>
							<td class="column1"><label id="usemaplabel" for="usemap">{#stormeimage_dlg.map}</label></td> 
							<td>
								<input id="usemap" name="usemap" type="text" value="" />
							</td> 
						</tr>

						<tr>
							<td class="column1"><label id="longdesclabel" for="longdesc">{#stormeimage_dlg.long_desc}</label></td>
							<td><table border="0" cellspacing="0" cellpadding="0">
									<tr>
									  <td><input id="longdesc" name="longdesc" type="text" value="" /></td>
									  <td id="longdesccontainer">&nbsp;</td>
									</tr>
								</table></td> 
						</tr>
					</table>
				</fieldset>
			</div>
		</div>

		<div class="mceActionPanel">
			<div style="float: right;">
				<input type="button" id="cancel" name="cancel" value="Done" onclick="tinyMCEPopup.close();" />
			</div>
		</div>
    </form>
	<script type="text/javascript">
		var swfupload;

		window.onload = function() {
			swfupload = new SWFUpload({
			debug: false,
			
			upload_url: "/files/swfupload/",
			//flash_url: "{{ STATIC_URL }}swfupload/swfupload.swf",
			flash_url: "/static/swfupload/swfupload.swf",
			
			post_params: {
				"storme_app_label" : ImageDialog.storme_app_label,
				"storme_model" : ImageDialog.storme_model,
				"storme_instance_id" : ImageDialog.storme_instance_id,
				"csrfmiddlewaretoken": "{{ csrf_token }}"
			},

			// File upload settings
			file_size_limit : "20480",	// 20 MB
//			file_types : "*.jpg;*.jpeg;*.gif;*.tif;*.tiff;*.png",
//			file_types_description : "All Files",
			file_post_name: "file",
			
			// Button settings (opens file-browse dialogue)
			button_placeholder_id: "spanButtonPlaceholder",
			button_width: 175,
			button_height: 24,
			button_cursor: SWFUpload.CURSOR.HAND,
			button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,

			// Action handlers
			file_queued_handler : fileQueued,
			file_queue_error_handler : fileQueueError,
			file_dialog_complete_handler : fileDialogComplete,
			upload_start_handler : uploadStart,
			upload_progress_handler : uploadProgress,
			upload_error_handler : uploadError,
			upload_success_handler : uploadSuccess,
			upload_complete_handler : uploadComplete,
			swfupload_loaded_handler : swfUploadLoaded,
			swfupload_pre_load_handler : swfUploadPreLoad,
			swfupload_load_failed_handler : swfUploadLoadFailed,

			custom_settings : {
				progressTarget : "fsUploadProgress",
				cancelButtonId : "btnCancel1"
			},
			
			// SWFObject settings
			minimum_flash_version : "9.0.28",
			});
			
		};
		
    </script>
</body> 
</html> 
