<script>
$(document).ready(function(){
	$('select').select2();
	$.each($(".select2-container"), function (i, n) {
            $(n).next().show().fadeTo(0, 0).height("0px").css("left", "auto"); // make the original select visible for validation engine and hidden for us
            $(n).prepend($(n).next());
            $(n).delay(500).queue(function () {
                $(this).removeClass("validate[required]"); //remove the class name from select2 container(div), so that validation engine dose not validate it
                $(this).dequeue();
            });
        });	
});
	function changeList(obj){
		var id = obj.value;
		$.ajax({
			type: "POST",
			url: "<?php echo base_url()?>setting/getState/",
			data: "region="+id,
			dataType:"json",
			success: function(content){
				if(content.status == "success") {
					var items = [];
					items.push('<option>-Please Select-</option>');
					for ( var i = 0; i < content.message.length; i++) {
					items.push('<option value="'+content.message[i].fldid+'">'
						+ content.message[i].fldname + '</option>');
					}
					jQuery("#state").empty();
					jQuery("#state").append(items.join('</br>'));
				} else {
					$("#error").html('<p>'+content.message+'</p>');
				}
			}
		});
		return false;
	}
</script>
<div id="content">                        
<div class="wrap">
                  
<div class="head">
	<div class="info">
		<h1><?php echo element('compName', $this->session->userdata('logged_in')) ?> [ 
		<?php echo element('compNo', $this->session->userdata('logged_in')) ?> ]</h1>
			<ul class="breadcrumb">
            	<li><a href="<?php echo base_url()?>home"><?php echo $this->lang->line('dashboard') ?></a> <span class="divider">-</span></li>
                <li><a href="zakat/home"><?php echo $this->lang->line('module') ?></a> <span class="divider">-</span></li>
                <li class="active"><?php echo $this->lang->line('title') ?></li>
            </ul>
	</div>
                          
	<div class="search">
		<form action="<?php echo base_url() ?>admin/search" method="post">
			<input name="search_text" type="text" placeholder="search..."/>                                
            <button type="submit"><span class="i-magnifier"></span></button>
		</form>
	</div>                        
</div>  <!-- Head -->
<div class="content">
	<div class="row-fluid">
		<div class="span12">
			<?php 
				$hidden = array('order_time' => date('Y-m-d H-i-s'));
				$attrib = array('id'=>'validate'); 
				echo form_open('', $attrib, $hidden);?>
            <div class="block">
               	<div class="head">
                   	<h2><?php echo $this->lang->line('title') ?></h2>
				</div>
				<div class="content np">    
                  <div class="controls-row">
                  	<div class="span2"><?php echo $this->lang->line('shortName') ?></div>
                   	<div class="span10">
						<?php
							$data = array(
									'name'=>'shortName',
									'id'=>'shortName',								
									'class'=>'span2 validate[required,maxSize[12]]',); 
							echo form_input($data, set_value('shortName')); ?>                       
                  	</div>                            
                  </div>    
                  <div class="controls-row">
                  	<div class="span2"><?php echo $this->lang->line('name') ?></div>
                   	<div class="span10">
						<?php
							$data = array(
									'name'=>'name',
									'id'=>'name',								
									'class'=>'span7 validate[required,maxSize[128]]',); 
							echo form_input($data, set_value('name')); ?>                       
                  	</div>                            
                  </div>    
                  <div class="controls-row">
                    	<div class="span2"><?php echo $this->lang->line('address') ?></div>
                   		<div class="span10">
                            	<?php 								
								$data = array(
									'name'=>'line1', 
									'id'=>'line1', 
									'class'=>'span10 validate[required,maxSize[128]]',); 
								echo form_input($data, set_value('line1')); ?>
                  		</div>
                  </div>
                  <div class="controls-row">
                    	<div class="span2"></div>
                   		<div class="span10">
                            	<?php 								
								$data = array(
									'name'=>'line2', 
									'id'=>'line2', 
									'class'=>'span10',); 
								echo form_input($data, set_value('line2')); ?>
                  		</div>
                  </div>
                  <div class="controls-row">
                    	<div class="span2"></div>
                   		<div class="span10">
                            	<?php 								
								$data = array(
									'name'=>'line3', 
									'id'=>'line3', 
									'class'=>'span10',); 
								echo form_input($data, set_value('line3')); ?>
                  		</div>
                  </div>
                  <div class="controls-row">
                    	<div class="span2"><?php echo $this->lang->line('city') ?></div>
                   		<div class="span10">
                            	<?php 								
								$data = array(
									'name'=>'city', 
									'id'=>'city', 
									'class'=>'span5 validate[required,maxSize[64]]',); 
								echo form_input($data, set_value('city')); ?>
                  		</div>
                  </div>
                  <div class="controls-row">
                    	<div class="span2"><?php echo $this->lang->line('postCode') ?></div>
                   		<div class="span10">
                            	<?php 								
								$data = array(
									'name'=>'postCode', 
									'id'=>'postCode', 
									'class'=>'span2 validate[required,maxSize[8]]',); 
								echo form_input($data, set_value('postCode')); ?>
                  		</div>
                  </div>
					<div class="controls-row"> <!-- row 1 -->
                    	<div class="span2"><?php echo $this->lang->line('country') ?></div>
                   		<div class="span4">
						<?php
							$preselcat = '458';
							$options[] = '--Please Select--';
							foreach($country as $row){
								$options[$row->fldid] = $row->fldcountry;
							}
							$js='onChange="changeList(this)" class="span12 validate[required]"';
							echo form_dropdown('country', $options, $preselcat, $js);
						?>
               		  </div>                
                   	  <div class="span2 tar"><?php echo $this->lang->line('state') ?></div>
                   		<div class="span4">
						<?php
							$preseltype = '0';
							$options='';
							$options[] = '--Please Select--';
							if($state != ''){
								foreach($state as $row){
									$options[$row->fldid] = $row->fldname;
								}
							}
							$js='id=state class="span12 validate[required]"';
							echo form_dropdown('state', $options, $preselcat, $js);
						?>       
                     </div>                
                  </div><!-- End Row 1 -->
                  <div class="controls-row">
                  	<div class="span2"><?php echo $this->lang->line('telephone') ?></div>
                   	<div class="span4">
						<?php
							$data = array(
									'name'=>'noTel',
									'id'=>'noTel',								
									'class'=>'span12',); 
							echo form_input($data, set_value('noTel')); ?>                       
                  	</div>                            
                  	<div class="span2 tar"><?php echo $this->lang->line('fax') ?></div>
                   	<div class="span4">
						<?php
							$data = array(
									'name'=>'noFax',
									'id'=>'noFax',								
									'class'=>'span12',); 
							echo form_input($data, set_value('noFax')); ?>                       
                  	</div>                            
                  </div>    
                  <div class="controls-row">
                  	<div class="span2"><?php echo $this->lang->line('email') ?></div>
                   	<div class="span10">
						<?php
							$data = array(
									'name'=>'email',
									'id'=>'email',								
									'class'=>'span5',); 
							echo form_input($data, set_value('email')); ?>                       
                  	</div>                            
                  </div>    
                  <div class="controls-row">
                  	<div class="span2"><?php echo $this->lang->line('website') ?></div>
                   	<div class="span10">
						<?php
							$data = array(
									'name'=>'website',
									'id'=>'website',								
									'class'=>'span8',); 
							echo form_input($data, set_value('website')); ?>                       
                  	</div>                            
                  </div>    
            	  <div class="footer">
            		<div class="side fr">
                		<div class="btn-group">
                        <?php 
							$data = array(
									'name'=>'validat', 
									'class'=>'btn',
									'onClick'=>"$('#validate').validationEngine('hide');"); 
							echo form_button($data,'Hide prompts');
							$data = array(
									'name'=>'mysubmit', 
									'class'=>'btn btn-primary');
							$js='onclick="return confirm(\''.$this->lang->line('message3').'\')"';
							echo form_submit($data,'Submit',$js);
							?>
                    	</div>
                		</div>
            		</div>                                    
				</div>  <!-- content -->
    </form>
		</div>  <!-- block -->
		</div>  <!-- span12 -->
	</div>  <!-- row-fluid -->
</div>  <!-- content -->
</div>  <!-- wrap -->
</div>  <!-- content -->
