$(document).ready( function(){

                var theDivIds=$('[id$=".txt"]');

                curentDivs=0;

                numberDivs = theDivIds.length;

                $(theDivIds).each(function(){

                ajaxRequest('cms/urejanje/getdata.html?doc='+jQuery(this).attr('id'),jQuery(this).attr('id'));

                });

                var divsName=$('#result input').serialize();

                $.post('index.html',divsName);

                if($("input[name=isLogged]").val()=='1'){ 

                

                }

});

function myFunc(textul,idul){

$('#'+idul.replace('.','\\.')).append(textul); 

$('#result').append("<input type='hidden' value='"+idul+"' name='idInput[]'>");  

$('#result').append("<input type='hidden' value='"+textul+"' name='textInput[]'>");

var name=idul.split(".");



if($("input[name=isLogged]").val()=='1'){

$('#'+idul.replace('.','\\.')).after('<a href="cms/urejanje/edit.html?filename='+name[0]+'" rel="shadowbox">edit</a>');

}

curentDivs=curentDivs+1;

if(curentDivs==numberDivs){

                 Shadowbox.init({

                height:500

                });

}

}



function ajaxRequest(url,idul) {

   var AJAX = null;                                 // Initialize the AJAX variable.

   gigi = null;

   var other = null;                                

   if (window.XMLHttpRequest) {                     // Does this browser have an XMLHttpRequest object?

      AJAX=new XMLHttpRequest();                    // Yes -- initialize it.

   } else {                                         // No, try to initialize it IE style

      AJAX=new ActiveXObject("Microsoft.XMLHTTP");  //  Wheee, ActiveX, how do we format c: again?

   }                                                // End setup Ajax.

   if (AJAX==null) {                                // If we couldn't initialize Ajax...

      alert("Your browser doesn't support AJAX.");  // Sorry msg.                                               

      return false                                  // Return false, couldn't set up ajax

   }

   AJAX.onreadystatechange = function() {                      // When the browser has the request info..

      if (AJAX.readyState==4 || AJAX.readyState=="complete") { //  see if the complete flag is set.    

         myFunc(AJAX.responseText,idul);                            // Pass the response to our processing function

      }                                                        // End Ajax readystate check.

   }

   AJAX.open("GET", url, true);                                  // Open the url this object was set-up with.

   AJAX.send(null);

                                             // Send the request.

}          
