      function submitWebAliveForm(document, method, lang)
      {
        if (window.document.WebAliveMainForm.progress != null && window.document.WebAliveMainForm.progress.value == 'true')
        {
		pleft = (screen.width  / 2) - (300 / 2);
		ptop  = (screen.height / 2) - (56  / 2);
		progressWindow = window.open('/system/utilities/progress.xml', 'progress', 'width=300; height=56; left=' + pleft + '; top=' + ptop);
        }
        var myform   = window.document.getElementsByTagName("form").item(0);
        var myaction = myform.getAttribute("xxx");
        myform.setAttribute("action", myaction);
        //window.document.WebAliveMainForm.action = window.document.WebAliveMainForm.xxx;
        processHttps();
        try
        {
          if (doValidations() == false)
          {
            return;
          }
        }
        catch (everything)
        {
        }
        window.document.WebAliveMainForm.WebAliveActionDocument.value = document;
        window.document.WebAliveMainForm.WebAliveActionMethod.value   = method;
        window.document.WebAliveMainForm.document.value               = document;
        window.document.WebAliveMainForm.lang.value                   = lang;
        window.document.WebAliveMainForm.submit();
      }
      
      function submitWebAliveFormParams(document, method, lang, parms)
      {
        if (window.document.WebAliveMainForm.progress != null && window.document.WebAliveMainForm.progress.value == 'true')
        {
		pleft = (screen.width  / 2) - (300 / 2);
		ptop  = (screen.height / 2) - (56  / 2);
		progressWindow = window.open('/system/utilities/progress.xml', 'progress', 'width=300; height=56; left=' + pleft + '; top=' + ptop);
        }
        var myform   = window.document.getElementsByTagName("form").item(0);
        var myaction = myform.getAttribute("xxx");
        myform.setAttribute("action", myaction);
        //window.document.WebAliveMainForm.action = window.document.WebAliveMainForm.xxx;
        processHttps();
        try
        {
          if (doValidations() == false)
          {
            return;
          }
        }
        catch (everything)
        {
        }
        window.document.WebAliveMainForm.WebAliveActionDocument.value = document;
        window.document.WebAliveMainForm.WebAliveActionMethod.value   = method;
        window.document.WebAliveMainForm.WebAliveActionParameters.value = parms;
        window.document.WebAliveMainForm.document.value               = document;
        window.document.WebAliveMainForm.lang.value                   = lang;
        window.document.WebAliveMainForm.submit();
      }
      
      function processHttps()
      {
        var goHttps = false;
        if (window.document.WebAliveMainForm.https != null)
        {
          if (window.document.WebAliveMainForm.https.type == 'checkbox')
          {
            if (window.document.WebAliveMainForm.https.checked)
            {
              goHttps = true;
            }
          }
          if (window.document.WebAliveMainForm.https.type == 'hidden')
          {
            if (window.document.WebAliveMainForm.https.value == 'true')
            {
              goHttps = true;
            }
          }
        }
        protocol = 'http';
        if (goHttps)
        {
          protocol = 'https';
        }
        action = window.document.WebAliveMainForm.action.substring(window.document.WebAliveMainForm.action.indexOf(':'));
        action = protocol + action;

/*
        var portHttp  = '80';
        var portHttps = '443';
alert(action);
        if (protocol == 'http')
        {
          action = stringReplace(action,portHttps,portHttp);
        }
        else
        {
          action = stringReplace(action,portHttp,portHttps);
        }
        window.document.WebAliveMainForm.action = action;
alert(action);
*/
      }

      function renameSelectedObjects()
      {
        pleft = (screen.width  / 2) - (400  / 2);
        ptop  = (screen.height / 2) - (200 / 2);
        j     = 0;

        for (i = 0; i < window.document.all.length; i++)
        {
          if (window.document.all[i].type == 'checkbox' &&
              window.document.all[i].checked)
          {
            if (window.document.all[i].name.substr(0, 8) == 'checkBox')
            {
              var aFile = window.document.all[i].name.substr(8);
              var aFileName = '';
              if (aFile.indexOf('.') != -1)
              {
                aFileName = aFile.substr(aFile.lastIndexOf('/') + 1, aFile.lastIndexOf('.') - aFile.lastIndexOf('/') - 1);
              }
              else
              {
                aFileName = aFile.substr(aFile.lastIndexOf('/') + 1);
              }
              var urlToOpen = '/system/object-catalog/documents/viewers/rename.xml?old_name=' + aFileName + '&old_path=' + aFile;
              window.open(urlToOpen, '', 'width=400, height=200, left=' + (pleft + (j * 20)) + ', top=' + (ptop + (j * 20)) + ', toolbar=false, location=false, menubar=false, resizable=false', false);
              j++;

            }
          }
        }
      }

      function openDetailForCheckBoxes(urlToOpen, windowWidth, windowHeight)
      {
        pleft = (screen.width  / 2) - (windowWidth  / 2);
        ptop  = (screen.height / 2) - (windowHeight / 2);
        j     = 0;
        for (i = 0; i < window.document.all.length; i++)
        {
          if (window.document.all[i].type == 'checkbox' &&
              window.document.all[i].checked)
          {
            if (window.document.all[i].name.substr(0, 8) == 'checkBox')
            {
              if (urlToOpen.indexOf('?') == -1)
              {
                window.open(urlToOpen + '?populate_file=' + window.document.all[i].name.substr(8), '', 'width=' + windowWidth + ', height=' + windowHeight + ', left=' + (pleft + (j * 20)) + ', top=' + (ptop + (j * 20)) + ', toolbar=false, location=false, menubar=false, resizable=false, status=no', false);
              }
              else
              {
                window.open(urlToOpen + '&populate_file=' + window.document.all[i].name.substr(8), '', 'width=' + windowWidth + ', height=' + windowHeight + ', left=' + (pleft + (j * 20)) + ', top=' + (ptop + (j * 20)) + ', toolbar=false, location=false, menubar=false, resizable=false, status=no', false);
              }
              j++;
            }
          }
        }
      }

      function openDebugDetailForCheckBoxes(urlToOpen, windowWidth, windowHeight)
      {
        pleft = (screen.width  / 2) - (windowWidth  / 2);
        ptop  = (screen.height / 2) - (windowHeight / 2);
        j     = 0;
        for (i = 0; i < window.document.all.length; i++)
        {
          if (window.document.all[i].type == 'checkbox' &&
              window.document.all[i].checked)
          {
            if (window.document.all[i].name.substr(0, 8) == 'checkBox')
            {
              if (urlToOpen.indexOf('?') == -1)
              {
                window.open(urlToOpen + '?populate_file=' + window.document.all[i].name.substr(8), '', 'width=' + windowWidth + ', height=' + windowHeight + ', left=' + (pleft + (j * 20)) + ', top=' + (ptop + (j * 20)) + ', toolbar=false, location=false, menubar=false, resizable=yes, status=yes, scrollbars=1', false);
              }
              else
              {
                window.open(urlToOpen + '&populate_file=' + window.document.all[i].name.substr(8), '', 'width=' + windowWidth + ', height=' + windowHeight + ', left=' + (pleft + (j * 20)) + ', top=' + (ptop + (j * 20)) + ', toolbar=false, location=false, menubar=false, resizable=yes, status=yes, scrollbars=1', false);
              }
              j++;
            }
          }
        }
      }

      function show_hide(obj,pic,site,name)
      {
        if (obj.style.display == "none")
        {
          obj.style.display = "inline";
          pic.src = "/webalive?document=/system/templates/graphics/box_close.gif&site=" + site;
        }
        else
        {
          obj.style.display = "none";
          pic.src = "/webalive?document=/system/templates/graphics/box_open.gif&site=" + site;
        }
        setCookie('WebAlivePosition_' + site + '_' + name, obj.style.display);
      }
      
      function wizardChangeStep(stepToActivate)
      {
        // hiding all steps
        try
        {
          step01.style.display = "none";
          step02.style.display = "none";
          step03.style.display = "none";
          step04.style.display = "none";
          step05.style.display = "none";
          step06.style.display = "none";
          step07.style.display = "none";
          step08.style.display = "none";
          step09.style.display = "none";
          step10.style.display = "none";
          step11.style.display = "none";
          step12.style.display = "none";
          step13.style.display = "none";
          step14.style.display = "none";
          step15.style.display = "none";
          step16.style.display = "none";
          step17.style.display = "none";
          step18.style.display = "none";
          step19.style.display = "none";
          step20.style.display = "none";
          step21.style.display = "none";
          step22.style.display = "none";
          step23.style.display = "none";
          step24.style.display = "none";
          step25.style.display = "none";
        }
        catch (everything)
        {
        }
        
        // showing active step
        stepToActivate.style.display = "inline";
      }

      function showTab(tabToActivate,linkToActivate)
      {
        // hiding all tabs
        try
        {
          tab1.style.display = "none";
          tab2.style.display = "none";
          tab3.style.display = "none";
          tab4.style.display = "none";
          tab5.style.display = "none";
          tab6.style.display = "none";
          tab7.style.display = "none";
          tab8.style.display = "none";
          tab9.style.display = "none";
        }
        catch (everything)
        {
        }
        // showing the new active tab
        tabToActivate.style.display = "inline";

        // setting all tab links back to normal
        try
        {
          tab1Link.style.fontWeight = "normal";
          tab2Link.style.fontWeight = "normal";
          tab3Link.style.fontWeight = "normal";
          tab4Link.style.fontWeight = "normal";
          tab5Link.style.fontWeight = "normal";
          tab6Link.style.fontWeight = "normal";
          tab7Link.style.fontWeight = "normal";
          tab8Link.style.fontWeight = "normal";
          tab9Link.style.fontWeight = "normal";
        }
        catch (everything)
        {
        }
        // setting active tab link in bold
        //linkToActivate.style.fontWeight = "bold";
      }
      
      function opendetailwindow(urlToOpen, windowWidth, windowHeight)
      {
        openDetailWindow(urlToOpen, windowWidth, windowHeight);
      }

      function openDetailWindow(urlToOpen, windowWidth, windowHeight)
      {
        pleft = (screen.width  / 2) - (windowWidth  / 2);
        ptop  = (screen.height / 2) - (windowHeight / 2);
        window.open(urlToOpen, '', 'width=' + windowWidth + ', height=' + windowHeight + ', left=' + pleft + ', top=' + ptop + ', toolbar=false, location=false, menubar=false, resizable=false', false);
      }

      function openDetailWindowResizable(urlToOpen, windowWidth, windowHeight)
      {
        pleft = (screen.width  / 2) - (windowWidth  / 2);
        ptop  = (screen.height / 2) - (windowHeight / 2);
        window.open(urlToOpen, '', 'width=' + windowWidth + ', height=' + windowHeight + ', left=' + pleft + ', top=' + ptop + ', toolbar=false, location=false, menubar=false, resizable=yes', false);
      }

      function openDetailWindowScrollBars(urlToOpen, windowWidth, windowHeight)
      {
        pleft = (screen.width  / 2) - (windowWidth  / 2);
        ptop  = (screen.height / 2) - (windowHeight / 2);
        window.open(urlToOpen, '', 'width=' + windowWidth + ', height=' + windowHeight + ', left=' + pleft + ', top=' + ptop + ', toolbar=false, location=false, menubar=false, resizable=false, scrollbars=1', false);
      }

      function openDetailWindowScrollBarsResizable(urlToOpen, windowWidth, windowHeight)
      {
        pleft = (screen.width  / 2) - (windowWidth  / 2);
        ptop  = (screen.height / 2) - (windowHeight / 2);
        window.open(urlToOpen, '', 'width=' + windowWidth + ', height=' + windowHeight + ', left=' + pleft + ', top=' + ptop + ', toolbar=false, location=false, menubar=false, resizable=yes, scrollbars=1, status=no', false);
      }

      function openDebugDetailWindowScrollBarsResizable(urlToOpen, windowWidth, windowHeight)
      {
        pleft = (screen.width  / 2) - (windowWidth  / 2);
        ptop  = (screen.height / 2) - (windowHeight / 2);
        window.open(urlToOpen, '', 'width=' + windowWidth + ', height=' + windowHeight + ', left=' + pleft + ', top=' + ptop + ', toolbar=false, location=false, menubar=false, resizable=yes, scrollbars=1, status=yes', false);
      }

      function openDebugDetailWindow(urlToOpen, windowWidth, windowHeight)
      {
        pleft = (screen.width  / 2) - (windowWidth  / 2);
        ptop  = (screen.height / 2) - (windowHeight / 2);
        window.open(urlToOpen, '', 'width=' + windowWidth + ', height=' + windowHeight + ', left=' + pleft + ', top=' + ptop + ', toolbar=false, location=false, menubar=false, resizable=false, status=yes', false);
      }

      function openDebugDetailWindowScrollBars(urlToOpen, windowWidth, windowHeight)
      {
        pleft = (screen.width  / 2) - (windowWidth  / 2);
        ptop  = (screen.height / 2) - (windowHeight / 2);
        window.open(urlToOpen, '', 'width=' + windowWidth + ', height=' + windowHeight + ', left=' + pleft + ', top=' + ptop + ', toolbar=false, location=false, menubar=false, resizable=false, status=yes, scrollbars=1', false);
      }

      function deleteObjects()
      {
        var value = '';
        var j = 0;
        for (i = 0; i < window.document.all.length; i++)
        {
          if (window.document.all[i].type == 'checkbox' &&
              window.document.all[i].checked)
          {
            if (window.document.all[i].name.substr(0, 8) == 'checkBox' && window.document.all[i].name.indexOf('/..') < 0)
            {
              value = value + window.document.all[i].name.substr(8, window.document.all[i].name.length) + ';';
              j++;
            }
          }
        }
        if (j == 0)
        {
          alert('Select object(s).');
        }
        else
        {
          documentToOpen = '/administrator/system/utilities/delete_objects.xml?objects=';
          if (documentToOpen.length + value.length > 2000)
          {
            alert('Too many objects selected.');
          }
          else
          {
            //openDetailWindow('/administrator/system/utilities/delete_objects.xml?objects=' + value, 400, 200);
            openDetailWindow('/system/utilities/delete_objects.xml?objects=' + value, 400, 200);
          }
        }
      }
      
      function deleteStatistics()
      {
        var value = '';
        var j = 0;
        for (i = 0; i < window.document.all.length; i++)
        {
          if (window.document.all[i].type == 'checkbox' &&
              window.document.all[i].checked)
          {
            if (window.document.all[i].name.substr(0, 8) == 'checkBox' && window.document.all[i].name.indexOf('/..') < 0)
            {
              value = value + window.document.all[i].name.substr(8, window.document.all[i].name.length) + ';';
              j++;
            }
          }
        }
        if (j == 0)
        {
          alert('Select object(s).');
        }
        else
        {
          documentToOpen = '/system/object-catalog/statistics/viewers/delete.xml?objects=';
          if (documentToOpen.length + value.length > 2000)
          {
            alert('Too many objects selected.');
          }
          else
          {
            openDetailWindow('/system/object-catalog/statistics/viewers/delete.xml?objects=' + value, 400, 200);
          }
        }
      }

      function checkBoxSetAll(checkBoxAll)
      {
        for (i = 0; i < window.document.all.length; i++)
        {
          if (window.document.all[i].type == 'checkbox')
          {
            if (window.document.all[i].name.substr(0, 8) == 'checkBox')
            {
              window.document.all[i].checked = checkBoxAll.checked;
            }
          }
        }
      }

      function copyMoveObjects(operation)
      {
        var value = '';
        var j = 0;
        for (i = 0; i < window.document.all.length; i++)
        {
          if (window.document.all[i].type == 'checkbox' &&
              window.document.all[i].checked)
          {
            if (window.document.all[i].name.substr(0, 8) == 'checkBox' && window.document.all[i].name.indexOf('..') < 0)
            {
              value = value + window.document.all[i].name.substr(8, window.document.all[i].name.length) + ';';
              j++;
            }
          }
        }
        if (j == 0)
        {
          alert('Select object(s).');
        }
        else
        {
          documentToOpen = '/system/object-catalog/documents/viewers/copy.xml?objects=';
          if (documentToOpen.length + value.length > 2000)
          {
            alert('Too many objects selected.');
          }
          else
          {
            if (operation == 'copy')
            {
              //openDetailWindowScrollBars('/administrator/studio/documents/document_copy.xml?objects=' + value, 400, 400);
              openDetailWindowScrollBars('/system/object-catalog/documents/viewers/copy.xml?objects=' + value, 400, 400);
            }
            else
            {
              //openDetailWindowScrollBars('/administrator/studio/documents/document_move.xml?objects=' + value, 400, 400);
              openDetailWindowScrollBars('/system/object-catalog/documents/viewers/move.xml?objects=' + value, 400, 400);
            }
          }
        }
      }

      function operationOnSetOfObjects(documentToOpen, width, height)
      {
        var value = '';
        var j = 0;
        for (i = 0; i < window.document.all.length; i++)
        {
          if (window.document.all[i].type == 'checkbox' &&
              window.document.all[i].checked)
          {
            if (window.document.all[i].name.substr(0, 8) == 'checkBox' && window.document.all[i].name.indexOf('..') < 0)
            {
              value = value + window.document.all[i].name.substr(8, window.document.all[i].name.length) + ';';
              j++;
            }
          }
        }
        if (j == 0)
        {
          alert('Select object(s).');
        }
        else
        {
          if (documentToOpen.length + value.length + 10 > 2000)
          {
            alert('Too many objects selected.');
          }
          else
          {
            openDetailWindow(documentToOpen + '?objects=' + value, width, height);
          }
        }
      }

      function operationOnSetOfObjectsScrollBars(documentToOpen, width, height)
      {
        var value = '';
        var j = 0;
        for (i = 0; i < window.document.all.length; i++)
        {
          if (window.document.all[i].type == 'checkbox' &&
              window.document.all[i].checked)
          {
            if (window.document.all[i].name.substr(0, 8) == 'checkBox')
            {
              value = value + window.document.all[i].name.substr(8, window.document.all[i].name.length) + ';';
              j++;
            }
          }
        }
        if (j == 0)
        {
          alert('Select object(s).');
        }
        else
        {
          openDetailWindowScrollBars(documentToOpen + '?objects=' + value, width, height);
        }
      }

      function operationOnSetOfObjectsScrollBarsResizable(documentToOpen, width, height)
      {
        var value = '';
        var j = 0;
        for (i = 0; i < window.document.all.length; i++)
        {
          if (window.document.all[i].type == 'checkbox' &&
              window.document.all[i].checked)
          {
            if (window.document.all[i].name.substr(0, 8) == 'checkBox')
            {
              value = value + window.document.all[i].name.substr(8, window.document.all[i].name.length) + ';';
              j++;
            }
          }
        }
        if (j == 0)
        {
          alert('Select object(s).');
        }
        else
        {
          openDetailWindowScrollBarsResizable(documentToOpen + '?objects=' + value, width, height);
        }
      }

      function operationOnSetOfObjectsScrollBarsResizableNull(documentToOpen, width, height)
      {
        var value = '';
        var j = 0;
        for (i = 0; i < window.document.all.length; i++)
        {
          if (window.document.all[i].type == 'checkbox' &&
              window.document.all[i].checked)
          {
            if (window.document.all[i].name.substr(0, 8) == 'checkBox')
            {
              value = value + window.document.all[i].name.substr(8, window.document.all[i].name.length) + ';';
              j++;
            }
          }
        }
        openDetailWindowScrollBarsResizable(documentToOpen + '?objects=' + value, width, height);
      }

      function checkTextAreaLength(textarea, maxlength)
      {
        if (textarea.value.length > maxlength)
        {
          textarea.value = textarea.value.substring(0, maxlength);
        }
      }
      
      function openDetailWindowForSelectedObject(documentToOpen, width, height)
      {
        openDetailWindow(documentToOpen + '&selected_object=' + window.document.WebAliveMainForm.WebAliveSelectedObject.value, width, height);
      }
      
      function openDetailWindowCheckObjectSelected(documentToOpen, width, height)
      {
        if (window.document.WebAliveMainForm.WebAliveSelectedObject.value != '')
        {
          openDetailWindow(documentToOpen, width, height);
        }
        else
        {
          alert('Select paragraph.');
        }
      }

      function openDetailWindowForSelectedPicture(documentToOpen, width, height, noError, populateFile, editLanguage, editVersion, zone, paragraphId, pictureId, picturePosition)
      {
        openDetailWindow(documentToOpen + '?populate_file=' + populateFile + '&edit_language=' + editLanguage + '&edit_version=' + editVersion + '&zone=' + zone + '&paragraph_id=' + paragraphId + '&picture_id=' + pictureId + '&picture_position=' + picturePosition, width, height);
      }
      
      function openDetailWindowForSelectedParagraph(documentToOpen, width, height, noError, populateFile, editLanguage, editVersion)
      {
        // retrieving selected object value
        selectedObject = window.document.WebAliveMainForm.WebAliveSelectedObject.value;
        
        // if no value selected, generating an alert
        if (selectedObject == '')
        {
          if (noError)
          {
            if (documentToOpen.indexOf('?') == -1)
            {
               openDetailWindow(documentToOpen + '?edit_version=' + editVersion + '&edit_language=' + editLanguage + '&zone=null&id=null&populate_file=' + populateFile, width, height);
            }
            else
            {
               openDetailWindow(documentToOpen + '&edit_version=' + editVersion + '&edit_language=' + editLanguage + '&zone=null&id=null&populate_file=' + populateFile, width, height);
            }
            return;
          }
          else
          {
            alert('Select paragraph.');
            return;
          }
        }
        
        // searching for items inside the object selected string
        nameStart = 0;
        nameStop  = selectedObject.indexOf('|', nameStart + 1);
        name = selectedObject.substring(nameStart, nameStop);
        zoneStart = nameStop + 1;
        zoneStop  = selectedObject.indexOf('|', zoneStart + 1);
        zone = selectedObject.substring(zoneStart, zoneStop);
        idStart = zoneStop + 1;
        idStop  = selectedObject.indexOf('|', idStart + 1);
        id = selectedObject.substring(idStart, idStop);
        versionStart = idStop + 1;
        versionStop  = selectedObject.indexOf('|', versionStart + 1);
        version = selectedObject.substring(versionStart, versionStop);
        languageStart = versionStop + 1;
        languageStop  = selectedObject.indexOf('|', languageStart + 1);
        editLanguage = selectedObject.substring(languageStart, languageStop); // ici
        fileStart = languageStop + 1;
        fileStop  = selectedObject.length;
        file = selectedObject.substring(fileStart, fileStop);
        
        // the end
        if (documentToOpen.indexOf('?') == -1)
        {
          openDetailWindow(documentToOpen + '?edit_version=' + version + '&edit_language=' + editLanguage + '&zone=' + zone + '&id=' + id + '&populate_file=' + file, width, height);
        }
        else
        {
          openDetailWindow(documentToOpen + '&edit_version=' + version + '&edit_language=' + editLanguage + '&zone=' + zone + '&id=' + id + '&populate_file=' + file, width, height);
        }
      }

      function objectSeeker(field, pattern, width, height, rootPath, condition)
      {
        url = 'http://d1850.webalive.net/system/object-catalog/editor/viewers/object_seek.xml?pattern=' + pattern + '&field=' + field + '&root_path=' + rootPath + '&condition=' + condition;
        openDetailWindowScrollBars(url, width, height);
      }
      
      function calendarSelector(field, width, height)
      {
        url = 'http://www.vldvlaamsbrabant.be/system/object-catalog/editor/viewers/calendar.xml?field=' + field;
        openDetailWindow(url, 240, 180);
      }
      
      function borderSelector(field, width, height)
      {
        url = 'http://d1850.webalive.net/system/object-catalog/editor/viewers/border_selector.xml?field=' + field;
        openDebugDetailWindowScrollBars(url, width, height);
      }

      function setFieldValue(name, value)
      {
        for (i = 0; i < opener.window.document.all.length; i++)
        {
          if (opener.window.document.all[i].name == name)
          {
            opener.window.document.all[i].value = value;
            break;
          }
        }
        window.close();
      }
      
      function setFieldValueCurrentWindow(name, value)
      {
        for (i = 0; i < window.document.all.length; i++)
        {
          if (window.document.all[i].name == name)
          {
            window.document.all[i].value = value;
            break;
          }
        }
      }
      
      function cellOnMouseOver(cell, color1, color2, color3)
      {
        if (cell.style.background != color3)
        {
          cell.style.background = color1;
        }
      }
      function cellOnMouseOut(cell, color1, color2, color3)
      {
        if (cell.style.background != color3)
        {
          cell.style.background = color2;
        }
      }
      function cellOnClick(cell, color1, color2, color3)
      {
        for (i = 0; i < window.document.all.length; i++)
        {
          if (window.document.all[i].name != null && window.document.all[i].name.substr(0,1) == '$')
          {
            window.document.all[i].style.background = window.document.all[i].name.substr(1,window.document.all[i].name.length);
          }
        }
        cell.style.background = color3;
      }
	  function isNotNull(value)
	  {
	    if (value == '')
	    {
		  return false;
	    }
	    else
	    {
		 return true;
	    }
	  }
	  function isInteger(value)
	  {
	    for (i = 0; i < value.length; i++)
	    {
		 c = value.charAt(i);
		 if (c < '0' || c > '9')
		 {
		   return false;
		 }
	    }
	    return true;
	  }
	  function isFloat(value)
	  {
	    for (i = 0; i < value.length; i++)
	    {
		 c = value.charAt(i);
		 if ((c < '0' || c > '9') && c != '.' && c != ',')
		 {
		   return false;
		 }
	    }
	    return true;
	  }
	  function isEmail(value)
	  {
	    at1 = value.indexOf('@');
	    at2 = value.indexOf('@', at1 + 1);
	    if (at1 == -1) { return false; }
	    if (at2 != -1) { return false; }
	    //point = value.indexOf('.', at1);
	    //if (point == -1) { return false; }
	    return true;
	  }
	  function isInRange(value,min,max)
	  {
	    if (value < min || value > max) { return false; }
	    return true;
	  }
	  function matchMask(value,mask)
	  {
	    if (value.length != mask.length) { return false; }
	    for (i = 0; i < value.length; i++)
	    {
		 c = value.charAt(i);
		 d = mask.charAt(i);
		 if (d == 'n')
		 {
		   if (c < '0' || c > '9') { return false; }
		 }
		 else if (d == 's')
		 {
		   if (c < 'a' || c > 'z')
		   {
			if (c < 'A' || c > 'Z')
			{
			  return false;
			}
		   }
		 }
		 else if (d == 'a')
		 {
		   if (c < 'a' || c > 'z')
		   {
			if (c < 'A' || c > 'Z')
			{
			  if (c < '0' || c > '9')
			  {
			    return false;
			  }
			}
		   }
		 }
		 else if (d == 'l')
		 {
		   if (c < 'a' || c > 'z') { return false; }
		 }
		 else if (d == 'U')
		 {
		   if (c < 'A' || c > 'Z') { return false; }
		 }
		 else
		 {
		   if (c != d) { return false; }
		 }
	    }
	    return true;
	  }
	  
	  function addLink(link)
	  {
	    var range = opener.currentObject.document.selection.createRange();
	    var text  = range.text;
	    if (text == '')
	    {
		 alert('Select the text area on which you wish to create a link.');
	    }
	    else
	    {
		 range.execCommand('CreateLink',false,link);
	    }
	    window.close();
	  }
      
	  function addPicture(picture,site)
	  {
      if (window.opener.document.WebAliveMainForm.WebAliveSelectedObject.value == '')
	    {
        alert('Select paragraph.');
	    }
	    else
	    {
        window.opener.currentObject.document.execCommand('InsertImage',false,'/' + site + picture);
        window.opener.currentObject.focus();
	    }
	    window.close();
	  }

      function changeTab(tab_left,tab_main,tab_right,tab_link,tab_page)
      {
        if (navigator.appName.indexOf('Explorer') != -1)
        {
					for (i = 0; i < window.document.all.length; i++)
					{
						if (window.document.all[i].name != null && window.document.all[i].name.substr(0, 4) == 'Tab_')
						{
							if (window.document.all[i].name == tab_page)
							{
								window.document.all[i].style.display = "inline";
							}
							else
							{
								window.document.all[i].style.display = "none";
							}
						}
					}
				}
				else
				{
					for (i = 0; i < document.WebAliveMainForm.elements.length; i++)
					{
						if (document.WebAliveMainForm.elements[i].name != null && document.WebAliveMainForm.elements[i].name.substr(0, 4) == 'Tab_')
						{
							if (document.WebAliveMainForm.elements[i].name == tab_page)
							{
								document.WebAliveMainForm.elements[i].style.display = "inline";
							}
							else
							{
								document.WebAliveMainForm.elements[i].style.display = "none";
							}
						}
					}
				}
      }
      
      function moveParagraph(direction,site,editorDocument)
      {
        //alert(direction);
        //alert(site);
        //alert(editorDocument);
        actionOnUnload=false;
        forwardChanges();
        submitWebAliveFormParams('', 'adminDocumentsEditorMoveParagraphs', '', 'direction=' + direction + ';site=' + site + ';editor_document=' + editorDocument + ';paragraph=' + window.document.WebAliveMainForm.WebAliveSelectedObject.value + ';object=documents')
      }
      
      function resizeWindow(windowWidth,windowHeight)
      {
        window.resizeTo(windowWidth,windowHeight);
        pleft = (screen.width  / 2) - (windowWidth  / 2);
        ptop  = (screen.height / 2) - (windowHeight / 2);
        window.moveTo(pleft,ptop);
      }
      
      function unloadEditor()
      {
        pos1 = location.href.indexOf('populate_file=');
        pos2 = location.href.indexOf('.xml', pos1);
        populateFile = location.href.substring(pos1 + 14, pos2) + '.xml';
        wwidth  = 320;
        wheight = 200;
        pleft = (screen.width  / 2) - (wwidth  / 2);
        ptop  = (screen.height / 2) - (wheight / 2);
        windowHandle = window.open('/system/object-catalog/documents/viewers/unload.xml?populate_file=' + populateFile,'','width=' + wwidth + ',height=' + wheight + ',left=' + pleft + ',top=' + ptop,false);
        windowHandle.moveTo(pleft,ptop);
      }
      
      function changeParagraphStyle(style,editorDocument)
      {
        if (window.document.WebAliveMainForm.WebAliveSelectedObject.value == '')
        {
          alert('Select paragraph.');
        }
        else
        {
          actionOnUnload = false;
          forwardChanges();
          submitWebAliveFormParams('', 'adminDocumentsEditorQuickChangeParagraphStyle', '', 'selected_paragraph=' + window.document.WebAliveMainForm.WebAliveSelectedObject.value + ';style=' + style + ';editor_document=' + editorDocument + ';object=documents');
        }
      }
      
      function getDataFieldValueByName(name)
      {
        return document.getElementsByName(name)[0].value;
        /*for (i = 0; i < window.document.all.length; i++)
        {
          if (window.document.all[i].name != null && window.document.all[i].name == name)
          {
            return window.document.all[i].value;
          }
        }
        return null;*/
      }
      function keyFunction(before,after)
      {
        key = window.event.keyCode;
    	if (key == 38 && window.event.altKey)
    	{
    	  // moving up
    	  if (before != null)
    	  {
    	    before.focus();
    	  }
    	}
    	if (key == 40 && window.event.altKey)
    	{
    	  // moving down
    	  if (after != null)
    	  {
    	    after.focus();
    	  }
    	}
        return;
      }
      function setCookie(name,value)
      {
        // preparing cookie expiration time
        var cookieDate = new Date();
        cookieDate.setTime(cookieDate.getTime() + (365 * 24 * 60 * 60 * 1000));
        document.cookie = name + "=" + value + ";expires=" + cookieDate.toGMTString();
        return;
      }
      function getCookieVal (offset)
      {
        var endstr = document.cookie.indexOf (";", offset);
        if (endstr == -1)
        {
          endstr = document.cookie.length;
        }
        return unescape(document.cookie.substring(offset, endstr));
      }
      function getCookie(name)
      {  
        var arg = name + "=";  
        var alen = arg.length;  
        var clen = document.cookie.length;  
        var i = 0;  
        while (i < clen)
        {    
          var j = i + alen;    
          if (document.cookie.substring(i, j) == arg)      
          {
            return getCookieVal (j);
          }
          i = document.cookie.indexOf(" ", i) + 1;    
          if (i == 0)
          {
            break;   
          }
        }  
        return null;
      }
      function changeWrapType(object)
      {
        if (object.wrap == 'soft')
        {
          object.wrap = 'off';
          setCookie('webalive-studio-text-edit-wrap-type','off');
        }
        else
        {
          object.wrap = 'soft';
          setCookie('webalive-studio-text-edit-wrap-type','soft');
        }
      }
      function doGlobalReplace(object,from,to)
      {
        var value = object.value;
        for (;;)
        {
          var begin = value.indexOf(from.value);
          if (begin == -1) { break; }
          newValue = value.substring(0, begin);
          newValue = newValue + to.value + value.substring(begin + from.value.length);
          value = newValue;
        }
        object.value = value;
      }
      function stringReplace(str,what,by)
      {
        var pos = str.indexOf(what);
        if (pos == -1)
        {
          return str;
        }
        var before = str.substring(0,pos);
        var after  = str.substring(pos + what.length);
        return before + by + after;
      }
      
      function getValueForField(name)
      {
        for (i = 0; i < window.document.all.length; i++)
        {
          if (window.document.all[i].name == 'PROPS_VIEWER_' + name)
          {
            return window.document.all[i].value;
          }
        }
        return null;
      }

      function openPropertiesForCheckBoxes(windowWidth, windowHeight, language)
      {
        pleft = (screen.width  / 2) - (windowWidth  / 2);
        ptop  = (screen.height / 2) - (windowHeight / 2);
        j     = 0;
        for (i = 0; i < window.document.all.length; i++)
        {
          if (window.document.all[i].type == 'checkbox' &&
              window.document.all[i].checked)
          {
            if (window.document.all[i].name.substr(0, 8) == 'checkBox')
            {
              obj = window.document.all[i].name.substr(8);
              //url = getValueForField(obj);
              url = 'http://d1850.webalive.net/system/object-catalog/documents/viewers/object-properties.xml?populate_file=' + obj + '&language=' + language;
              window.open(url, '', 'width='+windowWidth+', height='+windowHeight+', left=' + (pleft + (j * 20)) + ', top=' + (ptop + (j * 20)) + ', toolbar=false, location=false, menubar=false, resizable=false', false);
              j++;
            }
          }
        }
      }
      
      function openCloseInitialPosition(site, name, initial)
      {
        var value = getCookie('WebAlivePosition_' + site + '_' + name);
        if (value == 'none')
        {
          return initial;
        }
        else
        {
          return value;
        }
      }
      
      function openCloseChangePosition(object, site, name)
      {
        var value = object.style.display;
        if (value == "none")
        {
          value = "inline";
        }
        else
        {
          value = "none";
        }
        object.style.display = value;
        setCookie('WebAlivePosition_' + site + '_' + name, value);
      }
      
      function executeOperations(url)
      {
        openDetailWindow(url, 320, 200);
      }
      
      function getSelected(object)
      {
        return object.options[object.selectedIndex].value;
      }
      
      function launchProgressBar()
      {
        try
        {
          document.WebAliveMainForm.progress.value = 'true';
        }
        catch(everything)
        {
        }
	pleft = (screen.width  / 2) - (300 / 2);
	ptop  = (screen.height / 2) - (56  / 2);
	progressWindow = window.open('/system/utilities/progress.xml', 'progress', 'width=300; height=56; left=' + pleft + '; top=' + ptop);
      }
      
      function openWindowForPrint(urlToOpen)
      {
        pleft = 0;
        ptop  = 0;
        windowWidth = screen.width - 5;
        windowHeight = screen.height - 50;
        window.open(urlToOpen, '', 'width=' + windowWidth + ', height=' + windowHeight + ', left=' + pleft + ', top=' + ptop + ', toolbar=false, location=false, menubar=false, resizable=false, scrollbars=1', false);
      }
      
      function addBookmark(bookmarkurl, bookmarktitle)
      {
        if (document.all)
        {
          if (bookmarkurl == null)
          {
            bookmarkurl = location.href;
          }
          if (bookmarktitle == null)
          {
            bookmarktitle = document.title;
          }
          window.external.AddFavorite(bookmarkurl, bookmarktitle)
        }
      }
      
      function removeInvalidChars(a)
      {
        b = '';
        for (i = 0; i < a.length; i++)
        {
          x = a.charCodeAt(i);
//alert(x);
          if (x == 8230)      { b = b + '...'; }
          else if (x == 171)  { b = b + '"';   }
          else if (x == 187)  { b = b + '"';   }
          else if (x == 339)  { b = b + 'oe';  }
          else if (x == 8216) { b = b + "'";   }
          else if (x == 8217) { b = b + "'";   }
          else if (x == 8594) { b = b + "";    }
          else if (x == 8211) { b = b + "-";   }
          else { b = b + a.charAt(i); }
        }
        return b;
      }
      
      function dropDownGetSelected(obj)
      {
        return obj.options[obj.selectedIndex].value;
      }
      
      function executeMethod(method,document)
      {
        // initializing
        parameters = '';
      
        // collecting all values from the current form
        for (i = 0; i < window.document.all.length; i++)
        {
          if (window.document.all[i].type == 'hidden' || window.document.all[i].type == 'text' ||
              window.document.all[i].type == 'select-one' || window.document.all[i].type == 'textarea')
          {
            parameters = parameters + window.document.all[i].name + '=' + window.document.all[i].value + '&';
          }
          else if (window.document.all[i].type == 'checkbox' && window.document.all[i].checked)
          {
            parameters = parameters + window.document.all[i].name + '=true&';
          }
          else if (window.document.all[i].type == 'radio' && window.document.all[i].checked)
          {
            parameters = parameters + window.document.all[i].name + '=' + window.document.all[i].value + '&';
          }
        }
        
        // preparing url
        url = '/webalive?document=' + document + '&WebAliveActionDocument=' + document + '&WebAliveActionMethod=' + method + '&' + parameters;
        
        // executing in sub-window
        openDetailWindow(url, 1, 1);
      }

      function delay(gap)
      {
        var then,now;
        then = new Date().getTime();
        now  = then;
        while ((now - then) < gap)
        {
          now=new Date().getTime();
        }
      }
      
      function sendWindowByMail()
      {
        openDetailWindow('http://d1850.webalive.net/system/object-catalog/documents/viewers/send-window-by-mail.xml',400,200);
      }
      
      function openForPrint(template, width, height)
      {
        url = '';
        if (location.href.indexOf('?') > 0)
        {
          url = location.href + '&template=' + template;
        }
        else
        {
          url = location.href + '?template=' + template;
        }
        openDetailWindowScrollBars(url, width, height);
      }
      
      function paddClockNumber(num)
      {
      	if (num==0||num==1||num==2||num==3||num==4||num==5||num==6||num==7||num==8||num==9)
      	{
      	  return '0' + num;
      	}
      	else
      	{
      	  return '' + num;
      	}
      }

	function isValidCardNumber (strNum)
	{
	   if (strNum == '') return true;
	   var nCheck = 0;
	   var nDigit = 0;
	   var bEven = false;

	   for (n = strNum.length - 1; n >= 0; n--)
	   {
	      var cDigit = strNum.charAt (n);
	      if (isDigit (cDigit))
	      {
		 var nDigit = parseInt(cDigit, 10);
		 if (bEven)
		 {
		    if ((nDigit *= 2) > 9)
		       nDigit -= 9;
		 }
		 nCheck += nDigit;
		 bEven = ! bEven;
	      }
	      else if (cDigit != ' ' && cDigit != '.' && cDigit != '-')
	      {
		 return false;
	      }
	   }
	   return (nCheck % 10) == 0;
	}
	function isDigit (c)
	{
	   var strAllowed = "1234567890";
	   return (strAllowed.indexOf (c) != -1);
	}
	function isCardTypeCorrect (strNum, type)
	{
	   var nLen = 0;
	   for (n = 0; n < strNum.length; n++)
	   {
	      if (isDigit (strNum.substring (n,n+1)))
		 ++nLen;
	   }

	   if (type == 'Visa')
	      return ((strNum.substring(0,1) == '4') && (nLen == 13 || nLen == 16));
	   else if (type == 'Amex')
	      return ((strNum.substring(0,2) == '34' || strNum.substring(0,2) == '37') && (nLen == 15));
	   else if (type == 'Master Card')
	      return ((strNum.substring(0,2) == '51' || strNum.substring(0,2) == '52'
		      || strNum.substring(0,2) == '53' || strNum.substring(0,2) == '54'
		      || strNum.substring(0,2) == '55') && (nLen == 16));
	   else
	      return false;

	}
      function dropDownOpenClose(name)
      {
        var o = document.getElementById(name);
        if (o.style.display=='none')
        {
          o.style.display='inline';
        }
        else
        {
          o.style.display='none';
        }
      }

	function showCountOnPage(txt)
	{
		var container = document.getElementById('bottom-bar');
		if (container == null)
		{
			window.setTimeout("showCount(x)", 100);
		}
		else
		{
			container = container.getElementsByTagName('TBODY')[0];
			container = container.getElementsByTagName('TR')[0];
			container = container.getElementsByTagName('TD')[0];
			var font = container.getElementsByTagName('FONT')[0];
			var o = document.createElement('span');
			o.style.color = 'white';
			o.innerHTML = txt;
			container.appendChild(o);
			var space = container.offsetWidth - o.offsetWidth - font.offsetWidth;
			o.style.marginLeft = space + 'px';
		}
	}
	

	function DaysInMonth(WhichMonth, WhichYear)
	{
	  var DaysInMonth = 31;
	  if (WhichMonth == "Apr" || WhichMonth == "Jun" || WhichMonth == "Sep" || WhichMonth == "Nov") DaysInMonth = 30;
	  if (WhichMonth == "Feb" && (WhichYear/4) != Math.floor(WhichYear/4))	DaysInMonth = 28;
	  if (WhichMonth == "Feb" && (WhichYear/4) == Math.floor(WhichYear/4))	DaysInMonth = 29;
	  return DaysInMonth;
	}

	function ChangeOptionDays(Which,df)
	{
	  DaysObject = eval("document.WebAliveMainForm.Days" + Which);
	  MonthObject = eval("document.WebAliveMainForm.Month" + Which);
	  YearObject = eval("document.WebAliveMainForm.Year" + Which);
	
	  Month = MonthObject[MonthObject.selectedIndex].text;
	  Year = YearObject[YearObject.selectedIndex].text;
	
	  DaysForThisSelection = DaysInMonth(Month, Year);
	  CurrentDaysInSelection = DaysObject.length;
	  if (CurrentDaysInSelection > DaysForThisSelection)
	  {
	    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
	    {
	      DaysObject.options[DaysObject.options.length - 1] = null
	    }
	  }
	  if (DaysForThisSelection > CurrentDaysInSelection)
	  {
	    for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
	    {
	      NewOption = new Option(DaysObject.options.length + 1);
	      DaysObject.add(NewOption);
	    }
	  }
	    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
	    
	  monthNo = MonthObject.selectedIndex + 1;
	  Day = DaysObject[DaysObject.selectedIndex].text;

	    dfObject = document.getElementsByName(df)[0];
	    dfObject.value = Year + paddClockNumber(monthNo) + paddClockNumber(Day);
	}
	
