//------------------------------------------------- Actionbar.js-------------------------------------------------------------------------------------
    function Validate_AB_EditBox(ControlID, EditBoxID, IsMandatory, ValidateRange, MinValue, MaxValue, ErrorMessage)
    {
        if (IsMandatory == true)
        {
            if (IsEmpty(EditBoxID))
            {
                if (ErrorMessage == '')
                    alert("Value cannot be empty");
                else
                {
                    ErrorMessage = DecodeSpecialCharactersForJS(ErrorMessage);
                    alert(ErrorMessage);
                }
                return;
            }
        }
        
        if (ValidateRange == true)
        {
            if (!RangeCheck(EditBoxID, MinValue, MaxValue))
            {
                if (ErrorMessage == '')
                    alert("Value out of range");
                else
                {
                    ErrorMessage = DecodeSpecialCharactersForJS(ErrorMessage);
                    alert(ErrorMessage);
                }
                return;
            }
        }
        __doPostBack(ControlID,'');        
    }
    
    function IsEmpty(ControlId)
    {
        var objTextbox = document.getElementById(ControlId);
        if(objTextbox == null)
        {
            return false;
        }
        var value = objTextbox.value;
        value = LTrim(RTrim(value));
        if(value == '')
            return true;
        else
            return false;
        
    }  

    function RangeCheck(id, min_value, max_value)
    { 
        var obj = document.getElementById(id);
        
        var CurrText_signed = obj.value;
        var Grouping_Separator_Symbol = ',';
        if(CurrText_signed == '')
            return true;
        
        if(CurrText_signed.charAt(0) == '-')
            CurrText = CurrText_signed.substr(1);
        else
            CurrText = CurrText_signed;
            
        var temp_arr = CurrText.split(Grouping_Separator_Symbol);
        
        CurrText = '';
        for(i=0; i<temp_arr.length; i++)
        {
            CurrText = CurrText + temp_arr[i];
        }
        
        if (isNaN(CurrText))
        {
            obj.focus();
            return false;
        }
        
        if(CurrText_signed.charAt(0) == '-')
        {
            var temp = CurrText;
            CurrText = '-';
            CurrText = CurrText + temp;
        }
        
        if(min_value != null && min_value != '')
        {
            if(parseFloat(CurrText) < parseFloat(min_value))
            {
                obj.focus();
                
                return false;
            }        
        }

        if(max_value != null && max_value != '')
        {
            if(parseFloat(CurrText) > parseFloat(max_value))
            {
                obj.focus();
                
                return false;
            }
        }
        return true;
    }

    function Validate_Numeric_ActionBar(id)
    {
        var ControlObj = document.getElementById(id);
        var Grouping_Separator_Symbol = ',';

        if(ControlObj == null)
            return false;

        var CurrText = ControlObj.value;

        if(CurrText == '')
            return true;

        var temp_arr = CurrText.split(Grouping_Separator_Symbol);
        
        for(i = 0; i < temp_arr.length; i++)
        {
            var temp_int = temp_arr[i];
            
            if(isNaN(temp_int))
            {                
                ShowAlert('Alert_OnlyNumericExpected_Shared');
                ControlObj.focus();
                ControlObj.value = '';
                return false;
            }
          
            if(temp_arr[i].length != String(parseInt(temp_int)).length)
            {
                var tempstr = CurrText.substr(0,CurrText.length - 1);
                ControlObj.value = tempstr;
                ShowAlert('Alert_OnlyNumericExpected_Shared');
                ControlObj.focus();
                return false;
            }
        }
        return true;
    }
//------------------------------------------------- ALBaseControl.js-------------------------------------------------------------------------------------
/// to show popup and drag
var ALDragWindow,DottedWindow,ALXPosition,ALYPosition;
var browser      = navigator.appName; 
var IsmasterPage = "IsmasterPage";
var FunctionToExecuteonMoveStop = "";
var FunctionToExecuteonMove     = "";
var IsExcludeTopbarHeight             = "IsExcludeTopbarHeight";
function ALShowPopupBox(eventObj,WindowID)
{                                                      
    ALShowWindow = document.getElementById(WindowID); 
    ALShowWindow.style.display='block'; 
    ALShowWindow.style.position ='absolute';	
        
    if ( browser == 'Netscape' )
    {
        WindowWidth     = document.body.clientWidth;
        WindowHeight    = document.body.clientHeight;
    }
    else
    {
        WindowWidth     = document.body.offsetWidth;
        WindowHeight    = document.body.offsetHeight;
    }
    
    ALXPosition = eventObj.clientX + ALShowWindow.offsetWidth;
    ALYPosition = eventObj.clientY + ALShowWindow.offsetHeight;
    
   if(ALXPosition > WindowWidth)
    {
        ALShowWindow.style.left= (eventObj.clientX + document.body.scrollLeft) - ALShowWindow.offsetWidth + "px";
    }
    else
    {
        ALShowWindow.style.left= eventObj.clientX + document.body.scrollLeft + "px";
    }
    ALShowWindow.style.top = parseInt(ALMouseY(eventObj)) + "px";
}

function ALClosePopup(WindowID)
{
    if ( WindowID != '' )
    {
        var ALShowWindow = document.getElementById(WindowID);
        ALShowWindow.style.position ='absolute';
        
        if(browser == 'Netscape')
        {
            ALShowWindow.style.left   = 0 + "px";
            ALShowWindow.style.top    = 0 + "px";
        
            ALShowWindow.style.height = 0 + "px";
            ALShowWindow.style.width  = 0 + "px";
        }
        //else
            ALShowWindow.style.display  ='none';
    }
    
    Dimmmeframe = document.getElementById("Dimmerframe");
    if(Dimmmeframe != null)
    { 
        Dimmmeframe.style.position ='absolute';
        Dimmmeframe.style.display  ='none';
    }
}

var mov_XStart,mov_YStart,mov_XEnd,mov_YEnd,mov_HStart,mov_WStart,mov_HEnd,mov_WEnd,mov_Winbox,mov_factor;
var Zindex = 1000;
function ALShowPopupWindow(WindowID,X,Y,Height,Width,ShowSliding,showdimmer)
{
    ShowWindow     = document.getElementById(WindowID); 
    arrayPageSize  = ALGetPageSize();
    
    ShowWindow.style.position ='absolute';
    ShowWindow.style.display  = 'block';
    
    StartX = document.documentElement.scrollLeft? document.documentElement.scrollLeft :document.body.scrollLeft;
    StartY = document.documentElement.scrollTop? document.documentElement.scrollTop :document.body.scrollTop;
    
    if(X == "")
    {
        X = arrayPageSize[2] / 2;
        X -= Width / 2;
        
        if(document.getElementById(IsmasterPage) != null)
            X += 100; //Left Pane
    }
        X = parseInt(StartX) + parseInt(X);
    
    
    if(Y =="")
    {
        Y = arrayPageSize[3] / 2;
        Y -= Height / 2;
        
       if(document.getElementById(IsExcludeTopbarHeight) != null)       
            Y += 80; //Exclude top bar height
        
    }
        Y = parseInt(StartY) + parseInt(Y);
    
    if (parseInt(X) < 0)
        X = 0;
        
    if (parseInt(Y) < 0)
        Y = 0;
    
    if(showdimmer)
    {
        Dimmmeframe = document.getElementById("Dimmerframe"); 
        
        if(Dimmmeframe != null)
        {
            Dimmmeframe.style.position  ='absolute';
            Dimmmeframe.style.display   = 'block';
            Dimmmeframe.style.width     = arrayPageSize[0] + 'px';
            Dimmmeframe.style.height    = arrayPageSize[1] + 'px';
            Dimmmeframe.style.left      = '0px';
            Dimmmeframe.style.top       = '0px';
            Dimmmeframe.style.zIndex    = Zindex++;
        }
    }
              
    mov_XStart = StartX;
    mov_YStart = StartY;
    mov_XEnd   = X;
    mov_YEnd   = Y;
    mov_HStart = 1;
    mov_WStart = 1;
    mov_HEnd   = Height;
    mov_WEnd   = Width;
    mov_Winbox  = ShowWindow;
    mov_factor  = 20;
    mov_Winbox.style.zIndex = Zindex++;
    
    if(ShowSliding)
    {
        ShowWindow.style.overflow ='hidden';
        ALMovePopupwindow();
    }
    else
    {
        mov_Winbox.style.left   = mov_XEnd + "px";
        mov_Winbox.style.top    = mov_YEnd + "px";
        
        mov_Winbox.style.height = mov_HEnd + "px";
        mov_Winbox.style.width  = mov_WEnd + "px";
        ShowWindow.style.overflow ='visible';
    }
    
    if(browser != "Microsoft Internet Explorer") //for handling the Iframe problem in ff
    {
		ALEnableTextSelection(ShowWindow, true);
		ALEnableTextSelection(ShowWindow, false);
    }
}

//function to move the window while its displayed    
function ALMovePopupwindow()
{
    if( !((mov_YStart > (mov_YEnd - mov_factor)) && (mov_YStart < (mov_YEnd + mov_factor))) || 
     !((mov_XStart > (mov_XEnd - mov_factor)) && (mov_XStart < (mov_XEnd + mov_factor))))
    {
        mov_HStart  = mov_HStart + mov_factor;
        mov_WStart  = mov_WStart + mov_factor;
        
        if(mov_XStart >=  mov_XEnd)
            mov_XStart = mov_XEnd;
        else
            mov_XStart  = mov_XStart + mov_factor;
            
        if(mov_YStart >=  mov_YEnd)
            mov_YStart = mov_YEnd;
        else
            mov_YStart  = mov_YStart + mov_factor;
        
        if(mov_HStart >=  mov_HEnd)
            mov_HStart = mov_HEnd;
        else
            mov_HStart  = mov_HStart + mov_factor;
            
        if(mov_WStart >=  mov_WEnd)
            mov_WStart = mov_WEnd;
        else
            mov_WStart  = mov_WStart + mov_factor;
           
        mov_Winbox.style.left   = mov_XStart + "px";
        mov_Winbox.style.top    = mov_YStart + "px";
        
        mov_Winbox.style.height = mov_HStart + "px";
        mov_Winbox.style.width  = mov_WStart + "px";
        
        setTimeout (ALMovePopupwindow,1);
    }
    else
    {
        mov_Winbox.style.left   = mov_XEnd + "px";
        mov_Winbox.style.top    = mov_YEnd + "px";
        
        mov_Winbox.style.height = mov_HEnd + "px";
        mov_Winbox.style.width  = mov_WEnd + "px";
        ShowWindow.style.overflow ='visible';
    }
}
    
function ALGetPageSize()
{	    
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) 
    {	
	    xScroll = document.body.scrollWidth;
	    yScroll = window.innerHeight + window.scrollMaxY;
    } 
    else if (document.body.scrollHeight > document.body.offsetHeight)
    {   
        // all but Explorer Mac
	    xScroll = document.body.scrollWidth;
	    yScroll = document.body.scrollHeight;
    } 
    else 
    { 
        // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
	    xScroll = document.body.offsetWidth;
	    yScroll = document.body.offsetHeight;
    }
	
    var windowWidth, windowHeight;
    if (self.innerHeight) 
    {	
        // all except Explorer
	    windowWidth = self.innerWidth;
	    windowHeight = self.innerHeight;
    } 
    else if (document.documentElement && document.documentElement.clientHeight) 
    {   
        // Explorer 6 Strict Mode
	    windowWidth = document.documentElement.clientWidth;
	    windowHeight = document.documentElement.clientHeight;
    } 
    else if (document.body) 
    { 
        // other Explorers
	    windowWidth = document.body.clientWidth;
	    windowHeight = document.body.clientHeight;
    }	
	
    // for small pages with total height less then height of the viewport
    if(yScroll < windowHeight)
    {
	    pageHeight = windowHeight;
    } 
    else 
    { 
	    pageHeight = yScroll;
    }
    
    // for small pages with total width less then width of the viewport
    if(xScroll < windowWidth)
    {	
	    pageWidth = windowWidth;
    } 
    else 
    {
	    pageWidth = xScroll;
    }
    
    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight); 	    
    return (arrayPageSize);
}


function ALMouseX(evt) 
{
    if (evt.pageX)
    { 
     return evt.pageX;
    }
    else if (evt.clientX)
    { 
     return evt.clientX + (document.documentElement.scrollLeft? document.documentElement.scrollLeft :document.body.scrollLeft); 
    } 
    else return 0;
}

function ALMouseY(evt) 
{
    if (evt.pageY)
    { 
     return evt.pageY;
    }
    else if (evt.clientY)
    { 
     return evt.clientY + (document.documentElement.scrollTop? document.documentElement.scrollTop :document.body.scrollTop); 
    } 
    else return 0;
}

function ALGetWindowDiametric(Target)
{
    var left = 0;
    var top  = 0;
    var width  = 0;
    var height = 0;
    

    while (Target.offsetParent)
    {
	    left += Target.offsetLeft;
	    top  += Target.offsetTop;
	    Target     = Target.offsetParent;
	    
	    if(width == 0)
	       width = Target.clientWidth;
	       
	    if(height == 0)
	       height = Target.clientHeight;
    }
    
    left += Target.offsetLeft;
    top  += Target.offsetTop;

    return {X:left, Y:top, Width:width, Height:height};
}
    
function ALGetMouseXY(e)
{
    e = e || window.event;

    if(e.pageX || e.pageY)
    {
	    return {X:e.pageX, Y:e.pageY};
    }
    return {
            X:e.clientX ,
	        Y:e.clientY
           };
}
	
function ALGetMouseOffset(Target, e)
{
    e = e || window.event;

    var TargetPos = ALGetWindowDiametric(Target);
    var mousePos  = ALGetMouseXY(e);
    return {X:mousePos.X - TargetPos.X, Y:mousePos.Y - TargetPos.Y};
}

function ALIsMouseLButtonDown(e)
{
    var e = e || window.event;
    if(browser == "Microsoft Internet Explorer")
    {
        if(e.button == 1)
            return true;
        else
            return false;
    }
    else
        return true;
}

var PreviousDocumnetMouseMove   = null;
var PreviousDocumnetMouseUp     = null;
var PreviousDocumnetMouseDown   = null;
var ALDragWindowOffsetGXY       = null;             
            
            
function ALWindowDrag(WindowID)
{
    var DimensionObj;
    ALDragWindow     = document.getElementById(WindowID);
    
    if (ALDragWindow != null)
    {
        if(ALDragWindow.childNodes[1] != null && ALDragWindow.childNodes[1].style.display =='block')
             DimensionObj = ALDragWindow.childNodes[1];
        else if(ALDragWindow.childNodes[0] != null && ALDragWindow.childNodes[0].style.display =='block')
                DimensionObj = ALDragWindow.childNodes[0];
                
        DottedWindow = document.createElement("div");
        ALDragWindow.parentNode.appendChild(DottedWindow);
        DottedWindow.style.position ='absolute';
        DottedWindow.style.left   =  ALDragWindow.style.left;
        DottedWindow.style.top    =  ALDragWindow.style.top;
        DottedWindow.style.width  =  DimensionObj.clientWidth  + 'px';
        DottedWindow.style.height =  DimensionObj.clientHeight + 'px';
        DottedWindow.className    = "DottedWindow";
        
        ALDragWindow.style.position     ='absolute';
        ALDragWindow.style.zIndex       = Zindex++;
        
        DottedWindow.style.position     ='absolute';
        DottedWindow.style.zIndex       = Zindex++;
        
        if(PreviousDocumnetMouseMove == null)
        {
            PreviousDocumnetMouseMove   = document.onmousemove;
            PreviousDocumnetMouseUp     = document.onmouseup;
        }
            
        document.onmousemove = ALMouseMove; 
        document.onmouseup   = ALStopDrag;
        
        ALEnableTextSelection(ALDragWindow,false);
    }
    return;
}


function ALStopDrag()
{
    if (ALDragWindow != null) 
    {
        ALDragWindowID = ALDragWindow.id;
    
        if(FunctionToExecuteonMoveStop != null || FunctionToExecuteonMoveStop != "")
            setTimeout(FunctionToExecuteonMoveStop,0);
        
        if(DottedWindow !=null)
        {
            ALDragWindow.style.left   =  DottedWindow.style.left;            
            
            //If top of popup goes out of screen then by default it will be set to 0px.
            var WindowTop             = DottedWindow.style.top;   
            if(WindowTop.indexOf("-") == -1)
                ALDragWindow.style.top    =  WindowTop;
            else                
                ALDragWindow.style.top    =  "0px";
                
            ALDragWindow.parentNode.removeChild(DottedWindow);
            ALEnableTextSelection(ALDragWindow, true);
        }
    }
    
    ALDragWindow                = null;
    DottedWindow                = null;
    ALDragWindowOffsetGXY       = null;
    document.onmousemove        = PreviousDocumnetMouseMove;
    document.onmouseup          = PreviousDocumnetMouseUp;
    document.onselectstart      = null;
}

function ALMouseMove(e) 
{ 
    if (DottedWindow != null && ALDragWindow != null && ALIsMouseLButtonDown(e) == true) 
    { 
        ALDragWindowID = ALDragWindow.id;
        
        if(ALDragWindowOffsetGXY == null)
            ALDragWindowOffsetGXY          = ALGetMouseOffset(ALDragWindow,e);   
        
        ALMousePosition = ALGetMouseXY(e);
        
        DottedWindow.style.left     = ALMousePosition.X - ALDragWindowOffsetGXY.X  + 'px';
        DottedWindow.style.top      = ALMousePosition.Y - ALDragWindowOffsetGXY.Y  - 15 + 'px';
         
        if(FunctionToExecuteonMove != null || FunctionToExecuteonMove != "")
            setTimeout(FunctionToExecuteonMove,0);
            
        return false; 
    }
    else
        ALStopDrag();
} 

function ALEnableTextSelection(Target, Enable)
{
     if(Enable)
     {
        if (typeof Target.onselectstart!="undefined") //IE
            Target.onselectstart=null;
        else if (typeof Target.style.MozUserSelect!="undefined") //FF
                if(Target.innerHTML.indexOf("<iframe") < 0) // Not new popup page
                    Target.style.MozUserSelect="";
     }
     else
     {
       //document.onselectstart = function() {return false;} 
            
        if (typeof Target.onselectstart!="undefined") //IE
            Target.onselectstart=function(){return false;};
        else if (typeof Target.style.MozUserSelect!="undefined") //FF
            Target.style.MozUserSelect="none";
     }
}

var slideSpeed_ALBC = 20;	// Higher value = faster
var timer_ALBC = 1;	// Lower value = faster
var TargetHeight;
var TargetWidth;

function ALMinMax_ALBC(ExpandModeDiv, CollapseModeDiv, SildeMode)
{
    var numericId = 0;
    var ExpandDiv   = document.getElementById(ExpandModeDiv);
    var CollapseDiv = document.getElementById(CollapseModeDiv);
    
    ExpandDiv.style.overflow   ='hidden'
    CollapseDiv.style.overflow ='hidden';
    
    if(!ExpandDiv.style.display || ExpandDiv.style.display=='none')
    {
        ExpandDiv.style.display     ='block';
        ExpandDiv.style.position    = '';
        
        if(SildeMode == "Vertical")
        {
            ExpandDiv.style.height = CollapseDiv.offsetHeight + 'px';
            CollapseDiv.style.width  = ExpandDiv.offsetWidth + 'px';
            ALSlideVertical_ALBC(ExpandModeDiv, ExpandModeDiv, CollapseModeDiv, slideSpeed_ALBC, 1);  
        }
        else
        {
            ALSetnoWrapforTag(ExpandDiv,'td',true);
            ALSetnoWrapforTag(CollapseDiv,'td',true);
            ALSlideHorizontal_ALBC(ExpandModeDiv, ExpandModeDiv, CollapseModeDiv, slideSpeed_ALBC, 1);  
        }
		
        CollapseDiv.style.position  ='absolute';
        CollapseDiv.style.display   ='none';
    }
    else
    {
        if(SildeMode == "Vertical")
        {
            ExpandDiv.style.height = CollapseDiv.offsetHeight + 'px';
            CollapseDiv.style.width  = ExpandDiv.offsetWidth + 'px';
            ALSlideVertical_ALBC(ExpandModeDiv, CollapseModeDiv, ExpandModeDiv, (slideSpeed_ALBC*-1), 1);
        }
        else
        {
            ALSetnoWrapforTag(ExpandDiv,'td',true);
            ALSetnoWrapforTag(CollapseDiv,'td',true);
            ALSlideHorizontal_ALBC(ExpandModeDiv, CollapseModeDiv, ExpandModeDiv, (slideSpeed_ALBC*-1), 1);
        }
    }	
}

function ALSlideVertical_ALBC(SlidingDiv, ToShowDiv, ToHideDiv, direction, numTime)
{
    var obj =document.getElementById(SlidingDiv);
    
    if ( numTime == 1 )
    {
        if(document.getElementById(SlidingDiv+'_Height').value == "")
        {
            document.getElementById(SlidingDiv+'_Height').value = document.getElementById(SlidingDiv+'_Content').offsetHeight;
        }
        
        TargetHeight = parseInt(document.getElementById(SlidingDiv +'_Height').value) ;
        if ( obj.clientHeight == 0 )
            height = TargetHeight;
        else
            height = obj.clientHeight;
    }
    else
        height = obj.clientHeight;
    
    height = height + direction;
    rerunFunction = true;
    if(height>TargetHeight)
    {
        height = TargetHeight;
        rerunFunction = false;
    }
    if (direction >0 )  //Expanding
    {
        RHSHeight = 1;
        if(height<=RHSHeight)
        {
            height = 1;
            rerunFunction = false;
        }
    }
    else  //Collapsing
    {
        PrevDisplay = document.getElementById(ToShowDiv).style.display;
        document.getElementById(ToShowDiv).style.display='block';
        RHSHeight =parseInt(document.getElementById(ToShowDiv+'_Content').offsetHeight); 
        if(height<=RHSHeight || height<=20)
        {
            height = RHSHeight;
            document.getElementById(ToHideDiv).style.position='absolute';
            document.getElementById(ToHideDiv).style.display='none';
            document.getElementById(ToHideDiv).style.overflow='visible'
				
            document.getElementById(ToShowDiv).style.position='';
            document.getElementById(ToShowDiv).style.display='block';
            document.getElementById(ToShowDiv).style.overflow='visible'
            rerunFunction = false;
        }
        else
        {
            document.getElementById(ToShowDiv).style.display=PrevDisplay;
            rerunFunction = true;
        }
    }

    obj.style.height = height + 'px';
    var topPos = height - TargetHeight;
    if(topPos>0)topPos=0;
    document.getElementById(SlidingDiv+'_Content').style.top = topPos + 'px';
    if(rerunFunction)
    {
        setTimeout('ALSlideVertical_ALBC(\'' + SlidingDiv + '\',\'' + ToShowDiv + '\',\'' + ToHideDiv + '\',' + direction + ',2)',timer_ALBC);
    }
    else
    {
        if(height<=RHSHeight)
        {
            obj.style.display='none'; 
            obj.style.height = '';
        }
        else
        {
            document.getElementById(ToHideDiv).style.position='absolute';
            document.getElementById(ToHideDiv).style.display='none';
            document.getElementById(ToHideDiv).style.overflow='visible'
				
            document.getElementById(ToShowDiv).style.position='';
            document.getElementById(ToShowDiv).style.display='block';
            document.getElementById(ToShowDiv).style.overflow='visible'
            obj.style.height = '';
        }
    }
}

function ALSlideHorizontal_ALBC(SlidingDiv, ToShowDiv, ToHideDiv, direction, numTime)
{
    var obj =document.getElementById(SlidingDiv);
    
    if ( numTime == 1 )
    {
        if(document.getElementById(SlidingDiv+'_Width').value == "")
        {
            document.getElementById(SlidingDiv+'_Width').value = document.getElementById(SlidingDiv+'_Content').offsetWidth;
        }
        
        TargetWidth = parseInt(document.getElementById(SlidingDiv+'_Width').value) ;
    
        if ( obj.clientWidth == 0 )
            width = TargetWidth;
        else
            width = obj.clientWidth;
    }
    else
        width = obj.clientWidth;
    
    width = width + direction;
    rerunFunction = true;
    if(width>TargetWidth)
    {
        width = TargetWidth;
        rerunFunction = false;
    }
    if (direction >0 )  //Expanding
    {
        RHSwidth = 1;
        if(width<=RHSwidth)
        {
            width = 1;
            rerunFunction = false;
        }
    }
    else  //Collapsing
    {
        PrevDisplay = document.getElementById(ToShowDiv).style.display;
        document.getElementById(ToShowDiv).style.display='block';
        RHSwidth =parseInt(document.getElementById(ToShowDiv+'_Content').offsetWidth); 
        if(width<=RHSwidth)
        {
            width = RHSwidth;
            document.getElementById(ToHideDiv).style.position='absolute';
            document.getElementById(ToHideDiv).style.display='none';
            document.getElementById(ToHideDiv).style.overflow='visible'
				
            document.getElementById(ToShowDiv).style.position='';
            document.getElementById(ToShowDiv).style.display='block';
            document.getElementById(ToShowDiv).style.overflow='visible'
            rerunFunction = false;
        }
        else
        {
            document.getElementById(ToShowDiv).style.display=PrevDisplay;
            rerunFunction = true;
        }
    }

    obj.style.width = width + 'px';
    var leftPos = width - TargetWidth;
    if(leftPos>0)leftPos=0;
    document.getElementById(SlidingDiv+'_Content').style.left = leftPos + 'px';
    if(rerunFunction)
    {
        setTimeout('ALSlideHorizontal_ALBC(\'' + SlidingDiv + '\',\'' + ToShowDiv + '\',\'' + ToHideDiv + '\',' + direction + ',2)',timer_ALBC);
    }
    else
    {
        width = width + 10;
        obj.style.width = width + 'px';
        
        if(width<RHSwidth)
        {
            obj.style.display='none'; 
        }
        else
        {
            document.getElementById(ToHideDiv).style.position='absolute';
            document.getElementById(ToHideDiv).style.display='none';
            document.getElementById(ToHideDiv).style.overflow='visible'
				
            document.getElementById(ToShowDiv).style.position='';
            document.getElementById(ToShowDiv).style.display='block';
            document.getElementById(ToShowDiv).style.overflow='visible'
        }
    }
}


function ALSetnoWrapforTag(inputdocuementElement, TageName, noWrapValue)
{
//         if(inputdocuementElement.all.tags('td')[0] != null && inputdocuementElement.all.tags('td')[0].noWrap != noWrapValue)
//         {
//            for( var i=0 ; i < inputdocuementElement.all.tags(TageName).length ; i++)
//                inputdocuementElement.all.tags('td')[i].noWrap = noWrapValue;
//         }
}

//for vascript special character handling
function ALDecodeJavascriptParamterChar(inputstr)
{
    while(inputstr.indexOf("%26") > -1)
    inputstr = inputstr.replace("%26","&");
    
    while(inputstr.indexOf("%5C") > -1)
    inputstr = inputstr.replace("%5C","\\");
    
    while(inputstr.indexOf("%27") > -1)
    inputstr = inputstr.replace("%27","'");
    
    while(inputstr.indexOf("%28") > -1)
    inputstr = inputstr.replace("%28","(");
    
    while(inputstr.indexOf("%29") > -1)
    inputstr = inputstr.replace("%29",")");
    
    return inputstr;
}

// This function is to replace all th occurrences of specified String
function ALReplaceall(inputstr,Str_To_Replace,Str_Replace_With) 
{
	while(inputstr.indexOf(Str_To_Replace) >0 )
	{
	    inputstr = inputstr.replace(Str_To_Replace,Str_Replace_With);
	}
	return inputstr;
}

// This function allows to change the control Caption from Client side
function ALChangeCaption(WindowCaptionID, NewCaptionText)
{
  var captionLabel;
  
  captionLabel = document.getElementById(WindowCaptionID + "Max"); 
  if(captionLabel != null)
    captionLabel.innerHTML = NewCaptionText;
    
  captionLabel = document.getElementById(WindowCaptionID + "Min"); 
  if(captionLabel != null)
    captionLabel.innerHTML = NewCaptionText;
  
}

//Helper functions
function ALPause(numberMillis) 
{
    if(browser == "Microsoft Internet Explorer")
    {
        if(navigator.userAgent.indexOf('MSIE 7.0') < 0 )
        {
            var dialogScript ='window.setTimeout(function () { window.close(); }, ' + numberMillis + ');';
            var result = window.showModalDialog('javascript:document.write("<script>' + dialogScript + '<' + '/script>")');
        }
    }
}

function GetFormatedParameter(inputstr)
{
	var Outputstr = '';		
	
	if(inputstr == null)
	    return;
	    
	for (var i = 0; i < inputstr.length; i++) 
	{
        switch (inputstr.charAt(i))
        {
            case '+': 
                Outputstr += '%2B';
            break;
            case '/': 
                Outputstr += '%2F';
            break;
            case ' ': 
                Outputstr += '+';
            break;
            case '$': 
                Outputstr += '%24';
            break;
            case '&': 
                Outputstr += '%26';
            break;
            default :
                Outputstr += inputstr.charAt(i);
            break;
        }
	}
	return Outputstr
}

//-------------------------------------------------CommonJavascriptValidations.js----------------------------------------------------------------------------var NumbValueStr = '0123456789';
var LwrCharStr = 'abcdefghijklmnopqrstuvwxyz';
var UprCharStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
// For special characters in Email Address view Bugzilla bug ID= 1137.
var LValidCharStr = "_!#$%&'*+-/=?^`{|}~%";
var RValidCharStr = "_!#$%&'*+-/=?^`{|}~%";

//Common function used by all the functions to display the error message.
function ALShowError(ErrorMessage, DefaultErrorMessage)
{
    if (ErrorMessage == '' || ErrorMessage == null)
        alert(DefaultErrorMessage);
    else
        alert(ErrorMessage);
}

// This function will return false if the given value is not form the permitted values for that field.
//It is used by Validate_Alphabetic, Validate_AlphaNumeric, Validate_EmailAddress.
function ALIsValid(Value, PermittedValue, ErrorMessage, ShowError) 
{
    if (Value == "") 
        return true;
    
    if (ShowError != false)
        ShowError = true;
    
    for (i=0; i<Value.length; i++) 
    {
        if (PermittedValue.indexOf(Value.charAt(i),0) == -1) 
        {
            if (ShowError == true)
            {
                ALShowError(ErrorMessage, "Invalid input");
            }
            return false;            
        }
    }
    return true;
}


function ALGetMonthValue(Month)
{   
    switch(Month.toUpperCase())
    {
        case "JANUARY":
            return 0;
        case "FEBURARY":
            return 1;
        case "MARCH":
            return 2;
        case "APRIL":
            return 3;
        case "MAY":
            return 4;
        case "JUNE":
            return 5;
        case "JULY":
            return 6;
        case "AUGUST":
            return 7;
        case "SEPTEMBER":
            return 8;
        case "OCTOBER":
            return 9;
        case "NOVEMBER":
            return 10;
        case "DECEMBER":
            return 11;
    }
}

function ALCompairDates(Date_From, Month_From, Year_From, Date_To, Month_To, Year_To)
{
    if (parseInt(Year_From) < parseInt(Year_To))
        return true;
    else
    {   
        if (parseInt(Year_From) == parseInt(Year_To))
        {   
            if (parseInt(Month_From) < parseInt(Month_To))
                return true;
            else
            {
                if ( parseInt(Month_From) == parseInt(Month_To))
                {   
                    if (parseInt(Date_From) < parseInt(Date_To))
                        return true;
                }
            }
        }
    }    
    return false;
}


//Validate_Date is used to ensure that the set date is greater than the current date.
function ALValidate_Date(ControlID, ErrorMessage, ShowError)
{
    var ControlObject   = null;
    var Today_Date      = null;
    var Today_Month     = null;
    var Today_Year      = null;
    var Set_Date        = null;
    var Set_Month       = null;
    var Set_Year        = null;
    var SetDateArray    = null;
    var SetDate         = null;
    var ReturnedValue   = null;
    
    ControlObject = document.getElementById(ControlID);
    if (ControlObject == null)
        return false;
    
    if (ShowError != false)
        ShowError = true;
    
    //Getting current date and retrieving Day, Month, Year form it.    
    Today_Date  = new Date();
    Today_Month = Today_Date.getMonth();
    Today_Year  = Today_Date.getFullYear();
    Today_Date  = Today_Date.getDate();
    
    if (ControlObject.value != '')
    {
        //Splitting the date in Day, Month, Year tokens.
        SetDate         = ControlObject.value;
        SetDateArray    = SetDate.split(" ");
        Set_Date        = SetDateArray[0];
        Set_Month       = SetDateArray[1];
        Set_Month       = ALGetMonthValue(Set_Month); //Converting the Month to number.
        Set_Year        = SetDateArray[2];
    
        ReturnedValue = ALCompairDates(Today_Date, Today_Month, Today_Year, Set_Date, Set_Month, Set_Year);
        if (ReturnedValue == true)
            return true;
        else
        {
            if (ShowError == true)
            {
                ALShowError(ErrorMessage, "Set date should be greater than current date");
            }
            return false;            
        }
    }    
}

//Function to ensure that the TO date is greater than the FROM Date
function ALValidate_DateRange(BaseID, ControlIDFrom, ControlIDTo, ErrorMessage, ShowError)
{
    var ControlObjectFrom       = null;
    var ControlObjectTo         = null;
    var DateFrom                = null;
    var DateTo                  = null;
    var MonthFrom               = null;
    var MonthTo                 = null;
    var YearFrom                = null;
    var YearTo                  = null;
    var DateFromArray           = null;
    var DateToArray             = null;
    
    ControlIDFrom = BaseID + ControlIDFrom;
    ControlIDTo = BaseID + ControlIDTo;
    
    ControlObjectFrom   = document.getElementById(ControlIDFrom);
    ControlObjectTo     = document.getElementById(ControlIDTo);
    
    if (ControlObjectFrom == null || ControlObjectTo == null)
        return false;
    
    if (ShowError != false)
        ShowError = true;
    
    DateFrom        = ControlObjectFrom.value;
    DateTo          = ControlObjectTo.value;
    
    //Splitting the two dates in Day, Month, Year formatt.
    DateFromArray   = DateFrom.split(" ");
    DateToArray     = DateTo.split(" ");
    
    DateFrom        = DateFromArray[0];
    MonthFrom       = DateFromArray[1];
    MonthFrom       = ALGetMonthValue(MonthFrom); //Converting the Month to number.
    YearFrom        = DateFromArray[2];
    
    DateTo          = DateToArray[0];
    MonthTo         = DateToArray[1];
    MonthTo         = ALGetMonthValue(MonthTo);  //Converting the Month to number.
    YearTo          = DateToArray[2];
    
    ReturnedValue = ALCompairDates(DateFrom, MonthFrom, YearFrom, DateTo, MonthTo, YearTo);
    if (ReturnedValue == true)
        return true;
    else
    {
        if (ShowError == true)
        {
            ALShowError(ErrorMessage, "TO date should be greater than FROM date");
        }
        return false;
    }
}

//Function to ensure that only AlphaNumeric values are entered in the text box associated.
function ALValidate_AlphaNumeric(ControlID, ErrorMessage, ShowError)
{
    var ControlObject       = null;
    var Value               = null;
    var ReturnValue         = null;
    
    ControlObject = document.getElementById(ControlID);
    if (ControlObject == null)
        return false;
    
    if (ErrorMessage == "" || ErrorMessage == null)
        ErrorMessage = "Please enter an alpha-numeric value.";
    
    ReturnValue = ALIsValid(ControlObject.value, NumbValueStr+UprCharStr+LwrCharStr, ErrorMessage, ShowError);
    return ReturnValue;
}

//Function to ensure that only Alphabetic values are entered in the text box associated.
function ALValidate_Alphabetic(ControlID, ErrorMessage, ShowError)
{
    var ControlObject       = null;
    var Value               = null;
    var ReturnValue         = null;
    
    ControlObject = document.getElementById(ControlID);
    if (ControlObject == null)
        return false;
        
    if (ErrorMessage == "" || ErrorMessage == null)
        ErrorMessage = "Please enter an alphabetic value.";
    
    ReturnValue = ALIsValid(ControlObject.value, LwrCharStr+UprCharStr, ErrorMessage, ShowError);
    return ReturnValue;
}

//Function to ensure that the email address entered is a valid address.
function ALValidate_EmailAddress(ControlID, ErrorMessage, ShowError)
{
    var ControlObject   = null;
    var Value           = null;
    var RetrunValue     = null;
    var AtPos           = null;
    var SubStringArray  = null;
    var LoaclPart       = null;
    var DomainPart      = null;
    
    ControlObject = document.getElementById(ControlID);
    if (ControlObject == null)
        return false;
        
    if (ShowError != false)
        ShowError = true;
    
    Value = ControlObject.value;
    AtPos = -1;
    AtPos = Value.indexOf("@");
    
    //Will return false if the value does not contain @
    if ((AtPos == -1 || AtPos == "0"))
    {
        if (ShowError == true)
        {
            ALShowError(ErrorMessage, "Please enter a valid Email Address");
            ControlObject.focus();
        }        
        return false;
    }
    
    SubStringArray  = Value.split("@");
    // Will return false if the value contains more than on @.
    if (SubStringArray.length != 2)
    {
        if (ShowError == true)
        {
            ALShowError(ErrorMessage, "Please enter a valid Email Address");
            ControlObject.focus();
        }
        return false;
    }
    
    
    LocalPart       = SubStringArray[0];
    DomainPart      = SubStringArray[1];
    
    //Checking that the local part is restricted to the specifed character set.
    RetrunValue = ALIsValid(LocalPart, LwrCharStr+UprCharStr+NumbValueStr+LValidCharStr, "Please enter a valid email address", ShowError);
    if (RetrunValue == false)
        return false;
        
        
    //Will return false if email address doesnot contain "."
    if (DomainPart.indexOf(".") == -1)
    {
        if (ShowError == true)
        {
            ALShowError(ErrorMessage, "Please enter a valid Email Address");
            ControlObject.focus();
        }
        return false;
    }
    else
    {
        //Checking that the domain part is restricted to the specifed character set.
        RetrunValue = ALIsValid(DomainPart, LwrCharStr+UprCharStr+NumbValueStr+RValidCharStr, "Please enter a valid email address", ShowError);
        if (RetrunValue == false)
        {
            ControlObject.focus();
            return false;
        }
    }
    return true;
}


//Validate Range
//Validate_Numeric is used to check that the vlaues set for the field are numeric only.
function ALValidate_Numeric(ControlID, GroupingSeperatorSymbol, ErrorMessage, ShowError)
{
    var ControlObject           = null;
    var Value                   = null;
    var SignedValue             = null;
    var Value                   = null;
    var SubStringValues         = null;
    
    ControlObject = document.getElementById(ControlID);
    if (ControlObject == null)
        return false;
        
    if (ShowError != false)
        ShowError = true;
        
    SignedValue = ControlObject.value;
    if (SignedValue == '')
        return true;
        
    //Getting the +ve part of the value if the value entered is -ve.
    if (SignedValue.charAt(0) == '-')
        Value = SignedValue.substr(1);
    else
        Value = SignedValue;
        
    //Checking for spaces in the value.
    if (Value.indexOf(" ") != -1 || Value.indexOf(".") != -1 || Value == '')
    {
        if (ShowError == true)
        {
            ALShowError(ErrorMessage,"Please enter numeric values only");
            ControlObject.focus();
        }
        return false;
    }    
        
    //Setting default value for GroupingSeperatorSymbol if it is null or empty
    if (GroupingSeperatorSymbol == "" && GroupingSeperatorSymbol == null)
        GroupingSeperatorSymbol = ',';
        
    //Removing the grouping seperator symbol form the selected value
    SubStringArray = Value.split(GroupingSeperatorSymbol);
    
    Value = '';
    for (cnt = 0; cnt < SubStringArray.length; cnt++)
    {
        Value = Value + SubStringArray[cnt];
    }
    
    //Checking if the number is a numeric number or not
    if (isNaN(Value))
    {
        if (ShowError == true)
        {
            ALShowError(ErrorMessage,"Please enter numeric values only");
            ControlObject.focus();
        }
        return false;
    }
    return true;
}


//Validate_Float function is used to verify that the given value is of float type
function ALValidate_Float(ControlID, DecimalSeperatorSymbol, GroupingSeperatorSymbol, MaxAfterDecimal, ErrorMessage, ShowError)
{
    var ControlObject           = null;
    var Value                   = null;
    var SignedValue             = null;
    var Value                   = null;
    var SubStringValues         = null;
    var AfterDecimalValue       = null;
    
    ControlObject = document.getElementById(ControlID);
    if (ControlObject == null)
        return false;
        
    SignedValue = ControlObject.value;
    if (SignedValue == '')
        return true;
    
    if (ShowError != false)
        ShowError = true;
    
    //Getting the +ve part of the value if the value entered is -ve.
    if (SignedValue.charAt(0) == '-')
        Value = SignedValue.substr(1);
    else
        Value = SignedValue;
        
    //Setting default value for GroupingSeperatorSymbol if it is null or empty
    if (GroupingSeperatorSymbol == "" && GroupingSeperatorSymbol == null)
        GroupingSeperatorSymbol = ',';
        
    //Removing the grouping seperator symbol form the selected value
    SubStringArray = Value.split(GroupingSeperatorSymbol);
    
    Value = '';
    for (cnt = 0; cnt < SubStringArray.length; cnt++)
    {
        Value = Value + SubStringArray[cnt];
    }
    
    //Checking if the number is a numeric number or not
    if (isNaN(Value))
    {
        if (ShowError == true)
        {
            ALShowError(ErrorMessage,"Please enter floating value");
            ControlObject.focus();
        }
        return false;
    }
    
    //Setting default value for Decimal Seperator symbol if the value is not set.
    if (DecimalSeperatorSymbol == "" || DecimalSeperatorSymbol == null)
        DecimalSeperatorSymbol = ".";
    
    if (Value.indexOf(DecimalSeperatorSymbol) == -1)
    {
        if (ShowError == true)
        {
            ALShowError(ErrorMessage,"Please enter floating value");
            ControlObject.focus();
        }
        return false;
    }
    else
    {
        SubStringArray = '';
        SubStringArray = Value.split(DecimalSeperatorSymbol);
        AfterDecimalValue = SubStringArray[1];
        if (MaxAfterDecimal != "" && MaxAfterDecimal != null)
        {
            if (String(AfterDecimalValue).length > MaxAfterDecimal)
            {
                if (ShowError == true)
                {
                    ALShowError(ErrorMessage,"Value after decimal point is greater than permitted value");
                    ControlObject.focus();
                }
                return false;
            }
        }
    }
    return true;
}


// Function to check if the given value is in the specified range or not.

function ALValidate_Range(ControlID, MinValue, MaxValue, GroupingSeperatorSymbol, ErrorMessage, ShowError)
{
    var ControlObject   = null;
    var SignedValue     = null;
    var Value           = null;
    var SubstringArray  = null;
    var IsNumeric       = null;
    
    ControlObject = document.getElementById(ControlID);
    if (ControlObject == null)
        return false;
    
    if (ShowError != false)
        ShowError = true;
    
    SignedValue = ControlObject.value;
    if (SignedValue == '')
        return true;
    
    IsNumeric = ALValidate_Numeric(ControlID, GroupingSeperatorSymbol, ErrorMessage, ShowError)
    if (IsNumeric == false)
        return false;
    
    //Getting the +ve part of the value if the value entered is -ve.
    if (SignedValue.charAt(0) == '-')
        Value = SignedValue.substr(1);
    else
        Value = SignedValue;
    
    if (GroupingSeperatorSymbol == "" || GroupingSeperatorSymbol == null)
        GroupingSeperatorSymbol = ',';   //Setting ',' as the default GroupingSeperatorSymbol if not provided.
        
    SubstringArray = Value.split(GroupingSeperatorSymbol);
    
    
    //Removing GroupingSeperatorSymbol form the set value.
    Value = '';
    for (cnt=0; cnt<SubstringArray.length; cnt++)
    {
        Value = Value + SubstringArray[cnt];
    }
    
    if (SignedValue.charAt(0) == '-')
    {
        Value = '-' + Value;
    }
    
    //Checking if the value is less than the Minimum specified value
    if (MinValue != null && MinValue != '')
    {
        if (parseFloat(Value) < parseFloat(MinValue))
        {
            if (ShowError == true)
            {
                ALShowError(ErrorMessage, "Value is less than the Minimum specified");
                ControlObject.focus();
            }
            return false;
        }
    }
    
    
    //Checking if the value is greater than the Maximum specified value
    if (MaxValue != null && MaxValue != '')
    {
        if (parseFloat(Value) > parseFloat(MaxValue))
        {
            if (ShowError == true)
            {
                ALShowError(ErrorMessage, "Value is greater than the Maximum specified");
                ControlObject.focus();
            }
            return false;
        }
    }
    return true;
}


//Validate_Length function is used for checking that the vlue set to the field doesnot exceed the specified length.
function ALValidate_Length(ControlID, MaxLength, ErrorMessage, ShowError)
{
    var ControlObject   = null;
    var Value           = null;
    
    if (MaxLength == "" || MaxLength == null)
    { //Will return true if no max length is set.
        return true;
    }
    else
    {
        ControlObject = document.getElementById(ControlID);
        if (ControlObject == null) 
            return false;
            
        Value = ControlObject.value;
        if (String(Value).length > MaxLength)
        {
            if (ShowError == true)
            {
                ALShowError(ErrorMessage, "Length of the data exceeds the maximum permissible length");
                ControlObject.focus();
            }
            return false;
        }   
    }
    return true;
}


//This function is used for validating that some value is set to a field that mandatory
function ALValidate_Mandatory(ControlID, UIType, NotExpectedValue, ErrorMessage, ShowError)
{
    var ControlObject   = null;
    var Value           = null;
    var ItemCount       = null;
    
    ControlObject = document.getElementById(ControlID);
    if (ControlObject == null)
        return false;
    
    if (ShowError != false)
        ShowError = true;
    
    switch (UIType.toUpperCase())
    {
        //Check for dropdown list, that the default value is not selected by user.
        case "DROPDOWNLIST":
        {
            Value = ControlObject.value;
            if (Value == NotExpectedValue)
            {
                if(ShowError == true)
                {
                    ALShowError(ErrorMessage, "Please select a proper value");
                    ControlObject.focus();
                }
                return false;
            }
            return true;
        }
        // For Chckboxes atleast one value should be selecteed by the user
        case "CHECKBOXLIST":
        {
            var ObjectArray     = null;
            var DollarPos       = null;
            
            for(var i=0; i < document.forms[0].elements.length;i++)
            {
                items = document.forms[0].elements[i];
                temp = items.type;
                
                DollarPos = items.name.lastIndexOf("$");
                ObjectName  = items.name.substr(0, DollarPos);
                if ((temp == 'checkbox') && (ObjectName == ControlID))
                {
                    if (items.checked == true)
                    return true;
                }
            }
            if (ShowError == true)
            {
                ALShowError(ErrorMessage, "Please select a proper value");
            }
            return false;
        }
        // For Radiobuttons value should be selected by user.
        case "RADIOBUTTONLIST":
        {
            for(var i=0; i < document.forms[0].elements.length;i++)
            {
                items = document.forms[0].elements[i];
                temp = items.type;
                if ((temp == 'radio') && (items.name == ControlID))
                {
                    if (items.checked == true)
                    return true;
                }
            }
            if (ShowError == true)
            {
                ALShowError(ErrorMessage, "Please select a proper value");
            }
            return false;
        }
        // In case of other ui types an error will be given if no value is set to the control.
        default:
        {
            if (ControlObject.value == "")
            {
                if (ShowError == true)
                {
                    ALShowError(ErrorMessage, "Please fill all mandatory fields");
                    ControlObject.focus();
                }
                return false;
            }
            return true;
        }        
    }
}
//-------------------------------------------------ALPopupControl.js----------------------------------------------------------------------------

//Constant variables in the Java Script
var HiddentXPositionID = "_XPosition";
var HiddentYPositionID = "_YPosition";
var HiddenFloatingPopupIDList = "FloatingPopupIDList";
var HiddenProcessingHtm = "ProcessingHtm";

//To display new page in specified iframe
function ALRefeshPopupFrame(IframeContainerID, URL, Height, Width, doPageRefresh)
{
    IframeContainerDiv = document.getElementById(IframeContainerID);
    
    for(var i = 0; i < IframeContainerDiv.childNodes.length; i++)
        IframeContainerDiv.removeChild(IframeContainerDiv.childNodes[i]);
        
    IframeObj   = document.createElement("iframe");
    IframeContainerDiv.appendChild(IframeObj);
    
    IframeObj.src =  document.getElementById(HiddenProcessingHtm).value;
    if(IframeObj != null)
    {
        if((!(IframeObj.src == URL  || IframeObj.src == URL + "/")) || doPageRefresh)  
        {
            IframeObj.src          =  document.getElementById(HiddenProcessingHtm).value;
            ALPause(1);
                
            IframeObj.style.height = Height + "px";
            IframeObj.style.width  = (parseInt(Width) - 10) + "px";
            IframeObj.src = URL;
        }
    }
}

//To display new page DTML popup
function ALShowPopupUrlWindow(WindowID,X,Y,Height,Width,ShowSliding,showdimmer,isFloating,IframeContainerID,URL,doPageRefresh)
{
    ALShowPopupWindow(WindowID,X,Y,Height,Width,ShowSliding,showdimmer); //base control
    
    if(WindowID.indexOf("Div_") == 0)
        IframeContainerID = WindowID.replace("Div_","") + IframeContainerID; //Removing the first "Div_"
    
    ALRefeshPopupFrame(IframeContainerID, URL, Height, Width, doPageRefresh);
    if(isFloating)
        ALAddtoFloatingHandler(WindowID);
}

//To display floating popup
function ALShowPopupFloatingWindow(WindowID,X,Y,Height,Width,ShowSliding,showdimmer)
{
    ALShowPopupWindow(WindowID,X,Y,Height,Width,ShowSliding,showdimmer); //base control
    ALAddtoFloatingHandler(WindowID);
    
    XPositionhiddenInputID = WindowID.replace("Div_","") + HiddentXPositionID; 
    YPositionhiddenInputID = WindowID.replace("Div_","") + HiddentYPositionID;
    
    if(document.getElementById(XPositionhiddenInputID) != null)
        document.getElementById(XPositionhiddenInputID).value = X;
     
     if(document.getElementById(YPositionhiddenInputID) != null)
        document.getElementById(YPositionhiddenInputID).value = Y;
    
    //Base Control
    FunctionToExecuteonMove = "AlSetPosition(ALDragWindowID)";
}

//To add control to Floating Handler
function ALAddtoFloatingHandler(ControlID)
{
    if(document.getElementById(HiddenFloatingPopupIDList).value.indexOf(ControlID) < 0)
        document.getElementById(HiddenFloatingPopupIDList).value = document.getElementById(HiddenFloatingPopupIDList).value + ":" + ControlID;
    
    window.onscroll = ALSetFloatposition;    
}

//To set the floating position of the control
function ALSetFloatposition()
{
    ScrollX = document.documentElement.scrollLeft? document.documentElement.scrollLeft :document.body.scrollLeft;
    ScrollY = document.documentElement.scrollTop? document.documentElement.scrollTop :document.body.scrollTop;
    
    var FolatingControlIDArray = document.getElementById(HiddenFloatingPopupIDList).value.split(":");    
    
    for(i= 0; i< FolatingControlIDArray.length; i++)
    {
        if(FolatingControlIDArray[i] != "")
        {
           PopuControlObj = document.getElementById(FolatingControlIDArray[i]);
           
           if(PopuControlObj != null && PopuControlObj.style.position =='absolute')
           {
               XPositionhiddenInputID = FolatingControlIDArray[i].replace("Div_","") + HiddentXPositionID; 
               YPositionhiddenInputID = FolatingControlIDArray[i].replace("Div_","") + HiddentYPositionID;
               
               if(document.getElementById(XPositionhiddenInputID) != null)
                    PopuControlObj.style.left   = ScrollX + parseInt(document.getElementById(XPositionhiddenInputID).value) + "px";
               
               if(document.getElementById(YPositionhiddenInputID) != null)
                    PopuControlObj.style.top    = ScrollY + parseInt(document.getElementById(YPositionhiddenInputID).value) + "px";
          }
        }
    }
}

function AlSetPosition(ALDragWindowID)
{
    ALDragWindowObj = document.getElementById(ALDragWindowID)
    //To maintain the Floating Position in Move 
    XPositionhiddenInputID = ALDragWindowObj.id.replace("Div_","") + HiddentXPositionID; 
    YPositionhiddenInputID = ALDragWindowObj.id.replace("Div_","") + HiddentYPositionID;

    if(document.getElementById(XPositionhiddenInputID) != null)
        document.getElementById(XPositionhiddenInputID).value = ALDragWindowObj.style.left;

    if(document.getElementById(YPositionhiddenInputID) != null)
        document.getElementById(YPositionhiddenInputID).value = ALDragWindowObj.style.top;
}

//-------------------------------------------------ALTabJScript.js----------------------------------------------------------------------------
// JScript File

function ShowALTab(EventTarget, TabName, TabControlID)
 {
    //Previously Selected PageUniqueID
    PreviousSelectedTab = document.getElementById('SelectedTab_' + TabControlID);
    TabContainstToCache = document.getElementById('TabContainstToCache_' + TabControlID);
    
    HiddenPreviouslySelectedTabName = document.getElementById(TabControlID + '_hiddenPreviouslySelectedTabName');
    HiddenSelectedTabName           = document.getElementById(TabControlID + '_hiddenSelectedTabName');
    
    ClickedTabID = EventTarget.replace("Tab_","");
    if(PreviousSelectedTab.value == ClickedTabID)
        return;
        
    HiddenPreviouslySelectedTabName.value = HiddenSelectedTabName.value;
    HiddenSelectedTabName.value           = TabName;
    
    TabDiv = document.getElementById(ClickedTabID);
    if(TabDiv != null)
    {
        if(TabContainstToCache.value.indexOf("$" + ClickedTabID + "$") >= 0)
        {
            if(TabDiv.innerHTML.replace(/^\s*|\s(?=\s)|\s*$/g,"") == "")
            {
                __doPostBack(EventTarget,TabName);
                return;
            }
            else
             HighlightALTab(TabControlID, ClickedTabID);    
        }
        else
         __doPostBack(EventTarget,TabName);
    }
 }

 function HighlightALTab(TabControlID, ClickedTabID)
 {//debugger;
    PreviousSelectedTab     = document.getElementById('SelectedTab_' + TabControlID);
    PreviousSelectedTabID   = PreviousSelectedTab.value;
    
    if(ClickedTabID.indexOf('panel_FeaturesTab')<0)//if other than 'Features & Testcases' tab is clicked
    {
        var fgdiv=document.getElementById('fgdiv');//these both are defined in ProductAttributes.aspx
        var tcgdiv=document.getElementById('tcgdiv');
        if(fgdiv!=null)
        {
        fgdiv.style.visibility='hidden';   
            fgdiv.style.display='none';   
        }
        if(tcgdiv!=null)
        {
        tcgdiv.style.visibility='hidden';   
        tcgdiv.style.display='none';   
        }
    }
    if(ClickedTabID.indexOf('tab_grid')>0)//If either 'Features' or 'Testcases' tab is clicked.
    {
        var fgdiv=document.getElementById('fgdiv');//these both are defined in ProductAttributes.aspx
        var tcgdiv=document.getElementById('tcgdiv');
        if(fgdiv!=null)
        {
            if(ClickedTabID.indexOf('panel_FG')>0)
            {
                fgdiv.style.visibility='visible';   
                fgdiv.style.display='block';   
                tcgdiv.style.visibility='hidden';   
                tcgdiv.style.display='none';   
            }
            
        }
        if(tcgdiv!=null)
        {
            if(ClickedTabID.indexOf('panel_TCG')>0)
            {
                fgdiv.style.visibility='hidden';   
                fgdiv.style.display='none';   
                tcgdiv.style.visibility='visible';   
                tcgdiv.style.display='block';   
            }           
        }
    }
    if(PreviousSelectedTabID == ClickedTabID)
        return;
   
    TabSelectedon           = document.getElementById("Tabon_" + ClickedTabID);
    TabSelectedoff          = document.getElementById("Taboff_" + ClickedTabID);
    TabSelectedContainer    = document.getElementById(ClickedTabID);
    
    if(TabSelectedon == null || TabSelectedoff == null)
        return;

    var TabDivList = TabSelectedoff.parentNode.parentNode.getElementsByTagName("DIV");
    
    //Setting all the tabs off
    for(i= 0; i< TabDivList.length; i++)
    {   
        if(TabDivList[i].id != null && TabDivList[i].id != "" && TabDivList[i].id.indexOf("Tabon_" + TabControlID) == 0)
        {
            TabInstancedon          = document.getElementById(TabDivList[i].id);
            TabInstancedoff         = document.getElementById(TabDivList[i].id.replace("Tabon_","Taboff_"));
            TabInstancedContainer   = document.getElementById(TabDivList[i].id.replace("Tabon_",""));

            if(TabInstancedon != null && TabInstancedoff != null && TabInstancedContainer != null)
            {
                TabInstancedon.style.display         = 'none';
                TabInstancedoff.style.display        = 'block';
                TabInstancedContainer.style.display  = 'none';
                
                TabInstancedon.style.visibility         = 'hidden';
                TabInstancedoff.style.visibility        = 'visible';
                TabInstancedContainer.style.visibility  = 'hidden';
            }
        }
    }
    
     
    TabSelectedon.style.display         = 'block';
    TabSelectedoff.style.display        = 'none';
    TabSelectedContainer.style.display  = 'block';
    
    TabSelectedon.style.visibility         = 'visible';
    TabSelectedoff.style.visibility        = 'hidden';
    TabSelectedContainer.style.visibility  = 'visible';

    PreviousSelectedTab.value = ClickedTabID;
 }

//-------------------------------------------------BaseControl.js---------------------------------------------------------------------------
var PrevVisibleDivID='';
    var Action_Done = '';
    var PrevTRID='';        
    
    function DoNothing()
    {
        return;
    }
    
    function ShowPopup(e,WindowName,Action)
    {                              
        if (PrevVisibleDivID != '' )
        {
            var PrevDivID = document.getElementById(PrevVisibleDivID);
            PrevDivID.style.position ='absolute'; 
            PrevDivID.style.display  ='none';
            PrevDivID.style.overflow ='hidden';
        }
                    
        PrevVisibleDivID = WindowName;

        if( Action == 'OnClick')
        {
           Action_Done = 'MoreInfo';
        }      

        ShowWindow = document.getElementById(WindowName); 
        ShowWindow.style.display='block'; 	
            
        if ( navigator.appName == 'Netscape')
        {
            WindowWidth = document.body.clientWidth;
            WindowHeight = document.body.clientHeight;
        }
        else
        {
            WindowWidth = document.body.offsetWidth;
            WindowHeight = document.body.offsetHeight;
        }
        
        x = e.clientX + ShowWindow.offsetWidth;
        y = e.clientY + ShowWindow.offsetHeight;
        
       if(x > WindowWidth)
        {
            ShowWindow.style.left= (e.clientX + document.body.scrollLeft) - ShowWindow.offsetWidth + "px";
        }
        else
        {
            ShowWindow.style.left= e.clientX + document.body.scrollLeft + "px";
        }

        ShowWindow.style.top = parseInt(mouseY(e)) + "px";
    }

     function HidePopup (WindowName)
     {
            var PrevDivID = document.getElementById(WindowName);
            PrevDivID.style.position ='absolute'; 
            PrevDivID.style.display  ='none';
            PrevDivID.style.overflow ='hidden';
     }  


    function mouseY(evt) 
    {
        if (evt.pageY)
        { 
         return evt.pageY;
        }
        else if (evt.clientY)
        { 
         return evt.clientY + (document.documentElement.scrollTop? document.documentElement.scrollTop :document.body.scrollTop); 
        } 
        else return 0;
    }

    function mouseX(evt) 
    {
        if (evt.pageX) 
        {
            return evt.pageX;
        }
        else if (evt.clientX)
        {
            return evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
        }
        else return 0;
    }
        
    if (document.addEventListener) 
    {
       document.addEventListener('mouseup',Form_MouseUp,false);
    }
    else if (document.attachEvent)
    {
        document.attachEvent('on'+'mouseup',Form_MouseUp,false);
    }

    function Form_MouseUp()
     {
        if ( Action_Done == 'DragDrop')
         {
            if(isdrag==true)
             {
                ShowAlert("Alert_BaseCtrl_DropInValidPosition");
             }
            if(DivNode!=null)
             {
               DivNode.innerHTML="";
               DivNode.style.display="none";
              }
              cleanup();
         }
         else
         {
           if(Action_Done == 'MoreInfo')
             {    
              if(PrevVisibleDivID != '')
               {
                    var PrevDivID = document.getElementById(PrevVisibleDivID);
                    PrevDivID.style.position ='absolute';
                    PrevDivID.style.display  ='none';
                    PrevDivID.style.overflow ='hidden';
                }
             }
          } 
        Action_Done = '';
      }


//-------------------------------------------------Binder.js----------------------------------------------------------------------------
function HandleUpload(URL)
{
    X = document.body.offsetWidth / 2;
    X -= (800 / 2);
    X += 100; //Left Pane

    Y = document.body.offsetHeight / 2;
    Y -= (400 / 2);

    window.open(URL,'','top='+Y+'px,left='+X+'px,resizable=1,width=800,height=400,scrollbars=1,status=1');
}

function BinderHandleListDeletes(ButtonId,MessageIdForNoSelection,ConfirmMessageId,CheckBoxName)
{
        var count           = 0;
        var temp            = '';
        var ItemFound       = -1;
        var SelectedItem    = '';
        var items;
        var index;
            
        
        for(var i=0; i < document.forms[0].elements.length;i++)
        {
            items   = document.forms[0].elements[i];
            temp    = items.type; 

            if ((temp == 'checkbox') && (items.checked) && (items.name.indexOf(CheckBoxName)!=-1))
            {
                if(items.value != 'SelectAll')
                {
                    SelectedItem = SelectedItem + items.value + '$AL$' ;
                    count+=1;
                }
            }
            ItemFound = -1;
        }
       
        if(count < 1)
        {
            ShowAlert(MessageIdForNoSelection);
            return;
        }                             
        
        else  
        {   
            if (ShowConfirm(ConfirmMessageId) == true)
                __doPostBack(ButtonId,SelectedItem);	 		
        }
}




//-------------------------------------------------BlankSection.js----------------------------------------------------------------------------
 var slideSpeed_BS = 20;	// Higher value = faster
 var timer_BS = 1;	// Lower value = faster

    function HandleDiv_BS(ExpandModeDiv, CollapseModeDiv)
    {
        var numericId = 0;
        var ExpandDiv = document.getElementById(ExpandModeDiv);
	    HandleDiv_BS1(ExpandModeDiv, CollapseModeDiv);
        if(!ExpandDiv.style.display || ExpandDiv.style.display=='none')
        {
            ExpandDiv.style.display='block';
            ExpandDiv.style.visibility = 'visible';
            ExpandDiv.style.position = '';
            ExpandDiv.style.height = document.getElementById(CollapseModeDiv).offsetHeight + 'px';

            slideContent_BS(ExpandModeDiv, ExpandModeDiv, CollapseModeDiv, slideSpeed_BS, 1);
    		
            document.getElementById(CollapseModeDiv).style.visibility='hidden';
            document.getElementById(CollapseModeDiv).style.position='absolute';
            document.getElementById(CollapseModeDiv).style.display='none';
            document.getElementById(CollapseModeDiv).style.overflow='hidden';	
        }
        else
        {
            slideContent_BS(ExpandModeDiv, CollapseModeDiv, ExpandModeDiv, (slideSpeed_BS*-1), 1);
        }	
    }

    function slideContent_BS(SlidingDiv, ToShowDiv, ToHideDiv, direction, numTime)
    {
        var obj =document.getElementById(SlidingDiv);
        var contentObj = document.getElementById(SlidingDiv+'_Content');
        
        if ( numTime == 1 )
        {
            if ( obj.clientHeight == 0 )
                height = contentObj.offsetHeight;
            else
                height = obj.clientHeight;
        }
        else
            height = obj.clientHeight;
        
        height = height + direction;
        rerunFunction = true;
        if(height>contentObj.offsetHeight)
        {
            height = contentObj.offsetHeight;
            rerunFunction = false;
        }
        if (direction >0 )  //Expanding
        {
            RHSHeight = 1;
            if(height<=RHSHeight)
            {
                height = 1;
                rerunFunction = false;
            }
        }
        else  //Collapsing
        {
            PrevDisplay = document.getElementById(ToShowDiv).style.display;
            document.getElementById(ToShowDiv).style.display='block';
            RHSHeight =parseInt(document.getElementById(ToShowDiv+'_Content').offsetHeight); 
            if(height<=RHSHeight)
            {
                height = RHSHeight;
                document.getElementById(ToHideDiv).style.visibility='hidden';
                document.getElementById(ToHideDiv).style.position='absolute';
                document.getElementById(ToHideDiv).style.display='none';
                document.getElementById(ToHideDiv).style.overflow='hidden';
    				
                document.getElementById(ToShowDiv).style.visibility='visible';
                document.getElementById(ToShowDiv).style.position='';
                document.getElementById(ToShowDiv).style.display='block';
                document.getElementById(ToShowDiv).style.overflow='visible';
                rerunFunction = false;
            }
            else
                document.getElementById(ToShowDiv).style.display=PrevDisplay;
        }

        obj.style.height = height + 'px';
        var topPos = height - contentObj.offsetHeight;
        if(topPos>0)topPos=0;
        contentObj.style.top = topPos + 'px';
        if(rerunFunction)
        {
            setTimeout('slideContent_BS(\'' + SlidingDiv + '\',\'' + ToShowDiv + '\',\'' + ToHideDiv + '\',' + direction + ',2)',timer_BS);
        }
        else
        {
            if(height<=RHSHeight)
            {
                obj.style.display='none'; 
                obj.style.height = '';
            }
            else
            {
                document.getElementById(ToHideDiv).style.visibility='hidden';
                document.getElementById(ToHideDiv).style.position='absolute';
                document.getElementById(ToHideDiv).style.display='none';
                document.getElementById(ToHideDiv).style.overflow='hidden';
    				
                document.getElementById(ToShowDiv).style.visibility='visible';
                document.getElementById(ToShowDiv).style.position='';
                document.getElementById(ToShowDiv).style.display='block';
                document.getElementById(ToShowDiv).style.overflow='hidden';
                obj.style.height = '';
            }
        }
    }

    function HandleDiv_BS1(ExpandModeDiv, CollapseModeDiv)
    {
        if (document.getElementById(ExpandModeDiv).style.visibility == 'visible')
        {
            document.getElementById(CollapseModeDiv).style.visibility='hidden';
            document.getElementById(CollapseModeDiv).style.position='absolute';
            document.getElementById(CollapseModeDiv).style.display='none';
            document.getElementById(CollapseModeDiv).style.overflow='hidden';

            document.getElementById(ExpandModeDiv).style.visibility='visible';
            document.getElementById(ExpandModeDiv).style.position='';
            document.getElementById(ExpandModeDiv).style.display='block';
            document.getElementById(ExpandModeDiv).style.overflow='hidden';
        }
        else
        {
            if (document.getElementById(ExpandModeDiv).style.visibility == 'hidden')
            {
                document.getElementById(ExpandModeDiv).style.visibility='hidden';
                document.getElementById(ExpandModeDiv).style.position='absolute';
                document.getElementById(ExpandModeDiv).style.display='none';
                document.getElementById(ExpandModeDiv).style.overflow='hidden';
    				
                document.getElementById(CollapseModeDiv).style.visibility='visible';
                document.getElementById(CollapseModeDiv).style.position='';
                document.getElementById(CollapseModeDiv).style.display='block';
                document.getElementById(CollapseModeDiv).style.overflow='hidden';
            }
        }
    }





//-------------------------------------------------Validators.js----------------------------------------------------------------------------
// JScript File

function RTrim(str)
{
	if(str==null)
		return null;
	for(var i=str.length-1;str.charAt(i)==" ";i--);
	return str.substring(0,i+1);
}

function LTrim(str, char_to_remove)
{
	if(str==null)
		return null;
	for(var i=0;str.charAt(i)==char_to_remove;i++);
	return str.substring(i,str.length);
}

function Validate_Mandatory(Control_id, ErrorMessage, UIType, Value_Not_Expected)
{
    Value_Not_Expected = DecodeSpecialCharactersForJS(Value_Not_Expected);
    if(UIType == 'CALENDAR')
    {
        Control_id  = Control_id + '_CAL_DATE_TxtDate';
        
        
        /*var ObjFound = false;
        for(i=0;i<document.forms[0].elements.length;i++)
        {
            var tempobj = document.forms[0].elements[i];
            if(tempobj.id.search(Control_id) != -1)
            {
                ObjFound = true;
                Control_id = tempobj.id;
                break;
            }
        }
        
        if(ObjFound == false)
            return false;*/
        
        
        var ControlObj = document.getElementById(Control_id);
        if(ControlObj == null)
            return false;
            
        if(ControlObj.value == '' || ControlObj.value == null)
        {
            ShowError(ErrorMessage, 'Alert_EnterAllMandatoryFields_Shared');
            return false
        }
        return true;
    
    }else
    if (UIType == 'RANGECALENDAR')
    {
        var Control_id_From  = Control_id + '_TxtDateFrom';
        
        var ControlObjFrom = document.getElementById(Control_id_From);

        if(ControlObjFrom == null)
            return false;
        
        if(ControlObjFrom.value == '' || ControlObjFrom.value == null)
        {
            ShowError(ErrorMessage, 'Alert_EnterAllMandatoryFields_Shared');
            return false;
        }
        
        Control_id_To  = Control_id + '_TxtDateTo';
        var ControlObjTo = document.getElementById(Control_id_To);

        if(ControlObjTo == null)
            return false;

       if(ControlObjTo.value == '' || ControlObjTo.value == null)
        {
            ShowError(ErrorMessage, 'Alert_EnterAllMandatoryFields_Shared');
            return false;
        }
        return true;
    }
    else
    if(UIType == 'EDITBOX' || UIType == 'TEXTAREA' || UIType == 'CURRENCY')
    {

        var ControlObj = document.getElementById(Control_id);
        
        if(ControlObj == null)
            return false;
        
        var Trimmed_val = RTrim(ControlObj.value);

        if(Trimmed_val == '')
        {
            ShowError(ErrorMessage, 'Alert_EnterAllMandatoryFields_Shared');
            //try catch block putin because if the section containing the mandatory field is hidden then focus() method gives a javascript error.
            try
            {
                ControlObj.focus();
                ControlObj.value = '';
            }
            catch (e)
            {            
            }            
            return false;
        }
        return true;
    }else
    if(UIType == 'DROPDOWNLIST')
    {
        var ControlObj = document.getElementById(Control_id);
        
        if(ControlObj == null)
            return false;

        if ((ControlObj.value.toLowerCase()) == (Value_Not_Expected.toLowerCase()) || ControlObj.value == "")
        {
            ShowError(ErrorMessage, 'Alert_EnterAllMandatoryFields_Shared');
            ControlObj.focus();
            return false;
        }
        return true;
    }else
    if (UIType == 'MULTISELECT')
    {
        //var ControlDivObj = document.getElementById("Form_MS_Div_" + Control_id);
        var ControlHiddenObj = document.getElementById(Control_id);
        
        //if (ControlDivObj == null && ControlHiddenObj == null)
        if (ControlHiddenObj == null)
            return false;
        
        //if (ControlDivObj.innerHTML == '' && ControlHiddenObj.value == '')            
        if (ControlHiddenObj.value == '')        
        {
            ShowError(ErrorMessage, 'Alert_EnterAllMandatoryFields_Shared');
            return false;        
        }
        return true;
    }
    else
    if (UIType == 'BINDER' || UIType == 'FILEBINDER' || UIType == 'LISTCONTROL')
    {
        var ControlHiddenObj = document.getElementById(Control_id);        

        if (ControlHiddenObj == null)
            return false;
        
        if (parseInt(ControlHiddenObj.value) <= 0)        
        {            
            ShowError(ErrorMessage, 'Alert_EnterAllMandatoryFields_Shared');
            return false;        
        }
        return true;
    }
    else
    if(UIType == 'RADIOBUTTON')
    {
        var RBSelected = false;
        
        for(var i=0; i < document.forms[0].elements.length;++i)
        {
            var item = document.forms[0].elements[i];

            if ((item.type == 'radio') && (item.name.indexOf(Control_id) > 0) && (item.checked))
            {
                    RBSelected = true;
                    break;
            }
        }
        
        if (RBSelected == false)
        {
            ShowAlert('Alert_EnterAllMandatoryFields_Shared');
            return false;
        }
        return true;
    }
    else
    if(UIType == 'CHECKBOX')
    {
        var CBSelected = false;
        
        for(var i=0; i < document.forms[0].elements.length;++i)
        {
            var item = document.forms[0].elements[i];

            if ((item.type == 'checkbox') && (item.name.indexOf(Control_id) > 0) && (item.checked))
            {
                    CBSelected = true;
                    break;
            }
        }
        
        if (CBSelected == false)
        {
            ShowAlert('Alert_EnterAllMandatoryFields_Shared');
            return false;
        }
        return true;
    }
    if (UIType == 'DATERANGE' )
    {
        var tempControl_id;
       
        tempControl_id = Control_id + '_TxtDateFrom';
        
        var ControlObj = document.getElementById(tempControl_id);
        if(ControlObj == null)
            return false;
            
        if(ControlObj.value == '' || ControlObj.value == null)
        {
            ShowError(ErrorMessage, 'Alert_EnterAllMandatoryFields_Shared');
            return false
        }
        
        tempControl_id = Control_id + '_TxtDateTo';
        
        var ControlObj = document.getElementById(tempControl_id);
        if(ControlObj == null)
            return false;
            
        if(ControlObj.value == '' || ControlObj.value == null)
        {
            ShowError(ErrorMessage, 'Alert_EnterAllMandatoryFields_Shared');
            return false
        }
        
        return true;
    }
    
    if (UIType == 'TEXTRANGE' )
    {
        var tempControl_id;
        tempControl_id = Control_id + '_TextFrom';
        var ControlObj = document.getElementById(tempControl_id);
        
        if(ControlObj == null)
            return false;
           
        if(ControlObj.value == '' || ControlObj.value == null)
        {
            ShowError(ErrorMessage, 'Alert_EnterAllMandatoryFields_Shared');
            ControlObj.focus();
            return false
        }
        
        tempControl_id = Control_id + '_TextTo';
        
        var ControlObj = document.getElementById(tempControl_id);
        
        if(ControlObj == null)
            return false;
            
        if(ControlObj.value == '' || ControlObj.value == null)
        {
            ShowError(ErrorMessage, 'Alert_EnterAllMandatoryFields_Shared');
             ControlObj.focus();
            return false
        }
        
        return true;
    }
    else
    if(UIType == 'USERNAMESUGGESTIONBOX')
    {
        Control_id  = "Value_" + Control_id;
        var ControlObj = document.getElementById(Control_id);
        
        if(ControlObj == null)
            return false;

        if (ControlObj.value == "0")
        {
            ShowError(ErrorMessage, 'Alert_EnterAllMandatoryFields_Shared');
            ControlObj.focus();
            return false;
        }
        return true;
    }
}
function Validate_Numeric_ReportForm(Control_id, ErrorMessage, Grouping_Separator_Symbol, UIType)
{
    if(UIType != 'TEXTRANGE')
    {
        var ControlObj = document.getElementById(Control_id);
        
        if(ControlObj == null)
            return false;

        var CurrText = ControlObj.value;

        if(CurrText == '')
            return true;

    //    var temp_arr = CurrText.split(Grouping_Separator_Symbol);
    //    
    //    for(i = 0; i < temp_arr.length; i++)
    //    {
    //        var temp_int = temp_arr[i];
    //        
    //        if(isNaN(temp_int))
    //        {
    //            ShowError(ErrorMessage, 'Alert_EnterNumericValue_Shared');
    //            ControlObj.focus();
    //            return false;
    //        }
    //      
    //        if(temp_arr[i].length != String(parseInt(temp_int)).length)
    //        {
    //            ShowError(ErrorMessage, 'Alert_EnterNumericValue_Shared');
    //            ControlObj.focus();
    //            return false;
    //        }
    //    }

        if(!IsNumeric(CurrText, ErrorMessage, Grouping_Separator_Symbol))
        {
            ControlObj.focus();
            return false;
        }
    }else
    {
        var Control_From = document.getElementById(Control_id + "_TextFrom");
        var Control_To = document.getElementById(Control_id + "_TextTo");
        
        if(Control_From != null || Control_To != null)
        {
            var CurrText = Control_From.value;

            if(CurrText != '')
            {
                if(!IsNumeric(CurrText, ErrorMessage, Grouping_Separator_Symbol))
                {
                    Control_From.focus();
                    return false;
                }
            }
            
            CurrText = Control_To.value;
            if(CurrText != '')
            {
                if(!IsNumeric(CurrText, ErrorMessage, Grouping_Separator_Symbol))
                {
                    Control_To.focus();
                    return false;
                }
            }
        }else
        {
            ShowError(ErrorMessage, 'Alert_EnterNumericValue_Shared');
            return false;
        }
    }
    
    
    return true;
}

function Validate_Numeric(Control_id, ErrorMessage, Grouping_Separator_Symbol, EventObj)
{
    var ControlObj = document.getElementById(Control_id);
    //if(Grouping_Separator_Symbol == "")
    //    Grouping_Separator_Symbol = ',';
    
    if(ControlObj == null)
        return false;

    var CurrText = ControlObj.value;
    var tempCurrText;

    if(CurrText == '')
        return true;

    if(CurrText.charAt(0) == '-')
    {
        tempCurrText = CurrText.substr(1);
        if(tempCurrText == '' && EventObj == null)
        {
            ShowError(ErrorMessage, 'Alert_EnterNumericValue_Shared');
            ControlObj.focus();
            ControlObj.value = '';
            return false;
        }
    }
    else
    {
        if(isNaN(CurrText))
        {
            ShowError(ErrorMessage, 'Alert_EnterNumericValue_Shared');                    
            ControlObj.focus();
            ControlObj.value = "";                    
            return false;  
        }                
    }
//        CurrText = CurrText.substr(1);

    //Check for spaces in a numeric value.
    if (CurrText.indexOf(" ") != -1 || CurrText.indexOf(".") != -1)
    {
        ShowError(ErrorMessage, 'Alert_EnterNumericValue_Shared');
        ControlObj.focus();
        ControlObj.value = '';        
        return false;
    }

    var temp_arr = CurrText.split(Grouping_Separator_Symbol);
    
    for(i = 0; i < temp_arr.length; i++)
    {
        var temp_int = temp_arr[i];
        if (i == 0 && temp_int == '-')
        {
            continue;
        }
        else
        {
            if(isNaN(temp_int))
            {
                ShowError(ErrorMessage, 'Alert_EnterNumericValue_Shared');
                ControlObj.focus();
                ControlObj.value = '';
                
                return false;
            }
        }
//        if(temp_arr[i].length != String(temp_int).length)
//        {
//            ShowError(ErrorMessage, 'Alert_EnterNumericValue_Shared');
//            ControlObj.focus();
//            
//            if(!isNaN(parseInt(CurrText)))
//            {
//                ControlObj.value = parseInt(CurrText)
//            }
//            else
//            {
//                ControlObj.value = "";
//            }      
//            return false;
//        }
    }    
    return true;
}


function IsNumeric(Value, ErrorMessage, Grouping_Separator_Symbol)
{
    var temp_arr = Value.split(Grouping_Separator_Symbol);
    
    for(i = 0; i < temp_arr.length; i++)
    {
        var temp_int = temp_arr[i];
        
        if(isNaN(temp_int))
        {
            ShowError(ErrorMessage, 'Alert_EnterNumericValue_Shared');
            return false;
        }
      
        if(temp_arr[i].length != String(parseInt(temp_int)).length)
        {
            ShowError(ErrorMessage, 'Alert_EnterNumericValue_Shared');
            return false;
        }
    }
    
    return true;
}

function Validate_AlphaNumeric(Control_id, ErrorMessage)
{
    var ControlObj = document.getElementById(Control_id);
    
    if(ControlObj == null)
        return false;

    var CurrText = ControlObj.value;

    for(i = 0; i < CurrText.length; i++)
    {
        if((CurrText.charCodeAt(i) < 97 || CurrText.charCodeAt(i) > 122) && (CurrText.charCodeAt(i) < 65 || CurrText.charCodeAt(i) > 90) && (CurrText.charCodeAt(i) < 48 || CurrText.charCodeAt(i) > 57))
        {        
            ShowError(ErrorMessage, 'Alert_EnterAlphaNumericValue_Shared');
            ControlObj.focus();
            return false;
        }
    }
    return true;
}

function Validate_Alphabetic(Control_id, ErrorMessage)
{
    var ControlObj = document.getElementById(Control_id);
    
    if(ControlObj == null)
        return false;

    var CurrText = ControlObj.value;

    for(i = 0; i < CurrText.length; i++)
    {
        if((CurrText.charCodeAt(i) < 97 || CurrText.charCodeAt(i) > 122) && (CurrText.charCodeAt(i) < 65 || CurrText.charCodeAt(i) > 90))
        {        
            ShowError(ErrorMessage, 'Alert_EnterAlphabeticValues_Shared');
            ControlObj.focus();
            return false;
        }
    }
    return true;
}
function Validate_SpecialCharacters(Control_id, ErrorMessage)
{
    var ControlObj = document.getElementById(Control_id);
    
    if(ControlObj == null)
        return false;
    
    var CurrText = ControlObj.value;
}
function Validate_EmailAddress(Control_id, ErrorMessage)
{
    
    var ControlObj = document.getElementById(Control_id);
    
    if(ControlObj == null)
        return false;

    var email_id = ControlObj.value;
    email_id = LTrim(email_id,' ');
    email_id = RTrim(email_id);
	
	if (email_id == '')
        return true;
	
	var i,ch;
	var ampPos = -1,dotFlag=0,charFound=0 ,strLength=0,prDotPos=0;// ,dotCount=0;	
	
	strLength = email_id.length;
	ampPos    = email_id.indexOf("@"); 
	 
    if ((ampPos == -1) || (ampPos == 0) || (email_id.lastIndexOf("@") == (strLength - 1)))
    {
        ShowError(ErrorMessage, 'Alert_EnterValidEmailAddress_Shared');
        ControlObj.focus();
        return false;
    }
    else if ((email_id.indexOf(".") == -1) || (email_id.indexOf(".") == 0) || (email_id.lastIndexOf(".") == (strLength - 1)))
    {
        ShowError(ErrorMessage, 'Alert_EnterValidEmailAddress_Shared');
        ControlObj.focus();
        return false;
    }
    else if (email_id.search(" ")!= -1 )
    {
        ShowError(ErrorMessage, 'Alert_EnterValidEmailAddress_Shared');
        ControlObj.focus();
        return false;
    }
    else if( ampPos < (strLength - 2))		 
    {
        leftStr = email_id.substr(0,ampPos);	
		LleftStr =  leftStr.toLowerCase();
	
		rightStr = email_id.substr(ampPos+1);
		LrightStr = rightStr.toLowerCase();
	
	    //Reffer Bugzilla BugID = 1137 for more details.
		LValidCharStr = "abcdefghijklmnopqrstuvwxyz1234567890._!#$%&'*+-/=?^`{|}~%";
		RValidCharStr = "abcdefghijklmnopqrstuvwxyz1234567890._!#$%&'*+-/=?^`{|}~%";
		
		for (var i = 0; i < LleftStr.length; i++)
		{
		    if ( LValidCharStr.indexOf(LleftStr.charAt(i)) == -1) 
		    {
                ShowError(ErrorMessage, 'Alert_EnterValidEmailAddress_Shared');
                ControlObj.focus();
                return false;
		    }
		}
		
		if(LrightStr.indexOf(".") == -1)
		{
            ShowError(ErrorMessage, 'Alert_EnterValidEmailAddress_Shared');
            ControlObj.focus();
            return false;
		}
		
			
		prDotPos = 0;
		for (var i = 0; i < LrightStr.length; i++)
		{
		    if ( RValidCharStr.indexOf(LrightStr.charAt(i)) == -1) 
		    {
                ShowError(ErrorMessage, 'Alert_EnterValidEmailAddress_Shared');
                ControlObj.focus();
                return false;
		    } 
		    else if (LrightStr.charAt(i) == ".")
		    {
//              Refer Bug Id : 3764		    
//              Note: The following block has been commented since the domain in email address may contain dot (.) more than twice. _
//		              The check is already there to have at least one dot (.) in email domain, so the following block is commented
//                    e.g. margaret.sutor@scotland.gsi.gov.uk is a valid address  
//		        dotCount = (dotCount+1) ;
//		        if (dotCount > 2)
//		        {
//                    ShowError(ErrorMessage, 'Alert_EnterValidEmailAddress_Shared');
//                    ControlObj.focus();
//                    return false;
//	            }
		        dotLeft  = LrightStr.substring(prDotPos , i);
		        dotRight = LrightStr.substring(i);
    			prDotPos = (i+1);
		        if ((dotLeft == "") || (dotRight == ""))
		        {
                    ShowError(ErrorMessage, 'Alert_EnterValidEmailAddress_Shared');
                    ControlObj.focus();
                    return false;
		        }
		    }
		}
		return true;
    }	
    else
    {
        ShowError(ErrorMessage, 'Alert_EnterValidEmailAddress_Shared');
        ControlObj.focus();
        return false;
    }
}




function Validate_Range(Control_id, ErrorMessage, Grouping_Separator_Symbol, min_value, max_value)
{
    var ControlObj = document.getElementById(Control_id);
    //if(Grouping_Separator_Symbol == "")
    //    Grouping_Separator_Symbol = ',';
    
    
    if(ControlObj == null)
        return false;
    
    var CurrText_signed = ControlObj.value
    if(CurrText_signed == '')
        return true;
    
    if(CurrText_signed.charAt(0) == '-')
        CurrText = CurrText_signed.substr(1);
    else
        CurrText = CurrText_signed;
        
    var temp_arr = CurrText.split(Grouping_Separator_Symbol);
    
    CurrText = '';
    for(i=0; i<temp_arr.length; i++)
    {
        CurrText = CurrText + temp_arr[i];
    }
    
    
    if(CurrText_signed.charAt(0) == '-')
    {
        var temp = CurrText;
        CurrText = '-';
        CurrText = CurrText + temp;
    }
    

    if(min_value != null && min_value != '')
    {
        if(parseFloat(CurrText) < parseFloat(min_value))
        {
            ShowError(ErrorMessage, 'Alert_NumberOutOfRange_Shared');
            ControlObj.focus();
            return false;
        }        
    }

    if(max_value != null && max_value != '')
    {
        if(parseFloat(CurrText) > parseFloat(max_value))
        {
            ShowError(ErrorMessage, 'Alert_NumberOutOfRange_Shared');
            ControlObj.focus();
            return false;
        }    
    }
    return true;
}


function Validate_Length(Control_id, ErrorMessage, max_length)
{
    var ControlObj = document.getElementById(Control_id);
    
    if(ControlObj == null)
        return false;
    
    var CurrText = ControlObj.value
    
    if(max_length != '' && max_length != null)
    {
        if(CurrText.length > max_length)
        {
            ShowError(ErrorMessage, 'Alert_LengthMoreThanExpected_Shared');
            ControlObj.focus();
            return false;
        }
    }
    return true;
}

function ShowError(ErrorMessageId_Param, My_ErrorMessageId)
{
    if(ErrorMessageId_Param == null || ErrorMessageId_Param == '')
        ShowAlert(My_ErrorMessageId);
    else
        ShowAlert(ErrorMessageId_Param);
}

/*
function Validate_Date_Mandatory(Control_id, ErrorMessage)
{
    Control_id  = Control_id + '_CAL_DATE_TxtDate';
    
    
    var ObjFound = false;
    for(i=0;i<document.forms[0].elements.length;i++)
    {
        var tempobj = document.forms[0].elements[i];
        if(tempobj.id.search(Control_id) != -1)
        {
            ObjFound = true;
            Control_id = tempobj.id;
            break;
        }
    }
    
    if(ObjFound == false)
        return false;
    
    
    var ControlObj = document.getElementById(Control_id);
    if(ControlObj == null)
        return false;
        
    if(ControlObj.value == '' || ControlObj.value == null)
    {
        ShowError(ErrorMessage, 'Date Cannot be Empty');
        return false;
    }
    return true;
}
*/

function Validate_Date(Control_id, ErrorMessage)
{
    Control_id  = Control_id + '_CAL_DATE_TxtDate';
    
    var ControlObj = null;
    for(i=0;i<document.forms[0].elements.length;i++)
    {
        var tempobj = document.forms[0].elements[i];
        if(tempobj.id.search(Control_id) != -1)
        {
            ControlObj = tempobj;
            break;
        }
    }
    
    if(ControlObj == null)
        return false;

    var Todays_Date = new Date();
    
    var CurrText = ControlObj.value;
    
    if(CurrText == '' || CurrText == null)
        return true;
    
    var DaySelected = CurrText.split(' ')[0];
    var MonthSelected = CurrText.split(' ')[1];
    var YearSelected = CurrText.split(' ')[2];
    
    MonthSelected = GetMonthValue(MonthSelected);


    if(Todays_Date.getFullYear() < YearSelected)
        return true;
    else
    if(Todays_Date.getFullYear() == YearSelected)
    {
        if(Todays_Date.getMonth() < parseInt(MonthSelected))
            return true;
        else
        if(Todays_Date.getMonth() == parseInt(MonthSelected))
        {
            if(Todays_Date.getDate() > parseInt(DaySelected))
            {
                ShowError(ErrorMessage, 'Alert_InvalidDate_Shared');
                ControlObj.focus();
                return false;                
            }
            return true;
        }else
        {
            ShowError(ErrorMessage, 'Alert_InvalidDate_Shared');
            ControlObj.focus();
            return false;
        }
    }else
    {
        ShowError(ErrorMessage, 'Alert_InvalidDate_Shared');
        ControlObj.focus();
        return false;    
    }
}


function Validate_Date_Range(Control_id_from, Control_id_to, ErrorMessage)
{
    Control_id_from  = Control_id_from + '_CAL_DATE_TxtDate';
    Control_id_to  = Control_id_to + '_CAL_DATE_TxtDate';
    
    var ControlObj_from = null;
    var ControlObj_to = null;
    
    for(i=0;i<document.forms[0].elements.length;i++)
    {
        var tempobj = document.forms[0].elements[i];
        if(tempobj.id.search(Control_id_from) != -1)
        {
            ControlObj_from = tempobj;
            
            if(ControlObj_to != null)
                break;
            
        }else
        if(tempobj.id.search(Control_id_to) != -1)
        {
            ControlObj_to = tempobj;
            
            if(ControlObj_from != null)
                break;
        }
    }
    
    if(ControlObj_to == null || ControlObj_from == null)
        return false;

    var Day_from = ControlObj_from.value.split(' ')[0];
    var Month_from = ControlObj_from.value.split(' ')[1];
    var Year_from = ControlObj_from.value.split(' ')[2];
    
    Month_from = GetMonthValue(Month_from);
    
    var Day_to = ControlObj_to.value.split(' ')[0];
    var Month_to = ControlObj_to.value.split(' ')[1];
    var Year_to = ControlObj_to.value.split(' ')[2];
    
    Month_to = GetMonthValue(Month_to);

    if(Year_from < Year_to)
        return true;
    else
    if(Year_from == Year_to)
    {
        if(Month_from < Month_to)
            return true;
        else
        if(Month_from == Month_to)
        {
            if(Day_from > Day_to)
            {
                ShowError(ErrorMessage, 'Alert_InvalidDate_Shared');
                ControlObj.focus();
                return false;                
            }
            return true;
        }else
        {
            ShowError(ErrorMessage, 'Alert_InvalidDate_Shared');
            ControlObj.focus();
            return false;
        }
    }else
    {
        ShowError(ErrorMessage, 'Alert_InvalidDate_Shared');
        ControlObj.focus();
        return false;    
    }
}

function Validate_RangeCalendar_DateRange(Control_id)
{
    var Control_id_from  = Control_id + '_TxtDateFrom';
    var Control_id_to  = Control_id + '_TxtDateTo';
    var ControlObj_from = null;
    var ControlObj_to = null;
    var ErrorMessage = 'Alert_EnterValidDateRange_Shared';
    
    for(i=0;i<document.forms[0].elements.length;i++)
    {
        var tempobj = document.forms[0].elements[i];
        if(tempobj.id.search(Control_id_from) != -1)
        {
            ControlObj_from = tempobj;
            
            if(ControlObj_to != null)
                break;
            
        }else
        if(tempobj.id.search(Control_id_to) != -1)
        {
            ControlObj_to = tempobj;
            
            if(ControlObj_from != null)
                break;
        }
    }
     //code added by Sourabh Deshpande on 27Apr09 for Nuevosoft Test Manager Reports
     if(ControlObj_to == null && ControlObj_from == null)
        return true;
    //ends   
    if(ControlObj_to == null || ControlObj_from == null)
        return false;

    if (ControlObj_from.value == '' || ControlObj_to.value == '')
        return true;

    var Day_from = ControlObj_from.value.split(' ')[0];
    var Month_from = ControlObj_from.value.split(' ')[1];
    var Year_from = ControlObj_from.value.split(' ')[2];
    
    Month_from = GetMonthValue(Month_from);
    
    var Day_to = ControlObj_to.value.split(' ')[0];
    var Month_to = ControlObj_to.value.split(' ')[1];
    var Year_to = ControlObj_to.value.split(' ')[2];
    var iDayFrom, iDayTo;
    
    iDayFrom = parseInt(Day_from, 10);
    iDayTo = parseInt(Day_to, 10);
    
    Month_to = GetMonthValue(Month_to);

    if(Year_from < Year_to)
        return true;
    else
    if(Year_from == Year_to)
    {
        if(Month_from < Month_to)
            return true;
        else
        if(Month_from == Month_to)
        {
            if(iDayFrom > iDayTo)
            {
                ShowError(ErrorMessage, 'Alert_InvalidDate_Shared');
                ControlObj_from.focus();
                return false;                
            }
            return true;
        }else
        {
            ShowError(ErrorMessage, 'Alert_InvalidDate_Shared');
            ControlObj_from.focus();
            return false;
        }
    }else
    {
        ShowError(ErrorMessage, 'Alert_InvalidDate_Shared');
        ControlObj_from.focus();
        return false;    
    }
}
function Validate_RangeCalendar_DateRange_Reports(Control_id, AllowSingleDate)
{
    var Control_id_from  = Control_id + '_TxtDateFrom';
    var Control_id_to  = Control_id + '_TxtDateTo';
    var ControlObj_from = null;
    var ControlObj_to = null;
    var ErrorMessage = 'Alert_EnterValidDateRange_Shared';

    for(i=0;i<document.forms[0].elements.length;i++)
    {
        var tempobj = document.forms[0].elements[i];
        if(tempobj.id.search(Control_id_from) != -1)
        {
            ControlObj_from = tempobj;
            
            if(ControlObj_to != null)
                break;
            
        }else
        if(tempobj.id.search(Control_id_to) != -1)
        {
            ControlObj_to = tempobj;
            
            if(ControlObj_from != null)
                break;
        }
    } 
    if(ControlObj_to == null || ControlObj_from == null)
        return false;

    if (ControlObj_from.value == '' && ControlObj_to.value == '')
        return true;
    
    if (ControlObj_from.value == '' && ControlObj_to.value != '') 
    {
        if (AllowSingleDate == '1')
            return true;
        ShowError(ErrorMessage, 'Alert_InvalidDate_Shared');
        ControlObj_from.focus();
        return false;
    }
    else if (ControlObj_from.value != '' && ControlObj_to.value == '')
    {
        if (AllowSingleDate == '1')
            return true;
        ShowError(ErrorMessage, 'Alert_InvalidDate_Shared');
        ControlObj_to.focus();
        return false;
    }
    

    var Day_from = ControlObj_from.value.split(' ')[0];
    var Month_from = ControlObj_from.value.split(' ')[1];
    var Year_from = ControlObj_from.value.split(' ')[2];
    var Day_to = ControlObj_to.value.split(' ')[0];
    var Month_to = ControlObj_to.value.split(' ')[1];
    var Year_to = ControlObj_to.value.split(' ')[2];
    var iDayFrom = parseInt(Day_from, 10);
    var iDayTo = parseInt(Day_to, 10);
    
    Month_from = GetMonthValue(Month_from);
    Month_to = GetMonthValue(Month_to);

    if(Year_from < Year_to)
        return true;

    else if(Year_from == Year_to)
    {
        if(Month_from < Month_to)
            return true;
            
        else if(Month_from == Month_to)
        {
            if(iDayFrom > iDayTo)
            {
                ShowError(ErrorMessage, 'Alert_InvalidDate_Shared');
                ControlObj_from.focus();
                return false;                
            }
            return true;
        }
        else
        {
            ShowError(ErrorMessage, 'Alert_InvalidDate_Shared');
            ControlObj_from.focus();
            return false;
        }
    }
    else
    {
        ShowError(ErrorMessage, 'Alert_InvalidDate_Shared');
        ControlObj_from.focus();
        return false;    
    }
}

function Validate_Float(Control_id, ErrorMessage, Decimal_Separator_Symbol, Grouping_Separator_Symbol, Max_After_Decimal, EventObj)
{
    var ControlObj = document.getElementById(Control_id);
    //if(Grouping_Separator_Symbol == "")
    //    Grouping_Separator_Symbol = ',';
    var HasDecimal = false;
    
    if(ControlObj == null)
        return false;
        
    var CurrText = ControlObj.value;
    var tempCurrText;
    
    if(CurrText == '')
        return true;
    
    if(CurrText.charAt(0) == '-')
    {
        tempCurrText = CurrText.substr(1);
        if(tempCurrText == '' && EventObj == null)
        {
            ShowError(ErrorMessage, 'Alert_InvalidFloatNumber_Shared');
            ControlObj.focus();
            if(!isNaN(parseFloat(CurrText)))
            {
                ControlObj.value = parseFloat(CurrText)
            }
            else
            {
                ControlObj.value = "";
            }
            return false;      
        }
    }
    else
    {
        if(CurrText.charAt(0) == '.')
        {
            tempCurrText = CurrText.substr(1);
            if(tempCurrText == '' && EventObj == null)
            {
                ShowError(ErrorMessage, 'Alert_InvalidFloatNumber_Shared');
                ControlObj.focus();
                if(!isNaN(parseFloat(CurrText)))
                {
                    ControlObj.value = parseFloat(CurrText)
                }
                else
                {
                    ControlObj.value = "";
                }
                return false;      
            }
        }
        else
        {
            if(isNaN(parseFloat(CurrText)))
            {
                ShowError(ErrorMessage, 'Alert_InvalidFloatNumber_Shared');                    
                ControlObj.focus();
                ControlObj.value = "";                    
                return false;  
            }                
        }
    }    
    
    var str_before_decimal = null;
    var str_after_decimal = null;
    var temp_arr = null;
    if(CurrText.indexOf(Decimal_Separator_Symbol) != -1)
    {
        HasDecimal = true;
    
        temp_arr = CurrText.split(Decimal_Separator_Symbol);
        str_before_decimal = temp_arr[0];
        if(temp_arr.length != 1)
        {
            if(temp_arr.length == 2)
                str_after_decimal = CurrText.split(Decimal_Separator_Symbol)[1];
            else
            {
                ShowError(ErrorMessage, 'Alert_InvalidFloatNumber_Shared');
                ControlObj.focus();
                if(!isNaN(parseFloat(CurrText)))
                {
                    ControlObj.value = parseFloat(CurrText)
                }
                else
                {
                    ControlObj.value = "";
                }
                return false;
            }
        }
        
        
    }else
        str_before_decimal = CurrText;
    
    
    var before_decimal_cnt = 0;
    if(str_before_decimal != '')
    {
        temp_arr = str_before_decimal.split(Grouping_Separator_Symbol);
        
        for(i=0; i < temp_arr.length; i++)
        {
            var TrimmedVal = LTrim(temp_arr[i], '0');
            if (i == 0 && TrimmedVal == '-')
            {
                continue;
            }
            else
            {
                if(TrimmedVal != '' && TrimmedVal.length != String(parseInt(TrimmedVal)).length)
                {
                    ShowError(ErrorMessage, 'Alert_InvalidFloatNumber_Shared');
                    ControlObj.focus();
                    if(!isNaN(parseFloat(CurrText)))
                    {
                        ControlObj.value = parseFloat(CurrText)
                    }
                    else
                    {
                        ControlObj.value = "";
                    }
                    return false;                    
                }
            }
        }
        
        before_decimal_cnt = str_before_decimal.length - (temp_arr.length - 1);
    }
            
    
    temp_arr = null;
    var after_decimal_cnt = 0;
    if(str_after_decimal != null && str_after_decimal != '')
    {
        if (Grouping_Separator_Symbol != "")
        {
            temp_arr = str_after_decimal.split(Grouping_Separator_Symbol);
            for(i=0; i < temp_arr.length; i++)
            {
                if(temp_arr[i] != '')
                {
                    var TrimmedVal = LTrim(temp_arr[i], '0');
                    if(TrimmedVal != '' && TrimmedVal.length != String(parseInt(TrimmedVal)).length)
                    {
                        ShowError(ErrorMessage, 'Alert_InvalidFloatNumber_Shared');
                        ControlObj.focus();
                        if(!isNaN(parseFloat(CurrText)))
                        {
                            ControlObj.value = parseFloat(CurrText)
                        }
                        else
                        {
                            ControlObj.value = "";
                        }
                        return false;            
                    }
                }
                else
                {
                        ShowError(ErrorMessage, 'Alert_InvalidFloatNumber_Shared');
                        ControlObj.focus();
                        if(!isNaN(parseFloat(CurrText)))
                        {
                            ControlObj.value = parseFloat(CurrText)
                        }
                        else
                        {
                            ControlObj.value = "";
                        }
                        return false;
                }
            }

            after_decimal_cnt = str_after_decimal.length - (temp_arr.length - 1);
        }
        else
        {            
            temp_arr = str_after_decimal;
            temp_arr = LTrim(temp_arr, '0');
            if(temp_arr != '' && (isNaN(parseInt(temp_arr)) || temp_arr.length != String(parseInt(temp_arr)).length))
            {
                ShowError(ErrorMessage, 'Alert_InvalidFloatNumber_Shared');                    
                ControlObj.focus();
                ControlObj.value = str_before_decimal;
                return false;  
            } 
            after_decimal_cnt = str_after_decimal.length;
        }
    }          
    
    if(Max_After_Decimal > 0)
    {
        if(after_decimal_cnt > Max_After_Decimal)
        {
            ShowError(ErrorMessage, 'Alert_DigitsAfterDecimalExceedLimit_Shared');
            ControlObj.focus();
            
            var NewVal = str_before_decimal + ".";
            
            for(i=0; i<Max_After_Decimal; i++)
            {
                NewVal += str_after_decimal.charAt(i);
            }
            
            ControlObj.value = NewVal
            
            return false;                    
        }
    }
    
    return true;
}

function Validate_Float_ReportForm(Control_id, ErrorMessage, Decimal_Separator_Symbol, Grouping_Separator_Symbol, Max_After_Decimal, UIType)
{

    if(UIType != 'TEXTRANGE')
    {
        var ControlObj = document.getElementById(Control_id);
        
        if(ControlObj == null)
            return false;
            
        var CurrText = ControlObj.value;
        if(CurrText == '')
            return true;
        
        if(!IsFloat(CurrText, ErrorMessage, Decimal_Separator_Symbol, Grouping_Separator_Symbol, Max_After_Decimal))
        {
            ControlObj.focus();
            return false;
        }
        
    }else
    {
        var Control_From = document.getElementById(Control_id + '_TextFrom');
        var Control_To = document.getElementById(Control_id + '_TextTo');
        
        var CurrText = Control_From.value;
        if(CurrText != '')
        {
            if(!IsFloat(CurrText, ErrorMessage, Decimal_Separator_Symbol, Grouping_Separator_Symbol, Max_After_Decimal))
            {
                Control_From.focus();
                return false;
            }
        }
        
        CurrText = Control_To.value;
        if(CurrText == '')
            return true;
        
        if(!IsFloat(CurrText, ErrorMessage, Decimal_Separator_Symbol, Grouping_Separator_Symbol, Max_After_Decimal))
        {
            Control_To.focus();
            return false;
        }
        
    }
    
    return true;
}

function IsFloat(CurrText, ErrorMessage, Decimal_Separator_Symbol, Grouping_Separator_Symbol, Max_After_Decimal)
{
    if(CurrText.charAt(0) == '-')
        CurrText = CurrText.substr(1);
    
    var str_before_decimal = null;
    var str_after_decimal = null;
    var temp_arr = null;
    if(CurrText.indexOf(Decimal_Separator_Symbol) != -1)
    {
        temp_arr = CurrText.split(Decimal_Separator_Symbol);
        str_before_decimal = temp_arr[0];
        if(temp_arr.length != 1)
        {
            if(temp_arr.length == 2)
                str_after_decimal = CurrText.split(Decimal_Separator_Symbol)[1];
            else
            {
                ShowError(ErrorMessage, 'Alert_InvalidFloatNumber_Shared');
                //ControlObj.focus();
                return false;
            }
        }
        
        
    }else
        str_before_decimal = CurrText;
    
    
    var before_decimal_cnt = 0;
    if(str_before_decimal != '')
    {
        temp_arr = str_before_decimal.split(Grouping_Separator_Symbol);
        
        for(i=0; i < temp_arr.length; i++)
        {
            if(temp_arr[i].length != String(parseInt(temp_arr[i])).length)
            {
                ShowError(ErrorMessage, 'Alert_InvalidFloatNumber_Shared');
                //ControlObj.focus();
                return false;            
            }
        }
        
        before_decimal_cnt = str_before_decimal.length - (temp_arr.length - 1);
    }
            
    
    var after_decimal_cnt = 0;
    if(str_after_decimal != null && str_after_decimal != '')
    {
        temp_arr = str_after_decimal.split(Grouping_Separator_Symbol);

        for(i=0; i < temp_arr.length; i++)
        {
            if(temp_arr[i].length != String(parseInt(temp_arr[i])).length)
            {
                ShowError(ErrorMessage, 'Alert_InvalidFloatNumber_Shared');
                //ControlObj.focus();
                return false;            
            }
        }
        
        after_decimal_cnt = str_after_decimal.length - (temp_arr.length - 1);
    }
        
    
    if(Max_After_Decimal != null && Max_After_Decimal != '')
    {
        if(after_decimal_cnt > Max_After_Decimal)
        {
            ShowError(ErrorMessage, 'Alert_DigitsAfterDecimalExceedLimit_Shared');
            //ControlObj.focus();
            return false;                    
        }
    }
    
    return true;
}

function Redirect(URL)
{
    X = document.body.offsetWidth / 2;
    X -= (600 / 2);
    X += 100; //Left Pane

    Y = document.body.offsetHeight / 2;
    Y -= (460 / 2);

    window.open(URL,'','top='+Y+'px,left='+X+'px,resizable=1,width=600,height=460,scrollbars=1,status=1');
}

function Validate_Currency(Control_id, ErrorMessage, Decimal_Separator_Symbol, Grouping_Separator_Symbol, Max_After_Decimal)
{
    var ControlObj = document.getElementById(Control_id);
    //if(Grouping_Separator_Symbol == "")
    //    Grouping_Separator_Symbol = ',';
    var HasDecimal = false;
    
    if(ControlObj == null)
        return false;
        
    var CurrText = ControlObj.value;
    if(CurrText == '')
        return true;
    
    if(CurrText.charAt(0) == '-')
        CurrText = CurrText.substr(1);
    
    var str_before_decimal = null;
    var str_after_decimal = null;
    var temp_arr = null;
    if(CurrText.indexOf(Decimal_Separator_Symbol) != -1)
    {
        HasDecimal = true;
        temp_arr = CurrText.split(Decimal_Separator_Symbol);
        str_before_decimal = temp_arr[0];
        if(temp_arr.length != 1)
        {
            if(temp_arr.length == 2)
                str_after_decimal = CurrText.split(Decimal_Separator_Symbol)[1];
            else
            {
                ShowError(ErrorMessage, 'Alert_InvalidCurrencyValue_Shared');
                ControlObj.focus();
                if(!isNaN(parseFloat(CurrText)))
                {
                    ControlObj.value = parseFloat(CurrText);
                }
                else
                {
                    ControlObj.value = "";
                }
                return false;
            }
        }
    }
    else
        str_before_decimal = CurrText;
    
    var before_decimal_cnt = 0;
    if(str_before_decimal != '')
    {
        temp_arr = str_before_decimal.split(Grouping_Separator_Symbol);
        for(i=0; i < temp_arr.length; i++)
        {
            var TrimmedVal = LTrim(temp_arr[i], '0');
            if(TrimmedVal != '' && TrimmedVal.length != String(parseInt(TrimmedVal)).length)
            {
                ShowError(ErrorMessage, 'Alert_InvalidCurrencyValue_Shared');
                ControlObj.focus();
                if(!isNaN(parseFloat(CurrText)))
                {
                    ControlObj.value = parseFloat(CurrText);
                }
                else
                {
                    ControlObj.value = "";
                }
                return false;            
            }
        }
        before_decimal_cnt = str_before_decimal.length - (temp_arr.length - 1);
    }

    var after_decimal_cnt = 0;
    if(str_after_decimal != null && str_after_decimal != '')
    {
        temp_arr = str_after_decimal.split(Grouping_Separator_Symbol);
        for(i=0; i < temp_arr.length; i++)
        {
            if(temp_arr[i] != '')
            {
                var TrimmedVal = LTrim(temp_arr[i], '0');
                if(TrimmedVal != '' && TrimmedVal.length != String(parseInt(TrimmedVal)).length)
                {
                    ShowError(ErrorMessage, 'Alert_InvalidCurrencyValue_Shared');
                    ControlObj.focus();
                    if(!isNaN(parseFloat(CurrText)))
                    {
                        ControlObj.value = parseFloat(CurrText);
                    }
                    else
                    {
                        ControlObj.value = "";
                    }
                    return false;            
                }
            }
            else
            {
                    ShowError(ErrorMessage, 'Alert_InvalidCurrencyValue_Shared');
                    ControlObj.focus();
                    if(!isNaN(parseFloat(CurrText)))
                    {
                        ControlObj.value = parseFloat(CurrText);
                    }
                    else
                    {
                        ControlObj.value = "";
                    }
                    return false;
            }
        }
        after_decimal_cnt = str_after_decimal.length - (temp_arr.length - 1);
    }
    
    if(Max_After_Decimal != null && Max_After_Decimal != '')
    {
        if(after_decimal_cnt > Max_After_Decimal)
        {
            ShowError(ErrorMessage, 'Alert_DigitsAfterDecimalExceedLimit_Shared');
            ControlObj.focus();
            
            var NewVal = str_before_decimal + ".";

            for(i=0; i<Max_After_Decimal; i++)
            {
                NewVal += str_after_decimal.charAt(i);
            }
            
            ControlObj.value = NewVal;
            return false;                    
        }
    }
    
    return true;
}

function SelectAllCheckBox(ControlID, SelAllControlID)
{
    var CheckVal;
    var i;
    var item, itemAll;
    
    CheckVal = false;
    
    for(i=0; i < document.forms[0].elements.length; ++i)
    {
        itemAll = document.forms[0].elements[i];

        if ((itemAll.type == 'checkbox') && (itemAll.name.indexOf(SelAllControlID) > 0))
        {
            //CheckVal = itemAll.checked;
            break;
        }
    }
    
    for(i=0; i < document.forms[0].elements.length; ++i)
    {
        item = document.forms[0].elements[i];

        if ((item.type == 'checkbox') && (item.name.indexOf(ControlID) > 0))
        {
            item.checked = itemAll.checked;
        }
    }
    
}

//CheckBoxSelctionChanged
function CheckBoxSelctionChanged(ControlID, SelAllControlID)
{
    var itemAll;

    for(var i=0; i < document.forms[0].elements.length; ++i)
    {
        itemAll = document.forms[0].elements[i];

        if ((itemAll.type == 'checkbox') && (itemAll.name.indexOf(SelAllControlID) > 0))
        {
            itemAll.checked = false;
            break;
        }
    }
}

//-------------------------------------------------HelpJS.js----------------------------------------------------------------------------
 function DoVoid()
{
    return;
}

function ShowHelp(e,WindowName)
{                                                      
    ShowWindow = document.getElementById(WindowName); 
    ShowWindow.style.display='block'; 	
        
        if ( navigator.appName == 'Netscape' )
        {
            WindowWidth = document.body.clientWidth;
            WindowHeight = document.body.clientHeight;
        }
        else
        {
            WindowWidth = document.body.offsetWidth;
            WindowHeight = document.body.offsetHeight;
        }

        
        
        x = e.clientX + ShowWindow.offsetWidth;
        y = e.clientY + ShowWindow.offsetHeight;
        
       if(x > WindowWidth)
        {
            ShowWindow.style.left= (e.clientX + document.body.scrollLeft) - ShowWindow.offsetWidth + "px";
        }
        else
        {
            ShowWindow.style.left= e.clientX + document.body.scrollLeft + "px";
        }

   
    ShowWindow.style.top = parseInt(mouseY(e)) + "px";
        
}

function CloseHelp(CloseWindowID)
{
    if ( CloseWindowID != '' )
    {
        var HelpDivID = document.getElementById(CloseWindowID);
        HelpDivID.style.position ='absolute';
        HelpDivID.style.display  ='none';
        HelpDivID.style.overflow ='hidden';
    }
}


var dragapproved=false;
var z,x,y, browser, temp1, temp2;

function mouseY(evt) 
{
    if (evt.pageY)
    { 
     return evt.pageY;
    }
    else if (evt.clientY)
    { 
     return evt.clientY + (document.documentElement.scrollTop? document.documentElement.scrollTop :document.body.scrollTop); 
    } 
    else return 0;
}
function drags(e,HelpDivID)
{
    browser = navigator.appName; 
    
    HelpDiv = document.getElementById(HelpDivID);
    if (HelpDiv != null)
    {
            dragapproved=true;
            z=HelpDiv;
            temp1= parseInt(z.style.left, 10);
            temp2= parseInt(z.style.top, 10);                                    

            if (browser == 'Netscape')
            {
                x = e.clientX;
                y = e.clientY;
            }
            else
            {
                x=event.clientX;
                y=event.clientY;
            }                                    
            document.onmousemove=move;                                    
    }
    return;
}


function StopDrag()
{
    dragapproved = false;
}
function move(e) 
{ 
    if (dragapproved) 
    { 
        if (browser == 'Netscape') 
        { 
            z.style.left = temp1 + e.clientX - x + "px"; 
            z.style.top = temp2 + e.clientY - y + "px"; 
        } 
        else 
        { 
            z.style.left= temp1+ event.clientX-x; 
            z.style.top= temp2+ event.clientY-y; 
        } 
        return false; 
    }
} 

//-------------------------------------------------JCalender.js----------------------------------------------------------------------------
	var weekend = [0,6];
	var weekendColorClass = "CalendarWeekEndDateBK CalendarWeekEndDate";
	var weekDayColorClass = "CalendarDateBK CalendarDate";
	var fontface = "Verdana";
	var fontsize = 2;

	var gNow = new Date();
	var ggWinCal;
	var gFlagFirst=0;
	var giMonth,giDay,giYear;
	var gMinYear = 1990;
	var gMaxYear = 2020;
	var gTenantName = "";
	var gThemeName = "Default";
	var gCalendarTitle = "ALCalendar";
	var gEventOnDateSelection = "false";
	var gControlID = '';


	Calendar.TDaysArr	= [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,

	"","","","" ];


	Calendar.TMonthsArr	= [
01,
02,
03,
04,
05,
06,
07,
08,
09,
10,
11,
12,

	"","","","" ];


	Calendar.TYearArr	= [
1990,
1991,
1992,
1993,
1994,
1995,
1996,
1997,
1998,
1999,
2000,
2001,
2002,
2003,
2004,
2005,
2006,
2007,
2008,
2009,
2010,
2011,
2012,
2013,
2014,
2015,
2016,
2017,
2018,
2019,
2020,

	"","","","" ];


	isNav = (navigator.appName.indexOf("Netscape") != -1) ? true : false;
	isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
	
	Calendar.Months = ["January", "February", "March", "April", "May", "June",
	"July", "August", "September", "October", "November", "December"];

    Calendar.ShortMonths = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
    "Aug", "Sep", "Oct", "Nov", "Dec"];

	Calendar.TMonths = [
						"January", 
						"February", 
						"March", 
						"April", 
						"May", 
						"June", 
						"July", 
						"August", 
						"September", 
						"October", 
						"November", 
						"December", 
						];
						
	Calendar.TShortMonths = [
						"Jan", 
						"Feb", 
						"Mar", 
						"Apr", 
						"May", 
						"Jun", 
						"Jul", 
						"Aug", 
						"Sep", 
						"Oct", 
						"Nov", 
						"Dec", 
						];

	Calendar.TWeekDays = [
						"Su", 
						"Mo", 
						"Tu", 
						"We", 
						"Th", 
						"Fr", 
						"Sa"
						];

	// Non-Leap year Month days..
	Calendar.DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	// Leap year Month days..
	Calendar.lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

	function Calendar(p_item, p_WinCal, p_month, p_year, p_format) {
	   
		if ((p_month == null) && (p_year == null))	return;

		if (p_WinCal == null)
			this.gWinCal = ggWinCal;
		else
			this.gWinCal = p_WinCal;
		
		if (p_month == null) {
			this.gMonthName = null;
			this.gTMonthName = null;
			this.gTYear = null;
			this.gMonth = null;
			this.gYearly = true;
		} else {
			this.gMonthName = Calendar.get_month(p_month,p_format);
			this.gTMonthName = Calendar.get_Tmonth(p_month,p_format);
			this.gTYear = Calendar.get_TYear(p_year-1990);
			this.gMonth = new Number(p_month);
			this.gYearly = false;
		}

		this.gYear = p_year;
		this.gFormat = p_format;
		this.gBGColor = "white";
		this.gFGColor = "black";
		this.gTextColor = "black";
		this.gHeaderColor = "black";
		this.gReturnItem = p_item;
		
		this.gHiddenItem = h_item;
		//this.gControlID = h_controlID;
		
	}

	Calendar.get_month = Calendar_get_month;
	Calendar.get_Tmonth = Calendar_get_Tmonth;
	Calendar.get_TDay = Calendar_get_TDay;
	Calendar.get_TMonthNum = Calendar_get_TMonthNum;
	Calendar.get_TYear = Calendar_get_TYear;
	Calendar.get_daysofmonth = Calendar_get_daysofmonth;
	Calendar.calc_month_year = Calendar_calc_month_year;
	Calendar.print = Calendar_print;

	function Calendar_get_month(monthNo,format) {
	    if(format == "DD MMMM YYYY")
		    return Calendar.Months[monthNo];
		else
		    return Calendar.ShortMonths[monthNo];
	}

	function Calendar_get_Tmonth(monthNo,format) {
	    if(format == "DD MMMM YYYY")
		    return Calendar.TMonths[monthNo];
		else
		    return Calendar.TShortMonths[monthNo];
	}

	function Calendar_get_TDay(DayNo) {
		return Calendar.TDaysArr[DayNo];
	}

	function Calendar_get_TMonthNum(monthNo) {
		return Calendar.TMonthsArr[monthNo];
	}

	function Calendar_get_TYear(YearNo) {
		return Calendar.TYearArr[YearNo];
	}

	function Calendar_get_daysofmonth(monthNo, p_year) {
		/* 
		Check for leap year ..
		1.Years evenly divisible by four are normally leap years, except for... 
		2.Years also evenly divisible by 100 are not leap years, except for... 
		3.Years also evenly divisible by 400 are leap years. 
		*/
		if ((p_year % 4) == 0) {
			if ((p_year % 100) == 0 && (p_year % 400) != 0)
				return Calendar.DOMonth[monthNo];
		
			return Calendar.lDOMonth[monthNo];
		} else
			return Calendar.DOMonth[monthNo];
	}

	function Calendar_calc_month_year(p_Month, p_Year, incr) {
		/* 
		Will return an 1-D array with 1st element being the calculated month 
		and second being the calculated year 
		after applying the month increment/decrement as specified by 'incr' parameter.
		'incr' will normally have 1/-1 to navigate thru the months.
		*/
		var ret_arr = new Array();
		
		if (incr == -1) {
			// B A C K W A R D
			if (p_Month == 0) {
				ret_arr[0] = 11;
				ret_arr[1] = parseInt(p_Year) - 1;
			}
			else {
				ret_arr[0] = parseInt(p_Month) - 1;
				ret_arr[1] = parseInt(p_Year);
			}
		} else if (incr == 1) {
			// F O R W A R D
			if (p_Month == 11) {
				ret_arr[0] = 0;
				ret_arr[1] = parseInt(p_Year) + 1;
			}
			else {
				ret_arr[0] = parseInt(p_Month) + 1;
				ret_arr[1] = parseInt(p_Year);
			}
		}
		
		return ret_arr;
	}

	function Calendar_print() {
		ggWinCal.print();
	}

	function Calendar_calc_month_year(p_Month, p_Year, incr) {
		/* 
		Will return an 1-D array with 1st element being the calculated month 
		and second being the calculated year 
		after applying the month increment/decrement as specified by 'incr' parameter.
		'incr' will normally have 1/-1 to navigate thru the months.
		*/
		var ret_arr = new Array();
		
		if (incr == -1) {
			// B A C K W A R D
			if (p_Month == 0) {
				ret_arr[0] = 11;
				ret_arr[1] = parseInt(p_Year) - 1;
			}
			else {
				ret_arr[0] = parseInt(p_Month) - 1;
				ret_arr[1] = parseInt(p_Year);
			}
		} else if (incr == 1) {
			// F O R W A R D
			if (p_Month == 11) {
				ret_arr[0] = 0;
				ret_arr[1] = parseInt(p_Year) + 1;
			}
			else {
				ret_arr[0] = parseInt(p_Month) + 1;
				ret_arr[1] = parseInt(p_Year);
			}
		}
		
		return ret_arr;
	}

	// This is for compatibility with Navigator 3, we have to create and discard one object before the prototype object exists.
	new Calendar();

	Calendar.prototype.getMonthlyCalendarCode = function() {
		var vCode = "";
		var vHeader_Code = "";
		var vData_Code = "";
		
		// Begin Table Drawing code here..
		
		vCode = vCode + "<table width='100%' class='CalendarWeekBK' cellspacing='0' cellpadding='0' border='0'>";
		
		vHeader_Code = this.cal_header();
		vData_Code = this.cal_data();
		vCode = vCode + vHeader_Code + vData_Code;
		
		vCode = vCode + "</table>";
	
	
		return vCode;
	};


	Calendar.prototype.show = function() {
		var vCode = "";
		
		this.gWinCal.document.open();

		// Setup the page...
		this.wwrite("<html>");
		this.wwrite("<head><title>" + gCalendarTitle + "</title>");
		this.wwrite("<link rel='stylesheet' href=\"/"+ gTenantName + "/App_Themes/" + gThemeName + "/AlStyleSheet.css\" type='text/css'/>")
		this.wwrite("</head>");

		this.wwrite("<body class='CalenderBK' style=\"width: 100%; left: 0px; top: 0px; margin-bottom: 2px; margin-left: 2px; margin-right: 2px; margin-top: 2px;\">");

		// Show navigation buttons
		var prevMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, -1);
		var prevMM = prevMMYYYY[0];
		var prevYYYY = prevMMYYYY[1];

		var nextMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, 1);
		var nextMM = nextMMYYYY[0];
		var nextYYYY = nextMMYYYY[1];
	

		if(prevMM == 11)
		{
		var currMM = 0;
		var currYYYY = prevYYYY + 1;
		}
		else
		{
		var currMM = prevMM + 1;
		var currYYYY = prevYYYY;
		}

		this.wwrite("<table width='100%' border='0' cellspacing='2' cellpadding='3' class='CalendarMonthBK'><tr><td align='center'>");
		this.wwrite("</td>");
		if ( currMM==0 && currYYYY<=gMinYear )
		{
			this.wwrite("<td align='center' >&nbsp;</td>");
		}
		else
		{
		    var PreviousMonth = GetLocalizedString("Alert_PreviousMonth_Shared",null);
			this.wwrite("<td align='center' ><a href=\"" +
				"javascript:window.opener.Build(" + 
				"'" + this.gReturnItem + "', '" + prevMM + "', '" + prevYYYY + "', '" + this.gFormat + "'" +
				");" +
				"\"><img alt=\"" + PreviousMonth + "\" style='border: 0;' src=\"/" + gTenantName + "/App_Themes/" + gThemeName +   "/images/previous.gif\"/></a>"+
			"</td>");
		}
		this.wwrite("<td style='height:25px;white-space: nowrap' align='center' >&nbsp;<select name='LB_cal_month' class='FormInputArea' onchange='javascript:window.opener.Build(\""+ this.gReturnItem  + "\", this.value, \"" + currYYYY + "\", \"" + this.gFormat + "\");'>");
		
		
		for ( monthCnt=0; monthCnt<12; monthCnt++)
		{
			if ( monthCnt==this.gMonth )
				this.wwrite("<option value='" + monthCnt + "' selected='selected'>" + Calendar.get_Tmonth(monthCnt,this.gFormat) + "</option>");
			else
				this.wwrite("<option value='" + monthCnt + "'>" + Calendar.get_Tmonth(monthCnt,this.gFormat) + "</option>");
		}
		this.wwrite("</select>&nbsp;</td>"); 

		if ( currMM==11 && currYYYY>=gMaxYear )
		{
			this.wwrite("<td align='center' >&nbsp;</td>");
		}
		else
		{
		    var NextMonth = GetLocalizedString("Alert_NextMonth_Shared",null);
			this.wwrite("<td align='center' >"+	
				"<a href=\"" +
				"javascript:window.opener.Build(" + 
				"'" + this.gReturnItem + "', '" + nextMM + "', '" + nextYYYY + "', '" + this.gFormat + "'" +
				");" +
				"\"><img alt=\"" + NextMonth + "\" style='border: 0;' src=\"/" + gTenantName + "/App_Themes/" + gThemeName + "/images/next.gif\"/></a></td>");
		}

		this.wwrite("<td style=\"width:100%\" align='center' ></td>"); 

		if ( currYYYY<=gMinYear )
		{
			this.wwrite("<td align='center' >&nbsp;</td>");
		}
		else
		{
		    var PreviousYear = GetLocalizedString("Alert_PreviousYear_Shared",null);
			this.wwrite("<td align='center' ><a href=\"" +
				"javascript:window.opener.Build(" + 
				"'" + this.gReturnItem + "', '" + (currMM) + "', '" + (currYYYY-1) + "', '" + this.gFormat + "'" +
				");" +
				"\"><img alt=\"" + PreviousYear + "\" style='border: 0;' src=\"/" + gTenantName + "/App_Themes/" + gThemeName +  "/images/previous.gif\"/></a></td>");
		}

		this.wwrite("<td align='center' style='white-space: nowrap;' >&nbsp;<select name='LB_cal_year' class='FormInputArea' onchange='javascript:window.opener.Build(\""+ this.gReturnItem  + "\", \"" + currMM + "\", this.value, \"" + this.gFormat + "\");'>");
		
		for ( yearCnt=1990; yearCnt<=2020; yearCnt++)
		{
			if ( yearCnt == this.gTYear )
				this.wwrite("<option value='" + yearCnt + "' selected='selected'>" + yearCnt + "</option>");
			else
				this.wwrite("<option value='" + yearCnt + "'>" + yearCnt + "</option>");
		}
		this.wwrite("</select>&nbsp;</td> ");
		
		 
		if ( currYYYY>=gMaxYear )
		{
			this.wwrite("<td align='center' >&nbsp;</td>");
		}
		else
		{
		    var NextYear = GetLocalizedString("Alert_NextYear_Shared",null);
			this.wwrite("<td align='center' ><a href=\"" +
				"javascript:window.opener.Build(" + 
				"'" + this.gReturnItem + "', '" + (currMM) + "', '" + (currYYYY+1) + "', '" + this.gFormat + "'" +
				");" +
				"\"><img alt=\"" + NextYear + "\" style='border: 0;' src=\"/" + gTenantName + "/App_Themes/" + gThemeName + "/images/next.gif\"/></a></td>");
		}
		this.wwrite("<td align='center'></td></tr></table>");
	

		// Get the complete calendar code for the month..
		vCode = this.getMonthlyCalendarCode();
		this.wwrite(vCode);

		this.wwrite("</body></html>");
		this.gWinCal.document.close();
	};

	Calendar.prototype.showY = function() {
		var vCode = "";
		var i;
		var vr, vc, vx, vy;		// Row, Column, X-coord, Y-coord
		var vxf = 285;			// X-Factor
		var vyf = 200;			// Y-Factor
		var vxm = 10;			// X-margin
		var vym;				// Y-margin
		if (isIE)	vym = 75;
		else if (isNav)	vym = 25;
		
		this.gWinCal.document.open();

		this.wwrite("<html>");
		this.wwrite("<head><title>Calendar</title>");
		this.wwrite("<style type='text/css'>\n<!--");
		for (i=0; i<12; i++) {
			vc = i % 3;
			if (i>=0 && i<= 2)	vr = 0;
			if (i>=3 && i<= 5)	vr = 1;
			if (i>=6 && i<= 8)	vr = 2;
			if (i>=9 && i<= 11)	vr = 3;
			
			vx = parseInt(vxf * vc) + vxm;
			vy = parseInt(vyf * vr) + vym;

			this.wwrite(".lclass" + i + " {position:absolute;top:" + vy + ";left:" + vx + ";}");
		}
		this.wwrite("-->\n</style>");
		this.wwrite("</head>");

		this.wwrite("<body class='CalenderBK' style=\"width: 100%; left: 0px; top: 0px; margin-bottom: 2px; margin-left: 2px; margin-right: 2px; margin-top: 2px;\">");
		this.wwrite("<FONT FACE='" + fontface + "' SIZE=2><b>");
		this.wwrite("Year : " + this.gYear);
		this.wwrite("</b><br>");

		// Show navigation buttons
		var prevYYYY = parseInt(this.gYear) - 1;
		var nextYYYY = parseInt(this.gYear) + 1;
	

		// Get the complete calendar code for each month..
		var j;
		for (i=11; i>=0; i--) {
			if (isIE)
				this.wwrite("<DIV ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");
			else if (isNav)
				this.wwrite("<LAYER ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");

			this.gMonth = i;
			this.gMonthName = Calendar.get_month(this.gMonth,this.gFormat);
			vCode = this.getMonthlyCalendarCode();
			this.wwrite(this.gMonthName + "/" + this.gYear + "<br>");
			this.wwrite(vCode);

			if (isIE)
				this.wwrite("</DIV>");
			else if (isNav)
				this.wwrite("</LAYER>");
		}

		this.wwrite("</font><br></body></html>");
		this.gWinCal.document.close();
	};

	Calendar.prototype.wwrite = function(wtext) {
		this.gWinCal.document.writeln(wtext);
	};

	Calendar.prototype.wwriteA = function(wtext) {
		this.gWinCal.document.write(wtext);
	};

	Calendar.prototype.cal_header = function() {
		var vCode = "";
		
		vCode = vCode + "<tr>";
		vCode = vCode + "<td style=\"width:10%\" align='center' class='CalendarWeekEnds CalendarWeekBK'>" + Calendar.TWeekDays[0] + "</td>";
		vCode = vCode + "<td style=\"width:10%\" align='center' class='CalendarWeekDays CalendarWeekBK'>" + Calendar.TWeekDays[1] + "</td>";
		vCode = vCode + "<td style=\"width:10%\" align='center' class='CalendarWeekDays CalendarWeekBK'>" + Calendar.TWeekDays[2] + "</td>";
		vCode = vCode + "<td style=\"width:10%\" align='center' class='CalendarWeekDays CalendarWeekBK'>" + Calendar.TWeekDays[3] + "</td>";
		vCode = vCode + "<td style=\"width:10%\" align='center' class='CalendarWeekDays CalendarWeekBK'>" + Calendar.TWeekDays[4] + "</td>";
		vCode = vCode + "<td style=\"width:10%\" align='center' class='CalendarWeekDays CalendarWeekBK'>" + Calendar.TWeekDays[5] + "</td>";
		vCode = vCode + "<td style=\"width:10%\" align='center' class='CalendarWeekEnds CalendarWeekBK'>" + Calendar.TWeekDays[6] + "</td>";
		vCode = vCode + "</tr>";
		
		
		return vCode;
	};

	function HandleDate(item,value)
	{
		
	}
	Calendar.prototype.cal_data = function() {
		var vDate = new Date();
		vDate.setDate(1);
		vDate.setMonth(this.gMonth);
		vDate.setFullYear(this.gYear);

		var vFirstDay=vDate.getDay();
		var vDay=1;
		var vLastDay=Calendar.get_daysofmonth(this.gMonth, this.gYear);
		var vOnLastDay=0;
		var vCode = "";

		/*
		Get day for the 1st of the requested month/year..
		Place as many blank cells before the 1st day of the month as necessary. 
		*/

		vCode = vCode + "<tr>";
		for (i=0; i<vFirstDay; i++) {
			vCode = vCode + "<td style=\"width:10%\"" + this.write_weekend_string(i) + " >&nbsp;</td>";
		}


		var iPos	   = this.gReturnItem.indexOf(".");
		var sFieldName = this.gReturnItem.substring(iPos+1,this.gReturnItem.length);
		var sFormName  = this.gReturnItem.substring(0, iPos);

		// Write rest of the 1st week
		for (j=vFirstDay; j<7; j++) 
		{
		    if ( gEventOnDateSelection.toUpperCase() == "TRUE" )
		    {    
			    vCode = vCode + "<td align='center' style=\"width:10%\"" + this.write_weekend_string(j) + ">"+ 
				    "<a style=\"text-decoration: none\" href='javascript:void(0);' " + 
						    "onclick=\"self.opener.document." + this.gReturnItem + ".value='" + 
						    this.Tformat_data(vDay) + 
						    "';" +
						    "self.opener.document." + sFormName + "." + this.gHiddenItem + ".value='" + 
						    this.format_data(vDay) + 
						    "';" + 
						    "self.opener.__doPostBack('"+ gControlID +"','');" +
						    "window.close();\">" + 
					    this.format_day(vDay) + 
				    "</a>" + 
				    "</td>";
				    
			}
			else
			{
			    vCode = vCode + "<td align='center' style=\"width:10%\"" + this.write_weekend_string(j) + ">"+ 
				    "<a style=\"text-decoration: none\" href='javascript:void(0);' " + 
						    "onclick=\"self.opener.document." + this.gReturnItem + ".value='" + 
						    this.Tformat_data(vDay) + 
						    "';" +
						    "self.opener.document." + sFormName + "." + this.gHiddenItem + ".value='" + 
						    this.format_data(vDay) + 
						    "';" + 
						    "window.close();\">" + 
					    this.format_day(vDay) + 
				    "</a>" + 
				    "</td>";
				    
			}
			vDay=vDay + 1;
		}
		vCode = vCode + "</tr>";

		// Write the rest of the weeks
		for (k=2; k<7; k++) {
			vCode = vCode + "<tr>";

			for (j=0; j<7; j++) 
			{
			    if ( gEventOnDateSelection.toUpperCase() == "TRUE" )
		        {
				    vCode = vCode + "<td align='center' style=\"width:10%\"" + this.write_weekend_string(j) + ">" + 
					    "<a style=\"text-decoration: none\" href='javascript:void(0);' " + 
						    "onclick=\"self.opener.document." + this.gReturnItem + ".value='" + 
						    this.Tformat_data(vDay) + 
						    "';" +
						    "self.opener.document." + sFormName + "." + this.gHiddenItem + ".value='" + 
						    this.format_data(vDay) + 
						    "';" + 
						    "self.opener.__doPostBack('"+ gControlID +"','');" +
						    "window.close();\">" + 
					    this.format_day(vDay) + 
					    "</a>" + 
					    "</td>";
				}
				else
				{
				    vCode = vCode + "<td align='center' style=\"width:10%\"" + this.write_weekend_string(j) + ">" + 
					    "<a style=\"text-decoration: none\" href='javascript:void(0);' " + 
						    "onclick=\"self.opener.document." + this.gReturnItem + ".value='" + 
						    this.Tformat_data(vDay) + 
						    "';" +
						    "self.opener.document." + sFormName + "." + this.gHiddenItem + ".value='" + 
						    this.format_data(vDay) + 
						    "';" + 
						    "window.close();\">" + 
					    this.format_day(vDay) + 
					    "</a>" + 
					    "</td>";
				}
				vDay=vDay + 1;

				if (vDay > vLastDay) {
					vOnLastDay = 1;
					break;
				}
			}
		    vCode = vCode + "</tr>";
			if (vOnLastDay == 1)
				break;
		}
		
		// Fill up the rest of last week with proper blanks, so that we get proper square blocks
	/*	for (m=1; m<(7-j); m++) {
			if (this.gYearly)
				vCode = vCode + "<td WIDTH='10%'" + this.write_weekend_string(j+m) + 
				"><FONT SIZE='2' class=text> </FONT></td>";
			else
				vCode = vCode + "<td WIDTH='10%'" + this.write_weekend_string(j+m) + 
				">&nbsp;</td>";
		}*/
		
		return vCode;
	};

	Calendar.prototype.format_day = function(vday) {
	/*	var vNowDay = gNow.getDate();
		var vNowMonth = gNow.getMonth();
		var vNowYear = gNow.getFullYear();*/

		var vNowDay = giDay;
		var vNowMonth = giMonth;
		var vNowYear = giYear;

		if (vday == vNowDay && this.gMonth == vNowMonth && this.gYear == vNowYear)
			return ("<span class='CalenderSelectedDate'>" + Calendar.get_TDay(vday-1) + "</span>");
		else
			return (Calendar.get_TDay(vday-1));
	};

	Calendar.prototype.write_weekend_string = function(vday) {
		var i;

		// Return special formatting for the weekend day.
		for (i=0; i<weekend.length; i++) {
			if (vday == weekend[i])
				return (" class=\"" + weekendColorClass + "\"");
		}
	    return (" class=\"" + weekDayColorClass + "\"");
	};
		
	Calendar.prototype.format_data = function(p_day) {
		var vData;
		var vMonth = 1 + this.gMonth;
		vMonth = (vMonth.toString().length < 2) ? "0" + vMonth : vMonth;
		var vMon = Calendar.get_month(this.gMonth,this.gFormat).substr(0,3);
		var vFMon = Calendar.get_month(this.gMonth,this.gFormat);
		var vTFMon = Calendar.get_Tmonth(this.gMonth,this.gFormat);
		var vY4 = new String(this.gYear);
		var vTY4 = new String(this.gTYear);
		var vY2 = new String(this.gYear.substr(2,2));
		var vDD = (p_day.toString().length < 2) ? "0" + p_day : p_day;
		var vTDD =  Calendar.get_TDay(p_day-1);

		var today = new Date();

		var sHour = today.getHours();
		if(sHour < 10)
		  sHour = "0" + sHour;

		var sMin = today.getMinutes();
		if(sMin < 10)
			sMin = "0" + sMin;

		var sSec = today.getSeconds();
		if(sSec < 10)
			sSec = "0" + sSec;
			
		

		var sTime = sHour + ":" + sMin + ":" + sSec;


		//this.gFormat="DD-MONTH-YYYY"

		switch (this.gFormat) {
			case "MM\/DD\/YYYY" :
				vData = vMonth + "\/" + vDD + "\/" + vY4;
				break;
			case "MM\/DD\/YY" :
				vData = vMonth + "\/" + vDD + "\/" + vY2;
				break;
			case "MM-DD-YYYY" :
				vData = vMonth + "-" + vDD + "-" + vY4;
				break;
			case "MM-DD-YY" :
				vData = vMonth + "-" + vDD + "-" + vY2;
				break;

			case "DD\/MON\/YYYY" :
				vData = vDD + "\/" + vMon + "\/" + vY4;
				break;
			case "DD MMM YYYY" :
			    vData = vDD + " " + vMon + " " + vY4;
				break;
			case "DD\/MON\/YY" :
				vData = vDD + "\/" + vMon + "\/" + vY2;
				break;
			case "DD-MON-YYYY" :
				vData = vDD + "-" + vMon + "-" + vY4;
				break;
			case "DD-MON-YY" :
				vData = vDD + "-" + vMon + "-" + vY2;
				break;
			

			case "DD\/MONTH\/YYYY" :
				vData = vDD + "\/" + vFMon + "\/" + vY4;
				break;
			case "DD MMMM YYYY" :
			    vData = vDD + " " + vFMon + " " + vY4;
				break;
			case "DD\/MONTH\/YY" :
				vData = vDD + "\/" + vFMon + "\/" + vY2;
				break;
			case "DD-MONTH-YYYY" :
				vData = vDD + " " + vFMon + " " + vY4 ;
				break;
			case "DD-MONTH-YY" :
				vData = vDD + "-" + vFMon + "-" + vY2;
				break;

			case "DD\/MM\/YYYY" :
				vData = vDD + "\/" + vMonth + "\/" + vY4;
				break;
			case "DD\/MM\/YY" :
				vData = vDD + "\/" + vMonth + "\/" + vY2;
				break;
			case "DD-MM-YYYY" :
				vData = vDD + "-" + vMonth + "-" + vY4;
				break;
			case "DD-MM-YY" :
				vData = vDD + "-" + vMonth + "-" + vY2;
				break;

			default :
				vData = vMonth + "\/" + vDD + "\/" + vY4;
		}
		return vData;
	};
	
	Calendar.prototype.Tformat_data = function(p_day) {
		var vData;
		var vMonth = 1 + this.gMonth;
		vMonth = (vMonth.toString().length < 2) ? "0" + vMonth : vMonth;
		var vTMonth = Calendar.get_TMonthNum(vMonth);
		var vMon = Calendar.get_month(this.gMonth,this.gFormat).substr(0,3);
		var vFMon = Calendar.get_month(this.gMonth,this.gFormat);
		var vTFMon = Calendar.get_Tmonth(this.gMonth,this.gFormat);
		var vY4 = new String(this.gYear);
		var vTY4 = new String(this.gTYear);
		var vY2 = new String(this.gYear.substr(2,2));
		var vDD = (p_day.toString().length < 2) ? "0" + p_day : p_day;
		var vTDD =  Calendar.get_TDay(p_day-1);


//A
//Check for vY2
//Check for vMon
//A
		var today = new Date();

		var sHour = today.getHours();
		if(sHour < 10)
		  sHour = "0" + sHour;

		var sMin = today.getMinutes();
		if(sMin < 10)
			sMin = "0" + sMin;

		var sSec = today.getSeconds();
		if(sSec < 10)
			sSec = "0" + sSec;
			
		

		var sTime = sHour + ":" + sMin + ":" + sSec;


		//this.gFormat="DD-MONTH-YYYY"

		switch (this.gFormat) {
			case "MM\/DD\/YYYY" :
				vData = vTMonth + "\/" + vTDD + "\/" + vTY4;
				break;
			case "MM\/DD\/YY" :
				vData = vTMonth + "\/" + vTDD + "\/" + vY2;
				break;
			case "MM-DD-YYYY" :
				vData = vTMonth + "-" + vTDD + "-" + vTY4;
				break;
			case "MM-DD-YY" :
				vData = vTMonth + "-" + vTDD + "-" + vY2;
				break;

			case "DD\/MON\/YYYY" :
				vData = vTDD + "\/" + vMon + "\/" + vTY4;
				break;
			case "DD\/MON\/YY" :
				vData = vTDD + "\/" + vMon + "\/" + vY2;
				break;
			case "DD-MON-YYYY" :
				vData = vTDD + "-" + vMon + "-" + vTY4;
				break;
			case "DD-MON-YY" :
				vData = vTDD + "-" + vMon + "-" + vY2;
				break;

			case "DD\/MONTH\/YYYY" :
				vData = vTDD + "\/" + vTFMon + "\/" + vTY4;
				break;
			case "DD\/MONTH\/YY" :
				vData = vTDD + "\/" + vTFMon + "\/" + vY2;
				break;
			case "DD-MONTH-YYYY" :
				vData = vTDD + " " + vTFMon + " " + vTY4 ;
				break;
			case "DD-MONTH-YY" :
				vData = vTDD + "-" + vTFMon + "-" + vY2;
				break;

			case "DD\/MM\/YYYY" :
				vData = vTDD + "\/" + vTMonth + "\/" + vTY4;
				break;
			case "DD\/MM\/YY" :
				vData = vTDD + "\/" + vTMonth + "\/" + vY2;
				break;
			case "DD-MM-YYYY" :
				vData = vTDD + "-" + vTMonth + "-" + vTY4;
				break;
			case "DD-MM-YY" :
				vData = vTDD + "-" + vTMonth + "-" + vY2;
				break;

			case "DD MMMM YYYY" :
			    vData = vTDD + " " + vTFMon + " " + vTY4;
				break;
			case "DD MMM YYYY" :
			    vData = vTDD + " " + vTFMon + " " + vTY4;
				break;
				
			default :
				vData = vTMonth + "\/" + vTDD + "\/" + vTY4;
		}

		return vData;
	};
	
	function GetMonthValue(sMonthName)
	{
		switch(sMonthName.toUpperCase())
		{
			case "JANUARY":
			case "JAN":
					return 0;
			case "FEBRUARY":
			case "FEB":
					return 1;
			case "MARCH":
			case "MAR":
					return 2;
			case "APRIL":
			case "APR":
					return 3;
			case "MAY":
			case "MAY":
					return 4;
			case "JUNE":
			case "JUN":
					return 5;
			case "JULY":
			case "JUL":
					return 6;
			case "AUGUST":
			case "AUG":
					return 7;
			case "SEPTEMBER":
			case "SEP":
					return 8;
			case "OCTOBER":
			case "OCT":
					return 9;
			case "NOVEMBER":
			case "NOV":
					return 10;
			case "DECEMBER":
			case "DEC":
					return 11;

		}

	}
	function Build(p_item, p_month, p_year, p_format,h_item) {
		var p_WinCal = ggWinCal;

		var parentWin  = p_WinCal.opener;
		var iPos	   = p_item.indexOf(".");
		var sFieldName = h_item ;
		
		
		if(gFlagFirst == 0)
		{
			gFlagFirst = 1;
			for(i=0;i<parentWin.document.forms[0].elements.length;i++)
			{
				var item = parentWin.document.forms[0].elements[i];

				if(item.name == sFieldName)
				{
					sFieldText = item.value;
					if(sFieldText != "")
					{
						iDayPos    = sFieldText.indexOf(" ");
						iDay       = sFieldText.substring(0,iDayPos);
						sFieldText = sFieldText.substring(iDayPos+1,sFieldText.length);
						giDay    = iDay;

						iMonPos    = sFieldText.indexOf(" ");
						sMonthVal  = sFieldText.substring(0,iMonPos);
						sFieldText = sFieldText.substring(iMonPos+1,sFieldText.length);
						iMonth	   = GetMonthValue(sMonthVal);
						p_month    = iMonth;
						giMonth    = iMonth;
						
						iYear	   = sFieldText;
						p_year	   = iYear;
						giYear	   = iYear;
					}
					else
					{
					    giDay = new String(gNow.getDate());
						p_month = new String(gNow.getMonth());
						giMonth = gNow.getMonth();
						p_year = new String(gNow.getFullYear().toString());
						giYear = gNow.getFullYear();
						//p_format = "MM/DD/YYYY";
					}

				}
			}
		}

		
		
		gCal = new Calendar(p_item, p_WinCal, p_month, p_year, p_format);

		// Customize your Calendar here..
		gCal.gBGColor="white";
		gCal.gLinkColor="black";
		gCal.gTextColor="black";
		gCal.gHeaderColor="darkgreen";

		
		
		
		// Choose appropriate show function
		if (gCal.gYearly)	gCal.showY();
		else	gCal.show();
	}

	function show_calendar() {
		/* 
			p_month : 0-11 for Jan-Dec; 12 for All Months.
			p_year	: 4-digit year
			p_format: Date format (mm/dd/yyyy, dd/mm/yy, ...)
			p_item	: Return Item.
		*/


		gFlagFirst = 0;


        gControlID = arguments[0];
        h_item = arguments[1];
		p_item = arguments[2];
		
		
		var tempItem = document.getElementById('__TENANTNAME_' + gControlID);
		if(tempItem != null)
		    gTenantName = tempItem.value;
		    
		var tempItem1 = document.getElementById('__THEMENAME_' + gControlID);
		if(tempItem1 != null)
		    gThemeName = tempItem1.value;

		var tempItem2 = document.getElementById('__CalendarTitle_' + gControlID);
		if(tempItem2 != null)
		    gCalendarTitle = tempItem2.value;

		var tempItem3 = document.getElementById('__EventOnDateSelection_' + gControlID);
		if(tempItem3 != null)
		    gEventOnDateSelection = tempItem3.value;

        //bhavana
        if (arguments[3] == null)
			p_format = "DD MMMM YYYY";
		else
			p_format = arguments[3];
        
		if (arguments[4] == null)
			p_month = new String(gNow.getMonth());
		else
			p_month = arguments[4];
		if (arguments[5] == "" || arguments[5] == null)
			p_year = new String(gNow.getFullYear().toString());
		else
			p_year = arguments[5];
		
        var tempMonthNameArray = document.getElementById('__TMonthNameArray_' + gControlID);
		if(tempMonthNameArray != null)
		{
		    tempMonthNameArrayObj = tempMonthNameArray.value;
		    MonthNameArray = tempMonthNameArrayObj.split("$AL$");
		    for (var i=0; i<MonthNameArray.length; i++)
		    {
		        Calendar.TMonths[i] = MonthNameArray[i];
		    }
		}
		
        var tempShortMonthNameArray = document.getElementById('__TShortMonthNameArray_' + gControlID);
		if(tempShortMonthNameArray != null)
		{
		    tempShortMonthNameArrayObj = tempShortMonthNameArray.value;
		    ShortMonthNameArray = tempShortMonthNameArrayObj.split("$AL$");
		    for (var i=0; i<ShortMonthNameArray.length; i++)
		    {
		        Calendar.TShortMonths[i] = ShortMonthNameArray[i];
		    }
		}

        var tempWeekDayArray = document.getElementById('__TWeekDayArray_' + gControlID);
		if(tempWeekDayArray != null)
		{
		    tempWeekDayArrayObj = tempWeekDayArray.value;
		    WeekDayArray = tempWeekDayArrayObj.split("$AL$");
		    for (var i=0; i<WeekDayArray.length; i++)
		    {
		        Calendar.TWeekDays[i] = WeekDayArray[i];
		    }
		}

		vWinCal = window.open("", "_blank", 
			"width=305,height=150,status=no,resizable=no,top=360,left=380");
		vWinCal.opener = self;
		ggWinCal = vWinCal;
				
		Build(p_item, p_month, p_year, p_format ,h_item);
	}
	/*
	Yearly Calendar Code Starts here
	*/
	function show_yearly_calendar(p_item, p_year, p_format) {
		// Load the defaults..
		if (p_year == null || p_year == "")
			p_year = new String(gNow.getFullYear().toString());
		if (p_format == null || p_format == "")
			p_format = "MM/DD/YYYY";

		var vWinCal = window.open("", "_blank", "scrollbars=yes");
		vWinCal.opener = self;
		ggWinCal = vWinCal;

		Build(p_item, null, p_year, p_format);
	}
	

    function ClearDateFields(DateTextBox, DateHiddenField, JCalenderID)
    {
        var DateCtrl;
        var HiddenDate;
        
        DateTextBox = JCalenderID + "_" + DateTextBox;
        DateCtrl = document.getElementById(DateTextBox);
        DateCtrl.value = "";
        
        DateHiddenField = JCalenderID + "_" + DateHiddenField;
        HiddenDate = document.getElementById(DateHiddenField);
        HiddenDate.value = "";        
    }


   //-------------JRangeCalender.js:(Extn)The below two function were added for Predefined Search JCalendar.js------------------------------------

    function JCalendarClearFields(TextBoxID, DateHiddenField)
    {
        var TextBoxDate;
        var HiddenVariableDate;
                
        TextBoxDate = document.getElementById(TextBoxID);
        TextBoxDate.value = "";
        HiddenVariableDate = document.getElementById(DateHiddenField);
        HiddenVariableDate.value = "";        
    }
    
    function JRangeCalendarClearFields(FromTextBox, ToTextBox, FromHiddenField, ToHiddenField)
    {
        var DateFrom;
        var DateTo;
        var HiddenFrom;
        var HiddenTo;
        
        DateFrom = document.getElementById(FromTextBox);
        DateFrom.value = "";
        HiddenFrom = document.getElementById(FromHiddenField);
        HiddenFrom.value = "";        
        
        DateTo = document.getElementById(ToTextBox);
        DateTo.value = "";
        HiddenTo = document.getElementById(ToHiddenField);
        HiddenTo.value = "";        
    }
	
	

	//-----------------------End For PredefinedSearch JCalendar------------------------------------------------------------

//-------------------------------------------------JRangeCalender.js----------------------------------------------------------------------------
	
	
function JRClearFields(FromTextBox, ToTextBox, FromHiddenField, ToHiddenField, JRangeCtrlID)
{
    var DateFrom;
    var DateTo;
    var HiddenFrom;
    var HiddenTo;
    FromTextBox = JRangeCtrlID + "_" + FromTextBox;
    ToTextBox = JRangeCtrlID + "_" + ToTextBox;
    DateFrom = document.getElementById(FromTextBox);
    DateTo = document.getElementById(ToTextBox);
    DateFrom.value = "";
    DateTo.value = "";
    
    FromHiddenField = JRangeCtrlID + "_" + FromHiddenField;
    ToHiddenField = JRangeCtrlID + "_" + ToHiddenField;
    HiddenFrom = document.getElementById(FromHiddenField);
    HiddenTo = document.getElementById(ToHiddenField);
    HiddenFrom.value = "";
    HiddenTo.value = "";
}

//-------------------------------------------------ListControl.js----------------------------------------------------------------------------
var objToMove=null;
var isdrag=null;
var control_id=null;
var browser;
var CSS_OrgDragObj;
var dbl_clk=false;
var dbl_clk_id=null;
var in_out_flag = false;
var in_out_id = null;

var RowNum = null;
var DivNode = null;
var CSS_MouseOverTR = null;
var EventOn = null;
var tempX = 0;
var tempY = 0;

var PrevRowObj = null;
var RecNo = null;
var HideTimeOutHandle = null;

function HandleListMultiSelect(URL)
{
    X = document.body.offsetWidth / 2;
    X -= (600 / 2);
    X += 100; //Left Pane

    Y = document.body.offsetHeight / 2;
    Y -= (460 / 2);

    window.open(URL,'','top='+Y+'px,left='+X+'px,resizable=1,width=600,height=460,scrollbars=1,status=1');

}

function GetX(obj)
{
    var x;
    x = obj.offsetLeft;
    while(obj = obj.offsetParent)
        x += obj.offsetLeft;
    return x;
}
    
function GetY(obj)
{
    var y;
    y = obj.offsetTop;
    while(obj = obj.offsetParent)
        y += obj.offsetTop;
    return y;
}

function ToggleRow(RowObj)
{
    if (RowObj != null)
    {
        if (RowObj.className == "FirstHighlightedRowBar")
            RowObj.className = "AlternateFirstRowBar";
        else
            RowObj.className = "AlternateSecondRowBar";
    }
}

function ShowActionDiv(RowObj, ControlID, ClientID, RecordNumber, EventObj)
{      
    var divInner = document.getElementById("Div_InbuiltActions_" + ControlID);
    RecNo = RecordNumber;        

    if (PrevRowObj == RowObj)
    {
        ClearTimeoutHandle();
        HideActionDiv();
        return;
    }
            
    if (PrevRowObj == null)
    {
        PrevRowObj = RowObj;
    }
    
    if (PrevRowObj != RowObj)
    {
        ToggleRow(PrevRowObj);
        PrevRowObj = RowObj;
    }
    
    ClearTimeoutHandle();
    UnTip();
    
    config.BorderWidth = 0;
    config.Padding = 0;
    config.FadeIn	= 700;
    config.FollowMouse	= false;

    ScrollableDivObj = document.getElementById("ScollableDiv_" + ClientID);
    ScrollDivX = GetX(ScrollableDivObj);

    MouseY = mouseY(EventObj);
    
    config.Fix = [ScrollDivX-60, MouseY-13];    

    if (RowObj.className == "AlternateFirstRowBar")
        RowObj.className = "FirstHighlightedRowBar";
    else
        RowObj.className = "SecondHighlightedRowBar";        
    
    Tip (divInner.innerHTML);
    HideActionDiv();
}

function HideActionDiv()
{
    var HideFunction = "HideInBuiltActionDiv()";
    HideTimeOutHandle = setTimeout(HideFunction, 3000);
}

function HideInBuiltActionDiv()
{
    UnTip();        
    ToggleRow(PrevRowObj);
    PrevRowObj = null;
}

function ClearTimeoutHandle()
{
    if (HideTimeOutHandle != null)
        clearTimeout(HideTimeOutHandle);
}

function HandleInBuiltEditClick(ControlID)
{
    HideInBuiltActionDiv();
    EditUrlObj = document.getElementById(ControlID + "_InBuiltEditUrl");
    if (EditUrlObj != null)
    {
        EditUrl = EditUrlObj.value;
        EditUrl = EditUrl.replace("$RECNUMBER$", RecNo);
        setTimeout(EditUrl);
    }
}

function HandleInBuiltDeleteClick(ControlID)
{
    HideInBuiltActionDiv();
    DeleteUrlObj = document.getElementById(ControlID + "_InBuiltDeleteUrl");
    if (DeleteUrlObj != null)
    {
        DeleteUrl = DeleteUrlObj.value;
        DeleteUrl = DeleteUrl.replace("$RECNUMBER$", RecNo);
        setTimeout(DeleteUrl);
    }   
}

function HandleInBuiltCopy(ControlID, ControlName)
{
    var count = 0;
    var item;
    var SelRecordNumber = "";
    
    for(var i=0; i < document.forms[0].elements.length;i++)
    {
        item   = document.forms[0].elements[i];            

        if ((item.checked) && (item.name.indexOf(ControlName)!=-1))
        {                
            if (SelRecordNumber == "")
                SelRecordNumber = item.value;
            else
                SelRecordNumber = SelRecordNumber + ";" + item.value ;                
            count+=1;
        }            
    }
   
    if(count < 1)
    {
        alert('Please select record(s) to copy.');
        return;
    }
    else
    {            
        __doPostBack(ControlID,SelRecordNumber);	 		            
    }
}

function HandleInBuiltExport(ControlID, ControlName)
{
    var count = 0;
    var item;
    var SelRecordNumber = "";
    
    for(var i=0; i < document.forms[0].elements.length;i++)
    {
        item   = document.forms[0].elements[i];            

        if ((item.checked) && (item.name.indexOf(ControlName)!=-1))
        {                
            if (SelRecordNumber == "")
                SelRecordNumber = item.value;
            else
                SelRecordNumber = SelRecordNumber + ";" + item.value ;            
        }            
    }
    
    __doPostBack(ControlID,SelRecordNumber);	 		                
}

function HandleInBuiltDelete(Mode, ControlID, RecordNumber, ControlName)
{
    var count = 0;
    var item;
    var SelRecordNumber = "";
    if (Mode.toUpperCase() == "POPUP")
    {
    	__doPostBack(ControlID, RecordNumber);
    }
    else
    {                
        for(var i=0; i < document.forms[0].elements.length;i++)
        {
            item   = document.forms[0].elements[i];            

            if ((item.checked) && (item.name.indexOf(ControlName)!=-1))
            {                
                if (SelRecordNumber == "")
                    SelRecordNumber = item.value;
                else
                    SelRecordNumber = SelRecordNumber + ";" + item.value ;                
                count+=1;
            }            
        }
       
        if(count < 1)
        {
            alert('Please select record(s) to delete.');
            return;
        }
        else
        {            
            __doPostBack(ControlID,SelRecordNumber);	 		            
        }
    }
}    

function ListSelectAll(Source, Destination)
{
    var CBVal;   
    var hdchangedrows=''; 
    for (var i=0; i< document.forms[0].elements.length;i++)
    {
        items = document.forms[0].elements[i];
        if (items.name == Source)
        {
            CBVal = items.checked;
            break;
        }
    }
 if(Destination=='CB_TESTCASEID_tstclst_')
     {//do only for testcases list under test suite form.     
      //setDataChanged();   
        for (var i=0; i< document.forms[0].elements.length;i++)
        {
            items = document.forms[0].elements[i];
            if ((items.name != Source) && (items.name == Destination) && items.disabled != true)          
            {
                items.checked = CBVal; 
                logchangedrow(items);//function logchangedrow() is defined in TestManagement.js            
            }
        }
    }
    else
    {
        for (var i=0; i< document.forms[0].elements.length;i++)
        {
            items = document.forms[0].elements[i];
            if ((items.name != Source) && (items.name == Destination) && items.disabled != true)          
            {
                items.checked = CBVal;                 
            }
        }
    }
}
                    
function findPosX(obj)
{
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
            curleft += obj.offsetLeft;
            if(!obj.offsetParent)
                break;
            obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj)
{
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
            curtop += obj.offsetTop;
            if(!obj.offsetParent)
                break;
            obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}

function mousedblclk(e,id,ctrl_id,type)
{
    if(dbl_clk==true)
    {
        objToMove.className = CSS_OrgDragObj
    }
    dbl_clk = true;
    dbl_clk_id = id;

    objToMove = document.getElementById(id);
    objToMove.style.cursor = 'move';
    CSS_OrgDragObj = objToMove.className;
    objToMove.className = "MoveUpDown";
    Action_Done='DragDrop';
}

function mouseout(e,id,ctrl_id,type)
{
    if(isdrag != true) return;
    if(id.split(':AL:')[3] != objToMove.id.split(':AL:')[3]) return; 
    if(in_out_id != id)return;

    var tempEle = document.getElementById(id);
    tempEle.style.backgroundColor = "";

    tempEle.className = CSS_MouseOverTR;
    CSS_MouseOverTR = null;

    in_out_id = null;
    in_out_flag = false;
}

function mouseup(e,id,ctrl_id,type)
{
    if(type == 'True')
    {
        if(dbl_clk==false)
        {return;}
    }

    if(isdrag!=true){return;}
    DivNode.innerHTML="";
    DivNode.style.display="none";
    RowNum = document.getElementById(id);
    objToMove.className = CSS_OrgDragObj;
    if(CSS_MouseOverTR != null)
    {RowNum.className = CSS_MouseOverTR;}
    //"alert(RowNum.id);" +
    if(RowNum.id.split(":AL:")[3] == objToMove.id.split(":AL:")[3]  &&  parseInt(RowNum.id.split(":AL:")[4]) != parseInt(objToMove.id.split(":AL:")[4]))
    {
        if (EventOn == "Row") 
        { 
            var arg =String(objToMove.id).split(':AL:')[5] + '$'+ String(RowNum.id).split(':AL:')[5] + '$Row$'+ String(objToMove.id).split(':AL:')[4] + '$' + String(RowNum.id).split(':AL:')[4]; 
        }
        else 
        { 
            var arg = String(objToMove.id).split(':AL:')[4] + '$' + String(RowNum.id).split(':AL:')[4] + '$Column';
        }
        //"var target = ctrl_id + \"_Drag_Drop_Div\";\n" +
        var target = ctrl_id;
        cleanup();
        DivNode.innerHTML="";
        __doPostBack(target, arg);
    } 
    else if(RowNum.id.split(":AL:")[3] != objToMove.id.split(":AL:")[3])
        { 
            ShowAlert("Alert_ListCtrl_InvalidPosition");
            DivNode.innerHTML=""; 
        }
        else 
        { 
            DivNode.innerHTML=""; 
        }
    cleanup();
}

function mousedown(e,id,ctrl_id,type)
{
    browser = navigator.appName;
    //"alert(id);" +
    if(type == 'True')
    {
        if(dbl_clk==false  ||  dbl_clk_id!=id )
        {return;}
    }
    if(isdrag == true && dbl_clk==false)
    {
        document.getElementById(id).className = CSS_MouseOverTR;
        return;
    }

    if(dbl_clk==false || type == 'False')
    {
        cleanup();
    }

    objToMove = document.getElementById(id);
    if(dbl_clk==false)
    {
        CSS_OrgDragObj = objToMove.className;
        objToMove.className = "MoveUpDown";
    }
    var strid= String(String(id).substr(0,23));
    
    if(strid != 'Drag:AL:Drop:AL:Row:AL:' && strid != 'Drag:AL:Drop:AL:Col:AL:') return;

    if (strid == 'Drag:AL:Drop:AL:Row:AL:') 
    {
        EventOn = "Row"; 
    }
    else 
    { 
        EventOn = "Column"; 
    }

    control_id = String(ctrl_id);
    RowNum = objToMove;
    //"alert(EventOn);" +
    document.onmousemove = doMove_ListControl;
    objToMove.style.cursor = 'move';

    objToMove.style.zIndex = 1;

}

function mouseover(e,id,ctrl_id,type)
{
    if(isdrag != true) return;
    if(id.split(':AL:')[3] != objToMove.id.split(':AL:')[3]) return;
    if(in_out_flag == true)
    {
        var tempobj = getElementById(in_out_id);
        tempobj.className = CSS_MouseOverTR;
        CSS_MouseOverTR = null;
    }

    var tempEle = document.getElementById(id);

    if(isdrag==true && tempEle.id != objToMove.id)
    {
        CSS_MouseOverTR = tempEle.className;

        RowNum = tempEle;
        tempEle.style.borderColor = "Red";
        tempEle.className = "MoveUpDown";
        in_out_id = tempEle.id;
        in_out_flag = true;
    }
}


function cleanup()
{
    isdrag=false;
    if(objToMove!=null)
    {
        objToMove.style.cursor = 'default';
        objToMove.className = CSS_OrgDragObj;
        objToMove=null;
    }
    document.onmousemove=null;
    document.onmouseup=null;
    dbl_clk = false;
    dbl_clk_id=null;
    in_out_flag = false;
    in_out_id = null;
}

function doMove_ListControl(e,clnt_id)
{
//"alert(\"Inside DOMove\");" +
    objToMove.zIndex = 2;
    isdrag=true;

    if (EventOn == "Row")
    { 
        TRstyleHeight = objToMove.style.height; 
    } 
    else 
    { 
        TRstyleHeight = objToMove.offsetHeight;  
        TRstyleWidth = objToMove.offsetWidth; 
        TDAlign = objToMove.align; 
        TDVAlign = objToMove.vAlign;
    }

    TRClassName = objToMove.className;

    if(browser == "Netscape")
    {
        var td1 = objToMove.firstChild;
        var columns_str = "";
    
        if ( td1 == '[object HTMLTableCellElement]' )
        {
            TDColspan = td1.colSpan;
            TDAlign = td1.align;
            TDvAlign = td1.vAlign;
            var s1 = td1.innerHTML;
            var strLeft = "<TD style='width:" + td1.offsetWidth + "px; height:" + td1.offsetHeight + "px;' ";
            columns_str = strLeft + " align='" + TDAlign + "' valign='" + TDvAlign + "' colspan='" + TDColspan + "'>" + s1 + "</TD>";
        }

        var temptd = td1.nextSibling;
        while (temptd)
        {
            if ( temptd == '[object HTMLTableCellElement]' )
            {
                TDColspan = temptd.colSpan;
                TDAlign = temptd.align;
                TDvAlign = temptd.vAlign;
                var s1 = temptd.innerHTML;
                var strLeft = "<TD style='width:" + temptd.offsetWidth + "px; height:" + temptd.offsetHeight + "px;' ";            
                columns_str = columns_str + strLeft + " align='" + TDAlign + "' valign='" + TDvAlign + "' colspan='" + TDColspan + "'>" + s1 + "</TD>";
            }
            temptd = temptd.nextSibling;
        }
    }
    else if(browser == "Microsoft Internet Explorer")
    {
        if (EventOn == "Row")
        {
            var td1 = objToMove.firstChild;        
            TDColspan = td1.colSpan;
            TDAlign = td1.align;
            TDvAlign = td1.vAlign;
            var s1 = td1.innerHTML;
            var strLeft = "<TD style='width:" + td1.offsetWidth + "px; height:" + td1.offsetHeight + "px;' ";
            var columns_str = strLeft + " align='" + TDAlign + "' valign='" + TDvAlign + "' colspan='" + TDColspan + "'>" + s1 + "</TD>";
    
            var temptd = td1.nextSibling;
            while (temptd)
            {
                TDColspan = temptd.colSpan;
                TDAlign = temptd.align;
                TDvAlign = temptd.vAlign;
                var s1 = temptd.innerHTML;
                var strLeft = "<TD style='width:" + temptd.offsetWidth + "px; height:" + temptd.offsetHeight + "px;' ";
        
                var columns_str = columns_str + strLeft + " align='" + TDAlign + "' valign='" + TDvAlign + "' colspan='" + TDColspan + "'>" + s1 + "</TD>";
                temptd = temptd.nextSibling;
            }
        }
        else 
        { 
            columns_str = objToMove.innerHTML;
        } 
    }


    //"DivNode = document.getElementById(String(control_id)+'_Drag_Drop_Div');\n" +
    DivNode = document.getElementById(String(control_id + '_Div'));
    if (EventOn == "Row") 
    { 
        DivNode.innerHTML = "<table border='0' style='filter:alpha(opacity=50); opacity=5' class='BorderSecond'>" + "<TR style='height:" + TRstyleHeight + "px;' class='" + TRClassName + "'>" + columns_str + "</TR></table>";
    } 
    else 
    {
        DivNode.innerHTML = "<table border='0' style='filter:alpha(opacity=50); opacity=5' class='BorderSecond'>" + "<TR style='height:" + TRstyleHeight + "px; width:" + TRstyleWidth + "px;' class='" + TRClassName + "'> <TD style='height:" + TRstyleHeight + "px; width:" + TRstyleWidth + "px;' class='" + TRClassName + "' align='" + TDAlign + "' valign='" + TDVAlign + "'>" + columns_str + "</TD></TR></table>";
    }
    DivNode.style.display = "block";

    //"alert(TRstyleHeight);" +
    //"alert(TRClassName);" +
    //"alert(columns_str);" +

    if(browser == 'Netscape')
    {
        if (EventOn == "Row") 
        {
            DivNode.style.top=parseInt(mouseY(e)) + 1 + "px";
        } 
        else 
        { 
            DivNode.style.top= findPosY(objToMove) + "px";
        }

        DivNode.style.left=parseInt(mouseX(e)) + 1 + "px";
        DivNode.style.height=objToMove.offsetHeight+ "px";
        DivNode.style.width=objToMove.offsetWidth+ "px";
    }else
        if(browser == 'Microsoft Internet Explorer')
        {
            if (EventOn == "Row")
            {
                DivNode.style.top=parseInt(mouseY(event))+ "px";
            }
            else 
            { 
                DivNode.style.top= findPosY(objToMove) + "px";
                if (parseInt(mouseY(event)) > (findPosY(objToMove) + objToMove.offsetHeight) ||  parseInt(mouseY(event)) < findPosY(objToMove))
                {
                    //"alert(\"Hello\"); \n" +
                    if(DivNode!=null)
                    {
                        DivNode.innerHTML="";
                        DivNode.style.display="none";
                    }
                    cleanup();
                    return;
                } 
            }

            DivNode.style.left=parseInt(mouseX(event))+ "px";
            DivNode.style.height=objToMove.offsetHeight+ "px";
            DivNode.style.width=objToMove.offsetWidth+ "px";
        }
    return false;
}

function ShowThumbnail(TBHeight, TBWidth, PopupWindowID, SrcID, ThumbnailImg)
{
    PopupWindowID = "Div_" + PopupWindowID;
    SrcObj = document.getElementById(SrcID);
    document.getElementById(ThumbnailImg).src = SrcObj.src;
    var Popupwindow = document.getElementById(PopupWindowID);
    Popupwindow.style.height = TBHeight+ "px";
    Popupwindow.style.width = TBWidth+ "px";    
    //setTimeout ('ALShowPopupBox(\'' + event + '\',\'' + PopupWindowID + '\')',1000);
    ALShowPopupBox(event, PopupWindowID);
}

function HideThumbnail(PopupWindowID)
{
//alert(PopupWindowID);
    PopupWindowID = "Div_" + PopupWindowID;
    ALClosePopup(PopupWindowID);
} 

function ShowImgTT_ListControl(url)
{
    config. BorderWidth = 1;
    config. Padding = 0;
    config. FadeIn	= 300;
    config. FollowMouse		= false;
    return "<img id='img_ListCtrl' src='"+url+"' alt='' />";
}

//-------------------------------------------------MultiSelectList.js----------------------------------------------------------------------------

function SingleSelect(UnSelectedListBoxID, ValidSelectedListBoxID, HiddenControlClientID, ExplicitSelection)
{
    var UnSelectedListObject;
    var ValidSelectedListObject;
    var already_Selected = 0;
    
    UnSelectedListObject = document.getElementById(UnSelectedListBoxID);
    ValidSelectedListObject  = document.getElementById(ValidSelectedListBoxID);
    
    for (var VarCount=0; parseInt(VarCount) < parseInt(UnSelectedListObject.options.length); VarCount++)
    {
        if (UnSelectedListObject.options[VarCount].selected)
        {
            var OptionObject    = new Option();
            OptionObject.text   = UnSelectedListObject.options[VarCount].text;
            OptionObject.value  = UnSelectedListObject.options[VarCount].value;
            
            for (var tempCount=0; parseInt(tempCount) < parseInt(ValidSelectedListObject.options.length); tempCount++)
            {
                if(ValidSelectedListObject.options[tempCount].value == OptionObject.value)
                {
                    already_Selected = 1;
                    break;
                }
            }
            if(already_Selected == 0 )
            {
                ValidSelectedListObject.options[ValidSelectedListObject.options.length] = OptionObject;
            }
            if (ExplicitSelection == "True")
            {
                UnSelectedListObject.remove(VarCount);
                VarCount--;   
            }
        }
    }
    GetSelectedValues(ValidSelectedListBoxID, HiddenControlClientID);    
}

function SelectAll(UnSelectedListBoxID, ValidSelectedListBoxID, HiddenControlClientID, ExplicitSelection)
{
    var UnSelectedListObject;
    var ValidSelectedListObject;
    
    UnSelectedListObject = document.getElementById(UnSelectedListBoxID);
    ValidSelectedListObject  = document.getElementById(ValidSelectedListBoxID);
    
    var skipOne = false;
    var newItem = 0;

    for (x=0; x<UnSelectedListObject.length; x++) 
    {
        skipOne = false;
        for (i=0; i<ValidSelectedListObject.length; i++)	
        {
            if (ValidSelectedListObject.options[i].value == UnSelectedListObject.options[x].value) 
            {
                skipOne = true;
            }
        }
        if (!skipOne) 
        {
            newItem = ValidSelectedListObject.length;
            ValidSelectedListObject[newItem] = new Option(UnSelectedListObject.options[x].text, UnSelectedListObject.options[x].value, 0, 0);

            // Sort the list
            while (newItem > 0 && ValidSelectedListObject.options[newItem].text < ValidSelectedListObject.options[newItem-1].text) 
            {
                tempText = ValidSelectedListObject.options[newItem-1].text;
                tempValue = ValidSelectedListObject.options[newItem-1].value;

                ValidSelectedListObject.options[newItem-1].text = ValidSelectedListObject.options[newItem].text;
                ValidSelectedListObject.options[newItem-1].value = ValidSelectedListObject.options[newItem].value;

                ValidSelectedListObject.options[newItem].text = tempText;
                ValidSelectedListObject.options[newItem].value = tempValue;

                
                newItem = newItem - 1;
            }
        }
    }
    
    if (ExplicitSelection == "True")
    {
       VarCount = parseInt(UnSelectedListObject.options.length);
       while (VarCount >= 0)
       {
            UnSelectedListObject.remove(VarCount);
            VarCount--;  
       }     
    }
    
    for (x=0; x<ValidSelectedListObject.length; x++)	
    {
        ValidSelectedListObject.options[x].selected = false;
    }
    GetSelectedValues(ValidSelectedListBoxID, HiddenControlClientID);        
}



function SingleRemove(UnSelectedListBoxID, ValidSelectedListBoxID, HiddenControlClientID, ExplicitSelection)
{
    var UnSelectedListObject;
    var ValidSelectedListObject;

    UnSelectedListObject = document.getElementById(UnSelectedListBoxID);
    ValidSelectedListObject  = document.getElementById(ValidSelectedListBoxID);

    
    for (var VarCount=0; parseInt(VarCount) < parseInt(ValidSelectedListObject.options.length); VarCount++)
    {
        if (ValidSelectedListObject.options[VarCount].selected)
        {
            if (ExplicitSelection == "True")
            {
                var OptionObject    = new Option();
                OptionObject.text   = ValidSelectedListObject.options[VarCount].text;
                OptionObject.value  = ValidSelectedListObject.options[VarCount].value;
                
                UnSelectedListObject.options[UnSelectedListObject.options.length] = OptionObject;                
            }            
            ValidSelectedListObject.remove(VarCount);
            VarCount--;
        }        
    }
    GetSelectedValues(ValidSelectedListBoxID, HiddenControlClientID);    
}
          

function RemoveAll(UnSelectedListBoxID, ValidSelectedListBoxID, HiddenControlClientID, ExplicitSelection)
{
    var UnSelectedListObject;
    var ValidSelectedListObject;

    UnSelectedListObject = document.getElementById(UnSelectedListBoxID);
    ValidSelectedListObject  = document.getElementById(ValidSelectedListBoxID);


    for (var VarCount=0; parseInt(VarCount) < parseInt(ValidSelectedListObject.options.length); VarCount++)
    {
        if (ExplicitSelection == "True")
        {
            var OptionObject    = new Option();
            OptionObject.text   = ValidSelectedListObject.options[VarCount].text;
            OptionObject.value  = ValidSelectedListObject.options[VarCount].value;
            
            UnSelectedListObject.options[UnSelectedListObject.options.length] = OptionObject;
            
        }
        ValidSelectedListObject.remove(VarCount);
        VarCount--;
    }
    GetSelectedValues(ValidSelectedListBoxID, HiddenControlClientID);
}    
                                         
function GetSelectedValues(ValidSelectedListBoxID, HiddenControlClientID)
{
    var ValidSelectedListObject;
    var HiddenControlObject;
    var SelectedValues;

    ValidSelectedListObject = document.getElementById(ValidSelectedListBoxID);
    HiddenControlObject = document.getElementById(HiddenControlClientID);
    HiddenControlObject.value = "";
    SelectedValues = "";
    for (var VarCount=0; parseInt(VarCount) < parseInt(ValidSelectedListObject.options.length); VarCount++)
    {
        if (SelectedValues == "" || SelectedValues == null)
        {
            SelectedValues = ValidSelectedListObject.options[VarCount].value;
        }
        else
        {   
            SelectedValues = SelectedValues + '$AL$' + ValidSelectedListObject.options[VarCount].value;                                                                                
        }
    }
    var HiddenControlObject = document.getElementById(HiddenControlClientID);
    if (SelectedValues != "" || SelectedValues != null)
        HiddenControlObject.value = SelectedValues;
    else
        HiddenControlObject.value = "";        
    
}   

function SetSelectedValue(ClickedListBoxID, HiddenVariableValueID, CurrentLevel, LastLevel)
{
    var HiddenFieldVar = document.getElementById(HiddenVariableValueID);
    var sender = document.getElementById(ClickedListBoxID);
    HiddenFieldVar.value = "";
    for (var VarCount=0; parseInt(VarCount) < parseInt(sender.options.length); VarCount++)
    {
        
        if (sender.options[VarCount].selected)
        {
            HiddenFieldVar.value = sender.options[VarCount].value;            
        }
    }
    for (var i=parseInt(CurrentLevel+1); i <parseInt(LastLevel); i++)
    {
        var OldLevel = "_Level" + CurrentLevel;
        var NewLevel = "_Level" + i;
        var TempVariable = HiddenVariableValueID.replace(OldLevel, NewLevel);
        var SubHiddenFieldVar = document.getElementById(TempVariable);
        
        SubHiddenFieldVar.value="";
    }
}


function ListBoxClicked(ClickedListBoxID, DestinationListBoxID, thisID,CurrentLevel, LastLevel, ExplicitSelection, HiddenVariableValueID)
{
    SetSelectedValue(ClickedListBoxID, HiddenVariableValueID, CurrentLevel, LastLevel)
    SourceListBox = document.getElementById(ClickedListBoxID);
    DestinationListBox = document.getElementById(DestinationListBoxID);
    var CurrentLevel;
    
    for (var VarCount=0; parseInt(VarCount) < parseInt(SourceListBox.options.length); VarCount++)
    {
        if (SourceListBox.options[VarCount].selected)
        {
            pos = DestinationListBoxID.lastIndexOf("_");
            if (pos != -1)
            {
                ListBoxName = DestinationListBoxID.substr(0, pos+1); 
                CurrentLevel = DestinationListBoxID.substr(pos+1, pos+2); 
                
                for (i=CurrentLevel; i<=LastLevel; i++)
                {
                    var LBName = ListBoxName + i;
                    tempLB = document.getElementById(LBName); 
                    for(x=0; x<tempLB.length; x++)
                    { 
                        tempLB.options[x] = null;
                        x--;
                    }
                }                
            }
            
            var HiddenFieldValue = SourceListBox.options[VarCount].value;
            HiddenFieldValue = HiddenFieldValue.replace(/ /g,"_");
            HiddenFieldValue = thisID + "_" + HiddenFieldValue + "_HiddenField";
            VarHiddenField = document.getElementById(HiddenFieldValue);
            if (VarHiddenField.value != null && VarHiddenField.value != '')
            {
                ChildValuesArray = VarHiddenField.value;
                
                ChildValuesArray = ChildValuesArray.split(",");
                for (var i=0; i<ChildValuesArray.length; i++)
                {
                    SecArray = ChildValuesArray[i].split(":");
                    var OptionObject    = new Option();
                    OptionObject.text   = SecArray[1];
                    OptionObject.value  = SecArray[0];
                    if (ExplicitSelection != "True")
                        DestinationListBox.options[DestinationListBox.options.length] = OptionObject;
                    else
                    {
                        level = parseInt(CurrentLevel) - 1;
                        RetrunedVal = CheckIfChildValueSelected(thisID,level, SecArray[0]);
                        if (RetrunedVal == true)
                        {                            
                        }
                        else
                        {
                            DestinationListBox.options[DestinationListBox.options.length] = OptionObject;
                        }
                    }
                }
            }
        }
    }
        
}

function CheckIfChildValueSelected(thisID, LevelID, SelectedValue)
{
    LevelID = thisID + "_HiddenField_Level_" + LevelID;
    SelectedValues = document.getElementById(LevelID);
    if (SelectedValues.value != null && SelectedValues.value != '')
    {
        
        SelectedVal = SelectedValues.value.split("$AL$");
        for (var cnt=0; cnt < SelectedVal.length; cnt++)
        {
            if (SelectedValue == SelectedVal[cnt])
                return true;            
        }
    }
    return false;
}

function PostBackHandler(ControlID, Level, LastLevel, thisID, PreviousSelectionHFID, HiddenVariableValueID)
{
    SetSelectedValue(ControlID, HiddenVariableValueID, Level, LastLevel)
    
    ControlObj = document.getElementById(ControlID);
    HiddenFieldObj = document.getElementById(PreviousSelectionHFID);    
    pos = ControlID.lastIndexOf("_");
    if (pos != -1)
    {
        ListBoxName = ControlID.substr(0, pos+1); 
        CurrentLevel = parseInt(Level) + 2;
        for (i=CurrentLevel; i<=LastLevel; i++)
        {
            var LBName = ListBoxName + i;
            tempLB = document.getElementById(LBName); 
            //var selectedListItemValue = SrcLB.options[SrcLB.selectedIndex].value;
            for(x=0; x<tempLB.length; x++)
            { 
                tempLB.options[x] = null;
                x--;
            }
        }                    
    }
    for(i=Level; i<LastLevel; i++)
    {
        var HFName = thisID + "_HiddenField_PreviousSelection_Level" + i;
        RestHiddenFieldObj = document.getElementById(HFName);
        RestHiddenFieldObj.value = "";
    }    
    for (var VarCount=0; parseInt(VarCount) < parseInt(ControlObj.options.length); VarCount++)
    {
        if (ControlObj.options[VarCount].selected)
        {
            SelectedValue = ControlObj.options[VarCount].value;
            HiddenFieldObj.value = ControlObj.options[VarCount].value;
        }
    }     
    Level = parseInt(Level) + 1;
    Level = Level + ":" + SelectedValue;
    __doPostBack(ControlID,Level);
    
    
}

//-------------------------------------------------PopUpMenu.js----------------------------------------------------------------------------

var PrevVisibleDivID='';
var Action_Done = '';
var PrevTRID='';        



function changeTR(id) 
{       
    if ( PrevTRID != '')
    {
        if(document.getElementById(PrevTRID) != null)
            document.getElementById(PrevTRID).className='PopupMenuItemBar';
    }
    PrevTRID = id; 
    document.getElementById(id).className='PopupMenuSelectedItemBar';
}


if (document.addEventListener) 
{
    document.addEventListener('mouseup',Form_MouseUp_Popup,false);
}
else if (document.attachEvent)
{
    document.attachEvent('onmouseup',Form_MouseUp_Popup,false);
}

function Form_MouseUp_Popup()
{   
    if ( PrevVisibleDivID != '' )
    {  
        var PrevDivID = document.getElementById(PrevVisibleDivID); 
        if (PrevDivID != null)
        {
            PrevDivID.style.position ='absolute'; 
            PrevDivID.style.display  ='none'; 
            PrevDivID.style.overflow ='hidden'; 
        }
        else
        {
            PrevVisibleDivID = '';
        }
    }    
}



//-------------------------------------------------PredefinedSearch.js---------------------------------------------------------------------------
 function ShowNamedPopup(URL)
{
    X = document.body.offsetWidth / 2;
    X -= (600 / 2);
    X += 100; //Left Pane

    Y = document.body.offsetHeight / 2;
    Y -= (460 / 2);

    window.open(URL,'','top='+Y+'px,left='+X+'px,resizable=1,width=600,height=460,scrollbars=1,status=1');

}


function ClearNHFields(SelectedValuesDiv, AllowClearJavascript)
{
    var m_SelectedValuesDiv;
    
    m_SelectedValuesDiv = document.getElementById(SelectedValuesDiv);
    if (m_SelectedValuesDiv!= null)
        m_SelectedValuesDiv.innerHTML = "";
    if (AllowClearJavascript!= null)
    {
        var m_AllowClearJavascript =  new Function(DecodeSpecialCharactersForJS(AllowClearJavascript));
        m_AllowClearJavascript();
    }
}




function JRangeCalendarCheckFields( FromDate, ToDate)
    
    {
    
      
        var datefrom;
        datefrom = document.getElementById(FromDate);
        
        
        var dateto;
        dateto = document.getElementById(ToDate);
        
        
        if ((datefrom.value != "") && (dateto.value!= ""))
        {
                
        var dayfrom = datefrom.value;
        var datefrom1= dayfrom.split(" ");
                
        var dayfromvalue = datefrom1[0]*1;
        var monthfromvalue = GetMonthValue(datefrom1[1]);
        var yearfromvalue = parseInt(datefrom1[2]);
      
             
                
        var dayto = dateto.value;
        var dateto1= dayto.split(" ");
        
        
        var daytovalue = dateto1[0]*1;
        var monthtovalue = GetMonthValue(dateto1[1]);
        var yeartovalue = parseInt(dateto1[2]);
       
        
        
       if (yearfromvalue > yeartovalue)
        {
            ShowAlert('Alert_FromDateToDate_Shared');
            return false;
            
        }
        else
        {   
            if ((yearfromvalue == yeartovalue) && (monthfromvalue > monthtovalue)) 
            {
                ShowAlert('Alert_FromDateToDate_Shared');
                return false;
            }
            else
            {
                if ((yearfromvalue == yeartovalue) && (monthfromvalue == monthtovalue) && (dayfromvalue > daytovalue))
                {
                    ShowAlert('Alert_FromDateToDate_Shared');
                    return false;
                }
             }
         }
         }
      }    
     function OnSearchBtnClick(IDList, ControlID)
      {     //debugger;
      //code change for testmanager(17Dec09)            
      if(ControlID.indexOf("$gps$btn_Search")>0 || ControlID.indexOf("$tcps$btn_Search")>0)//this condition ensures that Search button is clicked on Features grid / Testcases grid / TestResults grid 
      {
          if (isdatachangedongrid())//isdatachangedongrid() is defined in TestManagement.js
          return;
      }
      //ends
        if (IDList == "")
        {
           __doPostBack(ControlID,'');
        }
        else
        {        
           
           var result = true;
           var Datatype = IDList.split("$NEXTFIELD$");
           var i = 0;
           
           
           
           while ( Datatype[i] != "")
           {
                
                var typeandcontent = Datatype[i].split("$");
                
                switch (typeandcontent[0])
                
                {   
                    case "DATERANGE": 
                    var index = 1;
                    
                    while(typeandcontent[index] != "")
                        {   
                            result = JRangeCalendarCheckFields(typeandcontent[index],typeandcontent[index+1]);
                            
                            if (result == false)
                                break;
                             
                            index = index +2;
                            
                         }
                         
                         break;
                         
                   //More cases along with logic can be added here.
                         
                   }
                   
                   if (result == false)
                             break;
                   
                   
               i++; 
           }
           if (result == false)
               { 
                    return; 
               }
               
          else
               { 
               __doPostBack(ControlID,''); 
               } 
        }      
     
      } 

//-------------------------------------------------SquareBlankSection.js----------------------------------------------------------------------------

var slideSpeed_SBS = 10000;	// Higher value = faster
var timer_SBS = 0;	// Lower value = faster

    function HandleDiv_SBS(ExpandModeDiv, CollapseModeDiv)
    {//debugger;
        var numericId = 0;
        var ExpandDiv = document.getElementById(ExpandModeDiv);
        
	    HandleDiv_SBS1(ExpandModeDiv, CollapseModeDiv);
        if(!ExpandDiv.style.display || ExpandDiv.style.display=='none')
        {
            ExpandDiv.style.display='block';
            ExpandDiv.style.visibility = 'visible';
            ExpandDiv.style.position = '';
            ExpandDiv.style.height = document.getElementById(CollapseModeDiv).offsetHeight + 'px';

            slideContent_SBS(ExpandModeDiv, ExpandModeDiv, CollapseModeDiv, slideSpeed_SBS, 1);
    		
            document.getElementById(CollapseModeDiv).style.visibility='hidden';
            document.getElementById(CollapseModeDiv).style.position='absolute';
            document.getElementById(CollapseModeDiv).style.display='none';
            document.getElementById(CollapseModeDiv).style.overflow='hidden';	
            handleProd_AB('S',ExpandModeDiv);             
        }
        else
        {
            slideContent_SBS(ExpandModeDiv, CollapseModeDiv, ExpandModeDiv, (slideSpeed_SBS*-1), 1);
             handleProd_AB('H',ExpandModeDiv);
        }
    }

    function slideContent_SBS(SlidingDiv, ToShowDiv, ToHideDiv, direction, numTime)
    {
        var obj =document.getElementById(SlidingDiv);
        var contentObj = document.getElementById(SlidingDiv+'_Content');
        
        if ( numTime == 1 )
        {
            if ( obj.clientHeight == 0 )
                height = contentObj.offsetHeight;
            else
                height = obj.clientHeight;
        }
        else
            height = obj.clientHeight;
        
        height = height + direction;
        rerunFunction = true;
        if(height>contentObj.offsetHeight)
        {
            height = contentObj.offsetHeight;
            rerunFunction = false;
        }
        if (direction >0 )  //Expanding
        {
            RHSHeight = 1;
            if(height<=RHSHeight)
            {
                height = 1;
                rerunFunction = false;
            }
        }
        else  //Collapsing
        {
            PrevDisplay = document.getElementById(ToShowDiv).style.display;
            document.getElementById(ToShowDiv).style.display='block';
            RHSHeight =parseInt(document.getElementById(ToShowDiv+'_Content').offsetHeight); 
            if(height<=RHSHeight)
            {
                height = RHSHeight;
                document.getElementById(ToHideDiv).style.visibility='hidden';
                document.getElementById(ToHideDiv).style.position='absolute';
                document.getElementById(ToHideDiv).style.display='none';
                document.getElementById(ToHideDiv).style.overflow='hidden';
    				
                document.getElementById(ToShowDiv).style.visibility='visible';
                document.getElementById(ToShowDiv).style.position='';
                document.getElementById(ToShowDiv).style.display='block';
                document.getElementById(ToShowDiv).style.overflow='visible';
                rerunFunction = false;
            }
            else
                document.getElementById(ToShowDiv).style.display=PrevDisplay;
        }

        obj.style.height = height + 'px';
        var topPos = height - contentObj.offsetHeight;
        if(topPos>0)topPos=0;
        contentObj.style.top = topPos + 'px';
        if(rerunFunction)
        {
            setTimeout('slideContent_SBS(\'' + SlidingDiv + '\',\'' + ToShowDiv + '\',\'' + ToHideDiv + '\',' + direction + ',2)',timer_SBS);
        }
        else
        {
            if(height<=RHSHeight)
            {
                obj.style.display='none'; 
                obj.style.height = '';
            }
            else
            {
                document.getElementById(ToHideDiv).style.visibility='hidden';
                document.getElementById(ToHideDiv).style.position='absolute';
                document.getElementById(ToHideDiv).style.display='none';
                document.getElementById(ToHideDiv).style.overflow='hidden';
    				
                document.getElementById(ToShowDiv).style.visibility='visible';
                document.getElementById(ToShowDiv).style.position='';
                document.getElementById(ToShowDiv).style.display='block';
                document.getElementById(ToShowDiv).style.overflow='hidden';
                obj.style.height = '';
            }
        }
    }

    function HandleDiv_SBS1(ExpandModeDiv, CollapseModeDiv)
    {
        if (document.getElementById(ExpandModeDiv).style.visibility == 'visible')
        {
            document.getElementById(CollapseModeDiv).style.visibility='hidden';
            document.getElementById(CollapseModeDiv).style.position='absolute';
            document.getElementById(CollapseModeDiv).style.display='none';
            document.getElementById(CollapseModeDiv).style.overflow='hidden';

            document.getElementById(ExpandModeDiv).style.visibility='visible';
            document.getElementById(ExpandModeDiv).style.position='';
            document.getElementById(ExpandModeDiv).style.display='block';
            document.getElementById(ExpandModeDiv).style.overflow='hidden';
        }
        else
        {
            if (document.getElementById(ExpandModeDiv).style.visibility == 'hidden')
            {
                document.getElementById(ExpandModeDiv).style.visibility='hidden';
                document.getElementById(ExpandModeDiv).style.position='absolute';
                document.getElementById(ExpandModeDiv).style.display='none';
                document.getElementById(ExpandModeDiv).style.overflow='hidden';
    				
                document.getElementById(CollapseModeDiv).style.visibility='visible';
                document.getElementById(CollapseModeDiv).style.position='';
                document.getElementById(CollapseModeDiv).style.display='block';
                document.getElementById(CollapseModeDiv).style.overflow='hidden';
            }
        }
    }






//-------------------------------------------------TaskPane.js-----------------------------------------------------------------------------------------

 function ShowSolutionWindow(URL,Target)
 {
  Width     = window.parent.screen.width  - 10 + "px";
  Height    = window.parent.screen.height - 175 + "px";
  Params    = 'left=0px,top=0px,width=' + Width + ',height='+ Height +',scrollbars=1,status=1,menubar=1,toolbar=1,location=1,resizable=1';
  window.open(URL,Target,Params);
 }
//------------------------------------------------------------------------------------------------------------------------------------------



//------------------------------------------------ALSuggestionBox.js -(Start)----------------------------------------------------------------------------------------------------

// JScript File

    var SearchTextBox;
    var SuggestionList;
    var AutoCompleteDiv1;
    var AutoCompleteDiv2;
    var DataDetailsarray;
    var Zindex;
    var IsSearchActive ;
    var IsSearchDataChanged;
    var previousSearchText;
    var GetDataListUrl;
    var CurrentGroupName;
    var DoUniqueSelection;
    var PrevousSearchValue;

    //setTimeout("LookupData()",300);
    document.onmouseup      = hideSuggestionListBox;

    Zindex                  = 1000;
    IsSearchActive          = false;
    function WriteTraceMessage(Message)
    {
        WriteTraceMessageDiv = document.getElementById("WriteTraceMessage");
        if( WriteTraceMessageDiv == null)
        {
            WriteTraceMessageDiv         = document.createElement("div");
            WriteTraceMessageDiv.id      = "WriteTraceMessage";
            document.forms[0].appendChild(WriteTraceMessageDiv);
        }
        WriteTraceMessageDiv.innerHTML += Message;
    }

    function VerifyData(eventObj, sender)
    {
        PrevousSearchValue = sender.value;
        if(eventObj.keyCode == 9)
        { 
            OnTabKeyPress(sender);
        }
    }
    
    function GetDataList(eventObj,sender,GroupName,UniqueSelection)
    {
        CurrentGroupName    = GroupName;
        DoUniqueSelection   = UniqueSelection;
        SearchTextBox       = sender;
       
        if((PrevousSearchValue == SearchTextBox.value) && (eventObj.keyCode != 40 && eventObj.keyCode != 38 && eventObj.keyCode != 13))
        {
            if(SearchTextBox.value == "")
            {
                document.getElementById("Value_" + SearchTextBox.id).value  = 0;
                document.getElementById(CurrentGroupName + SearchTextBox.id).value = 0;
                HiddenAutoCompelete();
            }
            return;
        }
         
         GetSuggestionList();
         
         if (eventObj.keyCode == 40 || eventObj.keyCode == 38 || eventObj.keyCode == 13) //Up -- Down key
         {
            CheckToSetTextboxvalue(eventObj);
            return;
         }
       
        document.getElementById("Value_" + SearchTextBox.id).value  = 0;
        document.getElementById(CurrentGroupName + SearchTextBox.id).value = 0;
        if(document.getElementById("iframeHandlerURL_" + CurrentGroupName) != null)
        GetDataListUrl        = document.getElementById("iframeHandlerURL_" + CurrentGroupName).src;
        else
        GetDataListUrl        = document.getElementById("hiddenHandlerURL_" + CurrentGroupName).value;

        IsSearchDataChanged   = true;

        LookupData();
    }

    function LookupData()
    {
        var GetKeyDataListUrl
        var GetDataLisyXmlHttp;
        var SearchKey;
        if(SearchTextBox != null)
        {
            SearchKey = SearchTextBox.value;
            if(SearchKey =="")
            {
                HiddenAutoCompelete();
                return;
            }
           /* WriteTraceMessage("C");
            if(previousSearchText == SearchTextBox.value && SearchTextBox.value!="" && (IsSearchDataChanged && !IsSearchActive))
            {
             WriteTraceMessage("R");
             IsSearchDataChanged    = false;
             IsSearchActive         = true;*/
             if( document.getElementById(CurrentGroupName + encodeURI(SearchKey)) == null)
             {
                //Get Data from Server
                GetKeyDataListUrl      =  GetDataListUrl + '&SearchText='+ encodeURI(GetFormatedParameter(SearchKey));
                ALAjaxDopageRequest(GetKeyDataListUrl,"InvokeshowSuggestionList",""); //Function in Ajax
                //setTimeout("ResetSearch()",10000);
             }
             else   
               showSuggestionList(SearchKey, document.getElementById(CurrentGroupName + encodeURI(SearchKey)).value);
             
           /* }
            else
                previousSearchText = SearchKey;*/
        }
        //setTimeout("LookupData()",300);     
    }

    function ResetSearch()
    {
        IsSearchActive         = false;
    }

    function InvokeshowSuggestionList(AjaxResponseText)
    {
        var Responsearray = null;
        var Searchkey     = null;
        var DataList      = null;

        IsSearchActive    = false;
        if(AjaxResponseText == "")
            return;
         
        Responsearray = AjaxResponseText.split("$ALEQAL$");
        Searchkey = Responsearray[0];
        DataList  = Responsearray[1];

        showSuggestionList(Searchkey, DataList);
    } 

    function showSuggestionList(Searchkey, DataList)
    {
        var OptionCount =0;
        if(DataList == "" || DataList == null)
        {
            hideSuggestionList();
            return;
        }

        GetSuggestionList();
        SuggestionList.innerHTML        = "";
        SuggestionList.style.position   = 'absolute';         

        var itemArray = DataList.split("$ALCOAL$");
        for(var i =0; i < itemArray.length;i++)
        {
            if(itemArray[i] == "")
                continue;
                
            DataDetailsarray          = itemArray[i].split("$ALQOAL$");
            
            if(DoUniqueSelection && IsValueSelected(DataDetailsarray[0]))
                continue;
                
            Item        = new Option();
            Item.value  = DataDetailsarray[0];
            Item.text   = DataDetailsarray[1];
            
            SuggestionList.options[OptionCount] = Item;
            
            if(OptionCount == 0)
                SuggestionList.size = 2;
            else if(OptionCount<4)
                SuggestionList.size = OptionCount+1;
           OptionCount++;
        }

        SuggestionList.selectedIndex = -1;

        if(SuggestionList.options.length > 0)
        {
            ShowAutoCompelete();
            //ShowAutoCompelete_Auto(Searchkey);
        }
        else
            HiddenAutoCompelete();

        showSuggestionListBox();

        //Add Data to page
        if( document.getElementById(CurrentGroupName + encodeURI(Searchkey)) == null)
        {
            HiddenField         = document.createElement("input");
            HiddenField.id      = CurrentGroupName + encodeURI(Searchkey);
            HiddenField.type    = 'hidden';
            HiddenField.value   = DataList;
            document.forms[0].appendChild(HiddenField);
            //document.getElementById("CacheHTML_" + CurrentGroupName).appendChild(HiddenField);
        }
    }

    function showSuggestionListBox()
    {
        if(SuggestionList != null)
        {
            SuggestionList.style.display    = "block";
            SuggestionList.style.position   = 'absolute';    
            SuggestionList.style.zIndex = Zindex++;
        }
    }

    function hideSuggestionList()
    {
        hideSuggestionListBox();
    }

    function hideSuggestionListBox()
    {
      if(SuggestionList != null)
      {
        if(SuggestionList.style.display == 'block')
        {
            SearchTextBox.focus();
            SearchTextBox.value = SearchTextBox.value;
        }
        
        SuggestionList.style.display = "none";
        SuggestionList.style.position= 'absolute';
        HiddenAutoCompelete();
      }
    }

    function CheckToSetTextboxvalue(eventObj,sender)
    {
        var SelectedValueIndex;
        if(SuggestionList != null && SuggestionList.style.display == "block")
        {
          if (eventObj.keyCode == 13) 
          {
              SetTextboxvalue(sender);
              return;
          }
          
           SelectedValueIndex = SuggestionList.selectedIndex;
           
           if (eventObj.keyCode == 38)
           {
                SelectedValueIndex--;
                if(SelectedValueIndex < 0)
                    SelectedValueIndex = 0;
           }
           else
           if (eventObj.keyCode == 40)
           {
                SelectedValueIndex++;
                if(SelectedValueIndex == SuggestionList.options.length)
                    SelectedValueIndex --;
           }
           
           SuggestionList.options[SelectedValueIndex].selected = true;
           SetSelectedvalue();
           HiddenAutoCompelete();
        }
    }

    function SetTextboxvalue(sender)
    {
        if (SuggestionList != null) 
        {
            SetSelectedvalue();
        }
        hideSuggestionList();
    }

    function SetSelectedvalue()
    {
        if(SuggestionList.options.length >0 )
        {
            if(SuggestionList.selectedIndex < 0)
                SuggestionList.selectedIndex = 0;
                
            SearchTextBox.value = SuggestionList[SuggestionList.selectedIndex].text;
            document.getElementById("Value_" + SearchTextBox.id).value  = SuggestionList[SuggestionList.selectedIndex].value;
            document.getElementById(CurrentGroupName + SearchTextBox.id).value = SuggestionList[SuggestionList.selectedIndex].value;
        }
    }

    function GetSuggestionList()
    {
        var SearchTextBoxDiametric;
        var SuggestionDiv;

        SuggestionList  = document.getElementById("SuggestionList");
        if(SuggestionList == null)
        {
           SuggestionDiv                    = document.createElement("div");
           SuggestionDiv.style.position     = 'absolute';
           SuggestionDiv.style.top          = "0px";
           SuggestionDiv.style.left         = "0px";
           SuggestionDiv.innerHTML          = "<select id=\"SuggestionList\" onclick=\"Javascript:SetTextboxvalue(this);\" ></select>";
           document.forms[0].appendChild(SuggestionDiv);
           SuggestionList                   = document.getElementById("SuggestionList")
           SuggestionList.size              = 2;
           SuggestionList.style.position    = 'absolute';
           SuggestionList.style.display     = 'none';
           SuggestionList.className         = SearchTextBox.className;
        }

        if(SuggestionList != null)
        {
            SearchTextBoxDiametric      = ALGetWindowDiametric(SearchTextBox);
            SuggestionList.style.top    = SearchTextBoxDiametric.Y + SearchTextBox.clientHeight + 3 + 'px';
            SuggestionList.style.left   = SearchTextBoxDiametric.X + 1 + 'px';
            SuggestionList.style.width  = SearchTextBox.clientWidth  + 4 + 'px';
        }
        SearchTextBox.className = SuggestionList.className;
    }

    function IsValueSelected(value)
    {
        var InputElements = document.getElementsByTagName("INPUT")
        for( var i = 0; i < InputElements.length; i ++ )
        {
            if(InputElements[i].id.indexOf(CurrentGroupName)==0)
            {
                if(InputElements[i].value == value)
                {
                    return IsElementVisible(InputElements[i]);
                }
            }
        }
        return false;
    }

    function IsElementVisible(ElementObj)
    {
        if(ElementObj.style != null && ElementObj.style.display == "none")
            return false;

        if(ElementObj.parentNode!= null)
                return IsElementVisible(ElementObj.parentNode);
        return true;
    }

    function Focuslost(eventObj,Sender, GroupName)
    {
        if(document.getElementById("Value_" + Sender.id).value == 0 &&  Sender.value != "")
        {
         if((SuggestionList!= null && SuggestionList.style.display != 'block') && Sender.className !="TextRed")
         {
            Sender.className = "TextRed";
            Sender.value = Sender.value;
         }
        }
    }     

    function OnTabKeyPress(Sender)
    {
         if(SuggestionList!= null && SuggestionList.style.display == 'block' && SuggestionList.length >=1)
         {
              if(Sender.type == "text" && SuggestionList.selectedIndex < 0)
                SuggestionList.options[0].selected = true;
                
              SetTextboxvalue(SuggestionList);
         }
         HiddenAutoCompelete();
    }

    function ShowAutoCompelete_Auto(InputText)
    {
        if(SuggestionList[0].text.toLowerCase() == InputText.toLowerCase())
            return;
            
        if( SearchTextBox.createTextRange )
        {
            SearchTextBox.value = SuggestionList[0].text;
            hRange = SearchTextBox.createTextRange();
            hRange.findText(SuggestionList[0].text.substring(InputText.length));
            hRange.select();
        }
        else
        {
            SearchTextBox.setSelectionRange( InputText.length, SuggestionList[0].text.length );
        }
    }


    function ShowAutoCompelete()
    {
        var Inputtext;
        var SelectedText;
        AutoCompleteDiv1     = document.getElementById("AutoCompleteDiv1");
        if(AutoCompleteDiv1 == null)
        {
           AutoCompleteDiv1                     = document.createElement("div");
           AutoCompleteDiv1.id                  = "AutoCompleteDiv1";
           AutoCompleteDiv1.style.display       = "none";
           AutoCompleteDiv1.style.position      = 'absolute';    
           document.forms[0].appendChild(AutoCompleteDiv1);
           AutoCompleteDiv1.className           = SearchTextBox.className;
           AutoCompleteDiv1.style.top           = '0px';
           AutoCompleteDiv1.style.left          = '0px';
        }

        AutoCompleteDiv2                          = document.getElementById("AutoCompleteDiv2");
        if(AutoCompleteDiv2 == null)
        {
           AutoCompleteDiv2                     = document.createElement("div");
           AutoCompleteDiv2.id                  = "AutoCompleteDiv2";
           AutoCompleteDiv2.style.display       = "none";
           AutoCompleteDiv2.style.position      = 'absolute'; 
           document.forms[0].appendChild(AutoCompleteDiv2);
           AutoCompleteDiv2.className           = SearchTextBox.className;
           AutoCompleteDiv2.className           = "TextSelected";
        }

        if(SuggestionList.options.length > 0)
        {
            Inputtext    = SearchTextBox.value;
            SelectedText = SuggestionList[0].text;
            
            //Reset the Input char with case
            Inputtext    = SelectedText.substring(0,Inputtext.length);
            SearchTextBox.value = Inputtext;
            
            SelectedText = SelectedText.substring(Inputtext.length);
	        Inputtext = ALReplaceall(Inputtext,"<","&lt;");
	        Inputtext = ALReplaceall(Inputtext,">","&gt;");
	        SelectedText = ALReplaceall(SelectedText,"<","&lt;");
	        SelectedText = ALReplaceall(SelectedText,">","&gt;");

            AutoCompleteDiv1.innerHTML      =  Inputtext;
            AutoCompleteDiv2.innerHTML      =  SelectedText.replace(" ","&nbsp;");
            AutoCompleteDiv2.style.display  = "block";
            AutoCompleteDiv1.style.display  = "block";

            SearchTextBoxDiametric          = ALGetWindowDiametric(SearchTextBox);
            AutoCompleteDiv2.style.top      = SearchTextBoxDiametric.Y + 3 + 'px';
            AutoCompleteDiv2.style.left     = SearchTextBoxDiametric.X + AutoCompleteDiv1.clientWidth + 5 + 'px';
            AutoCompleteDiv1.style.display  = "none";
        }
        else
        {
            AutoCompleteDiv2.style.display    = "none";
        }
    }

    function HiddenAutoCompelete()
    {
        if(AutoCompleteDiv2 != null)
            AutoCompleteDiv2.style.display    = "none";
    }
    
    function showSearchWindow(SearchTextBoxID, GroupName, UniqueSelection)
    {
        SearchTextBox       = document.getElementById(SearchTextBoxID);
        CurrentGroupName    = GroupName;
        DoUniqueSelection   = UniqueSelection;
        GetSuggestionList();
       
        if(document.getElementById("iframeHandlerURL_" + CurrentGroupName) != null)
        GetDataListUrl        = document.getElementById("iframeHandlerURL_" + CurrentGroupName).src;
        else
        GetDataListUrl        = document.getElementById("hiddenHandlerURL_" + CurrentGroupName).value;
        window.open(GetDataListUrl +"&ShowSearchWindow=true","","left=250,top=100,resizable=1,width=900,height=700,scrollbars=1,status=1");
    }
    
    function SetSearchSelectedUser(UserIDNamelist)
    {
        if((UserIDNamelist != null || UserIDNamelist!="") && SuggestionList != null)
        {
            showSuggestionList("$", UserIDNamelist);
            SetTextboxvalue(SuggestionList);
        }
    }
    
//------------------------------------------------ALSuggestionBox.js -(End)----------------------------------------------------------------------------------------------------

//----------------------------------------------------- Javascript Added for Multi Select ---------------------------------------------------------------
function RemoveSingleSelectedValue_Form(SelectedValuesID,Sender,PostBackID,FieldName)
{
    objSelectedValuesID = document.getElementById(SelectedValuesID);
    Arguments               = FieldName + "$AL$FIELDNAME$AL$";
    strVal                  = "";
        strVal = objSelectedValuesID.value;
        objSelectedValuesID.value = ""
        for(var ElementCount=0;ElementCount<CheckBoxList_FieldName.getElementsByTagName('input').length;ElementCount++)
        {
            ItemElement = CheckBoxList_FieldName.getElementsByTagName('input')[ElementCount];
            if(ItemElement.type == 'hidden')
            {
                CheckBoxList_FieldName.cells[ElementCount].innerHTML = "";
                Div_Delete = document.getElementById("Div_NHDelete_" + Sender);
                 if (Div_Delete!= null)
                    Div_Delete.style.display = "None";

            Arguments   = Arguments + strVal;
            alert(Arguments);
            __doPostBack(PostBackID,Arguments);
            }
         }
}
function RemoveSelectedMultiSelectValues(CheckBoxList_FieldName,Div_RemovePanelID,MSName, Sender, MSSelectedValues,ArgumentContain)
{
        objHiddenSelectedValues = document.getElementById(MSSelectedValues);
        Arguments               = MSName + "$AL$FIELDNAME$AL$";
        strAvailableVal         = "";
        strRemoveVal            = "";
        DeleteNo                = 0;
	objCheckBoxList_FieldName = document.getElementById(CheckBoxList_FieldName,Div_RemovePanelID);
        
	var ItemElements = objCheckBoxList_FieldName.getElementsByTagName('input');

	    for(var ElementCount=0;ElementCount<ItemElements.length;ElementCount++)
        {
            ItemElement = ItemElements[ElementCount];
            if(((ItemElement.type == 'checkbox')||(ItemElement.type == 'radio'))&&(ItemElement.checked))
            {
                strRemoveVal = strRemoveVal + ItemElement.value + "$COLON$" + ItemElement.text + "$AL$";
                DeleteNo ++;
            }
            else if(ItemElement.type == 'hidden')
            {
                strRemoveVal = strRemoveVal + ItemElement.value + "$COLON$" + ItemElement.text + "$AL$";
                DeleteNo ++;
            }
            else
                strAvailableVal = strAvailableVal + ItemElement.value + "$COLON$" + ItemElement.text + "$AL$";
         }
         
         if (DeleteNo > 0)
         {
            // Hide Remove button in case of no values selected
              if ((ItemElements.length ==0) || (ItemElements.length == DeleteNo))
              {
                 Div_Delete = document.getElementById(Div_RemovePanelID);
                 if (Div_Delete!= null)
                    Div_Delete.style.display = "None";
              }
            
            if (objHiddenSelectedValues!=null)
                objHiddenSelectedValues.value   = strAvailableVal;     
             if (ArgumentContain == "SELECTEDVAL")
                Arguments   = Arguments + strAvailableVal;
             else
                Arguments   = Arguments + strRemoveVal;
            __doPostBack(Sender,Arguments);
        }
        else
            ShowAlert('Alert_NoValuesSelectedForMultiSelect_Shared');
}
function handleProd_AB(v,frmid)//addded for testmanagement
{
var prod_ab=document.getElementById("p_ab");
if(prod_ab!=null)
{
if(frmid.indexOf('frm_ProductDetails')>-1)
{
if (v=='S')
{
prod_ab.style.visibility='visible';
prod_ab.style.display='block';
}else
{
prod_ab.style.visibility='hidden';
prod_ab.style.display='none';
}
}
}
}
function setFocus(ctrlid)
{

    var item=null;
    item=document.getElementById(ctrlid);
    if(item!=null)
    {
        item.focus();
    }
} 