function protect_images() 
{
   var all_images = document.getElementsByTagName('img');
   var image_detail = document.getElementById('image_detail');
   var image_content = document.getElementById('image_content');
   var detail_content = document.getElementById('detail_content');

   /* Remove */
   for(i=0;i<all_images.length;i++) 
   {
      current_image = all_images.item(i);
      current_class = current_image.className;
      
      if (current_class.indexOf('transparent') >= 0)
      {
         section_transparent = current_image.parentNode;
         if (image_detail) {
            image_detail.removeChild(section_transparent);
         } else {
            detail_content.removeChild(section_transparent);
         }
      }
   
   }
   
   total = all_images.length;
   
   /* Add */
   for(i=0;i<total;i++) 
   {
      current_image = all_images.item(i);
      current_class = current_image.className;

      if (current_class.indexOf('protected') >= 0)
      {
         section_transparent = document.createElement('div');
         image_transparent = document.createElement('img');     
         section_transparent.style.position = 'absolute';
         section_transparent.style.left = findPosX(current_image) + 'px';
         section_transparent.style.top = findPosY(current_image) + 'px';
         section_transparent.style.width = current_image.width + 'px';
         section_transparent.style.height = current_image.height + 'px';
         section_transparent.style.zIndex = 5;

         image_transparent.src = transparent_image();
         image_transparent.style.width = '100%';
         image_transparent.style.height = '100%';
         image_transparent.style.border = '0px solid black';
         image_transparent.className = 'transparent';
         image_transparent.onclick = function () { copyright_message(); return false; }
         image_transparent.oncontextmenu = function () { copyright_message(); return false;}

         section_transparent.appendChild(image_transparent);               
         if (image_detail) {
            image_detail.appendChild(section_transparent);
         } else if (detail_content) {
            detail_content.appendChild(section_transparent);
         }
      }   
   }
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

