<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<title></title>
		<!--MqRelPath--><link rel="stylesheet" type="text/css" href="../../theme/css/censusmain.css"/><!--/MqRelPath--><!--MqAbsPath><link rel="stylesheet" type="text/css" href="<BASE_VD>/theme/css/censusmain.css"/></MqAbsPath-->
		<!--MqRelPath--><script type="text/javascript" src="../../js/mqsysutils.js"></script><!--/MqRelPath--><!--MqAbsPath><script type="text/javascript" src="<BASE_VD>/js/mqsysutils.js"></script></MqAbsPath-->
		<!--MqRelPath--><script type="text/javascript" src="../../js/keylistener.js"></script><!--/MqRelPath--><!--MqAbsPath><script type="text/javascript" src="<BASE_VD>/js/keylistener.js" ></script></MqAbsPath-->
		<!--MqRelPath--><script type="text/javascript" src="../../js/jquery/jquery-1.7.1.js"></script><!--/MqRelPath--><!--MqAbsPath><script type="text/javascript" src="<BASE_VD>/js/jquery/jquery-1.7.1.js"></script></MqAbsPath-->
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
		<style>
			#ActiveFilterContainer {
				position:absolute;
				top:0;
				cursor:default;
				padding:2px 10px;
				height:26px;
				overflow:hidden;
			}
			.active-filter {
				cursor:default;
				display:inline-block;
				height:20px;
				line-height:20px;
				font-family:Tahoma, sans-serif;
				text-decoration:none;
				font-weight:400;
				font-size:12px;
				padding:3px 1px 3px 5px;
				color:#333;
				border:1px solid rgba(0,0,0,0);
				transition:border-color 0.5s ease;
			}

			.active-filter:hover, .active-filter:active {
				border:1px solid #ccc;
			}

			.active-filter span, .remove-active-filter-button {
				display:inline-block;
			}

			.active-filter-operator {
				color:#3498db;
			}

			.remove-active-filter-button {
				border:1px solid rgba(0,0,0,0);
				border-radius:2px;
				display:inline-block;
				width:10px;
				color:#ccc;
				text-decoration:none;
				font-size:11px;
				font-weight:200;
				padding:2px 2px 2px 3px;
				margin-left:1px;
				margin-right:2px;
				transition:color 0.5s ease;
				position:relative;
				top:-1px;
				transition:background-color 0.5s ease, border-color 0.5s ease, color 0.5s ease;
			}
			
			.active-filter:hover > .remove-active-filter-button, .active-filter:active > .remove-active-filter-button {
				color:#dd3333;
				border:1px solid #BDBECE;
				background-color:#F9FAFD;
			}

			/*This rule must be more specific than ".remove-active-filter-button:hover" to avoid needing !important*/
			.active-filter:hover > .remove-active-filter-button:hover, .active-filter:hover > .remove-active-filter-button:active {
				background-color:#FDF5CE;
				border:1px solid #FBCB09;
				transition:all 0s;
			}

		</style>
		<script type="text/javascript">
			var objMqStr = new MqString();
			var m_objMainRef = parent;

			function Form_OnLoad()
			{
				document.body.className=parent.CSS_TOOLBARB_BODY;
				updateFilters();
			}

			function removefilter(strID) {
				$("#active-"+strID).remove();
				var arrFilters = JSON.parse(m_objMainRef.m_objSLInput.GetAdhocFilters());
				//Remove filter from m_objMainRef.filters
				$.each(arrFilters, function(i, el){
					if (this.ID == strID){
						arrFilters.splice(i, 1);
					}
				});
				m_objMainRef.m_objSLInput.SetAdhocFilters(JSON.stringify(arrFilters));
				refreshSL();
			}

			function updateFilters(blnForceReloadSL) {
				var strPrevFilters=$("#ActiveFilterContainer").text();
				$("#ActiveFilterContainer").empty();
				var strFilters=m_objMainRef.m_objSLInput.GetAdhocFilters();
				if(strFilters) {
					var arrFilters = JSON.parse(strFilters);
					if(arrFilters && arrFilters.length > 0) {
						arrFilters.forEach(addFilter);
						refreshSL();
					}else{
						if(strPrevFilters!=""){
							refreshSL();
						}else{
							if(blnForceReloadSL){
								refreshSL();
							}
						}
					}
				}
			}

			function addFilter(objFilter) {
				var strFilterHTML = '<div class="active-filter" id="active-'+objFilter.ID+'">' +
					'<span>'+objMqStr.MqHtmlEncode(objFilter.fieldText)+'</span> '+
					'<span class="active-filter-operator">'+objMqStr.MqHtmlEncode(objFilter.operatorText.toUpperCase())+'</span> '+
					'<span>'+objMqStr.MqHtmlEncode(objFilter.value)+'</span> '+
					'<a class="remove-active-filter-button" title="Remove filter" href="#" onclick="removefilter(\''+objFilter.ID+'\')">'+
						'<i class="fa fa-times"></i>'+
					'</a>'+
				'</div>';
				$("#ActiveFilterContainer").append(strFilterHTML);
			}
			
			function refreshSL() {
				m_objMainRef.InitSLInputInfo(true, false); 
				m_objMainRef.m_objSLMgr.ApplySearchToSL(false, false, m_objMainRef.m_objSLInput);
				var strFilters=m_objMainRef.m_objSLInput.GetAdhocFilters();
				var lngToolbarHeight=0;
				if(strFilters) {
					var arrFilters = JSON.parse(strFilters);
					if(arrFilters.length > 0) {
						lngToolbarHeight=30;
					}
				}
				m_objMainRef.DEFAULT_TOOLBARB=lngToolbarHeight;
				parent.SetFrameHeights();
			}
		</script>
	</head>
	<body  onload="Form_OnLoad();loaded=true;initialized=true;" 
		topmargin="0" bottommargin="0" class="ToolbarBBody">
		<div class="ToolbarB1Div">
			<div id="ActiveFilterContainer">
				
			</div>
		</div>
	</body>
</html>
