function LoadPageData(lngRecordToTry,lngTotalRecord,lngCurrentPage,lngPageCount){
	var intValue;			
	if (objFrames.IsFrameLoaded(COMMANDBAR_FRAME_ID) && objFrames.IsFrameLoaded(TABS_FRAME_ID)){	
		objControls.initialize(lngCurrentPage,lngPageCount,lngTotalRecord);
				
		var objPageCaption=Tabs.document.getElementById("PageCaption");

		if (objPageCaption){
			var strPC=objControls.getPageCaption();
			objPageCaption.innerHTML=strPC;
		}				
				
		if (objStatus.GetUseCachedStatus()){
			objStatus.resetToCachedStatus();
		}

		objControlsUi.refreshControlsState();
	}else{
		var timeout=setTimeout("LoadPageData("+lngRecordToTry+","+lngTotalRecord+","+lngCurrentPage+","+lngPageCount+")",500);
	}	
}

function onClickControls(strAction, lngRecordID, fnAfterCall, blnNotModal)
{	
	if (!objControlsUi.isControlDisabled(objControlsUi.getControlId(strAction)) || strAction=="View" || (strAction=="Submit" && mblnIsSurveyView) || (strAction=="DeleteIssue" && lngRecordID)){
	
		if (strAction=="Save" || strAction=="Apply" || strAction=="Cancel" || strAction=="AddNew" || 
				strAction=="Submit" || strAction=="Copy" || strAction=="UpdateSLA" || strAction=="DeleteIssue" || strAction=="CopyParChd" || strAction=="AddChildIssueRec"){
			return onClickControlsServerSide(strAction, lngRecordID, fnAfterCall, blnNotModal);
		}else{
			if (strAction=="Add" || strAction=="RemoveT" || 
					strAction=="Refresh" || strAction=="Properties" || 
					strAction=="Details" || strAction=="GetLatest" ||
					strAction=="CheckIn" || strAction=="CheckOut" ||
					strAction=="Other"){
				onClickControlsScc(strAction);
			}else{
				onClickControlsClientSide(strAction);
			}
		}
	}
}

function onClickControlsScc(strAction){
	switch (strAction){
		case "Add":			objScc.getObject("MqSccFiles").add();break;
		case "RemoveT":		objScc.getObject("MqSccFiles").remove();break;
		case "Refresh":		objScc.getObject("MqSccFiles").refresh();break;
		case "Properties":	objScc.getObject("MqSccFiles").properties();break;
		case "Details":		objScc.getObject("MqSccFiles").details();break;
		case "GetLatest":	objScc.getObject("MqSccFiles").getLatest();break;
		case "CheckIn":		objScc.getObject("MqSccFiles").checkIn();break;
		case "CheckOut":	objScc.getObject("MqSccFiles").checkOut();break;
		case "Other":		break;
	}
}

function onClickControlsClientSide(strAction){
	if(strAction!="View" || (strAction=="View" && Number(objRecord.GetRecordId()))){	
		switch (strAction){
			case "MoveFirst":	objControls.MoveFirst();break;
			case "PageUp":		objControls.PageUp();break;
			case "MovePrevious":objControls.MovePrevious();break;
			case "MoveNext":	objControls.MoveNext();break;
			case "PageDown":	objControls.PageDown();break;
			case "MoveLast":	objControls.MoveLast();break;
			case "View":		objControls.View();break;
			case "Print":		objControls.Print(objRecord.GetRecordId());break;
		}
	}else{
		g_MqRef.MsgHlpr.DisplayMessage(MSG_ENTER_VALID_ISSUE_NUMBER);
	}
}


function onClickControlsServerSide(strAction, lngRecordID, fnAfterCall, blnNotModal)
{
	var strReturn="";
	if(!lngRecordID){
		lngRecordID = objRecord.GetRecordId();
	}
	var lngRevisionNumber = g_VWS.RecordMgr().CurrentRecord().GetRevisionNumber();
	var blnIsCompletelyIdle ;
	OnBeforeNavigate();		
	blnIsCompletelyIdle=IsCompletelyIdle();
	SetState(COMMANDBAR_FRAME_ID, BUSY_STATE );
	if (strAction=="Save"){ 
		if (LoadData.loaded){
			strReturn=objControlsSs.Save(lngRecordID,lngRevisionNumber,0,m_objLoadDataMgr);
		}
	}else{
		if (strAction=="Apply"){ 
			if (LoadData.loaded){
				strReturn=objControlsSs.Apply(lngRecordID,lngRevisionNumber,0,m_objLoadDataMgr);
			}
		}else{
			if (strAction=="Cancel" || strAction=="Delete"){
		
				if (lngRevisionNumber!=0 && strAction!="Delete"){
					//existing record
					objControlsSs.Cancel(lngRecordID, true, true, true);
				}else{
					// new record in edit mode
					objControlsSs.Cancel(lngRecordID, true, true, false);
				}
			}else{
				if (blnIsCompletelyIdle && strAction == 'AddNew') {
					strReturn=objControlsSs.AddNew();				
				}else{
					if (blnIsCompletelyIdle && strAction == 'Submit') {
						if (LoadData.loaded){
							strReturn=objControlsSs.Submit(m_objLoadDataMgr, fnAfterCall);
						}
					}else{
						if(strAction=="Copy"){
							if (LoadData.loaded){
								strReturn=objControlsSs.Copy(lngRecordID, true);
							}
						}else{
							if(strAction=="UpdateSLA"){
								if (LoadData.loaded){
									strReturn=objControlsSs.UpdateSLA(lngRecordID, true);
								}
							}else{
								if(strAction=="DeleteIssue"){
									if (LoadData.loaded){
										strReturn=objControlsSs.Delete(lngRecordID, blnNotModal);
									}
								}else{
									if(strAction=="CopyParChd"){
										if (LoadData.loaded){
											strReturn=objControlsSs.Copy(lngRecordID, true, true);
										}
									}else{
										if(strAction=="AddChildIssueRec"){
											strReturn=objControlsSs.AddChildIssueRecord(lngRecordID, true);
										}							
									}
								}
							}
						}
					}
				}	
			}
		}
	}
	SetState(COMMANDBAR_FRAME_ID, IDLE_STATE);
	SetIdleStatus();
	return strReturn;
}
