var NUM_COLS=4;

var m_arrQuickLinks = new Array(
								//<!--MqAvailableViews-->
								);

function WriteQuickLinksMenu(lngCurrentViewID, strValidViewIDs, strViewTitle)
{
	var strHTML='';
	var lngNumOnRow=0;
	var strCurrentViewTitle="";
	
	for(x=0; x<m_arrQuickLinks.length; x++){
		if(lngCurrentViewID==m_arrQuickLinks[x][0]){
			strCurrentViewTitle=m_arrQuickLinks[x][1];
		}
	}
	
	if(strCurrentViewTitle==""){
		strCurrentViewTitle=strViewTitle;
	}
	
	strHTML+='<div id="dvQuickLinksBtn" name="dvQuickLinksBtn" class="QuickLinks" ' +
				'onclick="ClickQuickLinks()" title="' + g_MqRef.RESX['QUICKLINKS_OPEN_TOOLTIP'] +'">' +
				'<table width="100%" border="0" height="100%">' +
				'<tr>' +
				'<td style="padding-top:0px; width="50" width:50px" valign="top">' +
				m_objMqButton.GetButtonHTML("QuickLinksMenuButton","","QuickLinksMenuButton",false,m_objMqButton.STATE_1,g_MqRef.RESX["QUICKLINKS_OPEN_TOOLTIP"]) + 
				'</td>' +		
				'<td valign="top" class="ViewTitle">' +	
				strCurrentViewTitle + 
				'</td></tr></table></div>';
	
	strHTML+='<div id="QuickLinksTop" name="QuickLinksTop" class="QuickLinksPopupTop" style="display:none"><img src="../../theme/images/images/menutoplight.png" /></div>' + 
				'<div id="dvQuickLinks" name="dvQuickLinks" class="QuickLinksPopup" style="display:none"' +
				'onclick="ClickQuickLinks()">' +
				'<table width="100%" border="0" height="100%">' +
				'<tr><td valign="top" style="padding-top:20px">' +			
				'<table width="100%">' +
				'<tr>' +
				'<td class="QuickLinksHeader" colspan="3">' +
				g_MqRef.RESX['QUICKLINKS_TITLE'] +
				'</td>' +
				'<td><div class="DlgCloseBtn" ><i class="fa fa-close"></i></div></td>' +
				'</tr>';
	
	for(x=0; x<m_arrQuickLinks.length; x++){
		
		if(UserHasAccessToView(m_arrQuickLinks[x][6], strValidViewIDs)){
			if(lngNumOnRow==0){
				strHTML+='<tr>';
			}
		
			strHTML+=	'<td width="205">';
		
			if(lngCurrentViewID==m_arrQuickLinks[x][0]){
				strHTML+='<div class="QuickLinksButtonSelected">';							
			}else{
				strHTML+='<div class="QuickLinksButton" onmouseover="this.className=\'QuickLinksButton QuickLinksButtonHover\'" onmouseout="this.className=\'QuickLinksButton\'" onclick="LoadView_2(\'' + m_arrQuickLinks[x][4] + '\', \'' + m_arrQuickLinks[x][5] + '\')">';
			}

			strHTML+=	'	<table>' +
						'		<tr>' +
						'			<td class="QuickLinksButtonImg" style="width:80px;text-align:center"><img src="' + m_arrQuickLinks[x][3] + '" style="width:42px;height:42px;" /></td>' +
						'			<td class="QuickLinksButton">' +
						'				<div class="QuickLinksTitle">' + m_arrQuickLinks[x][1] + '</div>' +
						'				<div class="QuickLinksDetails">' + m_arrQuickLinks[x][2] + '</div>' +
						'			</td>' +
						'		</tr>' +
						'	</table>' +
						'</div>' +
						'</td>';
			lngNumOnRow++;
		
			if(lngNumOnRow==NUM_COLS){
				strHTML+='</tr>';
				lngNumOnRow=0;
			}
		}
	}
	strHTML+='</tr>' +
				'</table>' +	
				'</td>' +
				'</tr>' +	
				'</table>' +	
				'</div>';
	document.write(strHTML);
}

function UserHasAccessToView(lngViewID, strValidViewIDs)
{
	var blnReturn=true;
	
	if(strValidViewIDs){
		var arrValidViews=strValidViewIDs.split(";");
		
		if(!g_MqRef.MqArr.IsValueInArray(lngViewID, arrValidViews)){
			blnReturn=false;
		}
	}
	
	return blnReturn;
}

function ClickQuickLinks()
{
	var objQuickLinks=document.getElementById("dvQuickLinks");
	if(objQuickLinks){
		if(!IsExpanded(objQuickLinks)){
			toggleQuickLinks(true);
		}else{
			toggleQuickLinks(false);
		}
	}
}
	    
function IsExpanded(objQuickLinks)
{
	return (objQuickLinks.style.display == "");
}

function toggleQuickLinks(blnExpand)
{
	var objQuickLinks=document.getElementById("dvQuickLinks");
	var objQLTop=document.getElementById("QuickLinksTop");
	if(objQuickLinks){
		if(blnExpand){
			if(!IsExpanded(objQuickLinks)){
				objQuickLinks.style.display="";
				if(objQLTop){
					objQLTop.style.display="";
				}
			}
		}else{
			objQuickLinks.style.display="none";
			if(objQLTop){
				objQLTop.style.display="none";
			}
		}
	}
}

function HideQuickLinksMenu()
{
	var objQLBtn=document.getElementById("dvQuickLinksBtn");
	
	if(objQLBtn){
		objQLBtn.style.display="none";
	}
}

function LoadView_2(strProjectName, strViewName)
{
	objControlsSs.SwitchToDiffView("View=" + g_MqRef.MqStr.MqEncodeURIComponent(strProjectName + "/" + strViewName));
}

function LoadView(strProjViewName)
{
	objControlsSs.SwitchToDiffView(strProjViewName);
}