<?
    global $vis_language;
    if(!(isset($operation['vis_operation']) && $operation['vis_operation']=='vis_login_check')) include_once(VIS_PATH_TEMPLATE."header.php");?>
    <script language="javascript">
    var vis_modules_list=Array();<?
    $brand=(VIS_BRAND_FREE!='VALID')?(VIS_BRANDING_NAME):'';
    if(isset($modules)) for($i=0;$i<count($modules);$i++) {
        echo "vis_modules_list['".$modules[$i]['module']."']={'vis_module_name':'".$modules[$i]['module_name']."', 'vis_header_title':'".$modules[$i]['header_title'].$brand."', 'vis_tab_name':'vis_module_".$modules[$i]['module']."_div'};";
    }
	echo "vis_modules_list['chat']={'vis_module_name':'Chat', 'vis_header_title':'Chat".$brand."', 'vis_tab_name':'vis_module_chat_div'};";
	echo "vis_modules_list['remoteaccess']={'vis_module_name':'Remoteaccess', 'vis_header_title':'Remoteaccess".$brand."', 'vis_tab_name':'vis_module_remoteaccess_div'};";
	echo "vis_modules_list['voip']={'vis_module_name':'Voip', 'vis_header_title':'Voip".$brand."', 'vis_tab_name':'vis_module_twilio_div'};";
	echo "vis_modules_list['cmdb']={'vis_module_name':'CMDB', 'vis_header_title':'CMDB".$brand."', 'vis_tab_name':'vis_module_cmdb_div'};";
	echo "vis_modules_list['problem']={'vis_module_name':'Problem', 'vis_header_title':'Problem".$brand."', 'vis_tab_name':'vis_module_problem_div'};";
	echo "vis_modules_list['changes']={'vis_module_name':'Changes', 'vis_header_title':'Changes".$brand."', 'vis_tab_name':'vis_module_changes_div'};";
	echo "vis_modules_list['releases']={'vis_module_name':'Releases', 'vis_header_title':'Releases".$brand."', 'vis_tab_name':'vis_module_releases_div'};";
	if(IS_LOGIN==1) { ?>
	$(document).ready(function() {
		var hash=location.hash;
		$('section#vis_main_panel_div').visInterface({'portal_height':$(window).height(), 'portal_width':$(window).width(), 'direction':'<? echo VIS_LANGUAGE_DIRECTION; ?>'}, function() {
			$("#vis_main_panel_div").show();
			$('#vis_header_div').visExecution('load_area', {'vis_module':"home", 'vis_operation':'load_header'});
			if(hash.toLowerCase().indexOf("ticket")>0) $('#vis_left_panel_div').html('<div class="m-xl"><h3></h3></div>').visExecution('load_area', {'vis_module':"home", 'vis_operation':'load_left_panel', 'vis_load_tabs': false});
			if(hash.toLowerCase().indexOf("view_sentmail")>0) if($("#vis_left_panel_div").is(":visible"))$('#vis_left_panel_div').html('<div class="m-xl"><h3></h3></div>').visExecution('load_area', {'vis_module':"home", 'vis_operation':'load_left_panel', 'vis_load_tabs': false});
			function check_automation() {
                var hash=window.location.hash;
                var urldetails=hash.split('/');
                var filter_id='';
                if(urldetails[2]=='filter_queue_ticket') filter_id=urldetails[5]+'-'+urldetails[4];
                else if(urldetails[2]=='filter_ticket') filter_id=urldetails[4];
                else filter_id=1;
				$.ajax({
					url: 'index.php?vis_tmpst=new Date().getTime()',
					data: {'vis_module':'home', 'vis_operation': 'check_automation', 'vis_logout_msg':1, 'vis_module_name':urldetails[1], 'vis_function':urldetails[2], 'vis_filterid':filter_id},
					type: "POST",
					dataType: "html",
					success: function(data) {
						var user = '';
						user = getCookie("vis_staff_local");
						is_logout = getCookie("IS_LOGOUT");
						if(user == "" && is_logout != 1) {
							$("#vis_main_panel_div").html(data);
							$("#vis_login_msg_div strong").html('Same user logged in some other location').parent().addClass('alert-danger').show();
						} else {
							$("#vis_global_msg_div").html(data);
						}
					}
				});
			}
			function getCookie(cname) {
				var name = cname + "=";
				var ca = document.cookie.split(';');
				for(var i=0; i<ca.length; i++) {
					var c = ca[i];
					while (c.charAt(0)==' ') c = c.substring(1);
					if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
				}
				return "";
			}
   function sendmail_queue() {
				$.ajax({
					url: 'backend.php',
					data: {},
					type: "POST",
					success: function(data) {
						
					}
				});
			}
			<? if(isset($_COOKIE['vis_staff_local'])) { ?>setInterval(check_automation, 60000); <? } ?>
			
			if(hash.toLowerCase().indexOf("view_blabs") == 2) {
				$('#vis_right_panel_div').html('<div class="m-xl"><h3>Loading...</h3></div>').visExecution('load_area', {'vis_module':"home", 'vis_operation':'load_right_panel', 'vis_current_module':"blabber", 'vis_load_tabs': false});
			} else if(hash.toLowerCase().indexOf("quick_view") == 2) {
				$('#vis_right_panel_div').html('<div class="m-xl"><h3>Loading...</h3></div>').visExecution('load_area', {'vis_module':"home", 'vis_operation':'load_right_panel', 'vis_current_module':"home", 'vis_load_tabs': false});
			} else if(hash.toLowerCase().indexOf("view_tasks") == 2) {
			    $('#vis_right_panel_div').html('<div class="m-xl"><h3>Loading...</h3></div>').visExecution('load_area', {'vis_module':"home", 'vis_operation':'load_right_panel', 'vis_current_module':"task", 'vis_load_tabs': false});
			}
		});
		
		if(location.hash=="" || location.hash=="#") hash="#/home/quick_view";
		$("#vis_workpanel_div").visExecution('load_hash_action', hash);			
		$("#vis_workpanel_div").css('display', 'block');
		
		$("#vis_main_panel_div").bind('click', function(event){
			var clickid=$(event.target).attr('id');
			//alert(clickid);
			//backtosearch
			if($("#search_result").is(":visible")) {
				if($('#vis_global_searchbarn').val()==0 || (clickid!='ticketm' && clickid!='ticketm1' && clickid!='clientm' && clickid!='clientm1' && clickid!='solutionm' && clickid!='solutionm1' && clickid!='forumm' && clickid!='forumm1' && clickid!='organizationm' && clickid!='organizationm1' && clickid!='problemsm' && clickid!='problemsm1' && clickid!='releasem' && clickid!='releasem1' && clickid!='changem' && clickid!='changem1' && clickid!='backtosearch')){
				$("#search_result").html('');
				$("#vis_global_searchbar").val('').parent().removeClass('open');
				$("#vis_global_searchbar").parent().removeClass('searchbgli');
				$("#global_search").removeClass("global_search_focus");
				$("#vis_global_searchbar").removeClass('focusonsearch');
				}
			}
			
			if($('#search_report_result').is(":visible")){$('#search_report_result').hide(); }
			
		});
	});
	<?
	} ?>
	
	
	
var oldhash;
var hash=window.location.hash;
oldhash=hash;
$(window).bind('hashchange', function()
{
	var hash=window.location.hash;
	if(oldhash=='' || oldhash===undefined)
	{
	oldhash=hash;
	}
	var hasholdnew=oldhash;
	if(hash.toLowerCase().indexOf("ticket_details")>0)
	{
	oldhash=hash;
	}
	if(oldhash.toLowerCase().indexOf("ticket_details")>0 && hash.toLowerCase().indexOf("ticket_details")<=0){
//call your function
	oldhash=hash;
//--------------
 var urldetails1=hasholdnew.split('/');
 var ticket_id=urldetails1[4];
  
 if(ticket_id!='')
 {
	$('#vis_ticket_reply_'+ticket_id).visExecution('load_operations',{'vis_module':'ticket', 'vis_operation':'lock_onreplyticket', 'vis_action':'unlock', 'vis_ticket_id':ticket_id});
 }	
//alert(oldhash+'----'+hash+'--new');
}

}); 
	
	</script>
	<title><? echo $vis_language['TXTLOGIN']; ?></title>
	</head>
<body dir="<? echo VIS_LANGUAGE_DIRECTION; ?>">
<div id="vis_global_msg_div" class="alert alert-danger" style="display:none;"></div>
<section class="vbox" id="vis_main_panel_div"></section>
<iframe name="vis_hidden_frame" id="vis_hidden_frame" style="display: none;" src="#post_reply"></iframe>
<? if(!(isset($operation['vis_operation']) && $operation['vis_operation']=='vis_login_check')) include_once(VIS_PATH_TEMPLATE."footer.php"); ?>