﻿

function OnDeletePhone(Phone,e)
{
	var k;			
	k = e.keyCode;
	if(k==0)
	{
	    k = e.which;
	}		
	if(k == 8 || k == 46 )
	{		
				var Length;
				var str=Phone.value;				
				var newVal;
				str=str.replace("(","");
				str=str.replace(")","");				
				str=str.replace("-","");	
				str=str.replace(" extn. ","");
				str=str.replace(" ","");
				Length=str.length;					
				str=str.substring(0,Length-1)												
				if(Length <= 1)
				{
					Phone.value="";										
				}
				else if(Length <= 4)
				{					
					newVal="("+str+")";					
					Phone.value=newVal;										
				}
				else if(Length <= 7)
				{
					newVal="("+ str.substring(0,3) +")";
					newVal=newVal+" "+ str.substring(3,6);
					Phone.value=newVal;					
				}
				else if(Length <= 11)
				{
					newVal="("+ str.substring(0,3) +")";
					newVal=newVal+" "+ str.substring(3,6);
					newVal=newVal+"-"+ str.substring(6,10);
					Phone.value=newVal;										
				}	
				else if(Length <= 14)
				{					
					newVal="("+ str.substring(0,3) +")";
					newVal=newVal+" "+ str.substring(3,6);
					newVal=newVal+"-"+ str.substring(6,10);					
					newVal=newVal+" extn. "+ str.substring(10,15);										
					Phone.value=newVal;					
				}		
			return false;
	}
}
function setPhone(Phone,e)
		{
			k = e.keyCode;
			if(k==0)
			{
			k = e.which;
			}			
			if(k >= 48 && k <= 57)
			{
				var Length;
				var str=Phone.value+String.fromCharCode(k);				
				var newVal;
				str=str.replace("(","");
				str=str.replace(")","");				
				str=str.replace("-","");	
				str=str.replace(" extn. ","");
				str=str.replace(" ","");
				Length=str.length;
				if(Length <= 3)
				{
					newVal="("+str+")";
					Phone.value=newVal;					
				}
				else if(Length <= 6)
				{
					newVal="("+ str.substring(0,3) +")";
					newVal=newVal+" "+ str.substring(3,6);
					Phone.value=newVal;
				}
				else if(Length <= 10)
				{
					newVal="("+ str.substring(0,3) +")";
					newVal=newVal+" "+ str.substring(3,6);
					newVal=newVal+"-"+ str.substring(6,10);
					Phone.value=newVal;
					
				}	
				else if(Length <= 14)
				{
					newVal="("+ str.substring(0,3) +")";
					newVal=newVal+" "+ str.substring(3,6);
					newVal=newVal+"-"+ str.substring(6,10);					
					newVal=newVal+" extn. "+ str.substring(10,15);										
					Phone.value=newVal;
				}				
				return false;		
			}
			return false;
		}
function setPhoneWithoutExten(Phone,e)
		{
			
			var k;			
			k = e.keyCode;
			if(k==0)
			{
			k = e.which;
			}			
			if(k >= 48 && k <= 57 )
			{
				var Length;
				var str=Phone.value+String.fromCharCode(k);				
				var newVal;
				str=str.replace("(","");
				str=str.replace(")","");				
				str=str.replace("-","");	
				str=str.replace(" extn. ","");
				str=str.replace(" ","");
				Length=str.length;
				if(Length <= 3)
				{
					newVal="("+str+")";
					Phone.value=newVal;					
				}
				else if(Length <= 6)
				{
					newVal="("+ str.substring(0,3) +")";
					newVal=newVal+" "+ str.substring(3,6);
					Phone.value=newVal;
				}
				else if(Length <= 10)
				{
					newVal="("+ str.substring(0,3) +")";
					newVal=newVal+" "+ str.substring(3,6);
					newVal=newVal+"-"+ str.substring(6,10);
					Phone.value=newVal;
					
				}					
				return false;		
			}
			return false;
		}
// ---- Functions to check maxlength of a multiline textbox--- //
function doBeforePaste(control)
{
   maxLength = control.attributes["maxLength"].value;
   if(maxLength)
   {
       event.returnValue = false;
   }
}
function doPaste(control)
{
   maxLength = control.attributes["maxLength"].value;
   value = control.value;
   if(maxLength)
   {
        event.returnValue = false;
        maxLength = parseInt(maxLength);
        var o = control.document.selection.createRange();
        var iInsertLength = maxLength - value.length + o.text.length;
        var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
        o.text = sData;       
    }
}

function LimitInput(control)
{
    if(control.value.length > control.attributes["maxLength"].value)
    {
        control.value = control.value.substring(0,control.attributes["maxLength"].value);
    }
};
// ------------------------ End ---------------------------- //

// --------------------- Validate Date --------------------- //
// Declaring valid date character, minimum year and maximum year
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)
{
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.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")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}

function ValidateDate(dt)
{
    dt = document.getElementById(dt);
    if(dt.value!="")
    {
        if (isDate(dt.value)==false)
	    {
		    dt.focus()
		    return false;
	    }
        return true;
    }
    return true;
 }
// ----------------- Validate Date - End --------------------- //


function CheckSelectAll(CheckBox, ctlTargetBaseControl)
{
    var TargetBaseControl = document.getElementById(ctlTargetBaseControl);
    var TargetChildControl = "chkSelect";
    
    var Inputs = TargetBaseControl.getElementsByTagName("input");
    
    for(var n = 0; n < Inputs.length; ++n)
    {
        if(Inputs[n].type == 'checkbox' && Inputs[n].id.indexOf(TargetChildControl,0) >= 0 && Inputs[n].disabled==false)
        {
            Inputs[n].checked = CheckBox.checked;                
        }
    }
}

function CheckSelect(CheckBox,ctlHeaderCheckBox,ctlTargetBaseControl)
{
    TotalChkBx=0;
    Counter=0;
    var TargetBaseControl = document.getElementById(ctlTargetBaseControl);
    var TargetChildControl = CheckBox.id.substr(CheckBox.id.lastIndexOf("_")+1,CheckBox.id.length-1);
    var TargetParentControl = ctlHeaderCheckBox.substr(ctlHeaderCheckBox.lastIndexOf("_")+1,ctlHeaderCheckBox.length-1);
    
    var Inputs = TargetBaseControl.getElementsByTagName("input");
    
    for(var n = 0; n < Inputs.length; ++n)
    {
        if(Inputs[n].type == 'checkbox' && Inputs[n].id.indexOf(TargetChildControl,0) >= 0 && Inputs[n].disabled==false && Inputs[n].id.indexOf(TargetParentControl,0) < 0)
        {
            TotalChkBx++;
            if(Inputs[n].checked==true)
                Counter++;
        }
    }
    
    var HeaderCheckBox = document.getElementById(ctlHeaderCheckBox);
    if(Counter < TotalChkBx)
        HeaderCheckBox.checked = false;
    else if(Counter == TotalChkBx)
        HeaderCheckBox.checked = true;
}

function CheckSelectRecords(ctlTargetBaseControl)
{
    Counter=0;
    var TargetBaseControl = document.getElementById(ctlTargetBaseControl);
    var TargetChildControl = "chkSelect";
    var TargetParentControl = "chkSelectAll";
    
    var Inputs = TargetBaseControl.getElementsByTagName("input");
    
    for(var n = 0; n < Inputs.length; ++n)
    {
        if(Inputs[n].type == 'checkbox' && Inputs[n].id.indexOf(TargetChildControl,0) >= 0 && Inputs[n].disabled==false && Inputs[n].id.indexOf(TargetParentControl,0) < 0)
        {
            if(Inputs[n].checked==true)
                Counter++;
        }
    }
     var ans;
    var flag=false;
    var elements=document.forms[0].elements;
    
    for(i=0;i<elements.length;i++)
    {
        if(elements[i].type== "checkbox" &&  elements[i].id.indexOf('chklistGroup')!=-1)
        {               
            if(elements[i].checked)
            {
                flag = true;        
                break;
            }                   
        }        
    }
    if(!flag)
    {
        alert("Please select Group(s).")
        return false;
    } 
    if(Counter==0)
    {
        alert("Please select record(s)");
        return false;
    }
    return true;
}


// ---------- To select one option in a Grid/Repeater/DataList controls ------------- //
function SelectOneOption(ctlTargetControl,ctlID)
{
    var TargetControl = document.getElementById(ctlTargetControl);
    var Inputs = TargetControl.getElementsByTagName("input");
    
    for(var n = 0; n < Inputs.length; ++n)
    {
        if(Inputs[n].type == 'radio')
        {
            if(Inputs[n].id == ctlID)
                Inputs[n].checked=true;
            else
                Inputs[n].checked=false;
        }
    }
}

function checkForSelectedGallery(ctl)
{
    var cnt = 0;
    var ctlRepeater = document.getElementById(ctl);
    for(i = 0; i < document.forms[0].elements.length; i++)
    {
        var ele;
        ele=document.forms[0].elements[i].type;
        if(ele.toLowerCase()=='checkbox')
        {
            if (document.forms[0].elements[i].checked==true)
            cnt++;   
        }            				
    }			
    if(cnt == 0)
    {
        alert("Please select record(s).");
        return false;	
    }
}





//Select atleast one checkbox

function fnDelete(ctlInitials,IsDelete)
{
    var ans;
    var flag=false;
    var elements=document.forms[0].elements;
    
    for(var j=0;j<elements.length;j++)
    {
        if(elements[j].type== "checkbox")
        {
         if(elements[j].id=='ctl00_MainContent_rptGroups_ctl01_chkSelect' && IsDelete=='1')
            {
            if(elements[j].checked)
            {
                alert("Default Group can not be deleted");
                for(i=0;i<elements.length;i++)
                {
//                    if(elements[i].type== "checkbox")
//                    {
//                        if(elements[i].checked)
//                    }
                }
                return false;
            }
            }
        }
    }
    for(i=0;i<elements.length;i++)
    {
                    
        if(elements[i].type== "checkbox" &&  elements[i].id.indexOf(ctlInitials)!=-1)
        {               
            if(elements[i].checked)
            {
           // alert(elements[i].value);
               
                flag = true;        
                break;
            }                   
        }        
    }
    if(flag)
    {
        if(ctlInitials=='chkSelect'&& IsDelete=='0')
            return true;
        else
        {
            ans=confirm("Are you sure to delete selected record(s)?");
            if (ans==true)
                return true;
            else
            {
                for(i=0;i<elements.length;i++)
                {
                    if(elements[i].type== "checkbox")
                    {
                        if(elements[i].checked)
                            elements[i].checked=false;
                    }        
                }
                return false;
            }
        }
    }
    else
    {
        alert("Please select record(s).")
        return false;
    }    
}




// Get selected rows' ID 
function GetSelectedID(ctlGrid, ctlSpan)
{
    var ID=0;
    var TargetBaseControl = document.getElementById(ctlGrid);
    var Inputs = TargetBaseControl.getElementsByTagName("input");        
    for(var n = 0; n < Inputs.length; ++n)
    {
        if(Inputs[n].type == 'radio')
        {
            if(Inputs[n].checked==true)
            {
                var strRadioID = Inputs[n].id;
                strRadioID = strRadioID.replace(ctlGrid + '_','');
                strRadioID = strRadioID.substr(0,strRadioID.indexOf('_'));
                ID = document.getElementById(ctlGrid + '_' + strRadioID + '_' + ctlSpan).innerHTML;
            }
        }
    }
    return ID;
}

// ------------- Manage Place Holder Admin -------------------- //
function ShowHidePanels(ctl,divFileUploadID,divTextID)
{
    var ddlArtType = $get(ctl);
    var ctlFileUpload = $get(divFileUploadID)
    var ctlText = $get(divTextID)
    if(ddlArtType.options[ddlArtType.selectedIndex].text=="Text")
    {
        ctlFileUpload.style.display='none';
        ctlText.style.display='';
    }
    else if((ddlArtType.options[ddlArtType.selectedIndex].value!="1") && (ddlArtType.options[ddlArtType.selectedIndex].value!="0"))
    {
        ctlFileUpload.style.display='';
        ctlText.style.display='none';
    }
}

// ------------- Manage Template Admin -------------------- //

function LoadScript(ID)
{     //alert(ID);
    flashArgs = new Array(); // 
     /* if need to call function then populate the array */
    flashArgs.push("");
    flashArgs.push("TemplatePreview");
    flashArgs.push("RefreshTemplate");
    flashArgs.push(ID);
    /* end */
    
    AC_FL_RunContent
    (            
        "src", "FlashFiles/Template",
        "width", "362",
        "height", "506",
        "align", "middle",
        "id", "TemplatePreview",
        "quality", "high",
        "bgcolor", "#869ca7",
        "name", "TemplatePreview",
        "flashvars",'wsdlURL=<%=MercuryPrintBLL.CommonFunctions.WebServiceURL %>webservices/Flash.asmx?wsdl&myName=TemplatePreview&tplId=' + ID,
        "allowScriptAccess","sameDomain",
        "type", "application/x-shockwave-flash",
        "pluginspage", "http://www.adobe.com/go/getflashplayer",
        "objectName","divTemplate"
    );
    window.TemplatePreview = document.forms[0].TemplatePreview;
}   

/*//#A 052005 AP: To get the top position of the object*/
function TopPos(obj, pos)
{
    var topCoord = 0;
    while(obj)
    {
       topCoord += obj.offsetTop;
       obj = obj.offsetParent;
    }
    return topCoord + pos;
}

/*// #A 052005 AP: To get the left position of the object*/
function LeftPos(obj, pos)
{
    var leftCoord = 0;
    while(obj)
    {
       leftCoord += obj.offsetLeft;
       obj = obj.offsetParent;
    }
    return leftCoord + pos;
}

//................MessagecharacterCount...............//

function CountCharactersGeneral(sourceTextBox, displayControl, maxLength)
{

    if(sourceTextBox != null && displayControl != null)
    {
           // try
          //  {
                sourceTextBox = document.getElementById(sourceTextBox);
                displayControl = document.getElementById(displayControl);
                if(sourceTextBox != null)
                {
                    var len = sourceTextBox.value.length
                    if (len<=maxLength)
                    {
                        //displayControl.value = maxLength -len;
                        displayControl.innerHTML = maxLength -len + " Character(s) remaining.";
                    }
                    else
                    {
                        sourceTextBox.value = sourceTextBox.value.substring(0, maxLength);
                        return false;
                    }
               }
         //  }
       //   catch(e)
        //   {
        //   alert(e.description):
          // }
    }
}
function GetSharedCheckBoxValue(chkShare,hdnGallries,hdnType,SubmitType,lblGalleryID)
    {    
     
    document.getElementById(hdnType).value=SubmitType;
    var Gallries=document.getElementById(hdnGallries);
     var GalleryID=document.getElementById(lblGalleryID);
     var IsShare=document.getElementById(chkShare);
     if(IsShare.checked==true)// Code if Checkbox Selected
     {
        if(Gallries.value=="")
        {
            Gallries.value=GalleryID.innerHTML;
        }
        else 
        {
            Gallries.value=Gallries.value+ ","+GalleryID.innerHTML;
        }
       
     }
      else // Code if Checkbox Un Selected
      {
        var Gallery_Array =Gallries.value.split(",");
        var IDList="";
        for(iCount=0; iCount<Gallery_Array.length; iCount++)
        {
            if(Gallery_Array[iCount]!=GalleryID.innerHTML)
            {
                if(IDList=="")
                {
                    IDList=Gallery_Array[iCount];
                }
                else 
                {
                    IDList=IDList+ ","+Gallery_Array[iCount];
                }
            }
        }
        Gallries.value=IDList;
         
      } 
    }


    // Function to Save the Selected Galleries IDs & Project IDs in the Hidden Field
    function GetCheckBoxValue(chkShare,hdnGallries,hdnType,SubmitType,lblGalleryID)
    {    
     
    document.getElementById(hdnType).value=SubmitType;
    var Gallries=document.getElementById(hdnGallries);
     var GalleryID=document.getElementById(lblGalleryID);
     var IsShare=document.getElementById(chkShare);
     if(IsShare.checked==true)// Code if Checkbox Selected
     {
        if(Gallries.value=="")
        {
            Gallries.value=GalleryID.innerHTML;
        }
        else 
        {
            Gallries.value=Gallries.value+ ","+GalleryID.innerHTML;
        }
       
     }
      else // Code if Checkbox Un Selected
      {
        var Gallery_Array =Gallries.value.split(",");
        var IDList="";
        for(iCount=0; iCount<Gallery_Array.length; iCount++)
        {
            if(Gallery_Array[iCount]!=GalleryID.innerHTML)
            {
                if(IDList=="")
                {
                    IDList=Gallery_Array[iCount];
                }
                else 
                {
                    IDList=IDList+ ","+Gallery_Array[iCount];
                }
            }
        }
        Gallries.value=IDList;
         
      } 
    }
     function SubmitSharedGallery()
    {
        document.forms.SubmitForm.action="/PhotoPrints.aspx";
        document.forms.SubmitForm.submit();   
    }
    function SubmitData(data)
    {
      
    if(data==1)
    {
         document.forms.SubmitForm.action="/Secure/MyPictures.aspx";
        document.forms.SubmitForm.submit(); 
    }
    else
    {
         document.forms.SubmitForm.action="/Secure/MyProjects.aspx";
        document.forms.SubmitForm.submit(); 
    }
   
    }
    
    
    function SubmitForm()
    {
        document.forms.SubmitForm.action="/Secure/Share.aspx";
        document.forms.SubmitForm.submit();   
    }
  
    function SendToField(hdnValue,lblID)
    {      
        document.getElementById(hdnValue).value=lblID;
      
       SubmitForm();
    }
  
    
    function ShareData(lblID,SubmitType,hdnType,hdnValue)
    {       
        document.getElementById(hdnType).value=SubmitType;
        document.getElementById(hdnValue).value=lblID;
        
       SubmitForm();
    }
    
    
     // Function to Save the Selected Galleries IDs & Project IDs in the Hidden Field
    function GetCheckBoxValueForImagePool(chkBox,hdnGallries,hdnType,SubmitType,lblGalImageID,Label1,ddlGalleries,hdnKey)
    { 
   // debugger;
    document.getElementById(hdnType).value=SubmitType;
    var ddlGalleries=document.getElementById(ddlGalleries);
    document.getElementById(hdnKey).value=ddlGalleries.options[ddlGalleries.selectedIndex].value;
    var Gallries=document.getElementById(hdnGallries);
    var GalleryImageID=document.getElementById(lblGalImageID);
    var ddlGalleries=document.getElementById(ddlGalleries);
     
    
        if(Gallries.value=="")
            Gallries.value=document.getElementById("ctl00_hdnValuesforUnSelection").value;
 
 //  alert( Gallries.value + '  ' +hdnGallries);
    //alert( Label1 + '  ' + document.getElementById(Label1)+ '   ' +document.getElementById(Label1).value);
   // alert(ddlGalleries.options[ddlGalleries.selectedIndex].value);
     var IsShare=document.getElementById(chkBox);
   //   alert( IsShare + '  ' +chkBox);
     if(IsShare.checked==true)// Code if Checkbox Selected
     {
        if(Gallries.value=="")
        {
            Gallries.value=GalleryImageID.innerHTML;
        }
        else 
        {
            Gallries.value=Gallries.value+ ","+GalleryImageID.innerHTML;
        }
     //   alert(Gallries.value);
         //document.getElementById(Label1).value=Gallries.value;
         document.getElementById(Label1).value=Gallries.value;
         document.getElementById(hdnGallries).value=Gallries.value;
     }
      else // Code if Checkbox UnSelected
      {
       if(Gallries.value=="")
        {
       // alert("server " + document.getElementById("ctl00_hdnValuesforUnSelection").value);
            Gallries.value=document.getElementById("ctl00_hdnValuesforUnSelection").value;
        }
       
        var Gallery_Array =Gallries.value.split(",");
        var IDList="";
        for(iCount=0; iCount<Gallery_Array.length; iCount++)
        {
            if(Gallery_Array[iCount]!=GalleryImageID.innerHTML)
            {
                if(IDList=="")
                {
                    IDList=Gallery_Array[iCount];
                }
                else 
                {
                    IDList=IDList+ ","+Gallery_Array[iCount];
                }
            }
        }
        Gallries.value=IDList;
          //  alert(IDList);
             document.getElementById(Label1).value=Gallries.value;
       document.getElementById("ctl00_hdnValuesforUnSelection").value=Gallries.value;
        //alert(gHashPoolValues.get(ddlGalleries.options[ddlGalleries.selectedIndex].value));
       document.getElementById(hdnGallries).value=Gallries.value;
        
      } 
      setbtnNextVisibility();
      
    }
    
    
     // Function to Save the Selected Galleries IDs & Project IDs in the Hidden Field
    function GetCheckBoxValueForProjectPool(chkBox,hdnProjects,hdnType,SubmitType,lblProjectImageID,Label1,ddlProjects,hdnProjectKey)
    {    
   
  //  debugger;
    document.getElementById(hdnType).value=SubmitType;
    var ddlProjects=document.getElementById(ddlProjects);
    document.getElementById(hdnProjectKey).value=ddlProjects.options[ddlProjects.selectedIndex].value;
    var Projects=document.getElementById(hdnProjects);
    var ProjectImageID=document.getElementById(lblProjectImageID);
    
  if(Projects.value=="")
            Projects.value=document.getElementById("ctl00_hdnValuesforUnSelection").value;
     var IsShare=document.getElementById(chkBox);
   //   alert( IsShare + '  ' +chkBox);
     if(IsShare.checked==true)// Code if Checkbox Selected
     {
        if(Projects.value=="")
        {
            Projects.value=ProjectImageID.innerHTML;
        }
        else 
        {
            Projects.value=Projects.value+ ","+ProjectImageID.innerHTML;
        }
      //  alert(Projects.value);
         //document.getElementById(Label1).value=Gallries.value;
         document.getElementById(Label1).value=Projects.value;
        
     }
      else // Code if Checkbox UnSelected
      {
      if(Projects.value=="")
        {
       // alert("server " + document.getElementById("ctl00_hdnProjectValuesforUnSelection").value);
            Projects.value=document.getElementById("ctl00_hdnProjectValuesforUnSelection").value;
        }
      
        var Gallery_Array =Projects.value.split(",");
        var IDList="";
        for(iCount=0; iCount<Gallery_Array.length; iCount++)
        {
            if(Gallery_Array[iCount]!=ProjectImageID.innerHTML)
            {
                if(IDList=="")
                {
                    IDList=Gallery_Array[iCount];
                }
                else 
                {
                    IDList=IDList+ ","+Gallery_Array[iCount];
                }
            }
        }
        Projects.value=IDList;
          //  alert(IDList);
             document.getElementById(Label1).value=Projects.value;
       document.getElementById("ctl00_hdnValuesforUnSelection").value=Projects.value;
        //alert(gHashPoolValues.get(ddlGalleries.options[ddlGalleries.selectedIndex].value));
        document.getElementById(Label1).value=IDList;
        
      } 
      setbtnNextVisibility();
    }
    
    function setbtnNextVisibility()
    {
//     var Gallries=document.getElementById("hdnGallries");
//       var Projects=document.getElementById("hdnProjects" );
// 
//        if (Gallries.value!="" || Projects.value!="")
//        {
//      
//             document.getElementById('ctl00_MainContent_btnInsertImagePool').style.display='block';
//        }
//        else
//        {
//             document.getElementById('ctl00_MainContent_btnInsertImagePool').style.display='none';
//        }
//    
    }
    
/*Add New Contact*/
function fnCheckGroup()
{
    var ans;
    var flag=false;
    var elements=document.forms[0].elements;
    
    for(i=0;i<elements.length;i++)
    {
        if(elements[i].type== "checkbox" &&  elements[i].id.indexOf('chklistGroup')!=-1)
        {               
            if(elements[i].checked)
            {
                flag = true;        
                break;
            }                   
        }        
    }
    if(!flag)
    {
        alert("Please select Group(s).")
        return false;
    } 
    if(Page_ClientValidate())
     return true;
    else
     return false;
}



