<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title><WC@TITLE></WC@TITLE></title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />


	<!--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--><link rel="stylesheet" type="text/css" href="../../theme/css/mqshared.css"/><!--/MqRelPath--><!--MqAbsPath><link rel="stylesheet" type="text/css" href="<BASE_VD>/theme/css/mqshared.css"/></MqAbsPath-->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
  
	<!--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/frameconstants.js"></script><!--/MqRelPath--><!--MqAbsPath><script type="text/javascript" src="<BASE_VD>/js/frameconstants.js"></script></MqAbsPath-->
	<!--MqRelPath--><script type="text/javascript" src="../../js/tmpltoolbar.js"></script><!--/MqRelPath--><!--MqAbsPath><script type="text/javascript" src="<BASE_VD>/js/tmpltoolbar.js"></script></MqAbsPath-->
	<!--MqRelPath--><script type="text/javascript" src="../../js/cmqsysmsg.js"></script><!--/MqRelPath--><!--MqAbsPath><script type="text/javascript" src="<BASE_VD>/js/cmqsysmsg.js"></script></MqAbsPath-->
	<!--MqRelPath--><script type="text/javascript" src="../../js/mqlist.js"></script><!--/MqRelPath--><!--MqAbsPath><script type="text/javascript" src="<BASE_VD>/js/mqlist.js"></script></MqAbsPath-->
	<!--MqRelPath--><script type="text/javascript" src="../js/constants.js"></script><!--/MqRelPath--><!--MqAbsPath><script type="text/javascript" src="<BASE_VD>/<VIEW_FOLDER>/js/constants.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-->
	<script type="text/javascript">
		var objSysMsg = new CMqSysMsg;
		var m_objMqButton = new MqButton();
		var m_objRef = parent;
		
		var COOKIE_NAME_SQE="MetaquestCensusWebSQE";
		
		var m_strQueryName="<WC@QUERYNAME></WC@QUERYNAME>";
		
		var mlngLastQuerySelected="";
		
		var m_arrRecentQueries=new Array(4);
		
		var m_dtSearchPress;
		var m_strLastSearch;
		
		function OnLoadToolbar()
		{	
			WriteRecentQueriesPanel();
			var objQueryName=document.getElementById("QueryName");
			if(objQueryName){
				objQueryName.value=m_strQueryName;
				objQueryName.title=m_strQueryName;
			}
			
			var objSearchBox=document.getElementById("txtfieldvalue");
			
			if(objSearchBox){
				objSearchBox.value=parent.SEARCH_MSG;
			}
		}
		
		function OnEnterSearch()
		{
			var objSearchBox=document.getElementById("txtfieldvalue");
			
			if(objSearchBox){
				if(objSearchBox.value==parent.SEARCH_MSG){
					objSearchBox.value="";
					objSearchBox.className="Search";
				}	
			}
		}
		
		function OnLeaveSearch()
		{
			var objSearchBox=document.getElementById("txtfieldvalue");
			
			if(objSearchBox){
				if(objSearchBox.value==""){
					objSearchBox.value=parent.SEARCH_MSG;
					objSearchBox.className="preSearch";
				}	
			}
		}
		
		function OnSearchKeyPress()
		{
			var objSearchBox=document.getElementById("txtfieldvalue");
			
			if(objSearchBox){
				var strValue=objSearchBox.value;
				
				if(strValue!= parent.SEARCH_MSG){
					if(strValue!=m_strLastSearch){
						m_strLastSearch=strValue;
						m_dtSearchPress=new Date();
						window.setTimeout("CallKeyPressSearch()", 1000);
					}
				}
			}
		}
		
		function CallKeyPressSearch()
		{
				
			if(m_dtSearchPress){
				var dtCurrent=new Date();
				if((dtCurrent.getTime()-m_dtSearchPress.getTime())>900){
					parent.InitSLInputInfo(false, false, true);
					
					parent.m_objSLMgr.ApplySearchToSL(false, false, parent.m_objSLInput, true);
				}
			}
		}
		
		function WriteRecentQueriesPanel()
		{
			var strHTML="";
			var strClass="";
			var lngCount=0;
			var strOnClick='onclick="HandleQueryList()"';

			var objQueryList=document.getElementById("cboQueries");
			
			if(objQueryList){
				if(objQueryList.options.length<=1){
					strOnClick='';
					
					var objMoreQueriesBtn=document.getElementById("ShowMoreQueries");
					if(objMoreQueriesBtn){
						objMoreQueriesBtn.style.visibility="hidden";
					}
				}
				for(x=0; x<objQueryList.options.length; x++){
					if(objQueryList.options[x]){
						
						if(objQueryList.options[x].selected){
							strClass="filterButtonSelected";
							mlngLastQuerySelected=objQueryList.options[x].value;				
							
							strHTML='<td class="' + strClass + '" id="qry' + objQueryList.options[x].value + '" ' + strOnClick + '>' + 
										objQueryList.options[x].text + '</td>';
						
							m_arrRecentQueries[lngCount]=objQueryList.options[x].value;
							
							lngCount++;
									
							break;
						}
					}
				}
			}
			
			var objRecentQueries=document.getElementById("RecentQueries");
			
			if(objRecentQueries){
				objRecentQueries.innerHTML="<table cellspacing='0'><tr>" + strHTML + "</tr></table>";
			}
		}
		
		function WriteRemainingQueriesList()
		{
			var strHTML="";
			var objQueryList=document.getElementById("cboQueries");
			
			if(objQueryList){
				for(x=0; x<objQueryList.options.length; x++){
					if(objQueryList.options[x]){
											
						if(!g_MqRef.MqArr.IsValueInArray(objQueryList.options[x].value, m_arrRecentQueries)){
							var lngDefSortAttr=objQueryList.options[x].getAttribute("MqDefSort");
							var lngDefLytAttr=objQueryList.options[x].getAttribute("MqDefLyt");
							strHTML+='<tr><td class="queryMenuItem" onmouseover="this.className=\'queryMenuItem queryMenuItemHover\'" onmouseout="this.className=\'queryMenuItem\'" onclick="objFrames.GetFrameWindow(TOOLBAR_FRAME_ID).RunQueryFromList(\'' + 
									objQueryList.options[x].value + '\', ' + lngDefSortAttr + ',' + lngDefLytAttr + ')">' + objQueryList.options[x].text + '</td></tr>';
						}
					}
				}
			}
					
			var objQryList=parent.document.getElementById("qryList");
			
			if(objQryList){
				objQryList.innerHTML='<table width="100%" marginwidth="0" cellpadding="0" cellspacing="0">' + strHTML + "</table>";
			}
		}
		
		function RunQueryFromList(lngQueryID, lngSortID, lngLayoutID)
		{
			var objQueryList=document.getElementById("cboQueries");
			
			if(objQueryList){
				for(x=0; x<objQueryList.options.length; x++){
					if(objQueryList.options[x].value==lngQueryID){
						objQueryList.options[x].selected=true;
					}
				}
			}
			
			if(lngSortID){
				var objSortList=document.getElementById("cbosort");
				
				if(objSortList){
					for(x=0; x<objSortList.options.length; x++){
						if(objSortList.options[x].value==lngSortID){
							objSortList.options[x].selected=true;
							objSortList.value=lngSortID;
							break;
						}
					}
				}
			}
			
			if(lngLayoutID){
				var objLayoutList=document.getElementById("cbolayout");
				
				if(objLayoutList){
					for(x=0; x<objLayoutList.options.length; x++){
						if(objLayoutList.options[x].value==lngLayoutID){
							objLayoutList.options[x].selected=true;
							objLayoutList.value=lngLayoutID;
							break;
						}
					}
				}
			}
			
			LoadOneQuery(lngQueryID);
			
			WriteRecentQueriesPanel();
			
			DoHandleQueryList(false);
		}
		
		function RefreshCurrentQuery()
		{
			if(parent){
				if(parent.m_objSLDD){
					parent.m_objSLDD.ResetDD();
				}
			}
			submitinfo(null,true);
		}
		
		function LoadOneQuery(lngSelectedQueryID)
		{
			if(lngSelectedQueryID!=mlngLastQuerySelected){
				if(lngSelectedQueryID){
					var objTxt=document.getElementById("txtquery");
					if(objTxt){
						objTxt.value=lngSelectedQueryID;
						
						objTxt=document.getElementById("txtquerytype");
						if(objTxt){
							objTxt.value=6;
						}
						if(parent){
							if(parent.m_objSLDD){
								if(parent.mstrCurrentViewFolder=="Resources%5FLibrary" || parent.mstrCurrentViewFolder=="Resources%5FSWAssets"){
									if(lngSelectedQueryID==10){
										parent.m_objSLDD.EnableDD();
									}else{
										parent.m_objSLDD.DisableDD();
									}
								}else{
									if(parent.mstrCurrentViewFolder=="Resources%5FManage" || parent.mstrCurrentViewFolder=="Resources%5FSWAssetTypes"){
										if(lngSelectedQueryID==1){
											parent.m_objSLDD.EnableDD();
										}else{
											parent.m_objSLDD.DisableDD();
										}
									}else{
										submitinfo(null, true);
									}
								}
							}else{
								submitinfo(null, true);
							}
						}else{
							submitinfo(null, true);
						}
						
						var objQryButton=document.getElementById("qry" + lngSelectedQueryID);
						
						if(objQryButton){
							objQryButton.className=objQryButton.className.replace("filterButtonUnSelected", "filterButtonSelected");
						
							if(mlngLastQuerySelected!=""){
								objQryButton=document.getElementById("qry" + mlngLastQuerySelected);
								if(objQryButton){
									objQryButton.className=objQryButton.className.replace("filterButtonSelected", "filterButtonUnSelected");
								}
							}
							mlngLastQuerySelected = lngSelectedQueryID;
						}
					}
				}
			}
		}
		
		function HandleQueryList()
	    {
			var objQryLst=parent.document.getElementById("qryList");
			if(objQryLst){
				DoHandleQueryList(!objQryLst.style.display=="");
			}					
	    }
	    
	    function DoHandleQueryList(blnShow)
	    {
			if(blnShow){
				WriteRemainingQueriesList();
			}
					
			var objQryLst=parent.document.getElementById("qryList");
			var objQryLstFrame=parent.document.getElementById("qryListFrame");
			var objQryListTop=parent.document.getElementById("qryListTop");
			
			if(objQryLst && objQryLstFrame && objQryListTop){
				if(blnShow){
					objQryLst.style.display="";
					objQryLstFrame.style.display="";
					objQryListTop.style.display="";
				}else{
					objQryLst.style.display="none";
					objQryLstFrame.style.display="none";
					objQryListTop.style.display="none";
				}
			}
	    }
		
		function ShowAdvancedOptions()
		{
			parent.OpenModalWindow("tmplAdvQry.htm", 860, 485, false);
		}
		
		function OpenExportWindow() 
		{
			var intWinOffset = 80; //Vertical offset to account for browser title bar, URL, etc
			var intWinHeight = 385; //Height of the export window
			var intWinWidth = 350; //Width of the export window
			var intWinTop = ((screen.height - intWinHeight) / 2) - intWinOffset ; //Center the window vertically
			var intWinLeft = (screen.width - intWinWidth) / 2; //Center the window horizontally

			window.open('VNExport.htm', 'newwindow', 'toolbar=no,directories=no,resizable=yes,width=' + intWinWidth + ',height=' + intWinHeight + 
			            ',top=' + intWinTop + ',left=' + intWinLeft);
		}
	</script>
</head>
<body  onload="OnLoadToolbar();loaded=true;initialized=true;"
	topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#ffffff">
	<select id="cboQueries" style="display:none">
		<WC@QUERY>QueryList</WC@QUERY>
	</select>
	<select name="cbosort" id="cbosort" style="display:none">
		<WC@SORTS>Sorts</WC@SORTS>
	</select>
	<select name="cbolayout" id="cbolayout" style="display:none">
		<WC@LAYOUT>Layouts</WC@LAYOUT>
	</select>
	
	<form name="CmdToolBar" action="#" style="display: none">	
	<input type='hidden' name='txtquery' id='txtquery' value="<WC@QUERYID></WC@QUERYID>" >
	<input type='hidden' name='txtquerytype' id='txtquerytype' value="<WC@QUERYTYPE></WC@QUERYTYPE>" >
	</form>
	
	<div class="toolbarBorder">
		<!--[if IE 7]>
		<div class="toolbar">
			<table style="padding-top:3px;" align="left" width="100%" border="0" cellpadding="0" cellspacing="0">
				<tr>
					<td id="ShowMoreQueries" style="padding-left:15px;width:20px; text-align:right;cursor:hand;cursor:pointer" class="filterButtonUnSelected filterButtonStart" onclick="HandleQueryList()" title="Show More..." /><img src="../../theme/images/buttons/showquery.png" /></td>
					<td id="RecentQueries" name="RecentQueries"></td>
					<td valign="middle" align="left">
						<input type="text" id="txtfieldvalue" name="txtfieldvalue" accesskey="s" class="preSearch" onkeyup="OnSearchKeyPress()" onfocus="OnEnterSearch()" onblur="OnLeaveSearch()" value="" />
					</td>
					<td width="200">				
						&#160;
					</td>
				</tr>
			</table>
		</div>
		<![endif]-->
		
		<!--[if (gte IE 8)|!(IE)]><!-->
		<div class="toolbar">
			<table style="padding-top:3px;padding-left:15px;padding-right:10px;" align="left" width="100%" border="0" cellpadding="0" cellspacing="0">
				<tr>
					<td id="ShowMoreQueries" style="width:20px; height:20px; text-align:right;cursor:hand;cursor:pointer" class="filterButtonSelected" onclick="HandleQueryList()" title="" /><img src="../../theme/images/buttons/showquery.png" /></td>
					<td id="RecentQueries" name="RecentQueries" class="filterButtonSelected"></td>
					<td id="RefreshSL" class='refreshSLButton' onclick='RefreshCurrentQuery();'><i style='font-size:22px;' class='fa fa-refresh'></i></td>
					<td class='advSearchButton' onclick='ShowAdvancedOptions()' id="slBtnAdvanced"><i style='font-size:22px; color:#666666;' class='fa fa-cog'></i></td>
					<td class='exportButton' onclick="OpenExportWindow()" id="slBtnExport"><i style='font-size:22px; color:#666666;' class='fa fa-download'></i></td>
					<td valign="middle" align="right" style="padding-right:4px" width="70%">
						<input type="text" id="txtfieldvalue" name="txtfieldvalue" accesskey="s" class="preSearch" onkeyup="OnSearchKeyPress()" onfocus="OnEnterSearch()" onblur="OnLeaveSearch()" value="" />
					</td>
				</tr>
			</table>
		</div>
		
		<script type="text/javascript">
			//set the tooltips
			m_objMqButton.SetTooltip("ShowMoreQueries", "SL.TT.SHOW_QUERY");
			m_objMqButton.SetTooltip("RefreshSL", "SL.TT.REFRESH");
			m_objMqButton.SetTooltip("slBtnAdvanced", "SL.TT.MODIFY");
			m_objMqButton.SetTooltip("slBtnExport", "SL.TT.EXPORT");
		</script>
		<!--<![endif]-->
	</div>
	</div>
	<script type="text/javascript">
		<WC@JSCODE></WC@JSCODE>
		// Called by the JSCODE
		function reloadSummaryList(){
		    if (parent){
		        if (parent.objFrames){
			        var winSL=parent.objFrames.GetFrameWindow(parent.SUMMARY_LIST_FRAME_ID);
			
			        if (winSL){
			            winSL.location.replace("SummaryList.ASP?WCI=SummaryListTmpl&ATO=1");
			        }else{
			            setTimeout("reloadSummaryList()",50);
			        }
                }
            }			
		}
		
		function loadDefaultValue(){
			var objTBar=parent.objFrames.GetFrameWindow(parent.TOOLBAR_FRAME_ID);
					
			if (objTBar){			
				var objCmdTlbrDoc=objTBar.document.CmdToolBar;
				objCmdTlbrDoc.QueryName.value="";
				objCmdTlbrDoc.txtquery.value=-1;
				objCmdTlbrDoc.txtquerytype.value=0;
			}
		}
		
		function initializeSQE(){
		
			var objSQE=parent.objFrames.GetFrameWindow(parent.SQE_FRAME_ID);
			if (objSQE){

				var frmsql = objSQE.document.SQE;
				var coll;
				
				if (frmsql) {
					
					var coll = frmsql.cbofield;
					
					if (coll) {
						coll.selectedIndex = -1;
						frmsql.cboretain.selectedIndex = 0;
					}
					
					coll = frmsql.cbotest;
					
					if (coll){
					   coll.selectedIndex = -1;
					}

					coll = frmsql.fieldvalue;
				   
					if (coll) {

						if (coll.options){
							coll.selectedIndex = -1;
						}else{
							coll.value='';
						}
					}
					
					coll = frmsql.txtfieldvalue;
				   
					if (coll) {
						coll.value='';
					}
				}
			}
		}

		parent.SetState(TOOLBAR_FRAME_ID,parent.IDLE_STATE);

		var strViewCookieName="<WC@COOKIENAME></WC@COOKIENAME>";
		var strViewCookieValue="<WC@COOKIEINFO></WC@COOKIEINFO>";			
		
	</script>
</body>
</html>

