1//# Generalise function
//# This function will checked or unchecked combobox from grid 
var XmlHttps11;
function sample11()
{
 alert("hello");
}
function checkall(frm)
		{
			var els = frm.elements; 
			for(i=0; i<els.length; i++)
			{ 
				switch(els[i].type)
			{
				case "checkbox":
					if(document.getElementById("chkAll").checked == true)
						els[i].checked = true;
					else
					els[i].checked = false;					
					break;	
			}
		}			
	}
    
   function checkOnlyOne(frm,pid)
		{			     
			var els = frm.elements; 
			for(i=0; i<els.length; i++)
			{ 
				switch(els[i].type)
			{
				case "checkbox":
				    if(els[i].id == "allcheck"+pid+"")
				    {
				        els[i].checked = true;
				        var obj =document.getElementById('hdnProfile');
				        obj.value = document.getElementById('hdnId'+pid).value;
				    }
				    else
				        els[i].checked = false;
					break;
			}
		}			
	}
			
function Reseting(frm)
{
			var els = frm.elements; 
			for(i=0; i<els.length; i++)
			{ 
				if(els[i].type="textbox")
				{
					els[i].value = "";
				}
			}
}
 
// This function will check wether any records selected or not before getting operation Multiple Delete, Multiple Active in active
 function selectchk(frm,optype)
  {
		var flag;
		flag = "false";
		var els = frm.elements; 
		var numerr =""
		for(i=0; i<els.length; i++)
			{ 
			switch(els[i].type)
			{
			case "checkbox":
				if(els[i].checked == true)
				{flag = "true";}
				break;	
			}
		}
		if(flag == 'true')
		{
			if (optype == 'delete')
				{
		 			 return delconfirm('multiple')
				}
			else if(optype == 'active')
				{
					if(confirm(active)==true)
					{
						return true
					}
					else
					{
					 return false;
					}
				}
				else if(optype == 'inactive')		 
				{
					if(confirm(inactive)==true)
					{
						return true;
					}
					else
					{
						return false;
					}
				}
		}
		else
		{
		 alert(selectrecord);
		 return false;
		}
   }

 // this function will ask to user for confirmation of deleting records
function delconfirm(single)
 {

	var msg;
	if(single=='single') 
	{
		msg = singleDel;		    
	}
	else
	{
		msg = multipleDel;
	}
	{
	}
	if(confirm(msg)== true)
	{
		return true;
	}
	else
	{
		return false;
	}
 }
 
function validation(ctrlnm)
{
    if(document.getElementById(ctrlnm).value == "")
    {
        alert('Please Enter The Keyword For Search');
        return false;
    }

    if(isNaN(document.getElementById(ctrlnm).value)==false)
    {
        alert('Please Enter Valid Keyword For Search');
        return false;
    }
    
}

//For Grid Checkbox
function selectedgdchk(gridname) 
{
    var cnt = 0;
    var theGridView = document.getElementById(gridname);  
    for ( var rowCount = 1; rowCount < theGridView.rows.length; rowCount++ ) 
    {
	    if ( theGridView.rows(rowCount).cells(0).children(0)!=null) 
	    {
		    if ( theGridView.rows(rowCount).cells(0).children(0).checked == true ) 
		    {
		       cnt++;
	        }
	    }
    }
   if(cnt == 0)
   {
        alert('Please Select the record!!!');
        return false;
   }
}

function SelectedCity(cltr)
{
    if(document.getElementById(cltr).value != "")
    {
        var varstr = document.getElementById(cltr).value;
        var obj = document.getElementById('jsCity');
        obj.value = varstr;
        alert(varstr);
        //return varstr;
    }
    
}



function CountryGdchk(gridname,country) 
{
    var cnt = 0;
    var theGridView = document.getElementById(gridname);   
    for ( var rowCount = 1; rowCount < theGridView.rows.length; rowCount++ ) 
    {
        if ( theGridView.rows(rowCount).cells(0).children(0)!=null) 
	    {		              
		    if ( theGridView.rows(rowCount).cells(0).children(0).checked == true && theGridView.rows(rowCount).cells(1).innerText == country) 
		    {
		        cnt++;		        
	        }
	    }
	   	    
    }
   if(cnt == 0)
   {
        alert('Please Select the record!!!');
        return false;
   }
}

//grid checkbox
function gridchk(gridname,name)
{
    var cnt = 0;
    var theGridView = document.getElementById(gridname);   
    
    for ( var rowCount =1; rowCount <= theGridView.rows.length; rowCount++ ) 
    {
        var temp =document.getElementById(gridname+'_ctl0'+rowCount+'_chkSelection');
        if (temp!=null) 
	    {
	        if ( temp.checked == true &&  document.getElementById(gridname+'_ctl0'+rowCount+'_hdn').value == name) 
		    {
		        cnt++;
	        }
	    }
	    
    }
   if(cnt == 0)
   {
        alert('Please Select the record!!!');
        return false;
   }
}

function gridchkDelete(gridname,name)
{
//    var cnt = 0;
//    var theGridView = document.getElementById(gridname);   
//    for ( var rowCount =1; rowCount <= theGridView.rows.length; rowCount++ ) 
//    {
//        var temp =document.getElementById(gridname+'_ctl0'+rowCount+'_chkSelection');
//        
//        if (temp!=null) 
//	    {	
//	        //alert(document.getElementById(gridname+'_ctl0'+rowCount+'_hdn').value);
//	        if ( temp.checked == true &&  document.getElementById(gridname+'_ctl0'+rowCount+'_hdn').value == name) 
//		    {
//		        cnt++;		        
//	        }
//	    }	    
//    }
   
    if(!confirm('Are you sure Delete Selected Record(s)!'))
    {
        return false;
    }

}


//grid checkbox for Profile Update
function gridchk11(gridname,name,setupId)
{
    var cnt = 0;
    var theGridView = document.getElementById(gridname);   
    for ( var rowCount =1; rowCount <= theGridView.rows.length; rowCount++ ) 
    {
        var temp =document.getElementById(gridname+'_ctl0'+rowCount+'_chkSelection');
        
        if (temp!=null) 
	    {	
	        //alert(document.getElementById(gridname+'_ctl0'+rowCount+'_hdn').value);
	        if ( temp.checked == true &&  document.getElementById(gridname+'_ctl0'+rowCount+'_hdn').value == name) 
		    {
		        cnt++;		        
	        }
	    }	    
    }
   if(cnt == 0)
   {
        alert('Please Select the record!!!');
        return false;
   }     
}

function callForEdit() //call this function on Edit Home setup...
{
        var fullURL;
        fullURL = parent.document.URL;
        var qryStr = fullURL.substring(fullURL.indexOf('?')+6, fullURL.length);
        var call = qryStr.split('&');
        if(call[0] == "editing")
        {
            var setupId = call[1].substring(call[1].indexOf('=')+1, call[1].length);
            var setupId1 = setupId.split('#');
            callHomeSetupEdit(setupId1[0]);
        }
}
function callHomeSetupEdit(sid)
{
    document.getElementById('Div11').innerHTML = "";
    var url = "frmHomeSetup_Add.aspx?mess=edit&setupId="+sid+"";
    XmlHttp = GetXmlHttpObject(receiveProfiles);
    xmlHttp_Get(XmlHttp, url);
}

function receiveProfiles()
  {  
     var serverResponse ="";   
     
        if (XmlHttp.readyState == 4 || XmlHttp.readyState == 'complete')
        {       
            var str = XmlHttp.responseText; 
            var tables = str.split('##');
            if(str == "1")
            {
                alert('Profile Not Found this Location !!');
                return false;
            }
            else 
            {                           
                document.getElementById('gridPro').innerHTML = tables[0] + tables[1];
                var obj =document.getElementById('hdnProfile');
                obj.value=tables[2];//profile_ID set in hidden variable...
            }
        }
  }

///Move Item From One listbox To Another
function fnMoveItems(lst1,lst2)
{
     var varFromBox = document.all(lst1);
     var varToBox = document.all(lst2); 
     if ((varFromBox != null) && (varToBox != null)) 
     { 
          if(varFromBox.length < 1) 
          {
                alert('There are no items in the source ListBox');
                return false;
          }
          if(varToBox.length >7)
          {
               alert('Select Not More Than 8 Cities');
               return false;
          }
          if(varFromBox.options.selectedIndex == -1) // when no Item is selected the index will be -1
          {
                alert('Please select an Item to move');
                return false;
          }
          for (i=0;i<varToBox.length;i++)
          {
                if(varToBox.options[i].value == varFromBox.options[varFromBox.options.selectedIndex].value)
                {
                    alert('You All Ready Select This City');
                    return false;    
                }
          }
         
          var newOption = new Option(); // Create a new  instance of ListItem 
          newOption.value = varFromBox.options[varFromBox.options.selectedIndex].value;
          newOption.text =  varFromBox.options[varFromBox.options.selectedIndex].text; 
          varToBox.options.add(newOption); //Append the item in Target Listbox
          var Citylst = document.getElementById('lstbxTo');
          var obj = document.getElementById('city');
          obj.value="";
          var CityName=document.getElementById('CityId');
          CityName.value=""; 
          for (i=0;i<Citylst.length;i++)
          {
              if(CityName.value=='')
              {
                 CityName.value = Citylst.options[i].text; 
              }
              else
              {
                    CityName.value +="." +Citylst.options[i].text; 
              }
              
          } 
          for (i=0;i<Citylst.length;i++)
          {
              if(obj.value=='')
              {
                    obj.value = Citylst.options[i].value;
              }
              else
              {
                    obj.value +="." +Citylst.options[i].value;
              }
              
          } 
          //varState.value +="."+ document.getElementById('ddState').value;        
     }
     return false; 
}

function MoveItem()
{
    var fromlst =document.getElementById('lstbxTo');
    if(fromlst != null)
    {
        if(fromlst.options.selectedIndex == -1) // when no Item is selected the index will be -1
        {
            alert('Please select an Item to move');
            return false;
        }
        if(fromlst.length < 1) 
        {
            alert('There are no items in the ListBox');
            return false;
        }
        fromlst.remove(fromlst.options.selectedIndex)
        var Citylst = document.getElementById('lstbxTo');
        if(Citylst.length <8)
        {
               var obj = document.getElementById('city');
               obj.value="";
               for (i=0;i<Citylst.length;i++)
               {
                   if(obj.value=='')
                   {
                        obj.value = Citylst.options[i].value;
                   }
                   else
                   {
                         obj.value +="." +Citylst.options[i].value;
                   }
               }  
        }
    }
    return false;
}

//## Record Added 
function RecordAdded()
{
	alert(RecordAdded);
}
//## Record Added 
function RecordUpdated()
{
	alert(RecordUpdated);
}
function RecordDeleted()
{
	alert(RecordDeleted);
}

function validMessage(ope,frm)
{
	if (ope =='Update')
	{
		alert(RecordUpdated);
		window.open(frm,'_self','');
	}	
	else if(ope =='Add')
	{
		alert(RecordAdded);
		window.open(frm,'_self','');
	}

	else if(ope =='Delete')
	{
		alert(RecordDeleted);
		window.open(frm,'_self','');
	}
}

function Trim(s) 
{
// Remove leading spaces and carriage returns
while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
{
s = s.substring(1,s.length);
}
// Remove trailing spaces and carriage returns
while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
{
s = s.substring(0,s.length-1);
}
return s;
} 

//ele[i].title.replace("*"," ")
