function DisplayConformation(ConfMsg,url)
{
	var NewQueryString="";
	if (confirm(ConfMsg)==true)	
	{
		//the bellow lines are added to display first page when a single Role is there in last page and that role is deleted
		var gd = igtbl_getGridById(strClientID + "_igGrid");
		if(gd.Rows.length==1)
		{
			var nvcQueryString=url.split("&");
			var part_num=0;
			while (part_num < nvcQueryString.length)
			{
					if(nvcQueryString[part_num].indexOf("page")!=-1)
					{
						var PageArray;
						PageArray=nvcQueryString[part_num].split("=");
						var PageNumber;
						PageNumber=PageArray[1];
						if(PageNumber!=1)
						NewQueryString = NewQueryString + "&" + ComponentInstanceID + "_page=" + (PageNumber-1);
					}
					else
					{
						NewQueryString=NewQueryString + '&' + nvcQueryString[part_num];
					}
					part_num+=1;
			}
			fnChangeView(NewQueryString.substring(1));
		}
		else
		{
			fnChangeView(url);
		}
	 }
	/*if(! confirm(ConfMsg))
		return false;	
	fnChangeView(URL);*/
}
function SelectCheckBoxID(cbx,GridID)
{
	var grid=igtbl_getGridById(GridID);
	var strIDList;
	var frmID=grid.UniqueID.substring(0,grid.UniqueID.lastIndexOf(":")).replace(":","_")
	strIDList=document.getElementById(frmID + "_hdnSelectedList").value;
	if(cbx.checked)
	{
		if(strIDList=="")
		{
			strIDList=cbx.id;	
				
		}
		else
		{
		   
		   strIDList=strIDList+ "," + cbx.id;
		}
	}
	else
	{
		 strIDList=strIDList.replace(cbx.id+"," ,"");
		 strIDList=strIDList.replace(cbx.id,"");
		 grid.Bands[0].Columns[0].Element.childNodes[0].checked=false; /*This is to un check the selecct all check box if any of user check boxes are un checked*/
		   
	}
	strIDList=strIDList.replace(",,",",");  /* This line deletes two continues camma if exist in selected list */
	if(strIDList.lastIndexOf(",")==strIDList.length-1)
		strIDList=strIDList.substring(0,strIDList.length-1); /* this is to delete the last camma if exist in selected list */ 
	document.getElementById(frmID + "_hdnSelectedList").value=strIDList;
	
}
function fnSendMessageLinkClick(ObjectID,ObjType,UserStatus)
{
	popupwindow=window.open("PublicModules/SendMail.aspx?ObjectIDs="+ ObjectID + "&ObjectType=" + ObjType + "&UserStatus=" +UserStatus ,"SendMessage","height=450,width=800,status=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,left=30,top=50");
	popupwindow.focus();
}
function fnAssignLinkClick(ObjectID,command,ObjType)	
{
	
	var targetURL;
	var features;
	var gs=igtbl_getGridById(igGridName);
	features='width=800,height=600,scrollbars=yes,resizable=Yes,status=1';
	targetURL="admin/Assign.aspx?ObjectID=" + ObjectID + "&cmd=" + command + "&ObjectType=" + ObjType;		
	popupwindow=window.open(targetURL,"UserList",features);
	popupwindow.focus();
}


function fnCheckItemsSelected(action,strClientID,alertMsg,cnfMsg,url)
{
	if(document.getElementById(strClientID + "_hdnSelectedList").value=='')
	{
		alert(alertMsg);
		return false;
	}
	if(url != null)
		document.forms[0].action = url;
	var selectList;
	selectList=',' + document.getElementById(strClientID + "_hdnSelectedList").value + ',';
	if((selectList.indexOf(','+UserID+',')!=-1) && (action=='Deactivate'))
	{
		   alert('Login User can not be deactivated');
		   if(selectList.length==3) // means only login user i.e ,1,
				return false;
	}
	
	
	if( action=='Activate' || action=='Deactivate' )
	{
		
		if(confirm(cnfMsg))
		{
			if(action=='Deactivate')
			{
			  UserID=UserID+',';
			  selectList=selectList.replace(UserID,'');
			  document.getElementById(strClientID + "_hdnSelectedList").value=selectList;
			}
			 return true;
		}
		else
		   return false;
		
	}
	else if(action=='AssignContentToUsers' || action=='UnAssignContentToUsers')
	{
		var ObjectIDList;
		ObjectIDList=document.getElementById(strClientID + "_hdnSelectedList").value;
		popupwindow=window.open("Admin/AssignContent.aspx?UserID=" + ObjectIDList+"&str="+action,'popup','resizable=yes,scrollbars=yes,resizable=yes,height=450,width=800');
		popupwindow.focus();
		return false;
	}
	else if(action=='SendMessage')
	{
		fnSendMessageLinkClick(document.getElementById(strClientID + "_hdnSelectedList").value)
		return false;
	}
	
}

//==Satish 20110413
function fnDenyUserReg(ObjectID, cnfMsg, urlparameters) {
    //debugger;
    if (urlparameters == undefined) {
        var agree = confirm(cnfMsg);
        if (agree) {
            var features = 'height=480,width=750,status=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,left=30,top=50ss';
            var targetURL = "admin/DenyComments.aspx?ObjectID=" + ObjectID;
            popupwindow = window.open(targetURL, "NotApproveUserReg", features);
            popupwindow.focus();
        }
    }
    else {
        var agree1 = confirm(cnfMsg);
        if (agree1) {
            PerformActionOnUsers(ObjectID, 'denyuser', urlparameters)
            __doPostBack('refresh', '');
        }
    }

}

 function TrackPrivilegesChecked(chkObj,RoleID,hdnID)
  {	 
		var hdnObj=document.getElementById(hdnID);		

		if(chkObj.checked==true)
		{
			hdnObj.value=hdnObj.value + RoleID + '|';
		}
		else
		{
			hdnObj.value=hdnObj.value.toString().replace(RoleID + '|','');
		}
		try
		{
			hdnObj.value=hdnObj.value.replace('undefined','')
		}catch(e){}
    }
function afterSelectedTabChange(owner, tabItem, evnt)
{
	fnSavePasswordValues();
	var ultraTab = igtab_getTabById (owner.ID);
	if(ultraTab.getSelectedIndex()==0)
	{			
		SetEnablePrevButton(false);
		SetEnableNextButton(true);
	}
	if(ultraTab.getSelectedIndex()>0)
	{	
		//SetEnableNextButton(true);
		try
		{
			var flag=0;
			for(tabCount=ultraTab.getSelectedIndex()+1;tabCount<ultraTab.Tabs.length;tabCount++)
			{
				if(ultraTab.Tabs[tabCount].getVisible()==true)
				{				    
					flag=1;
					break;
				}	
			}			
			if(flag==0)
			{
				SetEnableNextButton(false);				
			}
			else
			{
				SetEnableNextButton(true);				
			}
				
		}
		catch(ex)
		{
		
		}
		SetEnablePrevButton(true);
	}
	if(ultraTab.getSelectedIndex()==ultraTab.Tabs.length-1)
	{		
		SetEnableNextButton(false);
		SetEnablePrevButton(true);
	}	
}



function fnEmailConfirm(hdnEmailConfirmObj)
{			
	Page_ClientValidate();
	ValidatorOnSubmit()	
	if(!Page_IsValid)
	{				
		return false;
	}	
	return true;
}

function fnActivateAction(UserStatus,action,strClientID,alertMsg,cnfMsg,ObjectTypeID,SiteID)
{
	if(document.getElementById(strClientID + "_hdnSelectedList").value=='')
	{
		alert(alertMsg);
		return false;
	}
	
	var selectList;
	selectList=',' + document.getElementById(strClientID + "_hdnSelectedList").value + ',';
	if((selectList.indexOf(','+UserID+',')!=-1) && (action=='deactivate'))
	{
		   alert('Login User can not be deactivated');
		   if(document.getElementById(strClientID + "_hdnSelectedList").value.indexOf(",")==-1) 
				return false;
			
			selectList=selectList.replace(','+UserID,'')
			
			//this statement is moved down to resolve the issue getting error when only admin is selected and click on deactivate button
			//Modified by sharma
	}
	if(action=='activate' || action=='deactivate' || action=='approvalstatus|activate' || action=='approvalstatus|deactivate' )
	{
		var agree=confirm(cnfMsg);
		var WinName=action;
		if(agree)
		{
			var csvObjectIDs=selectList; //document.getElementById(strClientID + "_hdnSelectedList").value;
			PerformActionOnUserList(csvObjectIDs,action,SiteID)
			if (action.split("|").length =2)
			{
				WinName=action.split("|")[1];
			}
			//popupwindow=window.open("PublicModules/SendMail.aspx?ObjectIDs="+csvObjectIDs+"&action=" +action+"&userstatus="+UserStatus+"&ObjectType="+ObjectTypeID ,action,"height=450,width=750,status=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,left=30,top=50");
			popupwindow=window.open("PublicModules/SendMail.aspx?ObjectIDs="+csvObjectIDs+"&action=" +action+"&userstatus="+UserStatus+"&ObjectTypeID="+ObjectTypeID ,WinName,"height=450,width=750,status=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,left=30,top=50");
			popupwindow.focus();
			document.getElementById(strClientID + "_hdnSelectedList").value="";
		}
		
	}
	return false;
}
function fnSingleActivateAction(UserStatus, csvObjectIDs, action, cnfMsg, url, email, ObjectTypeID, SiteID, urlparameters) {

    if (urlparameters == undefined) {
        var agree = confirm(cnfMsg);
        var WinName = action;
        if (agree) {
            PerformActionOnUserList(csvObjectIDs, action, SiteID)
            if (action.split("|").length = 2) {
                WinName = action.split("|")[1];
            }
            if (email = null || email == "") {
                document.getElementById(strClientID + "_hdnSelectedList").value = ""; //this state ment is written by sharma. this is written to resolve the issue 9868. The issue is if user select a check box and click of activate link then user will be activated. again if clicked on activate then selection maintais so again asking conformation to delete
                __doPostBack('refresh', '');  /* this is to just post back the form after deactivation actoin if the user is not having email issue no 9539*/
            }
            else {
                //popupwindow=window.open("PublicModules/SendMail.aspx?ObjectIDs="+csvObjectIDs+"&action=" +action+"&userstatus="+UserStatus+"&ObjectType="+ObjectTypeID ,action,"height=450,width=750,status=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,left=30,top=50");
                popupwindow = window.open("PublicModules/SendMail.aspx?ObjectIDs=" + csvObjectIDs + "&action=" + action + "&userstatus=" + UserStatus + "&ObjectTypeID=" + ObjectTypeID, WinName, "height=450,width=750,status=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,left=30,top=50");
                popupwindow.focus();
            }
        }
    }
    else {
        var agree = confirm(cnfMsg);
        var WinName = action;
        if (agree) {
            PerformActionOnUserList(csvObjectIDs, action, SiteID)
            if (action.split("|").length = 2) {
                WinName = action.split("|")[1];
            }
            if (email = null || email == "") {
                document.getElementById(strClientID + "_hdnSelectedList").value = ""; //this state ment is written by sharma. this is written to resolve the issue 9868. The issue is if user select a check box and click of activate link then user will be activated. again if clicked on activate then selection maintais so again asking conformation to delete
                __doPostBack('refresh', '');  /* this is to just post back the form after deactivation actoin if the user is not having email issue no 9539*/
            }
            else {
                popupwindow = window.open("PublicModules/SendMail.aspx?ObjectIDs=" + csvObjectIDs + "&action=" + action + "&userstatus=" + UserStatus + "&ObjectTypeID=" + ObjectTypeID + "&urlparameters=adminapproval", WinName, "height=450,width=750,status=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,left=30,top=50");
                popupwindow.focus();
            }
        }
    }


}
function showConfirmMailing(cmd, ObjectID, ObjectTypeID, msg) {
    var agree = confirm(msg);
    if (agree == true) {
        CloseAndSendMail(cmd, ObjectID, ObjectTypeID);
    }
    else {
        var newurl = fnRemoveFromURL('ObjectID,Mode,hidesearch', window.location.href);
        window.location.href = newurl.replace('#', '');
    }
    //window.showModalDialog("admin/ConfirmMailing.aspx?cmd=" + cmd + "&ObjectID=" + ObjectID + "&ObjectTypeID=" + ObjectTypeID,'','dialogHeight:200px;dialogWidth:340px;center:yes;status:no'); 
}
function CloseAndSendMail(cmd,ObjectID,ObjectTypeID)
{
	popupwindow=window.open("PublicModules/SendMail.aspx?ObjectIDs="+ObjectID+"&action=" + cmd ,cmd,"height=450,width=750,status=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,left=30,top=50");
	popupwindow.focus();
}
function EditAndSendMail(cmd,ObjectID,ObjectTypeID)
{
	popupwindow=window.open("PublicModules/SendMail.aspx?ObjectIDs="+ObjectID+"&action=" + cmd ,action,"height=450,width=750,status=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,left=30,top=50");
	popupwindow.focus();
}


function fnUpdateUserLock(UserIDList,Operation)
{
	var agree=confirm('Are you sure you want to '+ Operation +' the selected user(s)?');
	if(agree)
	{
		PerformActionOnUserList(UserIDList,Operation)
		var action;
		if(Operation.toLowerCase()=="lock")
		  action=1
		else
		  action=2
		
		popupwindow=window.open("PublicModules/SendMail.aspx?ObjectIDs="+UserIDList+"&action=lock"+"&Locked=" +action+"&ObjectTypeID=1",Operation,"height=450,width=750,status=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,left=30,top=50");
		popupwindow.focus();
		document.getElementById(strClientID + "_hdnSelectedList").value="";
				
		//__doPostBack('refresh','')
	}
		/*
	if(Operation=='Lock')
		document.getElementById('lnkLock_'+UserIDList).innerText='UnLock'
	else
		document.getElementById('lnkLock_'+UserIDList).innerText='Lock'
		*/
	
}
function fnLockAllSelectedUsers(btnLock)
{
    var StrCannotLockUserList=document.getElementById(btnLock.getAttribute("hdnCanNotLockClientID")).value;
    var StrCannotUNLockUserList=document.getElementById(btnLock.getAttribute("hdnCanNotUnLockClientID")).value;
	if(document.getElementById(btnLock.getAttribute("hdnSelectedListClientID")).value=="")
	{
		alert("Please Select user to lock");
		return false;
	}
	if(StrCannotLockUserList!="")
	{
	
	    if(StrCannotUNLockUserList==StrCannotLockUserList)
	    {
	        alert("Selected Users are not enabled for lock");
	        return false;
	    }
	        
	    var arrCannotUNLockUsers=StrCannotUNLockUserList.split(",");
		var counter=0
		var DisabledToLockingUsers="";
		while(counter<arrCannotUNLockUsers.length)
		{
		    if(StrCannotLockUserList.indexOf(arrCannotUNLockUsers[counter])!=-1)
		        DisabledToLockingUsers=DisabledToLockingUsers + "," + arrCannotUNLockUsers[counter]
		    counter++;


		}
		if (DisabledToLockingUsers.substring(0,1)==",") 
		    DisabledToLockingUsers=DisabledToLockingUsers.substring(1,DisabledToLockingUsers.length);
		if (DisabledToLockingUsers.substring(DisabledToLockingUsers.length-1)==",") 
		    DisabledToLockingUsers=DisabledToLockingUsers.substring(0,DisabledToLockingUsers.length-1);
		if(DisabledToLockingUsers!="")
		{
		    alert("Lock operation is not applicable to following users \n" + DisabledToLockingUsers);
		    StrCannotUNLockUserList=StrCannotUNLockUserList.replace(DisabledToLockingUsers,"")
		    StrCannotLockUserList=StrCannotLockUserList.replace(DisabledToLockingUsers,"")
		}
		if (StrCannotLockUserList.substring(0,1)==",") 
		    StrCannotLockUserList=StrCannotLockUserList.substring(1,StrCannotLockUserList.length);
		if (StrCannotLockUserList.substring(StrCannotLockUserList.length-1)==",") 
		    StrCannotLockUserList=StrCannotLockUserList.substring(0,StrCannotLockUserList.length-1);
			
		var msgToDisplay="";
		if(StrCannotLockUserList!="") 
	        msgToDisplay=btnLock.getAttribute("cnflockallmsg").replace("{0}", "\n" + StrCannotLockUserList)
		if(StrCannotUNLockUserList!="")
		{
			if(msgToDisplay!="")
			    alert(msgToDisplay);
		}
		else
		{

			alert(msgToDisplay);
			return false;
		}	
	}
	fnUpdateUserLock(document.getElementById(btnLock.getAttribute("hdnSelectedListClientID")).value,'Lock')

}
function fnUnLockAllSelectedUsers(BtnUnLock)
{
    var StrCannotLockUserList=document.getElementById(BtnUnLock.getAttribute("hdnCanNotLockClientID")).value;
    var StrCannotUNLockUserList=document.getElementById(BtnUnLock.getAttribute("hdnCanNotUnLockClientID")).value;
        
	if(document.getElementById(BtnUnLock.getAttribute("hdnSelectedListClientID")).value=="")
	{
		alert("Please Select user to Unlock");
		return false;
	}
	
	
	if(StrCannotUNLockUserList!="")
	{
	    if(StrCannotLockUserList==StrCannotUNLockUserList)
	    {
	        alert("Selected users are not enabled to unlock");
	        return false;
	    }    
	    var arrCannotLockUsers=StrCannotLockUserList.split(",");
		var counter=0
		var DisabledToLockingUsers="";
		while(counter<arrCannotLockUsers.length)
		{
		    if(StrCannotUNLockUserList.indexOf(arrCannotLockUsers[counter])!=-1)
		        DisabledToLockingUsers=DisabledToLockingUsers + "," + arrCannotLockUsers[counter]
		    counter++;
		}
		if (DisabledToLockingUsers.substring(0,1)==",") 
		    DisabledToLockingUsers=DisabledToLockingUsers.substring(1,DisabledToLockingUsers.length);
	    
		if (DisabledToLockingUsers.substring(DisabledToLockingUsers.length-1)==",") 
		    DisabledToLockingUsers=DisabledToLockingUsers.substring(0,DisabledToLockingUsers.length-1);
		if(DisabledToLockingUsers!="")
		{
		    alert("UnLock operation is not applicable to following users \n" + DisabledToLockingUsers);
		    StrCannotUNLockUserList=StrCannotUNLockUserList.replace(DisabledToLockingUsers,"")
		    StrCannotLockUserList=StrCannotLockUserList.replace(DisabledToLockingUsers,"")
		}
		if (StrCannotUNLockUserList.substring(0,1)==",") 
		    StrCannotUNLockUserList=StrCannotUNLockUserList.substring(1,StrCannotUNLockUserList.length);
		    
		if (StrCannotUNLockUserList.substring(StrCannotUNLockUserList.length-1)==",") 
		    StrCannotUNLockUserList=StrCannotUNLockUserList.substring(0,StrCannotUNLockUserList.length-1);
	
		var msgToDisplay="";
		if(StrCannotUNLockUserList!="") 
	        msgToDisplay=BtnUnLock.getAttribute("cnfUNlockallmsg").replace("{0}", "\n" + StrCannotUNLockUserList)
		if(StrCannotLockUserList!="")
		{
	    	if(msgToDisplay!="")
			    alert(msgToDisplay);



		}
		else
		{

			alert(msgToDisplay);
		    return false
		}
	}	
	fnUpdateUserLock(document.getElementById(BtnUnLock.getAttribute("hdnSelectedListClientID")).value,'UnLock')
	document.getElementById(BtnUnLock.getAttribute("hdnCanNotUnLockClientID")).value="";
	document.getElementById(BtnUnLock.getAttribute("hdnCanNotLockClientID")).value="";
	document.getElementById(BtnUnLock.getAttribute("hdnSelectedListClientID")).value==""
}

function fnGetSelectedObjectIDInUserList(gridName, cellId)
{	
try{
	var igGrid;
	igGrid = igtbl_getGridById(gridName);
	var ClientID=igGrid.UniqueID.substring(0,igGrid.UniqueID.lastIndexOf("$"));
	if (ClientID!='' && ClientID!= null)
			ClientID=ClientID + '_';
	var hdnBox=document.getElementById(ClientID+'hdnSelectedList');
	var hdnCannotLockUsers=document.getElementById(ClientID+'hdnCanNotLock');
	var hdnCannotUNLockUsers=document.getElementById(ClientID+'hdnCanNotUnLock');
	
	if( hdnBox!=null)
	{
		var strVal="";
		var strCannotLockUsers=""
		var strCannotUNLockUsers=""
		strVal="," + hdnBox.value + ",";
		strCannotLockUsers="," + hdnCannotLockUsers.value + ",";
		strCannotUNLockUsers=","+ hdnCannotUNLockUsers.value + ",";
		var cell = igtbl_getCellById(cellId);
		if (cell.getRow(0).getCellFromKey("chkAssign") != null)
		{
			if(cellId==cell.getRow(0).getCellFromKey("chkAssign").Element.id)
			{
				if (cell.getRow(0).getCellFromKey("chkAssign").getValue()=="true" )
				{
					if(strVal.indexOf("," + cell.getRow(0).getCellFromKey("ObjectID").getValue() + ",")==-1)
					{
						if( hdnBox.value=="")	
							strVal= cell.getRow(0).getCellFromKey("ObjectID").getValue().toString();
						else
							strVal += cell.getRow(0).getCellFromKey("ObjectID").getValue().toString();			
						if(cell.getRow(0).getCellFromKey("Login Status").getValue()==1)
							if( hdnCannotLockUsers.value=="")	
								strCannotLockUsers= cell.getRow(0).getCellFromKey("FirstName").getValue().toString()+' '+cell.getRow(0).getCellFromKey("LastName").getValue().toString();
							else
								strCannotLockUsers += cell.getRow(0).getCellFromKey("FirstName").getValue().toString()+' '+cell.getRow(0).getCellFromKey("LastName").getValue().toString();
			
						if(cell.getRow(0).getCellFromKey("Login Status").getValue()==2)
							if( hdnCannotUNLockUsers.value=="")	
								strCannotUNLockUsers= cell.getRow(0).getCellFromKey("FirstName").getValue().toString()+' '+cell.getRow(0).getCellFromKey("LastName").getValue().toString();
							else
								strCannotUNLockUsers += cell.getRow(0).getCellFromKey("FirstName").getValue().toString()+' '+cell.getRow(0).getCellFromKey("LastName").getValue().toString();
					}
				}
				else
				{
					var objVal =',' +  cell.getRow(0).getCellFromKey("ObjectID").getValue().toString() + ',';
					if(cell.getRow(0).getCellFromKey("Login Status").getValue()==1)
						var objcannotlockval=','+cell.getRow(0).getCellFromKey("FirstName").getValue().toString() +' '+ cell.getRow(0).getCellFromKey("LastName").getValue().toString() + ',';
					if(cell.getRow(0).getCellFromKey("Login Status").getValue()==2)
						var objcannotUNlockval=','+cell.getRow(0).getCellFromKey("FirstName").getValue().toString() +' '+ cell.getRow(0).getCellFromKey("LastName").getValue().toString() + ',';
						
					strVal=strVal.replace(objVal,',');
					
					if(cell.getRow(0).getCellFromKey("Login Status").getValue()==1)
						strCannotLockUsers=strCannotLockUsers.replace(objcannotlockval,',')
					if(cell.getRow(0).getCellFromKey("Login Status").getValue()==2)
						strCannotUNLockUsers=strCannotUNLockUsers.replace(objcannotUNlockval,',')
				}
				
				if (strVal.substring(0,1)==",") strVal=strVal.substring(1);
				if(strCannotLockUsers.substring(0,1)==",") strCannotLockUsers=strCannotLockUsers.substring(1);
				if(strCannotUNLockUsers.substring(0,1)==",") strCannotUNLockUsers=strCannotUNLockUsers.substring(1);
				
				if (strVal.substring(strVal.length-1)==",") strVal=strVal.substring(0,strVal.length-1);
				if (strCannotLockUsers.substring(strCannotLockUsers.length-1)==",") strCannotLockUsers=strCannotLockUsers.substring(0,strCannotLockUsers.length-1);
				if (strCannotUNLockUsers.substring(strCannotUNLockUsers.length-1)==",") strCannotUNLockUsers=strCannotUNLockUsers.substring(0,strCannotUNLockUsers.length-1);
				
				hdnBox.value=strVal;	
				hdnCannotLockUsers.value=strCannotLockUsers;
				hdnCannotUNLockUsers.value=strCannotUNLockUsers;
			}
		}
		
	igGrid.Bands[0].Columns[0].Element.childNodes[0].checked=false; /*This is to un check the selecct all check box if any of user check boxes are un checked*/
	
	for (rcount=0;rcount<igGrid.Rows.length;rcount++)
	{
		if(igGrid.Rows.getRow(rcount).getCellFromKey("chkAssign").isEditable()==true)
		{	
			if (igGrid.Rows.getRow(rcount).getCellFromKey("chkAssign").getValue() == "false")
			{
				igGrid.Bands[0].Columns[0].Element.childNodes[0].checked=false;
				return
			}
		}
	}
	igGrid.Bands[0].Columns[0].Element.childNodes[0].checked=true;
	}
	}catch(ex){alert(ex.message)}
}
/**************AFFILIATES******************************************/
function fnAffiliateSingleActivate(UserStatus,csvObjectIDs,action,cnfMsg,url,email,ObjectTypeID,SiteID,afstatus)
{
	var agree=confirm(cnfMsg);
	var WinName=action;
	if(agree)
	{
		PerformActionOnAffiliateList(csvObjectIDs,action,SiteID)
		if (action.split("|").length=2)
		{
			WinName=action.split("|")[1];
		}
		if(email=null || email=="")
		{
			document.getElementById(strClientID + "_hdnSelectedList").value=""; 
			__doPostBack('refresh',''); 
		}
		else
		{
			popupwindow=window.open("PublicModules/SendMail.aspx?ObjectIDs="+csvObjectIDs+"&action=" +action+"&afuserstatus="+UserStatus+"&ObjectTypeID="+ObjectTypeID+"&isaffiliate=true&affiliatestatus="+afstatus,WinName,"height=450,width=750,status=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,left=30,top=50");
			//popupwindow=window.open("PublicModules/SendMail.aspx?ObjectIDs="+csvObjectIDs+"&action=" +action+"&userstatus="+UserStatus+"&ObjectTypeID="+ObjectTypeID+"&isaffiliate=true,WinName,"height=450,width=750,status=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,left=30,top=50");
			popupwindow.focus();
		}
	}
}

function fnGetSelectedObjectIDInAffiliateList(gridName, cellId)
{	
try{
	var igGrid;
	igGrid = igtbl_getGridById(gridName);
	var ClientID=igGrid.UniqueID.substring(0,igGrid.UniqueID.lastIndexOf("$"));
	if (ClientID!='' && ClientID!= null)
			ClientID=ClientID + '_';
	var hdnBox=document.getElementById(ClientID+'hdnSelectedList');	
	if( hdnBox!=null)
	{
	    
		var strVal="";		
		strVal="," + hdnBox.value + ",";		
		var cell = igtbl_getCellById(cellId);
		if (cell.getRow(0).getCellFromKey("chkAssign") != null)
		{
			if(cellId==cell.getRow(0).getCellFromKey("chkAssign").Element.id)
			{
				if (cell.getRow(0).getCellFromKey("chkAssign").getValue()=="true" )
				{
					if(strVal.indexOf("," + cell.getRow(0).getCellFromKey("UserID").getValue() + ",")==-1)
					{
						if( hdnBox.value=="")	
							strVal= cell.getRow(0).getCellFromKey("UserID").getValue().toString();
						else
							strVal += cell.getRow(0).getCellFromKey("UserID").getValue().toString();			
					}
				}
				else
				{
					var objVal =',' +  cell.getRow(0).getCellFromKey("UserID").getValue().toString() + ',';	
					strVal=strVal.replace(objVal,',');				
				}
				
				if (strVal.substring(0,1)==",") strVal=strVal.substring(1);					
				if (strVal.substring(strVal.length-1)==",") strVal=strVal.substring(0,strVal.length-1);
				hdnBox.value=strVal;					
			}
		}
		
	igGrid.Bands[0].Columns[0].Element.childNodes[0].checked=false; /*This is to un check the selecct all check box if any of user check boxes are un checked*/
	
	for (rcount=0;rcount<igGrid.Rows.length;rcount++)
	{
		if(igGrid.Rows.getRow(rcount).getCellFromKey("chkAssign").isEditable()==true)
		{	
			if (igGrid.Rows.getRow(rcount).getCellFromKey("chkAssign").getValue() == "false")
			{
				igGrid.Bands[0].Columns[0].Element.childNodes[0].checked=false;
				return
			}
		}
	}
	igGrid.Bands[0].Columns[0].Element.childNodes[0].checked=true;
	}
	}catch(ex){alert(ex.message)}
}

function fnAffiliateDetails(AffiliateID)
{
    popupwindow=window.open("PublicModules/AffiliateDetails.aspx?AfID="+ AffiliateID,'AffiliateDetails',"height=500,width=750,status=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,left=30,top=250");
	popupwindow.focus();
}
/**************AFFILIATES******************************************/
function fnChangeMembership(ObjectID,ObjType,UserStatus)
{
	popupwindow=window.open("Admin/ChangeMembership.aspx?ObjectID="+ ObjectID + "&ObjectType=" + ObjType + "&UserStatus=" +UserStatus ,"ChangeMembership","height=450,width=800,status=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,left=30,top=50");
	popupwindow.focus();
	
}

/*------Renew Membership----------*/
function fnRenewMembership(ObjectID,ObjType,UserStatus)
{
	popupwindow=window.open("Admin/RenewMembership.aspx?ObjectID="+ ObjectID + "&ObjectType=" + ObjType + "&UserStatus=" +UserStatus ,"ChangeMembership","height=450,width=800,status=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,left=30,top=50");
	popupwindow.focus();
	
}

/*******************************Learning Portals*****************************************************/
function fnUpdateTempLPStatus(status,LPName,action,cnfMsg,email,siteid)
{
    var agree=confirm(cnfMsg);
	var WinName=action;
	if(agree)
	{
	    var result;
		result = UpdateTempLPStatus(LPName,action,siteid)
		if (result == "approved") {
		    __doPostBack(action + '*' + email + '*' + LPName) //Use a symbol that is not used in inssp_CreateLearningPortal
		}
		else {
		    alert(result);
		    __doPostBack('','')
		}
	}
}

function fnGetSelectedObjectIDInLP(gridName, cellId)
{	
try{
	var igGrid;
	igGrid = igtbl_getGridById(gridName);
	var ClientID=igGrid.UniqueID.substring(0,igGrid.UniqueID.lastIndexOf("$"));
	if (ClientID!='' && ClientID!= null)
			ClientID=ClientID + '_';
	var hdnBox=document.getElementById(ClientID+'hdnSelectedList');	
	if( hdnBox!=null)
	{	    
		var strVal="";		
		strVal="," + hdnBox.value + ",";		
		var cell = igtbl_getCellById(cellId);
		if (cell.getRow(0).getCellFromKey("chkAssign") != null)
		{
			if(cellId==cell.getRow(0).getCellFromKey("chkAssign").Element.id)
			{
				if (cell.getRow(0).getCellFromKey("chkAssign").getValue()=="true" )
				{
					if(strVal.indexOf("," + cell.getRow(0).getCellFromKey("EmailAddress").getValue() + ",")==-1)
					{
						if( hdnBox.value=="")	
							strVal= cell.getRow(0).getCellFromKey("EmailAddress").getValue().toString();
						else
							strVal += cell.getRow(0).getCellFromKey("EmailAddress").getValue().toString();			
					}
				}
				else
				{
					var objVal =',' +  cell.getRow(0).getCellFromKey("EmailAddress").getValue().toString() + ',';	
					strVal=strVal.replace(objVal,',');				
				}
				
				if (strVal.substring(0,1)==",") strVal=strVal.substring(1);					
				if (strVal.substring(strVal.length-1)==",") strVal=strVal.substring(0,strVal.length-1);
				hdnBox.value=strVal;					
			}
		}
		
	igGrid.Bands[0].Columns[0].Element.childNodes[0].checked=false; /*This is to un check the selecct all check box if any of user check boxes are un checked*/
	
	for (rcount=0;rcount<igGrid.Rows.length;rcount++)
	{
		if(igGrid.Rows.getRow(rcount).getCellFromKey("chkAssign").isEditable()==true)
		{	
			if (igGrid.Rows.getRow(rcount).getCellFromKey("chkAssign").getValue() == "false")
			{
				igGrid.Bands[0].Columns[0].Element.childNodes[0].checked=false;
				return
			}
		}
	}
	igGrid.Bands[0].Columns[0].Element.childNodes[0].checked=true;
	}
	}catch(ex){alert(ex.message)}
}

function fnLPSendMessageLink(Emails,ObjType)
{
	popupwindow=window.open("PublicModules/SendMail.aspx?Emails="+ Emails,"SendLPPendingRequestMessage","height=450,width=800,status=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,left=30,top=50");
	popupwindow.focus();
}
function fnLPAssignSite(LPID)
{
	popupwindow=window.open("Admin/AssignLPSite.aspx?LPID="+ LPID,"AssignLPSite","height=450,width=800,status=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,left=30,top=50");
	popupwindow.focus();
}
/*******************************Learning Portals*****************************************************/
