function AddListMenuItems(m, ctx)
{
    if (typeof(Custom_AddListMenuItems) != "undefined") 
    {
        if (Custom_AddListMenuItems(m, ctx))           
            return;
    }
    if (ctx.listBaseType == BASETYPE_DISCUSSION)
    {
        strDisplayText = L_Reply_Text;
        if(itemTable.Ordering.length>=504) 
        {
            var L_ReplyLimitMsg_Text="Cannot reply to this thread. The reply limit has been reached.";
            strAction="alert('" + L_ReplyLimitMsg_Text + "')";
        }
        else
        {
            strAction = "STSNavigate('" + ctx.newFormUrl 
            + "?Threading=" + escapeProperly(itemTable.Ordering)
            + "&Guid=" + escapeProperly(itemTable.ThreadID)
            + "&Subject=" + escapeProperly(itemTable.Subject)
            + "&Source=" + GetSource() + "')";
        }
        strImagePath = ctx.imagesPath + "reply.gif";
        CAMOpt(m, strDisplayText, strAction, strImagePath);
    }
    strDisplayText = L_ViewItem_Text;
    strAction = "STSNavigate('" + ctx.displayFormUrl+"?ID="+ currentItemID + "&Source=" +
                GetSource() + "')";
    strImagePath = "";
    CAMOpt(m, strDisplayText, strAction, strImagePath);
    strDisplayText = L_EditItem_Text;
    strAction = "STSNavigate('" + ctx.editFormUrl+"?ID="+ currentItemID + "&Source=" +
                GetSource() + "')";
    strImagePath = ctx.imagesPath + "edititem.gif";
    CAMOpt(m, strDisplayText, strAction, strImagePath);
    if (ctx.listTemplate == LISTTEMPLATE_EVENTS &&
        currentItemID.indexOf(".0.") > 0)
    {
        var SeriesIdEnd = currentItemID.indexOf(".0.");
        var itemSeriesID = currentItemID.substr(0, SeriesIdEnd);
        strDisplayText = L_EditSeriesItem_Text;
        strAction = "STSNavigate('" + ctx.editFormUrl+"?ID="+ itemSeriesID + "&Source=" +
                    GetSource() + "')";
        strImagePath = ctx.imagesPath + "recur.gif";
        CAMOpt(m, strDisplayText, strAction, strImagePath);
    }
    if (currentItemID.indexOf(".0.") < 0)
    {
		strDisplayText = L_DeleteItem_Text;
		strAction = "DeleteListItem()";
		strImagePath = ctx.imagesPath + "delitem.gif";
		CAMOpt(m, strDisplayText, strAction, strImagePath);
    }
    if (ctx.listTemplate == LISTTEMPLATE_CONTACTS)
    {
        strDisplayText = L_ExportContact_Text;
        strAction = "STSNavigate('" + ctx.HttpPath + "&Cmd=Display&CacheControl=1&List=" + ctx.listName + "&ID=" +  currentItemID + "&Using=" + escapeProperly(ctx.listUrlDir) + "/vcard.vcf" + "')";
        strImagePath = ctx.imagesPath + "exptitem.gif";
        CAMOpt(m, strDisplayText, strAction, strImagePath);
    }
}

function AddDocLibMenuItems(m, ctx)
{
    if (typeof(Custom_AddDocLibMenuItems) != "undefined") 
    {
        if (Custom_AddDocLibMenuItems(m, ctx))           
            return;
    }
    var RootFolder = GetRootFolder(ctx);
    setupMenuContext(ctx);
    if (currentItemFileUrl == null)
        currentItemFileUrl = itemTable.ServerUrl;
    if (currentItemFSObjType == null)
        currentItemFSObjType = itemTable.FSObjType;
    var currentItemEscapedFileUrl = escapeProperly(
        unescapeProperly(currentItemFileUrl));
    if (currentItemFSObjType != 1) 
    {
        strDisplayText = L_ViewProperties_Text;    
        strAction = "STSNavigate('" + ctx.displayFormUrl+"?ID="+ currentItemID + 
                    "&Source=" + GetSource() + RootFolder + "')";
        strImagePath = "";
        CAMOpt(m, strDisplayText, strAction, strImagePath);
    }
    strDisplayText = L_EditProperties_Text;    
    strAction = "STSNavigate('" + ctx.editFormUrl+"?ID="+ currentItemID + 
                "&Source=" + GetSource() + RootFolder + "')";
    strImagePath = ctx.imagesPath + "edititem.gif";
    CAMOpt(m, strDisplayText, strAction, strImagePath);
    if (currentItemFSObjType != 1) 
    {
        if (ctx.isWebEditorPreview == 0)
        {
            setDocType();
            if (currentItemAppName != "" && currentItemOpenControl != "")
            {
                strDisplayText = StBuildParam(L_EditIn_Text, currentItemAppName);
                strAction = "editDocumentWithProgID2('" + currentItemFileUrl + "', '" + currentItemProgId + "', '" + currentItemOpenControl + "')";
                strImagePath = ctx.imagesPath + currentItemIcon;
                
            }
        }
    }
    strDisplayText = L_DeleteDocItem_Text;
    strAction = "DeleteDocLibItem('" + 
            ctx.HttpPath + "&Cmd=Delete&List=" + ctx.listName + 
            "&ID=" + currentItemID + "&owsfileref=" +
            currentItemEscapedFileUrl + "&NextUsing=" + GetSource() + "')";
    strImagePath = ctx.imagesPath + "delitem.gif";
    CAMOpt(m, strDisplayText, strAction, strImagePath);
    if (currentItemFSObjType != 1 && ctx.listTemplate == LISTTEMPLATE_IMAGE_LIBRARY)
    {
        strAction = "DownloadOriginalImage(" + currentItemID + ")";
        strImagePath = ctx.imagesPath + "download.gif";
        strDisplayText = L_DownloadOriginal_Text;
        CAMOpt(m, strDisplayText, strAction, strImagePath);
    }
    if (currentItemFSObjType != 1) 
    {
        if (ctx.PortalUrl != null)
        {
            strDisplayText = L_AddToMyLinks_Text;
            strAction = "Portal_Tasks('PinToMyPage')"; ;
            strImagePath = "";
            
            strDisplayText = L_AddToCategory_Text;
            strAction = "Portal_Tasks('Categorize')"; ;
            strImagePath = "";
            
            CAMSep(m);
        }
    }
}

timerID = null;
var active = 0;

function ChangePage(num){
    	if(document.getElementById){
    		obj[active].style.visibility = "hidden";
    		active = num;
    		obj[active].style.top = 0;
    		obj[active].style.visibility = "visible";
    	}
}
    
function ScrollUp(speed){
    	if(document.getElementById){
    		if(parseInt(obj[active].style.top) < 0){
    			obj[active].style.top = parseInt(obj[active].style.top) + speed + "px";
		}
    		timerID = setTimeout("ScrollUp("+speed+")",30);
    	}
}

function ScrollDown(speed){
    	if(document.getElementById){                        
    		if(parseInt(obj[active].style.top) > document.getElementById('QLnkParent').offsetHeight - obj[active].offsetHeight){ 
    			obj[active].style.top = parseInt(obj[active].style.top) - speed + "px";
		}
    		timerID = setTimeout("ScrollDown("+speed+")",30);
    	}
}

function ScrollStop(){
    	if(document.getElementById){
    		clearTimeout(timerID);
    	}
}

function ScrollPageInit() {
      if(document.getElementById){
    		obj = document.getElementById("QLnkParent").getElementsByTagName("div");
    		obj['QLnkChild'].style.visibility = "visible";
    		obj['QLnkChild'].style.top = 0;
    	}
    	if(document.addEventListener){
    		for(i=0;i<document.getElementsByTagName('a').length;i++){
    			document.getElementsByTagName('a')[i].style.position = "relative";
		}
    	}
}