function NGPostBack(target,arg)
{
////    alert(target);
   var finalargument='';
 if (arguments.length > 0 && target != null)
      finalargument  = target;
           
 if (arguments.length > 1 && arg != null) 
    finalargument = finalargument + '|' + arg;
////    
////    alert(finalargument);
////    alert(target);
  //__doPostBack('ctl01$cpTarget$hdf_Target', finalargument);


} 
//UpdatePanel::used to PostBack the page & update panel named panel.
function UpdatePanel(panel)
{   
    __doPostBack(_Target, panel);
} 


//This function is called whenever user click on close button of Tool
function CloseTool(toolBarName, toolName)
{
       
  __doPostBack(toolBarName, toolName);
}




//This checks if the client browser has a popupblocker software installed or not.
function IsPopupBlocker() 
{
var oWin = window.open("","testpopupblocker","width=10,height=10,top=5000,left=5000");
if (oWin==null || typeof(oWin)=="undefined") {
    alert("Please allow popups on this site or you may not be able to access some of the functionalities. ");
} else 
{
	oWin.close();
}
return;
}


function ValidateBuffer(src, args)
{   
    if (args != null)
    {   
        args.IsValid = ! isNaN(args.Value);        
    }    
}

//---------------------
//returns the <protocol>//hostname/pathname
function NGServerUrl()
{
    var protocol = window.location.protocol;
    var theHost = window.location.hostname;
    var port = window.location.port;
    
    if (port)
    {
        port=":"+ port;
    }
    
    var path = window.location.pathname;
        path = path.substring(0, path.indexOf("/", 1));
    
    var newUrl = protocol + "//" + theHost +  port + path;
    return newUrl;	
}



//NGNavigate - navigate's to the specified url.
//Url        : this value can be either relativeUrl or absolute url
//resolveUrl : can be either true or false. if the value is true, the perfix's the url with server url 
function NGNavigate(url, resolveUrl)
{
    var prefixServerUrl = new Boolean(resolveUrl);
    var newUrl = url;
    if(prefixServerUrl)
    {
        newUrl = NGServerUrl() + url;
    }
    //window.navigate(newUrl);    
    window.location.href = newUrl;
}



//-------------------------
function SetDirection(elementID)
{
     
   try{
     var elm=NgGetElementById(elementID);
     var eLeft=parseInt(xreplace(elm.style.left,"px",""));
     var mapWidth= parseInt(xreplace(NgGetElementById("MapControlDiv").style.width,"px",""));
      // alert(elementID)
      // alert(elm.getAttribute("SetSmartNavValues"))
     if(elm.getAttribute("SetSmartNavValues")==null && eLeft < 50)
      {
    
       if (eLeft==1)
         mapWidth=mapWidth/4;
       
       if (htmlDir=="LTR")
          {
            if( elm.style.left != "")
                 elm.style.left=eLeft+ mapWidth + "px";
          }
        else
          {   
            if( eLeft!=1 && eLeft < 50)
                eLeft=20;
            
           
            // This is when the box loads after execution of this line
            var cWidth= elm.clientWidth;
           
            if (cWidth==0)
                cWidth=220;
            
                 elm.style.left=document.body.clientWidth - mapWidth - cWidth - eLeft + "px";                   
        }
      }
     }catch(e){}
}

//-------------------------
function SetDirectionFlip(elementID)
{
     
   try{
     var elm=NgGetElementById(elementID);
     var eLeft=parseInt(xreplace(elm.style.left,"px",""));
     
      // alert(elementID)
      // alert(elm.getAttribute("SetSmartNavValues"))
     if(elm.getAttribute("SetSmartNavValues")==null)
      {
       
       if (htmlDir=="RTL")
          {
            if( elm.style.left != "")
                elm.style.left=document.body.clientWidth - eLeft - elm.clientWidth + "px";  
          }
             
                                  
        }
      
     }catch(e){}
}


     //-------------------------	
     function NgOpenPopup(url,iWidth,iHeight,PopupTitle)
        { 
                
        var commoniFrame="commoniFrame";
        var commoniFrameWraper=_CommonPopupLayer;
         var popupTitleId="commoniFrameTitle";
        
            //Find the iFrame by ID
            var _iFrame;
                   try{
                      _iFrame=NgGetElementById(commoniFrame);
                     } 
                   catch(e){}
            //Find the iFrame LayerWraper by ID
            if (commoniFrameWraper !=null)
              {
               var _iFrameLayer;
               try{
                   _iFrameLayer=NgGetElementById(commoniFrameWraper);
                  } 
               catch(e){}
               
                if (_iFrameLayer!=null)
                    {
                     ShowLayer(commoniFrameWraper,null,null);
                     _iFrameLayer.style.visibility='visible';
                    }
              }   
             
             if (_iFrame!=null)
                {
                  ShowLayer(commoniFrame,null,null);
                 
                 _iFrame.style.visibility='visible';
                 frames[commoniFrame].location.href=url;
                 
                 if (iHeight!=null)
                   _iFrame.height= iHeight;
                 if (iWidth!=null)
                   _iFrame.width= iWidth;
                }
        
        //Set the popup title
        var _PopupTitleElement;
        _PopupTitleElement=NgGetElementById(popupTitleId);

        if (_PopupTitleElement !=null)
            _PopupTitleElement.innerHTML=PopupTitle;
        
         }
         
         

 //-------------------------	
    function NgClosePopup()
    { 
        var commoniFrame="commoniFrame";
        var commoniFrameWraper=_CommonPopupLayer;           
        var _iFrame;
        try{
                  _iFrame=window.top.NgGetElementById(commoniFrame);
        } catch(e){}
        
        if (commoniFrameWraper !=null)
        {
            var _iFrameLayer;
              try{
                      _iFrameLayer=window.top.NgGetElementById(commoniFrameWraper);
                 } catch(e){}
                   
            if (_iFrameLayer!=null)
                {
                 HideLayer(commoniFrameWraper,null,null);
                 _iFrameLayer.style.visibility='hidden';
                }
        }
         
        if (_iFrame!=null)
        {
             _iFrame.style.display = 'none';
             HideLayer(commoniFrame,null,null);
             window.top.frames[commoniFrame].location.href='about:blank';
        }         
    }


    //-------------------------	
     function NgOpenWindow(url,windowTitle, attributes)
        { 
        
        //height= Specifies the height of the window. 
        //left= Specifies the x coordinates of the window in pixels. IE only. See "screenX" as well. 
        //location= Specifies if the location bar of the window should be included. 
        //menubar= Specifies if the menu bar of the window should be included. 
        //resizable= Specifies if window should be resizable. 
        //screenX= Specifies the x coordinates of the window in pixels. NS only. See "left" as well. 
        //screenY= Specifies the x coordinates of the window in pixels. NS only. See "top" as well. 
        //scrollbars =Specifies if window should contain scrollbars. 
        //status= Specifies if the status bar of the window should be included. 
        //toolbar= Specifies if the toolbar of the window (ie: reload button) should be included. 
        //top= Specifies the y coordinates of the window in pixels. IE only. See "screenY" as well. 
        //width= Specifies the width of the window. 
        
        // Example:
        // windowTitle='Orion Window';
        // attributes= 'width=600,height=500,status,resizable';
        // window.open('http://www.Oriongis.com',windowTitle,attributes);

        if(attributes ==null)
            attributes="";
            
        if(url !=null)    
            window.open(url,windowTitle, attributes);

        }
        

    //-------------------------	
     function NgCloseWindow()
        { 
            window.close();
        }
        
     
     //-------------------------	
     function NgRefreshParentWindow()
     {        
        if (window.top)
        {        
            window.top.RefreshPage();
        }
     }
        
    //-------------------------	
     function NgRefreshWindow()
    {
       window.RefreshPage();
    }
        
        
    //------------------------- 
    function xreplace(s, r, w){
       return s.split(r).join(w);
    }


 function getUniqueValue()
 {
    var date = new Date();
    var value0 = date.toGMTString();
    var value1 = replaceAll(value0, " ", "_");
    var value2 = replaceAll(value1, ":", "_");
    return replaceAll(value2, ",", "_");
 }
 
 function replaceAll(strValue, sourceChar, destChar)
 {
    if(strValue != null && sourceChar != null && destChar != null)
    {
        while(strValue.indexOf(sourceChar) >= 0)
        {
            strValue = strValue.replace(sourceChar, destChar);
        }
    } 
    
    return strValue;
 }
 
  function NgAdjustPopupSize()
  {
    var commoniFrame="commoniFrame";
    
    var _iFrame;
    try{
              _iFrame=window.top.NgGetElementById(commoniFrame);
    } catch(e){}
   
   
        try{
            window.top.calcHeight(commoniFrame);
            window.top.calcWidth(commoniFrame);    
        }catch(e){}
   }




// disable default context menu
    function _hideDefaultContextmenu(e)
    {       
        var firingEle = (m_ie5) ? event.srcElement : e.target;
         
        if(firingEle.href != null && firingEle.href.substring(0,11)=='javascript:')
        { 
           if (!m_ie5)
              e.stopPropagation();
          
          return false;
        }          
    }

   
    var m_ie5 = (window.navigator.appName.toLowerCase().indexOf("microsoft")>=0);

    if (m_ie5)
    {
        document.attachEvent('oncontextmenu',_hideDefaultContextmenu);	            
    }
    else
    {
        
        document.addEventListener('contextmenu',_hideDefaultContextmenu,false);
       
    }
   
 