<script type="text/javascript">
	$(document).ready(function(){
		$('select').select2();


		/*****Option image******/    
	    function format(state) {
	    	if(state.text != '<?php echo $this->lang->line('graphList'); ?>')
	    		return '<span class="oh" style="display:block"><span class="fl">'+state.text+'</span><img class="fr" src="<?php echo base_url() ?>images/graphs/'+$(state.element).data('image')+'" width="150px" /></span>';
	    	else
	    		return state.text;
	    }
	    $("#graphList").select2({
	        formatResult: format,
	        formatSelection: format,
	        escapeMarkup: function(m) { return m; }
	    });
	    /*****GST Register supplier's color change end******/
	    $.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();
		    });	
	    });
	    <?php if(isset($saveStatus)): ?>
	    	alertbox('Graph Saved Successfully',1);
	    <?php endif; ?>
	});		
</script>
<style type="text/css">
	.select2-container span img{
		display:none !important;
	}
</style>

<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='<?php echo base_url()."setting/companyList" ?>'><?php echo $this->lang->line('module') ?></a> <span class="divider">-</span></li>
                    <li class="active"><?php echo $this->lang->line('addNewGraph') ?></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
                $attrib = array('id' => 'validate');
					echo form_open_multipart('', $attrib);
				?>
					<!-- form id="validate" method="POST" action="javascript:alert('Form #validate submited');"-->
                    <div class="block">
						<div class="head">
							<h2><?php echo $this->lang->line('addNewGraph') ?></h2>
							<ul class="buttons">
								<li><a href="#" class="block_toggle"><span class="i-arrow-down-3"></span></a></li>
							</ul>
						</div>
                        <div class="content np">    
							<div class="controls-row">
								<div class="span2"><?php echo form_label($this->lang->line('graphList')); ?></div>
                                <div class="span4">
                                <select class="span12 validate[required]" id="graphList" name="graph_id"><option value="null"><?php echo $this->lang->line('graphList'); ?></option>
                                <?php
                                if (!empty($ref_graph)) {
									foreach ($ref_graph as $row) {
                                ?>
									<option value="<?php echo $row->id; ?>" data-image="<?php echo $row->screenShoot; ?>"> <?php echo $row->name; ?></option>
									<?php }
								} ?>
                                </select>
                                </div>
                            </div>                    
                            <div class="controls-row">
								<div class="span2"><?php echo form_label($this->lang->line('pageList')); ?></div>
								<div class="span4">
                                <?php
								$preseldept = '0';
								unset($options);
								$options[NULL] = $this->lang->line('pageList');
								if(isset($selPage) && !empty($selPage)){
									foreach($selPage as $row){
										$options[$row->fldid] = !empty($this->lang->line($row->parent))?$this->lang->line($row->parent)."->".$this->lang->line($row->name):$this->lang->line($row->name);
									}
								}
								$js = "id='companyID' class='span12'";
									echo form_dropdown('page_id', $options, $preseldept, $js);
								?>  
                                </div>
							</div>
                            <div class="controls-row">
								<div class="span2"><?php echo form_label($this->lang->line('order')); ?></div>
                                <div class="span4">
                                <?php
                                $data = array(
									'name' => 'order',
                                    'class' => 'span12 validate[required,maxSize[128]]',);
                                     echo form_input($data);
								?>
                                </div>
							</div>
						</div> <!--content np -->
						<div class="footer">
							<div class="side fr">
								<div class="btn-group">
									<input type="submit" name="submit" value="Submit" class="btn-form btn-success-form" onclick="return confirm('Press OK to continue...')">								
								</div>
							</div>
						</div>
					</div> <!--block -->
				</div> <!--span 12 -->
			</div> <!--row fluid -->
		</div>  <!--content class -->
	</div>  <!--wrap -->
</div> <!--content id -->