function LoadPhoto(file,idtab,alb_id){
/*        
    // Create new JsHttpRequest object.
    var req = new JsHttpRequest();
    // Code automatically called on load finishing.
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
      	if (req.responseJS.result == true)
                        AddPhoto(idtab,req.responseJS.photo_id,alb_id,req.responseJS.img);
        }
    }
    // Prepare request object (automatically choose GET or POST).
    req.open(null, 'ajax/backend/back_photoalbum.php', true);
    // Send data to backend.
    req.send( { img_file: file, 'album_id' : alb_id, 'func' : 'load'} );
*/
           JsHttpRequest.query(
               'ajax/backend/back_photoalbum.php', // backend
               {
                'img_file' : file, 
                'album_id' : alb_id,
                'func'     : 'load'
               },
               // Function is called when an answer arrives. 
               function(result, errors) {
               // Write errors to the debug div.
               //alert(errors); 
               // Write the answer.
                  if (result) {
		             if (result['result'] == true)
                        AddPhoto(idtab,result['photo_id'],alb_id,result['img']);
                  }
               },
               false  // do not disable caching
               );
}
function DeletePhoto(idtab,photo_num,photo_id,alb_id)
{
         if (!confirm(l_confirm_quest)) return;
         JsHttpRequest.query(
         'ajax/backend/back_photoalbum.php', // backend
         {
          'photo'    : photo_id,
          'album_id' : alb_id, 
          'func'     : 'delete'
         },
         // Function is called when an answer arrives. 
         function(result, errors) {
         // Write errors to the debug div.
         //alert(errors); 
         // Write the answer.
            if (result) {
               if (result['result'] == true)
                  DelPhoto(idtab,photo_num);
            }
         },
         false  // do not disable caching
         );      
}
function UpdatePhoto(photo_num){

         
         var f = document.forms['photoalbum'];
         photo_id = f.elements['photo_id'+photo_num].value;
         photo_name = f.elements['photo_name'+photo_num].value;
         photo_desc = f.elements['photo_desc'+photo_num].value;
           
        // if (photo_name != '' || photo_desc != ''){ 
            JsHttpRequest.query(
            'ajax/backend/back_photoalbum.php', // backend
            {
             'photo'    : photo_id,
             'pname'    : photo_name,
             'pdesc'    : photo_desc,
             'func'     : 'update'
            },
            // Function is called when an answer arrives. 
            function(result, errors) {
            // Write errors to the debug div.
            //alert(errors); 
            // Write the answer.
               if (result) {
                  if (result['result'] == false)
                     alert(result['text']);
	else
	  confirm(result['text']);
                  //   DelPhoto(idtab,photo_num);
               }
            },
            false  // do not disable caching
            );      
        // }
}
function DeleteComment(id){

         if (!confirm(l_confirm_quest)) return;
         JsHttpRequest.query(
         'ajax/backend/back_photoalbum.php', // backend
         {
          'com_id'    : id,
          'func'      : 'comment_delete'
         },
         // Function is called when an answer arrives. 
         function(result, errors) {
         // Write errors to the debug div.
         //alert(''); 
         //document.write(errors);
         // Write the answer.
            if (result) {
               if (result['result'] == true) {
                  c = document.getElementById('com_am');
                  c.innerHTML = c.innerHTML-1; 
                  if (is_ie)
                     document.getElementById('comment'+id).removeNode(true);
                  else{
                       node = document.getElementById('comment'+id);
                       node.parentNode.removeChild(node);
                  }
               }
                  //DelPhoto(idtab,photo_num);
            }
         },
         false  // do not disable caching
         );         
}

