﻿// JScript File
var xmlHttp; 
var requestURL = ''; 
var resultValue = '';
var UploadButtonID=0;
var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0; 
var is_ie5 = (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0; 
var is_opera = ((navigator.userAgent.indexOf("Opera6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1)) ? 1 : 0; 
//netscape, safari, mozilla behave the same??? 
var is_netscape = (navigator.userAgent.indexOf('Netscape') >= 0) ? 1 : 0; 
var MyContantPlaceHolderId="ctl00_MyContantPlaceHolder_";
var oDHW=null;

//For FullScreenDashboard- By Avneesh Pandey

  function fullScreenwindow(theURL) {
window.open(theURL, '','width='+(screen.width)+',height='+(screen.height)+',top=0,left=0,resizable=yes,toolbar=yes,scrollbars=yes,menubar=yes,addressbar=yes');
}

function show_data(strName,rURL,rValue)
{ 
	 if (strName.length > 0)
	 { 
		  resultValue = rValue;
		  //Append the name to search for to the requestURL 
		  //var url = requestURL + strName; 
		  var url = rURL + strName;
		  //Create the xmlHttp object to use in the request 
		  //stateChangeHandler will fire when the state has changed, i.e. data is received back 
		  // This is non-blocking (asynchronous) 
		  xmlHttp = GetXmlHttpObject(stateChangeHandler); 
	      
		  //Send the xmlHttp get to the specified url 
		  xmlHttp_Get(xmlHttp, url); 
	 } 
	 else 
	 { 
		  //Textbox blanked out, clear the results 
		  document.getElementById(resultValue).innerHTML = ''; 
	 } 
} 

//stateChangeHandler will fire when the state has changed, i.e. data is received back 
// This is non-blocking (asynchronous) 
function stateChangeHandler() 
{ 
    //readyState of 4 or 'complete' represents that data has been returned 
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
    { 
        //Gather the results from the callback 
        var str = xmlHttp.responseText; 
        
        //Populate the innerHTML of the div with the results 
       document.getElementById(resultValue).innerHTML =str; //"<tr><td>ss</td></tr><tr><td>ss</td></tr>"; 
    } 
} 

// XMLHttp send GET request 
function xmlHttp_Get(xmlhttp, url)
{ 
    xmlhttp.open('GET', url, true); 
    xmlhttp.setRequestHeader("Content-Type","text/html");
	  xmlhttp.setRequestHeader("Request-Object","CHTTPREQUEST");
    xmlhttp.send(null); 
} 


function BindCalender(TextBoxCalender,FormatCalenderText,ButtonCalender)
{
	 Calendar.setup ({ inputField : getElementByID(TextBoxCalender), ifFormat : FormatCalenderText , showsTime : false, button : getElementByID(ButtonCalender), singleClick : true, step : 1 });
}

function CheckSelectedItem()
{
 var dropdownIndex = document.getElementById('colorsselect').selectedIndex;
  var dropdownValue = document.getElementById('colorsselect')[dropdownIndex].value;
document.write(dropdownValue);




}


function CheckUploadForBlank()
{
  var MyUploadFile=document.getElementById(getElementByID("TextBoxGHGReportID"));
  if(MyUploadFile.value=="")
     {
        alert("Please Upload Report");
        return false; 
     }

}
function DisableButton()
{
    var MyMediaFile=document.getElementById(getElementByID("MediaFileUpload"));
    var MyUTube=document.getElementById(getElementByID("txtUTubeURL"));
   
    var elements = document.getElementById(getElementByID("rbtnType")).getElementsByTagName("*"); 
  
    for(i=0; i<elements.length;i++) 
    {
		  if(elements[i].type=='radio')
		  {
				
				if(elements[i].checked) 
				{ 
				    var Selected=elements[i].value;
				}				
				
		  }
	}	 
     if(Selected=="U" && MyUTube.value=="")
     {
        alert("You Tube URL can not be Blank");
        return false; 
     }

    else if(Selected=="M" && MyMediaFile.value=="")
    {
     alert("Select File can not be blank");
       return false;
    }
    else
    {
      var MyButton=document.getElementById(getElementByID("btnSave"));
      var MyPleaseWaitButton=document.getElementById(getElementByID("btnsavediv"));
   
      MyButton.style.visibility ="hidden"; 
      MyPleaseWaitButton.style.display = "block";
        
      return true;
     
  }
    
}


 //Select/Deselect CheckBox  
 
function CheckNestedGrid(parentChk,obj) 
{
	 obj=""+'div'+obj+"";	 
    var elements =  document.getElementById(obj).getElementsByTagName("*"); 
    for(i=0; i<elements.length;i++) 
    {
		  if(elements[i].type=='checkbox')
		  {
				
				if(parentChk.checked == true) 
				{  
					 if(elements[i].type=='checkbox')
					 {
						  
						  elements[i].checked = true;
					 }       
				}
				else 
				{
					 if(elements[i].type=='checkbox')
					 {
						  elements[i].checked = false;
					 }
				} 
        }      
    }    
}
function Check(parentChk) 
{
    var elements =  document.getElementsByTagName("INPUT"); 
    for(i=0; i<elements.length;i++) 
    {
		  if(elements[i].type=='checkbox')
		  {
				
				if(parentChk.checked == true) 
				{  
					 if(elements[i].type=='checkbox')
					 {
						  elements[i].checked = true;
					 }       
				}
				else 
				{
					 if(elements[i].type=='checkbox')
					 {
						  elements[i].checked = false;
					 }
				} 
        }      
    }    
}


var oldgridSelectedColor;

function setMouseOverColor(element)
{
    oldgridSelectedColor = element.style.backgroundColor;
    //element.style.backgroundColor='yellow';
    element.style.cursor='hand';
    element.style.textDecoration='underline';
}

function setMouseOutColor(element)
{
    //element.style.backgroundColor=oldgridSelectedColor;
    element.style.textDecoration='none';
}

var ArrRecordCount='';
        String.prototype.endsWith = function(txt,ignoreCase)
        {
          var rgx;
          if(ignoreCase)
          {
            rgx = new RegExp(txt+"$","i");
          }
          else
          {
            rgx = new RegExp(txt+"$");
          }
          return this.match(rgx)!=null; 
        }

        String.prototype.startsWith = function(str) 
        {
            return (this.match("^"+str)==str)
        }
        String.prototype.endsWith = function(str) 
        {
            return (this.match(str+"$")==str)
        }
        function getElementIdSpecific(MyElementStart,MyElementEnd)
        {  
          var elements;        
          elements = document.getElementsByTagName("body")[0].getElementsByTagName("*");
            for(elementsCount=0; elementsCount<elements.length;elementsCount++) 
            {
		          if(elements[elementsCount].id.startsWith(MyElementStart) && elements[elementsCount].id.endsWith(MyElementEnd))
		          {		                
						 return elements[elementsCount].id;   
				  }
            }
        }
        function getElementId(MyElement,Istop)
        {  
            var elements;
        if(Istop)
        elements=top.document.getElementsByTagName("body")[0].getElementsByTagName("*");
        else
         elements = document.getElementsByTagName("body")[0].getElementsByTagName("*");
            for(elementsCount=0; elementsCount<elements.length;elementsCount++) 
            {
		          if(elements[elementsCount].id.indexOf(MyElement)>=0)
		          {		                
						 return elements[elementsCount];   
				  }
            }
        }
        
        function getElementByID(MyElement,Istop)
        {            
       var elements;
        if(Istop)
        elements=top.document.getElementsByTagName("body")[0].getElementsByTagName("*");
        else
         elements = document.getElementsByTagName("body")[0].getElementsByTagName("*");
            for(getElementByIDCount=0; getElementByIDCount<elements.length;getElementByIDCount++) 
            {
		          if(elements[getElementByIDCount].id.indexOf(MyElement)>=0)
		          {
						  return elements[getElementByIDCount].id;   
					 }
            }
        }
        
        function DropDownMassSelectActionButton(MyButton,PostBackUrl,PostBackDelimiter,XGridName,HidenVieldRecID,DropDownID)
        {  
        
            ArrRecordCount='';
                        
            var HidenVieldRecIDControl=document.getElementById(getElementId(HidenVieldRecID));
            
            var TargetBaseControl = document.getElementById(getElementId(XGridName));
            var elements =  TargetBaseControl.getElementsByTagName("td");             
            for(i=0; i<elements.length;i++) 
            {
	              if(elements[i].firstChild!=null &&  elements[i].firstChild.firstChild!=null && elements[i].firstChild.firstChild.type=='checkbox')
	              {  
	                  if(elements[i].firstChild.firstChild.checked == true)
	                  { 
                        var Child= elements[i].firstChild;	
                        var ActualDropDownvalue=Child['PrimaryValue']+DropDownID;
                        var DropDownValueOfCheckedBox=document.getElementById(getElementId(ActualDropDownvalue)).value;                         
                        
                        if(ArrRecordCount.length==0)
                        {
                            ArrRecordCount=ArrRecordCount+Child['PrimaryValue']+"="+DropDownValueOfCheckedBox;
                        
                        }
                        else
                        {  
                            ArrRecordCount=ArrRecordCount+PostBackDelimiter+Child['PrimaryValue']+"="+DropDownValueOfCheckedBox;
                        
                        }
                          
                      }
                  }      
            }           
            if(ArrRecordCount.length==0)
            {
                alert('No item is selected ! Please select item.');
                return false;
            }
            else
            {
                if(HidenVieldRecIDControl!=null)
                {
                    HidenVieldRecIDControl.value=ArrRecordCount;
                    ArrRecordCount="";
                    window.document.forms[0].action=PostBackUrl; 
                }
                else
                {
                    window.document.forms[0].action=PostBackUrl+ "&RecId='"+ArrRecordCount+"'"; 
                }                 
            }
        }
        function GetDropDownValue(Button,DropdownID,PostBackURL,PrimaryValue)
        {                             
            var index = document.getElementById(getElementId(DropdownID));              
            window.document.forms[0].action=PostBackURL+ "&RecId='"+PrimaryValue+"="+index.value+"'";            
        }
        
        function CheckAll(parentChk,XGridName) 
        {
           
           
            var elements =  window.document.forms[0].getElementsByTagName("INPUT"); 
          
            for(i=0; i<elements.length;i++) 
            {
		          if(elements[i].type=='checkbox')
		          {
				        if(parentChk.checked == true) 
				        {  
					         if(elements[i].type=='checkbox'&& elements[i].id.indexOf('ChkSELECT')>=0 && elements[i].id.indexOf(XGridName)>=0)
					         {
						          elements[i].checked = true;
					         }       
				   }
				   else 
				   {
				       if(elements[i].type=='checkbox' && elements[i].id.indexOf('ChkSELECT')>=0 && elements[i].id.indexOf(XGridName)>=0)
				       {
					          elements[i].checked = false;
				       }
				   } 
                }      
            }    
        }
              
       function SetImageValue(val)
       {           
            window.opener.document.getElementById(HiddenField).value= val;
            window.opener.document.getElementById(ThImage).src="ThumbNailHandler.ashx?ID="+val;
            window.opener.document.getElementById(FlImage).src="ThumbNailHandler.ashx?ID="+val+"&Type=C";
            window.opener.document.getElementById(ThImage).width=64;
            window.opener.document.getElementById(ThImage).height=64;
            
            window.close();
            return false;
       }
       function IsCheckBoxImageSelected(parentcontrolname,listname,childcontrolname,IsCount,PostBackUrl)
        {
            var elements = document.getElementById(parentcontrolname);
            var st='';
            elementsAll=  document.getElementsByTagName("body")[0].getElementsByTagName("*");
			 count=0;
			 for(i=0; i<elementsAll.length;i++) 
				 {
					  if(elementsAll[i].id.indexOf(listname)>=0)
					  {
							TargetBaseControl = elementsAll[i];
							if(TargetBaseControl.id.indexOf(childcontrolname)>=0)
							{
							   if(TargetBaseControl.checked==true)
							   {	
							         var strid=TargetBaseControl.id;
							         var varArray = new Array();
                                     varArray = strid.split('_');
                                     st=varArray[0]+"_"+varArray[1]+"_"+"MyImageID";  
                                    
							         count=count+1;
							         break;
							   }
							}  
					  }
				 }	
				 
		
            	dialogArguments.document.getElementById(HiddenField).value= document.getElementById(st).innerText;
	            dialogArguments.document.getElementById(ThImage).src="ThumbNailHandler.ashx?ID="+document.getElementById(st).innerText;
	            dialogArguments.document.getElementById(FlImage).src="ThumbNailHandler.ashx?ID="+document.getElementById(st).innerText+"&Type=C";
	            dialogArguments.document.getElementById(ThImage).width=64;
	            dialogArguments.document.getElementById(ThImage).height=64;
	            window.close();
	            return false;

        }
        
        
      
	  
	   function CheckNumberOfCheckBoxSelected(val,Counter,MultipleSelect)
        {     
            
             var i;
             var FirstItem;
             if(MultipleSelect=="Y")
             {
                 var SelectedArray = new Array();
                 SelectedArray = val.split(',');                                       
                window.opener.document.getElementById(HiddenField).value= val;
                FirstItem=SelectedArray[0].toString();
                window.opener.document.getElementById(ThImage).src="ThumbNailHandler.ashx?ID="+FirstItem;
                window.opener.document.getElementById(FlImage).src="ThumbNailHandler.ashx?ID="+FirstItem+"&Type=C";
                window.opener.document.getElementById(ThImage).width=64;
                window.opener.document.getElementById(ThImage).height=64;    
                window.close();
                return false;  
              
             }
              else if(MultipleSelect=="N")
              {
               if(Counter > 1)
               {
                   alert("Multiple selection not allowed");
                   return false;
               }
           
                window.opener.document.getElementById(HiddenField).value= val;              
                window.opener.document.getElementById(ThImage).src="ThumbNailHandler.ashx?ID="+val;              
                window.opener.document.getElementById(FlImage).src="ThumbNailHandler.ashx?ID="+val+"&Type=C";             
                window.opener.document.getElementById(ThImage).width=64;
                window.opener.document.getElementById(ThImage).height=64;                
                window.close();
                return false;               
             }   
         
        }    
	    
	    function ConfirmArchive()
	    {
	    
	    
	    }
         function CofirmFunction()
        {        
          var test = confirm('Are you sure you want to delete');
          if (test) {return true;}
          else {return false;}
        } 	 
         function CofirmReportDelete()
        {        
          var test = confirm('Are You Sure You Want to Delete this Report');
          if (test) {return true;}
          else {return false;}
        } 	 
        
	

        function IsCheckBoxSelected(parentcontrolname,listname,childcontrolname,IsCount,PostBackUrl)
        {
            var elements = document.getElementById(parentcontrolname);
            elementsAll=  document.getElementsByTagName("body")[0].getElementsByTagName("*");
			 count=0;
			 for(i=0; i<elementsAll.length;i++) 
				 {
					  if(elementsAll[i].id.indexOf(listname)>=0)
					  {
							TargetBaseControl = elementsAll[i];
							if(TargetBaseControl.id.indexOf(childcontrolname)>=0)
							{
							   if(TargetBaseControl.checked==true)
							   {							     
							     window.document.forms[0].action=PostBackUrl; 							     
							     count=count+1;
							   
							   }
							}  
					  }
				 }				 
            if(count==0)
            {    
                 alert("No item is selected ! Please select item.");
                 return false;
                 
            }
            if(IsCount=='Y')
            {
                if(count>10)
                {
                   alert("You can not select more then 10 Items");
                   return false;
                
                }
            }
        }
        
         function IsImageCheckBoxSelected(listname,childcontrolname,IsCount)
        {       
            var elements = document.getElementById(listname);
            elementsAll=  document.getElementsByTagName("body")[0].getElementsByTagName("*");
			 count=0;
			 for(i=0; i<elementsAll.length;i++) 
				 {
					  if(elementsAll[i].id.indexOf(listname)>=0)
					  {
							TargetBaseControl = elementsAll[i];
							if(TargetBaseControl.id.indexOf(childcontrolname)>=0)
							{
							   if(TargetBaseControl.checked==true)
							   {					     
							      							     
							     count=count+1;
							   
							   }
							}  
					  }
				 }				 
            if(count==0)
            {    
                 alert("No item is selected ! Please select item.");
                 return false;
                 
            }
            else
            {  

                return true;
            }
        }
        
        function IsImageDeleteCheckBoxSelected(listname,childcontrolname,IsCount)
        {       
            var elements = document.getElementById(listname);
            elementsAll=  document.getElementsByTagName("body")[0].getElementsByTagName("*");
			 count=0;
			 for(i=0; i<elementsAll.length;i++) 
				 {
					  if(elementsAll[i].id.indexOf(listname)>=0)
					  {
							TargetBaseControl = elementsAll[i];
							if(TargetBaseControl.id.indexOf(childcontrolname)>=0)
							{
							   if(TargetBaseControl.checked==true)
							   {							     						     
							     count=count+1;
							   
							   }
							}  
					  }
				 }				 
            if(count==0)
            {    
                 alert("No item is selected ! Please select item.");
                 return false;
                 
            }
            else
            {  
              if(confirm('Are you sure to Delete the record?'))
			  {
			  return true;
			  }
			  else return false;
                
            }
        }
        
        function DoDelete()
        {         
          if(confirm('Are you sure to Delete the record?'))
		  {
		  return true;
		  }
		  else return false; 
        
        }
        
        function OnPostBack(PostBackURL)
        {
           
            window.document.forms[0].action=PostBackURL;
             window.document.forms[0].submit();
            
        
        }
        function MassSelection(MyButton,PostBackUrl,PostBackDelimiter,XGridName,HidenVieldRecID)
        {
      
             MyButton.disabled=false;
			 ArrRecordCount='';
			 var HidenVieldRecIDControl=null;
			 var TargetBaseControl='';
			 var elementsAll=  document.getElementsByTagName("body")[0].getElementsByTagName("*");
			 for(i=0; i<elementsAll.length;i++) 
				 {
					  if(elementsAll[i].id.indexOf(HidenVieldRecID)>=0)
					  {
							HidenVieldRecIDControl = elementsAll[i];
							break;	  
					  }
				 }
	 		 
	         elementsAll=  document.getElementsByTagName("body")[0].getElementsByTagName("*");
			 for(i=0; i<elementsAll.length;i++) 
				 {
					  if(elementsAll[i].id.indexOf(XGridName)>=0)
					  {
					      if(elementsAll[i].id.indexOf('GridFilter')<0)
					      {    					  
							   TargetBaseControl = elementsAll[i];
							    break;	 
					      }
					      
					  }
				 }
	 				
			 var elements = TargetBaseControl.getElementsByTagName("span");
	          
			 for(i=0; i<elements.length;i++ ) 
				 {
			  		var check= elements[i].getElementsByTagName("INPUT");

                    for (j=0;j<check.length;j++)
                        {
                           if(elements[i].attributes["PrimaryValue"]!= null && elements[i].attributes["PrimaryValue"].nodeValue!=null) 
					        {
                              if(check[j].type=='checkbox' && check[j].checked == true)
                                {
								  if(ArrRecordCount.length==0)
								   {								
										  ArrRecordCount=ArrRecordCount+elements[i].attributes["PrimaryValue"].nodeValue;							 
								   }
								  else
								   {  								
										  ArrRecordCount=ArrRecordCount+PostBackDelimiter+elements[i].attributes["PrimaryValue"].nodeValue;										 
								   }
								
						        } 
						    }
						}						      
				  }

	          if(ArrRecordCount.length==0)
				 {
					  alert('No item is selected ! Please select item.');
					  
					  return false;
				 }
			  else
				 {
			          if(confirm('Are you sure to '+MyButton.value+' the record?'))
					  {
						if(HidenVieldRecIDControl!=null)
						{
					    	 HidenVieldRecIDControl.value=ArrRecordCount;
							 //window.document.forms[0].action=PostBackUrl+ "&RecId='"+ArrRecordCount+"'";
							  window.document.forms[0].action=PostBackUrl+ "&RecId="+ArrRecordCount;
						}
						else
						{
							 //window.document.forms[0].action=PostBackUrl+ "&RecId='"+ArrRecordCount+"'";
							 window.document.forms[0].action=PostBackUrl+ "&RecId="+ArrRecordCount;
						}
						if(MyButton.id.length==0)
						        ButtonWithoutValidationDisabled(MyButton.name);
						else    
						        ButtonWithoutValidationDisabled(MyButton.id);
	                  }
			        else
			        {
				        return false;
			        }
		        }			
				
           }
        
        
        function UnCheckParent(CurrentChkBox,ParentGridView,ParentCheckBox,Delimiter) 
        {                        
            var ParentControl=getElementId(ParentCheckBox);
            var TargetBaseControl ;//= getElementId(ParentGridView);    
            var elementsAll=  document.getElementsByTagName("body")[0].getElementsByTagName("*");
			 for(i=0; i<elementsAll.length;i++) 
				 {
					  if(elementsAll[i].id.indexOf(ParentGridView)>=0)
					  {
					      if(elementsAll[i].id.indexOf('GridFilter')<0)
					      {    					  
							   TargetBaseControl = elementsAll[i];
							    break;	 
					      }
					      
					  }
				 }
            var elements =  TargetBaseControl.getElementsByTagName("INPUT"); 
            var count=0;
            var chkSelectCount=0;
            if(CurrentChkBox.type=='checkbox')
            {
                if(ParentControl.checked == true) 
                 {
			         if(CurrentChkBox.checked == false)
			         {
				          ParentControl.checked = false;
			         }   
			     }
				else
				{
				     
				     if(CurrentChkBox.checked == true)
			         {
			            for(i=0; i<elements.length;i++) 
                         {
			                if(elements[i].type=='checkbox' && elements[i].id.indexOf('ChkSELECT')>=0)
			                {
			                    chkSelectCount=chkSelectCount+1;
			                    if(elements[i].checked == true)
			                    {
			                        count=count+1;
			                    }
			                }
			             }
			            CurrentChkBox.checked = true;
			            if(count==chkSelectCount)
			            {
			                ParentControl.checked = true;
			            }
			         }   
				}
			}
        }
        function LockAccountPolicyFields(CheckBoxAccountPolicyEnableAccountLockUp,TextBoxAccountPolicyLockOutDuration,TextBoxAccountPolicyLockOutBadAttempt,TextBoxAccountPolicyResetCountMinutes)
        {                               
            var AccountPolicyEnableAccountLockUp=getElementId("CheckBoxAccountPolicyEnableAccountLockUp");
            var AccountPolicyLockOutDuration=getElementId("TextBoxAccountPolicyLockOutDuration");
            var AccountPolicyLockOutBadAttempt=getElementId("TextBoxAccountPolicyLockOutBadAttempt");
            var AccountPolicyResetCountMinutes=getElementId("TextBoxAccountPolicyResetCountMinutes");            
            
            if(AccountPolicyEnableAccountLockUp.checked)
            {
                AccountPolicyLockOutDuration.disabled=false;
                AccountPolicyLockOutBadAttempt.disabled=false;
                AccountPolicyResetCountMinutes.disabled=false;
            }
            else
            {
                AccountPolicyLockOutDuration.disabled=true;
                AccountPolicyLockOutBadAttempt.disabled=true;
                AccountPolicyResetCountMinutes.disabled=true;
            } 
        }
        function AuditEventManagement(CheckBoxAuditPolicyEnableAuditEvent,CheckBoxAuditPolicyUserManagement,CheckBoxAuditPolicySecurityPolicyChange,CheckBoxAuditPolicyLogOnLogOff,CheckBoxAuditPolicyApplicationAccess)
        {
            
            var EnableAuditEvent=getElementId(CheckBoxAuditPolicyEnableAuditEvent);
            var UserManagement=getElementId(CheckBoxAuditPolicyUserManagement);
            var SecurityPolicyChange=getElementId(CheckBoxAuditPolicySecurityPolicyChange);
            var LogOnLogOff=getElementId(CheckBoxAuditPolicyLogOnLogOff);
            var ApplicationAccess=getElementId(CheckBoxAuditPolicyApplicationAccess);
        
            if (EnableAuditEvent.checked)
            {           
                UserManagement.checked = true;
                SecurityPolicyChange.checked = true;
                LogOnLogOff.checked = true;
                ApplicationAccess.checked = true;
            }
            else
            {               
                UserManagement.checked = false;
                SecurityPolicyChange.checked = false;
                LogOnLogOff.checked = false;
                ApplicationAccess.checked = false;
            }
        
        }
        
        function AuditChildEventManagement(CheckBoxAuditPolicyEnableAuditEvent,CheckBoxAuditPolicyUserManagement,CheckBoxAuditPolicySecurityPolicyChange,CheckBoxAuditPolicyLogOnLogOff,CheckBoxAuditPolicyApplicationAccess)
        {
            
            var EnableAuditEvent=getElementId(CheckBoxAuditPolicyEnableAuditEvent);
            var UserManagement=getElementId(CheckBoxAuditPolicyUserManagement);
            var SecurityPolicyChange=getElementId(CheckBoxAuditPolicySecurityPolicyChange);
            var LogOnLogOff=getElementId(CheckBoxAuditPolicyLogOnLogOff);
            var ApplicationAccess=getElementId(CheckBoxAuditPolicyApplicationAccess);
        
            if (UserManagement.checked || SecurityPolicyChange.checked ||  LogOnLogOff.checked || ApplicationAccess.checked)
            {     
                EnableAuditEvent.checked = true;               
            }
            
        
        }
        
        function CheckUnCheckCheckBoxList(MyCheckBox,CheckBoxListColumnID)
        {            
            var LabelArray = MyCheckBox.parentNode.getElementsByTagName('label');
            
            if (MyCheckBox.checked==true)
            {   
                CheckedValue = LabelArray[0].innerHTML;
                if(CheckedValue.toUpperCase()=="UPDATE" || CheckedValue.toUpperCase()=="CREATE" || CheckedValue.toUpperCase()=="DELETE")
                {
                    var index = getElementId(CheckBoxListColumnID); 
                                
                    var CheckBoxArray = index.getElementsByTagName('input');
                    
                    var StringcheckedValue = '';                
                    for (var CheckBoxArrayCount=0; CheckBoxArrayCount <CheckBoxArray.length;CheckBoxArrayCount++)
                    {                    
                        var CheckBoxRef = CheckBoxArray[CheckBoxArrayCount];
                        var LabelArray = CheckBoxRef.parentNode.getElementsByTagName('label');
                        CheckedValue = LabelArray[0].innerHTML;
                        if (CheckedValue.toUpperCase()=="READ")
                        {
                            CheckBoxRef.checked=true;
                        }
                     }
                  }                
            }
            else
            {
                CheckedValue = LabelArray[0].innerHTML;
                var CountOfOtherCheckBox=0;
                var StringcheckedValue='';
                if(CheckedValue.toUpperCase()=="READ")
                {
                    var index = getElementId(CheckBoxListColumnID);              
                    var CheckBoxArray = index.getElementsByTagName('input');                    
                    StringcheckedValue = '';                
                    for (var CheckBoxArrayCount=0; CheckBoxArrayCount <CheckBoxArray.length;CheckBoxArrayCount++)
                    {                    
                        var CheckBoxRef = CheckBoxArray[CheckBoxArrayCount];
                        var LabelArray = CheckBoxRef.parentNode.getElementsByTagName('label');
                        CheckedValue = LabelArray[0].innerHTML;
                        if (CheckedValue.toUpperCase()!="READ" && CheckBoxRef.checked==true)
                        {
                            StringcheckedValue+=CheckedValue+",";
                            CountOfOtherCheckBox++;
                        }                        
                     }
                  }
                  StringcheckedValue=StringcheckedValue.substring(0,StringcheckedValue.length-1)
                  if(CountOfOtherCheckBox>0)
                  {
                    alert("You can not take back Read Permission until '" + StringcheckedValue+ "' Permissions are not taken back.");
                    MyCheckBox.checked=true;
                    return; 
                  }   
                  
            }            
        }
        
        
        
        function GetCheckBoxListColumn(Button,CheckBoxListColumnID,PostBackURL,PrimaryValue)
        {
            
            var index = getElementId(CheckBoxListColumnID);  
                  
            var CheckBoxArray = index.getElementsByTagName('input');
            var StringcheckedValue = '';        
                   
            for (var i=0; i <CheckBoxArray.length;i++)
            {
                
                var CheckBoxRef = CheckBoxArray[i];
                var LabelArray = CheckBoxRef.parentNode.getElementsByTagName('label');
                CheckedValue = LabelArray[0].innerHTML;
                if (CheckBoxRef.checked==true)
                {
                    if(StringcheckedValue!="")
                    {
                        StringcheckedValue=StringcheckedValue+".";
                    }
                   StringcheckedValue=StringcheckedValue+CheckedValue;
                }
             }              
            window.document.forms[0].action=PostBackURL+ "&RecId='"+PrimaryValue+"="+StringcheckedValue+"'";  
        }

        
     function CheckBoxMassSelectActionButton(MyButton,PostBackUrl,PostBackDelimiter,XGridName,HidenVieldRecID,CheckBoxListID)
      {  
              
           ArrRecordCount='';
           var HidenVieldRecIDControl=null;
	  	   var TargetBaseControl='';

           var elementsAll=   document.getElementsByTagName("body")[0].getElementsByTagName("*");
		   for(i=0; i<elementsAll.length;i++) 
		   {
			  if(elementsAll[i].id.indexOf(HidenVieldRecID)>=0)
			  {
				HidenVieldRecIDControl = elementsAll[i];
				break;	  
			  }
		   }
          
           elementsAll=  document.getElementsByTagName("body")[0].getElementsByTagName("*");
		   for(i=0; i<elementsAll.length;i++) 
		   {
			 if(elementsAll[i].id.indexOf(XGridName)>=0)
			  {
				TargetBaseControl = elementsAll[i];
				break;	  
			  }
		   }
		 
           var elements = TargetBaseControl.getElementsByTagName("span");                  
           //Run the for loop
           for(i=0; i<elements.length;i++) 
            {
                 var check= elements[i].getElementsByTagName("INPUT");
                 for (j=0;j<check.length;j++)
                   {
                   
                    if(elements[i].attributes["PrimaryValue"]!= null && elements[i].attributes["PrimaryValue"].nodeValue!=null) 
                     {
                     
                       //for all elements of type CheckBox,check if it is checked or not
                      if(check[j].type=='checkbox' && check[j].checked == true)
	                   {                     
                          var ActualCheckBoxListvalue=elements[i].attributes["PrimaryValue"].nodeValue+CheckBoxListID;                           
                          var CheckBoxValueOfCheckedBox=getElementId(ActualCheckBoxListvalue);                                                  
                          //get the relevant input fileds of type checkbox
                          var CheckBoxArray = CheckBoxValueOfCheckedBox.getElementsByTagName('input');
                          var StringcheckedValue = '';                     
                          for (var CheckBoxArrayCount=0; CheckBoxArrayCount <CheckBoxArray.length;CheckBoxArrayCount++)
                          {           
                            //run the loop for each checkbox found             
                            var CheckBoxRef = CheckBoxArray[CheckBoxArrayCount];
                            var LabelArray = CheckBoxRef.parentNode.getElementsByTagName('label');
                            //if the CheckBox is checked then get its value                            
                            if (CheckBoxRef.checked==true)
                            {   
                                CheckedValue = LabelArray[0].innerHTML;
                                if(StringcheckedValue!="")
                                {
                                    StringcheckedValue=StringcheckedValue+".";
                                }
                               StringcheckedValue=StringcheckedValue+CheckedValue;
                            }
                          } 
                         //Finally Store the value in a global variable 
                         if(ArrRecordCount.length==0)
                         {
                             ArrRecordCount=ArrRecordCount+elements[i].attributes["PrimaryValue"].nodeValue+"="+StringcheckedValue;                        
                         }
                         else
                         {  
                             ArrRecordCount=ArrRecordCount+PostBackDelimiter+elements[i].attributes["PrimaryValue"].nodeValue+"="+StringcheckedValue;                        
                         }                          
                      }
                 }
               }       
            }           
            if(ArrRecordCount.length==0)
            {
                alert('No item is selected ! Please select item.');
                return false;
            }  
                 
            else
            {
                //pass the final Column values to hidden field if it is not null
                if(HidenVieldRecIDControl!=null)
                {
                    HidenVieldRecIDControl.value=ArrRecordCount;
                    ArrRecordCount="";
                    window.document.forms[0].action=PostBackUrl; 
                }
                //else set the action of the form with the values passed in the QueryString
                else
                {
                    window.document.forms[0].action=PostBackUrl+ "&RecId='"+ArrRecordCount+"'"; 
                }                 
            }
        }
        
        function CheckEmptyTextBox(TextBoxObject,Defaultvalue,LabelValue)
        {            
	        var TextBoxObjectValue = TextBoxObject.value;	
	        if(TextBoxObjectValue=="")
	        {		
	            if(confirm("The [" + LabelValue + "] is Empty. Do you want the system to automatically put in default value?"))
	            {
	                TextBoxObject.value = Defaultvalue;
	                return true;
	            }
	            else
	            {
	                TextBoxObject.focus();
	                return false;
	            }
	        }
	        if(parseInt(TextBoxObjectValue)<Defaultvalue)
	        {
	            if(confirm("The [" + LabelValue + "] value should be " + Defaultvalue + " or greater. Do you want the system to automatically put in default value?"))
	            {
	                TextBoxObject.value = Defaultvalue;
	                return true;
	            }
	            else
	            {
	                TextBoxObject.focus();
	                return false;
	            }
	        }
        }
        function BlockNonNumbers(TextBoxObject, e, AllowDecimal, AllowNegative)
        {

	        var Key;
	        var IsCtrl = false;
	        var KeyChar;
	        var Reg;
        		
	        if(window.event) {
		        Key = e.keyCode;
		        IsCtrl = window.event.ctrlKey
	        }
	        else if(e.which) {
		        Key = e.which;
		        IsCtrl = e.ctrlKey;
	        }
        	
	        if (isNaN(Key)) return true;
        	
	        KeyChar = String.fromCharCode(Key);
        	
	        // check for backspace or delete, or if Ctrl was pressed
	        if (Key == 8 || IsCtrl)
	        {
		        return true;
	        }
	        
	        Reg = /\d/;
	        var IsFirstN = AllowNegative ? KeyChar == '-' && TextBoxObject.value.indexOf('-') == -1 : false;
	        var IsFirstD = AllowDecimal ? KeyChar == '.' && TextBoxObject.value.indexOf('.') == -1 : false;
        	
	        return IsFirstN || IsFirstD || Reg.test(KeyChar);
        }
        
        function BlockNonNumbersAllowColon(TextBoxObject, e, AllowDecimal, AllowNegative)
        {

	        var Key;
	        var IsCtrl = false;
	        var KeyChar;
	        var Reg;
        		
	        if(window.event) {
		        Key = e.keyCode;
		        IsCtrl = window.event.ctrlKey
	        }
	        else if(e.which) {
		        Key = e.which;
		        IsCtrl = e.ctrlKey;
	        }
        	
	        if (isNaN(Key)) return true;
        	
	        KeyChar = String.fromCharCode(Key);
        	
        	if(KeyChar == "-")
            {
               // to allow negative at the starting position only
               if(TextBoxObject.value.length!=0)
                  return false;
            }
            
	        // check for backspace or delete, or if Ctrl was pressed
	        if (Key == 8 || IsCtrl)
	        {
		        return true;
	        }
	        if(KeyChar == ":")
            {
               return true;
            }

	        Reg = /\d/;
	        var IsFirstN = AllowNegative ? KeyChar == '-' && TextBoxObject.value.indexOf('-') == -1 : false;
	        var IsFirstD = AllowDecimal ? KeyChar == '.' && TextBoxObject.value.indexOf('.') == -1 : false;
        	
	        return IsFirstN || IsFirstD || Reg.test(KeyChar);
        }
        
        
        function BlockNonNumbersOffSetValue(TextBoxObject, e, AllowDecimal, AllowNegative,AllowPositive)
        {
            //alert(TextBoxObject);
	        var Key;
	        var IsCtrl = false;
	        var KeyChar;
	        var Reg;
        		
	        if(window.event) {
		        Key = e.keyCode;
		        IsCtrl = window.event.ctrlKey
		       
	        }
	        else if(e.which) {
		        Key = e.which;
		        IsCtrl = e.ctrlKey;
	        }
        	
	        if (isNaN(Key)) return true;
        	
	        KeyChar = String.fromCharCode(Key);
	        
	        
        	//if(isInteger(KeyChar)) return false;
       	
	        // check for backspace or delete, or if Ctrl was pressed
	        if (Key == 8 || IsCtrl)
	        {
		        return true;
	        }

	        Reg = /\d/;
	        var IsFirstN = AllowNegative ? KeyChar == '-' && TextBoxObject.value.indexOf('-') == -1 : false;
	        var IsFirstP = AllowPositive ? KeyChar == '+' && TextBoxObject.value.indexOf('+') == -1 : false;
	        var IsFirstD = AllowDecimal ? KeyChar == ':' && TextBoxObject.value.indexOf(':') == -1 : false;
        	
	        return IsFirstN || IsFirstP || IsFirstD || Reg.test(KeyChar);
        }
        
       function isInteger (s)
       {
            var i;
            if (isEmpty(s))
            if (isInteger.arguments.length == 1) return 0;            
            else return (isInteger.arguments[1] == true);
            for (i = 0; i < s.length; i++)
            {
                 var c = s.charAt(i);
                 if (!isDigit(c)) return false;
            }
            return true;
        }

        function isEmpty(s)
        {
          return ((s == null) || (s.length == 0))
        }

       function isDigit (c)
       {
          return ((c >= "0") && (c <= "9"))
       }        
      
        function isValidInteger(TextBoxObject , AllowDecimal)
        {
            var strString=TextBoxObject.value;
            var strValidChars ;
            var strChar;
            if(AllowDecimal)
            {
                strValidChars = "0123456789.";
            }
            else
            {            
                strValidChars = "0123456789";
            }
            

            //  test strString consists of valid characters listed above
            for (i = 0; i < strString.length ; i++)
            {
                strChar = strString.charAt(i);
                if (strValidChars.indexOf(strChar) == -1)
                 {                    
                    alert('Characters are not allowed');
                    TextBoxObject.value='';
                    TextBoxObject.focus();
                    return false;
                 }
            }
            return true;          
           
        }
        
        function BlockNonNumbersForDate(TextBoxObject, e)
        {

	        var Key;
	        var IsCtrl = false;
	        var KeyChar;
	        var Reg;
	        if(window.event) {
		        Key = e.keyCode;
		        IsCtrl = window.event.ctrlKey
	        }
	        else if(e.which) {
		        Key = e.which;
		        IsCtrl = e.ctrlKey;
	        }
	        if (isNaN(Key)) return true;
        	  
	        KeyChar = String.fromCharCode(Key);
        	
	        // check for backspace or delete, or if Ctrl was pressed
	        if (Key == 45 || Key == 8 || IsCtrl)
	        {
		        return true;
	        }

	        Reg = /\d/;
        	
	        return Reg.test(KeyChar);
        }
        function DataPointDateValidate(TextBoxObject, e)
        {

	        var Key;
	        var IsCtrl = false;
	        var KeyChar;
	        var Reg;
        	  
	        if(window.event) {
		        Key = e.keyCode;
		        IsCtrl = window.event.ctrlKey
	        }
	        else if(e.which) {
		        Key = e.which;
		        IsCtrl = e.ctrlKey;
	        }
	        if (isNaN(Key)) return true;
        	  
	        KeyChar = String.fromCharCode(Key);
        	
	        // check for backspace or delete, or if Ctrl was pressed
	        if (Key == 47 || Key == 8 || IsCtrl)
	        {
		        return true;
	        }

	        Reg = /\d/;
        	
	        return Reg.test(KeyChar);
        }
        function AllowOnlyAlphanumeric(TextBoxObject, e)
        { 
            
            var Key;
	        var IsCtrl = false;
	        var KeyChar;
	        var Reg;
        		
	        if(window.event) {
		        Key = e.keyCode;
		        IsCtrl = window.event.ctrlKey
	        }
	        else if(e.which) {
		        Key = e.which;
		        IsCtrl = e.ctrlKey;
	        }
        	
	        //if (isNaN(Key)) return true;
	        
	        KeyChar = String.fromCharCode(Key);
	        
	        // check for backspace or delete, or if Ctrl was pressed
	        if (Key == 8 || IsCtrl)
	        {
		        return true;
	        }
	        
            var checkOK = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-";
            var checkStr = TextBoxObject.value;
            var allValid = true;
            if(checkOK.indexOf(KeyChar) == -1)  
            {
                allValid=false;
                return false; 
            }  
            Reg = /\d/;
	        return allValid || Reg.test(KeyChar);
        }

var dtCh= "-";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){

	if(dtStr.value=='')
	 return true;
	 
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.value.indexOf(dtCh)
	var pos2=dtStr.value.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.value.substring(0,pos1)
	var strDay=dtStr.value.substring(pos1+1,pos2)
	var strYear=dtStr.value.substring(pos2+1)
	
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm-dd-yyyy")
		dtStr.focus();
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		dtStr.focus();
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		dtStr.focus();
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		dtStr.focus();
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.value.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		dtStr.focus();
		alert("Please enter a valid date")
		return false
	}
return true
}
function ShowImagePanel(ObjButton,PanelControl,ObjCancel)
{ 
    var StyleDisplay=getElementId(PanelControl).style['display']; 
    if(StyleDisplay=='none')
    {
        getElementId(PanelControl).style['display']='block';
        ObjButton.style['display']='none';
    }
    else
    {
        getElementId(ObjCancel).style['display']='block';
        getElementId(PanelControl).style['display']='none';
        ObjButton.style['display']='block';
    }
} 

function DoUpload(PostBackURL,ElementName)
{    
  
      var filename = document.getElementById(getElementByID(ElementName));
      if(filename.value=="")
      {
          alert("Select File can not be blank");
			     return false;
      }
      else
      {
		    if(UploadButtonID>0)
        {
            window.document.forms[0].action=PostBackURL+ "&RecId="+UploadButtonID+""; 
        }
        else
        {
            window.document.forms[0].action=PostBackURL; 
        }
        return true;
     }    		
}

function ShowImageUploadControl(PrimaryKey,obj)
{
    UploadButtonID=PrimaryKey;
    //displayCoords(obj) ;
    return false;  
}

function ShowXGridViewImageUploadControl(PrimaryKey,ModelID,CornerID,DialogActionID)
{
    UploadButtonID=PrimaryKey;
    ShowModelWindow(ModelID,CornerID,DialogActionID,'True') ;
    return false;  
}
function ShowXGridViewImageURLUploadControl(PrimaryKey,ModelID,CornerID,DialogActionID,DocumentUploadControlID,AllowURLRow)
{
    UploadButtonID=PrimaryKey;
    ShowModelWindow(ModelID,CornerID,DialogActionID,'True') ;
   
    if(AllowURLRow=='true')
    {
        document.getElementById('Header'+DocumentUploadControlID).innerHTML="YouTube URL Save";
        document.getElementById('Title'+DocumentUploadControlID).innerHTML="Save";
        document.getElementById('SelectFileRowXGridViewUploadImageControl').style.display = "none";
        document.getElementById('URLRowXGridViewUploadImageControl').style.display = "block";
    }
    else
    {
        document.getElementById('HeaderXGridViewUploadImageControl').innerHTML="Media File Upload";
        document.getElementById('TitleXGridViewUploadImageControl').innerHTML="Upload";
        document.getElementById('SelectFileRowXGridViewUploadImageControl').style.display = "block";
        document.getElementById('URLRowXGridViewUploadImageControl').style.display = "none";
    }
    return false;  
}

function displayCoords(obj) 

{

       var scrolledX, scrolledY; 
       if( self.pageYOffset )
       { 
              scrolledX = self.pageXOffset; 
              scrolledY = self.pageYOffset; 
       } 
       else if( document.documentElement && document.documentElement.scrollTop )
       { 
              scrolledX = document.documentElement.scrollLeft;
              scrolledY = document.documentElement.scrollTop; 
       }
       else if( document.body )
       { 
              scrolledX = document.body.scrollLeft;
              scrolledY = document.body.scrollTop;
       }
       // Next, determine the coordinates of the center of browser's window  

       var centerX, centerY; 
       if( self.innerHeight )
       { 
              centerX = self.innerWidth; 
              centerY = self.innerHeight; 
       } 
       else if( document.documentElement && document.documentElement.clientHeight )
       { 
              centerX = document.documentElement.clientWidth; 
              centerY = document.documentElement.clientHeight; 
       } 
       else if( document.body ) 
       { 
              centerX = document.body.clientWidth; 
              centerY = document.body.clientHeight; 
       }  

       var Xwidth = 400;
    var Yheight = 300;
    
       // Xwidth is the width of the div, Yheight is the height of the 

       // div passed as arguments to the function: 

       var leftOffset = scrolledX + (centerX - Xwidth) / 2; 
       var topOffset = scrolledY + (centerY - Yheight) / 2;     

    

    //var left = parseInt((window.screen.availWidth/2) - (width/2));

    //var top = parseInt((window.screen.availHeight/2) - (height/2));

       document.getElementById(obj).style.left = eval(leftOffset);
       document.getElementById(obj).style.top = eval(topOffset);
       document.getElementById(obj).style.display = "block";

} 

function doNothing()
{
}

function fnHidePopDiv(obj)
{  
   document.getElementById(obj).style.display = 'none';
}

//var keys = ["BasicSearch","AdvanceSearch"]; 
var keys = ["BasicSearch"]; 
tabPreviousKey = '';
function SelectSearchTab(key)
{
	 for( var i=0; i<keys.length;i++)
	 {
		  var liclass = '';
		  var linkclass = '';

		  if ( key == keys[i])
		  {
				var liclass = 'active';
				var linkclass = 'current';
		  }
		  
  		  document.getElementById('Tab_LI_'+keys[i]).className = liclass;
  		  document.getElementById('Tab_Link_'+keys[i]).className = linkclass;
	 }
	 getElementId('BasichSearchForm').style.display = 'none';
	 //getElementId('AdvanceSearchForm').style.display = 'none';
	 //document.getElementById('BasichSearchForm').style.display = 'none';
	 //document.getElementById('AdvanceSearchForm').style.display = 'none';
	 switch(key)
	 {
		  case 'BasichSearch':
				getElementId('BasichSearchForm').style.display = '';
				//document.getElementById('BasichSearchForm').style.display = '';
		  break;
		  case 'AdvanceSearch':
				getElementId('AdvanceSearchForm').style.display = '';
				//document.getElementById('AdvanceSearchForm').style.display = '';
		  break;
	 }
}

function ActiveSearchFormTab()
{
	 var liclass = 'active';
	 var linkclass = 'current';
	 var myurl = document.URL;
	 len=myurl.indexOf('ADVANCESEARCH');
	 if(len>0)
	 {
	 	  getElementId('BasichSearchForm').style.display = 'none';
		  getElementId('AdvanceSearchForm').style.display = ''; 		 
		  document.getElementById('Tab_LI_AdvanceSearch').className = liclass;
  		  document.getElementById('Tab_Link_AdvanceSearch').className = linkclass;
	 }
	 else
	 {
	 	  document.getElementById('Tab_LI_BasicSearch').className = liclass;
  		  document.getElementById('Tab_Link_BasicSearch').className = linkclass;
	 }
}
function CheckBuildingName(checkBoxObject,DropDownBuildingNameObject)
{
    
    if(checkBoxObject.checked)
    {
        var BuildingName=getElementId(DropDownBuildingNameObject);        
        if(BuildingName.value=="")
        {
            alert("Please select Building Name");
            checkBoxObject.checked=false;
		    return false ;           
        }
        else
            return true;          
    }   
 } 

	 var g_Modal = null;
	 var ModalBG = null;
	 var cornerexample = null;
	 var DialogActionBtn=null;
	 
	function ShowAjaxModelLookUp(ModuleV)
	{
	
		ModalBG="ModalBG";
		cornerexample="cornerexample";
		DialogActionBtn="DialogActionBtn";
		this.CurrentURL=ModuleV;
//		 var Modulevalue=ModuleV;
//		 var Appvalue=AppV;
//		 var Formvalue=FormV;
//		 var Recvalue=RecV;
//		 var SessionValue =SessionV;
//		 var ClientValue=ClientV;
		/* Sweep unnecessary empty text nodes. */
		DOMManager.sweep();

		/*
		 * Attach supporting css bind required
		 * classes for transparency support in Opera.
		 */
		addExtensionsForOpera();

		/* Attach opacity css. */
		attachOpacityCSS();

		/* Adjust height. */
		adjustHeight();

		/* Create the modal dialog */
		g_Modal=new ModalDialog(ModalBG,cornerexample,
			"inside123",DialogActionBtn);

		/* create an AJAX request */
		var ajax = _.ajax();
		/*
		 * Note that _.ajax(); is a shorthand notation 
		 * for new XHRequest();
		 * Visit http://sardalya.pbwiki.com/Shortcuts details.
		 */

		/* 
		 * You can add as many fields as you like to the post data. 
		 * Normally the server will use this data to create an
		 * output that makes sense which may be an XML, a JSON String
		 * or an HTML String.
		 */
		// http://localhost:2818/POWERSMITHS.WOW.WebApp/Property.aspx?Module=Site.Administration&App=WOW.Building&FormAction=DETAILVIEW&SESSIONID=20357e6e-36e0-4c5c-b1e7-0eb9556fc070&CLIENTID=1&RecID=489
//		ajax.removeAllFields();
//		ajax.addField("Module",Modulevalue);
//		ajax.addField("App",Appvalue);
//		ajax.addField("FormAction",Formvalue);
//		ajax.addField("SESSIONID",SessionValue);
//		ajax.addField("CLIENTID",ClientV);
//		ajax.addField("RecID",Recvalue);

		ajax.oncomplete=ajax_complete;
		ajax.onerror=ajax_error;

		g_Modal.show("Fetching data... Please wait...");

		/*
		 * Disable close action if you want to force the user 
		 * to wait for the outcome of the AJAX request.
		 * Although it is generally not recommended 
		 * this may be necessary at certain times.
		 */
		g_Modal.disableClose();

		/* Post data to the server. */
		ajax.get(this.CurrentURL);

	}
	
	 function ShowModelWindow(M,C,D,MoveOption)
	 {
		//alert(M +' '+C +' '+' '+D )
		ModalBG=M;
		cornerexample=C;
		DialogActionBtn=D;
		  		/* Sweep unnecessary empty text nodes. */
		DOMManager.sweep();

		/*
		 * Attach supporting css bind required
		 * classes for transparency support in Opera.
		 */
		addExtensionsForOpera();

		/* Attach opacity css. */
		attachOpacityCSS();

		/* Adjust height. */
		adjustHeight();

		/* Create the modal dialog */
		g_Modal=new ModalDialog(ModalBG,cornerexample,
			"LookupInsideContant",DialogActionBtn);

		  		g_Modal.show("Testing is the best country...");
		  		
		
		//g_Modal.disableClose();
	 }
	 
	 function ShowModelWindowEquivalent(M,C,D,MoveOption)
	 {
		//alert(M +' '+C +' '+' '+D )
		ModalBG=M;
		cornerexample=C;
		DialogActionBtn=D;
		  		/* Sweep unnecessary empty text nodes. */
		DOMManager.sweep();

		/*
		 * Attach supporting css bind required
		 * classes for transparency support in Opera.
		 */
		addExtensionsForOpera();

		/* Attach opacity css. */
		attachOpacityCSS();

		/* Adjust height. */
		adjustHeight();

		/* Create the modal dialog */
		g_Modal=new ModalDialog(ModalBG,cornerexample,
			"LookupInsideContant",DialogActionBtn);

  		g_Modal.show("Testing is the best country...");  		
  		
  		return false; 
		
		//g_Modal.disableClose();
	 }
	 function ShowModelWindowRead(M,C,D,Title,Desc,CatID,ImageURL)
	 {
		//alert(M +' '+C +' '+' '+D )
		ModalBG=M;
		cornerexample=C;
		DialogActionBtn=D;
		  		/* Sweep unnecessary empty text nodes. */
		DOMManager.sweep();

		/*
		 * Attach supporting css bind required
		 * classes for transparency support in Opera.
		 */
		addExtensionsForOpera();

		/* Attach opacity css. */
		attachOpacityCSS();

		/* Adjust height. */
		adjustHeight();

		/* Create the modal dialog */
		g_Modal=new ModalDialog(ModalBG,cornerexample,
			"LookupInsideContant",DialogActionBtn);

		  		g_Modal.show("Testing is the best country...");
		document.getElementById('DescriptionEditPoint').innerHTML=document.getElementById(getElementByID(Desc)).value.replace(/<.*?>/g,'');
		document.getElementById('ImageEndpoint').src=ImageURL;		
		document.getElementById('TitleEditPoint').innerHTML=document.getElementById(getElementByID(Title)).value;
		document.getElementById('HiddentEditPoint').value=CatID;
	
	 }
	 function ShowModelWindowRead1(M,C,D,Title,Desc,CatID,ImageURL)
	 {
		//alert(M +' '+C +' '+' '+D )
		ModalBG=M;
		cornerexample=C;
		DialogActionBtn=D;
		  		/* Sweep unnecessary empty text nodes. */
		DOMManager.sweep();

		/*
		 * Attach supporting css bind required
		 * classes for transparency support in Opera.
		 */
		addExtensionsForOpera();

		/* Attach opacity css. */
		attachOpacityCSS();

		/* Adjust height. */
		adjustHeight();

		/* Create the modal dialog */
		g_Modal=new ModalDialog(ModalBG,cornerexample,
			"LookupInsideContant",DialogActionBtn);

		  		g_Modal.show("Testing is the best country...");		
		
		document.getElementById('DescriptionEditPoint1').innerHTML=document.getElementById(getElementByID(Desc)).value.replace(/<.*?>/g,'');
		document.getElementById('ImageEndpoint1').src=ImageURL;		
		document.getElementById('TitleEditPoint1').innerHTML=document.getElementById(getElementByID(Title)).value;
		document.getElementById('HiddentEditPoint1').value=CatID;

	 }
	 
	 function ShowModelWindowRead2(M,C,D,Title,Desc,CatID,ImageURL)
	 {
		//alert(ImageURL)
		ModalBG=M;
		cornerexample=C;
		DialogActionBtn=D;
		  		/* Sweep unnecessary empty text nodes. */
		DOMManager.sweep();

		/*
		 * Attach supporting css bind required
		 * classes for transparency support in Opera.
		 */
		addExtensionsForOpera();

		/* Attach opacity css. */
		attachOpacityCSS();

		/* Adjust height. */
		adjustHeight();

		/* Create the modal dialog */
		g_Modal=new ModalDialog(ModalBG,cornerexample,
			"LookupInsideContant",DialogActionBtn);

		  		g_Modal.show("Testing is the best country...");		
		
		document.getElementById('TitleEditPoint2').value=document.getElementById(getElementByID(Title)).value;
		document.getElementById('HiddentEditPoint2').value=CatID;
		document.getElementById('ImageEndpoint2').src=ImageURL;
			
		 var content = document.getElementById(getElementByID(Desc)).value;		
        MYVAL='DescriptionEditPoint2';
        MyVALWYSWYG='wysiwyg';	
       document.getElementById(getElementIdSpecific(MyVALWYSWYG,MYVAL)).contentWindow.document.body.innerHTML=	content;
	
	
	 }
	function ShowModelWindowRead3(M,C,D,Title,Desc,CatID,ImageURL)
	 {

		ModalBG=M;
		cornerexample=C;
		DialogActionBtn=D;
		  		/* Sweep unnecessary empty text nodes. */
		DOMManager.sweep();

		/*
		 * Attach supporting css bind required
		 * classes for transparency support in Opera.
		 */
		addExtensionsForOpera();

		/* Attach opacity css. */
		attachOpacityCSS();

		/* Adjust height. */
		adjustHeight();

		/* Create the modal dialog */
		g_Modal=new ModalDialog(ModalBG,cornerexample,
			"LookupInsideContant",DialogActionBtn);
			
		  		g_Modal.show("Testing is the best country...");
		  		
	
        document.getElementById(getElementByID('DescriptionEditPoint2')).value=document.getElementById(getElementByID(Desc)).value;     
        document.getElementById(getElementByID('TitleEditPoint2')).value=document.getElementById(getElementByID(Title)).value;               
        document.getElementById('ImageEndpoint2').src=ImageURL;
        
        document.getElementById(getElementByID('HiddentEditPoint2')).value=CatID; 
           
        var content = document.getElementById(getElementByID(Desc)).value;	
        MYVAL='DescriptionEditPoint2';
        MyVALWYSWYG='wysiwyg';	
       document.getElementById(getElementIdSpecific(MyVALWYSWYG,MYVAL)).contentWindow.document.body.innerHTML=	content;

		//g_Modal.disableClose();
	 }
	 
	 function ShowModelWindowClassTitleRead(M,C,D,Title,Desc,CatID,ImageURL)
	 {
		document.getElementById('ImageEndpointClassTitle').src=ImageURL;
		ModalBG=M;
		cornerexample=C;
		DialogActionBtn=D;
		  		/* Sweep unnecessary empty text nodes. */
		DOMManager.sweep();

		/*
		 * Attach supporting css bind required
		 * classes for transparency support in Opera.
		 */
		addExtensionsForOpera();

		/* Attach opacity css. */
		attachOpacityCSS();

		/* Adjust height. */
		adjustHeight();

		/* Create the modal dialog */
		g_Modal=new ModalDialog(ModalBG,cornerexample,
			"LookupInsideContant",DialogActionBtn);
			
		  		g_Modal.show("Testing is the best country...");
		
        document.getElementById(getElementByID('DescriptionEditPoint2')).value=document.getElementById(getElementByID(Desc)).value;     
        document.getElementById(getElementByID('TitleEditPoint2')).value=document.getElementById(getElementByID(Title)).value;       
              
        
        
        document.getElementById(getElementByID('HiddentEditPoint2')).value=CatID; 
           
        var content = document.getElementById(getElementByID(Desc)).value;	
        MYVAL='DescriptionEditPoint2';
        MyVALWYSWYG='wysiwyg';	
       document.getElementById(getElementIdSpecific(MyVALWYSWYG,MYVAL)).contentWindow.document.body.innerHTML=	content;

	
	 }
	  function ShowModelWindowClassTitleReadScoreCard(M,C,D,Title,Desc,CatID,ImageURL)
	 {
		document.getElementById('ImageEndpointClassTitle').src=ImageURL;
		ModalBG=M;
		cornerexample=C;
		DialogActionBtn=D;
		  		/* Sweep unnecessary empty text nodes. */
		DOMManager.sweep();

		/*
		 * Attach supporting css bind required
		 * classes for transparency support in Opera.
		 */
		addExtensionsForOpera();

		/* Attach opacity css. */
		attachOpacityCSS();

		/* Adjust height. */
		adjustHeight();

		/* Create the modal dialog */
		g_Modal=new ModalDialog(ModalBG,cornerexample,
			"LookupInsideContant",DialogActionBtn);
			
		  		g_Modal.show("Testing is the best country...");
		
        document.getElementById(getElementByID('DescriptionEditPoint2')).value=document.getElementById(getElementByID(Desc)).value;     
        document.getElementById(getElementByID('TitleEditPoint2')).innerText=document.getElementById(getElementByID(Title)).value;       
            
           
             
        document.getElementById(getElementByID('HiddentEditPointClassTitle')).value=CatID;            
        var content = document.getElementById(getElementByID(Desc)).value;	
        MYVAL='DescriptionEditPoint2';
        MyVALWYSWYG='wysiwyg';	
       document.getElementById(getElementIdSpecific(MyVALWYSWYG,MYVAL)).contentWindow.document.body.innerHTML=	content;
	 }
	 
	/* Triggered when a successful AJAX response comes from the server.*/
	function ajax_complete(strResponseText,objResponseXML)
	{
		g_Modal.show(strResponseText);
		
		/* Re-activate close button. */
		g_Modal.enableClose();
	}

	/* Triggered when server generates an error. */
	function ajax_error(intStatus,strStatusText)
	{
		g_Modal.show("Error code: ["+ intStatus+ "] error message: [" + 
			strStatusText + "].");

		/* Re-activate close button. */
		g_Modal.enableClose();
	}
	
	
	function window_resize(evt)
	{
		adjustHeight();
	}

	function adjustHeight()
	{
	winW=document.body.scrollWidth;
	winH=document.body.scrollHeight;

	var Vart1=document.body.clientHeight;
	var Vart2=document.body.clientWidth;
		var intWindowHeight=WindowObject.getInnerDimension().getY();
		var intWindowWidth=WindowObject.getInnerDimension().getX();
		if(winH>intWindowHeight)
		{
		    intWindowHeight=winH;
		}
		if(winW>intWindowWidth)
		{
		    intWindowWidth=winW;
		}
		var dynModalBG=new DynamicLayer(ModalBG);
		var intModalHeight=dynModalBG.getHeight();
		var intModalWidth=dynModalBG.getWidth();
		if(intModalWidth<intWindowWidth)
		{
			dynModalBG.setWidth(intWindowWidth);
		}
		if(intModalHeight<intWindowHeight)
		{
			dynModalBG.setHeight(intWindowHeight);
		}
               
	}

	function addExtensionsForOpera()
	{
		/* classes for opera */
		var ModalBG=new CBObject(ModalBG).getObject();
		if(typeof(window.opera)!="undefined")
		{
			ModalBG.className="modalOpera";
		}
	}

	function attachOpacityCSS()
	{
		/*
		 * CSS for opacity support
		 * Note that this can be directly added to the body.
		 * If you do not care about blindly adhering to standards
		 * you can directly include the rules into Master.css
		 *
		 * Do I care? Yes and no.(visit http://www.sarmal.com/Exceptions.aspx
		 * to learn how I feel about it).
		 */
		var opacityCSS = document.createElement("link");
		opacityCSS.type="text/css";
		opacityCSS.rel="stylesheet";
		opacityCSS.href="App_Themes/Application.css";
		document.getElementsByTagName("head")[0].appendChild(opacityCSS);
	}
	
	function ClearDiv(FileObj,NameObj,DescObj)
	{
		 NameObj= getElementByID(NameObj);
		 document.getElementById(NameObj).value='';
		 
		 DescObj= getElementByID(DescObj);
		 document.getElementById(DescObj).value='';
		 
		 FileObj= getElementByID(FileObj);
		 
		 FileObj= FileObj.replace('_','$');
		 FileObj= FileObj.replace('_','$');

		 var who=document.getElementsByName(FileObj)[0];
		 who.value="";
		 var who2= who.cloneNode(false);
		 who2.onchange= who.onchange;
		 who.parentNode.replaceChild(who2,who);

		  //document.getElementById('FileUpload1').value='';
	}	
	function ClearURLUploadDiv(FileObj,NameObj,DescObj,URLObj)
	{
		 NameObj= getElementByID(NameObj);
		 document.getElementById(NameObj).value='';
		 
		 DescObj= getElementByID(DescObj);
		 document.getElementById(DescObj).value='';
		 
		 URLObj= getElementByID(URLObj);
		 document.getElementById(URLObj).value='';
		 
		 FileObj= getElementByID(FileObj);
		 
		 FileObj= FileObj.replace('_','$');
		 FileObj= FileObj.replace('_','$');

		 var who=document.getElementsByName(FileObj)[0];
		 who.value="";
		 var who2= who.cloneNode(false);
		 who2.onchange= who.onchange;
		 who.parentNode.replaceChild(who2,who);

		 
	}	
    function ShowLookupNewWindow(QueryString)
    {         
    }
    if (window.addEventListener) 
        window.addEventListener("onclick", ShowLookupNewWindow, false); 
    else if (window.attachEvent) 
        window.attachEvent("onclick", ShowLookupNewWindow); 
    else if (document.getElementById) 
        window.onload= ShowLookupNewWindow;


	function CheckExcelExt(formObj)
	{
		  //formObj= 'ctl00_MyContantPlaceHolder_' +formObj;
		 formObj= getElementByID(formObj);
	 	  var filename = document.getElementById(formObj).value;
	 	  if(eval(filename.length)>4)
	 	  {
				var filelength = parseInt(filename.length) - 3;
				var fileext = filename.substring(filelength,filelength + 3).toLowerCase();

				//Check file name
				if(filename=='')
				{
		  			 alert ('You must select a file.');
					 document.getElementById(formObj).focus();
					 return false;
				}
				// Check file extenstion
				if (fileext != 'xls' && fileext != 'XLS'  && fileext !='lsx'  && fileext !='LSX')
				{
					 alert ('You can import only excel file!');
					 document.getElementById(formObj).focus();
					 return false;
				}
				else
					 return true;
		  }
		  else
		  {
				alert ('You must select valid file.');
				document.getElementById(formObj).focus();
				return false;
		  }
	}
	
	function CheckRowstoAppend(formObj)
	{		
		 formObj= getElementByID(formObj);
		 var TextBoxObject=document.getElementById(formObj);
	 	 var TextBoxValue = TextBoxObject.value;
	 	 var IsIntFlag=1;
	 	  var strString=TextBoxValue;
          var strValidChars = "0123456789";
           
            //  test strString consists of valid characters listed above
            for (i = 0; i < strString.length ; i++)
            {
                strChar = strString.charAt(i);
                if (strValidChars.indexOf(strChar) == -1)
                   IsIntFlag=0;
                
            }
         
		if(TextBoxValue.length > 2||TextBoxValue==''||TextBoxValue==0||IsIntFlag==0)
		{
		     alert ('Please enter number between 1 to 99.');
			 TextBoxObject.focus();
			 TextBoxObject.value="";
			 return false;
		}
		else 
		    // set text box as read only
		    TextBoxObject.readOnly=true;
		    return true;		 			 	   
	}		
	
	function CheckTextBoxForBlank()
	{
	
	
	
	
	
	
	
	}
	function CheckExt(formObj)
	{		 
		 formObj= getElementByID(formObj);
	 	  var filename = document.getElementById(formObj).value;
	 	  if(eval(filename.length)>4)
	 	  {
				var filelength = parseInt(filename.length) - 3;
				var fileext = filename.substring(filelength,filelength + 3).toLowerCase();

				//Check file name
				if(filename=='')
				{
		  			 alert ('You must select a file.');
					 document.getElementById(formObj).focus();
					 return false;
				}
				// Check file extenstion
				if (fileext != 'gif' && fileext != 'jpeg' && fileext != 'jpg' && fileext != 'bmp' && fileext != 'png')
				{
					 alert ('You can only upload gif, jpg, jpeg, png and bmp images!');
					 document.getElementById(formObj).focus();
					 return false;
				}
				else
					 return true;
		  }
		  else
		  {
				alert ('You must select valid file.');
				document.getElementById(formObj).focus();
				return false;
		  }
	 }
	 
	 function CheckTextBox()
	{		 
		
	 	  var filename = document.getElementById('ctl00$MyContantPlaceHolder$FileUploadXGridViewUploadImageControl').value;
	 	  if(filename=="")
	 	  {
		      alert("Select a valid file");
					 return false;
		  }
		  else
		  {
				return true
				
		  }
	 }
	 
	 
	 function UploadFileNotBlank(formObj)
	{		 
		 formObj= getElementByID(formObj);
	 	  var filename = document.getElementById(formObj).value;
	 	  if(eval(filename.length)>4)
	 	  {
				var filelength = parseInt(filename.length) - 3;
				var fileext = filename.substring(filelength,filelength + 3).toLowerCase();

				//Check file name
				if(filename=='')
				{
		  			 alert ('You must select a file.');
					 document.getElementById(formObj).focus();
					 return false;
				}
				
				else
					 return true;
		  }
		 return true;
	 }
	function CheckExtScoreCardSetting(formObj,MyTextControl,MyTextDescControl)
	{		 
		 formObj= getElementByID(formObj);
		  MyTextControl= getElementByID(MyTextControl);
		   MyTextDescControl= getElementByID(MyTextDescControl);
		   
	 	  var filename = document.getElementById(formObj).value;
	 	    var Title = document.getElementById(MyTextControl).value;
	 	    var Desciption = document.getElementById(MyTextDescControl).value; 	    
	 	    
	 	     
                if(eval(filename.length)>4)
                {
	                var filelength = parseInt(filename.length) - 3;
	                var fileext = filename.substring(filelength,filelength + 3).toLowerCase();
	                
	                // Check file extenstion
	                if (fileext != 'gif' && fileext != 'jpeg' && fileext != 'jpg' && fileext != 'bmp' && fileext != 'png')
	                {
		                 alert ('You can only upload gif, jpg, jpeg, png and bmp images!');
		                 document.getElementById(formObj).focus();
		                 return false;
	                }
	            } 
                if (filename !='' || Title !='' || Desciption !='')
                {
	                 return true;
	            }
	            else
	            {
	                alert ('You must select atlest one field.');
	                document.getElementById(formObj).focus();
	                return false;
	            }                          
               
        }
	 	 
	 function ImageControlHeader(PostBackURL,PrimaryKey)
      {
    
        window.document.forms[0].action=PostBackURL+ "&RecId="+PrimaryKey;
        window.document.forms[0].submit();
    }
        
  function OpenKioskWindow(URL)
  {   

     
       if (navigator.appName == "Microsoft Internet Explorer")
       { // better be ie6 at least
          window.open(URL, '', 'toolbar=no,titlebar=no,statusbar=no,resizable=yes,location=no,status=no,scrollbars=yes,fullscreen=yes');
       }
       else if (navigator.appName == "Windows Internet Explorer")
       { // better be ie7 at least
          window.open(URL, '', 'toolbar=no,titlebar=no,statusbar=no,resizable=yes,location=no,status=no,scrollbars=yes,fullscreen=yes');
       }
       else
       { // i.e. if Firefox
          window.open(URL, '', 'fullscreen=yes,statusbar=no,location=no ,BookMarks Toolbar=no ,Titlebar=no , Navigation Toolbar=no ,scrollbars=yes, resizable=yes ');
       }	 
		        

  }
			  
function GetXmlHttpObject(handler)
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		  objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}

function SetDropDownValueToHiddenControl(SelectedValue,MyCurrentHiddenField)
{    
 document.getElementById(MyContantPlaceHolderId + MyCurrentHiddenField).value=SelectedValue;
}

function GetDropDownItems(MyCurrentValue,MyDropDownControl)
{ 
	  var val=MyCurrentValue;
	  MyCurrentDropDownControlID=getElementByID(MyDropDownControl);
	  if(val!="")
	  {      
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			{
				 alert ("Browser does not support HTTP Request")
				 return
			} 
			var url="ReturnBuildingNames.ashx";
			url=url+"?val="+val;
			url=url+"&sid="+Math.random();
			xmlHttp.onreadystatechange=DropDownStateChanged;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
	  }
	  else
	  {
	        ResetDropDown(MyDropDownControl); 
	  }
}
function GetDataPointItems(MyCurrentValue,MyDropDownControl,MyParentControl)
{ 
	  var MyParentControlValue;
      if(MyParentControl!=null)
      {
          var MyParentControlValue=document.getElementById(getElementByID(MyParentControl)).value;
          
      }
	  
	  var val=MyCurrentValue;
	  MyCurrentDropDownControlID=getElementByID(MyDropDownControl);
	  if(val!="")
	  {      
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			{
				 alert ("Browser does not support HTTP Request")
				 return
			} 
			var url="ReturnDataPointNames.ashx";
			url=url+"?val="+val;
			url=url+"&control="+MyDropDownControl;			
			url=url+"&sid="+Math.random();
			if(MyParentControlValue!=null)
			{
			    url=url+"&parentId="+MyParentControlValue;
			}
			xmlHttp.onreadystatechange=DropDownStateChanged;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
	  }
	  else
	  {
	       SetDropDownValueToHiddenControl("",'DropDownListBuildingFeatureDatapoint');
           ResetDropDown('DropDownListBuildingFeatureDatapoint') ;
	  }
}
function GetDataClassItems(MyCurrentValue,MyDropDownControl,MyParentControl)
{ 
      var MyParentControlValue;
      var ClientID;
      if(MyParentControl!=null)
      {
          var MyParentControlValue=document.getElementById(MyContantPlaceHolderId + MyParentControl).value; 
          
      }
       if(document.getElementById(MyContantPlaceHolderId + 'MyHiddenControlClientID')!=null)
      {
         ClientID=document.getElementById(MyContantPlaceHolderId + 'MyHiddenControlClientID').value; 
      }
      
	  var val=MyCurrentValue;
	  MyCurrentDropDownControlID=document.getElementById(MyContantPlaceHolderId + MyDropDownControl).id;
    
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			{
				 alert ("Browser does not support HTTP Request")
				 return
			} 
			var url="ReturnDataClassNames.ashx";
			url=url+"?val="+val;						
			url=url+"&sid="+Math.random();
			url=url+"&ClientID="+ClientID;
			if(MyParentControlValue!=null && MyParentControlValue!="")
			{
			    url=url+"&parentId="+MyParentControlValue;
			}
			xmlHttp.onreadystatechange=DropDownStateChanged;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);

           if(document.getElementById(MyContantPlaceHolderId +'DropDownListCommonDataClassID')!=null)
           {
	            SetDropDownValueToHiddenControl("",'DropDownListCommonDataClassID');
                ResetDropDown('DropDownListCommonDataClassID') ; 
           }
           if(document.getElementById(MyContantPlaceHolderId +'MyHiddenControlDataClass')!=null)
           {
                SetDropDownValueToHiddenControl("",'MyHiddenControlDataClass');
           }
          
           if(document.getElementById(MyContantPlaceHolderId + 'DropDownListBuildingFeatureDatapoint')!=null)
           {
                SetDropDownValueToHiddenControl("",'DropDownListBuildingFeatureDatapoint');
                ResetDropDown('DropDownListBuildingFeatureDatapoint') ;
           }
           
           if(document.getElementById(MyContantPlaceHolderId +'DropDownListSustainabilityProjectDatapoint')!=null)
           {
                SetDropDownValueToHiddenControl("",'DropDownListSustainabilityProjectDatapoint');
                ResetDropDown('DropDownListSustainabilityProjectDatapoint') ;
           }
           
           if(document.getElementById(MyContantPlaceHolderId +'MyHiddenControlDataPoint')!=null)
           {
                SetDropDownValueToHiddenControl("",'MyHiddenControlDataPoint');
           }
           
           if(document.getElementById(MyContantPlaceHolderId +'DropDownListBuildingFeatureArithmeticOperation')!=null)
	       {
	            ResetDropDown('DropDownListBuildingFeatureArithmeticOperation');
	       }
	       
	       if(document.getElementById(MyContantPlaceHolderId +'DropDownListSustainabilityProjectArithmeticOperation')!=null)
	       {
	             ResetDropDown('DropDownListSustainabilityProjectArithmeticOperation');
	       }
	       
	       if(document.getElementById(MyContantPlaceHolderId +'MyHiddenControlArithmetic')!=null)
	       {
	            SetDropDownValueToHiddenControl("",'MyHiddenControlArithmetic');
	       }

}

function GetDataClassItemsClient(MyCurrentValue,MyDropDownControl,MyParentControl)
{ 
        var MyParentControlValue;
      var MyParentControl=MyParentControl + 'ID';
     
      if(MyParentControl!=null)
      {
          var MyParentControlValue=document.getElementById(MyContantPlaceHolderId + MyParentControl).value;
      }  
	  var val=MyCurrentValue;
	  MyCurrentDropDownControlID=document.getElementById(MyContantPlaceHolderId + MyDropDownControl).id;
     
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			{
				 alert ("Browser does not support HTTP Request")
				 return
			} 
			var url="ReturnDataPointNames.ashx";
			url=url+"?val="+val;						
			url=url+"&sid="+Math.random();
			if(MyParentControlValue!=null)
			{
			    url=url+"&ClientID="+MyParentControlValue;
			}					
			xmlHttp.onreadystatechange=DropDownStateChanged;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);

             if(document.getElementById(MyContantPlaceHolderId +'DropDownListSustainabilityProjectDatapoint')!=null)
           {
                SetDropDownValueToHiddenControl("",'DropDownListSustainabilityProjectDatapoint');
                ResetDropDown('DropDownListSustainabilityProjectDatapoint') ;
           }
           if(document.getElementById(MyContantPlaceHolderId +'MyHiddenControlDataPoint')!=null)
           {
                SetDropDownValueToHiddenControl("",'MyHiddenControlDataPoint');
           }

	  
}

function GetClientID(MyCurrentValue,MyParentControl)
{ 
      var MyParentControlValue;
      if(MyParentControl!=null)
      {
          var MyParentControlValue=document.getElementById(getElementByID(MyParentControl)).value; 
         
      }     
	  
	  if(MyParentControlValue!="")
	  {      
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			{
				 alert ("Browser does not support HTTP Request")
				 return
			} 
			var url="ReturnDataClassNames.ashx";
			url=url+"?ClientID="+MyParentControlValue;						
			url=url+"&sid="+Math.random();
			
			xmlHttp.onreadystatechange=DropDownStateChanged;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
	  }else{}
}

function GetResourceDataClassItems(MyCurrentValue,MyDropDownControl)
{ 
      
	  var val=MyCurrentValue;
	  var ClientID;
	  MyCurrentDropDownControlID=getElementByID(MyDropDownControl);
	  
	   if(document.getElementById(getElementByID('MyHiddenControlClientID'))!=null)
      {
         ClientID=document.getElementById(getElementByID('MyHiddenControlClientID')).value;           
      }
     
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			{
				 alert ("Browser does not support HTTP Request")
				 return
			} 
			var url="ReturnResourceDataClass.ashx";
			url=url+"?val="+val;						
			url=url+"&sid="+Math.random();
			url=url+"&ClientID="+ClientID;
			xmlHttp.onreadystatechange=DropDownStateChanged;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);

           if(document.getElementById(MyContantPlaceHolderId +'DropDownListBuildingFeatureResource')!=null)
           { 
	            SetDropDownValueToHiddenControl("",'DropDownListBuildingFeatureResource');
                ResetDropDown('DropDownListBuildingFeatureResource') ; 
           }
           if(document.getElementById(MyContantPlaceHolderId +'DropDownListCommonDataClassID')!=null)
           {
                SetDropDownValueToHiddenControl("",'DropDownListCommonDataClassID');
                ResetDropDown('DropDownListCommonDataClassID') ; 
           }
           if(document.getElementById(MyContantPlaceHolderId +'DropDownListBuildingFeatureDatapoint')!=null)
           {
                SetDropDownValueToHiddenControl("",'DropDownListBuildingFeatureDatapoint');
                ResetDropDown('DropDownListBuildingFeatureDatapoint') ;
           }
           
           if(document.getElementById(MyContantPlaceHolderId +'DropDownListBuildingFeatureArithmeticOperation')!=null)
	       {
	            SetDropDownValueToHiddenControl("",'MyHiddenControlArithmetic');
	            ResetDropDown('DropDownListBuildingFeatureArithmeticOperation');
	       }
           
	//  }   
}


function GetArithmeticItems(MyCurrentValue,MyDropDownControl)
{ 
	   var val=MyCurrentValue;
	  var ClientID;
	  
	  MyCurrentDropDownControlIDA=document.getElementById(MyContantPlaceHolderId + MyDropDownControl).id;
	  if(document.getElementById(MyContantPlaceHolderId + 'MyHiddenControlClientID')!=null)
      {
         ClientID=document.getElementById(MyContantPlaceHolderId + 'MyHiddenControlClientID').value; 
          
      }
     
			xmlHttpA=GetXmlHttpObject()
			if (xmlHttpA==null)
			{
				 alert ("Browser does not support HTTP Request")
				 return
			} 
			var url="ReturnArithmeticNames.ashx";
			url=url+"?val="+val;						
			url=url+"&sid="+Math.random();
			url=url+"&ClientID="+ClientID;
			xmlHttpA.onreadystatechange=DropDownStateChangedArithmetic;
			xmlHttpA.open("GET",url,true);
			xmlHttpA.send(null);

	    if(document.getElementById(MyContantPlaceHolderId +'DropDownListBuildingFeatureArithmeticOperation')!=null)
	    {
	         
	        ResetDropDown('DropDownListBuildingFeatureArithmeticOperation');
	    }
	    
	    if(document.getElementById(MyContantPlaceHolderId +'MyHiddenControlArithmetic')!=null)
	    {
	        SetDropDownValueToHiddenControl("",'MyHiddenControlArithmetic');
	    }
	    
	    if(document.getElementById(MyContantPlaceHolderId +'DropDownListSustainabilityProjectArithmeticOperation')!=null)
	    {
	        ResetDropDown('DropDownListSustainabilityProjectArithmeticOperation');
	    }

}
function DropDownStateChangedArithmetic() 
{ 
	 if (xmlHttpA.readyState==4 || xmlHttpA.readyState=="complete")
	 {     
		  //if(xmlHttp.responseText!="") return false    
		  var strHTTPA=xmlHttpA.responseText;
		  if(strHTTPA=="Not Found")
		  {  
				alert("Data Not found"); 
		  }
		  else
		  {
		        BindDropDown(MyCurrentDropDownControlIDA,strHTTPA);  
		  }
	 } 
}
function DropDownStateChanged() 
{ 
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 {        
		  var strHTTP=xmlHttp.responseText;
		  if(strHTTP=="Not Found")
		  {  
				alert("Data Not found"); 
		  }
		  else
		  {
		    
		        BindDropDown(MyCurrentDropDownControlID,strHTTP);  
		  }
	 } 
}

function BindDropDown(CurrentControlID,StringArray)
{

       var tempArray = new Array();
       tempArray = StringArray.split('~`');
       var ii=0;     
       var jj=0;       
       var len = document.getElementById(CurrentControlID).options.length;
       for (ii=0; ii<len; ii++) {
              document.getElementById(CurrentControlID).remove(0); //It is 0 (zero) intentionally 
       }
       if(tempArray.length>1)
       {
              document.getElementById(CurrentControlID).options[jj]=new Option('--Select--','');
              for(ii=0;ii<tempArray.length;ii++)
              {   
                        jj++;           
                        var SecondtempArray = new Array();
                        SecondtempArray = tempArray[ii].split('`~');
                        document.getElementById(CurrentControlID).options[jj]=new Option(SecondtempArray[1],SecondtempArray[0]);
              }
       }
       else
       {
                document.getElementById(CurrentControlID).options[0]=new Option('--Select--','');
              if(StringArray.length > 5)
              { 
                        var SecondtempArray = new Array();
                        SecondtempArray = StringArray.split('`~');
                        
                        document.getElementById(CurrentControlID).options[1]=new Option(SecondtempArray[1],SecondtempArray[0]);
              }
       }
       document.getElementById(CurrentControlID).focus();  
       document.getElementById(CurrentControlID).selectedvalue='';  
}




 function BlockNonNumbersForConfig(TextBoxObject,MinValue,MaxValue)
{              
    var obj = TextBoxObject.id;  
    var TextBoxObjectValue= TextBoxObject.value; 
  
    if(TextBoxObjectValue < eval(MinValue))
    {
        alert("Invalid value !\rPlease enter the value between " + MinValue + " and " + MaxValue);      
        TextBoxObject.focus();		            
    }  
    if(TextBoxObjectValue >eval(MaxValue) )
    {
        alert("Invalid value !\rPlease enter the value between " + MinValue + " and " + MaxValue);
        TextBoxObject.focus();	
    }	        	      
}    

function DisplayGridrowShowCase(obj)
{
   var grid = document.getElementById('ctl00_MyContantPlaceHolder_ListKioskTabs');
        for( i = 0; i < document.getElementById('ctl00_MyContantPlaceHolder_ListKioskTabs').rows.length; ++i )
        {
          var rows = document.getElementById('ctl00_MyContantPlaceHolder_ListKioskTabs').rows.length;          
          var rowText = grid.rows[i].cells[1].innerHTML;
          
             if(rowText=="<SPAN>WOW Showcase</SPAN>" || rowText=="<span>WOW Showcase</span>")
               {
                 if(obj=='P')
                   {                       
                     if(navigator.appName.indexOf("Microsoft") > -1)
                       {
                        grid.rows[i].style.display= 'block'
                        } 
                        else 
                        {
                        grid.rows[i].style.display='table-row' ; 
                        }
                   }
                   if(obj=='U' || obj=='G' )
                   {
                     grid.rows[i].style.display='none';                     
                   }
              }
        }
}

function DisplayGridrowMultipleKiosk(obj)
{
   var grid = document.getElementById('ctl00_MyContantPlaceHolder_ListKioskTabs');
        for( i = 0; i < document.getElementById('ctl00_MyContantPlaceHolder_ListKioskTabs').rows.length; ++i )
        {
          var rows = document.getElementById('ctl00_MyContantPlaceHolder_ListKioskTabs').rows.length;          
          var rowText = grid.rows[i].cells[1].innerHTML;
          
             if(rowText=="<SPAN>Multiple KIOSKS</SPAN>" || rowText=="<span>Multiple KIOSKS</span>")
               {
                 if(obj=='P')
                   {                       
                     if(navigator.appName.indexOf("Microsoft") > -1)
                       {
                        grid.rows[i].style.display= 'block'
                        } 
                        else 
                        {
                        grid.rows[i].style.display='table-row' ; 
                        }
                   }
                   if(obj=='U' || obj=='G' )
                   {
                     grid.rows[i].style.display='none';                     
                   }
              }
        }
}
function DisplayForm(obj)
{
    if(obj=='U')
    {
        document.getElementById('PublicDiv').style.display = "none";
        document.getElementById('UserDiv').style.display = "block";
        document.getElementById('GroupDiv').style.display = "none";
        DisplayGridrowShowCase('U');
        DisplayGridrowMultipleKiosk('U');
    }
    else if(obj=='P')
    {
        document.getElementById('PublicDiv').style.display = "block";
        document.getElementById('UserDiv').style.display = "none";
        document.getElementById('GroupDiv').style.display = "none";
        DisplayGridrowShowCase('P');
        DisplayGridrowMultipleKiosk('P')
        
    }
     else if(obj=='G')
    {
        document.getElementById('PublicDiv').style.display = "none";
        document.getElementById('UserDiv').style.display = "none";
        document.getElementById('GroupDiv').style.display = "block";
        DisplayGridrowShowCase('G');
        DisplayGridrowMultipleKiosk('U');
        
    }
    else
    {
        document.getElementById('PublicDiv').style.display = "none";
        document.getElementById('UserDiv').style.display = "none";
        document.getElementById('GroupDiv').style.display = "none";
   }
}


function DisplaySystemForm(obj)
{
    if(obj=='Image')
    {
        document.getElementById('PublicDiv').style.display = "none";
        document.getElementById('UserDiv').style.display = "block";
  
    }
    else if(obj=='YouTube')
    {
        document.getElementById('PublicDiv').style.display = "block";
        document.getElementById('UserDiv').style.display = "none";
   
    }
     
    else
    {
        document.getElementById('PublicDiv').style.display = "none";
        document.getElementById('UserDiv').style.display = "none";

   }
}

function GetPersonBuilding(CurrentValue,CurrentPersonCode,CurrentBuildingName,CurrentBuildingID)
{ 
	 
	  var val=CurrentValue;
	  var MyClientID='';
	  
	  MyPersonCode=document.getElementById(getElementByID("_"+CurrentPersonCode));
	  
	  MyBuildingName=document.getElementById(getElementByID("_"+CurrentBuildingName));
	  MyBuildingID=document.getElementById(getElementByID("_"+CurrentBuildingID));
	  MyClientID= document.getElementById(getElementByID('_CurrentClientID')).value;
	 
	  if(val!="")
	  {      
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			{
				 alert ("Browser does not support HTTP Request")
				 return
			} 
			var url="ReturnBuildingPersonNames.ashx";
			url=url+"?val="+val;
			url=url+"&clientid="+MyClientID;
			url=url+"&sid="+Math.random();
			xmlHttp.onreadystatechange=GetPersonBuildingStateChanged;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
	  }
	  else
	  {
	      MyBuildingID.value="";
	      MyBuildingName.innerText="";
	      MyPersonCode.innerText="";
	  }
}

 function LaunchKioskWindow(URL)
  {    
       if (navigator.appName == "Microsoft Internet Explorer" || navigator.appName == "Windows Internet Explorer")
       {
            if(navigator.appVersion.indexOf("MSIE 6.0")!=-1)
            {				
                if(confirm("This action will close the window and open the Kiosk. Are you sure?"))
                {
                    if(document.getElementById("LogoutID")!=null)
                    { 
                         var btn = document.getElementById("LogoutID");                        
                         btn.click();
						 window.open(URL, '', 'toolbar=no,titlebar=no,statusbar=no,resizable=yes,location=no,status=no,scrollbars=yes,fullscreen=yes');
						 window.opener = top;
						 window.close();
                    } 
                }
            }
            else if(navigator.appVersion.indexOf("MSIE 7.0")!=-1)
            {
                if(confirm("This action will close the window and open the Kiosk. Are you sure?"))
                {
                    if(document.getElementById("LogoutID")!=null)
                    {
                        var btn = document.getElementById("LogoutID");
                        btn.click();
                        window.open('','_parent','');
                        window.close();
						window.open(URL, '', 'toolbar=no,titlebar=no,statusbar=no,resizable=yes,location=no,status=no,scrollbars=yes,fullscreen=yes');
                    } 
                }
            }
            else
            {
                if(confirm("This action will close the window and open the Kiosk. Are you sure?"))
                {
                    if(document.getElementById("LogoutID")!=null)
                    {
                        var btn = document.getElementById("LogoutID");
                        btn.click();                        
						window.open(URL, '', 'toolbar=no,titlebar=no,statusbar=no,resizable=yes,location=no,status=no,scrollbars=yes,fullscreen=yes');
						window.opener = top;
						window.close();
					}   
                }
            }
      }
      else
      {	
			if(confirm("This action will log out the session and open the Kiosk. Are you sure?"))
			{				
				if(document.getElementById("LogoutID")!=null)
				{					
					var btn = document.getElementById("LogoutID");					
					location.href=btn.href ;
					//btn.click();              
					
					window.open(URL, '', 'fullscreen=yes,statusbar=no,location=no ,BookMarks Toolbar=no ,Titlebar=no , Navigation Toolbar=no ,scrollbars=yes, resizable=yes ');					
					window.opener = top;					
					window.close();
				  }
			}
      } 
  } 

function GetPersonBuildingStateChanged() 
{ 
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")	 
	 {     
		  //if(xmlHttp.responseText!="") return false    
		  var strHTTP=xmlHttp.responseText;
		  if(strHTTP=="Not Found")
		  {  
				alert("Data Not found"); 
		  }
		  else
		  {
		      var tempArray = new Array();
				tempArray = strHTTP.split('`~');  
				MyBuildingID.value=tempArray[0];
				MyBuildingName.innerText=tempArray[1];
				MyPersonCode.innerText=tempArray[2];
		  }
	 } 
}

   function MassSelectionPersonType(MyButton,PostBackUrl,PostBackDelimiter,XGridName,HidenVieldRecID)
        {     
			 ArrRecordCount='';
			 var HidenVieldRecIDControl=null;
			 var TargetBaseControl='';
			 var elementsAll=  document.getElementsByTagName("body")[0].getElementsByTagName("*");
			 for(i=0; i<elementsAll.length;i++) 
				 {
					  if(elementsAll[i].id.indexOf(HidenVieldRecID)>=0)
					  {
							HidenVieldRecIDControl = elementsAll[i];
							break;	  
					  }
				 }
	 		 
	         elementsAll=  document.getElementsByTagName("body")[0].getElementsByTagName("*");
			 for(i=0; i<elementsAll.length;i++) 
				 {
					  if(elementsAll[i].id.indexOf(XGridName)>=0)
					  {
							TargetBaseControl = elementsAll[i];
							break;	  
					  }
				 }
	 				
			 var elements = TargetBaseControl.getElementsByTagName("span");
	          
			 for(i=0; i<elements.length;i++ ) 
				 {
			  		var check= elements[i].getElementsByTagName("INPUT");

                    for (j=0;j<check.length;j++)
                        {
                           if(elements[i].attributes["PrimaryValue"]!= null && elements[i].attributes["PrimaryValue"].nodeValue!=null) 
					        {
                              if(check[j].type=='checkbox' && check[j].checked == true)
                                {
								  if(ArrRecordCount.length==0)
								   {								
										  ArrRecordCount=ArrRecordCount+elements[i].attributes["PrimaryValue"].nodeValue;							 
								   }
								  else
								   {  								
										  ArrRecordCount=ArrRecordCount+PostBackDelimiter+elements[i].attributes["PrimaryValue"].nodeValue;										 
								   }
								
						        } 
						    }
						}						      
				  }

	          if(ArrRecordCount.length==0)
				 {
					  alert('No item is selected ! Please select item.');
					  return false;
				 }
			  else
				 {   
				 
				 
				 //Check if Element is not null
				  if(document.getElementById(getElementByID('_DropDownListKioskType'))!=null)
				   {
				     //Find Element value and assign it to variable
				     var KioskTypeValue=document.getElementById(getElementByID('_DropDownListKioskType'));
				     //Check if KioskType value is blank
				     if(KioskTypeValue.value=="")
				     {
				       alert("Select Kiosk Type");
				       return false				 
				     }
				     
				    
				      //Check if Kiosk Value Type is P
				     else if(KioskTypeValue.value=="P")
				     {
				     //Find Element value and assign it to variable			     
				     if(document.getElementById(getElementByID('_DropDownListKioskPublicBuilding'))!=null)
				     {
				     
				         var publicKiosk=document.getElementById(getElementByID('_DropDownListKioskPublicBuilding'));
    				     
				         if(publicKiosk.value=="")
				         {
				           alert("Select Building Name");
				           return false					     
				         }
				     
				     }
				     
				     }
				     
				     //Check if KioskType consist of User
				     
				     else if(KioskTypeValue.value=="U")
				     {
				     
				     if(document.getElementById(getElementByID('_DropDownListKioskPersonName'))!=null)
				     {
				      var publicKiosk=document.getElementById(getElementByID('_DropDownListKioskPersonName'));
				     
				     if(publicKiosk.value=="")
				     {
				       alert("Select Person Name");
				       return false					     
				     }
				     
				     }
				     
				     }
				     
				     //Check if kiosk Type if Group 
				    else if(KioskTypeValue.value=="G")
				     {
				     
				     //Check if Elemengt is not null
				     if(document.getElementById(getElementByID('_DropDownListKioskGroup'))!=null)
				     { 
				      //Assign Element value to variable
				     var publicKiosk=document.getElementById(getElementByID('_DropDownListKioskGroup'))
				     
				     if(publicKiosk.value=="")
				     {
				       alert("Select Group Name");
				       return false					     
				     }
				     
				     }
				     
				     }	     
				     
				   }			    
				    ButtonWithoutValidationDisabled(MyButton.id);
					window.document.forms[0].action=PostBackUrl+ "&KioskId="+ArrRecordCount+"";						
		         }			
				
        }
        
function CheckUploadOption(obj)
{

   if(obj.value=='U')
   {
     document.getElementById('MediaFileUpload').style.display = "none";
     document.getElementById('txtUTubeURL').style.display = "block";
     document.getElementById('MediaID').style.display="none";
     document.getElementById('UTubeID').style.display="block";
     document.getElementById('UpdatetxtUTubeURL').style.display = "block"; 
     document.getElementById('UpdateFileUpload').style.display = "none";
     document.getElementById('UpdateMediaID').style.display="none";
     document.getElementById('UpdateUTubeID').style.display="block";

   }
   else
   { 
     document.getElementById('MediaID').style.display="block";
     document.getElementById('UTubeID').style.display="none";
     document.getElementById('MediaFileUpload').style.display = "block";
     document.getElementById('txtUTubeURL').style.display = "none";  
     document.getElementById('UpdateFileUpload').style.display = "block";  
     document.getElementById('UpdatetxtUTubeURL').style.display = "none";   
     document.getElementById('UpdateMediaID').style.display="block";
     document.getElementById('UpdateUTubeID').style.display="none";   
   }      
}
        
function ShowGrid(obj)
{
    var div = document.getElementById('div'+obj);
    var img = document.getElementById('img' + obj);        
    if (div.style.display == "none")
    {            
        
        div.style.display = "block";
        img.src = "images/collapse.GIF";
    }
    else
    {
        div.style.display = "none";
			img.src = "images/expand.GIF";
    }
    

}
function ShowImageLibraryWindow(URL)
{

    window.open(URL,'', 'toolbar=no,titlebar=no,statusbar=no,resizable=yes,location=no,status=no,scrollbars=yes');
}

function getElementByOpenarID(MyElement)
{            
    var elements= document.getElementsByTagName("body")[0].getElementsByTagName("*");  
    for(getElementByIDCount=0; getElementByIDCount<elements.length;getElementByIDCount++) 
    {       
          if(elements[getElementByIDCount].id.indexOf(MyElement)>=0)
          {
			      //alert('MyElement ' + elements[getElementByIDCount].id);   
			      return elements[getElementByIDCount].id;   
		  }
    }
}
function ShowLEEDModelPopupWindow(HiddenField,ThImage,FlImage)
{   
     var HiddenFields=getElementByOpenarID(HiddenField); 
     ThImage=getElementByID(ThImage);
	  FlImage=getElementByID(FlImage);
	  
     var url=window.document.forms[0].action;
	 url=url.replace("ScoreCard.aspx","ImageLibrary.aspx");
      url=url.replace("DETAILVIEW","INDEXIMAGEVIEWER");
      
     url=url+'&HiddenField='+ HiddenFields +'&ThImage='+ThImage+'&FlImage='+FlImage;     
	 window.open(url,'', 'toolbar=no,titlebar=no,statusbar=no,resizable=yes,location=no,status=no,scrollbars=yes');
}
function ShowLEEDSETTINGModelPopupWindow(HiddenField,ThImage,FlImage)
{      
     var HiddenFields=getElementByOpenarID(HiddenField);     
     ThImage=getElementByID(ThImage);
	  FlImage=getElementByID(FlImage);
	  
     var url=window.document.forms[0].action;
	 url=url.replace("ScoreCardSetting.aspx","ImageLibrary.aspx");
      url=url.replace("DETAILVIEW","INDEXIMAGEVIEWER");
      
     url=url+'&HiddenField='+ HiddenFields +'&ThImage='+ThImage+'&FlImage='+FlImage;     
	 window.open(url,'', 'toolbar=no,titlebar=no,statusbar=no,resizable=yes,location=no,status=no,scrollbars=yes');
}

function ShowModelPopupWindow(HiddenField,ThImage,FlImage,Mode,MultipleImage,EnableLogo)
{
	 HiddenField=getElementByID(HiddenField);
	 ThImage=getElementByID(ThImage);
	 FlImage=getElementByID(FlImage);
	 
	 var url=window.document.forms[0].action;
	 url=url.replace("Property.aspx","ImageLibrary.aspx");
	 url=url.replace("Inventory.aspx","ImageLibrary.aspx");
	 url=url.replace("NEWFEATURE","INDEXIMAGEVIEWER");
	 url=url.replace("LookUpSelectPage.aspx","ImageLibrary.aspx");
	 url=url.replace("EDITSCOPE","INDEXIMAGEVIEWER");
	 
	 url=url.replace("SUBCATEGORYNEW","INDEXIMAGEVIEWER");
	 url=url.replace("SUBCATEGORYEDIT","INDEXIMAGEVIEWER");
	 url=url.replace("SCOPENEW","INDEXIMAGEVIEWER");
	 url=url.replace("SELECTGAUGE","INDEXIMAGEVIEWER");
	
	 url=url.replace("EDITEQUIVALENTUNIT","INDEXIMAGEVIEWER");
	 url=url.replace("UPDATEEQUIVALENTUNIT","INDEXIMAGEVIEWER");
	 url=url.replace("SAVESUSTAINABLITY","INDEXIMAGEVIEWER");	 
	 url=url.replace("NEWSUSTAINABLITY","INDEXIMAGEVIEWER");
	 
	 url=url.replace("EDITSUSTAINABLITY","INDEXIMAGEVIEWER");	 
	 url=url.replace("UPDATESUSTAINABLITY","INDEXIMAGEVIEWER");
	 
	 url=url.replace("COMMONDATACLASSUPDATE","INDEXIMAGEVIEWER");
	 url=url.replace("COMMONDATACLASSEDIT","INDEXIMAGEVIEWER");
	 
	 url=url.replace("EQUIVALENTNEW","INDEXIMAGEVIEWER");
     url=url.replace("EQUIVALENTSAVE","INDEXIMAGEVIEWER");
	 url=url.replace("UPDATEFEATURE","INDEXIMAGEVIEWER");
	 url=url.replace("EDITFEATURE","INDEXIMAGEVIEWER");
	 url=url.replace("SAVEFEATURE","INDEXIMAGEVIEWER");
	 url=url.replace("ADDBUILDING","INDEXIMAGEVIEWER");	 
	 url=url.replace("EDITBUILDING","INDEXIMAGEVIEWER");
	 url=url.replace("NEWCARBONFOOTPRINT","INDEXIMAGEVIEWER");
	 url=url.replace("SAVECARBONFOOTPRINT","INDEXIMAGEVIEWER");
	 url=url.replace("UPDATECARBONFOOTPRINT","INDEXIMAGEVIEWER");
	 url=url.replace("EDITCARBONFOOTPRINT","INDEXIMAGEVIEWER");
	 url=url.replace("UPDATE","INDEXIMAGEVIEWER");
     url=url.replace("NEW","INDEXIMAGEVIEWER");
     url=url.replace("SAVE","INDEXIMAGEVIEWER");
     url=url.replace("EDIT","INDEXIMAGEVIEWER");
     
     
    
	 url=url+'&HiddenField='+HiddenField +'&ThImage='+ThImage+'&FlImage='+FlImage+'&Mode='+Mode +'&MultiImage='+MultipleImage+'&EnableLogo='+EnableLogo;
	
     
	 window.open(url,'', 'toolbar=no,titlebar=no,statusbar=no,resizable=yes,location=no,status=no,scrollbars=yes');
	
}

function ShowLookupSelectWindow(QueryString,FieldNameID,FieldNameValue,EntityName)
{
     var State=document.getElementById(getElementByID('_TextBoxBuildingStateProv'));

     var City=document.getElementById(getElementByID('_TextBoxBuildingCity'));	

     var Country =  document.getElementById(getElementByID('_DropDownListBuildingCountryName'));
        
     var SelectedValue=Country.options[Country.selectedIndex].text;
     if(SelectedValue=="--Select--")
         SelectedValue="";
	 this.MyFieldNameID = FieldNameID;
	 this.FieldNameValue= FieldNameValue;
	 
     this.CurrentURL = "LookUpWindow.aspx" +'?'+QueryString + '&EntityName='+ EntityName+'&HiddenFieldID='+this.MyFieldNameID+'&HiddenFieldValue='+this.FieldNameValue +'&Country='+ SelectedValue +'&State='+ State.value +'&City='+ City.value;
     window.open(this.CurrentURL,"Details","width=600px,height=500px,left=250px,top=50px,resize=1,scrollbars=1");
     
	 return false;
}

/* Javascript to Check is Caps lock is on or not   */
function capLock(e){

 KeyCode = e.keyCode?e.keyCode:e.which;
 StrokeKey = e.shiftKey?e.shiftKey:((KeyCode == 16)?true:false);
 if(((KeyCode >= 65 && KeyCode <= 90) && !StrokeKey)||((KeyCode >= 97 && KeyCode <= 122) && StrokeKey))
    {
        //document.getElementById('lblMessage').innerHTML= 'Caps Lock is on';
        showToolTip(e);
    }
    else
    {
        //document.getElementById('lblMessage').innerHTML= '';
        hideToolTip();
    }
    

}
function showToolTip(e){
	if(document.all)e = event;
	text="Caps Lock is On.";
	var obj = document.getElementById('bubble_tooltip');
	var obj2 = document.getElementById('bubble_tooltip_content');
	var PasswordControl=document.getElementById('txtPassword');
	
	obj2.innerHTML = text;
	obj.style.display = 'block';
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
	var leftPos = 550;
	
	if(leftPos<0)leftPos = 0;
	obj.style.left = getX(PasswordControl) + 'px';
	obj.style.top=getY(PasswordControl) + 'px';
	setTimeout("document.getElementById('bubble_tooltip').style.display = 'none';",1500);	
	
}	
function getY( oElement )
{
    var iReturnValue = 0;
    while( oElement != null )
    {
        iReturnValue += oElement.offsetTop;
        oElement = oElement.offsetParent;
    }
    iReturnValue=iReturnValue-60;
    return iReturnValue;
}
function getX( oElement )
{
    var iReturnValue = 0;
    while( oElement != null ) 
    {
        iReturnValue += oElement.offsetLeft ;
        oElement = oElement.offsetParent;
    }
    iReturnValue=iReturnValue-30;
    return iReturnValue;
}
function hideToolTip()
{
	document.getElementById('bubble_tooltip').style.display = 'none';
	
}
function MyAuditLogViewer(URL)
{
    window.open(URL,"","width=600,height=450,toolbar=no,titlebar=no,statusbar=no,resizable=yes,location=no,status=no,scrollbars=yes");
}
function ValiDateAuditLogData()
{
    var PnlMessage= document.getElementById('PnlMessage');
    
    if(!confirm('Are you sure to Delete the Record?'))
    {
        return false;
    } 
    if (PnlMessage != null)
    {
      PnlMessage.style.display = 'none';
    }
    return true;
}
function CloseAuditLogData()
{
   window.close();
}
function ValidateScoreCardTextBox(PostBackURL)
{
    var TextBoxObjectValue = document.getElementById(getElementByID('_TitleEditPoint2'));		 
    if(TextBoxObjectValue.value == "")
    {		
        alert("Enter Title ");        
        TextBoxObjectValue.focus(); 
        return false;        
    }     
    window.document.forms[0].action=PostBackURL;       
    return true;
}

function EnterKeyPress(button)
{
   if(event.which || event.keyCode)
    {
      if ((event.which == 13) || (event.keyCode == 13)) 
        {
          if(button!=null)
           {           
            var MyButton=document.getElementById(getElementByID("_"+button));	          
            MyButton.click();
           }
          return false;
        }
    }
   else 
   {
     return true;
   }
}

///////////////////////////////////Script block for disabling Button having validation ////////////////////////////////////
var CurrentBtnId;
function BtnToDisabled(BtnID)
{
  var flag=true;
  var BtnText=document.getElementById(getElementByID(BtnID)).value;
     switch(BtnText)
        {
        
            case 'Save':
               if(ValidateImage())              
                     BtnText='Saving';                  
                  else
                      flag=false;
              break;
            
            case 'Update':
            
              BtnText='Updating';
              break;
            
                     
        }
    
    if(flag)
       {
        CurrentBtnId=BtnID;
        setTimeout("DisableBtn()",1);
       } 
    else
    document.getElementById(getElementByID(BtnID)).disabled=false;
    
    return flag;


}

///this fuction is called by server side button on a event of OnClientClick (if the page validation on it then aspnet_validation.js is generated which initialise the Page_IsValid property by this we can check page validation but it activate after 1 millisecond so we use setTimeout method for time delay.) 
function ButtonWithValidationDisabled(BtnID)
{
    if (this.Page_Validators != undefined && this.Page_Validators != null) 
    { 
        //Looping through the whole validation collection. 
        for(var i=0; i<this.Page_Validators.length; i++) 
        { 
            ValidatorEnable(Page_Validators[i],true); 
           
        } 
    }
    var flag=true;
    if(Page_ClientValidate()) 
    {
       flag=BtnToDisabled(BtnID);   
    }       
    else 
    { 
        flag=false;
    }

   return flag;

}

function Page_ClientValidate() {
Page_InvalidControlToBeFocused = null;
if (typeof(Page_Validators) == "undefined") {
return true;
}
var i;
for (i = 0; i < Page_Validators.length; i++) {
ValidatorValidate(Page_Validators[i], null);
}
ValidatorUpdateIsValid();

Page_BlockSubmit = !Page_IsValid;
return Page_IsValid;
}

// this fuction is called after 1 millisecond this is done because in this duration button event subscribe the deligate.
    function DisableBtn()
     {
          document.getElementById(getElementByID(CurrentBtnId)).disabled=true;        
     }



///////////////////////////////////Script block for disabling Button having no validation ////////////////////////////////////
var btnID=null;


function ButtonWithoutValidationDisabled(BtnID)
   {   
           try
           {
            if (Page_Validators != undefined && Page_Validators != null) 
            { 
                //Looping through the whole validation collection. 
                for(var i=0; i<Page_Validators.length; i++) 
                { 
                    ValidatorEnable(Page_Validators[i],false);               
                } 
            }
            if (typeof(Page_ClientValidate) == 'function')
               Page_ClientValidate();
          }
          catch(e){}
          
          
      
    btnID=document.getElementById(getElementByID(BtnID));
    
    if(btnID==null)
         btnID=document.getElementById(BtnID);
        
    var flag=false;
    var BtnText=btnID.value;
        switch(BtnText)
            {              
                case 'Edit':
                  BtnText='Edit';
                  break;
                  
                case 'Cancel':
                  BtnText='Canceling';
                  break;
                  
                case 'Search':
                  if(isDateValidate())              
                     BtnText='Searching';                  
                  else
                      flag=true;
                  break;
                
               case 'Clear':
                  BtnText='Clearing';
                  break;
                  
                  

            }
            btnID.value=BtnText;
            if(!flag)
            {
              setTimeout("Disabled();",1);
              if(BtnText=="Archive" || BtnText=="Un-Archive" || BtnText=="Activate" || BtnText=="Deactivate" || BtnText=="Associate")
              {
                CurrentBtnId=BtnID;
                setTimeout("EnableBtn();",1);
              }
              
              return true;
            }
            else
              return false;
     
           
      

    }
    // this fuction is called after 1 millisecond this is done because in this duration button event subscribe the deligate.
    function Disabled()
    {
       
      btnID.disabled=true;
    }
    
    
    function ValidateImage()
    {
        var flag=true;
        var theForm = document.forms[0];
          if (!theForm) 
          {
               theForm = document.aspnetForm;
          }
        for(var x= 0; x < theForm.elements.length; x++)
        {
        
            if(theForm.elements[x].id.indexOf("IMAGE_DOCUMENT_ID") > -1 && theForm.elements[x].type == "file"  )
            {  
              var dtStr=theForm.elements[x];
              flag= IsValidateImage(dtStr,false);
              if(!flag)
              { 
                break;
              }
            }
       }
      return flag;
    }
function IsValidateImage(formObj,Ismandatory)
{  
      try
      { 
      var flag=false;
        formObj= formObj.id;
         var filename = document.getElementById(formObj).value;
        if(filename == "" && !Ismandatory)
        return true;
        
               if (((filename.split(":\\").length >1) ||(filename.split(":/").length >1)  ) && (filename.split(".").length >1) )
                {
                                var myFiles=filename.split('.');
                          var cnt=parseInt(myFiles.length)-1;
                          var fileext =myFiles[cnt].toLowerCase();
                          
                              // Check file extenstion
                              if (fileext != 'gif' && fileext != 'jpeg' && fileext != 'jpg' && fileext != 'bmp' && fileext != 'png')
                              {
                                     alert ('You can only upload gif, jpg, jpeg, png and bmp images!');
                            document.getElementById(formObj).focus();
                                     flag= false;
                              }
                              else
                              {                         
                                    flag= true;
                              }
                         
                }
                else
                {
                   
                          alert ('You must select a valid file.');
                          document.getElementById(formObj).focus();
                          flag= false;
                }
        
          return flag;
          }
          catch(e)
        { 
        }
 }

    
    //////////////////////end of disabling page having no validation//////////////////////

    
    //Function used to validate DataTime 
function isDateValidate()
{
 var flag=true;
 var theForm = document.forms[0];
      if (!theForm) 
      {
           theForm = document.aspnetForm;
      }
    for(var x= 0; x < theForm.elements.length; x++)
    {
    
        if(theForm.elements[x].id.indexOf("DATE") > -1 && theForm.elements[x].type == "text"  )
        {  
          var dtStr=theForm.elements[x];
          flag= isDate(dtStr);
          if(!flag)
          { 
            break;
          }
        }
   }
  return flag;
}
   ////get Query string value
    function GetqueryStr(Key)
     {
        hu = window.location.search.substring(1);
        gy = hu.split("&");
        for (i=0;i<gy.length;i++)
         {
        ft = gy[i].split("=");
            if (ft[0] == Key)
            {
            return ft[1];
            }
        }
    }
    
    function DisabledEffect()
    {
      
        var myMainDiv;
        var myProgressDiv;
        var myDoc;
        if(top!=null)
        {
          myDoc=top.document;
        }
        else
        {
          myDoc=document;
        }
        myMainDiv=myDoc.createElement("div");
        myMainDiv.id="MainDiv";
        myProgressDiv=myDoc.createElement("div");
        myProgressDiv.id="ProgressBar";
        myMainDiv.style.display='block';
        myMainDiv.style.position='absolute';
        myMainDiv.style.top='0px';
        myMainDiv.style.left='0px';
        
        if(top!=null)
        {
          myMainDiv.style.width= top.document.body.offsetWidth;
          myMainDiv.style.height= top.document.body.offsetHeight;
        }
        else
        {
          myMainDiv.style.width= document.body.offsetWidth;
          myMainDiv.style.height= document.body.offsetHeight;
        }
        myMainDiv.style.cursor="not-allowed";
        myMainDiv.style.backgroundColor = "rgb(0,0,0)";
        myMainDiv.style.filter = "alpha(opacity=60)";
        myMainDiv.style.opacity = "0.6";
        myProgressDiv.style.display="block";
       //var pos=getCursorPosition();
        myDoc.body.appendChild(myMainDiv);
        myDoc.body.appendChild(myProgressDiv);
        myProgressDiv.className="waitProgress";
	    myProgressDiv.style.left =  (myDoc.body.clientWidth - myProgressDiv.offsetWidth) / 2 +"px";
	    myProgressDiv.style.top = (myDoc.body.clientHeight - myProgressDiv.offsetHeight) / 2 +"px";
	    myProgressDiv.innerHTML="Loading...";
    }
     function  EnabledEffect()
    {
        var myMainDiv;
        var myProgressDiv;
        if(top!=null)
        {
          myMainDiv=top.document.getElementById('MainDiv');
          myProgressDiv=top.document.getElementById('ProgressBar');
        }
        else
        {
          myMainDiv=document.getElementById('MainDiv');
          myProgressDiv=document.getElementById('ProgressBar');
        }
        myProgressDiv.style.display="none";
        myMainDiv.style.display='none';
        myMainDiv.style.top='0px';
        myMainDiv.style.left='0px';
        myMainDiv.style.width= '0px';
        myMainDiv.style.height= '0px';
    
    }
    
     function ClosePopUpWithParentRefresh()
    {
       DisabledEffect();
      if(top.location.href.indexOf("#")>-1)
      top.location.href=top.location.href.replace("#","");
      else
       top.location.href=top.location.href;
       
        CloseModal();   
       
	    return false;
  	   
	    
    }
    function CloseChildPopUpWithParentRefresh()
    {
      if(location.href.indexOf("#")>-1)
      parent.location.href=parent.location.href.replace("#","");
      else
       parent.location.href=parent.location.href;
        CloseModal();   
	    return false;
    }
     function CloseChildPopUpWithOutParentRefresh()
    {
      if(location.href.indexOf("#")>-1)
      parent.location.href=parent.location.href.replace("#","");
      CloseModal();   
	    return false;
    }
    
    function PageRefresh()
    {
       if (self != top) 
        {
            if (window.location.href.replace)
            {
              //parent.location.reload();
              top.location.replace(parent.location.href);  
            }
            else
            {
               top.location.href=self.document.href;
            }            
        }
         
    }
    function ClosePopUpWithOutParentRefresh()
    { 
         
          SetfocusOnPoPupClose();
          CloseModal();   
          return false;
            
    }
    function CloseModal()
    {     
         try
         {
         
           var MainDiv=parent.document.getElementById("MyOuterDiv");
           var NewMainDiv=parent.document.getElementById("ParentMyOuterDiv");  
           
           var NewModalDiv=parent.document.getElementById("Parentdgbox");
           var NewParentDiv=parent.document.getElementById("ParentContentDiv");
           var ModalDiv=parent.document.getElementById("dgbox");
           var ParentDiv=parent.document.getElementById("ContentDiv");
           if(NewModalDiv!=null)
           {
                NewMainDiv.removeChild(NewParentDiv);
                NewMainDiv.removeChild(NewModalDiv);
           }
           else
           {
                MainDiv.removeChild(ParentDiv);
                MainDiv.removeChild(ModalDiv);
           }
         
          
          
         }
         catch(e){}
    
    }
    /////end Close Modal Popup//////
        
          //open modal popup
     var MyIframe = null;
    function ShowIframe(url,windowHeight,windowWidth,windowTitle)
     {
   
	  MyIframe = new IframeDailog();
	 MyIframe.WebSouceURL=url;
	 MyIframe.IframeID='Iframe_Save';
	 MyIframe.IframeTitle=windowTitle;
	 MyIframe.WindowHeight=windowHeight;
	 MyIframe.WindowWidth=windowWidth;
	 MyIframe.Show();
     }
     //////end //////////
    function OpenModal(ModalUrl,windowTitle,windowWidth,windowHeight)
    {
           var MyWindowHeight;
           var MyWindowWidth ;
            if(windowHeight==null)
               MyWindowHeight='500';
            if(windowWidth==null)
              MyWindowWidth='550';
       
                    
             var MyIframe = new IframeDailog();
	         MyIframe.WebSouceURL=ModalUrl;
	         MyIframe.IframeID='Iframe_Save';
	         MyIframe.IframeTitle=windowTitle;
             MyIframe.WindowHeight=windowHeight;
	         MyIframe.WindowWidth=windowWidth;
	         MyIframe.Show();
          
              
    }
    
    //method to get cursor position.
function getCursorPosition() { var cursor = {xAxis:250, yAxis:100};
   try
   {

         e = e || window.event;
        if (e.pageX || e.pageY) {
            cursor.xAxis = e.pageX;
            cursor.yAxis = e.pageY;
        } 
        else {
            var de = document.documentElement;
            var b = document.body;
            cursor.xAxis = e.clientX + 
                (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
            cursor.yAxis = e.clientY + 
                (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
        }
   
    }
    catch(e)
    {
   
     return cursor;
    }
    return cursor;
}



// CDC and GHG Enhancenment
function GetGHGInventoryName(MyCurrentValue,MyDropDownControl)
{ 

      var MyParentControlValue;
      var ClientID;
      
       if(document.getElementById(getElementByID('MyHiddenControlClientID'))!=null)
      {
         ClientID=document.getElementById(getElementByID('MyHiddenControlClientID')).value; 
          
      }
      
    
	  var val=MyCurrentValue;
	  MyCurrentDropDownControlID=getElementByID(MyDropDownControl);
	       
	    xmlHttp=GetXmlHttpObject()
	    if (xmlHttp==null)
	    {
		     alert ("Browser does not support HTTP Request")
		     return
	    } 
	    var url="ReturnGHGInventoryNames.ashx";
	    url=url+"?val="+val;		
	    url=url+"&sid="+Math.random();
	    url=url+"&ClientID="+ClientID;	
	    if(MyDropDownControl=='DropDownListGHGInventory2')
	       url=url+"&IsScope=Scope";			
	    xmlHttp.onreadystatechange=DropDownStateChanged;
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);


        if(MyDropDownControl=='DropDownListGHGInventory1')
        {    
              SetDropDownValueToHiddenControl("",'MyHiddenControlGHGInventory2');
              SetDropDownValueToHiddenControl("",'MyHiddenControlGHGInventory3');
              SetDropDownValueToHiddenControl("",'MyHiddenControlGHGInventory4');
              ResetDropDown('DropDownListGHGInventory2') ; 
              ResetDropDown('DropDownListGHGInventory3') ;
              ResetDropDown('DropDownListGHGInventory4') ;      
        }
        if(MyDropDownControl=='DropDownListGHGInventory2')
        {    
              SetDropDownValueToHiddenControl("",'MyHiddenControlGHGInventory2');
              SetDropDownValueToHiddenControl("",'MyHiddenControlGHGInventory3');
              SetDropDownValueToHiddenControl("",'MyHiddenControlGHGInventory4'); 
              ResetDropDown('DropDownListGHGInventory3') ;
              ResetDropDown('DropDownListGHGInventory4') ;      
        }
        if(MyDropDownControl=='DropDownListGHGInventory3')
        {              
              SetDropDownValueToHiddenControl(val,'MyHiddenControlGHGInventory2');
              SetDropDownValueToHiddenControl("",'MyHiddenControlGHGInventory3');
              SetDropDownValueToHiddenControl("",'MyHiddenControlGHGInventory4'); 
              ResetDropDown('DropDownListGHGInventory4') ;    
        }
        if(MyDropDownControl=='DropDownListGHGInventory4')
        {         
             SetDropDownValueToHiddenControl(val,'MyHiddenControlGHGInventory3');   
        }

      SetEmissionFactorFields();

}
// CDC and GHG Enhancenment
function GetShowCaseFeatureName(MyCurrentValue,MyDropDownControl)
{ 
      var RecID=  document.location.href.split('?')[1].split('&')[5].split('=')[1];
        
      var MyParentControlValue;
      var ClientID;      
      if(document.getElementById(getElementByID('MyHiddenControlClientID'))!=null)
      {
         ClientID=document.getElementById(getElementByID('MyHiddenControlClientID')).value; 
      }     
	  var val=MyCurrentValue;
	  MyCurrentDropDownControlID=getElementByID(MyDropDownControl);
	       
	    xmlHttp=GetXmlHttpObject()
	    if (xmlHttp==null)
	    {
		     alert ("Browser does not support HTTP Request")
		     return
	    } 
	    var url="ReturnShowCaseFeatureName.ashx";
	    url=url+"?val="+val;		
	    url=url+"&sid="+Math.random();
	    url=url+"&ClientID="+ClientID;
	    url=url+"&RecID="+RecID;			    
	    xmlHttp.onreadystatechange=DropDownStateChanged;
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);
      
        if(MyDropDownControl=='DropDownListGHGInventory2')
        {    
              SetDropDownValueToHiddenControl("",'MyHiddenControlGHGInventory2');
              SetDropDownValueToHiddenControl("",'MyHiddenControlGHGInventory3');
              SetDropDownValueToHiddenControl("",'MyHiddenControlGHGInventory4'); 
              ResetDropDown('DropDownListGHGInventory3') ;
              ResetDropDown('DropDownListGHGInventory4') ;      
        }
   
}
function SetEmissionFactorFields()
{
      var EmissionFactorText =document.getElementById(getElementByID('TextBoxEmissionFactor')).value=''; 

      var EmissionFactorValue = document.getElementById(getElementByID('HiddenEmissionFactor')).value='';
}

function ResetDropDown(MyDropDownControl)
{
    selectbox=document.getElementById(getElementByID(MyDropDownControl));
    
    var i;
    for(i=selectbox.options.length-1;i>=0;i--)
    {
          selectbox.remove(i);   
    }
     addOption(selectbox,'--Select--','');
      
}
function addOption(selectbox,text,value )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}

 /////////////////////////////////////////end of disabling page having no validation/////////////////////////////////////////////////////////
function setIframesrc(myURL,IframeId)
{ 
   document.getElementById(getElementByID('inlineframe')).src=myURL+"&"+Math.random();
   return false;
}

function setIframesrc(myURL,IframeId)
    {
      ShowIframe();
      document.getElementById(getElementByID('inlineframe')).src=myURL+"&"+Math.random();
      return false;
    }

    
   function ShowIframe()
    {
        if(document.getElementById('td_inventryiframe')!=null)
        {
           document.getElementById(getElementByID('inlineframe')).style.visibility="visible";
           document.getElementById('btn_Inventry').style.display="none";
        }
    }
    function HideIframe(myId)
    { 
       if(document.getElementById('td_inventryiframe')!=null)
        {
            document.getElementById(getElementByID('inlineframe')).style.visibility="hidden";
            document.getElementById('btn_Inventry').style.display="block";
         }   
    }

function RefreshPage()
{


if(top!=null)
top.document.location.reload();
}
function RefreshTree() 
{ 
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 {     
		  //if(xmlHttp.responseText!="") return false    
		  var strHTTP=xmlHttp.responseText;
		  var defaultElement=top.document.getElementById('myscript');
            var myElement= defaultElement.cloneNode(true);
            defaultElement.parentNode.replaceChild(myElement,defaultElement);
		  myElement.innerHTML=strHTTP;
		 
		  if(strHTTP=="Not Found")
		  {  
				alert("Data Not found"); 
		  }
		  else
		  {
		    
		        
		  }
	 } 
}


// SetDropDownFactorGWPTable
function SetDropDownFactorGWPTable(MyCurrentValue,MyDropDownControl)
{ 
  var GWPTable=document.getElementById(getElementByID(MyDropDownControl));
  if(MyCurrentValue=="ECO2")
  {
    GWPTable.value="";
    GWPTable.disabled=true;
    
  }
  else
   GWPTable.disabled=false;

}




//Set Search TextBox and DropDown to null
function ClearSearchForm()
{
  var element;
  var DropCount=0;
  for (var i = 0; i < document.forms[0].elements.length; i++)
  {
    element = document.forms[0].elements[i];
    switch (element.type)
    {
      case 'select-one':
        DropCount++;
        break;
     
    }
  }
  for (var i = 0; i < document.forms[0].elements.length; i++)
  {
    element = document.forms[0].elements[i];
    switch (element.type)
    {
     case 'text':
        element.value="";
        break;
      case 'select-one':
        if(DropCount>0)
        {
        element.value="";
        DropCount--;
        }
        break;
      case 'checkbox':
        element.checked=false;
        break;
     
    }
  }
     var objxmlHttpLookup = new XMLHttpObject();   //Object creation
     var orginalURL = document.location.href;
     var urlQueryString = document.location.href.split('?');
     var QsArray = urlQueryString[1].split('&');
     
     objxmlHttpLookup.WebPage = "WOWSpace.aspx?AppType=WOW.ClearSearch&" + urlQueryString[1];
     objxmlHttpLookup.Async=false;
     objxmlHttpLookup.Querystring='';
     objxmlHttpLookup.Method = "POST";    //Setting Method 
     objxmlHttpLookup.Init();   //Initiate the AjaxCal
     var Unitvalue=objxmlHttpLookup.ResponseData();
     document.location.href = document.location.href;
}

function ShowPopUpWindow(url)
{
var myurl = url.split('&');

var mysecondurl = myurl[0].split('/');
var myfinalurl = mysecondurl[mysecondurl.length-1];
window.open(myfinalurl);
}


function ValidateDataPointReading(Textbox , Reading)
{

    var valTime = new RegExp("^([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])$");
    if (Reading.match(valTime) == null) {
         alert("Please enter correct time format (hh:mm:ss)");
         Textbox.focus();
         return false; 
      } 

    return true; 

}
function ValidateTaskTime(Textbox , Reading)
{

        var valTime = new RegExp("^([0-1][0-9]|[2][0-3]):([0-5][0-9])$");
        if (Reading.length > 0) 
        {

        if (Reading.match(valTime) == null) {
         alert("Please enter correct time format (hh:mm)\nMaximum value allowed is 23:59");
   
         return false; 
      } 
       
    
      }
      
    return true;

}
function GetServiceDataItems(MyClientID,MyDropDownControl)
{ 
       var ClientID;
       var val;
       if(getElementByID('MyHiddenControlClientID',true)!=null)
       {         
          ClientID=MyClientID;
          getElementByID('MyHiddenControlClientID',true).value=MyClientID;          
       }
      
	   //MyCurrentDropDownControlID=getElementByID(MyDropDownControl,true);
	   MyCurrentDropDownControlID="ctl00_MyContantPlaceHolder_"+MyDropDownControl;
	    xmlHttp=GetXmlHttpObject()
	    if (xmlHttp==null)
	    {
		     alert ("Browser does not support HTTP Request")
		     return
	    } 
	    var url="ReturnDataClassNames.ashx";
	    url=url+"?val=service";						
	    url=url+"&sid="+Math.random();
	    url=url+"&ClientID="+MyClientID;
	    xmlHttp.onreadystatechange=DropDownNewServicePostStateChanged;
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);	  
	  
}

function DropDownNewServicePostStateChanged()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 {     
		  //if(xmlHttp.responseText!="") return false    
		  var strHTTP=xmlHttp.responseText;
		  if(strHTTP=="Not Found")
		  {  
				alert("Data Not found"); 
		  }
		  else
		  {
		    
		        BindNewServiceDropDown(MyCurrentDropDownControlID,strHTTP);		        
		        ClosePopUpWithOutParentRefresh();
		      
		  }
	 } 

}

function BindNewServiceDropDown(CurrentControlID,StringArray)
{
       var tempArray = new Array();
       tempArray = StringArray.split('~`');
       var ii=0;     
       var jj=0;     
       var len = parent.document.getElementById(CurrentControlID).options.length;
       for (ii=0; ii<len; ii++) 
       {              
              parent.document.getElementById(CurrentControlID).remove(0); //It is 0 (zero) intentionally 
       }
       if(tempArray.length>1)
       {              
              parent.document.getElementById(CurrentControlID).options[jj]=new Option('--Select--','');
              for(ii=0;ii<tempArray.length;ii++)
              {   
                        jj++;           
                        var SecondtempArray = new Array();
                        SecondtempArray = tempArray[ii].split('`~');                        
                        parent.document.getElementById(CurrentControlID).options[jj]=new Option(SecondtempArray[1],SecondtempArray[0]);
              }
       }
       else
       {              
              parent.document.getElementById(CurrentControlID).options[0]=new Option('--Select--','');
              if(StringArray.length > 5)
              { 
                        var SecondtempArray = new Array();
                        SecondtempArray = StringArray.split('`~');
                        //top.document.getElementById(getElementByID(CurrentControlID,true)).options[1]=new Option(SecondtempArray[1],SecondtempArray[0]);
                        parent.document.getElementById(CurrentControlID).options[1]=new Option(SecondtempArray[1],SecondtempArray[0]);
              }
       }
       
       parent.document.getElementById(CurrentControlID).focus();  
       parent.document.getElementById(CurrentControlID).selectedvalue='';
       

}

function GetServiceDataClassItems(MyClientID,MyDropDownControl,MyParentControl)
{ 
      var MyParentControlValue;
      var ClientID;
      var val;
      if(getElementByID('MyHiddenControlClientID',true)!=null)
      {     
         ClientID=MyClientID;
         getElementByID('MyHiddenControlClientID',true).value=MyClientID;          
      }
      if(MyParentControl!=null)      
      {
          val=top.document.getElementById(getElementByID(MyParentControl,true)).value;           
      }
      
	  MyCurrentDropDownControlID=getElementByID(MyDropDownControl,true);
	       
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			 alert ("Browser does not support HTTP Request")
			 return
		} 
		var url="ReturnDataClassNames.ashx";
		url=url+"?val="+val;						
		url=url+"&sid="+Math.random();
		url=url+"&ClientID="+ClientID;
		if(MyParentControlValue!=null && MyParentControlValue!="")
		{
		    url=url+"&parentId="+MyParentControlValue;
		}
		xmlHttp.onreadystatechange=DropDownPostStateChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	 
}


function DropDownPostStateChanged() 
{ 
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 {     
		  //if(xmlHttp.responseText!="") return false    
		  var strHTTP=xmlHttp.responseText;
		  if(strHTTP=="Not Found")
		  {  
				alert("Data Not found"); 
		  }
		  else
		  {
		    
		        BindPostDropDown(MyCurrentDropDownControlID,strHTTP);  		        
		        SetfocusOnPoPupClose();
		        ClosePopUpWithOutParentRefresh();
		       
		  }
	 } 
}

 
   function SetfocusOnPoPupClose()
{    
    if(getElementId('TextBoxDPLName',true)!=null)
        getElementId('TextBoxDPLName',true).focus();
    if(getElementId('TextBoxDataPointName',true)!=null)
        getElementId('TextBoxDataPointName',true).focus();
    if(getElementId('TextBoxCommonDataName',true)!=null)
        getElementId('TextBoxCommonDataName',true).focus();
     if(getElementId('txtNo',true)!=null)
        getElementId('txtNo',true).focus();
     if(getElementId('SUBJECT',true)!=null)
        getElementId('SUBJECT',true).focus();   
     if(getElementId('Source',true)!=null)
    getElementId('Source',true).focus();
    if(getElementId('BtnAddMember',true)!=null)
        getElementId('BtnAddMember',true).disabled=false;        
    if(document.getElementById('ctl00_MyContantPlaceHolder_TextBoxDashboardTitle')!=null)
        document.getElementById('ctl00_MyContantPlaceHolder_TextBoxDashboardTitle').focus();
    if(document.getElementById('ctl00_MyContantPlaceHolder_BASICSEARCHpro_inmd_meterdatapoint.DATAPOINT_NAME')!=null)
    document.getElementById('ctl00_MyContantPlaceHolder_BASICSEARCHpro_inmd_meterdatapoint.DATAPOINT_NAME').focus();
    
    if(document.getElementById("frm_AddDashboard")!=null)
    {
      if(document.getElementById("frm_AddDashboard").contentWindow.document!=null)
      {
        var myContainer=document.getElementById("frm_AddDashboard").contentWindow.document;
        if(myContainer.getElementById('ctl00_MyContantPlaceHolder_TextBoxDashboardTitle')!=null)
           myContainer.getElementById('ctl00_MyContantPlaceHolder_TextBoxDashboardTitle').focus();
      }
    }
}

function BindPostDropDown(CurrentControlID,StringArray)
{
       var tempArray = new Array();
       tempArray = StringArray.split('~`');
       var ii=0;     
       var jj=0;       
       var len = top.document.getElementById(getElementByID(CurrentControlID,true)).options.length;
       for (ii=0; ii<len; ii++) {
              top.document.getElementById(getElementByID(CurrentControlID,true)).remove(0); //It is 0 (zero) intentionally 
       }
       if(tempArray.length>1)
       {
              top.document.getElementById(getElementByID(CurrentControlID,true)).options[jj]=new Option('--Select--','');
              for(ii=0;ii<tempArray.length;ii++)
              {   
                        jj++;           
                        var SecondtempArray = new Array();
                        SecondtempArray = tempArray[ii].split('`~');
                        top.document.getElementById(getElementByID(CurrentControlID,true)).options[jj]=new Option(SecondtempArray[1],SecondtempArray[0]);
              }
       }
       else
       {
                top.document.getElementById(getElementByID(CurrentControlID,true)).options[0]=new Option('--Select--','');
              if(StringArray.length > 5)
              { 
                        var SecondtempArray = new Array();
                        SecondtempArray = StringArray.split('`~');
                        
                        top.document.getElementById(getElementByID(CurrentControlID,true)).options[1]=new Option(SecondtempArray[1],SecondtempArray[0]);
              }
       }
       top.document.getElementById(getElementByID(CurrentControlID,true)).focus();  
       top.document.getElementById(getElementByID(CurrentControlID,true)).selectedvalue=''; 
       

}

function OpenChartingEngineImage(url , ImageID)
{
 window.open(url+"&IMAGEID="+ ImageID,"ChartViewer","width=800,height=600");
 return false;
}

function IsValidateEcologImage(formObj,BtnID,Ismandatory)
{  
      try
      { 
      var flag=false;
        formObj= getElementByID(formObj);
         var filename = document.getElementById(formObj).value;
        if(filename == "" && !Ismandatory)
        return true;
        
               if (((filename.split(":\\").length >1) ||(filename.split(":/").length >1)  ) && (filename.split(".").length >1) )
                {
                                var myFiles=filename.split('.');
                          var cnt=parseInt(myFiles.length)-1;
                          var fileext =myFiles[cnt].toLowerCase();
                          
                              // Check file extenstion
                              if (fileext != 'gif' && fileext != 'jpeg' && fileext != 'jpg' && fileext != 'bmp' && fileext != 'png')
                              {
                                     alert ('You can only upload gif, jpg, jpeg, png and bmp images!');
                            document.getElementById(formObj).focus();
                                     flag= false;
                                     CurrentBtnId=BtnID;
                                     setTimeout("EnableBtn()",1);                                     
                              }
                              else
                              {                         
                                    flag= true;
                              }
                         
                }
                else
                {
                   
                          alert ('You must select a valid file.');
                          document.getElementById(formObj).focus();
                          flag= false;
                          CurrentBtnId=BtnID;
                          setTimeout("EnableBtn()",1);
                }
        
          return flag;
          }
          catch(e)
        { 
        }
 }
 function EnableBtn()
     {
          document.getElementById(getElementByID(CurrentBtnId)).disabled=false;        
     }
     
     
     
var viewLastSelectedIndex;
function GridFilterListOnChange()
{
    viewSelectedIndex = document.getElementById(getElementByID('GridFilter_GHGManual')).value ;
    
    if(viewSelectedIndex == -1)
    {
     
   if(viewLastSelectedIndex==null || viewLastSelectedIndex==''|| viewLastSelectedIndex=='undefined')
    {
    viewLastSelectedIndex = LastSelectedValue('','');
   
    }
    document.getElementById(getElementByID('GridFilter_GHGManual')).value = viewLastSelectedIndex;
    
    return false;
      
    }
    
    var elements =  window.document.forms[0].getElementsByTagName("INPUT"); 
    
    for(i=0; i<elements.length;i++) 
        {
	         
	       if(elements[i].type=='checkbox' && elements[i].id.indexOf('ChkSELECT')>=0 )				       
	       {
		          elements[i].checked = false;
	       }		 
                  
        }    
    
    viewLastSelectedIndex = viewSelectedIndex;
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm._doPostBack(getElementByID('GridFilter_GHGManual'), '');

    
return true;
}

var viewLastSelectedIndex;
function GridFilterOnChange(grdID)
{
    viewSelectedIndex = document.getElementById(getElementByID(grdID)).value ;
    
    if(viewSelectedIndex == -1)
    {
     
   if(viewLastSelectedIndex==null || viewLastSelectedIndex==''|| viewLastSelectedIndex=='undefined')
    {
    viewLastSelectedIndex = LastSelectedValue('','');
   
    }
    document.getElementById(getElementByID(grdID)).value = viewLastSelectedIndex;
    
    return false;
      
    }
    
    var elements =  window.document.forms[0].getElementsByTagName("INPUT"); 
    
    for(i=0; i<elements.length;i++) 
        {
	         
	       if(elements[i].type=='checkbox' && elements[i].id.indexOf('ChkSELECT')>=0 )				       
	       {
		          elements[i].checked = false;
	       }		 
                  
        } 
        
    viewLastSelectedIndex = viewSelectedIndex;
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm._doPostBack(getElementByID(grdID), '');

    
return true;
}

function copy(txtID)
{
   
    var MyTextBox=document.getElementById(getElementByID(txtID));
    if(MyTextBox.value=="")
        alert ('URL is empty');
    else
     {
        MyTextBox.focus();
        MyTextBox.select();
        CopiedTxt=document.selection.createRange();
        CopiedTxt.execCommand("Copy");
        MyTextBox.focus();
     }

}


function CheckAllChildDPPermission(parentChk,XGridName) 
    {
       
       
        var elements =  window.document.forms[0].getElementsByTagName("INPUT"); 
      
        for(i=0; i<elements.length;i++) 
        {
	          if(elements[i].type=='checkbox')
	          {
			        if(parentChk.checked == true) 
			        {  
				         if(elements[i].type=='checkbox'&& elements[i].id.indexOf('ChkPERMISSIONSELECT')>=0 && elements[i].id.indexOf(XGridName)>=0)
				         {
					          elements[i].checked = true;
				         }       
			   }
			   else 
			   {
			       if(elements[i].type=='checkbox' && elements[i].id.indexOf('ChkPERMISSIONSELECT')>=0 && elements[i].id.indexOf(XGridName)>=0)
			       {
				          elements[i].checked = false;
			       }
			   } 
            }      
        }    
    }
    
    
    
function UnCheckParentDPPermission(CurrentChkBox,ParentGridView,ParentCheckBox,Delimiter) 
    {                        
        var ParentControl=getElementId(ParentCheckBox);
        var TargetBaseControl ;//= getElementId(ParentGridView);    
        var elementsAll=  document.getElementsByTagName("body")[0].getElementsByTagName("*");
		 for(i=0; i<elementsAll.length;i++) 
			 {
				  if(elementsAll[i].id.indexOf(ParentGridView)>=0)
				  {
				      if(elementsAll[i].id.indexOf('GridFilter')<0)
				      {    					  
						   TargetBaseControl = elementsAll[i];
						    break;	 
				      }
				      
				  }
			 }
        var elements =  TargetBaseControl.getElementsByTagName("INPUT"); 
        var count=0;
        var chkSelectCount=0;
        if(CurrentChkBox.type=='checkbox')
        {
            if(ParentControl.checked == true) 
             {
		         if(CurrentChkBox.checked == false)
		         {
			          ParentControl.checked = false;
		         }   
		     }
			else
			{
			     
			     if(CurrentChkBox.checked == true)
		         {
		            for(i=0; i<elements.length;i++) 
                     {
		                if(elements[i].type=='checkbox' && elements[i].id.indexOf('ChkPERMISSIONSELECT')>=0)
		                {
		                    chkSelectCount=chkSelectCount+1;
		                    if(elements[i].checked == true)
		                    {
		                        count=count+1;
		                    }
		                }
		             }
		            CurrentChkBox.checked = true;
		            if(count==chkSelectCount)
		            {
		                ParentControl.checked = true;
		            }
		         }   
			}
		}
    }
    
    
    
    function MassSelectionDPPermission(MyButton,PostBackUrl,PostBackDelimiter,XGridName,HidenVieldRecID)
        {
             MyButton.disabled=false;
			 var ArrRecordCount=0;
			 var HidenVieldRecIDControl=null;
			 var TargetBaseControl='';
			 var elementsAll=  document.getElementsByTagName("body")[0].getElementsByTagName("*");
			 
			 for(i=0; i<elementsAll.length;i++) 
				 {
					  if(elementsAll[i].id.indexOf(XGridName)>=0)
					  {
					      if(elementsAll[i].id.indexOf('GridFilter')<0)
					      {    					  
							   TargetBaseControl = elementsAll[i];
							    break;	 
					      }
					      
					  }
				 }
	 			var check= TargetBaseControl.getElementsByTagName("INPUT");
                for (j=0;j<check.length;j++)
                     {
                         if(check[j].type=='checkbox' && check[j].checked == true &&  (check[j].id.indexOf("ChkPERMISSIONSELECT")!=-1))
                           {
								if(ArrRecordCount==0)
								   {								
										ArrRecordCount=1;		
										break;					 
								   }
						   } 
					}
											      

	          if(ArrRecordCount==0)
				 {
					  alert('No item is selected ! Please select item.');
					  
					  return false;
				 }
			  else
				 {
			          if(confirm('Are you sure to '+MyButton.value+' the record?'))
					  {
						
	                  }
			        else
			        {
				        return false;
			        }
		        }			
				
           }
           
        function MassSelectionDPUpdatePermission(MyButton,PostBackUrl,PostBackDelimiter,XGridName,HidenVieldRecID)
        {
             MyButton.disabled=false;
			 var ArrRecordCount=0;
			 var HidenVieldRecIDControl=null;
			 var TargetBaseControl='';
			 var elementsAll=  document.getElementsByTagName("body")[0].getElementsByTagName("*");
			 for(i=0; i<elementsAll.length;i++) 
				 {
					  if(elementsAll[i].id.indexOf(XGridName)>=0)
					  {
					      if(elementsAll[i].id.indexOf('GridFilter')<0)
					      {    					  
							   TargetBaseControl = elementsAll[i];
							    break;	 
					      }
					      
					  }
				 }
	 				
			 
			  		var check= TargetBaseControl.getElementsByTagName("INPUT");
                   
                    for (j=0;j<check.length;j++)
                        {
                           
                              if(check[j].type=='checkbox' && check[j].checked == true &&  (check[j].id.indexOf("ChkPERMISSIONSELECT")!=-1))
                                {
								  if(ArrRecordCount==0)
								   {								
										  ArrRecordCount=1;		
										  break;					 
								   }
						        } 
						}
					
	         if(ArrRecordCount==0)
			 {
				  alert('No item is selected ! Please select item.');
				  
				  return false;
			 }
           }
           
           
           
function SetDataPointEnableKioskFlag(ActiveChkBox ,KioskCheckBox)
{

    var ActiveChkBox=getElementId(ActiveChkBox);
    var KioskCheckBox=getElementId(KioskCheckBox);

    if(ActiveChkBox.checked == false) 
    {
        KioskCheckBox.checked=false;
        
    }
    
}


function GetDataPointEnableKioskFlag(ActiveChkBox ,KioskCheckBox)
{

    var ActiveChkBox=getElementId(ActiveChkBox);
    var KioskCheckBox=getElementId(KioskCheckBox);

    if(KioskCheckBox.checked == true) 
    {
        if(ActiveChkBox.checked == false) 
        {      
               
            ActiveChkBox.checked=true;
            
        }
    }
    
}
////////////////////////////////////////////////////////////////////////////

function DoCancel()
    { 
          SetfocusOnPoPupClose();
          CloseModal();   
          return false;
            
    }
  function CheckAllChildInventoy(parentChk,XGridName) 
    {      
       
        var elements =  window.document.forms[0].getElementsByTagName("INPUT"); 
      
        for(i=0; i<elements.length;i++) 
        {
	          if(elements[i].type=='checkbox')
	          {
			        if(parentChk.checked == true) 
			        {  
				         if(elements[i].type=='checkbox'&& elements[i].id.indexOf('ChkSELECT')>=0 && elements[i].id.indexOf(XGridName)>=0)
				         {
					          elements[i].checked = true;
				         }       
			   }
			   else 
			   {
			       if(elements[i].type=='checkbox' && elements[i].id.indexOf('ChkSELECT')>=0 && elements[i].id.indexOf(XGridName)>=0)
			       {
				          elements[i].checked = false;
			       }
			   } 
            }      
        }    
    }



 function UnCheckParentDPInventory(CurrentChkBox,ParentGridView,ParentCheckBox,Delimiter) 
    {                        
        var ParentControl=getElementId(ParentCheckBox);
        var TargetBaseControl ;//= getElementId(ParentGridView);    
        var elementsAll=  document.getElementsByTagName("body")[0].getElementsByTagName("*");
		 for(i=0; i<elementsAll.length;i++) 
			 {
				  if(elementsAll[i].id.indexOf(ParentGridView)>=0)
				  {
				      if(elementsAll[i].id.indexOf('GridFilter')<0)
				      {    					  
						   TargetBaseControl = elementsAll[i];
						    break;	 
				      }
				      
				  }
			 }
        var elements =  TargetBaseControl.getElementsByTagName("INPUT"); 
        var count=0;
        var chkSelectCount=0;
        if(CurrentChkBox.type=='checkbox')
        {
            if(ParentControl.checked == true) 
             {
		         if(CurrentChkBox.checked == false)
		         {
			          ParentControl.checked = false;
		         }   
		     }
			else
			{
			     
			     if(CurrentChkBox.checked == true)
		         {
		            for(i=0; i<elements.length;i++) 
                     {
		                if(elements[i].type=='checkbox' && elements[i].id.indexOf('ChkSELECT')>=0)
		                {
		                    chkSelectCount=chkSelectCount+1;
		                    if(elements[i].checked == true)
		                    {
		                        count=count+1;
		                    }
		                }
		             }
		            CurrentChkBox.checked = true;
		            if(count==chkSelectCount)
		            {
		                ParentControl.checked = true;
		            }
		         }   
			}
		}
    }
    
function DoAddInventory()
{    
    var InventoryID=0;
    var DPLID=0;
    var BuildingID=0;
    var DataClassID=0;
    if(document.getElementById(getElementByID('MyHiddenControlInventoryID'))!=null)
        InventoryID=document.getElementById(getElementByID('MyHiddenControlInventoryID')).value; 
    if(document.getElementById(getElementByID('MyHiddenControlDPLID'))!=null)
         DPLID=document.getElementById(getElementByID('MyHiddenControlDPLID')).value;
    if(document.getElementById(getElementByID('MyHiddenControlBuildingID'))!=null)
         BuildingID=document.getElementById(getElementByID('MyHiddenControlBuildingID')).value;
    if(document.getElementById(getElementByID('MyHiddenControlDataClassID'))!=null)
        DataClassID=document.getElementById(getElementByID('MyHiddenControlDataClassID')).value;
       
   CheckedAll();
   if(InventoryID==0 || DPLID==0)
   {
           alert('Select some inventory before adding.');
           return;
   }
   else
    {
        var PostBackURL="Inventory.aspx?Module=Site.DataToolkit&App=DataToolKit.InventoryAssociation&FormAction=ADDINVGLIST&SESSIONID="+Session_ID+"&CLIENTID="+Client_ID+"&INV_ID="+InventoryID +"&BuildingID="+BuildingID +"&DataClassID="+DataClassID +"&DPL_ID="+DPLID +"&Navigation=false";
        window.document.forms[0].action=PostBackURL;
        window.document.forms[0].submit();
    }
    ///////////////////////////////////////////////////////// 
    
}
function DoAssociate(MyButton)
{
        var InventoryID=document.getElementById(getElementByID('MyHiddenControlInventoryID')).value; 
        var DPLID=document.getElementById(getElementByID('MyHiddenControlDPLID')).value;
        var BuildingID=document.getElementById(getElementByID('MyHiddenControlBuildingID')).value; 
        var DataClassID=document.getElementById(getElementByID('MyHiddenControlDataClassID')).value;
        var gridview=window.frames['inlineframe'].document.getElementById('ListInventoryList');
        var PostBackURL="Inventory.aspx?Module=Site.DataToolkit&App=DataToolKit.InventoryAssociation&FormAction=ASSOCIATEINVGLIST&SESSIONID="+Session_ID+"&CLIENTID="+Client_ID+"&INV_ID="+InventoryID +"&BuildingID="+BuildingID +"&DataClassID="+DataClassID +"&DPL_ID="+DPLID +"&Navigation=false";
        MassSelectionInventory(MyButton,PostBackURL,'-',gridview,"HidenVieldRecID")  
}


function MassSelectionInventory(MyButton,PostBackUrl,PostBackDelimiter,TargetBaseControl,HidenVieldRecID)
{
     MyButton.disabled=false;
	 ArrRecordCount='';
	 var HidenVieldRecIDControl=null;
	 			
	 var elements = TargetBaseControl.getElementsByTagName("span");
      
	 for(i=0; i<elements.length;i++ ) 
		 {
	  		var check= elements[i].getElementsByTagName("INPUT");

            for (j=0;j<check.length;j++)
                {
                   if(elements[i].attributes["PrimaryValue"]!= null && elements[i].attributes["PrimaryValue"].nodeValue!=null) 
			        {
                      if(check[j].type=='checkbox' && check[j].checked == true)
                        {
						  if(ArrRecordCount.length==0)
						   {								
								  ArrRecordCount=ArrRecordCount+elements[i].attributes["PrimaryValue"].nodeValue;							 
						   }
						  else
						   {  								
								  ArrRecordCount=ArrRecordCount+PostBackDelimiter+elements[i].attributes["PrimaryValue"].nodeValue;										 
						   }
						
				        } 
				    }
				}						      
		  }

      if(ArrRecordCount.length==0)
		 {
			  alert('No item is selected ! Please select item.');
			  
			  return false;
		 }
	  else
		 {
	          if(confirm('Are you sure to '+MyButton.value+' the record?'))
			  {
				if(HidenVieldRecIDControl!=null)
				{
			    	 HidenVieldRecIDControl.value=ArrRecordCount;
					 window.document.forms[0].action=PostBackUrl+ "&RecId='"+ArrRecordCount+"'";
				}
				else
				{
					 window.document.forms[0].action=PostBackUrl+ "&RecId='"+ArrRecordCount+"'";
					window.document.forms[0].submit();
				}
				ButtonWithoutValidationDisabled(MyButton.id);
              }
	        else
	        {
		        return false;
	        }
        }			
		
   }          
           
function CheckedAll()
{
    if(document.getElementById('ListInventoryList')!=null)
    {
        var CheckboxIDObj=document.getElementById('ListInventoryList').getElementsByTagName("INPUT");
        for (j=0;j<CheckboxIDObj.length;j++)
        {
            if(CheckboxIDObj[j].type == 'checkbox')
            {        
                CheckboxIDObj[j].checked = true;
            }
        }
    }   
}

function CheckMillionsRang(TextBoxObject)
{         
    if(eval(TextBoxObject.value)> 1000000.99)
    {
        alert('Value must be less then 1000000.99');
        TextBoxObject.value='';
        TextBoxObject.focus();
        return false;
    }  
     return true;    
}
function CheckNumbersRang(TextBoxObject)
{         
    if(isNaN(TextBoxObject.value)==false)
    {
        if(eval(TextBoxObject.value)> 100.9 || eval(TextBoxObject.value)< 1 )
        {   
            alert('Value must be between 1 and 100');
            TextBoxObject.value='';
            TextBoxObject.focus();
            return false;
        }  
    }
     return true;    
}

function CallSrv(ddl)
{   
   var ddl=document.getElementById('ctl00_MyContantPlaceHolder_BASICSEARCHGHGF.FACTOR_TABLE_ID');
   if(ddl!=null)
   {    
     document.getElementById('ctl00_MyContantPlaceHolder_btnBASICSEARCH').click();
   
   }
  
}
function DisableTextBox(currentRadioObj)
{
    var id = currentRadioObj.id.split('RadioBtnTemplate')[1];
    var elements =  window.document.forms[0].getElementsByTagName("INPUT"); 
    for(i=0; i<elements.length;i++) 
    {
          if(elements[i].type=='text' && elements[i].id.indexOf("txtResetTimeOut")>=0)
          {
                elements[i].value="";
                elements[i].disabled=true;
          }
    }
    if(currentRadioObj.checked)
         document.getElementById("txtResetTimeOut"+id).disabled = false;    
}

function ShowFileUploadPopUp()
{   
    var ClientIDValue=GetCurrentQueryString("CLIENTID");
    OpenModal("DocumentHandler.aspx?CLIENTID="+ClientIDValue,"Screen Saver Upload",'595','300');	     	 
    return false;
}

function BlankFunction()
{
    return false;
}

//Function to view the preview of Media files
function GetMediaContainerString(ContainerId)
{
    var MyContainerId=document.getElementById("ctl00_MyContantPlaceHolder_"+ContainerId);
    if(MyContainerId.value.length>0)
    {
      OpenModal("PreviewMediaFiles.aspx?DocumentId="+MyContainerId.value,"Preview",'595','300');	     	 
    }
    return false;
}
////Function to get value of QueryString Variables////

function GetCurrentQueryString(GetVariableValue)
{       
       var url=document.location.href;
       
       if(url!='undefined' && url != null)
       {
           var QueryStringArray = url.split("?");
           if(QueryStringArray.length > 0 )
           {
               var QueryString = QueryStringArray[1];
               if(QueryString != null )
               {
                    var ValuePairsArray = QueryString.split("&");
                    
                    for(var i=0; i < ValuePairsArray.length; i++)
                    {
                        var ValuePairs = ValuePairsArray[i].split("=");
                        if(ValuePairs[0].toUpperCase() == GetVariableValue.toUpperCase())
                          {
                                return ValuePairs[1];
                          }
                    }
               return null;
               }
           }
       }
}
function GetDashboardGroupItems(MyDropDownControl,MyTextBoxTitle,MyUserID,MyFormAction)
{ 
     
     var ClientID;    
     var val="DASHBOARDGROUP";  
      if(document.getElementById(getElementByID('MyHiddenControlClientID'))!=null)
      {
         ClientID=document.getElementById(getElementByID('MyHiddenControlClientID')).value; 
      }
         MyCurrentDropDownControlID="ctl00_MyContantPlaceHolder_"+MyDropDownControl;
            MyTextBoxTitleID="ctl00_MyContantPlaceHolder_"+MyTextBoxTitle;
       xmlHttp=GetXmlHttpObject()
	    if (xmlHttp==null)
	    {
		     alert ("Browser does not support HTTP Request")
		     return
	    } 
	    var url="ReturnDataClassNames.ashx";
	    url=url+"?val="+val;		
	    url=url+"&sid="+Math.random();
	    url=url+"&ClientID="+ClientID;
	    url=url+"&UserID="+MyUserID;
	    if (MyFormAction=="NEW")
	    	    xmlHttp.onreadystatechange=ChangeDashboardGroupNewState;
	    if (MyFormAction=="EDIT")
	    	    xmlHttp.onreadystatechange=ChangeDashboardGroupEditState;	    
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);
   
}
function ChangeDashboardGroupEditState() 
{ 
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 {     
		  //if(xmlHttp.responseText!="") return false    
		  var strHTTP=xmlHttp.responseText;
		  if(strHTTP=="Not Found")
		  {  
				alert("Data Not found"); 
		  }
		  else
		  {
		    
		        BindDashboardDropDown(MyCurrentDropDownControlID,MyTextBoxTitleID,strHTTP); 		      
		       KillDHTMLWindowWithParentRefresh('EditDashboardGroup','MyChildPopupNewWindow');
		  }
	 } 
}
function ChangeDashboardGroupNewState() 
{ 
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 {     
		  //if(xmlHttp.responseText!="") return false    
		  var strHTTP=xmlHttp.responseText;
		  if(strHTTP=="Not Found")
		  {  
				alert("Data Not found"); 
		  }
		  else
		  {
		    
		        BindDashboardDropDown(MyCurrentDropDownControlID,MyTextBoxTitleID,strHTTP); 
		        KillDHTMLWindow('NewDashboardGroup','MyChildPopupNewWindow')
		      
		  }
	 } 
}

function BindDashboardDropDown(CurrentControlID,MyTextBoxTitleID,StringArray)
{

       var tempArray = new Array();
       tempArray = StringArray.split('~`');
       var ii=0;     
       var jj=0;      
       var myContainer= parent.document.getElementById("frm_AddDashboard").contentWindow.document; 
       var len = myContainer.getElementById(CurrentControlID).options.length;
      
       for (ii=0; ii<len; ii++) {
              myContainer.getElementById(CurrentControlID).remove(0); //It is 0 (zero) intentionally 
        
       }
       if(tempArray.length>1)
       {
              myContainer.getElementById(CurrentControlID).options[jj]=new Option('--Select--','');
              for(ii=0;ii<tempArray.length;ii++)
              {   
                        jj++;           
                        var SecondtempArray = new Array();
                        SecondtempArray = tempArray[ii].split('`~');
                        myContainer.getElementById(CurrentControlID).options[jj]=new Option(SecondtempArray[1],SecondtempArray[0]);
                    
              }
       }
       else
       {
                myContainer.getElementById(CurrentControlID).options[0]=new Option('--Select--','');
                          
              if(StringArray.length > 5)
              { 
                        var SecondtempArray = new Array();
                        SecondtempArray = StringArray.split('`~');
                        
                       myContainer.getElementById(CurrentControlID).options[1]=new Option(SecondtempArray[1],SecondtempArray[0]);
               }
       }
       myContainer.getElementById(MyTextBoxTitleID).focus();  
       myContainer.getElementById(CurrentControlID).selectedvalue='';  
}


 function BlockNonNumbersForThreshold(TextBoxObject, e)
        {

	        var Key;
	        var IsCtrl = false;
	        var KeyChar;
	        var Reg;
	        if(window.event) {
		        Key = e.keyCode;
		        IsCtrl = window.event.ctrlKey
	        }
	        else if(e.which) {
		        Key = e.which;
		        IsCtrl = e.ctrlKey;
	        }
	        if (isNaN(Key)) return true;
        	  
	        KeyChar = String.fromCharCode(Key);
        	
	        // check for backspace or delete, or if Ctrl was pressed
	        if (Key == 45 || Key == 8 || IsCtrl)
	        {
		        return true;
	        }

	        Reg = /\d/;
        	
	        return Reg.test(KeyChar);
        }
 
        
        function isValidThreshHold(TextBoxObject , AllowDecimal)
        {
           
            var strString=TextBoxObject.value;
            
            if(TextBoxObject.value<=0)
            {
            alert("Please provide valid Threshold value.");
            TextBoxObject.focus();
            return false;
            }
            var strValidChars ;
            var strChar;
            if(AllowDecimal)
            {
                strValidChars = "0123456789.";
            }
            else
            {            
                strValidChars = "0123456789";
            }
            

            //  test strString consists of valid characters listed above
            for (i = 0; i < strString.length ; i++)
            {
                strChar = strString.charAt(i);
                if (strValidChars.indexOf(strChar) == -1)
                 {                    
                    alert('Only integer value is allowed');
                    TextBoxObject.value='';
                    TextBoxObject.focus();
                    return false;
                 }
            }
            return true;          
           
        }
        
     
//--------------Notification Indexview Grid----------------------

function NotificationIndexViewGridAction()
{
    var i;
    var mystr ='';
    var num = 0 ;
    var MyGrid=document.getElementById('ctl00_MyContantPlaceHolder_ListGridNOTIFICATION_ID');
    var MyShowArchiveCheck=document.getElementById('ctl00_MyContantPlaceHolder_BASICSEARCHARCHIVE_FLAG');
    
    var MyGridRowCount=MyGrid.getElementsByTagName("tr").length;
    for(i=0;i<MyGridRowCount;i++)
    {
        var MyCell=MyGrid.rows[i].cells[2];
        if(MyCell!=null)
        {
           var MyActionCell=MyGrid.rows[i].cells.length-1;
            if(MyGrid.rows[i].cells[MyActionCell]!=null)
            {
                var SpanElements = MyGrid.rows[i].cells[MyActionCell].getElementsByTagName("span");
                  var NotificationType=MyCell.childNodes[0].innerHTML;
                
                if(NotificationType.toUpperCase().indexOf("TASK")!=-1)
                {  
                    num = i+1;      
                    if(num < 10)
                    {
                        mystr = "0" + num;
                    }
                    else
                    {
                        mystr = num;
                    }   
                    document.getElementById('ctl00_MyContantPlaceHolder_ListGridNOTIFICATION_ID_ctl'+ mystr + '_Acknowledge1').style.display="none";
                    SpanElements[1].innerHTML = '';
                }
            
                var MyImgCell=MyGrid.rows[i].cells[0];
                if(MyImgCell!=null)
                {
                         num = i+1; 
                         if(num==1)
                            continue;
                         if(num < 10)
                           {
                               mystr = "0" + num;
                           }
                            else
                            {
                                mystr = num;
                            }  
                             var ImageSource=document.getElementById('ctl00_MyContantPlaceHolder_ListGridNOTIFICATION_ID_ctl'+ mystr + '_ImageControl_NewMessage').src;
                             
                             var pos=ImageSource.lastIndexOf("/");
                             var fileName=ImageSource.substring(pos+1);
                             if(fileName=="NewMessage.jpg")
                             {
                                document.getElementById('ctl00_MyContantPlaceHolder_ListGridNOTIFICATION_ID_ctl'+ mystr + '_Mark as unread3').style.display="none";
                                    SpanElements[2].innerHTML = '';
                             }  
                }
            }
            else
            {
                return false;
            }
        }
        else
        {
            return false;
        }    
    }
   
    
}

//--------------Created By Sparsh----------------------
//Modified By Rajveer 30/11/2010

function AddDataPoint()
{

    var MySessionID= GetCurrentQueryString('SESSIONID');
    var MyClientID=GetCurrentQueryString('CLIENTID');
    this.CurrentURL="WOWSpace.aspx?Module=Academic.WOWSpace&App=WOW.DPStatus&FormAction=DPSELECTINDEXVIEW&SESSIONID="+MySessionID+"&CLIENTID="+MyClientID+"&IsChild=Y&Navigation=false";
    oDHW = new DHTMLWindow();
    oDHW.id = "Datapointstatus";
    oDHW.width = 900;
    oDHW.height = 500;    
    oDHW.title = "Select Datapoint"
    oDHW.top = 0;
    oDHW.left = 0;
    oDHW.modal = true;
    oDHW.contentURL = this.CurrentURL;
    oDHW.obj = "oDHW";
    oDHW.callbackFunc = "";
    oDHW.closeMode="KILL";
    oDHW.drag=false;     
    oDHW.myContainerId="MyPopupNewWindow"; 
    oDHW.Init(); 	 
    return false;
}


//--------------Created By Sparsh----------------------
function SelectDataPoint()
{    
    //Get the Ids of the records which are selected 
    var RecordIDs = MassRecordSelection("-","ListGridEVENT_ID");
    //if there is no record selected then return false
    if(RecordIDs == null || RecordIDs == '')
    {
        return false;
    }
    var MySessionID= GetCurrentQueryString('SESSIONID');
    var MyClientID=GetCurrentQueryString('CLIENTID');
    var objInsertDataPoint = new XMLHttpObject(); //Object creation
    //Set the Url of the page where the function for insering the records exists         
    objInsertDataPoint.WebPage = 'WOWSpace.aspx?Module=Academic.WOWSpace&App=WOW.DPStatus&FormAction=DATAPOINTINSERT&SESSIONID='+MySessionID +'&CLIENTID='+MyClientID+'&InsertValue='+ RecordIDs+"&IsChild=Y&Navigation=false"; 
    objInsertDataPoint.Async=false;
    objInsertDataPoint.Querystring='';
    objInsertDataPoint.Method = "POST"; //Setting Method 
    objInsertDataPoint.Init();//Initiate the AjaxCal  
    //Get the responce data       
    var MyAjaxResponseData=objInsertDataPoint.ResponseData();
     //Evaluate the responce data
     eval(MyAjaxResponseData);
      //if there is no error then alert the user about the successful insertion of records
     //and then refresh the grid on the parent page as well as the grid in the popup page       
    if(ajaxResponse.errorCode == "0")
    {
     alert("Data Point Assigned Successfully");     
     __doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDownEVENT_ID','');
     parent.__doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDownEVENT_STATUS_ID','');
     return false;
    }  
    //else alert the user with the error occured 
    else
    {       
     alert(ajaxResponse.errorMessage);     
     return false;
    }     //***************************************************************************** 
    return false;
}

//Function used to select primary key of selected checkbox in GridView
function MassRecordSelection(PostBackDelimiter,XGridName)
{   
	 ArrRecordCount='';	 
	 var TargetBaseControl='';
	 var elementsAll=  document.getElementsByTagName("body")[0].getElementsByTagName("*"); 
     
	 for(i=0; i<elementsAll.length;i++) 
	 {
		  if(elementsAll[i].id.indexOf(XGridName)>=0)
		  {
			 if(elementsAll[i].id.indexOf('GridFilter')<0)
             {                               
                     TargetBaseControl = elementsAll[i];
                      break;  
             }   
		  }
    }
			
	 var elements = TargetBaseControl.getElementsByTagName("span");
      
	 for(i=0; i<elements.length;i++ ) 
		 {
	  		var check= elements[i].getElementsByTagName("INPUT");

            for (j=0;j<check.length;j++)
                {
                   if(elements[i].attributes["PrimaryValue"]!= null && elements[i].attributes["PrimaryValue"].nodeValue!=null) 
			        {
                      if(check[j].type=='checkbox' && check[j].checked == true)
                        {
						  if(ArrRecordCount.length==0)
						   {								
								  ArrRecordCount=ArrRecordCount+elements[i].attributes["PrimaryValue"].nodeValue;							 
						   }
						  else
						   {  								
								  ArrRecordCount=ArrRecordCount+PostBackDelimiter+elements[i].attributes["PrimaryValue"].nodeValue;										 
						   }
						 check[j].checked = false;
				        } 
				    }
				}						      
		  }

      if(ArrRecordCount.length==0)
		 {
			  alert('No item is selected ! Please select item.');
			  return false;
		 }
	  else
		 {	         
				return ArrRecordCount;
				 
         }			
		
} 
// -----------------Created By Amit---------------------------------


function OpenAssignPermissionWindow(MyURL)
{
    this.CurrentURL = MyURL;    
 
    oDHW = new DHTMLWindow();
    oDHW.id = "AssignPermission";
    oDHW.width = 500;
    oDHW.height = 500;    
    oDHW.title = "Assign Permission"
    oDHW.top = 0;
    oDHW.left = 0;
    oDHW.modal = true;
    oDHW.contentURL = this.CurrentURL;
    oDHW.obj = "oDHW";
    oDHW.callbackFunc = "";
    oDHW.closeMode="KILL";
    oDHW.drag=false;     
    oDHW.myContainerId="MyPopupNewWindow"; 
    oDHW.Init(); 	 
    return false;
}
//---------------------created BY Amit------------------------------
function AssignAppPermission(MyURL,MyGridName,MyPrimaryObjectIDName)
{
//var InsertIds=GetCurrentQueryString("InsertValue");
var RecordIDs = MassRecordSelection("-",MyGridName);
    //if there is no record selected then return false
    if(RecordIDs == null || RecordIDs == '')
    {
        return false;
    }
    ButtonWithoutValidationDisabled("btnAssign");

    var objAssignPermission = new XMLHttpObject(); //Object creation
    //Set the Url of the page where the function for insering the records exist        
    objAssignPermission.WebPage = MyURL+"&InsertValue="+ RecordIDs+"&Navigation=false"; 
    objAssignPermission.Async=false;
    objAssignPermission.Querystring='';
    objAssignPermission.Method = "POST"; //Setting Method 
    objAssignPermission.Init();//Initiate the AjaxCal  
    //Get the responce data       
    var MyAjaxResponseData=objAssignPermission.ResponseData();
     //Evaluate the responce data
     eval(MyAjaxResponseData);
      //if there is no error then alert the user about the successful insertion of records
     //and then refresh the grid on the parent page as well as the grid in the popup page       
    if(ajaxResponse.errorCode == "0")
    {
     alert("Permission Assigned Successfully");     
       parent.__doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDown'+MyPrimaryObjectIDName,'');
     __doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDown'+MyPrimaryObjectIDName,'');
   
     return false;
    }  
    //else alert the user with the error occured 
    else
    {       
     alert(ajaxResponse.errorMessage);     
     return false;
    }     //***************************************************************************** 
    return false;

}

//--------------Created By Sparsh--------------------
var GridRefreshTimeOutID=0;
function SetGridRefreshTimeOut(ApplicationId)
{    
    GridRefreshTimeOutID = setInterval("RefreshDataGrid('"+ApplicationId+"')",180000);
}

//--------------Created By Sparsh--------------------
function RefreshDataGrid(ApplicationId)
{  
    RefreshAppName();
     //***************************************************************************** 
     if(ApplicationId == 'WOW.DPStatus')
        __doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDownEVENT_STATUS_ID','');
     if(ApplicationId == 'WOW.Task')
        __doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDownTASK_ID','');
     if(ApplicationId == 'WOW.Notification')
        __doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDownNOTIFICATION_ID','');       
}

//--------------Created By Sparsh--------------------
function RefreshAppName()
{        
    var MySessionID= GetCurrentQueryString('SESSIONID');
    var MyClientID=GetCurrentQueryString('CLIENTID');
    var objNotification = new XMLHttpObject(); //Object creation
    //Set the Url of the page where the function for insering the records exists         
    objNotification.WebPage = 'AjaxCalls.aspx?func=AppRecordCount&SESSIONID='+MySessionID +'&CLIENTID='+MyClientID; 
    objNotification.Async=false;
    objNotification.Querystring='';
    objNotification.Method = "POST"; //Setting Method 
    objNotification.Init();//Initiate the AjaxCal  
    //Get the responce data       
    var MyAjaxResponseData=objNotification.ResponseData();
    //Evaluate the responce data
    eval(MyAjaxResponseData);
    //if there is no error then alert the user about the successful insertion of records
    //and then refresh the grid on the parent page as well as the grid in the popup page    
    if(ajaxResponse.errorCode == "0")    
    {   
        if(ajaxResponse.CountString != null || ajaxResponse.CountString != '')
        {            
             var CountArray = new Array();
             CountArray = ajaxResponse.CountString.split('|');
             
             var NotificationCountString = CountArray[0];
             var NotificationCountArray = new Array();
             NotificationCountArray = NotificationCountString.split('~');
             var NotificationCount = NotificationCountArray[1];
             
             var TaskCountString = CountArray[1];     
             var TaskCountArray = new Array();
             TaskCountArray = TaskCountString.split('~'); 
             var TaskCount = TaskCountArray[1];
             
             var DataPointCountString = CountArray[2];     
             var DataPointCountArray = new Array();
             DataPointCountArray = DataPointCountString.split('~'); 
             var DataPointCount = DataPointCountArray[1];         
        }
        var elementsAll = document.getElementsByTagName("body")[0].getElementsByTagName("a"); 
        for(i=0;i<elementsAll.length;i++)
        {           
            if(elementsAll[i].attributes["class"]!= null)
            {                
                var App_Css = elementsAll[i].attributes["class"].nodeValue;
                if(App_Css.indexOf('AppMenuCSS') != -1)
                {               
                    var App_Name = elementsAll[i].innerHTML;
                    if(TaskCount!=0)
                    {
                        if(App_Name.indexOf('My Tasks') != -1)
                        {                        
                            if (elementsAll[i].childNodes[1]==null)                        
                                elementsAll[i].parentNode.innerHTML = elementsAll[i].parentNode.innerHTML.replace("</a>","").replace("</A>","") + "<span class = 'AppMenuRecordCSS'> (" + TaskCount + ")</span></a>";                          
                            else                                                    
                                elementsAll[i].childNodes[1].innerHTML="(" + TaskCount + ")";                    
                        }
                    }
                    if(NotificationCount!=0)
                    {
                        if(App_Name.indexOf('Notifications') != -1)
                        {
                            if (elementsAll[i].childNodes[1]==null)
                                elementsAll[i].parentNode.innerHTML = elementsAll[i].parentNode.innerHTML.replace("</a>","").replace("</A>","") + "<span class = 'AppMenuRecordCSS'> (" + NotificationCount + ")</span></a>";  
                            else
                                elementsAll[i].childNodes[1].innerHTML="(" + NotificationCount + ")";                        
                        }
                    }
                    if(DataPointCount!=0)
                    {
                        if(App_Name.indexOf('Datapoint Status') != -1)
                        {
                            if (elementsAll[i].childNodes[1]==null)
                                elementsAll[i].parentNode.innerHTML = elementsAll[i].parentNode.innerHTML.replace("</a>","").replace("</A>","") + "<span class = 'AppMenuRecordCSS'> (" + DataPointCount + ")</span></a>";  
                            else
                                elementsAll[i].childNodes[1].innerHTML="(" + DataPointCount + ")";                         
                        }
                    }
                }
            }
        }  
    }
    else
    {       
         alert(ajaxResponse.errorMessage);    
         return false;
    } 
   
}

//Change Application name of Property management,Site zone Management,FacilityRegion Management in Site Administration
function ChangeFacilityAppName()
{        
    var MyClientID=GetCurrentQueryString('CLIENTID');
    var objAppConfigLogicalName = new XMLHttpObject(); //Object creation
    //Set the Url of the page where the function for insering the records exists         
    objAppConfigLogicalName.WebPage = 'AjaxCalls.aspx?func=GetAppConfigLogicalName&CLIENTID='+MyClientID; 
    objAppConfigLogicalName.Async=false;
    objAppConfigLogicalName.Querystring='';
    objAppConfigLogicalName.Method = "POST"; //Setting Method 
    objAppConfigLogicalName.Init();//Initiate the AjaxCal  
    //Get the responce data       
    var MyAjaxResponseData=objAppConfigLogicalName.ResponseData();
    //Evaluate the responce data
    eval(MyAjaxResponseData);
    //if there is no error then alert the user about the successful insertion of records
    //and then refresh the grid on the parent page as well as the grid in the popup page    
    if(ajaxResponse.errorCode == "0")    
    {   
        if(ajaxResponse.CountString != null || ajaxResponse.CountString != '')
        {            
                 var CountArray = new Array();
                 CountArray = ajaxResponse.CountString.split('~');
                 var Property=CountArray[0];                     
                 var Region = CountArray[1]; 
                 var Zone = CountArray[2];    
        }
        var elementsAll = document.getElementsByTagName("body")[0].getElementsByTagName("a"); 
        for(i=0;i<elementsAll.length;i++)
        {           
            if(elementsAll[i].attributes["class"]!= null)
            {                
                var App_Css = elementsAll[i].attributes["class"].nodeValue;
                if(App_Css.indexOf('AppMenuCSS') != -1)
                {               
                    var App_Name = elementsAll[i].innerHTML;
                    
                        if(App_Name.indexOf('Property Management') != -1)
                        {                        
                            if (elementsAll[i].childNodes[1]==null)                        
                                elementsAll[i].parentNode.innerHTML = elementsAll[i].parentNode.innerHTML.replace("</a>","").replace("</A>","").replace("Property Management",Property+" Management");                          
                        }
                    
                   
                        if(App_Name.indexOf('Site Division Management') != -1)
                        {
                            if (elementsAll[i].childNodes[1]==null)
                                elementsAll[i].parentNode.innerHTML = elementsAll[i].parentNode.innerHTML.replace("</a>","").replace("</A>","").replace("Site Division",Region);
                         }
                    
                   
                        if(App_Name.indexOf('Site Zone Management') != -1)
                        {
                            if (elementsAll[i].childNodes[1]==null)
                                elementsAll[i].parentNode.innerHTML = elementsAll[i].parentNode.innerHTML.replace("</a>","").replace("</A>","").replace("Site Zone",Zone);  
                                                
                        
                    }
                }
            }
        }  
    }
    else
    {       
         alert(ajaxResponse.errorMessage);    
         return false;
    } 
   
}

//Change Application name of Property management,Site zone Management,FacilityRegion Management in Permission Management
function ChangePermissionApplicationName()
{
    var MyClientID=GetCurrentQueryString('CLIENTID');
    var objAppConfigLogicalName = new XMLHttpObject(); //Object creation
    //Set the Url of the page where the function for insering the records exists         
    objAppConfigLogicalName.WebPage = 'AjaxCalls.aspx?func=GetAppConfigLogicalName&CLIENTID='+MyClientID; 
    objAppConfigLogicalName.Async=false;
    objAppConfigLogicalName.Querystring='';
    objAppConfigLogicalName.Method = "POST"; //Setting Method 
    objAppConfigLogicalName.Init();//Initiate the AjaxCal  
    //Get the responce data       
    var MyAjaxResponseData=objAppConfigLogicalName.ResponseData();
    //Evaluate the responce data
    eval(MyAjaxResponseData);
    //if there is no error then alert the user about the successful insertion of records
    //and then refresh the grid on the parent page as well as the grid in the popup page    
    if(ajaxResponse.errorCode == "0")    
    {   
        if(ajaxResponse.CountString != null || ajaxResponse.CountString != '')
        {            
                 var CountArray = new Array();
                 CountArray = ajaxResponse.CountString.split('~');
                 var Property=CountArray[0];                     
                 var Region = CountArray[1]; 
                 var Zone = CountArray[2];    
        }
        
        var rootElements=document.getElementById("dTreeJS0");
        var childElements=rootElements.getElementsByTagName("span");
        var childElementsToolTip=rootElements.getElementsByTagName("a");
        for(i=0;i<childElements.length;i++)
        {
            if(childElements[i].innerText.indexOf('Property Management')>=0)
            {
                childElements[i].innerText=Property+" Management";
            }
            if(childElements[i].innerText.indexOf('Site Division Management')>=0)
            {
                childElements[i].innerText=Region+" Management";
            }
            
            if(childElements[i].innerText.indexOf('Site Zone Management')>=0)
            {
                childElements[i].innerText=Zone+" Management";
            }
        
        }
        //Change tool tip permission management of Property management,Site zone Management,FacilityRegion Management Applications
          for(i=0;i<childElementsToolTip.length;i++)
            {           
                if(childElementsToolTip[i].attributes["title"]!= null)
                {                
                    var App_title = childElementsToolTip[i].attributes["title"].nodeValue;
                    if(App_title.indexOf('Property Management') != -1)
                    {
                    childElementsToolTip[i].attributes["title"].nodeValue=Property+" Management";
                    }
                     if(App_title.indexOf('Site Division Management') != -1)
                    {
                    childElementsToolTip[i].attributes["title"].nodeValue=Region+" Management";
                    }
                     if(App_title.indexOf('Site Zone Management') != -1)
                    {
                    childElementsToolTip[i].attributes["title"].nodeValue=Zone+" Management";
                    }
                }
             }
       
     }  
    
    else
    {       
         alert(ajaxResponse.errorMessage);    
         return false;
    }
}


//Show Application Name in Label in Permission Management
function ChangePermissionDetailName()
{
    var MyClientID=GetCurrentQueryString('CLIENTID');
    var objPermissionDetailName = new XMLHttpObject(); //Object creation
    //Set the Url of the page where the function for insering the records exists         
    objPermissionDetailName.WebPage = 'AjaxCalls.aspx?func=GetAppConfigLogicalName&CLIENTID='+MyClientID; 
    objPermissionDetailName.Async=false;
    objPermissionDetailName.Querystring='';
    objPermissionDetailName.Method = "POST"; //Setting Method 
    objPermissionDetailName.Init();//Initiate the AjaxCal  
    //Get the responce data       
    var MyAjaxResponseData=objPermissionDetailName.ResponseData();
    //Evaluate the responce data
    eval(MyAjaxResponseData);
    //if there is no error then alert the user about the successful insertion of records
    //and then refresh the grid on the parent page as well as the grid in the popup page    
    if(ajaxResponse.errorCode == "0")    
    {   
        if(ajaxResponse.CountString != null || ajaxResponse.CountString != '')
        {            
                 var CountArray = new Array();
                 CountArray = ajaxResponse.CountString.split('~');
                 var Property=CountArray[0];                     
                 var Region = CountArray[1]; 
                 var Zone = CountArray[2];    
        }      
       var elementObj=document.getElementById("LabelPermissionsApplicationID");    
       
    if(elementObj!=null)
          {
                if(elementObj.innerText.indexOf('Property Management')>=0)
                {
                    elementObj.innerText=Property+" Management";
                }
                if(elementObj.innerText.indexOf('Site Division Management')>=0)
                {
                    elementObj.innerText=Region+" Management";
                }
                
                if(elementObj.innerText.indexOf('Site Zone Management')>=0)
                {
                    
                    elementObj.innerText=Zone+" Management";
                }
         }
        
     
     }  
    
    else
    {       
         alert(ajaxResponse.errorMessage);    
         return false;
    }
    
}

//--------------Created By Sparsh----------------------

function AddMyKiosks()
{
   var MySessionID= GetCurrentQueryString('SESSIONID');
    var MyClientID=GetCurrentQueryString('CLIENTID');
    CurrentURL="WOWSpace.aspx?Module=Academic.WOWSpace&App=WOW.MyKiosks&FormAction=MYKIOSKSSELECTINDEXVIEW&SESSIONID="+MySessionID+"&CLIENTID="+MyClientID+"&IsChild=Y&Navigation=false";
    this.CurrentURL = CurrentURL;   
 
    oDHW = new DHTMLWindow();
    oDHW.id = "KioskPopup";
    oDHW.width = 750;
    oDHW.height = 500;    
    oDHW.title = "Select KIOSKS"
    oDHW.top = 0;
    oDHW.left = 0;
    oDHW.modal = true;
    oDHW.contentURL = this.CurrentURL;
    oDHW.obj = "oDHW";
    oDHW.callbackFunc = "";
    oDHW.closeMode="KILL";
    oDHW.drag=false;     
    oDHW.myContainerId="MyPopupNewWindow"; 
    oDHW.Init(); 	 
    return false;
}
//--------------Created By Sparsh----------------------
function SelectMyKiosks()
{    
    //Get the Ids of the records which are selected 
    var RecordIDs = MassRecordSelection("-","ListGridKIOSK_ID");
    //if there is no record selected then return false
    if(RecordIDs == null || RecordIDs == '')
    {
        return false;
    }
    var MySessionID= GetCurrentQueryString('SESSIONID');
    var MyClientID=GetCurrentQueryString('CLIENTID');
    var objInsertDataPoint = new XMLHttpObject(); //Object creation
    //Set the Url of the page where the function for insering the records exists         
    objInsertDataPoint.WebPage = 'WOWSpace.aspx?Module=Academic.WOWSpace&App=WOW.MyKiosks&FormAction=MYKIOSKSINSERT&SESSIONID='+MySessionID +'&CLIENTID='+MyClientID+'&InsertValue='+ RecordIDs+"&IsChild=Y&Navigation=false"; 
    objInsertDataPoint.Async=false;
    objInsertDataPoint.Querystring='';
    objInsertDataPoint.Method = "POST"; //Setting Method 
    objInsertDataPoint.Init();//Initiate the AjaxCal  
    //Get the responce data       
    var MyAjaxResponseData=objInsertDataPoint.ResponseData();
     //Evaluate the responce data
     eval(MyAjaxResponseData);
      //if there is no error then alert the user about the successful insertion of records
     //and then refresh the grid on the parent page as well as the grid in the popup page       
    if(ajaxResponse.errorCode == "0")
    {
     alert("Kiosks Assigned Successfully");     
     __doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDownKIOSK_ID','');
     parent.__doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDownKIOSK_USER_ID','');
     return false;
    }  
    //else alert the user with the error occured 
    else
    {       
     alert(ajaxResponse.errorMessage);     
     return false;
    }     //***************************************************************************** 
    return false;
}

function DeleteMyKiosk(RecordId)
{
    if(confirm("Are you sure you want to delete this record?"))
    {
            var MySessionID= GetCurrentQueryString('SESSIONID');
            var MyClientID=GetCurrentQueryString('CLIENTID');
            var objInsertDataPoint = new XMLHttpObject(); //Object creation
            //Set the Url of the page where the function for insering the records exists    
            objInsertDataPoint.WebPage = 'WOWSpace.aspx?Module=Academic.WOWSpace&App=WOW.MyKiosks&FormAction=INDEXVIEWCUSTOMDELETE&SESSIONID='+MySessionID +'&CLIENTID='+MyClientID+'&RecID='+ RecordId; 
            objInsertDataPoint.Async=false;
            objInsertDataPoint.Querystring='';
            objInsertDataPoint.Method = "POST"; //Setting Method 
            objInsertDataPoint.Init();//Initiate the AjaxCal  
            //Get the responce data       
            var MyAjaxResponseData=objInsertDataPoint.ResponseData();
             //Evaluate the responce data
             eval(MyAjaxResponseData);
              //if there is no error then alert the user about the successful insertion of records
             //and then refresh the grid on the parent page as well as the grid in the popup page       
            if(ajaxResponse.errorCode == "0")
            {          
             __doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDownKIOSK_USER_ID','');   
             return false;
            }  
            //else alert the user with the error occured 
            else
            {       
             alert(ajaxResponse.errorMessage);     
             return false;
            }     //***************************************************************************** 
            return false;
    }
    else
    {
        return false;
    }
}

function CustomLaunchKioskWindow(RecordId)
{
    var MySessionID= GetCurrentQueryString('SESSIONID');
    var MyClientID=GetCurrentQueryString('CLIENTID');
    var objNotification = new XMLHttpObject(); //Object creation
    //Set the Url of the page where the function for insering the records exists         
    objNotification.WebPage = 'AjaxCalls.aspx?func=GetBuildingID&SESSIONID='+MySessionID +'&CLIENTID='+MyClientID+'&RecID='+ RecordId;  
    objNotification.Async=false;
    objNotification.Querystring='';
    objNotification.Method = "POST"; //Setting Method 
    objNotification.Init();//Initiate the AjaxCal  
    //Get the responce data       
    var MyAjaxResponseData=objNotification.ResponseData();
     //Evaluate the responce data
     eval(MyAjaxResponseData);
      //if there is no error then alert the user about the successful insertion of records
     //and then refresh the grid on the parent page as well as the grid in the popup page
     if(ajaxResponse.errorCode == "0")    
     {   
       if(ajaxResponse.BuildingID != null || ajaxResponse.BuildingID != '')
        {
             var BuildingId = ajaxResponse.BuildingID; 
        }
        if(ajaxResponse.PersonID != null || ajaxResponse.PersonID != '')
        {
             var PersonId = ajaxResponse.PersonID; 
        }
        if(ajaxResponse.KioskType != null || ajaxResponse.KioskType != '')
        {
             var KioskType = ajaxResponse.KioskType; 
        }
        if(KioskType == 'U')
        {
             var URL = "KIOSKPage.aspx?FormAction=HOME&BuildingID=" + BuildingId + "&PersonId=" + PersonId + "&ClientID=" + MyClientID + "&SESSIONID=" + MySessionID + "&HasDefaultModule=Y";        
        }
        else
        {
            var URL = "KIOSKPage.aspx?FormAction=HOME&BuildingID=" + BuildingId + "&ClientID=" + MyClientID + "&SESSIONID=" + MySessionID + "&HasDefaultModule=Y";        
        }
         if (navigator.appName == "Microsoft Internet Explorer" || navigator.appName == "Windows Internet Explorer")
             {
                if(navigator.appVersion.indexOf("MSIE 6.0")!=-1)
                {				
                    if(confirm("This action will close the window and open the Kiosk. Are you sure?"))
                    {
                        if(document.getElementById("LogoutID")!=null)
                        { 
                             var btn = document.getElementById("LogoutID");                        
                             btn.click();
						     window.open(URL, '', 'toolbar=no,titlebar=no,statusbar=no,resizable=yes,location=no,status=no,scrollbars=yes,fullscreen=yes');
						     window.opener = top;
						     window.close();
                        } 
                    }
                }
                else if(navigator.appVersion.indexOf("MSIE 7.0")!=-1)
                {
                    if(confirm("This action will close the window and open the Kiosk. Are you sure?"))
                    {
                        if(document.getElementById("LogoutID")!=null)
                        {
                            var btn = document.getElementById("LogoutID");
                            btn.click();
                            window.open('','_parent','');
                            window.close();
						    window.open(URL, '', 'toolbar=no,titlebar=no,statusbar=no,resizable=yes,location=no,status=no,scrollbars=yes,fullscreen=yes');
                        } 
                    }
                }
                else
                {
                    if(confirm("This action will close the window and open the Kiosk. Are you sure?"))
                    {
                        if(document.getElementById("LogoutID")!=null)
                        {
                            var btn = document.getElementById("LogoutID");
                            btn.click();                        
						    window.open(URL, '', 'toolbar=no,titlebar=no,statusbar=no,resizable=yes,location=no,status=no,scrollbars=yes,fullscreen=yes');
						    window.opener = top;
						    window.close();
					    }   
                    }
                }
            }
            else
            {	
			    if(confirm("This action will log out the session and open the Kiosk. Are you sure?"))
			    {				
				    if(document.getElementById("LogoutID")!=null)
				    {					
					    var btn = document.getElementById("LogoutID");					
					    location.href=btn.href ;
					    //btn.click();              
    					
					    window.open(URL, '', 'fullscreen=yes,statusbar=no,location=no ,BookMarks Toolbar=no ,Titlebar=no , Navigation Toolbar=no ,scrollbars=yes, resizable=yes ');					
					    window.opener = top;					
					    window.close();
				      }
			    }
            }             
         
    }
    else
    {       
         alert(ajaxResponse.errorMessage);    
         return false;
    }  
}

function CustomOpenKioskWindow(RecordId)
{
    var MySessionID= GetCurrentQueryString('SESSIONID');
    var MyClientID=GetCurrentQueryString('CLIENTID');
    var objNotification = new XMLHttpObject(); //Object creation
    //Set the Url of the page where the function for insering the records exists         
    objNotification.WebPage = 'AjaxCalls.aspx?func=GetBuildingID&SESSIONID='+MySessionID +'&CLIENTID='+MyClientID+'&RecID='+ RecordId;  
    objNotification.Async=false;
    objNotification.Querystring='';
    objNotification.Method = "POST"; //Setting Method 
    objNotification.Init();//Initiate the AjaxCal  
    //Get the responce data       
    var MyAjaxResponseData=objNotification.ResponseData();
     //Evaluate the responce data
     eval(MyAjaxResponseData);
      //if there is no error then alert the user about the successful insertion of records
     //and then refresh the grid on the parent page as well as the grid in the popup page
     if(ajaxResponse.errorCode == "0")    
     {   
        if(ajaxResponse.BuildingID != null || ajaxResponse.BuildingID != '')
        {
             var BuildingId = ajaxResponse.BuildingID; 
        }
        if(ajaxResponse.PersonID != null || ajaxResponse.PersonID != '')
        {
             var PersonId = ajaxResponse.PersonID; 
        }
        if(ajaxResponse.BuildingID != null || ajaxResponse.BuildingID != '')
        {
             var KioskType = ajaxResponse.KioskType; 
        }
        if(KioskType == 'U')
        {
             var URL = "KIOSKPage.aspx?FormAction=HOME&BuildingID=" + BuildingId + "&PersonId=" + PersonId + "&ClientID=" + MyClientID + "&SESSIONID=" + MySessionID + "&HasDefaultModule=Y";        
        }
        else
        {
            var URL = "KIOSKPage.aspx?FormAction=HOME&BuildingID=" + BuildingId + "&ClientID=" + MyClientID + "&SESSIONID=" + MySessionID + "&HasDefaultModule=Y";        
        }
         if (navigator.appName == "Microsoft Internet Explorer")
         { // better be ie6 at least
            window.open(URL, '', 'toolbar=no,titlebar=no,statusbar=no,resizable=yes,location=no,status=no,scrollbars=yes,fullscreen=yes');
         }
         else if (navigator.appName == "Windows Internet Explorer")
         { // better be ie7 at least
            window.open(URL, '', 'toolbar=no,titlebar=no,statusbar=no,resizable=yes,location=no,status=no,scrollbars=yes,fullscreen=yes');
         }
         else
         { // i.e. if Firefox
            window.open(URL, '', 'fullscreen=yes,statusbar=no,location=no ,BookMarks Toolbar=no ,Titlebar=no , Navigation Toolbar=no ,scrollbars=yes, resizable=yes ');
         }
          
    }
    else
    {       
         alert(ajaxResponse.errorMessage);    
         return false;
    }  
}

function ChangeFirstChildCss()
{
    var obj = document.getElementById('menuList'); 
    if(obj.childNodes[0].childNodes[0].className = 'FirstKioskListing')
    {
        obj.childNodes[0].childNodes[0].className = 'KioskListing';
    }
}

function OpenChart(QueryString,ControlID)
{	 
   var Control='';
   
    this.CurrentURL = "Property.aspx?Module=Site.Administration&App=WOW.ShowCase&FormAction=ASSIGNCHART&"+QueryString+"&Scope="+Control.replace(" ","")+"&Navigation=false"; 
   
    oDHW = new DHTMLWindow();
    oDHW.id = "ShowCaseChart";
    oDHW.width = 700;
    oDHW.height = 500;    
    oDHW.title = "Chart"
    oDHW.top = 0;
    oDHW.left = 0;
    oDHW.modal = true;
    oDHW.contentURL = this.CurrentURL;
    oDHW.obj = "oDHW";
    oDHW.callbackFunc = "";
    oDHW.closeMode="KILLCHILD";
    oDHW.drag=false;      
    oDHW.target = "parent";  
    oDHW.myContainerId="MyChildPopupNewWindow";
    oDHW.Init();
   return false;
}
function OpenShowCaseElement(CurrentURL)
{
    this.CurrentURL = CurrentURL +"&Navigation=false";    
    oDHW = new DHTMLWindow();
    oDHW.id = "PreviewFile";
    oDHW.width = 700;
    oDHW.height = 500;    
    oDHW.title = "Showcase Element"
    oDHW.top = 0;
    oDHW.left = 0;
    oDHW.modal = true;
    oDHW.contentURL = this.CurrentURL;
    oDHW.obj = "oDHW";
    oDHW.callbackFunc = "";
    oDHW.closeMode="KILL";
    oDHW.drag=false;     
    oDHW.myContainerId="MyPopupNewWindow"; 
    oDHW.Init(); 	 
    return false;
}
function OpenEditShowCaseElement(CurrentID)
{
    CurrentURL = location.href.replace("RecID","ShowCaseRecId").replace("DETAILVIEW","EDITSHOWELEMENT"); 
    CurrentURL =  CurrentURL +"&Navigation=false&RecId="+CurrentID;
    oDHW = new DHTMLWindow();
    oDHW.id = "PreviewFile";
    oDHW.width = 700;
    oDHW.height = 500;    
    oDHW.title = "Showcase Element"
    oDHW.top = 0;
    oDHW.left = 0;
    oDHW.modal = true;
    oDHW.contentURL = this.CurrentURL;
    oDHW.obj = "oDHW";
    oDHW.callbackFunc = "";
    oDHW.closeMode="KILL";
    oDHW.drag=false;     
    oDHW.myContainerId="MyPopupNewWindow"; 
    oDHW.Init();              
    return false;
}  

////////////Update Acknowledge/////////////
function UpdateAcknowledge(NotificationID)
{
var url = window.location.href;
var session= GetCurrentQueryString('SESSIONID');
var client=GetCurrentQueryString('CLIENTID');
this.CurrentURL="WOWSpace.aspx?Module=Academic.WOWSpace&App=WOW.Notification&FormAction=UPDATEDETAIL&SESSIONID="+session+"&CLIENTID="+client+"&RecID="+NotificationID+"&Action=Acknowledge"+"&Navigation=false";
document.location.href=this.CurrentURL;
return false;
}



//////////Update Archive/////////////////////
function UpdateArchive(NotificationID,ArchiveFlag)
{
var url = window.location.href;
var session= GetCurrentQueryString('SESSIONID');
var client=GetCurrentQueryString('CLIENTID');
if(ArchiveFlag.toUpperCase()=="ARCHIVE")
    this.CurrentURL="WOWSpace.aspx?Module=Academic.WOWSpace&App=WOW.Notification&FormAction=UPDATEDETAIL&SESSIONID="+session+"&CLIENTID="+client+"&RecID="+NotificationID+"&Action=Archive"+"&Navigation=false";
if(ArchiveFlag.toUpperCase()=="UNARCHIVE")
    this.CurrentURL="WOWSpace.aspx?Module=Academic.WOWSpace&App=WOW.Notification&FormAction=UPDATEDETAIL&SESSIONID="+session+"&CLIENTID="+client+"&RecID="+NotificationID+"&Action=Unarchive"+"&Navigation=false";
document.location.href=this.CurrentURL;
return false;
}


//////////Update AcknowledgeIndex/////////////
function UpdateAcknowledgeIndex(NotificationID)
{
var url = window.location.href;
var session= GetCurrentQueryString('SESSIONID');
var client=GetCurrentQueryString('CLIENTID');
this.CurrentURL="WOWSpace.aspx?Module=Academic.WOWSpace&App=WOW.Notification&FormAction=UPDATE&SESSIONID="+session+"&CLIENTID="+client+"&RecID="+NotificationID+"&Action=Acknowledge"+"&Navigation=true";
var objInsertLead = new XMLHttpObject(); //Object creation
    //Set the Url of the page where the function for insering the records exists         
    objInsertLead.WebPage = this.CurrentURL;
    objInsertLead.Async=false;
    objInsertLead.Querystring='';
    objInsertLead.Method = "POST"; //Setting Method 
    objInsertLead.Init();//Initiate the AjaxCal  
    //Get the responce data       
    var MyAjaxResponseData=objInsertLead.ResponseData();
     //Evaluate the responce data
     eval(MyAjaxResponseData);
      //if there is no error then alert the user about the successful insertion of records
     //and then refresh the grid on the parent page as well as the grid in the popup page       
    if(ajaxResponse.errorCode == "0")
    {          
     __doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDownNOTIFICATION_ID','');     
     return false;
    }  
    //else alert the user with the error occured 
    else
    {       
     alert(ajaxResponse.errorMessage);     
     return false;
    }
     //***************************************************************************** '
    return false;

}


//////////Update ArchiveIndex/////////////////////
function UpdateArchiveIndex(NotificationID)
{
var url = window.location.href;
var session= GetCurrentQueryString('SESSIONID');
var client=GetCurrentQueryString('CLIENTID');
this.CurrentURL="WOWSpace.aspx?Module=Academic.WOWSpace&App=WOW.Notification&FormAction=UPDATE&SESSIONID="+session+"&CLIENTID="+client+"&RecID="+NotificationID+"&Action=Archive"+"&Navigation=true";

var objInsertLead = new XMLHttpObject(); //Object creation
    //Set the Url of the page where the function for insering the records exists         
    objInsertLead.WebPage = this.CurrentURL;
    objInsertLead.Async=false;
    objInsertLead.Querystring='';
    objInsertLead.Method = "POST"; //Setting Method 
    objInsertLead.Init();//Initiate the AjaxCal  
    //Get the responce data       
    var MyAjaxResponseData=objInsertLead.ResponseData();
     //Evaluate the responce data
     eval(MyAjaxResponseData);
      //if there is no error then alert the user about the successful insertion of records
     //and then refresh the grid on the parent page as well as the grid in the popup page       
    if(ajaxResponse.errorCode == "0")
    {          
     __doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDownNOTIFICATION_ID','');     
     return false;
    }  
    //else alert the user with the error occured 
    else
    {       
     alert(ajaxResponse.errorMessage);     
     return false;
    }
     //***************************************************************************** '
    return false;

}
///////DashBoard Scripts:- Added By Avneesh Pandey///////////////
function AddDashboard()
{
var session= GetCurrentQueryString('SESSIONID');
var client=GetCurrentQueryString('CLIENTID');
this.CurrentURL="DashBoard.aspx?Module=Academic.WOWSpace&App=WOW.Dashboard&FormAction=NEW&SESSIONID="+session+"&CLIENTID="+client+"&Navigation=false";
//OpenModal(this.CurrentURL,"New Dashboard item",'600','400');	  
 oDHW = new DHTMLWindow();
    oDHW.id = "AddDashboard";
    oDHW.width = 700;
    oDHW.height = 400;    
    oDHW.title = "New Dashboard Item";
    oDHW.top = 0;
    oDHW.left = 0;
    oDHW.modal = true;
    oDHW.contentURL = this.CurrentURL;
    oDHW.obj = "oDHW";
    oDHW.callbackFunc = "";
    oDHW.closeMode="KILL";
    oDHW.drag=false;     
    oDHW.myContainerId="MyPopupNewWindow"; 
    oDHW.Init(); 	 
return false;
}


function OpenShowCaseElementDashboard()
{
var session= GetCurrentQueryString('SESSIONID');
var client=GetCurrentQueryString('CLIENTID');
this.CurrentURL="Property.aspx?Module=Site.Administration&App=WOW.ShowCase&FormAction=ASSIGNCHART&SESSIONID="+session+"&CLIENTID="+client+"&Scope=&Navigation=false";
//OpenModal(this.CurrentURL,"New Dashboard item",'500','330');	  
oDHW = new DHTMLWindow();
    oDHW.id = "ShowCaseElementDashboard";
    oDHW.width = 700;
    oDHW.height = 400;    
    oDHW.title = "Chart"
    oDHW.top = 0;
    oDHW.left = 0;
    oDHW.modal = true;
    oDHW.contentURL = this.CurrentURL;
    oDHW.obj = "oDHW";
    oDHW.callbackFunc = "SetfocusOnPoPupClose";
    oDHW.closeMode="KILLCHILD";
    oDHW.drag=false;      
    oDHW.target = "parent";  
    oDHW.myContainerId="MyChildPopupNewWindow";
    oDHW.Init();
return false;
}

function OpenNewDashboardGroup()
{
var session= GetCurrentQueryString('SESSIONID');
var client=GetCurrentQueryString('CLIENTID');
this.CurrentURL="DashBoard.aspx?Module=Academic.WOWSpace&App=WOW.Dashboard&FormAction=NEWDASHBOARDGROUP&SESSIONID="+session+"&CLIENTID="+client+"&Scope=&Navigation=false";  
    oDHW = new DHTMLWindow();
    oDHW.id = "NewDashboardGroup";
    oDHW.width = 700;
    oDHW.height = 350;    
    oDHW.title = "New Dashboard Group"
    oDHW.top = 0;
    oDHW.left = 0;
    oDHW.modal = true;
    oDHW.contentURL = this.CurrentURL;
    oDHW.obj = "oDHW";
    oDHW.callbackFunc = "SetfocusOnPoPupClose";
    oDHW.closeMode="KILLCHILD";
    oDHW.drag=false;      
    oDHW.target = "parent";  
    oDHW.myContainerId="MyChildPopupNewWindow";
    oDHW.Init(); 
return false;
}



function EditDashboardGroup()
{
  var DashBoardDropDown=document.getElementById('ctl00_MyContantPlaceHolder_DropDownDashboardGroup');
  var DashBoardDropDownvalue=DashBoardDropDown.value;
  if(DashBoardDropDown.value=="")
  {
        alert("Please select a Dashboard Group.");
        return false;
  }
  var session= GetCurrentQueryString('SESSIONID');
  var client=GetCurrentQueryString('CLIENTID');
  this.CurrentURL="DashBoard.aspx?Module=Academic.WOWSpace&App=WOW.Dashboard&FormAction=EDITDASHBOARDGROUP&SESSIONID="+session+"&CLIENTID="+client+"&Scope=&Navigation=false&RecID="+DashBoardDropDownvalue;  
  oDHW = new DHTMLWindow();
    oDHW.id = "EditDashboardGroup";
    oDHW.width = 700;
    oDHW.height = 350;    
    oDHW.title = "Edit Dashboard Group"
    oDHW.top = 0;
    oDHW.left = 0;
    oDHW.modal = true;
    oDHW.contentURL = this.CurrentURL;
    oDHW.obj = "oDHW";
    oDHW.callbackFunc = "SetfocusOnPoPupClose";
    oDHW.closeMode="KILLCHILD";
    oDHW.drag=false;      
    oDHW.target = "parent";  
    oDHW.myContainerId="MyChildPopupNewWindow";
    oDHW.Init();

return false;
}


function DeleteDashboardGroup(MyRecordID,MyUserID)
{
    var answer=confirm("Are you sure you want to delete this Dashboard Group?");
    if(answer)
        {            
            var myContainer= parent.document.getElementById("frm_AddDashboard").contentWindow.document; 
            var DashBoardDropDown=myContainer.getElementById('ctl00_MyContantPlaceHolder_DropDownDashboardGroup');
            var DashBoardDropDownvalue=DashBoardDropDown.value;
            var session= GetCurrentQueryString('SESSIONID');
            var client=GetCurrentQueryString('CLIENTID');
            this.CurrentURL="DashBoard.aspx?Module=Academic.WOWSpace&App=WOW.Dashboard&FormAction=DELETEDASHBOARDGROUP&SESSIONID="+session+"&CLIENTID="+client+"&Scope=&Navigation=false&RecID="+DashBoardDropDownvalue+"&UserID="+MyUserID;
            document.location.href=this.CurrentURL;return false;
            KillDHTMLWindowWithParentRefresh('EditDashboardGroup','MyChildPopupNewWindow');
            
        }
    else
    return false;
}

function Setfocus()
{
   if(parent.document.getElementById("frm_AddDashboard").contentWindow.document!=null)
    {
       var myContainer=parent.document.getElementById("frm_AddDashboard").contentWindow.document;
       if(myContainer.getElementById('ctl00_MyContantPlaceHolder_TextBoxDashboardTitle')!=null)
           myContainer.getElementById('ctl00_MyContantPlaceHolder_TextBoxDashboardTitle').focus();
    }
}

////////////Show MOdalWindow/////////////////////////
function ShowNotificationDetail(NotificationID)
{
    var url = window.location.href;
    var session= GetCurrentQueryString('SESSIONID');
    var client=GetCurrentQueryString('CLIENTID');
    this.CurrentURL="WOWSpace.aspx?Module=Academic.WOWSpace&App=WOW.Notification&FormAction=DETAILVIEW&SESSIONID="+session+"&CLIENTID="+client+"&RecID="+NotificationID+"&Navigation=false"; 
    oDHW = new DHTMLWindow();
    oDHW.id = "NotificationPopUp";
    oDHW.width = 700;
    oDHW.height = 500;    
    oDHW.title = "Notification Details"
    oDHW.top = 0;
    oDHW.left = 0;
    oDHW.modal = true;
    oDHW.contentURL = this.CurrentURL;
    oDHW.obj = "oDHW";
    oDHW.callbackFunc = "RefreshNotificationGrid";
    oDHW.closeMode="KILL";
    oDHW.drag=false;     
    oDHW.myContainerId="MyPopupNewWindow"; 
    oDHW.Init(); 	 
    return false;
}

// function to open pop up for "Related To DataPoints" in Task, new and edit mode.
function OpenDataPointTable()
{	
// get value for SessionID from QueryString.
var session= GetCurrentQueryString('SESSIONID');
// get value for ClientID from QueryString.
var client=GetCurrentQueryString('CLIENTID');
//Set final url for pop up navigation.
this.CurrentURL = "Property.aspx?Module=Site.DataToolkit&App=WOW.DataPointMgmt&FormAction=RELATEDTODPBASICSEARCH&SESSIONID="+session+"&CLIENTID="+client+"&Navigation=false";
oDHW = new DHTMLWindow();
    oDHW.id = "SelectDataPointPopUp";
    oDHW.width = 800;
    oDHW.height = 450;    
    oDHW.title = "Details"
    oDHW.top = 0;
    oDHW.left = 0;
    oDHW.modal = true;
    oDHW.contentURL = this.CurrentURL;
    oDHW.obj = "oDHW";
    oDHW.callbackFunc = "";
    oDHW.closeMode="KILLCHILD";
    oDHW.drag=false;      
    oDHW.target = "parent";    
    oDHW.myContainerId="MyChildPopupNewWindow"; 
    oDHW.Init(); 	 
    return false;
   
}

function MassSelectionWithNoConfirm(MyButton,PostBackUrl,PostBackDelimiter,XGridName,HidenVieldRecID)
{  
              
           ArrRecordCount='';
           var HidenVieldRecIDControl=null;
	  	   var TargetBaseControl='';

           var elementsAll=   document.getElementsByTagName("body")[0].getElementsByTagName("*");
		   for(i=0; i<elementsAll.length;i++) 
		   {
			  if(elementsAll[i].id.indexOf(HidenVieldRecID)>=0)
			  {
				HidenVieldRecIDControl = elementsAll[i];
				break;	  
			  }
		   }
          
           elementsAll=  document.getElementsByTagName("body")[0].getElementsByTagName("*");
		   for(i=0; i<elementsAll.length;i++) 
		   {
			 if(elementsAll[i].id.indexOf(XGridName)>=0)
			  {
				TargetBaseControl = elementsAll[i];
				break;	  
			  }
		   }
		 
           var elements = TargetBaseControl.getElementsByTagName("span");                  
           //Run the for loop
           for(i=0; i<elements.length;i++) 
            {
                 var check= elements[i].getElementsByTagName("INPUT");
                 for (j=0;j<check.length;j++)
                 {
                   
                    if(elements[i].attributes["PrimaryValue"]!= null && elements[i].attributes["PrimaryValue"].nodeValue!=null) 
                     {
                     
                       //for all elements of type CheckBox,check if it is checked or not
                      if(check[j].type=='checkbox' && check[j].checked == true)
	                   {                     
                         //Finally Store the value in a global variable 
                         if(ArrRecordCount.length==0)
                                ArrRecordCount=ArrRecordCount+elements[i].attributes["PrimaryValue"].nodeValue;     
                         else
                                ArrRecordCount=ArrRecordCount+PostBackDelimiter+elements[i].attributes["PrimaryValue"].nodeValue;                        
                       }
                     }
                 }       
            }           
            if(ArrRecordCount.length==0)
            {
                alert('No item is selected ! Please select item.');
                return false;
            }  
                 
            else
            {
                //pass the final Column values to hidden field if it is not null
                if(HidenVieldRecIDControl!=null)
                {
                    HidenVieldRecIDControl.value=ArrRecordCount;
                    ArrRecordCount="";
                    window.document.forms[0].action=PostBackUrl; 
                }
                //else set the action of the form with the values passed in the QueryString
                else
                {
                    window.document.forms[0].action=PostBackUrl+ "&RecId="+ArrRecordCount; 
                }                 
            }
}

//////Function to allow negative at starting//////
function AllowNegative(TextBoxObject)
{
    if(isNaN(TextBoxObject.value))
    {
        alert("Invalid value.");
        TextBoxObject.value = "";
        TextBoxObject.focus();
        return false;
    }
}


function OpenDataPointTask(CurrentURL)
{
    this.CurrentURL = CurrentURL +"&Navigation=false";    
 
    oDHW = new DHTMLWindow();
    oDHW.id = "TaskPopUP";
    oDHW.width = 900;
    oDHW.height = 500;    
    oDHW.title = "Task Details"
    oDHW.top = 0;
    oDHW.left = 0;
    oDHW.modal = true;
    oDHW.contentURL = this.CurrentURL;
    oDHW.obj = "oDHW";
    oDHW.callbackFunc = "KillDHTMLWindowWithParentRefresh";
    oDHW.closeMode="KILL";
    oDHW.drag=false;     
    oDHW.myContainerId="MyPopupNewWindow"; 
    oDHW.Init(); 	 
    return false;
}
function OpenDataPointAlert(CurrentURL)
{
    this.CurrentURL = CurrentURL +"&Navigation=false";    
 
    oDHW = new DHTMLWindow();
    oDHW.id = "AlertPopUP";
    oDHW.width = 700;
    oDHW.height = 500;    
    oDHW.title = "Alert Details"
    oDHW.top = 0;
    oDHW.left = 0;
    oDHW.modal = true;
    oDHW.contentURL = this.CurrentURL;
    oDHW.obj = "oDHW";
    oDHW.callbackFunc = "";
    oDHW.closeMode="KILL";
    oDHW.drag=false;     
    oDHW.myContainerId="MyPopupNewWindow"; 
    oDHW.Init(); 	 
    return false;
}
function OpenAlertRecipent(CurrentURL)
{
    this.CurrentURL = CurrentURL +"&Navigation=false";  
    
    oDHW = new DHTMLWindow();
    oDHW.id = "RecipientPopUp";
    oDHW.width = 600;
    oDHW.height = 400;    
    oDHW.title = "Recipient"
    oDHW.top = 0;
    oDHW.left = 0;
    oDHW.modal = true;
    oDHW.contentURL = this.CurrentURL;
    oDHW.obj = "oDHW";
    oDHW.callbackFunc = "";
    oDHW.closeMode="KILL";
    oDHW.drag=false;     
    oDHW.myContainerId="MyChildPopupNewWindow"; 
    oDHW.Init();              
    return false;
}  


// For Unarchive in Notification at indexmode
function UpdateUnArchiveIndex(NotificationID)
{
    var url = window.location.href;
var session= GetCurrentQueryString('SESSIONID');
var client=GetCurrentQueryString('CLIENTID');
this.CurrentURL="WOWSpace.aspx?Module=Academic.WOWSpace&App=WOW.Notification&FormAction=UPDATE&SESSIONID="+session+"&CLIENTID="+client+"&RecID="+NotificationID+"&Action=UnArchive&Navigation=true";

var objInsertLead = new XMLHttpObject(); //Object creation
    //Set the Url of the page where the function for insering the records exists         
    objInsertLead.WebPage = this.CurrentURL;
    objInsertLead.Async=false;
    objInsertLead.Querystring='';
    objInsertLead.Method = "POST"; //Setting Method 
    objInsertLead.Init();//Initiate the AjaxCal  
    //Get the responce data       
    var MyAjaxResponseData=objInsertLead.ResponseData();
     //Evaluate the responce data
     eval(MyAjaxResponseData);
      //if there is no error then alert the user about the successful insertion of records
     //and then refresh the grid on the parent page as well as the grid in the popup page       
    if(ajaxResponse.errorCode == "0")
    {          
     __doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDownNOTIFICATION_ID','');     
     return false;
    }  
    //else alert the user with the error occured 
    else
    {       
     alert(ajaxResponse.errorMessage);     
     return false;
    }
     //***************************************************************************** '
    return false;

}
function UpdateMarkAsReadIndex(NotificationID)
{
    var url = window.location.href;
var session= GetCurrentQueryString('SESSIONID');
var client=GetCurrentQueryString('CLIENTID');
this.CurrentURL="WOWSpace.aspx?Module=Academic.WOWSpace&App=WOW.Notification&FormAction=UPDATE&SESSIONID="+session+"&CLIENTID="+client+"&RecID="+NotificationID+"&Action=MarkUnread&Navigation=true";

var objInsertLead = new XMLHttpObject(); //Object creation
    //Set the Url of the page where the function for insering the records exists         
    objInsertLead.WebPage = this.CurrentURL;
    objInsertLead.Async=false;
    objInsertLead.Querystring='';
    objInsertLead.Method = "POST"; //Setting Method 
    objInsertLead.Init();//Initiate the AjaxCal  
    //Get the responce data       
    var MyAjaxResponseData=objInsertLead.ResponseData();
     //Evaluate the responce data
     eval(MyAjaxResponseData);
      //if there is no error then alert the user about the successful insertion of records
     //and then refresh the grid on the parent page as well as the grid in the popup page       
    if(ajaxResponse.errorCode == "0")
    {          
     __doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDownNOTIFICATION_ID','');     
     return false;
    }  
    //else alert the user with the error occured 
    else
    {       
     alert(ajaxResponse.errorMessage);     
     return false;
    }
     //***************************************************************************** '
    return false;

    
}

// Method for Edit Task
function EditTask(TaskID)
{
    var url = window.location.href;
    var session= GetCurrentQueryString('SESSIONID');
    var client=GetCurrentQueryString('CLIENTID');
    var RecID=GetCurrentQueryString('RecID');
    this.CurrentURL="WOWSpace.aspx?Module=Academic.WOWSpace&App=WOW.Task&FormAction=EDIT&SESSIONID="+session+"&CLIENTID="+client+"&RecID="+TaskID+"&Navigation=true"; 
    location.href=this.CurrentURL;
    return false;
}

// Method to Archive Tasks
function TaskArchive(TaskID)
{
var url = window.location.href;
var session= GetCurrentQueryString('SESSIONID');
var client=GetCurrentQueryString('CLIENTID');
this.CurrentURL="WOWSpace.aspx?Module=Academic.WOWSpace&App=WOW.Task&FormAction=ARCHIVE&SESSIONID="+session+"&CLIENTID="+client+"&RecID="+TaskID+"&Archive=Y"+"&Navigation=true";

var objInsertLead = new XMLHttpObject(); //Object creation
    //Set the Url of the page where the function for insering the records exists         
    objInsertLead.WebPage = this.CurrentURL;
    objInsertLead.Async=false;
    objInsertLead.Querystring='';
    objInsertLead.Method = "POST"; //Setting Method 
    objInsertLead.Init();//Initiate the AjaxCal  
    //Get the responce data       
    var MyAjaxResponseData=objInsertLead.ResponseData();
     //Evaluate the responce data
     eval(MyAjaxResponseData);
      //if there is no error then alert the user about the successful insertion of records
     //and then refresh the grid on the parent page as well as the grid in the popup page       
    if(ajaxResponse.errorCode == "0")
    {          
     __doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDownTASK_ID','');     
     return false;
    }  
    //else alert the user with the error occured 
    else
    {       
     alert(ajaxResponse.errorMessage);     
     return false;
    }
     //***************************************************************************** '
    return false;

}
// Method to unarchive Tasks
function TaskUnArchive(TaskID)
{
var url = window.location.href;
var session= GetCurrentQueryString('SESSIONID');
var client=GetCurrentQueryString('CLIENTID');
this.CurrentURL="WOWSpace.aspx?Module=Academic.WOWSpace&App=WOW.Task&FormAction=ARCHIVE&SESSIONID="+session+"&CLIENTID="+client+"&RecID="+TaskID+"&Archive=N"+"&Navigation=true";

var objInsertLead = new XMLHttpObject(); //Object creation
    //Set the Url of the page where the function for insering the records exists         
    objInsertLead.WebPage = this.CurrentURL;
    objInsertLead.Async=false;
    objInsertLead.Querystring='';
    objInsertLead.Method = "POST"; //Setting Method 
    objInsertLead.Init();//Initiate the AjaxCal  
    //Get the responce data       
    var MyAjaxResponseData=objInsertLead.ResponseData();
     //Evaluate the responce data
     eval(MyAjaxResponseData);
      //if there is no error then alert the user about the successful insertion of records
     //and then refresh the grid on the parent page as well as the grid in the popup page       
    if(ajaxResponse.errorCode == "0")
    {          
     __doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDownTASK_ID','');     
     return false;
    }  
    //else alert the user with the error occured 
    else
    {       
     alert(ajaxResponse.errorMessage);     
     return false;
    }
     //***************************************************************************** '
    return false;

}
// Method for Mark As Read
function TaskMarkAsRead(TaskID)
{
    var url = window.location.href;
    var session= GetCurrentQueryString('SESSIONID');
    var client=GetCurrentQueryString('CLIENTID');
    var RecID=GetCurrentQueryString('RecID');
    this.CurrentURL="WOWSpace.aspx?Module=Academic.WOWSpace&App=WOW.Task&FormAction=MARKUNREAD&SESSIONID="+session+"&CLIENTID="+client+"&RecID="+TaskID+"&Navigation=true"; 
    var objInsertLead = new XMLHttpObject(); //Object creation
    //Set the Url of the page where the function for insering the records exists         
    objInsertLead.WebPage = this.CurrentURL;
    objInsertLead.Async=false;
    objInsertLead.Querystring='';
    objInsertLead.Method = "POST"; //Setting Method 
    objInsertLead.Init();//Initiate the AjaxCal  
    //Get the responce data       
    var MyAjaxResponseData=objInsertLead.ResponseData();
     //Evaluate the responce data
     eval(MyAjaxResponseData);
      //if there is no error then alert the user about the successful insertion of records
     //and then refresh the grid on the parent page as well as the grid in the popup page       
    if(ajaxResponse.errorCode == "0")
    {          
     __doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDownTASK_ID','');     
     return false;
    }  
    //else alert the user with the error occured 
    else
    {       
     alert(ajaxResponse.errorMessage);     
     return false;
    }
     //***************************************************************************** '
    return false;
}
// Function to show/hide "Mark As Unread" link
function TaskIndexViewGridAction()
{
    var i;
    var mystr ='';
    var num = 0 ;
    var MyGrid=document.getElementById('ctl00_MyContantPlaceHolder_ListGridTASK_ID');
  
    var MyGridRowCount=MyGrid.getElementsByTagName("tr").length;
    for(i=0;i<MyGridRowCount;i++)
    {
        var MyCell=MyGrid.rows[i].cells[2];
        if(MyCell!=null)
        {
            if(MyGrid.rows[i].cells[8]!=null)
            {
                var SpanElements = MyGrid.rows[i].cells[8].getElementsByTagName("span");
                var MyImgCell=MyGrid.rows[i].cells[0];
                if(MyImgCell!=null)
                {
                         num = i+1; 
                         if(num==1)
                            continue;
                         if(num < 10)
                           {
                               mystr = "0" + num;
                           }
                            else
                            {
                                mystr = num;
                            }  
                             var ImageSource=document.getElementById('ctl00_MyContantPlaceHolder_ListGridTASK_ID_ctl'+ mystr + '_ImageControl_NewMessage').src;
                             
                             var pos=ImageSource.lastIndexOf("/");
                             var fileName=ImageSource.substring(pos+1);
                             if(fileName=="NewMessage.jpg")
                             {
                                document.getElementById('ctl00_MyContantPlaceHolder_ListGridTASK_ID_ctl'+ mystr + '_Mark As Unread2').style.display="none";
                                SpanElements[1].innerHTML = '';
                             }  
                }
        }
        else
        {return false;}
        }
        else
        {
            return false;
        }    
    }
   
    
}

// Method for custom New button in Task
function NewTask()
{    
    var MySessionID= GetCurrentQueryString('SESSIONID');
    var MyClientID=GetCurrentQueryString('CLIENTID');
    this.CurrentURL="WOWSpace.aspx?Module=Academic.WOWSpace&App=WOW.Task&FormAction=NEW&SESSIONID="+MySessionID+"&CLIENTID="+MyClientID;
     location.href=this.CurrentURL;
    return false;
}

function GetTaskReminderValue(MyCurrentValue,MyDropDownControl)
{
     MyCurrentDropDownControlID=getElementByID(MyDropDownControl);
    if(MyCurrentValue!="")
    {
      var ClientID= GetCurrentQueryString('CLIENTID');
        
      var MyParentControlValue;
      var val="TASKREMINDERVALUE";//MyCurrentValue;
	  xmlHttp=GetXmlHttpObject()
	    if (xmlHttp==null)
	    {
		     alert ("Browser does not support HTTP Request")
		     return
	    } 
	    var url="ReturnDataClassNames.ashx";
	    url=url+"?val="+val;	
	    url=url+"&MyCurrentvalue="+MyCurrentValue;
	    url=url+"&sid="+Math.random();
	    url=url+"&ClientID="+ClientID;
	    xmlHttp.onreadystatechange=DropDownStateChanged;
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);
	}
	else
	{
	   ResetDropDown(MyCurrentDropDownControlID) ;     
	}
	
   
}

/**************-----Function for Enabling the Checkboxes 
                    in Task New and edit Mode-----Created by Amit------**************/
                    
function SetTaskReminderFlag()
{
    var TaskReminderFlag=document.getElementById('ctl00_MyContantPlaceHolder_ACTIVE_FLAG');
    var ReminderUnit=document.getElementById('ctl00_MyContantPlaceHolder_REMINDERUNIT');
    var ReminderValue=document.getElementById('ctl00_MyContantPlaceHolder_REMINDERVALUE');
    var ReminderENotificationFlag=document.getElementById('ctl00_MyContantPlaceHolder_REMINDER_ENOTIFICATION_FLAG');
    var ReminderSysNotificationFlag=document.getElementById('ctl00_MyContantPlaceHolder_REMINDER_SYSNOTIFICATION_FLAG');
    if(!TaskReminderFlag.checked)
        {
          
            ReminderUnit.selectedIndex=ReminderUnit.length-1;
            ResetDropDown(ReminderValue.id);
            ReminderENotificationFlag.checked=false;
            ReminderSysNotificationFlag.checked=false;
            ReminderUnit.disabled=true;
            ReminderValue.disabled=true;
            ReminderENotificationFlag.disabled=true;
            ReminderSysNotificationFlag.disabled=true;
        }   
    else
        {
            ReminderUnit.disabled=false;
            ReminderValue.disabled=false;
            ReminderENotificationFlag.disabled=false;
            ReminderSysNotificationFlag.disabled=false;
        }
}




//-----Created By Megha Razdaan-------

function DisassociateAppPermission(RecordId)
{
    if(confirm('Are you sure to delete the record?'))
	{
			
			       
    var MySessionID= GetCurrentQueryString('SESSIONID');
    var MyClientID=GetCurrentQueryString('CLIENTID');
    var objInsertDataPoint = new XMLHttpObject(); //Object creation
    //Set the Url of the page where the function for insering the records exists    
    objInsertDataPoint.WebPage = 'Property.aspx?Module=Site.Administration&App=WOW.KioskType&FormAction=DELETEASSOCIATEDKIOSKMEMBERS&SESSIONID='+MySessionID +'&CLIENTID='+MyClientID+'&RecID='+ RecordId; 
    objInsertDataPoint.Async=false;
    objInsertDataPoint.Querystring='';
    objInsertDataPoint.Method = "POST"; //Setting Method 
    objInsertDataPoint.Init();//Initiate the AjaxCal  
    //Get the responce data       
    var MyAjaxResponseData=objInsertDataPoint.ResponseData();
     //Evaluate the responce data
     eval(MyAjaxResponseData);
      //if there is no error then alert the user about the successful insertion of records
     //and then refresh the grid on the parent page as well as the grid in the popup page       
     
    if(ajaxResponse.errorCode == "0")
    {          
     __doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDownKIOSK_PERMISSION_ID','');     
     return false;
    }  
    //else alert the user with the error occured 
    else
    {       
     alert(ajaxResponse.errorMessage);     
     return false;
    } 
  }
    else
       {
        return false;
       }    //***************************************************************************** 
     
 
 }

function BulkDisassociateAppPermission(MassDeleteUrl)
{
 //Get the Ids of the records which are selected 
    var RecordIDs = MassMemberSelection("-","ListGridKIOSK_PERMISSION_ID");
    //if there is no record selected then return false
    if(RecordIDs == null || RecordIDs == '')
    {        
        return false;
    }    
    var objInsertDataPoint = new XMLHttpObject(); //Object creation
    //Set the Url of the page where the function for insering the records exists         
    objInsertDataPoint.WebPage = MassDeleteUrl + '&DeleteValue='+ RecordIDs; 
    objInsertDataPoint.Async=false;
    objInsertDataPoint.Querystring='';
    objInsertDataPoint.Method = "POST"; //Setting Method 
    objInsertDataPoint.Init();//Initiate the AjaxCal  
    //Get the responce data       
    var MyAjaxResponseData=objInsertDataPoint.ResponseData();
     //Evaluate the responce data
     eval(MyAjaxResponseData);
      //if there is no error then alert the user about the successful insertion of records
     //and then refresh the grid on the parent page as well as the grid in the popup page       
    if(ajaxResponse.errorCode == "0")
    {       
     __doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDownKIOSK_PERMISSION_ID','');  
     return false;
    }  
    //else alert the user with the error occured 
    else
    {       
     alert(ajaxResponse.errorMessage);     
     return false;
    }     //***************************************************************************** 
    return false;
}                

//-----------------Method By Rajveer Rathore------

function OpenDataPointAlert(CurrentURL)
{
    this.CurrentURL = CurrentURL +"&Navigation=false";    
 
    oDHW = new DHTMLWindow();
    oDHW.id = "AlertPopUP";
    oDHW.width = 700;
    oDHW.height = 500;    
    oDHW.title = "Alert Details"
    oDHW.top = 0;
    oDHW.left = 0;
    oDHW.modal = true;
    oDHW.contentURL = this.CurrentURL;
    oDHW.obj = "oDHW";
    oDHW.callbackFunc = "KillDHTMLWindowWithParentRefresh";
    oDHW.closeMode="KILL";
    oDHW.drag=false;     
    oDHW.myContainerId="MyPopupNewWindow"; 
    oDHW.Init(); 	 
    return false;
}
//------------------Created By Amit-----------
function RefreshNotificationGrid()
{
parent.__doPostBack('ctl00$MyContantPlaceHolder$ListPageSizeDropDownNOTIFICATION_ID','');
}


function BlockNonNumbersAllowDecimal(TextBoxObject, e, AllowDecimal, AllowNegative)
        {

	        var Key;
	        var IsCtrl = false;
	        var KeyChar;
	        var Reg;
        		
	        if(window.event) {
		        Key = e.keyCode;
		        IsCtrl = window.event.ctrlKey
	        }
	        else if(e.which) {
		        Key = e.which;
		        IsCtrl = e.ctrlKey;
	        }
        	
	        if (isNaN(Key)) return true;
        	
	        KeyChar = String.fromCharCode(Key);
        	
        	if(KeyChar == "-")
            {
               // to allow negative at the starting position only
               if(TextBoxObject.value.length!=0)
                  return false;
            }
            
	        // check for backspace or delete, or if Ctrl was pressed
	        if (Key == 8 || IsCtrl)
	        {
		        return true;
	        }
	        if(KeyChar == ".")
            {
               return true;
            }

	        Reg = /\d/;
	        var IsFirstN = AllowNegative ? KeyChar == '-' && TextBoxObject.value.indexOf('-') == -1 : false;
	        var IsFirstD = AllowDecimal ? KeyChar == '.' && TextBoxObject.value.indexOf('.') == -1 : false;
        	
	        return IsFirstN || IsFirstD || Reg.test(KeyChar);
        }
        
//-------------Method from Shweta-----------------------
function NewLookupTable()
{    
    var MySessionID= GetCurrentQueryString('SESSIONID');
    var MyClientID=GetCurrentQueryString('CLIENTID');
    this.CurrentURL="Property.aspx?Module=Site.DataToolkit&App=DataToolKit.LookupTable&FormAction=NEW&SESSIONID="+MySessionID+"&CLIENTID="+MyClientID;
    location.href=this.CurrentURL;
    return false;
}

//LookUpTable Delete confirm Message
function DeleteGridRecords(MyButton,XGridName)
        {
             MyButton.disabled=false;
                   var ArrRecordCount=0;
                   var TargetBaseControl='';
                   var elementsAll=  document.getElementsByTagName("body")[0].getElementsByTagName("*");
                   
                   for(i=0; i<elementsAll.length;i++) 
                         {
                                if(elementsAll[i].id.indexOf(XGridName)>=0)
                                {
                                    TargetBaseControl = elementsAll[i];
                                    break;                               
                                }
                         }
                              
                   if(TargetBaseControl=="" && TargetBaseControl!=null)
                         {
                             alert("No records to delete.");
                             return false;
                          }
                  var check = TargetBaseControl.getElementsByTagName("INPUT");
                
                  
            for (j=0;j<check.length;j++)
                {
                    if(check[j].type=='checkbox' && check[j].checked == true)
                        {
                                    if(ArrRecordCount==0)
                                     {                                              
                                                ArrRecordCount=1;       
                                                break;                              
                                     }
                              } 
                      }

                if(ArrRecordCount==0)
                         {
                                alert('No item is selected ! Please select item.');
                                
                                return false;
                         }
                    else
                         {
                            if(confirm('Are you sure you want to delete records ?'))
                            {
                                  
                            }
                          else
                          {
                                return false;
                          }
                    }               
                        
           }


  // // 
  function DPInventoryDelete(MyButton,XGridName,HidenVieldRecID)
        {
             MyButton.disabled=false;
			 var ArrRecordCount=0;
			 var TargetBaseControl='';
			 var elementsAll=  document.getElementsByTagName("body")[0].getElementsByTagName("*");
			 
			 for(i=0; i<elementsAll.length;i++) 
				 {
					  if(elementsAll[i].id.indexOf(XGridName)>=0)
					  {
					      if(elementsAll[i].id.indexOf('GridFilter')<0)
					      {    					  
							   TargetBaseControl = elementsAll[i];
							    break;	 
					      }
					      
					  }
				 }
	 				
			var check = TargetBaseControl.getElementsByTagName("INPUT");
	          
			
            for (j=0;j<check.length;j++)
                {
                    if(check[j].type=='checkbox' && check[j].checked == true)
                        {
					      if(ArrRecordCount==0)
					       {								
							      ArrRecordCount=1;		
							      break;					 
					       }
			            } 
			    }

	          if(ArrRecordCount==0)
				 {
					  alert('No item is selected ! Please select item.');
					  
					  return false;
				 }
			  else
				 {
			          if(confirm('Are you sure to '+MyButton.value+' the record?'))
					  {
						
	                  }
			        else
			        {
				        return false;
			        }
		        }			
				
           }    
           
           function FacilityLayerManagementNewToolTip()
{

 var MyClientID=GetCurrentQueryString('CLIENTID');
    var objAppConfigLogicalName = new XMLHttpObject(); //Object creation
    //Set the Url of the page where the function for insering the records exists         
    objAppConfigLogicalName.WebPage = 'AjaxCalls.aspx?func=GetAppConfigLogicalName&CLIENTID='+MyClientID; 
    objAppConfigLogicalName.Async=false;
    objAppConfigLogicalName.Querystring='';
    objAppConfigLogicalName.Method = "POST"; //Setting Method 
    objAppConfigLogicalName.Init();//Initiate the AjaxCal  
    //Get the responce data       
    var MyAjaxResponseData=objAppConfigLogicalName.ResponseData();
    //Evaluate the responce data
    eval(MyAjaxResponseData);
    //if there is no error then alert the user about the successful insertion of records
    //and then refresh the grid on the parent page as well as the grid in the popup page    
    if(ajaxResponse.errorCode == "0")    
    {   
        if(ajaxResponse.CountString != null || ajaxResponse.CountString != '')
        {            
                 var CountArray = new Array();
                 CountArray = ajaxResponse.CountString.split('~');                                   
                 var Region = CountArray[1];                  
        }       
   
           var elementObj=document.getElementById("ctl00_MyContantPlaceHolder_btnNewFACILITY_REGION_ID");       
           elementObj.attributes["title"].nodeValue="Create New "+Region;
           
    }
    else
    {       
         alert(ajaxResponse.errorMessage);    
         return false;
    } 

} 

////Function to check the length of Logical name in Facility Layer config
function checkLength(MyButton)
{
   if(MyButton.value.length > 50)
   {
     alert("Logical Name cannot exceed 50 characters");
     MyButton.focus();
     return false;
   }
}

////Function to see image preview in media library
function ShowImagePreview(ImageId,IsSysFlag)
{   
    var ClientIDValue=GetCurrentQueryString("CLIENTID");
        
    var imageid=ImageId.id;
    var valuesarray = imageid.split("_");
    if(valuesarray.length > 0 )
           {
               var first = valuesarray[0];
               var second = valuesarray[1];
               var id=first+"_"+second+"_MyImageID";
               var value=document.getElementById(id).innerHTML;
           }
    //OpenModal("ThumbNailHandler.ashx?ID="+value+"&Type=C","Image Preview",'700','500');	  
    oDHW = new DHTMLWindow();
    oDHW.id = "ImagePreview";
    oDHW.width = window.screen.width-110;
    oDHW.height = window.screen.height-120;
    oDHW.title = "Image Preview"
    oDHW.top = 50;
    oDHW.left = 40;
    oDHW.modal = true;
    oDHW.contentURL = "PreviewMediaFiles.aspx?DocumentId="+value+"&ClientId="+ClientIDValue+"&ISSYSFLAG="+IsSysFlag;
    oDHW.obj = "oDHW";
    oDHW.callbackFunc = "";
    oDHW.closeMode="KILL";
    oDHW.drag=true;      
    oDHW.myContainerId="MyImagePreviewContainer";
    oDHW.Init();     	 
    return false;
}

//// Function for ImageEdit in Image Library.
function GetLibraryImageData(MyEditButton)
{
  
    var MyEditButtonid=MyEditButton.id;
    var valuesarray = MyEditButtonid.split("_");
    if(valuesarray.length > 0 )
    {
        var first = valuesarray[0];
        var second = valuesarray[1];
        var MyImg=first+"_"+second+"_MyImageID";
        var MyImgTitleID=first+"_"+second+"_TitleImage";
        var MyImgDescriptionID=first+"_"+second+"_ImageDescription";
        var MyImageID=document.getElementById(MyImg).innerHTML;
        var MyImgTitle=document.getElementById(MyImgTitleID).title;
        var MyImgDescription=document.getElementById(MyImgDescriptionID).innerHTML;
    }
   if(document.getElementById('UpdatetxtName')!=null)
    {
        var ImageNameTextBox= document.getElementById('UpdatetxtName');
        ImageNameTextBox.value=MyImgTitle;
    }
    if(document.getElementById('UpdatetxtDescription')!=null)
    {
        var ImageNameTextBox= document.getElementById('UpdatetxtDescription');
        ImageNameTextBox.value=MyImgDescription;
    }
    if(document.getElementById('UpdateImage')!=null)
    {
      var ImageNameTextBox= document.getElementById('UpdateImage');
      ImageNameTextBox.src= "ThumbNailHandler.ashx?ID=" + MyImageID ;
    }
    if(document.getElementById('MyHiddenImageID')!=null)
    {
        var MyHiddenImageID=document.getElementById('MyHiddenImageID');
        MyHiddenImageID.value=MyImageID;
    }
} 

//To set the focus on object itself 
function SetFocusOnTextBox(Obj,e,AllowNegative,AllowAll)
{
     if(window.event)
        {
            keynum=e.keyCode
        }
        if(e.which)
        {
            keynum=e.which;
        }
        ///To disable Enter key (Keycode of Enter is 13)///
      if (keynum== 13)
      {
        Obj.focus();
        return false;
      }
      if(AllowAll)
            return true;
      else
      {
        if (AllowNegative)
            {   
                CarotPos=doGetCaretPosition(Obj);
                if((keynum==45)&&(CarotPos!=0))
                    return false;
                else
                    return BlockNonNumbers(Obj,e,true,true);
                    
            }
        else
            return BlockNonNumbers(Obj,e,true,false);
      }

}

/////ShowPopUpWindow for Showing Wisdom
function ShowPopUpWindow(url,title,target)
{
   
        oDHW = new DHTMLWindow();
        oDHW.id = "InmdAlertPopUP";
        oDHW.width = 700;
        oDHW.height = 500;
        if(title !="")
            oDHW.title = title;
        else
            oDHW.title = "Powersmiths WOW";
        oDHW.top = 0;
        oDHW.left = 0;
        oDHW.modal = true;
        oDHW.contentURL = url;
        oDHW.obj = "oDHW";
        oDHW.callbackFunc = "KillDHTMLWindowWithParentRefresh";
        oDHW.closeMode="KILL";
        oDHW.drag=false;      
        oDHW.myContainerId="MyPopupNewWindow";
        oDHW.Init();   
        return false;

}
function DeleteInmdAlert(InmdAlertID)
{
    var test = confirm('Are you sure you want to delete');
          if (test==true) 
          {           
            var MySessionID= GetCurrentQueryString('SESSIONID');
            var MyClientID=GetCurrentQueryString('CLIENTID');
            document.location.href="Property.aspx?Module=System.Administration&App=WOW.INMDRegistry&FormAction=DELETE&SESSIONID=" + MySessionID + "&CLIENTID=" + MyClientID + "&RecID=" +InmdAlertID;
            return false;
           
           }
           else 
           {
            return false;
           }
 }
         
    
function EditInmdAlert(INmdAlertID)
{
    var MySessionID= GetCurrentQueryString('SESSIONID');
    var MyClientID=GetCurrentQueryString('CLIENTID');
    this.CurrentURL="Property.aspx?Module=System.Administration&App=WOW.INMDRegistry&FormAction=EDIT&SESSIONID=" + MySessionID + "&CLIENTID=" + MyClientID  + "&RecID=" + INmdAlertID+"&Navigation=false";
    oDHW = new DHTMLWindow();
    oDHW.id = "InmdAlertPopUP";
    oDHW.width = 700;
    oDHW.height = 500;    
    oDHW.title = "Alert Details"
    oDHW.top = 0;
    oDHW.left = 0;
    oDHW.modal = true;
    oDHW.contentURL = this.CurrentURL;
    oDHW.obj = "oDHW";
    oDHW.callbackFunc = "KillDHTMLWindowWithParentRefresh";
    oDHW.closeMode="KILL";
    oDHW.drag=false;     
    oDHW.myContainerId="MyPopupNewWindow"; 
    oDHW.Init(); 	 
    return false;
    
}

// Function to refresh sustainability projects grid
function RefreshSustainabilityProjectsGrid()
{
__doPostBack('ctl00$MyContantPlaceHolder$ListSustainability','');
 var MyGrid=document.getElementById('ctl00_MyContantPlaceHolder_ListSustainability');
 var MyCheck=MyGrid.getElementsByTagName("input");
 for(i=0;i<MyCheck.length;i++)
 {
    element = MyCheck[i];
    if(element.type=='checkbox')
    { 
       if(element.checked==true)
       element.checked = false;
    }
 }
}
//---Method to Change the Search control caption in Notification  Application
function NotificationControls_ChangeText()
{
    var MySearchControls=document.getElementById('ctl00_MyContantPlaceHolder_BasichSearchFormSearch');
    if(MySearchControls!=null)
    {
        var MyCells=MySearchControls.getElementsByTagName('td');
        for(i=0;i<MyCells.length;i++)
        {
          if(MyCells[i].innerHTML=="DataPoint")
          {
            MyCells[i].innerHTML="DataPoint/INMD";
            break;
          }  
        }
    }
}

function CheckReadingValue(ReadingTextBox,TotalLength,AfterDecimal)
{
    var myMaxvalue="";
    var ReadingValue=ReadingTextBox.value;
    var BeforeDecimal=TotalLength-AfterDecimal;
    var AlertMsg="";
    var DecimalIndex=0;
    DecimalIndex=ReadingValue.indexOf(".");
    MinusIndex=ReadingValue.indexOf("-");
    myMaxvalue=Math.pow(10,BeforeDecimal)-1;
           
    if(DecimalIndex==-1)
    {
           if(ReadingValue>myMaxvalue)
            {
                AlertMsg="Maximum "+BeforeDecimal+" digits are allowed before decimal.";
                alert(AlertMsg);
                ReadingTextBox.value="";
                ReadingTextBox.focus();
                return false;
            }
           if(MinusIndex!=-1)
           {
                if(ReadingValue.substring(MinusIndex,ReadingValue.length).length>BeforeDecimal+1)
                {
                    AlertMsg="Maximum "+BeforeDecimal+" digits are allowed before decimal.";
                    alert(AlertMsg);
                    ReadingTextBox.value="";
                    ReadingTextBox.focus();
                    return false;
                    
                }
           }
       
    }
    else
    {
        if(ReadingValue.substring(0,DecimalIndex)>myMaxvalue)
        {
            AlertMsg="Maximum "+BeforeDecimal+" digits are allowed before decimal.";
            alert(AlertMsg);
            ReadingTextBox.value="";
            ReadingTextBox.focus();
            return false;
        }
        
         if(MinusIndex!=-1)
         {
            if(ReadingValue.substring(MinusIndex,DecimalIndex).length>BeforeDecimal+1)
            {
                AlertMsg="Maximum "+BeforeDecimal+" digits are allowed before decimal.";
                alert(AlertMsg);
                ReadingTextBox.value="";
                ReadingTextBox.focus();
                return false;
                
            }
         }
        if(ReadingValue.substring(DecimalIndex,ReadingValue.length).length>AfterDecimal+1)
        {
            AlertMsg="Maximum "+AfterDecimal+" digits are allowed after decimal.";
            alert(AlertMsg);
            ReadingTextBox.value="";
            ReadingTextBox.focus();
            return false;
        }
       
    }
}
function doGetCaretPosition (ctrl) 
{
	var CaretPos = 0;	// IE Support
	if (document.selection)
	{
		ctrl.focus ();
		var Sel = document.selection.createRange ();
		Sel.moveStart ('character', -ctrl.value.length);
		CaretPos = Sel.text.length;
	}
	// Firefox support
	else if (ctrl.selectionStart || ctrl.selectionStart == '0')
		CaretPos = ctrl.selectionStart;
	return CaretPos;
}


//GridRefresh 
function IndexGridRefresh(ErrorNo,ErrorMessage,RecID,MyGridId)
{
     ErrorMessage=ErrorMessage.replace(/~/g,"'") //regular Expression for replacing ' 
     var Myerror=ErrorNo+"&"+ErrorMessage+"&"+RecID;
   __doPostBack(MyGridId,Myerror)  //Sending EventArgs  
				
       var MyGrid=document.getElementById(MyGridId);
       var MyCheck=MyGrid.getElementsByTagName("input");
       for(i=0;i<MyCheck.length;i++)            //For Clearing the CheckBoxes
        {
            element = MyCheck[i];
            if(element.type=='checkbox')
               { 
                    if(element.checked==true)
                        element.checked = false;
                    
               }
                
        }
        return false;
}   

// Code Added by Shweta //
// Functions added to get Building drop down binded and selected after searching in INMD Registry //
// For defect 2503 //
var MyBuildingSelectedValue='';
function GetBuildingDropDownItems(MyCurrentValue,MyDropDownControl)
{ 
	  var val=MyCurrentValue;
	  MyCurrentDropDownControlID=getElementByID(MyDropDownControl);
	  
	  if(val!="")
	  {      
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			{
				 alert ("Browser does not support HTTP Request")
				 return
			} 
			var url="ReturnBuildingNames.ashx";
			url=url+"?val="+val;
			url=url+"&sid="+Math.random();
			xmlHttp.onreadystatechange = DropDownBuildingStateChanged;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
	  }
	  else
	  {
	        ResetDropDown(MyDropDownControl); 
	  }
}

function DropDownBuildingStateChanged() 
{ 
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 {     
		  //if(xmlHttp.responseText!="") return false    
		  var strHTTP=xmlHttp.responseText;
		  if(strHTTP=="Not Found")
		  {  
				alert("Data Not found"); 
		  }
		  else
		  {
	            BindDropDown(MyCurrentDropDownControlID,strHTTP);  
		        if(MyBuildingSelectedValue!='')
	            {
	                if(document.getElementById(MyCurrentDropDownControlID)!=null)
                    {
                    SetSelectedIndex(document.getElementById(MyCurrentDropDownControlID),MyBuildingSelectedValue);
                    }
                }
		  }
	 } 
}

function SetSelectedIndex(MyDropDownControl, ControlValue) 
{
    for ( var i = 0; i < MyDropDownControl.options.length; i++ ) 
    {
        if ( MyDropDownControl.options[i].value == ControlValue ) 
        {
            MyDropDownControl.options[i].selected = true;
            return;
        }
    }
}


