﻿// JScript File

    function OpenConversations (UserId)
    {
        window.open("ConversationList.aspx?UserId=" + encodeURIComponent(UserId), "", "resizable=no,toolbar=no,scrollbars=yes,menubar=no,status=no,directories=no,width=760,height=400");
    }
    
    function ConfirmOpenChat(ConvId, UserId, LanguageCode)
    {
        if (confirm("¿Seguro que desea atender la llamada del usuario?")==true)
        {
              OpenChat (ConvId, UserId, LanguageCode);
              return true;
        }
        else
              return false;
    }
    
    function CreateChat (UserId, LanguageCode)
    {
       window.open("AdminChat.aspx?UserId=" + encodeURIComponent(UserId) + "&LanguageCode=" + LanguageCode, "", "resizable=no,toolbar=no,scrollbars=no,menubar=no,status=no,directories=no,width=765,height=503");
    }
    
    function OpenChat (ConvId, UserId, LanguageCode)
    {
       window.open("AdminChat.aspx?ConversationId=" + encodeURIComponent(ConvId) + "&UserId=" + encodeURIComponent(UserId) + "&LanguageCode=" + LanguageCode, "", "resizable=no,toolbar=no,scrollbars=no,menubar=no,status=no,directories=no,width=700,height=510");
    }

    function OpenOperatorDetails(UserId)
    {
        location.href="OperatorDetailsPage.aspx?OperatorId=" + encodeURIComponent(UserId);
    }
    
    function OpenPartnerDetails(PartId)
    {
        location.href="PartnerDetails.aspx?PartId=" + encodeURIComponent(PartId);
    }
       
    function TransferChat (ConvId, UserId)
    {
        window.open("TransferChat.aspx?ConversationId=" + encodeURIComponent(ConvId) + "&UserId=" + encodeURIComponent(UserId), "", "resizable=no,toolbar=no,scrollbars=no,menubar=no,status=no,directories=no,width=380,height=100");
    }
    
     function OpenConversationDetails (ConvId)
    {
       window.open("ConversationDetails.aspx?ConversationId=" + encodeURIComponent(ConvId), "", "resizable=yes,toolbar=no,scrollbars=yes,menubar=no,status=no,directories=no,width=800,height=600");
    }
    
    function OpenSurveyDetails (AnsweredSurveyId)
    {
       window.open("GenericAnsweredSurvey.aspx?AnsweredSurveyId=" + encodeURIComponent(AnsweredSurveyId), "", "resizable=yes,toolbar=no,scrollbars=both,menubar=no,status=no,directories=no,width=800,height=600");
    }
    
    function OpenInvoiceDetails (InvoiceId)
    {
       window.open("Invoice.aspx?InvoiceId=" + encodeURIComponent(InvoiceId), "", "resizable=yes,toolbar=no,scrollbars=yes,menubar=no,status=no,directories=no,width=800,height=600");
    }
    
    function showHide(object)
    {
          if (document.getElementById(object).style.display == 'none')
          {
                document.getElementById(object).style.display = 'block';
          }
          else
          {
                document.getElementById(object).style.display = 'none';
          }
    }
    
    function ShowHideTable(theTable)
    {
          if (document.getElementById(theTable).style.display == 'none')
          {
                document.getElementById(theTable).style.display = 'block';
          }
          else
          {
                document.getElementById(theTable).style.display = 'none';
          }
    }
    
    function DeleteOperatorSkill (CategoryWebText, SkillWebText)
    {
        if (confirm("¿Seguro que desea eliminar la habilidad seleccionada?")==true)
        {
            location.href = window.location.href + "&CategoryWebText=" + CategoryWebText + "&SkillWebText=" + SkillWebText; 
            return false;
        }
        else
            location.href = window.location.href; 
            return false;
    }
    
    function DeletePartnerSkill (CategoryWebText, SkillWebText, PartnerId)
    {
        if (confirm("¿Seguro que desea eliminar la habilidad seleccionada?")==true)
        {
            var interrogationIdx = window.location.href.indexOf('?');
            
            if (interrogationIdx > -1)
            {
                location.href = window.location.href.substring(0,interrogationIdx) + "?CategoryWebText=" + CategoryWebText + "&SkillWebText=" + SkillWebText + "&PartnerId=" + PartnerId; 
            }
            else
            {
                location.href = window.location.href + "?CategoryWebText=" + CategoryWebText + "&SkillWebText=" + SkillWebText + "&PartnerId=" + PartnerId; 
            }
            
            return false;
        }
        else
            location.href = window.location.href; 
            return false;
    }
       
    function OpenRanking ()
    {
        window.open("Ranking.aspx", "", "resizable=yes,toolbar=no,scrollbars=yes,menubar=no,status=no,directories=no,width=1100,height=800");
    }
    
    function Highlight_On(obj)
    {        
        if(obj != null)
        {
            obj.originalClassName = obj.className;
            obj.className = obj.className + 'HL';
        }
    } 
    
    function Highlight_Off(obj)
    {
        if(obj != null)
        {
            obj.className = obj.originalClassName;
        }
    }
    
    function OpenEndUserDetails(LicenseCode)
    {
       location.href("LicenseDetails.aspx?LicenseCode=" + encodeURIComponent(LicenseCode));
    }
    
    function OpenEndUserDetailsWithDates(LicenseCode, initialDate, endDate)
    {
       location.href("LicenseDetails.aspx?LicenseCode=" + encodeURIComponent(LicenseCode) + "&InitialDate=" + initialDate + "&EndDate=" + endDate);
    }
    
    function OpenIncidenceDetails(ConversationId, credId, crmLocation)
    {
       window.open(crmLocation + "/IntegracionUlises/ListaIncConvUlises.aspx?sessionId=" + encodeURIComponent(ConversationId)+ "&IdOperador=" + encodeURIComponent(credId), "", "resizable=no,toolbar=no,scrollbars=both,menubar=no,status=no,directories=no,width=700,height=410");
    }
    
    function OpenAddImageFrame(UserName, backupWebLocation)
    {
       window.open( backupWebFramesLocation + "/WebPages/Frames/AddImageFrame.aspx?UserName=" + encodeURIComponent(UserName), "", "resizable=no,toolbar=no,scrollbars=both,menubar=no,status=no,directories=no,width=535,height=170");
    }
    
    function OpenAddTemplateFrame(UserName, backupWebLocation)
    {
       window.open( backupWebFramesLocation + "/WebPages/Frames/AddTemplateFrame.aspx?UserName=" + encodeURIComponent(UserName), "", "resizable=no,toolbar=no,scrollbars=yes,menubar=no,status=no,directories=no,width=560,height=230");
    }
    
    function OpenAddApplicationFrame(UserName, backupWebLocation)
    {
       window.open( backupWebFramesLocation + "/WebPages/Frames/AddApplicationFrame.aspx?UserName=" + encodeURIComponent(UserName), "", "resizable=no,toolbar=no,scrollbars=yes,menubar=no,status=no,directories=no,width=660,height=370");
    }
    
    function isNumberKey(evt)
    {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;
            
         return true;
    }
    
    function isLoginKey(evt)
    {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (((charCode > 47) && (charCode < 58))||((charCode > 64) && (charCode < 91))||((charCode > 96) && (charCode < 123))||(charCode == 95)||(charCode == 45))
            return true;
         return false;
    }
    
    // Play ring sound
    function PlaySound()
    {
        if (document.all && document.getElementById)
        {
            document.getElementById("ringsound").src = "";
            document.getElementById("ringsound").src = "../../sounds/ringin2.wav";
        }

    }
    
    var previousRow;
    var previousColor;
    
    function ChangeRowColor(row)
    {
        //If last clicked row and the current clicked row are same
        if (previousRow == row)
            return;//do nothing
        //If there is row clicked earlier
        else if (previousRow != null)
            //change the color of the previous row back to white
            document.getElementById(previousRow).style.backgroundColor = previousColor;
        
        //change the color of the current row to light yellow
        
        previousColor = document.getElementById(row).style.backgroundColor;
        document.getElementById(row).style.backgroundColor = "#ffffda";            
        //assign the current row id to the previous row id 
        //for next row to be clicked
        previousRow = row;
    }
    
    function confirmPayment() 
    { 
        return confirm("El pedido se establecerá como PAGADO, ¿está seguro?");
    }
   
    function confirm_DeleteAdmin(admin)
    {
        if (confirm("¿Seguro que desea eliminar al administrador?\n(Es posible que el administrador siga activo durante unos minutos después de su eliminación)")==true)
        {
            var interrogationIdx = window.location.href.indexOf('?');
            
            if (interrogationIdx > -1)
            {
                location.href = window.location.href.substring(0,interrogationIdx) + "?Admin=" + encodeURIComponent(admin);
            }
            else
            {
                location.href = window.location.href + "?Admin=" + encodeURIComponent(admin);
            }
            return false;
        }
        else
            return false;
    }
    
    function confirm_DeleteUseServices(url, partId)
    {
        if (confirm("¿Seguro que desea resetear la licencia?")==true)
        {
              location.href="LicensesPage.aspx?LicId=" + encodeURIComponent(url) + "&PartId=" + encodeURIComponent(partId);
              return false;
        }
        else
              return false;
    }
    
    function confirm_DeleteLicense(url, partId)
    {
        if (confirm("¿Seguro que desea dar de baja la licencia?")==true)
        {
              location.href="LicensesPage.aspx?DeleteLicId=" + encodeURIComponent(url) + "&PartId=" + encodeURIComponent(partId);
              return false;
        }
        else
              return false;
    }
    
    function confirm_RestoreLicense(url, partId)
    {
        if (confirm("¿Seguro que desea dar de alta la licencia?")==true)
        {
              location.href="LicensesPage.aspx?RestoreLicId=" + encodeURIComponent(url) + "&PartId=" + encodeURIComponent(partId);
              return false;
        }
        else
              return false;
    }
    
    function OpenExternalIFrame(url, width, height)
    {        
        var backDiv = document.getElementById('backDiv');
        var externalIFrame = document.getElementById('externalIFrame');
        
        self.scrollTo(0,0);
        
        backDiv.style.visibility = 'visible';
        backDiv.style.height = '100%';
        
        externalIFrame.src = url;
        externalIFrame.style.visibility = 'visible';
        externalIFrame.style.marginLeft = ((width/2)* (-1)) + 'px';
        externalIFrame.style.width = width + 'px';
        externalIFrame.style.height = height + 'px';
        
        document.body.style.overflow = 'hidden';
    }
    
    function OpenNotifications()
    {
       location.href("Notification.aspx");
    }
        
    