<link rel="stylesheet" href="<?php echo base_url('resources/css/bootstrap.min.css') ?>" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="<?php echo base_url('resources/css/AdminLTE.min.css') ?>">
<style type="text/css">
	#cssmenu .has-sub ul li:hover a,#cssmenu .has-sub ul li a{width: 105%}
	#message_box{position: fixed; bottom: 10px; }
	#loading{display: none}
	#div_delegasi{width: 100%; margin-top:-10px; min-height: 800px; border: none; overflow: scroll; }
</style>
<div id="message_box" class="alert" hidden>
	<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
		<div class="body_message"> </div>
		<div class="progress progress-sm active">
			<div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: 1%">
			</div>
		</div>
</div>
<?php print_r("session di sipp311 : "). print_r($this->session->all_userdata()) ?>
<br /><br /><br />
<script type="text/javascript">
	
	var is_connect="<?php echo $this->session->userdata('is_connect');?>";
	if (is_connect==0 || is_connect=="" ) {
	    var domain_delegasi="<?php echo base_url_delegasi()?>";
		var ip_sipp="<?php echo base_url()?>";
			$.ajax({
			     url:ip_sipp+"c_delegasi/send_identity",
			     dataType:'json',
			     success: function(json) {
			     		var iframe = document.getElementById('div_delegasi');
						iframe.src = iframe.src;
						setHeight();
			            $('#message_box').addClass('alert-info');
			            $('.body_message').empty();
			            $('.body_message').append('konek');
			            $('#message_box').fadeIn();
    		            showbusy();
			            setTimeout(function(){
						    $('#message_box').fadeOut();
						    $('.progress').hide();
						}, 5000);
						
						$.ajax({
						    type: "POST",
						    url: "<?php echo base_url();?>"+'c_delegasi/session_connect/1',
							}).done(function( msg ) {
							     concole.log('set session success');
							});
		         },
		         error: function() {
		         		var iframe = document.getElementById('div_delegasi');
						iframe.src = iframe.src;
						setHeight();
			            $('#message_box').fadeIn();
			            $('#message_box').addClass('alert-danger');
			            $('.body_message').empty();
			            $('.body_message').append('Tidak bisa konek ke server delegasi, coba refresh browser, atau cek koneksi internet anda, terima  kasih');
			            window.open('login','_self');
			            setTimeout(function(){
						    $('#message_box').fadeOut();
						}, 5000);
						$.ajax({
						     type: "POST",
						     url: "<?php echo base_url();?>"+'c_delegasi/session_connect/0',
							}).done(function( msg ) {
							     concole.log('set session failed');
						});
		         },
		         beforeSend: function(){
		         		showbusy();
		         		$('#message_box').addClass('alert-warning');
			            $('.body_message').empty();
			            $('.body_message').append('Koneksi ke server.........');
			            $('#message_box').fadeIn();
			            showbusy();
			            setTimeout(function(){
						    $('#message_box').fadeOut();
						     $('.progress').hide();
						}, 6000);
		         },
	     		 complete: function(){
	     		 		$('.progress').hide();
	     		 }
			});
	}else{
		var iframe = document.getElementById('div_delegasi');
		iframe.src = iframe.src;
		setHeight();
	}
	$('.alert .close').on('click', function(e) {
	    $(this).parent().fadeOut();
	});
	$(document).on('showalert', '.alert', function(){
	   $(this).css('bottom',$(this).top()-500); 
	}) 
	function showbusy(){
				$('.progress').show();
				var i = 0;
				setInterval(function () {
					$('.progress-bar').css('width', i+'%');
					if (i > 200){i=1};
					i+=10;
				},100);
				
	}		
	function setHeight() {
    	parent.document.getElementById('div_delegasi').style.height = document['body'].offsetHeight + 100 + 'px';
	}
</script>
<script src="<?php echo base_url('resources/js/bootstrap.min.js') ?>"></script>
<div id="content_iframe">
	<iframe id="div_delegasi" scrolling="yes" src="<?php echo base_url_delegasi()?>dashboard_delegasi"></iframe>
</div>