<?php echo $this->Html->script('site_js/common');?>
<?php //echo $this->Html->script('ckeditor/ckeditor');?>
<?php echo $this->Html->script(array('site_js/nicEdit')); ?>
<script type="text/javascript">
	bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });
</script>
<script>
	$(document).ready(function(){
		//initial hide
		$("#cancel").hide();

		$("#changeimage").click(function(){
			$("#fileIntro").show();
			$("#cancel").show();
			$("#curImage").hide();
			$("#changeimage").hide();
			$("#deleteimage").hide();
			
		});

		$("#cancel").click(function(){
			$("#fileIntro").hide();
			$("#cancel").hide();
			$("#changeimage").show();
			$("#deleteimage").show();
			$("#curImage").show();
			
		});
		
		$("#cancel2").hide();

		$("#changeimage2").click(function(){
			$("#fileAtch").show();
			$("#cancel2").show();
			$("#curImage2").hide();
			$("#changeimage2").hide();
			$("#deletefile").hide();
			$("#current_attachment").hide();
		});

		$("#cancel2").click(function(){
			$("#fileAtch").hide();
			$("#cancel2").hide();
			$("#changeimage2").show();
			$("#curImage2").show();
			$("#deletefile").show();
			$("#current_attachment").show();
			
		});
	});
</script>
<style>
#ContentAddForm {
margin-bottom: 0px;
}

.modal {
  background-clip: padding-box;
  background-color: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
  left: 30%;
  margin-left: -280px;
  outline: medium none;
  position: fixed;
  top: 10%;
  width: 82%;
	height:92%;
  z-index: 1050;
}

.modal-body {
  max-height: 100%;
  overflow-y: auto;
  padding: 15px;
  position: relative;
}
.col-md-4 img {
  max-height: 100% !important;
  width: 390px !important;
}
.cropper-img img{
	max-height: 80px;
	margin-bottom: 10px;
}
.row-fluid .span10 {
    width: 83.606%;
}
.modal-content {
  box-shadow: none;
}
.modal-content {
  background-clip: padding-box;
  background-color: #fff;
  border: none;
  border-radius: 0px;
  position: relative;
}
.modal-footer {
  background-color: #fff;
  border-radius:0px;
  border-top: none;
  box-shadow: none;
  margin-bottom: 0;
  padding: 0;
  text-align: right;
}
.awesome-cropper .modal-dialog {
  width: 1080px;
}

.margin-bt{
	margin-bottom: 20px;
}
@media screen and (-webkit-min-device-pixel-ratio:0) { 
	  .margin-bt{
	    	margin-bottom: 0px;
	  }
}
body { padding-bottom: 40px; }
</style>
<style>

	.dis_b{display: block;}
	.dis_n{display: none;}
	.dis_b2{display: block;}
	.dis_n2{display: none;}

 </style>
<div class="blocktitle">Discussion - Draft - Edit</div>
<div class="tar borb">
	<?php //echo $this->Html->link('Class Discussions',array('action'=>'discussion'),array('class'=>'btn btn-mini'))?>
	<?php //echo $this->Html->link('My Discussions',array('action'=>'discussion','Mydiscussions'),array('class'=>'btn btn-mini'))?>
	<?php //echo $this->Html->link('Create',array('action'=>'add','Discussion'),array('class'=>'btn btn-mini'))?>
	<?php echo $this->Html->link('Back',array('action'=>'draft'),array('class'=>'btn btn-mini'))?>
</div>
<br/>

<div class="w97p pdl10">
<div class="classcontents form">
	<?php echo $this->Form->create('Classcontent',array('type'=>'file')); ?>
		<?php
			echo $this->Form->input('id');
			echo $this->Form->hidden('type');
			?>
				<div class="row-fluid" style="margin-top:15px;">
					<div class="span2">Title</div>
					<div class="span10"><?php echo $this->Form->input('title',array('div'=>false,'label'=>false,'style'=>'width:99%;'));?></div>
				</div>
				<div class="row-fluid margin-bt" id="intro" style="margin-top:15px;">
				<div class="span2">Intro Image:</div>
				<div class="span10">
					<?php 
		                 if (!empty($this->data['Classcontent']['link1'])){?>
		                       <img src="<?php echo $this->data['Classcontent']['link1'];?>"   class="profile-image"   id="profileImg" style=""/>
		                    <label id="deliMG" onclick="deletethumb(<?php echo $this->data['Classcontent']['id'];?>);" style="font-weight:normal;margin-top:7px; " class="">Remove Image</label>            
		                   <?php }else {?>
						      <?php echo $this->Form->input('introImg',array('type'=>'file','label'=>false,'div'=>array('id'=>'fileIntro')));?>
						<?php }?> 
	           </div>
			</div>
			<div class="row-fluid" style="margin-top:15px;">
					<div class="span2"><?php echo 'Content'?></div>
					<div class="span10"><?php echo $this->Form->input('content',array('class'=>'ckeditor','label'=>false));?></div>
				</div>
				<div class="row-fluid mrt10" id="atttach" >
					<div class="span2" style="margin-top: 10px;">Attach:</div>
					<div class="span10" style="margin-top: 10px;">
						<?php if ($this->data['Classcontent']['linkfile']){?>
							<?php echo $this->Html->link($this->data['Classcontent']['linkfile'],array('escape'=>false,'target'=>'_blank','style'=>'text-decoration: underline;'));?>
							<label id="deliMG" onclick="delete_file(<?php echo $this->data['Classcontent']['id'];?>);" style="font-weight:normal;margin-top:7px; " class="">Remove File</label>
						<?php }else {
							echo $this->Form->input('attachF',array('type'=>'file','label'=>false,'onchange'=>"validate2(this.value)",'div'=>array('id'=>'fileAtch','class'=>'')));
						}?>
						
					</div>
				</div>
		<div class="divline mrr5"></div>
		<div class="tar mrr5 mrt15"><!-- class:button-group-list -->
			<?php echo $this->Form->input("Publish",array('label'=>false,'type'=>'submit','name'=>'btnPost','div'=>false));?>
			<?php echo $this->Form->input("Save",array('label'=>false,'type'=>'submit','name'=>'btnSave','div'=>false));?>
			
			<?php //echo $this->Form->input("Publish",array('label'=>false,'type'=>'submit','name'=>'btnPublish','div'=>false));?>
			<div class="btnreset">
				<?php echo $this->Html->link('Cancel',array('controller'=>'classcontents','action'=>'discussion'));?>
			</div>
		</div>
		
	<?php echo $this->Form->end(); ?>
</div>
</div>
<script type="text/javascript">
     var path='<?php echo $this->webroot;?>';
		function deletethumb(id){
			 $.ajax({
			     	type: 'POST',
			     	url: path +'classcontents/deletethumb',
			     	data: {id:id},
			     	success: function(data){
				     	location.href="<?php echo $this->here?>";
			     	}
		     	});
		}

		function delete_file(id){
			 $.ajax({
			     	type: 'POST',
			     	url: path +'classcontents/delete_file',
			     	data: {id:id},
			     	success: function(data){
				     	location.href="<?php echo $this->here?>";
			     	}
		     	});
		}
	</script>