﻿function checkAll2( control, cbGroupName )
{
var cbGroup = control.form.elements[cbGroupName], i = 0, cb;
while( cb = cbGroup[i++] )
{
cb.checked = control.checked;
}
}

function checkall(pID, el){
	var ip = document.getElementById(pID).getElementsByTagName('input'), i = ip.length - 1;
	for (i; i > -1; --i){
		if(ip[i].type && ip[i].type.toLowerCase() === 'checkbox'){
			ip[i].checked = el.checked;
		}
	}
}

function uncheckall(){
	var ip = document.getElementsByTagName('input'), i = ip.length - 1;
	for (i; i > -1; --i){
		if(ip[i].type && ip[i].type.toLowerCase() === 'checkbox'){
			ip[i].checked = false;
		}
	}
}



/* Added on 12/21/2010   sappikatla@icfi.com*/


function changemodal()
{

 var MasterpanelID=document.getElementById("MstPnlID");

         $(document).ready(function(){
                                if(MasterpanelID!=null)
                                    {
                                       var masID="#" + MasterpanelID.value;
                                       $(masID).removeClass("sitepmappathCurrNode")            
                                    }
            });

    $find("programmaticModalPopupBehavior").hide(); 
    $find("ForgotUsernamePopupBehavior").show(); 
    return false;
}

function backtotop(pageheaderLblclientID)
            {
             var pageheaderlbl=pageheaderLblclientID.id;
             if(pageheaderlbl!=null)
                    {
                  document.getElementById(pageheaderlbl).scrollIntoView(true);
                    }
            }


function closePopup_Res()
{
    var x=$find("UserFeedbackPopupExtender"); 
            if (x!=null)
                        {   
                        x.hide();
                         }
}

function closePopup_EmailConfirm()
{
    var y=$find("EmailConfirmationPopUp"); 
            if (y!=null)
                        {   
                        y.hide();
                         }
}

 function cleartxt(txtbox)
            {
  var x=document.getElementById(txtbox.id);
           if (x!=null)
                    {   
                    x.value='';
                   var checkname=x.id.indexOf("tbxTitle");
                   if(checkname != -1) {$find("TBoxWtrmarkExt1").set_Text("");}
                    else {$find("TBoxWtrmarkExt2").set_Text("");}
                     }
            return false;
            }
            
           
/* Added on 12/21/2010   sappikatla@icfi.com*/

/* sappikatla@icfi.com  Code for Cross Browser compatibility*/

function openmodal()
{

/* 2 parameter's needed.The hidepanel parameter & the status_label*/

  var MasterpanelID=document.getElementById("MstPnlID");
  var StaLblID=document.getElementById("StaLblID");

         $(document).ready(function(){
                                if(MasterpanelID!=null)
                                    {
                                       var masID="#" + MasterpanelID.value;
                                       $(masID).removeClass("sitepmappathCurrNode")            
                                    }
                                if(StaLblID!=null)
                                    {
                                        var StaLbID="#" + StaLblID.value;
                                        $(StaLbID).text("");
                                    }
            });

    $find("programmaticModalPopupBehavior").show(); 
     return false;
}


function closemodal()
{
 
 /* 3 parameters are added.In this order  UserName,Password,Statuslbl  */
 
  var UsrNmID=document.getElementById("UsrNmID");
  var PswdID=document.getElementById("PswdID");
  var StaLblID=document.getElementById("StaLblID");  
 
 $(document).ready(function(){
 
                            if(UsrNmID!=null)
                                  {
                                      var x="#" + UsrNmID.value;
                                       $(x).val("");   
                                   }                               
                            if(PswdID!=null)
                                  {
                                      var y="#" + PswdID.value;
                                      $(y).val("");   
                                  }
                             if(StaLblID!=null)
                                {
                                    var z="#" + StaLblID.value;
                                   $(z).text("");
                                }
            });

    $find("programmaticModalPopupBehavior").hide();    
}

function closeForogotmodal()
{  

 /* 2 parameters are added.In this order  EmailID,Label_Status   */
 
  var UsrNmID=document.getElementById("FgtEmlID");
  var PswdID=document.getElementById("FgtLblSta");
 
$(document).ready(function(){

                            if(UsrNmID!=null)
                              {
                                   var x1='#'+UsrNmID.value; 
                                   $(x1).val("");   
                               }
                               
                            if(PswdID!=null)
                              {
                                   var x2='#'+PswdID.value; 
                                   $(x2).replaceWith("");;            
                              }                        

            });
            
var popup=$find("ForgotUsernamePopupBehavior")
if (popup!=null){ popup.hide(); }


}

function userfeedback()
                    {
  var cookieExists=document.cookie.indexOf("mrc");    
   
   if (cookieExists==-1)
        {
            openmodal();
             return false;
        }
}

function cs(){

/*1 param is sent .  loadingdiv   */

     $(document).ready(function(){           
                if (loadingdiv[0]!=null)
                       { 
                        var x2='#'+loadingdiv[0]; 
                        $(x2).css("display","none");                       
                       }
            });            
                    }

/*                */

/*
    ----------------------------------------------------------
                Admin Resource Javascript
    ----------------------------------------------------------    
*/

  function ddlclearSel(ddlClientId)
        {
        
        if(ddlClientId!=null)
            {
            var ddl_ClientId=document.getElementById(ddlClientId.id);
            ddl_ClientId.selectedIndex=0;            
            }
            return false;
            
        }
        
 function Reset()
    {
                         if (elementCollection.length!=0)
                            {
                                document.getElementById(elementCollection[0]).checked=false;                     
                                document.getElementById(elementCollection[1]).checked= false;
                                document.getElementById(elementCollection[2]).checked=false;                     
                                document.getElementById(elementCollection[3]).selectedIndex=-1;
                                $find("TBoxWtrmarkExt1").set_Text("");
                                $find("TBoxWtrmarkExt2").set_Text("");
                            }
    
    }                 
        
   function setFocus(clientid)
    {
        if (clientid!=null)
            {
              document.getElementById(clientid.id).scrollIntoView(true);
            }
    }
        
        
/*----------------------------------------------------------*/


/*----------------Smoother flow of Collapsible panel----------------*/
   function pageLoad(sender, args) 
            {
                smoothAnimation();
            }
       
       
    function smoothAnimation()
    {
            var collPanel = $find("CollPanelExt_AdminSearch");
            if(collPanel!=null)
                           {
            collPanel._animation._fps = 45;
            collPanel._animation._duration = 0.50;
                            }
    }
    
/*------------------------------------------------------------*/

/* Animation on Updatepanel when updated */

function onUpdating()
     {
     
        var hdnfield = $get('HddnFieldUpdPanel'); 
        // get the update progress div
        var updateProgressDiv = $get('updateProgressDiv');
        
        if(updateProgressDiv==null)
        {
            var hdnfields=$get('HddnFieldupdProDiv');
            updateProgressDiv=$get(hdnfields.value);
        }
         
        // make it visible
        updateProgressDiv.style.display = 'block';        
        updateProgressDiv.style.backgroundImage = "url('~/images/transparent.png')";
        //  get the Updatepanel element               

        var UpdPnl = $get(hdnfield.value);
        //UpdPnl.disabled=true;
        
        // get the bounds of both the Updatepanel and the progress div
        var UpdPnlBounds = Sys.UI.DomElement.getBounds(UpdPnl);
        //--------------------------------Test--------------------------------
        updateProgressDiv.style.width = UpdPnlBounds.width+ 'px';
        updateProgressDiv.style.height = UpdPnlBounds.height+ 'px';
        var x = UpdPnlBounds.x;
        var y = UpdPnlBounds.y;
        Sys.UI.DomElement.setLocation (updateProgressDiv, x, y);
        return;
        /*-----------------------------------------------------------------*/
        var updateProgressDivBounds = Sys.UI.DomElement.getBounds(updateProgressDiv);
        
        //    do the math to figure out where to position the element (the center of the Updatepanel)
        var x = UpdPnlBounds.x + Math.round(UpdPnlBounds.width / 2) - Math.round(updateProgressDivBounds.width / 2);
        var y = UpdPnlBounds.y + Math.round(UpdPnlBounds.height / 2) - Math.round(updateProgressDivBounds.height / 2);
        
        //    set the progress element to this position
        Sys.UI.DomElement.setLocation (updateProgressDiv, x, y);        
    }

    function onUpdated() 
    {
        var hdnfield = $get('HddnFieldUpdPanel'); 
        var UpdPnl = $get(hdnfield.value);
        UpdPnl.disabled=false;
    
        // get the update progress div
        var updateProgressDiv = $get('updateProgressDiv'); 
        
        if(updateProgressDiv==null)
        {
            var hdnfields=$get('HddnFieldupdProDiv');
            updateProgressDiv=$get(hdnfields.value);
        }
        // make it invisible
        updateProgressDiv.style.display = 'none';
          
    }


/*----------------------------------------------------*/

function closemodalInsert()
{
    /* Cancel Insert popup for PAGE LINK*/
    $find("PgBtmLnksInsertEditModal").hide(); 
    return false;
}

function ResetScrollPosition()
    {
        /* 
             Scroll to top of page if Error in ajax enabled page.
             Used in ***SearchEditAddResources*** page      
        */
        setTimeout("window.scrollTo(0,0)",0);
    }
    
   function Labelfocus(LabelID)
    {        
       var cntrl12=document.getElementById(LabelID.id);
       if (cntrl12!=null)
        {    
            //cntrl12.focus();                
          cntrl12.scrollIntoView(true);
         return;            
        }
    }

    function Labeltest(UsrCliID, PassCliID) 
    {
        if (UsrCliID != null && PassCliID != null)
         {

            var UsNmTxtBx = UsrCliID.id;
            var PwdTxtBx = PassCliID.id;

            var getUsNmtxtbox = document.getElementById(UsNmTxtBx);
            var getPwdtxtbox = document.getElementById(PwdTxtBx);

            if (getUsNmtxtbox.value != '' && getPwdtxtbox.value != '') 
            {
                getUsNmtxtbox.disabled = true;
                getPwdtxtbox.disabled = true;
                getUsNmtxtbox.style.background = '#CCCCCC';
                getPwdtxtbox.style.background = '#CCCCCC';
            }

        }

    }


    /*-------------TAAView Print-------------*/


    function codeSelect() {
        //var myDiv = document.getElementById(sId);ContentPanel
        var DivID = document.getElementById("ContentPanel");
        var myDiv;
        if (DivID != null) {
            myDiv = document.getElementById(DivID.value);
        }
        if (window.getSelection) {
            var selection = window.getSelection();
            if (selection.setBaseAndExtent) { /* for Safari */
                selection.setBaseAndExtent(myDiv, 0, myDiv, 1);
            }
            else { /* for FF, Opera */
                var range = document.createRange();
                range.selectNodeContents(myDiv);
                selection.removeAllRanges();
                selection.addRange(range);
            }
        }
        else { /* for IE */
            var range = document.body.createTextRange();
            range.moveToElementText(myDiv);
            range.select();
        }
        return false;
    }


    /*----------------------------------*/

    /*---------User Voting Report--------*/


    function supressPostBack() 
        {
            return false;
        }
    


    /*----------------------------------*/
