﻿  
    var PreviousFile = 0,DivNumberCount = 0,DivNumberValue=0,lblpendingVal ="",lblModifiedDate=""
    var PresentationInfo = "",PrivatePresCount = 0,range = 0,GuestUserIDName,GuestID,GuestName,GuestIDEnc;
    var Validation = true,Active = 1;     
    var FileArray = new Array(10),FileArrayIndex = 0,startCount=11,countincrement=0;
    
    var pnlMultipleUploadIndex = 0,pnlMultipleUploadIDs="",arrpnlMultipleUpload = new Array(100);
    var arrNewpnlMultipleUpload = new Array(100);
    var countBars=0;
  
    
    // The function is for getting the presentation DIV to be uploaded.
   
    function GetUploadDivs(FileName,FileSize,FileModifiedDate,PfileName,pExtension)
    { 
    //          try
    //          {
         
        
        if(DivNumberCount > TotalFiles)
        {
          DivNumberCount = DivNumberCount - 1;
          return;
        }
        
        DivNumberValue++;
        pnlMultipleUploadIndex++;
        
        pnlMultipleUploadIDs = pnlMultipleUploadIDs + "pnlMultipleUpload" + pnlMultipleUploadIndex+",";
        
        oXMLHTTP=GetXmlHttpObject();
        //for pre
        var url= m_strUploadURL + 'multipleupload/MultipleUploadDiv.aspx?DivNumberVal= '+DivNumberValue+'&PresentationName='+FileName+'&PresentationSize='+FileSize+'&PresentationModifiedDate='+FileModifiedDate+'&PRfileName='+PfileName+'&PRExtension='+pExtension;            
        //for local
        //var url= m_strUploadURL+'MultipleUploadDiv.aspx?DivNumberVal= '+DivNumberValue+'&PresentationName='+FileName+'&PresentationSize='+FileSize+'&PresentationModifiedDate='+FileModifiedDate+'&PRfileName='+PfileName+'&PRExtension='+pExtension;            
        oXMLHTTP.onreadystatechange=stateChanged;
        oXMLHTTP.open ('GET',url,true);
        oXMLHTTP.send (null);
    //          } 
    //          catch(ex)
    //          {
    //           alert(ex.description);
    //          } 
    }
  
    function stateChanged()
    {
      
        if (oXMLHTTP.readyState==4 || oXMLHTTP.readyState=="complete")
        {
             var txt = oXMLHTTP.responseText;                
             var sIndex = txt.indexOf("<div1>");
             var LIndex = txt.indexOf("</div1>")-1;                 
             txt = txt.substring(sIndex,LIndex);
             
             var myDiv = document.getElementById("mainParentDiv");
             var newLabel = document.createElement("DIV");
             newLabel.innerHTML = txt;
             myDiv.appendChild(newLabel);
             myDiv.focus();
              document.getElementById("UploadButton").style.display = "block";
              
             while(DivNumberCount < TotalFiles)
             {
               DisplayDivs();
               break;
             }
             
               var Width = document.getElementById("outer").offsetWidth;
               var Height = document.getElementById("outer").offsetHeight
               if(DivNumberCount>1)
               window.scrollTo(Width,Height);
         }
    }    
        /* HTTPRequest Object Declaration */
    function GetXmlHttpObject()
    {
        return (window.XMLHttpRequest)?(new XMLHttpRequest()):(new ActiveXObject("Microsoft.XMLHTTP"));
    }
    
    //GetProgressBarDiv(k,FileSizeBar,txtTileShort,Sno);
    function GetProgressBarDiv(k,FileSizeBar,txtTileShort,Sno)
    {
        if(txtTileShort != "" && Sno>0 && Sno<=10)
        {
            oXMLHTTP=GetXmlHttpObject();
            //for pre
            var url= m_strUploadURL+'multipleupload/MultipleUploadDiv.aspx?DisplayBarNumber= '+k+'&FileSizeBar='+FileSizeBar+'&txtTileShort='+txtTileShort+'&Sno='+Sno;            
            //for local
            //var url= m_strUploadURL+'MultipleUploadDiv.aspx?DisplayBarNumber= '+k+'&FileSizeBar='+FileSizeBar+'&txtTileShort='+txtTileShort+'&Sno='+Sno;            
            oXMLHTTP.onreadystatechange=stateChangedBar;
            oXMLHTTP.open ('GET',url,true);
            oXMLHTTP.send (null);
        }
    }
    
    function stateChangedBar()
    {
        if (oXMLHTTP.readyState==4 || oXMLHTTP.readyState=="complete")
        {
             var txt = oXMLHTTP.responseText;                
             var sIndex = txt.indexOf("<div2>");
             var LIndex = txt.indexOf("</div2>")-1;  
             
             txt = txt.substring(sIndex,LIndex);   
           
             var myDiv = document.getElementById("mainDisplayBar");
             
             var newLabel = document.createElement("DIV");
             
             newLabel.innerHTML = txt;
             myDiv.appendChild(newLabel);
            
             if(countBars  == arrSerailNumberIDs.length-1)
             {
               UploadPresentation();
             }
             
             
             while(countBars < arrSerailNumberIDs.length - 1)
             {
                countBars++;
                if(countBars<=10)
                {
                  GetProgressBarDiv(arrProgressBarNumberIds[countBars],arrFileSizeBarIds[countBars],arrtxtTitleShortIds[countBars],arrSerailNumberIDs[countBars])
                }
                break;
             }
             
         }
    }    
    
    function CloseMultipleDiv(crossId)
    {

      var lengthOfCross;var DivNumber;var SelectDiv;
      if(Active == 0)
      { 
       return;
      }
      
      lengthOfCross = crossId.id.length;
      DivNumber = crossId.id.substring(12,lengthOfCross);
      
      pnlMultipleUploadIDs = pnlMultipleUploadIDs.replace("pnlMultipleUpload"+DivNumber,'');
      
      SelectDiv = "pnlMultipleUpload" + DivNumber;
    
      DivNumberCount = Number(DivNumberCount) - 1;
      
      if(DivNumberCount == 0)
      {
        document.getElementById("UploadButton").style.display = "none";
        document.getElementById('guideDiv').style.display ="none";
      }
      
      PreviousFile = Number(PreviousFile) - 1;
                  
      document.getElementById(SelectDiv).style.display = "none";
            
      //removeFiles = removeFiles + document.getElementById("filemodificationdate"+DivNumber).value+",";
      
      var removeFileParam = document.getElementById("filemodificationdate"+DivNumber).value;    
      
      thisMovie("multipleFileUpload").myFlexFunction(removeFileParam,"",'no');
    }
        
    function trimString(str) 
    {
         str = this != window? this : str;
         return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
    }
   
    var modifiedArrayDate = new Array(11);
    var pendingDiv = new Array(11);

    
    // The page redirect to Successfull page after uploading all ppt's.
    function RedirectPage()
    {        
        var is_ie6 = (agt.indexOf("msie 6.")!=-1);        
        if(!is_ie6)
        {
            if(document.cookie.indexOf('loggedIn')==-1)
            {               
               var myDate=new Date();
               myDate.setDate(myDate.getDate() + 365);
               document.cookie='GuestMemberID=' + GuestID + '; domain='+UploadDomain+''  + '; expires=' + myDate + '; path=/'; 
               document.cookie='GuestUserName=' + GuestName + '; domain='+UploadDomain+''  + '; expires=' + myDate + '; path=/';
               document.cookie='asNewGuestMemberID=' + GuestIDEnc + '; domain='+UploadDomain+''  + '; expires=' + myDate + '; path=/';
            }
        }
        PresentationCount = 0;
        location.href = m_strServerURL + 'Upload-presentation-successful/multipleupload';
    }
    
//     function CookieEncrypt_Callback(Response)
//     {
//       var cookVal = Response.value;
//       var myDate=new Date();
//       myDate.setDate(myDate.getDate() + 365);
//       document.cookie='asNewGuestMemberID=' + cookVal + '; domain='+UploadDomain+''  + '; expires=' + myDate + '; path=/';       
//       alert(readCookie('asNewGuestMemberID')+'  aa');
//     }
     
   
     
     function readCookie(name) 
     {
	    var nameEQ = name + "=";
	    var ca = document.cookie.split(';');
	    for(var i=0;i < ca.length;i++) 
	    {
		    var c = ca[i];
		    while (c.charAt(0)==' ') c = c.substring(1,c.length);
	     	if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	    }
	    return null;
     }

    
    // The function is used for displaying the progress bar's.
    function Displaybar(BarNumber,byteStream,TotalFileSize,modifiedDate,LastmodifiedDate)
    {
        
        var PercentBar,numberBar;
        var PreBarNumber;
        PreBarNumber = BarNumber - 1 ;
        numberBar = pendingDiv[PreBarNumber].substring(10,pendingDiv[PreBarNumber].length);
        document.getElementById("imgUploading"+numberBar).style.display = "none";
        document.getElementById("imgUploaded"+numberBar).style.display = "block";
        document.getElementById(pendingDiv[BarNumber]).style.display = "none";
        document.getElementById("fright"+numberBar).style.paddingRight = "19px";
        numberBar = pendingDiv[BarNumber].substring(10,pendingDiv[BarNumber].length);
        document.getElementById("imgUploading"+numberBar).style.display = "block";
        document.getElementById("fright"+numberBar).style.paddingRight ="0px";
        PercentBar = (byteStream/TotalFileSize) * 100;
        document.getElementById("PercentageValue").innerHTML = Math.round(PercentBar*100)/100 + "%";
        if(document.getElementById("ProgressPercent"))
        document.getElementById("ProgressPercent").style.width = Math.round(PercentBar*100)/100+"%";
        if(modifiedDate == LastmodifiedDate &&  byteStream == TotalFileSize)
        { 
            document.getElementById("imgUploading"+numberBar).style.display = "none";
            document.getElementById("imgUploaded"+numberBar).style.display = "block";
            document.getElementById("fright"+numberBar).style.paddingRight ="19px";
           setTimeout("RedirectPage()",10000);
        }
    }
    
    // Call by MultipleFileUpload swf file which send the information for each file(ModifiedDate,byteStream,TotalFileSize).

    function progress(modifiedDate,byteStream,TotalFileSize)
    {
    //       try
    //       {
        var Percent,number;
        modifiedArrayDate = lblModifiedDate.split('>');
        pendingDiv =  lblpendingVal.split('>');
        LastmodifiedDate = modifiedArrayDate[modifiedArrayDate.length-1];

        switch(modifiedDate)
        {
            case modifiedArrayDate[0]:
                number = pendingDiv[0].substring(10,pendingDiv[0].length);
                document.getElementById("imgUploading"+number).style.display = "block";
                document.getElementById(pendingDiv[0]).style.display = "none";
                document.getElementById("fright"+number).style.paddingLeft ="60px";
                Percent = (byteStream/TotalFileSize) * 100;
                document.getElementById("PercentageValue").innerHTML = Math.round(Percent*100)/100 + "%";
                document.getElementById("ProgressPercent").style.width = Math.round(Percent*100)/100+"%";
            if(modifiedDate == LastmodifiedDate &&  byteStream == TotalFileSize)
            {
                document.getElementById("imgUploading"+number).style.display = "none";
                document.getElementById("imgUploaded"+number).style.display = "block";
                document.getElementById("fright"+number).style.paddingLeft ="60px";
                setTimeout("RedirectPage()",10000);
            }
            break;
            case modifiedArrayDate[1]:
                 Displaybar(1,byteStream,TotalFileSize,modifiedDate,LastmodifiedDate);
            break;
            case modifiedArrayDate[2]:
                 Displaybar(2,byteStream,TotalFileSize,modifiedDate,LastmodifiedDate);
            break;
            case modifiedArrayDate[3]:
                 Displaybar(3,byteStream,TotalFileSize,modifiedDate,LastmodifiedDate);
            break;
            case modifiedArrayDate[4]:
                 Displaybar(4,byteStream,TotalFileSize,modifiedDate,LastmodifiedDate);
            break;
            case modifiedArrayDate[5]:
                 Displaybar(5,byteStream,TotalFileSize,modifiedDate,LastmodifiedDate);
            break;
            case modifiedArrayDate[6]:
                 Displaybar(6,byteStream,TotalFileSize,modifiedDate,LastmodifiedDate);
            break;
            case modifiedArrayDate[7]:
                 Displaybar(7,byteStream,TotalFileSize,modifiedDate,LastmodifiedDate);
            break;
            case modifiedArrayDate[8]:
                 Displaybar(8,byteStream,TotalFileSize,modifiedDate,LastmodifiedDate);
            break;
            case modifiedArrayDate[9]:
                 Displaybar(9,byteStream,TotalFileSize,modifiedDate,LastmodifiedDate);
            break;
        }
    }
		
        var j;
        var arr = new Array(11);
        var arroFile = new Array(5);
        var arroFileStart = new Array(5);
        var PresentationFilename="";
        var FileExtension="";
        var ModifiedDate="",ModifiedDateStart="";
        
        // function called by swf file which send the Presentation information like pptname,extension,modified date etc
        // information is received on the fileList variable separated by '|'
        
        function fileList(fileList)
        { 
//         try
//         {
                        
          if(fileList == "")
          return;
          
         j = 0;
         var SelectedFiles;
         var countFiles = 0;
         fileList = fileList.substring(0,fileList.length - 1);
         arr = fileList.split('|');
         ModifiedDateStart = "";
         for(var jStart = 0 ; jStart<arr.length;jStart++)
         {
            arroFileStart = arr[jStart].split(',');  
            ModifiedDateStart = ModifiedDateStart + arroFileStart[3] + ",";
         }         
         
         ModifiedDateStart = ModifiedDateStart.substring(0,ModifiedDateStart.length - 1);
         
         if(arr.length > 10 )
         {
           thisMovie("multipleFileUpload").myFlexFunction(ModifiedDateStart,"",'no');
           alert("You can't upload more than 10 files at a time");
           if(DivNumberCount == 0)
           {
               document.getElementById("UploadButton").style.display = "none";
               document.getElementById("guideDiv").style.display = "none";
           }
           return;
         }   
         else
         {
           SelectedFiles = arr.length;
//           document.getElementById("UploadButton").style.display = "block";
         }
         
         PreviousFile = PreviousFile + SelectedFiles;
         
         if(PreviousFile > 10)
         {
           PreviousFile = 9;
           TotalFiles = 10;
           range = 1;
         }
         else
         {
          range = 0; 
         }
         
         if(range == 1)
         {
            PreviousFile  = DivNumberCount;
            thisMovie("multipleFileUpload").myFlexFunction(ModifiedDateStart,"",'no');
            
            if(PreviousFile >= 10)
            {
             alert("You can't upload more than 10 files at a time.");
            }
            else
            {
              alert("You can't upload more than 10 files at a time.Select only "+(10 - Number(PreviousFile)) + " more file(s) to get a total of 10 (Maximum files allowed in one go).");
            }
            return;
         }
         
         TotalFiles = PreviousFile;
         arroFile = arr[j].split(',');
         j++;
             
         DivNumberCount++ ;
         
         FileExtension = arroFile[1].substring(arroFile[1].lastIndexOf('.')+1,arroFile[1].length);
         
         //alert("FileExtension" + FileExtension);
         
         arroFile[1] = arroFile[1].substring(0,arroFile[1].lastIndexOf('.'));
         PresentationFilename = arroFile[1];
         ModifiedDate = arroFile[3].replace('+','_');
         
         GetUploadDivs(arroFile[1],arroFile[2],ModifiedDate,PresentationFilename,FileExtension);
        
         
         document.getElementById("guideDiv").style.display="block";
//         }
//         catch(ex)
//         {
//          alert(ex.description);
//         }
         
        }
        
        function DisplayDivs()
        {
            
            if(!arr[j])
            {
              try
              {
                return;  
              }
              catch(ex)
              {
               
              }
            }
             arroFile = arr[j].split(',');
             j++;
             DivNumberCount++ ;
             FileExtension = arroFile[1].substring(arroFile[1].lastIndexOf('.')+1,arroFile[1].length);
             arroFile[1] = arroFile[1].substring(0,arroFile[1].lastIndexOf('.'));
             PresentationFilename = arroFile[1];
             ModifiedDate = arroFile[3].replace('+','_');
             GetUploadDivs(arroFile[1],arroFile[2],ModifiedDate,PresentationFilename,FileExtension);
        }


        // Function for validating the Uploading on submit button
        
        var validateUploadvar = false;
        function ValidateUpload(varValCookEncr,CompVal)
        { 
           var Validation = true;
           if (varValCookEncr != null && varValCookEncr != 'undefined' && CompVal != null && CompVal != 'undefined')
           {
                Validation = ValidateCookie(varValCookEncr,CompVal);
           }
           if(validateUploadvar == true)
           {
             return false;
           }
            var fileUpload,title,tags,count = 0,strExtm,validErrTitle=0,validErrTag=0;titlefocus="",tagfocus="";
            var iTags = "~`!@#%^&*()+=[]\\\'./{}|\":<>?_";
            
            var lenCount=0;
        //          try
        //          {      
            
            arrpnlMultipleUpload = pnlMultipleUploadIDs.split(',');
            
            for(var len = 0;len<pnlMultipleUploadIndex;len++)
            {
              arrNewpnlMultipleUpload[len]="";
              if(arrpnlMultipleUpload[len] != "")
              {
               arrNewpnlMultipleUpload[len] = arrpnlMultipleUpload[len];
              }
            }
            
            for(var i=1;i<=pnlMultipleUploadIndex;i++)
            {
                if(document.getElementById(arrNewpnlMultipleUpload[i-1]))
                {
                    fileUpload = document.getElementById("txtTitle" + i);   

                    title = document.getElementById("txtTitle"+i);
                    tags = document.getElementById("txtTags"+i);  
                    lblValidation = document.getElementById("lblValidation"+i);
                    
                    lblTitleError = document.getElementById("lblTitleError"+i);
                    lblTagError = document.getElementById("lblTagError"+i);

                    fileUpload.value = trimString(fileUpload.value); 
                    
                    title.value = trimString(title.value); 
                    tags.value = trimString(tags.value); 

                    lblValidation.innerHTML= "";
                    
                    lblTitleError.innerHTML = "";
                    lblTagError.innerHTML="";

                    if(fileUpload.value == "")
                    {
                        Validation = false;
                        fileUpload.style.border = "2px solid #D00B0B";
                        lblTitleError.style.display ='none';
                    }
                    
                     if (title.value == "")
                    {
                            Validation = false;
                            title.style.border = "2px solid #D00B0B";
                    }
                    else
                    {
                            title.style.border = "1px solid #c5c5c5";   
                            title.className = "inputfield2"; 

                            if(title.value.indexOf("<") >= 0 || title.value.indexOf(">") >= 0 )
                            {
                                Validation = false;
                                title.style.border = "2px solid #D00B0B";
                                lblTitleError.style.display ='block';
                                lblTitleError.innerHTML = "*Invalid characters in presentation title.";
                                if(titlefocus == "")
                                titlefocus = title;
                                validErrTitle = 1;
                            }
                            else
                            {
                              lblTitleError.style.display ='none';
                              validErrTitle = 0;
                            }
                            
                    }  

                    if (Validation == false)
                    {                  
                        
                        if (title.value == "" || fileUpload.value == "")
                        {
                         lblValidation.style.display ='block';
                         lblValidation.innerHTML ="*Some fields were missed. Please check below fields marked with red.";
                         if(titlefocus == "")
                         titlefocus = title;
                         validErrTag = 1;
                        }
                        else
                        {
                            lblValidation.style.display = 'none'; 
                            lblValidation.innerHTML = "";
                            validErrTag = 0;
                        }

                    }
                    else
                    { 
                        lblValidation.style.display = 'none';
                        lblValidation.innerHTML = "";
                    }       

                if(tags.value!="")
                {
                    for (var j = 0; j < tags.value.length; j++) 
                    {
                        if (iTags.indexOf(tags.value.charAt(j)) != -1) 
                        {
                            Error = false;
                            Validation = false;
                            tags.style.border = "2px solid #D00B0B";
                            
                            if(validErrTag == 1 || validErrTitle == 1)
                            {
                              lblValidation.style.width = "100%";
                              lblTitleError.style.width = "100%";
                              lblTagError.innerHTML = "*Special characters are not allowed in presentation tags.";
                            }
                            else
                             lblTagError.innerHTML = "*Special characters are not allowed in presentation tags.";
                             
                             if(tagfocus == "")
                             tagfocus = tags;
                            
                            break;
                        }
                        else
                        {
                             tags.style.border = "1px solid #c5c5c5";   
                             tags.className = "inputfield2";
                        }
                    } 
                } 
                else
                {
                        tags.style.border = "1px solid #c5c5c5";   
                        tags.className = "inputfield2";
                }                    

            }
        } //for loop end here   
        
        if(titlefocus != "")
        {
        
          titlefocus.focus();
          
        }
        
        if(tagfocus != "")
        {
          tagfocus.focus();
           
        }
        
        
            var PrivateCount = 0;
            for(var k=1;k<=pnlMultipleUploadIndex;k++)
            {
              if(document.getElementById(arrNewpnlMultipleUpload[k-1]))
              {
                if(document.getElementById("chkPrivate"+k)!=null && document.getElementById("chkPrivate"+k)!='undefined')
                 {
                    if(document.getElementById("chkPrivate"+k).checked==true)
                    PrivateCount++;
                 }
              }
            }     
            
            var MaxPrivatePresCount = strMaxPrivatePresCount;
            var AvailablePresCount = strAvailablePresCount;
            
            if(MaxPrivatePresCount == "" && AvailablePresCount == "")
            {
             
            }
            else
            {
                 if(Number(PrivateCount) > Number(AvailablePresCount))
                 {
                   document.getElementById("divPrivateMsg").style.display = "block";
                   document.getElementById('lblPrivateErrMsg').innerHTML = "*You have exceeded the limit of your ("+MaxPrivatePresCount+") presentations as Private.To upload more, contact <a href='mailto:support@authorstream.com'>Support</a>.";
                   window.scrollTo(0,0);
                   Validation = false;
                 }  
                 else
                 {
                   document.getElementById("divPrivateMsg").style.display = "none";
                 }
              }
        
        if(Validation == true)
        {
        // 11 Feb 
            try
            {
              Active = 0;
              document.onclick = function(e)
              {
                Active = 0;
              }
              
              PopupShow('ShowLoading','modalBackground');
              
              var is_ie6 = (agt.indexOf("msie 6.")!=-1);
              if(is_ie6)
               {
                    document.getElementById("flashSelect").style.display="none";
               }
               else
               {
                 document.getElementById("flashSelect").style.visibility="hidden";
                 document.getElementById("flashSelect").style.width = "0px";
                 document.getElementById("flashSelect").style.height = "0px";
               }
               
               document.getElementById("disable_btn").style.display="block";
               
            if(document.cookie.indexOf('GuestMemberID') == -1)
            {
                if(document.cookie.indexOf('userId') == -1)
                {
                  memberIDvalue = 0
                }
            }   
                if(memberIDvalue == 0)
                {
                   var is_ie6 = (agt.indexOf("msie 6.")!=-1);
                   if(is_ie6)
                   {
                     authorSTREAM.BizLayer.UploadPresentation.GetGuestIDName('IE6',GetUserIDUseNameFunction_Callback);
                   }
                   else
                   {
			         authorSTREAM.BizLayer.UploadPresentation.GetGuestIDName('1',GetUserIDUseNameFunction_Callback);
			       } 
                }
                else
                {
                        GuestID = memberIDvalue; 
                        GuestIDEnc = memberIDvalueEncrypted;
                        if(strGuestName!="")
                        {
                          GuestName = strGuestName;
                        }
                        SetProgressBarIds();
                }
            }
            catch(ex)
            {
             //alert(ex.description);
            }
        }
          return false;

        }
        
     function thisMovie(movieName) {
        if (navigator.appName.indexOf("Microsoft") != -1) {
            return window[movieName];
        }
        else 
        {
            return document[movieName];
        }
    }

    function ValidateCookie(varValEncrypt,CompVal) // 1 in case of GuestMemberID , 2 in Case of LoggedIn User
    { 
        var cookValActual = ''; 
        if(CompVal == 1)
        { 
            cookValActual = readCookie("GuestMemberID");
        }
        else if(CompVal == 2)
        {
            cookValActual = readCookie("userId");
        }
        if(cookValActual != varValEncrypt)
        {
            location.href = m_strServerURL + 'SignIn/Dashboard';           
            return false;
        }
        return true
    }
     // The function is called when the submit button is fired for uploading all files.
     function callUpload() 
     {
     try
     {
       
        validateUploadvar = true;
        document.onkeypress = function(e)
        {
            return false;;
        }
        //removeFiles = removeFiles.substring(0,removeFiles.length-1);      
        PresentationInfo = PresentationInfo.substring(0,PresentationInfo.length-1); 
        //alert("PresentationInfo " + PresentationInfo);
        
        
        thisMovie("multipleFileUpload").myFlexFunction("",PresentationInfo,'yes');
      }
      catch(ex)
      {
        //alert(ex.description);
      } 
     }
     
     
     
     
     
     // The function is used for getting the GuestUserName and GuestID.
     function GetUserIDUseNameFunction_Callback(Response)
     {
       var GuestArray = new Array(3);
       GuestUserIDName = Response.value;
       GuestArray = GuestUserIDName.split('~');
       GuestID = GuestArray[0];
       GuestName = GuestArray[1];
       GuestIDEnc = GuestArray[2];
       PopupShow('ShowLoading','modalBackground');
       SetProgressBarIds(); 
     }

       var arrProgressBarNumberIds = new Array(50);
       var arrFileSizeBarIds = new Array(50);
       var arrtxtTitleShortIds = new Array(50);
       var arrSerailNumberIDs = new Array(50);
       

       
       function SetProgressBarIds()
       {
            var serialNo=0,FileSizeBar,TotalSize=0,ProgressBarNumberIds="",SerailNumberIDs="";
            var FileSizeBarIds="",txtTitleShortIds="";
            
            
            for(var k=1;k<=pnlMultipleUploadIndex;k++)
            {
              if(document.getElementById(arrNewpnlMultipleUpload[k-1]))
              {
                 serialNo++;
                 ProgressBarNumberIds = ProgressBarNumberIds + k+",";
                 SerailNumberIDs = SerailNumberIDs + serialNo + ",";
                 
                if(Number(document.getElementById("fileSize"+k).value)/1048576 >= 1 )
                {
                
                  FileSizeBar = Math.round((Number(document.getElementById("fileSize"+k).value)/1048576)*100)/100 + " MB";
                }
                else if(Number(document.getElementById("fileSize"+k).value)/1024 >= 1 )
                {
                  FileSizeBar = Math.round((Number(document.getElementById("fileSize"+k).value)/1024)*100)/100 + " KB";
                }
                else
                {
                  FileSizeBar = document.getElementById("fileSize"+k).value+ " byte";
                }
                
                TotalSize = TotalSize + Number(document.getElementById("fileSize"+k).value);
                
                var txtTileShort = ShortString(document.getElementById("txtTitle"+k).value);
                
                FileSizeBarIds=FileSizeBarIds+FileSizeBar+",";
                txtTitleShortIds=txtTitleShortIds+txtTileShort + ",";
                
              }
            }   
            
             if(TotalSize > 1073741824)
             {
                document.getElementById("ShowLoading").style.display = "none";
                PopupClose();
                alert("The file size exceed 1GB limit,please remove some files.");
                return ;
             }
            
            ProgressBarNumberIds = ProgressBarNumberIds.substring(0,ProgressBarNumberIds.length-1);
            arrProgressBarNumberIds = ProgressBarNumberIds.split(',');
               
            FileSizeBarIds = FileSizeBarIds.substring(0,FileSizeBarIds.length-1);
            arrFileSizeBarIds = FileSizeBarIds.split(',');
               
            txtTitleShortIds = txtTitleShortIds.substring(0,txtTitleShortIds.length-1);
            arrtxtTitleShortIds = txtTitleShortIds.split(',');
               
            SerailNumberIDs = SerailNumberIDs.substring(0,SerailNumberIDs.length-1);
            arrSerailNumberIDs = SerailNumberIDs.split(',');
                           
            GetProgressBarDiv(arrProgressBarNumberIds[countBars],arrFileSizeBarIds[countBars],arrtxtTitleShortIds[countBars],arrSerailNumberIDs[countBars])
           
       }
       
        var PresentationCount = 0;
       function UploadPresentation()
       {
           var DivExist,PPtTitle="",Category="",CategoryName="",PPTName="",PPTags="",Private="";
           var Sno = 0,PTitle="",PCategory="",PCatName="",PName="",Ptag="",Pprivate="",PrentationFileName="";
           var PrentationExtension="",AllowDownload="",AllowDownloadPremium="",Emails="",ChannelIDs="",LicenseIDs="";
                        
            for(var k=1;k<=pnlMultipleUploadIndex;k++)
            {
              if(document.getElementById(arrNewpnlMultipleUpload[k-1]))
              {
//                if(document.getElementById("chkPrivate"+k)!=null && document.getElementById("chkPrivate"+k)!='undefined')
//                 {
//                    if(document.getElementById("chkPrivate"+k).checked==true)
//                    PrivateCount++;
//                 }
                    PresentationCount = PresentationCount + 1;                      
                    lblpendingVal = lblpendingVal + "lblpending" + k + ">";
                    lblModifiedDate  = lblModifiedDate  +   document.getElementById("filemodificationdate" + k).value + ">" ;
                    var w = document.getElementById("category"+k).selectedIndex;
                    PTitle = trimString(document.getElementById("txtTitle"+k).value);
                    PCategory = document.getElementById("category"+k).options[document.getElementById("category"+k).selectedIndex].value;
                    PCatName = document.getElementById("category"+k).options[w].text;
                    Ptag = trimString(document.getElementById("txtTags"+k).value);
                    Pprivate= document.getElementById("chkPrivate"+k).checked;
                    AllowDownload = document.getElementById("chkAllowDownload"+k).checked; 
                    AllowDownloadPremium = document.getElementById("chAllowPremium"+k).checked; 
                    PrentationFileName = document.getElementById("hdnPFileName"+k).value;
                    PrentationExtension = document.getElementById("hdnPExtension"+k).value;
                    Emails = document.getElementById("hdnEmails"+k).value;
                    ChannelIDs = document.getElementById("ddlChannels"+k).options[document.getElementById("ddlChannels"+k).selectedIndex].value;
                    try{
                    LicenseIDs = document.getElementById("license"+k).options[document.getElementById("license"+k).selectedIndex].value;
                    }
                    catch(Ex){}
                    PresentationInfo = PresentationInfo +  PTitle + ">" + PCategory + ">" + PCatName + ">" + Ptag + ">" + Pprivate + ">" + PrentationFileName + ">" + PrentationExtension + ">" + GuestID + ">" + GuestName + ">" + AllowDownload + ">" + Emails+ ">"+ SessID + ">" + ChannelIDs + ">" + LicenseIDs + ">" + AllowDownloadPremium + ">"+ PresentationCount +"<";
               }
             }
             
           
//            var MaxPrivatePresCount = strMaxPrivatePresCount;
//            var AvailablePresCount = strAvailablePresCount;
//            
//            if(MaxPrivatePresCount == "" && AvailablePresCount == "")
//            {
//             
//            }
//            else
//            {
//                 if(Number(PrivateCount) > Number(AvailablePresCount))
//                 {
//                   document.getElementById("divPrivateMsg").style.display = "block";
//                   document.getElementById('lblPrivateErrMsg').innerHTML = "*You have exceeded the limit of your ("+MaxPrivatePresCount+") presentations as Private.To upload more, contact <a href='mailto:support@authorstream.com'>Support</a>.";
//                   window.scrollTo(0,0);
//                   
//                   document.getElementById("ShowLoading").style.display = "none";
//                   PopupClose();
//                   Validation = false;
//                   
//                 }  
//              }
             
             lblpendingVal = lblpendingVal.substring(0,lblpendingVal.length-1);
             lblModifiedDate = lblModifiedDate.substring(0,lblModifiedDate.length-1);
             
             if(Validation == true)
             {
                  document.getElementById("ShowLoading").style.display = "none";
                  
                  PopupShow('UploadProgressBar','modalBackground');
                  
                  var is_ie6 = (agt.indexOf("msie 6.")!=-1);
                  if(is_ie6)
                   {
                        document.getElementById("flashSelect").style.display="none";
                   }
                   else
                   {
                     document.getElementById("flashSelect").style.visibility="hidden";
                     document.getElementById("flashSelect").style.width = "0px";
                     document.getElementById("flashSelect").style.height = "0px";
                   }
               
                document.getElementById("disable_btn").style.display="block";
                  callUpload();
             }
       }
       
       function ShortString(title)
       {
          var len;
          len = title.length;
          if(len > 20)
          title = title.substring(0,20)+"...";
          return title;
       }
       
// Tags Function
var ctlCurrent;
 var ctlCurrentSelectID;
 var prevVal = "";
 function AutoFill(ctlID, ctlSelectID)
 {    
    ctlCurrent = document.getElementById(ctlID);
    var ctlText = ctlCurrent.value;
    var splitTags = ctlText.split(',');
    var iTagCounter;
    prevVal = "";
    for(iTagCounter=0;iTagCounter<splitTags.length-1;iTagCounter++)
    {
        prevVal = prevVal + trim(splitTags[iTagCounter]," ") + ", ";
    }
    ctlText = splitTags[iTagCounter];
    ctlCurrentSelectID = document.getElementById(ctlSelectID);
    MultipleUpload.AutoFillTags(ctlText,AutoFillTags_Callback);
    
 }
 
 function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
 }

 function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
 }

 function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
 }
 
 function AutoFillTags_Callback(Response)
 {
   
    if(Response.value!="")
    {
        var myTag_array=Response.value.split(",");
        
        var iTagCounter;
        for(iTagCounter=ctlCurrentSelectID.options.length-1;iTagCounter>=0;iTagCounter--)
        {
            ctlCurrentSelectID.remove(iTagCounter);
        }
        
        for(var iTagCounter = 0; iTagCounter < myTag_array.length; iTagCounter++)
        {
            var strOption = myTag_array[iTagCounter].replace('/',' ');
            var myOption = new Option(strOption,strOption,false,true);
            ctlCurrentSelectID.options[ctlCurrentSelectID.length] = myOption;
        }
        
        if(myTag_array.length!=1)
            ctlCurrentSelectID.size = myTag_array.length;
        else
            ctlCurrentSelectID.size = 2;
        
        ctlCurrentSelectID.selectedIndex = 0;
        ctlCurrentSelectID.style.display = 'block';
    }
    else
    {
        var iTagCounter;
        for(iTagCounter=ctlCurrentSelectID.options.length-1;iTagCounter>=0;iTagCounter--)
        {
            ctlCurrentSelectID.remove(iTagCounter);
        }
        ctlCurrentSelectID.style.display = 'none';
    }
 }

 function FillControlValue()
 {
    ctlCurrent.value = prevVal + ctlCurrentSelectID.options[ctlCurrentSelectID.selectedIndex].value + ', '; 
    ctlCurrentSelectID.style.display = 'none';
    ctlCurrent.focus();
     
 }
 
 // Move current cursor position on list box from tags 
 function displayKeyCode(evt, ctlSelect)
 {
 
     var charCode = (evt.which) ? evt.which : event.keyCode
     if(charCode == 40 || charCode == 38)
     {
        if(document.getElementById(ctlSelect).value != "")
        {
          document.getElementById(ctlSelect).selectedIndex = 0;        
          document.getElementById(ctlSelect).focus();   
        }
       
     }
     else if(charCode == 27)
     {
        return false;
     }     
 }
 
 function SelectControlValue(evt)
 {
    ctlCurrent.value = prevVal + ctlCurrentSelectID.options[ctlCurrentSelectID.selectedIndex].value;
 }
 
 // Fill Tags values on enter press on listbox
 function EnterControlValue(evt)
 {
     var charCode = (evt.which) ? evt.which : event.keyCode
     
     if(charCode == 13 || charCode == 9)
     {
        FillControlValue();
        return false;
     }
     else if(charCode == 27)
     {
        HideTagDiv();        
        return false;
     }
     else
     {
        if(charCode == 40)
        {
            if(ctlCurrentSelectID.selectedIndex==ctlCurrentSelectID.size-1)
                ctlCurrent.focus();
                
                
        }
        else if(charCode == 38)
        {
            if(ctlCurrentSelectID.selectedIndex==0)
                ctlCurrent.focus();
                
        }
        else
        {
            ctlCurrent.focus();
            
         }   
             
     }
 }
 
document.onclick = function(e)
{
    HideTagDiv();
}

function HideTagDiv()
{
    try{
        for(var i=0;i<10;i++)
        {
            if(document.getElementById('selectAutoFillTags' +i)!='undefined' && document.getElementById('selectAutoFillTags' +i)!=null)
            {
                document.getElementById('selectAutoFillTags' +i).style.display = 'none';
            }                
        }
    }catch(err){}
}
 
 
 // --------------- Select Contact Details -------------------
var currentHref='aHrefSelect1';
var aHrefNumber = 1;
function ShowDivWithLoader(DivId,show,ctlID)
{
    var Ctl = document.getElementById(DivId);            
    if (Ctl == null)
        return;
    else
    {
        if (show)
        {
            if(ctlID!=null)
                aHrefNumber = ctlID.replace('aHrefSelect','');
                
            currentHref = 'aHrefSelect' + aHrefNumber;
                       
            if(Ctl.style.display == "block")
            {
                Ctl.style.display = "none";
            }
            else
            {
                Ctl.style.display = "block";
                Ctl.style.left = LeftPos(document.getElementById(currentHref),1);
                Ctl.style.top = TopPos(document.getElementById(currentHref),15);
            }
            document.getElementById("tdUpd").style.display="block";
            return true;
        }
        else
        {
            Ctl.style.display = "none";
            document.getElementById("divAdd").style.display="none";
        }
    }
    
}

var currentHref='aHrefSelect1';
var aHrefNumber = 1;
function ShowDiv(DivId,show,ctlID)
{
    var Ctl = document.getElementById(DivId);        
    
    if (Ctl == null)
        return;
    else
    {
        if (show)
        {
            var _strEmails="";    
            if(ctlID!=null)
                aHrefNumber = ctlID.replace('aHrefSelect','');
                
            currentHref = 'aHrefSelect' + aHrefNumber;
            	
            var f = document.getElementById("dlstContacts");
            
            if (f!=null)
            {
                if(f.getElementsByTagName("input") != null)
                {
                    for(var i=0;i<f.getElementsByTagName("input").length;i++ )
                    {
                        if(f.getElementsByTagName("input").item(i).type=='hidden')
                        {
                            if(ctlID!=null)
                            {    
                                var strEmailVal = f.getElementsByTagName("input").item(i).value;                                
                                f.getElementsByTagName("input").item(i+1).checked=false;        

                                if(document.getElementById("hdnEmails" + aHrefNumber).value.indexOf(strEmailVal)!=-1)
	                            {	                    
	                                if(f.getElementsByTagName("input").item(i+1).type=='checkbox')
	                                {
                                        f.getElementsByTagName("input").item(i+1).checked=true;
	                                }
	                            }
	                          
	                        }
	                    }
                        else if(f.getElementsByTagName("input").item(i).type=='checkbox')
                        {
	                        if(f.getElementsByTagName("input").item(i).checked==true)
	                        {
	                            _strEmails = _strEmails + (f.getElementsByTagName("input").item(i).value) +",";
	                            
	                        }
	                    }	            
                    }
                    
                    _strEmails = _strEmails.substring(0,_strEmails.length-1);          
                    
                    if(_strEmails.length>0)
	                {
	                    document.getElementById("hdnEmails" + aHrefNumber).value=_strEmails;
	                    
	                }
	                
	                
                }
            }
            
            if(ctlID!=null)
                Ctl.style.display = "block";
            else
            {
                if(Ctl.style.display == "block")
                    Ctl.style.display = "none";
                else
                    Ctl.style.display = "block";
            }
            Ctl.style.left = LeftPos(document.getElementById(currentHref),1);
            Ctl.style.top = TopPos(document.getElementById(currentHref),15);
            document.getElementById("tdUpd").style.display="none";
            return true;
        }
        else
        {
            Ctl.style.display = "none";
            document.getElementById("divAdd").style.display="none";
        }
    }
    
}


function ShowAddDiv(DivId,show)
{           
    var Ctl=document.getElementById(DivId);
    if(Ctl==null)
        return;
    else
    {
        if(show)
        {                    
            Ctl.style.display="block";
            document.getElementById("divAdd").style.display="block";
            document.getElementById("divContacts").style.display="none";
            document.getElementById("txtContacts").value = "";
            document.getElementById("divAddContactsError").style.visibility = "hidden";
            document.getElementById("divAddContactsError").style.display = "none";
            document.getElementById("divAdd").style.left = LeftPos(document.getElementById(currentHref),1);
            document.getElementById("divAdd").style.top = TopPos(document.getElementById(currentHref),15);
        }
        else
        {
            Ctl.style.display="none";
            document.getElementById("divAdd").style.display="none";
            document.getElementById("divContacts").style.display="block";
        }
    }
}
function checkUncheckAll(theElement, checked) {        
    var theForm = document.form1.elements;       
    var z = 0;        
    for(z=0; z<theForm.length;z++) {
        if(theForm[z].type == 'checkbox' && theForm[z].name != 'chkPrivate')  {
            theForm[z].checked = checked; 
            var EmailId = new String(theForm[z].attributes["onclick"].value);
            EmailId= EmailId.split('"');
            CheckUncheck(theForm[z], EmailId[1]);                               
        }
    }
}
function CheckUncheck(Chk, EmailId)
{
    if ((Chk.checked == undefined) || (Chk.checked == false))
        RemoveContact(EmailId);
    else
        AddContact(EmailId);    
}
function AddContact(EmailId)
{       
   var txtEmail = document.getElementById("hdnEmails" + aHrefNumber);
   

   
   var Emails = new String(txtEmail.value);      
    Emails = Emails.trim();        
    if ((Emails != "") && (Emails.charAt(Emails.length-1) != ",") && (Emails.charAt(Emails.length-1) != ";"))
        Emails = Emails + ", ";            
    txtEmail.value = Emails;           
   if (txtEmail.value.indexOf(EmailId, 0) == -1)
        txtEmail.value = txtEmail.value + " "+ EmailId + ", ";  
                      
       
}
function RemoveContact(EmailId)
{
    var AllEmails = new String(document.getElementById("hdnEmails" + aHrefNumber).value);
    AllEmails = AllEmails.replace(EmailId + ",", "");
    AllEmails = AllEmails.replace("  ", " ");       
    document.getElementById("hdnEmails" + aHrefNumber).value = AllEmails;
  
}   
function openWindow()
{       
   window.open(m_strServerURL + "ImportContacts.aspx",'',"left=0,top=0,width=700,height=600,status=1");                           
} 
function Validate()
{        

    addContact = true;
    var returnValue = true;
    var Control = document.getElementById("txtContacts");                    
    if ((Control.value.trim() == "") || (Control.value.trim() == ",") || (Control.value.trim() == ";"))
    {          
        returnValue = false;
        document.getElementById("divAddContactsError").style.visibility = "visible";
        document.getElementById("divAddContactsError").style.display = "inline";            
        Control.className = "input_txtbox_popup_red";            
        document.getElementById("spBlank").style.visibility = "visible";
        document.getElementById("spBlank").style.display = "inline";
        document.getElementById("spMsg").style.visibility = "hidden";
        document.getElementById("spMsg").style.display = "none";
    }
    else if(IsValidEmails(Control.value) == false)
    {             
        document.getElementById("divAddContactsError").style.visibility = "visible";
        document.getElementById("divAddContactsError").style.display = "inline";  
        document.getElementById("spBlank").style.visibility = "hidden";
        document.getElementById("spBlank").style.display = "none";
        document.getElementById("spMsg").style.visibility = "visible";
        document.getElementById("spMsg").style.display = "inline";
        returnValue = false;
        Control.className = "input_txtbox_popup_red";
    }
    else
    {   
        Control.className = "input_txtbox_popup"; 
        document.getElementById("divAddContactsError").style.visibility = "hidden";
        document.getElementById("divAddContactsError").style.display = "none";           
        document.getElementById("spMsg").style.visibility = "hidden";
        document.getElementById("spMsg").style.display = "none";
    }   
    if(returnValue) 
    {            
        MultipleUpload.AddContacts(document.getElementById("txtContacts").value,Add_CallBack); 
        if(document.getElementById("lblContacts"))
        document.getElementById("lblContacts").style.display = 'none';
        
    }    
    else
        return false;
}

function Add_CallBack(response)
{
    if (response.error != null)
    {    
        //alert(response.error); 
        return;
    }	
    ShowAddDiv('divAdd',false);
    chk();
}

var ctlCurHrefID;
function FillDataList(ctlID)
{

    document.getElementById("tdUpd").style.display="block";
    ShowDivWithLoader('divContacts', true,ctlCurHrefID);
    ctlCurHrefID = ctlID;
    oSelectContactsXMLHTTP=GetXmlHttpObject();
    //for pre
    var url= m_strUploadURL + 'multipleupload/SelectContactsDiv.aspx';
    //for local
    //var url= m_strUploadURL + 'SelectContactsDiv.aspx';
    oSelectContactsXMLHTTP.onreadystatechange=stateChangedSelectContacts;
    oSelectContactsXMLHTTP.open ('GET',url,true);
    oSelectContactsXMLHTTP.send (null);
}

function stateChangedSelectContacts()
{
    if (oSelectContactsXMLHTTP.readyState==4 || oSelectContactsXMLHTTP.readyState=="complete")
    {
         var txt = oSelectContactsXMLHTTP.responseText;
         var sIndex = txt.indexOf("<div1>");
         var LIndex = txt.indexOf("</div1>")-1;
         txt = txt.substring(sIndex,LIndex);
       
         if(trimString(txt)=='<div1>')
         {
            document.getElementById('spnSubmit').style.display='none';
            document.getElementById('divSelectAll').style.display='none';
            document.getElementById('spnLblContacts').style.display='inline';
            document.getElementById("dataListSelectContacts").innerHTML="";            
         }
         else
         {
             document.getElementById("dataListSelectContacts").innerHTML=txt;
             document.getElementById('spnSubmit').style.display='inline';
             document.getElementById('spnLblContacts').style.display='none';
             document.getElementById('divSelectAll').style.display='inline';
         }
         
         
//         if(document.getElementById("dlstContacts")!=null)
//         {
//            if(document.getElementById("lblContacts"))
//            {
//              document.getElementById("lblContacts").style.display="none";
//            }
//         }
//         
//         if(document.getElementById('spnSubmit'))
//         document.getElementById('spnSubmit').style.display='inline';
         
         ShowDiv('divContacts', true,ctlCurHrefID);
         document.getElementById("tdUpd").style.display="none";
    }
}

function IsValidEmails(Emails)
{
    var Emails = new String(Emails);
    Emails = Emails.split(/(,)|(;)/);       
    for (var i =0; i<Emails.length;i++)
    {
        if ((IsValidEmail(Emails[i].trim()) == false) && (Emails[i].trim() != "") && (Emails[i].trim() != ";") && (Emails[i].trim() != ","))
            return false;
    }
    return true;
}     
 
function UpdateImg()
{
    document.getElementById('gif_image').src = m_strServerURL + 'images/loader.gif';
}

function sel_clear_all(val)
{ 
    var f= document.getElementById("dlstContacts");
	
	if(f != null)
	{
	    for(var i=0;i<f.getElementsByTagName("input").length;i++ )
	    {
	      f.getElementsByTagName("input").item(i).checked=val;
        }
    }    
} 

/*//#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 + 'px';
}

/*// #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 + 'px';
}

function CheckKeyCode(e)
{
    if (navigator.appName == 'Microsoft Internet Explorer')
        var KeyPressed = e.keyCode;
    else
        var KeyPressed = e.which;    
    if (KeyPressed == 13)
    {
        document.getElementById("btnAddSubmit").click();                   
    }
    else
        return false;
}

// To show hide 'Select Contacts' link on Private checked
function ShowHideContacts(ctlID, aHrefSelectID)
{
    if(ctlID.checked)
    {
        document.getElementById(aHrefSelectID).style.display='inline';
     }
    else
    {
        document.getElementById(aHrefSelectID).style.display='none';
        if(document.getElementById("divContacts"))
        document.getElementById("divContacts").style.display='none';
        if(document.getElementById("divAdd"))
        document.getElementById("divAdd").style.display='none';
    }
}


// To bind Contact Data list again
function chk()
{
    document.getElementById("tdUpd").style.display="block";
    oSelectContactsXMLHTTP=GetXmlHttpObject();
    //for pre
    var url= m_strUploadURL + 'multipleupload/SelectContactsDiv.aspx';
    //for local
    //var url= m_strUploadURL + 'SelectContactsDiv.aspx';
    oSelectContactsXMLHTTP.onreadystatechange=stateChangedImportContacts;
    oSelectContactsXMLHTTP.open ('GET',url,true);
    oSelectContactsXMLHTTP.send (null);
}

function stateChangedImportContacts()
{
    if (oSelectContactsXMLHTTP.readyState==4 || oSelectContactsXMLHTTP.readyState=="complete")
    {
         var txt = oSelectContactsXMLHTTP.responseText;
         var sIndex = txt.indexOf("<div1>");
         var LIndex = txt.indexOf("</div1>")-1;
         txt = txt.substring(sIndex,LIndex);
         
         if(trimString(txt)=='<div1>')
         {
            document.getElementById('spnSubmit').style.display='none';
            document.getElementById('divSelectAll').style.display='none';
            document.getElementById('spnLblContacts').style.display='inline';
            document.getElementById("dataListSelectContacts").innerHTML="";            
         }
         else
         {
             document.getElementById("dataListSelectContacts").innerHTML=txt;
             document.getElementById('spnSubmit').style.display='inline';
             document.getElementById('spnLblContacts').style.display='none';
             document.getElementById('divSelectAll').style.display='inline';
         }
       
//         document.getElementById("dataListSelectContacts").innerHTML=txt;
//         if(document.getElementById('spnSubmit'))
//         document.getElementById('spnSubmit').style.display='inline';
         document.getElementById("tdUpd").style.display="none";
    }
}


//function CloseContactDiv(privateId,divContactsId)
//{
//  if(document.getElementById(privateId).checked == false)
//  document.getElementById(divContactsId).style.display = "none";
//}

function ShowToolTipDIv(e,id,ctlPlaceID)
{
    document.getElementById(id).style.display='block';    
    document.getElementById(id).style.top = TopPos(document.getElementById(ctlPlaceID),-230);
    document.getElementById(id).style.left = LeftPos(document.getElementById(ctlPlaceID),-214);
}

function HideToolTipDIv(id)
{
    document.getElementById(id).style.display='none';
}

function SetOnCheckedChange(chkInputId,divChan)
{
    if(chkInputId.checked)
    {
         document.getElementById(divChan).style.display = "none";
    }
    else
    {
        document.getElementById(divChan).style.display = "block";
    }
}

function AllowDownloadChk(ctrl,chAllowdownload)
{
  try
  {
      //alert(ctrl.id.substring(ctrl.id.length-1,ctrl.id.length));
     var chPre = chAllowdownload + ctrl.id.substring(ctrl.id.length-1,ctrl.id.length);
      
      //id.disabled='disabled';
      
      if(ctrl.checked==true)
      {
        document.getElementById(chPre).checked = true;
        document.getElementById(chPre).disabled=true;
      }
      else 
      {
        //document.getElementById(chPre).checked = false;
        document.getElementById(chPre).disabled = false;
      }
  }
  catch(Ex)
  {
   //alert(ex);
  }
}
