
var openPanelID;
var openPanelFrameID;
var openPanelURL;
var txtTickerControlID;
var isDisplayMax; 
var helpIFrameSource = null;
var formTypeHelpSource = null;

function ShowTourPopUp(url)
{
	open(url, 'newwindow', 'top=80, left=100, width=600, height=550, toolbar=no, scrollbars=no, location=no, menubar=no, status=no resizable=no, maximize=no')
}

function ShowPopupWithLeftTop(displayText)
{
    var oPopup = window.createPopup();
	var txt="<div style='FONT-WEIGHT: bold; FONT-SIZE: xx-large; COLOR: darkgray; "+
			"FONT-FAMILY: Verdana; POSITION: absolute'>" + displayText + "</div>";
	oPopup.document.body.innerHTML = txt;
	oPopup.show(window.screen.availWidth/2-150, window.screen.availHeight/2-30, 300, 60, document.body);
}

//Opens the new Modal window
function ShowHelpWindow(URL, ClientID)
{
    var features, left, fromTop;

      left = self.screenLeft + findPosX(getObj(ClientID))-document.body.scrollLeft - 150;
      fromTop = self.screenTop + 30 + findPosY(getObj(ClientID))-document.body.scrollTop;
//    features = "dialogWidth: 400px; dialogHeight: 400px; dialogLeft: " + left + "px; dialogTop: " + fromTop + "px; help: no; status: no;";
    features = "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=400,left = " + left + ",top = " + fromTop;
//    window.showModalDialog("../prefs/test1.aspx", "", features);

    objFin = window.open(URL, "popupHelp", features);    
    objFin.focus();
}

function ChangeBGStyle(control,overAndOut,overColor)
{
    if(overAndOut=='Over')
    {
        if (control.bgColor!=null && control.bgColor.length > 0)
            control.borderColor=control.bgColor;
        else
            control.borderColor=control.style.backgroundColor;
        if (overColor!=null && overColor.length > 0)
            control.style.backgroundColor=control.borderColor;//overColor;
        else
            control.style.backgroundColor=control.borderColor;
    }
    else 
    {
   	    control.style.backgroundColor=control.borderColor;
    }
}

//This method is used for Finacials chart popup
function popUpFinancials(URL, CompanyName, VTitle) {
    //day = new Date();
    //id = day.getTime();
    var verTtitle = "&vtitle=";
    if(VTitle)
        verTtitle += VTitle;
    else
        verTtitle += "1";
    var cName = "&companyname=" + escape(CompanyName);
   objFin = window.open(URL.replace("@","'") + cName + verTtitle, "popupFin" , "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=400,left = 500,top = 325");    
    objFin.focus();
    //eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=400,left = 500,top = 325');");
}
//This method is used for Xbrl Viewer Chart PopUp
function popUpChart(Params, CompanyName) {
    var url = "charts/chart.aspx?" + Params;
    var cName = "&companyname=" + escape(CompanyName);
    objFin = window.open(url.replace("@","'") + cName, "popupFin" , "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=400,left = 500,top = 325");    
    objFin.focus();
}
//This function is used for add to dashboard popup
function popUpAddToDashboard(URL, PropValue) {
    //day = new Date();
    //id = day.getTime();
    var val="&pvalue=" + escape(PropValue);
    objAddToDash = window.open(URL+val, "addToDash", "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=300,height=300,left = 500,top = 325");
    objAddToDash.focus();
    //eval("page" + id + " = window.open(URL+val, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=300,height=300,left = 500,top = 325');");
}

function SymbolLookup(URL){
	    objLookUp = window.open(URL, "SymbolLookup" , "height=400,width=600,copyhistory=no,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no");    
        objLookUp.focus();
    }

// OPens the Calendar window
function Calendar(frmTextBox,url) {
      left = self.screenLeft + findPosX(getObj(frmTextBox))-document.body.scrollLeft;
        fromTop = self.screenTop + 30 + findPosY(getObj(frmTextBox))-document.body.scrollTop;
      sUrl =url + frmTextBox; 
      objCal=window.open(sUrl,'DatePickerPopUp','width=175,toolbar=0,status=0,height=180,left=' + left+ ',top=' + fromTop + ',resizable=no');
      objCal.focus();

      }
//Open CallStreet Window
function PopUpCallStreetWindow(URL)
{
    objCallStreet = window.open(URL, "CallStreet" , "height=550,width=770,copyhistory=no,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no");    
        objCallStreet.focus();
}   
   
   
	function findPosX(obj)
	{
		var curleft = 0;
		if (document.getElementById || document.all)
		{
			//alrt("dd");
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		} else if (document.layers){
			curleft += obj.x;
			}
		return curleft;
	}

function findPosY(obj)
{
	
	var curtop = 0;
	if (document.getElementById || document.all)
	{
		
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (document.layers)
		curtop += obj.y;
		
	return curtop;
}

function getObj(name)
	{
	
	if (document.getElementById)
	{
	
		this.obj = document.getElementById(name);
	
		this.style = document.getElementById(name).style;
	}
	else if (document.all)
	{
		this.obj = document.all[name];
		this.style = document.all[name].style;
	}
	else if (document.layers)
	{
		if (document.layers[name])
		{
	   		this.obj = document.layers[name];
	   		this.style = document.layers[name];
		}
		else
		{
			this.obj = document.layers.testP.layers[name];
			this.style = document.layers.testP.layers[name];
		}
	}
	
	return this.obj;
}

function showObjSection(objID)
{
    showObj(objID);
    showObj(objID + "Sep1");
    showObj(objID + "Sep2");
    showObj(objID + "Sep3");
}
function hideObjSection(objID)
{
    hideObj(objID);
    hideObj(objID + "Sep1");
    hideObj(objID + "Sep2");
    hideObj(objID + "Sep3");
}

/////////////////////////////////////////////////////////
// showObj
// Parameters: object--Object name
// JLIU Added 12/29/2005
/////////////////////////////////////////////////////////
function showObj(object) 
{
    if (document.getElementById)
    {
        document.getElementById(object).style.display = 'inline';
    }
    else if (document.layers && document.layers[object])
    {
        document.layers[object].display = 'inline';
    }
    else if (document.all)
    {
        document.all[object].style.display = 'inline';
    }
}

/////////////////////////////////////////////////////////
// hideObj
// Parameters: object--Object name
// JLIU Added 12/29/2005
/////////////////////////////////////////////////////////
function hideObj(object) 
{
    if (document.getElementById)
    {
        document.getElementById(object).style.display = 'none';
    }
    else if (document.layers && document.layers[object])
    {
        document.layers[object].display = 'none';
    }
    else if (document.all)
    {
        document.all[object].style.display = 'none';
    }
}
 function ShowHidePanelGeneric(panelID,callerID,visible,divID)
    {
      
        var obj = document.getElementById(panelID);
        var objDiv = document.getElementById(divID);
           if(visible=="true")
           {
            objDiv.style.top=  (findPosY(getObj(callerID))-document.body.scrollTop +30) +"px";
            objDiv.style.left = (findPosX(getObj(callerID))-document.body.scrollLeft)+"px";
            obj.style.display = "";
            
            }
            else if(visible=="false")
           {
            obj.style.display = "none";
           } 
           
       
    }
    
    //global report 
    function ShowHidePanelGR(panelID,callerID,visible,divID)
    {      
        var obj = document.getElementById(panelID);
        var objDiv = document.getElementById(divID);
           if(visible=="true")
           {
                objDiv.style.top=  (findPosY(getObj(callerID))-document.body.scrollTop +15) +"px";
                objDiv.style.left = (findPosX(getObj(callerID))-document.body.scrollLeft)+"px";
                obj.style.display = "";            
            }
            else if(visible=="false")
           {
            obj.style.display = "none";
           }                   
    }
    
    function ShowAddToFolderPanel(panelID,callerID,divID,framid,url,e)
    {
        var obj = document.getElementById(panelID);
        var objDiv = document.getElementById(divID);
        var objFrame = document.getElementById(framid);
        var objTitle = document.getElementById(panelID + "Title");
        var objCaller = document.getElementById(callerID);
        var cLeft = 0;
        var cTop = 0;
	    var cHeight = objCaller.offsetHeight;
	    var cWidth = objCaller.offsetWidth;
	    var fHeight = parseInt(objFrame.style.height) + 4;
	    var fWidth = parseInt(objFrame.style.width);
	    var sTop = getScrollTop();
	    var sLeft = getScrollLeft();
        
	    for(var objTemp = objCaller; objTemp && objTemp.tagName != 'BODY'; objTemp = objTemp.offsetParent)
	    {
	        cLeft += objTemp.offsetLeft;
	        cTop += objTemp.offsetTop;
	    }
	    if(cTop - fHeight >= sTop && cTop + cHeight + fHeight > getWinHeight() + sTop)
	        cTop -= fHeight;
	    else 
	        cTop += cHeight;
	    if(cLeft - fWidth >= sLeft && cLeft + cWidth + fWidth > getWinWidth() + sLeft)
	        cLeft -= (fWidth + 5);
	    else 
	        cLeft += (cWidth + 5);
	    objDiv.style.left = cLeft + 'px';
	    objDiv.style.top = cTop + 'px';
 

        objFrame.src=url;
//        objDiv.style.top=  (findPosY(getObj(callerID))-document.body.scrollTop)+"px";
//        objDiv.style.left = (findPosX(getObj(callerID))-document.body.scrollLeft - 310)+"px";
        obj.style.display = "";
        if(openPanelID != panelID)
        {
            CloseOpenPanel(openPanelID,openPanelFrameID,openPanelURL)
        }
        openPanelID=panelID;
        openPanelFrameID=framid;
        openPanelURL = url;
        if(objTitle)
        {
            objTitle.innerText = " Add To Folder";
        }
        CancelBubble(e);
    }
    function ShowAlertPanel(panelID,callerID,divID,framid,url,urlParam,e)
    {
        
        var obj = document.getElementById(panelID);
        var objDiv = document.getElementById(divID);
        var objFrame = document.getElementById(framid);
        var objTitle = document.getElementById(panelID + "Title");
        var objCaller = document.getElementById(callerID);
        var cLeft = 0;
        var cTop = 0;
	    var cHeight = objCaller.offsetHeight;
	    var cWidth = objCaller.offsetWidth;
	    var fHeight = parseInt(objFrame.style.height) + 4;
	    var fWidth = parseInt(objFrame.style.width);
	    var sTop = getScrollTop();
	    var sLeft = getScrollLeft();
        
	    for(var objTemp = objCaller; objTemp && objTemp.tagName != 'BODY'; objTemp = objTemp.offsetParent)
	    {
	        cLeft += objTemp.offsetLeft;
	        cTop += objTemp.offsetTop;
	    }
	    if(cTop - fHeight >= sTop && cTop + cHeight + fHeight > getWinHeight() + sTop)
	        cTop -= fHeight;
	    else 
	        cTop += cHeight;
	    if(cLeft - fWidth >= sLeft && cLeft + cWidth + fWidth > getWinWidth() + sLeft)
	        cLeft -= (fWidth + 5);
	    else 
	        cLeft += (cWidth + 5);
	    objDiv.style.left = cLeft + 'px';
	    objDiv.style.top = cTop + 'px';


        objFrame.src=url + "&addalert=" + escape(urlParam);
//        objDiv.style.top=  (findPosY(getObj(callerID))-document.body.scrollTop) +"px";
//        objDiv.style.left = (findPosX(getObj(callerID))-document.body.scrollLeft - 310) +"px";
        obj.style.display = "";
        if(openPanelID != panelID)
        {
            CloseOpenPanel(openPanelID,openPanelFrameID,openPanelURL)
        }
        openPanelID=panelID;
        openPanelFrameID=framid;
        openPanelURL = url;
        if(objTitle)
        {
            objTitle.innerText = " Add Alert";
        }
        CancelBubble(e);
    }
    function ShowThumbnailPanel(panelID, callerID, divID, framid, url, e) {

        var obj = document.getElementById(panelID);
        var objDiv = document.getElementById(divID);
        var objFrame = document.getElementById(framid);
        var objCaller = document.getElementById(callerID);
        var cLeft = 0;
        var cTop = 0;
        var cHeight = objCaller.offsetHeight;
        var cWidth = objCaller.offsetWidth;
        var fHeight = parseInt(objFrame.style.height) + 4;
        var fWidth = parseInt(objFrame.style.width);
        var sTop = getScrollTop();
        var sLeft = getScrollLeft();

        for (var objTemp = objCaller; objTemp && objTemp.tagName != 'BODY'; objTemp = objTemp.offsetParent) {
            cLeft += objTemp.offsetLeft;
            cTop += objTemp.offsetTop;
        }
        if (cTop - fHeight >= sTop && cTop + cHeight + fHeight > getWinHeight() + sTop)
            cTop -= fHeight;
        else
            cTop += cHeight;
        if (cLeft - fWidth >= sLeft && cLeft + cWidth + fWidth > getWinWidth() + sLeft)
            cLeft -= (fWidth + 5);
        else
            cLeft += (cWidth + 5);
        objDiv.style.left = cLeft + 'px';
        objDiv.style.top = cTop + 'px';


        objFrame.src = url;
        obj.style.display = "";
        if (openPanelID != panelID) {
            CloseOpenPanel(openPanelID, openPanelFrameID, openPanelURL)
        }
        openPanelID = panelID;
        openPanelFrameID = framid;
        openPanelURL = url;
//        if (objTitle) {
//            objTitle.innerText = " Add Alert";
//        }
//        CancelBubble(e);
    }    
    function HideAlertPanel(panelID,framid,url)
    {
        
        var obj = document.getElementById(panelID);
        var objFrame = document.getElementById(framid);
        
        objFrame.src=url;
        obj.style.display = "none";
        ClearOpenPanel(openPanelID,openPanelFrameID,openPanelURL);
    }
    function ShowDashBoardPanel(panelID,panelTitleID,panelTitleText,callerID,visible,divID,framid,url)
    {
        var obj = document.getElementById(panelID);
        var objDiv = document.getElementById(divID);
        var objFrame = document.getElementById(framid);
        var objTitleDiv = document.getElementById(panelTitleID);
        var objCaller = document.getElementById(callerID);
        var cLeft = 0;
        var cTop = 0;
	    var cHeight = objCaller.offsetHeight;
	    var cWidth = objCaller.offsetWidth;
	    var fHeight = parseInt(objFrame.style.height) + 4;
	    var fWidth = parseInt(objFrame.style.width);
	    var sTop = getScrollTop();
	    var sLeft = getScrollLeft();
        
	    for(var objTemp = objCaller; objTemp && objTemp.tagName != 'BODY'; objTemp = objTemp.offsetParent)
	    {
	        cLeft += objTemp.offsetLeft;
	        cTop += objTemp.offsetTop;
	    }
	    if(cTop - fHeight >= sTop && cTop + cHeight + fHeight > getWinHeight() + sTop)
	        cTop -= fHeight;
	    else 
	        cTop += cHeight;
	    if(cLeft - fWidth >= sLeft && cLeft + cWidth + fWidth > getWinWidth() + sLeft)
	        cLeft -= (fWidth + 5);
	    else 
	        cLeft += (cWidth + 5);
	    objDiv.style.left = cLeft + 'px';
	    objDiv.style.top = cTop + 'px';
        
        
        objFrame.src=url;
        if(objTitleDiv)
            objTitleDiv.innerText = panelTitleText;
//       objDiv.style.top=  (findPosY(getObj(callerID))-document.body.scrollTop)+"px";
//       objDiv.style.left = (findPosX(getObj(callerID))-document.body.scrollLeft - 310)+"px";
        obj.style.display = "";
        if(openPanelID != panelID)
        { 
            CloseOpenPanel(openPanelID,openPanelFrameID,openPanelURL)
        }
        
        openPanelID=panelID;
        openPanelFrameID=framid;
        openPanelURL = url;
        
    }    
    function ShowHideDashBoardPanel(panelID,panelTitleID,panelTitleText,callerID,visible,divID,framid,url)
    {
        
        var obj = document.getElementById(panelID);
        var objDiv = document.getElementById(divID);
        var objFrame = document.getElementById(framid);
         objFrame.src=url;
           if(visible=="true")
           {
                var objTitleDiv = document.getElementById(panelTitleID);
                var objCaller = document.getElementById(callerID);
                var cLeft = 0;
                var cTop = 0;
	            var cHeight = objCaller.offsetHeight;
	            var cWidth = objCaller.offsetWidth;
	            var fHeight = parseInt(objFrame.style.height);
	            var fWidth = parseInt(objFrame.style.width);
	            var sTop = getScrollTop();
	            var sLeft = getScrollLeft();
                
	            for(var objTemp = objCaller; objTemp && objTemp.tagName != 'BODY'; objTemp = objTemp.offsetParent)
	            {
	                cLeft += objTemp.offsetLeft;
	                cTop += objTemp.offsetTop;
	            }
	            if(cTop - fHeight >= sTop && cTop + cHeight + fHeight > getWinHeight() + sTop)
	                cTop -= (fHeight + 6);
	            else 
	                cTop += (cHeight + 6);
	            if(cLeft - fWidth >= sLeft && cLeft + cWidth + fWidth > getWinWidth() + sLeft)
	                cLeft -= (fWidth - cWidth + 6);
	            else 
	                cLeft += (cWidth - cWidth + 6);
	            objDiv.style.left = cLeft + 'px';
	            objDiv.style.top = cTop + 'px';
                if(objTitleDiv)
                    objTitleDiv.innerText = panelTitleText;
              //objDiv.style.top=  (findPosY(getObj(callerID))-document.body.scrollTop +30)+"px";
              //objDiv.style.left = (findPosX(getObj(callerID))-document.body.scrollLeft)+"px";
                obj.style.display = "";
                if(openPanelID != panelID)
                {
                    CloseOpenPanel(openPanelID,openPanelFrameID,openPanelURL)
                }
                
                openPanelID=panelID;
                openPanelFrameID=framid;
                openPanelURL = url;
           
            }
            else if(visible=="false")
           {
            obj.style.display = "none";
            ClearOpenPanel(openPanelID,openPanelFrameID,openPanelURL);
           } 
           
       
    }
    function ShowHideDPQPanel(panelID,panelTitleID,panelTitleText,callerID,visible,divID,framid,url)
    {
        
        var obj = document.getElementById(panelID);
        var objDiv = document.getElementById(divID);
        var objFrame = document.getElementById(framid);
         objFrame.src=url + "&filingids=" + dpqFilingIDs;
           if(visible=="true")
           {
                var objTitleDiv = document.getElementById(panelTitleID);
                var objCaller = document.getElementById(callerID);
                var cLeft = 0;
                var cTop = 0;
	            var cHeight = objCaller.offsetHeight;
	            var cWidth = objCaller.offsetWidth;
	            var fHeight = parseInt(objFrame.style.height);
	            var fWidth = parseInt(objFrame.style.width);
	            var sTop = getScrollTop();
	            var sLeft = getScrollLeft();
                
	            for(var objTemp = objCaller; objTemp && objTemp.tagName != 'BODY'; objTemp = objTemp.offsetParent)
	            {
	                cLeft += objTemp.offsetLeft;
	                cTop += objTemp.offsetTop;
	            }
	            if(cTop - fHeight >= sTop && cTop + cHeight + fHeight > getWinHeight() + sTop)
	                cTop -= (fHeight + 6);
	            else 
	                cTop += (cHeight + 6);
	            if(cLeft - fWidth >= sLeft && cLeft + cWidth + fWidth > getWinWidth() + sLeft)
	                cLeft -= (fWidth - cWidth + 6);
	            else 
	                cLeft += (cWidth - cWidth + 6);
	            objDiv.style.left = cLeft + 'px';
	            objDiv.style.top = cTop + 'px';
                if(objTitleDiv)
                    objTitleDiv.innerText = panelTitleText;
              //objDiv.style.top=  (findPosY(getObj(callerID))-document.body.scrollTop +30)+"px";
              //objDiv.style.left = (findPosX(getObj(callerID))-document.body.scrollLeft)+"px";
                obj.style.display = "";
                if(openPanelID != panelID)
                {
                    CloseOpenPanel(openPanelID,openPanelFrameID,openPanelURL)
                }
                
                openPanelID=panelID;
                openPanelFrameID=framid;
                openPanelURL = url;
           
            }
            else if(visible=="false")
           {
            obj.style.display = "none";
            ClearOpenPanel(openPanelID,openPanelFrameID,openPanelURL);
           } 
           
       
    }    
    function ShowHideAlertPopupPanel(panelID,callerID,visible,divID,framid,url)
    {
        
        var obj = document.getElementById(panelID);
     
        var objDiv = document.getElementById(divID);
        var objFrame = document.getElementById(framid);
         objFrame.src=url;
           if(visible=="true")
           {
                objDiv.style.top=  (findPosY(getObj(callerID))-document.body.scrollTop +30)+"px";
                objDiv.style.left = (findPosX(getObj(callerID))-document.body.scrollLeft - 150)+"px";
                obj.style.display = "";
                if(openPanelID != panelID)
                {
                    CloseOpenPanel(openPanelID,openPanelFrameID,openPanelURL)
                }
                openPanelID=panelID;
                openPanelFrameID=framid;
                openPanelURL = url;
           
            }
            else if(visible=="false")
           {
            obj.style.display = "none";
            ClearOpenPanel(openPanelID,openPanelFrameID,openPanelURL);
           } 
           
       
    }

    function getScrollTop()
    {
	    if(document.documentElement.scrollTop) 
	        return document.documentElement.scrollTop;
	    if(document.body.scrollTop) 
	        return document.body.scrollTop;
	    if(window.pageYOffset) 
	        return window.pageYOffset;
	    return 0;
    }    
    function getScrollLeft()
    {
	    if(document.documentElement.scrollLeft) 
	        return document.documentElement.scrollLeft;
	    if(document.body.scrollLeft) 
	        return document.body.scrollLeft;
	    if(window.pageXOffset) 
	        return window.pageXOffset;
	    return 0;
    }    
    function getWinHeight()
    {
	    if(window.innerHeight) 
	        return window.innerHeight;
	    if(document.documentElement.clientHeight) 
	        return document.documentElement.clientHeight;
	    if(document.body.clientHeight) 
	        return document.body.clientHeight;
	    return 0;
    }
    function getWinWidth()
    {
	    if(window.innerWidth) 
	        return window.innerWidth;
	    if(document.documentElement.clientWidth) 
	        return document.documentElement.clientWidth;
	    if(document.body.clientWidth) 
	        return document.body.clientWidth;
	    return 0;
    }
    function ShowCalendarPanel(panelID, callerID, divID, framid, url)
    {           
        
        var obj = document.getElementById(panelID);
        var objDiv = document.getElementById(divID);
        var objFrame = document.getElementById(framid);
        var objCaller = document.getElementById(callerID);
        var cLeft = 0;
        var cTop = 0;
	    var cHeight = objCaller.offsetHeight;
	    var cWidth = objCaller.offsetWidth;
	    var fHeight = parseInt(objFrame.style.height) + 4;
	    var fWidth = parseInt(objFrame.style.width);
	    var sTop = getScrollTop();
	    var sLeft = getScrollLeft();
        
	    for(var objTemp = objCaller; objTemp && objTemp.tagName != 'BODY'; objTemp = objTemp.offsetParent)
	    {
	        cLeft += objTemp.offsetLeft;
	        cTop += objTemp.offsetTop;
	    }
	    if(cTop - fHeight >= sTop && cTop + cHeight + fHeight > getWinHeight() + sTop)
	        cTop -= fHeight;
	    else 
	        cTop += cHeight;
	    if(cLeft - fWidth >= sLeft && cLeft + cWidth + fWidth > getWinWidth() + sLeft)
	        cLeft -= (fWidth - cWidth);
	    else 
	        cLeft += (cWidth - cWidth);
	    objDiv.style.left = cLeft + 'px';
	    objDiv.style.top = cTop + 'px';
       
        objFrame.src = url;
        obj.style.display = "";
        if(openPanelID != panelID)
        {
            CloseOpenPanel(openPanelID, openPanelFrameID, openPanelURL)
        }
        openPanelID = panelID;
        openPanelFrameID = framid;
        openPanelURL = url;
       
    }     
    function ShowHideParentPanelGeneric(panelID,visible)
    {
        var obj = parent.document.getElementById(panelID);
       if(visible=="true")
       {
  
        obj.style.display = "";
        
        }
        else if(visible=="false")
       {
        obj.style.display = "none";
       } 
    }
var timeleft
var currentTimer = null
var run = false
var timeOff = 1000

    
    function InitializeClose(panelID,visible)
{
   
    timeleft = 2;
    Start(panelID,visible)
}



function Start(panelID,visible)
{
    if (timeleft==0)
    {
        run = false;
        ShowHideParentPanelGeneric(panelID,visible)
    }
    else
    {
        self.status = timeleft
        timeleft = timeleft - 1
        run = true
        currentTimer = self.setTimeout("Start('" + panelID + "','" + visible +"')", timeOff)
    }
}

/////////////////////////////////////////////////////////
// Generic Show Hide Panel Help function               //
/////////////////////////////////////////////////////////
    function ShowHidePanelHelp(panelID,callerID,visible,divID,iframeID)
    {
        var obj = document.getElementById(panelID);
        var objDiv = document.getElementById(divID);
         var objIFrame = document.getElementById(iframeID);
                 
        if(visible=="true")
        {
            objDiv.style.top=  (findPosY(getObj(callerID))-document.body.scrollTop-16)+"px";
            objDiv.style.left = (findPosX(getObj(callerID))-document.body.scrollLeft-120)+"px";
            obj.style.display = "";            
            
            if(openPanelID != panelID)
            {
                CloseOpenPanel(openPanelID,openPanelFrameID,openPanelURL)
            }
             if (objIFrame!=null)
            {
                if (formTypeHelpSource != null)
                {
                    objIFrame.src = formTypeHelpSource;
                }
                else
                {
                    formTypeHelpSource = objIFrame.src;
                }
            }
            openPanelID=panelID;
            openPanelFrameID=null;
            openPanelURL = null;
                                             
        }
        else if(visible=="false")
        {
            obj.style.display = "none";
            ClearOpenPanel(openPanelID,openPanelFrameID,openPanelURL);                              
       } 
     
    }
/////////////////////////////////////////////////////////
// Generic Show Hide Panel Help function               //
/////////////////////////////////////////////////////////
    function ShowHidePanelGenericHelp(panelID,callerID,visible,divID,iframeID,callerpos)
    {
        var obj = document.getElementById(panelID);   
	    var obj = document.getElementById(panelID);
        var objDiv = document.getElementById(divID);
        var objFrame = document.getElementById(iframeID);
        var objCaller = document.getElementById(callerID);
        var cLeft = 0;
        var cTop = 0;
	    var cHeight = objCaller.offsetHeight;
	    var cWidth = objCaller.offsetWidth;
	    var fHeight = parseInt(objFrame.style.height) + 4;
	    var fWidth = parseInt(objFrame.style.width);
	    var sTop = getScrollTop();
	    var sLeft = getScrollLeft();
        
	    for(var objTemp = objCaller; objTemp && objTemp.tagName != 'BODY'; objTemp = objTemp.offsetParent)
	    {
	        cLeft += objTemp.offsetLeft;
	        cTop += objTemp.offsetTop;
	    }
	    if(cTop - fHeight >= sTop && cTop + cHeight + fHeight > getWinHeight() + sTop)
	        cTop -= fHeight;
	    else 
	        cTop += cHeight;
	    if(cLeft - fWidth >= sLeft && cLeft + cWidth + fWidth > getWinWidth() + sLeft)
	        cLeft -= (fWidth - cWidth);
	    else 
	        cLeft += (cWidth - cWidth);
	    objDiv.style.left = cLeft + 'px';
	    objDiv.style.top = cTop + 'px';
	        
        if(visible=="true")
        {
            obj.style.display = "";            
            
            if(openPanelID != panelID)
            {
                CloseOpenPanel(openPanelID,openPanelFrameID,openPanelURL)
            }
             if (objFrame!=null)
            {
                if (formTypeHelpSource != null)
                {
                    objFrame.src = formTypeHelpSource.replace("edgar/formtypes","massdownload/default");
                }
            }
            openPanelID=panelID;
            openPanelFrameID=null;
            openPanelURL = null;
                                             
        }
        else if(visible=="false")
        {
            obj.style.display = "none";
            ClearOpenPanel(openPanelID,openPanelFrameID,openPanelURL);                              
       } 
     
    }    

/////////////////////////////////////////////////////////
// General Show Hide Panel Help function               //
/////////////////////////////////////////////////////////
    function ShowHidePanelGeneralHelp(panelID,callerID,visible,divID,iframeID,callerpos,srcPath)
    {
        var obj = document.getElementById(panelID);   
	    var obj = document.getElementById(panelID);
        var objDiv = document.getElementById(divID);
        var objFrame = document.getElementById(iframeID);
        var objCaller = document.getElementById(callerID);
        var cLeft = 0;
        var cTop = 0;
	    var cHeight = objCaller.offsetHeight;
	    var cWidth = objCaller.offsetWidth;
	    var fHeight = parseInt(objFrame.style.height) + 4;
	    var fWidth = parseInt(objFrame.style.width);
	    var sTop = getScrollTop();
	    var sLeft = getScrollLeft();
        
	    for(var objTemp = objCaller; objTemp && objTemp.tagName != 'BODY'; objTemp = objTemp.offsetParent)
	    {
	        cLeft += objTemp.offsetLeft;
	        cTop += objTemp.offsetTop;
	    }
	    if(cTop - fHeight >= sTop && cTop + cHeight + fHeight > getWinHeight() + sTop)
	        cTop -= fHeight;
	    else 
	        cTop += cHeight;
	    if(cLeft - fWidth >= sLeft && cLeft + cWidth + fWidth > getWinWidth() + sLeft)
	        cLeft -= (fWidth - cWidth);
	    else 
	        cLeft += (cWidth - cWidth);
	    objDiv.style.left = cLeft + 'px';
	    objDiv.style.top = cTop + 'px';
	        
        if(visible=="true")
        {
            obj.style.display = "";            
            
            if(openPanelID != panelID)
            {
                CloseOpenPanel(openPanelID,openPanelFrameID,openPanelURL)
            }
             if (objFrame!=null)
            {
                objFrame.src = srcPath;
            }
            openPanelID=panelID;
            openPanelFrameID=null;
            openPanelURL = null;
                                             
        }
        else if(visible=="false")
        {
            obj.style.display = "none";
            ClearOpenPanel(openPanelID,openPanelFrameID,openPanelURL);                              
       } 
     
    }        
    
///////////////////////////////////////////////////////////////////
//  Show hide help panel on All Filings and Expanded Form Types  
//  search screens; Move the layer right so that market  
//  segment icon won't overlaps layer
///////////////////////////////////////////////////////////////////
    function ShowHidePanelHelpAwayIcon(panelID,callerID,visible,divID)
    {
        var obj = document.getElementById(panelID);
        var objDiv = document.getElementById(divID);
        
        if(visible=="true")
        {
            objDiv.style.top=  (findPosY(getObj(callerID))-document.body.scrollTop-16)+"px";
            objDiv.style.left = (findPosX(getObj(callerID))-document.body.scrollLeft-60)+"px";
            obj.style.display = "";            
            
            if(openPanelID != panelID)
            {
                CloseOpenPanel(openPanelID,openPanelFrameID,openPanelURL)
            }
            openPanelID=panelID;
            openPanelFrameID=null;
            openPanelURL = null;                                      
        }
        else if(visible=="false")
        {
            obj.style.display = "none";
            ClearOpenPanel(openPanelID,openPanelFrameID,openPanelURL);                              
        } 
     
    }

/////////////////////////////////////////////////////////
// Show Hide Header Help Panel                         //
/////////////////////////////////////////////////////////
function ShowHidePanelHeaderHelp(panelID,callerID,visible,divID,iframeID)
    {
        var obj = document.getElementById(panelID);
        var objDiv = document.getElementById(divID);
        var objIFrame = document.getElementById(iframeID);
      
        if(visible=="true")
        {
            var objCaller = document.getElementById(callerID);
            var cLeft = 0;
            var cTop = 0;
	        var cHeight = objCaller.offsetHeight;
	        var cWidth = objCaller.offsetWidth;
	        var fHeight = parseInt(objIFrame.style.height);
	        var fWidth = parseInt(objIFrame.style.width);
	        var sTop = getScrollTop();
	        var sLeft = getScrollLeft();
            
	        for(var objTemp = objCaller; objTemp && objTemp.tagName != 'BODY'; objTemp = objTemp.offsetParent)
	        {
	            cLeft += objTemp.offsetLeft;
	            cTop += objTemp.offsetTop;
	        }
	        if(cTop - fHeight >= sTop && cTop + cHeight + fHeight > getWinHeight() + sTop)
	            cTop -= (fHeight + 4);
	        else 
	            cTop += (cHeight + 4);
	        if(cLeft - fWidth >= sLeft && cLeft + cWidth + fWidth > getWinWidth() + sLeft)
	            cLeft -= (fWidth - 4);
	        else 
	            cLeft += (cWidth - 4);
	        objDiv.style.left = cLeft + 'px';
	        objDiv.style.top = cTop + 'px';

            //objDiv.style.top=  (findPosY(getObj(callerID))-document.body.scrollTop-16)+"px";
            //objDiv.style.left = (findPosX(getObj(callerID))-document.body.scrollLeft-140)+"px";
            obj.style.display = "";
            
            //If users click a link on the layer, the layer navigate to another url. 
            //We store the original iframe src to a variable. When users click the help link again,
            //we put the original src back to the iframe.
            if (objIFrame!=null)
            {
                if (helpIFrameSource != null)
                {
                    objIFrame.src = helpIFrameSource;
                }
                else
                {
                    helpIFrameSource = objIFrame.src;
                }
            }
            
            if(openPanelID != panelID)
            {
                CloseOpenPanel(openPanelID,openPanelFrameID,openPanelURL)
            }
            openPanelID=panelID;
            openPanelFrameID=null;
            openPanelURL = null;                                           
        }
        else if(visible=="false")
        {
            obj.style.display = "none";
            ClearOpenPanel(openPanelID,openPanelFrameID,openPanelURL);                          
       } 
     
    }
    
 /////////////////////////////////////////////////////////
// ShowHide QUICK Search Panel
/////////////////////////////////////////////////////////
     function ShowHideQucikSearchPanel(panelID,callerID,visible,divID,hidePanelID,IFrameID,IFrameURL)
    {
        var obj = document.getElementById(panelID);
        var objDiv = document.getElementById(divID);
        var objFrame = document.getElementById(IFrameID);
        var lstObj;
        var error;
       try
       {
         lstObj =divlstActGroup;
       }
       catch(error)
       {
        lstobj =null;
       }
           objFrame.src=IFrameURL;
           if(visible=="true")
           {
                objDiv.style.top=  (findPosY(getObj(callerID))+18)+"px";
                objDiv.style.left = (findPosX(getObj(callerID))-405)+"px";
                obj.style.display = "";
                HidePanel(hidePanelID);
                if(openPanelID != panelID)
                {
                    CloseOpenPanel(openPanelID,openPanelFrameID,openPanelURL)
                }
                openPanelID=panelID;
                openPanelFrameID=null;
                openPanelURL = null;
                 if(lstObj !=null)
                {
                    lstObj.style.display = "none";
                }
                if(txtTickerControlID !=null)
                {
                  setControlFocus(txtTickerControlID)
                }
                
           }
           else if(visible=="false")
           {
            obj.style.display = "none";
            if(lstObj !=null)
                {
                    lstObj.style.display = "";
                }
            ClearOpenPanel(openPanelID,openPanelFrameID,openPanelURL);
           } 
           
           
       
    }
    
/////////////////////////////////////////////////////////
// ShowHide Login Panel
/////////////////////////////////////////////////////////
     function ShowHideLoginPanel(panelID,callerID,visible,divID,hidePanelID)
    {
        
        var obj = document.getElementById(panelID);
        var objDiv = document.getElementById(divID);
           if(visible=="true")
           {
            objDiv.style.top=  (findPosY(getObj(callerID))+18)+"px";
            objDiv.style.left = (findPosX(getObj(callerID))-375)+"px";
            obj.style.display = "";
            HidePanel(hidePanelID);
             if(openPanelID != panelID)
            {
                CloseOpenPanel(openPanelID,openPanelFrameID,openPanelURL)
            }
             openPanelID=panelID;
             openPanelFrameID=null;
             openPanelURL = null;
            }
            else if(visible=="false")
           {
            obj.style.display = "none";
            ClearOpenPanel(openPanelID,openPanelFrameID,openPanelURL);
           
           } 
           
       
    }
  /////////////////////////////////////////////////////////
// ShowHide Login Panel
/////////////////////////////////////////////////////////
     function HidePanel(panelID)
    {
      
        var obj = document.getElementById(panelID);
        var lstObj
        if(obj != null)
        {
            obj.style.display = "none";
         }
      try
       {
         lstObj =divlstActGroup;
       }
       catch(error)
       {
        lstobj =null;
       }
       
          if(lstObj !=null)
            {
                lstObj.style.display = "";
            }
    }
/////////////////////////////////////////////////////////
// Redirect QUICK Search Panel
/////////////////////////////////////////////////////////
function QuickSearchRedirect(strUrl)
{
    var obj = window.parent.document.location;
    obj.href=strUrl;
}
////////////////////////////////////////////////////////
// Redirect QUICK Search Panel
/////////////////////////////////////////////////////////
function setControlFocus(controlClientID)
{
     var obj= document.getElementById(controlClientID);
      obj.focus();
     
}
function SetTIckerControlClientID(controlClientID)
{

     txtTickerControlID = controlClientID;
     
}

function CloseOpenPanel(panelID,framid,url)
{
        var obj = document.getElementById(panelID);
        var objFrame = document.getElementById(framid);
        if(objFrame!=null)
        {
        objFrame.src=url;
        }
        if(obj != null)
        {
         obj.style.display = "none";
        }                
}

function ClearOpenPanel(panelID,framid,url)
{
      panelID=null;
      framid=null;
      url = null;
}
//Sets the title of display Page
function PageTitle(currentTitle)
{
     parent.document.title=currentTitle;
}

function ClearTimeFrame(ListBoxID)
{
    var objListBox = document.getElementById(ListBoxID);
    if(objListBox != null)
    {
        objListBox.value='';
    }
}

//disable date range and specific date
function ClearDateFields(ListBoxID, TextBoxFromID, TextBoxToID, TextBoxID)
{
    var objListBox = document.getElementById(ListBoxID);
    var objTextBoxFrom = document.getElementById(TextBoxFromID);
    var objTextBoxTo = document.getElementById(TextBoxToID);
    var objTextBox = document.getElementById(TextBoxID);

    if (objListBox.options[objListBox.selectedIndex].value != '')
    {
        objTextBoxFrom.value='';
        objTextBoxTo.value='';
        objTextBox.value='';
    }
}

//disable time frame and specific date
function Clear2DateFields(ListBoxID, TextBoxID)
{
    var objListBox = document.getElementById(ListBoxID);
    var objTextBox = document.getElementById(TextBoxID);
    
    objListBox.value='';
    objTextBox.value='';
}

//disable time frame and date range   
function Clear3DateFields(ListBoxID, TextBoxFromID, TextBoxToID)
{
    var objListBox = document.getElementById(ListBoxID);
    var objTextBoxFrom = document.getElementById(TextBoxFromID);
    var objTextBoxTo = document.getElementById(TextBoxToID);
    
    objListBox.value='';
    objTextBoxFrom.value='';
    objTextBoxTo.value='';
}

//This method is used to clear the textbox in the dashboard list page.
function TextboxClear(TxtBox, RButton)
{
    var rButton = document.getElementById(RButton);
    var tBox = document.getElementById(TxtBox);
    
    if(tBox.value == "Enter Dashboard Name")
    {
        tBox.value = "";
    }
    rButton.checked = true;
}
//this method is used in dashboard list page to populate the textbox with default text
function TextboxDefault(TxtBox, RButton)
{
    var rButton = document.getElementById(RButton);
    var tBox = document.getElementById(TxtBox);
    if(tBox.value == "")
    {
        tBox.value = "Enter Dashboard Name";
        rButton.checked = false;
    }
}

function CancelBubble(evt)
{
//        var eventInstance = (window.event) ? window.event : e;
//        eventInstance.cancelBubble = true;
        
    var e=(evt)?evt:window.event;
    if (window.event) {
        e.cancelBubble=true;
    } else {
        e.stopPropagation();
    }
        
}
/////////////////////////////////////////////////////////
// Redirect 
/////////////////////////////////////////////////////////
function ViewFilingsRedirect(strUrl,e)
{
    var eventInstance = (window.event) ? window.event : e;
        eventInstance.cancelBubble = true;
        window.location.href=strUrl;
   
}
function ShowHideCriteria(panelID, divHideID, divShowID, visible)
    {
        var objPanel = document.getElementById(panelID); 
        var objdivHide = document.getElementById(divHideID);
        var objdivShow = document.getElementById(divShowID);
        
        if(visible=="true")
        {
            objPanel.style.display = "";
            objdivShow.style.display="none";
            objdivHide.style.display="";           
        }
        else if(visible=="false")
        {
            objPanel.style.display = "none";
            objdivShow.style.display="";
            objdivHide.style.display="none";                   
        }
    }
    
    
function ShowHideUpdateCompanyPanel(panelID,callerID,visible,divID,IFrameID,IFrameURL)
{
    var objPanel = document.getElementById(panelID);
    var objDiv = document.getElementById(divID);
    var objFrame = document.getElementById(IFrameID);
  
   objFrame.src=IFrameURL;
   if(visible=="true")
   {
        var objCaller = document.getElementById(callerID);
        var cLeft = 0;
        var cTop = 0;
        var cHeight = objCaller.offsetHeight;
        var cWidth = objCaller.offsetWidth;
        var fHeight = parseInt(objFrame.style.height);
        var fWidth = parseInt(objFrame.style.width);
        var sTop = getScrollTop();
        var sLeft = getScrollLeft();
        
        for(var objTemp = objCaller; objTemp && objTemp.tagName != 'BODY'; objTemp = objTemp.offsetParent)
        {
            cLeft += objTemp.offsetLeft;
            cTop += objTemp.offsetTop;
        }
        if(cTop - fHeight >= sTop && cTop + cHeight + fHeight > getWinHeight() + sTop)
            cTop -= (fHeight + 6);
        else 
            cTop += (cHeight + 6);
        if(cLeft - fWidth >= sLeft && cLeft + cWidth + fWidth > getWinWidth() + sLeft)
            cLeft -= (fWidth - cWidth - 150);
        else 
            cLeft += (cWidth - cWidth - 150);
        objDiv.style.left = cLeft + 'px';
        objDiv.style.top = cTop + 'px';
        
        //objDiv.style.top=  (findPosY(getObj(callerID))-document.body.scrollTop +30) +"px";
        //objDiv.style.left = (findPosX(getObj(callerID))-document.body.scrollLeft)+"px";
        
        objPanel.style.display = "";

        if(openPanelID != panelID)
        {
            CloseOpenPanel(openPanelID,openPanelFrameID,openPanelURL)
        }
        openPanelID=panelID;
        openPanelFrameID=null;
        openPanelURL = null;                     
   }
   else if(visible=="false")
   {
        objPanel.style.display = "none";
        
        ClearOpenPanel(openPanelID,openPanelFrameID,openPanelURL);
   } 
}

function TRLinkNavigate(url)
{
    var actualURL = url.replace("@@","'");
    window.location.href=actualURL;
}
function ResizeIFrame(FrameID, ActualHeight)
{
    var adjusHeight;
    var iframe = document.getElementById(FrameID);
    if (iframe == null)
      iframe = window.parent.frames[FrameID];

    if(iframe != null)
    {
        if (iframe.contentDocument && iframe.contentDocument.body.offsetHeight && iframe.contentDocument.body.offsetHeight > 0)
           adjusHeight = iframe.contentDocument.body.offsetHeight + 10;
        else if (iframe.Document && iframe.Document.body.scrollHeight && iframe.Document.body.scrollHeight > 0)
           adjusHeight = iframe.Document.body.scrollHeight; 
           
        if(!ActualHeight)
            ActualHeight = iframe.style.height.replace("px", "");
        if(adjusHeight < ActualHeight)
            iframe.style.height = adjusHeight + "px";
     }
}
function DeleteAllPopuAlerts()
{
    if(openPanelID.length > 0 && openPanelFrameID.length > 0)
        ShowHideAlertPopupPanel(openPanelID,'','false','divAlertPopup',openPanelFrameID,'');
    var objAlertCount = document.getElementById("ctl00_cphHeader_Header1_hlAlertCount");
    if(objAlertCount)
        objAlertCount.style.display = "none";
}
function FilingSearch(RouterURL, SearchTextID, QueryParams)
{
    var objSearchText = document.getElementById(SearchTextID);
    var searchText = "";
    var fullURL = "";
   
    if(objSearchText)
    {
        if(isAllSpaces(objSearchText.value))
        {        
            alert('Please enter a ticker symbol or company name.');
            return false;		
        }
        searchText =objSearchText.value.replace(/&/g,'');
        if(arguments.length == 3)
            fullURL = RouterURL + QueryParams + "&searchtext=" + searchText;
        else
            fullURL = RouterURL + "?searchtext=" + searchText;
                        
        window.parent.location.href = fullURL;
        return false;
    }
}
//var timeleftGS
//var currentTimerGS = null
//var runGS = false
//var timeOffGS = 1000

function DisplayGettingStartedPopup(PageURL){

	var strTarget = PageURL;
	var strName = "DisplayGettingStarted";
	var strDetails = "height=652,width=500,copyhistory=no,directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no";
	var objPopup = window.open(strTarget, strName, strDetails);
	timeleftGS = 2;
	
	if(objPopup !=null)
	    objPopup.focus();
	//StartFocusWindow(objPopup);
}
function OpenInParentWindow(PageURL)
{
	if(window.opener != null){
		window.opener.top.document.location.href = PageURL;
	}
	else{
		this.top.document.location.href = PageURL;
	}
}

function ValidateLogin(UsernameID, PasswordID, objButton)
{
 var objUserName = document.getElementById(UsernameID);
 var objPassword = document.getElementById(PasswordID);   
 var inputCounter = 0;
 var alertMsg;
 if(objUserName && objUserName.value.length <= 0)
 {
    inputCounter++;
    alertMsg = "Please enter User Name.";
 }
 if(objPassword && objPassword.value.length <= 0)
 {
    inputCounter++;
    alertMsg = "Please enter Password.";
 }
    
 if(inputCounter == 2)
 {
    alert("Please enter User Name and Password.");
    return false;
 }
 if(inputCounter == 1)
 {
    alert(alertMsg);
    return false;
 }
 if(objButton)
    objButton.disabled = true;
 return true;
}
//function StartFocusWindow(ObjPopup)
//{
//    if (timeleftGS==0)
//    {
//        runGS = false;
//        ObjPopup.focus();
//    }
//    else
//    {
//        self.status = timeleftGS
//        timeleftGS = timeleftGS - 1
//        runGS = true
//        currentTimerGS = self.setTimeout("StartFocusWindow(" + ObjPopup + ")", timeOffGS);
//    }
//}
function RedirectPage(strUrl)
{
    window.parent.location.href = strUrl;   
}

function AutoPosition(callerID,divID)
{
    var objDiv = document.getElementById(divID);
    var nName = navigator.appName

    if(nName.indexOf("Micro")>=0)
    {
        objDiv.style.top=  (findPosY(getObj(callerID))+18)+"px";
    }
    else
    {
            objDiv.style.top=  (findPosY(getObj(callerID))+25)+"px";
    }
            objDiv.style.left = (findPosX(getObj(callerID))-330)+"px";
          
}
// async sorting logic
function ResetSortColumn(FunctionID, CurrentSortColum)
{
    showLoadingSmall(FunctionID+CurrentSortColum);
    var sortOrder = $get(FunctionID+"hfSO").value;
    //methodcalVal = new String(WebmethodCall);
    var methodcalVal = $get(FunctionID+"hfWM").value;
    methodcalVal = methodcalVal.replace(/@#/g, "'");
    $get(FunctionID+"hfSC").value = CurrentSortColum;
    methodcalVal = methodcalVal.replace("##SC##", CurrentSortColum);
    if(sortOrder == "D")
    {
        methodcalVal = methodcalVal.replace("SortOrder=D", "SortOrder=A");
        $get(FunctionID+"hfSO").value = "A";
    }
    else
    {
        methodcalVal = methodcalVal.replace("SortOrder=A", "SortOrder=D");
        $get(FunctionID+"hfSO").value = "D";
    }
    //alert(methodcalVal);
    eval(methodcalVal);
}
function DoSorting(FunctionID, SortColumnID, SortColumnHideID, SortOrderID)
{
    if($get(SortColumnHideID).value.length>0)
    {
        var imageHide=FunctionID +$get(SortColumnHideID).value;
        var imageShow=FunctionID +$get(SortColumnID).value;
        if(parseInt($get(SortColumnHideID).value) == parseInt($get(SortColumnID).value))
        {
            $get(imageShow).style.display="inline";
        }
        else
        {
            $get(imageHide).style.display="none";
            $get(imageShow).style.display="inline";
        }
        
        if($get(SortOrderID).value == "D")
        {
            $get(imageShow + "img").src = $get(imageShow + "img").src.replace("sortup","sortdown");
        }
        else
        {
            $get(imageShow + "img").src = $get(imageShow + "img").src.replace("sortdown","sortup");
        }
    }
}    
function SetTopPrevNextLinks(FunctionID)
{
    var objdivBot = $get(FunctionID + "divBot");
    var objdivTop = $get(FunctionID + "divTop");
    var objdivBotH = $get(FunctionID + "divBotH");
    var objdivTopH = $get(FunctionID + "divTopH");

    if(objdivBot && objdivTop)
    {
        objdivTop.innerHTML = objdivBot.innerHTML;
    }

    if(objdivBotH && objdivTopH)
    {
        objdivTopH.innerHTML = objdivBotH.innerHTML;
    }
}
function ShowHideInsiderPre(ShowHideFlag, FunctionID, CurrentSortColum, WebmethodCall)
{
    showLoadingSmallNP(FunctionID);
    var sortOrder = $get(FunctionID+"hfSO").value;
    var objSHI = $get(FunctionID + "SHI");
    methodcalVal = new String(WebmethodCall);
    
    //setting webmoth change to back history hidden field
    if($get(FunctionID+"hfWMHist") && $get(FunctionID+"hfRPP"))
    {
        var webMethodHist = methodcalVal.replace("StartRow=1", "StartRow=##SR##");
        webMethodHist = webMethodHist.replace("EndRow=" + $get(FunctionID+"hfRPP").value, "EndRow=##ER##");
        $get(FunctionID+"hfWMHist").value = webMethodHist;
    }
    
    methodcalVal = methodcalVal.replace("SortOrder=##SO##", "SortOrder=" + sortOrder);
    $get(FunctionID+"hfWM").value = methodcalVal;
    methodcalVal = methodcalVal.replace(/@#/g, "'");
    methodcalVal = methodcalVal.replace("##SC##", $get(FunctionID+"hfSC").value);
    
    if(objSHI)
        objSHI.value = ShowHideFlag;
    //alert($get(FunctionID+"hfWM").value);
    eval(methodcalVal);
}
function ShowHideInsiderPost(FunctionID)
{
    var objdivSI = $get(FunctionID + "divSI");
    var objdivHI = $get(FunctionID + "divHI");
    var objSHI = $get(FunctionID + "SHI");
    
    if(objdivSI && objdivHI && objSHI)
    {
        if(objSHI.value == "1")
        {
            objdivHI.style.display="none";
            objdivSI.style.display="inline";
        }
        else
        {
            objdivSI.style.display="none";
            objdivHI.style.display="inline";
        }
    }
    //alert($get(FunctionID+"hfWM").value);
}
// For Download and Print Queue logic
var dpqFilingIDs = "|";
function AddDPQFilingID(obj, FilingID, DPQID)
{
    var objTag = document.getElementById("div_" + FilingID);
    if(!obj.checked)
    {
        obj.checked = false;
        dpqFilingIDs = dpqFilingIDs.replace("|" + FilingID + "|", "|");
        if(objTag)
            objTag.style.display = 'none';
    }
    else if(dpqFilingIDs.split("|").length < 22) // 22 means greater than 20
    {
        obj.checked = true;
        dpqFilingIDs += FilingID + "|";
        if(objTag)
        {
            objTag.style.display = 'inline';
            objTag.style.position = 'relative';
        }
    }
    else
    {
        obj.checked = false;
        alert("You cannot add more than 20 filings.");
    }
    
    var divDPQColumnHeader = document.getElementById(DPQID)
    var divDPQColumnHeader1 = document.getElementById(DPQID + "1")
    //var divDPQColumnFooter = document.getElementById(DPQID + "2")
    if(dpqFilingIDs.length > 2 && dpqFilingIDs.split("|").length > 3)
    {
        if(divDPQColumnHeader && divDPQColumnHeader1)
        {
            divDPQColumnHeader.style.display = 'none';
            divDPQColumnHeader1.style.display = 'inline';
        }
//        if(divDPQColumnFooter)
//        {
//            divDPQColumnFooter.style.display = 'inline';
//        }
    }
    else
    {
        if(divDPQColumnHeader && divDPQColumnHeader1)
        {
            divDPQColumnHeader.style.display = 'inline';
            divDPQColumnHeader1.style.display = 'none';
        }
//        if(divDPQColumnFooter)
//        {
//            divDPQColumnFooter.style.display = 'none';
//        }
    }
}

// DPQ function changed for Topics to accomodate duplicate filing ids
function AddDPQFilingIDTopics(obj, FilingID, DPQID, Index) {
    var objTag = document.getElementById("div_" + FilingID + "_" + Index);
    if (!obj.checked) {
        obj.checked = false;
        dpqFilingIDs = dpqFilingIDs.replace("|" + FilingID + "|", "|");
        if (objTag)
            objTag.style.display = 'none';
    }
    else if (dpqFilingIDs.split("|").length < 22) // 22 means greater than 20
    {
        obj.checked = true;
        dpqFilingIDs += FilingID + "|";
        if (objTag) {
            objTag.style.display = 'inline';
            objTag.style.position = 'relative';
        }
    }
    else {
        obj.checked = false;
        alert("You cannot add more than 20 filings.");
    }

    var divDPQColumnHeader = document.getElementById(DPQID)
    var divDPQColumnHeader1 = document.getElementById(DPQID + "1")
    //var divDPQColumnFooter = document.getElementById(DPQID + "2")
    if (dpqFilingIDs.length > 2 && dpqFilingIDs.split("|").length > 3) {
        if (divDPQColumnHeader && divDPQColumnHeader1) {
            divDPQColumnHeader.style.display = 'none';
            divDPQColumnHeader1.style.display = 'inline';
        }
        //        if(divDPQColumnFooter)
        //        {
        //            divDPQColumnFooter.style.display = 'inline';
        //        }
    }
    else {
        if (divDPQColumnHeader && divDPQColumnHeader1) {
            divDPQColumnHeader.style.display = 'inline';
            divDPQColumnHeader1.style.display = 'none';
        }
        //        if(divDPQColumnFooter)
        //        {
        //            divDPQColumnFooter.style.display = 'none';
        //        }
    }
}


function PrintDownloadLinks(DPQURL)
{
    var windName = "PrintHTMLFilings" + Math.round(100*Math.random());
    var pdW = window.open(DPQURL, windName, 'toolbar=no,location=no,directories=no,menubar=no,status=no,scrollbars=yes,resizable=yes,replace=no,width=600,height=400');
}
//Displays loading img on loading the control
function showLoading(divID)
{
    var objDiv = document.getElementById(divID)
    if(objDiv)
        objDiv.innerHTML = '<table width=\"100%\"><tr><td align="center"><br/><img src="images/asyncloading.gif" /></td></tr></table>';
}
//Displays loading img on sorting
function showLoadingSmall(divID)
{
    var objDiv = document.getElementById(divID)
    if(objDiv)
    {
        objDiv.innerHTML = '<img src="images/snake_transparent_small.gif" />';
        objDiv.style.display = 'inline';
    }
}
//Displays loading img on paging
function showLoadingSmallNP(divID)
{
    var objDivTopH = document.getElementById(divID+'divTopH')
    var objDivBotH = document.getElementById(divID+'divBotH')
    if(objDivTopH)
    {
        objDivTopH.innerHTML = '<img src="images/snake_transparent_small.gif" />';
    }
    if(objDivBotH)
    {
        objDivBotH.innerHTML = '<table width=\"100%\"><tr><td align="center"><img src="images/snake_transparent_small.gif" /></td></tr></table>';
    }
}

//Adding back button history - start
var userNavigated = true;
function addPageHostory(StartRow, EndRow, FunctionID)
{
    var val = StartRow + "-" + EndRow + "-" + FunctionID;
    userNavigated = false;
    Sys.Application.addHistoryPoint({s: val});
    userNavigated = true;
}
function onNavigate(sender, e) 
{
    var val = e.get_state().s || 0;
    
    if(userNavigated && val != 0)
    {
        var arrVal = val.split("-");
        if(arrVal && arrVal.length == 3)
        {
            ShowBackResults(arrVal[0], arrVal[1], arrVal[2]);
        }
    }
}
function ShowBackResults(StartRow, EndRow, FunctionID)
{
    var webMethod = $get(FunctionID + "hfWMHist").value;
    
    if(webMethod && webMethod.length > 0)
    {
        if(dpqFilingIDs && dpqFilingIDs.split('|').length > 3) 
        {
            if(window.confirm('You have multiple filings queued for download or printing. Click OK to remove these filings from the queue or Cancel to return to the current results.'))
            {
                dpqFilingIDs = '|'; 
            } 
            else 
                return false;
        }
        webMethod = webMethod.replace("##SR##", StartRow);
        webMethod = webMethod.replace("##ER##", EndRow);
        webMethod = webMethod.replace(/@#/g, "'");
        webMethod = webMethod.replace("##SC##", $get(FunctionID+"hfSC").value);
        webMethod = webMethod.replace("##SO##", $get(FunctionID+"hfSO").value);
        addPageHostory(StartRow, EndRow, FunctionID);
        eval(webMethod);
    }
}
//Adding back button history - end

//Series and classes function
var oldSeriesUID = "";
function ShowHideSeries(UID, AppPath)
{
    var objImage = document.getElementById("img" + UID);
    var objDiv = document.getElementById("div" + UID);
    
    if(oldSeriesUID != UID)
    {
        var objOldDiv = document.getElementById("div" + oldSeriesUID);
        var objOldImage = document.getElementById("img" + oldSeriesUID);
        
        if(objOldDiv)
        {
            if(objOldDiv.style.display == "inline")
            {
                objOldDiv.style.display = "none";
                if(objOldImage)
                    objOldImage.src = AppPath + "/images/icons/smaximize.gif";
            }
        }
    }
    
    if(objDiv)
    {
        if(objDiv.style.display == "none")
        {
            objDiv.style.display = "inline";
            if(objImage)
            {
                objImage.src = AppPath + "/images/icons/sminimize.gif";
            }
            objDiv.focus();
        }
        else
        {
            objDiv.style.display = "none";
            if(objImage)
            {
                objImage.src = AppPath + "/images/icons/smaximize.gif";
//                objImage.focus();
            }
        }
        oldSeriesUID = UID;
    }
}

//Autocomplete
function PositionList(source, eventArgs)
{
    var divTarget = source.get_completionList();
    var divWidth = divTarget.style.left.replace('px','');
    var itemCount = divTarget.childNodes.length;

    if(divWidth)
    {
        divWidth=parseInt(divWidth);
        if (!source._height) { source._height=divWidth-325+'px'; }
        divTarget.style.left=source._height;
    }
    divTarget.style.width ='450px';
    if (itemCount < 12) { divTarget.style.height=itemCount*17+'px'; }//based on one row height:17px
    else { divTarget.style.height='204px'; }
}

function FormatListItems(source, eventArgs)
{
    sugList=source.get_completionList();
    for(iC=0;iC<sugList.childNodes.length;iC++)
    {
        var sugValue=sugList.childNodes[iC].innerHTML;
        if(sugValue)
        {
            var tValue=sugValue.substring(0,sugValue.indexOf('~~'));
            sugValue="<span class=\"t\">"+tValue+"</span><span class=\"n\">"+sugValue.substring(sugValue.indexOf('~~')+2)+"</span>";
            sugList.childNodes[iC].innerHTML=sugValue;
            sugList.childNodes[iC].childNodes[0]._value=sugList.childNodes[iC].childNodes[1]._value=sugList.childNodes[iC]._value;
            sugList.childNodes[iC].title=sugList.childNodes[iC].childNodes[0].title=sugList.childNodes[iC].childNodes[1].title=tValue;
        }
    }
}

 
   function ShowHideLabel(labelText, visible, callerID)
    {
        var obj = document.getElementById(callerID);
         
        if (obj != null)
        {
            if(visible=="true")
            {
                //users didn't type in anything.
                if(obj.value =='')
                {  
                    obj.value = labelText;
                }                                 
            }
            else if(visible=="false")
            {
                //users typed in something different from original text.
                if(obj.value == labelText)
                {
                    obj.value = ''; 
                }                                           
            } 
        }
     
    } 
 
