/***** CUSTOMIZE THESE VARIABLES *****/
var imgRe = /^.+\.(jpg|jpeg|gif|png)$/i;

function editGallery(galleryID) {
  var  fuseactionX = "gallery.edit";
  jQuery.post("index.php", { fuseaction: fuseactionX},
  function(data) {
     showDialog("600px","500px",data);
  });
}




function previewImageGallery(fl,number) {

   var path = fl.value;
   if (path.search(imgRe) != -1) {
       if (path.length > 0) {
           handleimgPreviewGallery('imagePreviewTest','imgFuseAction',number);
           $j("#imagePreviewTest").submit();
       }
   } else {
     alert("JPG, PNG, and GIFs only!");
     $j("#picField").attr("value","");
   }
   setTimeout("resetimgPreviewGallery()",400);
}


function closeImageWindowGallery () {
  $j("#imagePreviewTest").submit();
  setTimeout("resetEditorBg()",400);
}

function handleimgPreviewGallery(imagePreviewTest, imgFuseAction,number) {
  $j("#"+imagePreviewTest).attr("target",'previewIMg'+number);
  $j("#"+imgFuseAction).attr("value","gallery.preview");
  $j("#imgNumber").attr("value",number);
  
}


function resetimgPreviewGallery(hasSites) {
  $j("#imagePreviewTest").attr("target",'topframe');
  if (hasSites==false)
     $j("#imgFuseAction").attr("value","gallery.update");
  else
    $j("#imgFuseAction").attr("value","gallery.chooseSites");
  $j("#imgNumber").attr("value","-1");
	
}

function handleEditDialogsGallery(fuseParts1) {
  var  fuseactionX = "edit."+ fuseParts1;

  jQuery.post("index.php", { fuseaction: fuseactionX},
  function(data) {
        showDialog(600,400,data);

  });
}

function GalleryAdd() {
	if(confirm("De aanpassingen in het huidige scherm gaan verloren door deze actie!\n\nWilt u doorgaan?")){
   jQuery.post("index.php", { fuseaction: "gallery.add"},
	function(data) {
  		var idResult = '#gallery_content';
		$j(idResult).html(data);
	});
	
	}
}


function GalleryEdit() {
   jQuery.post("index.php", { fuseaction: "gallery.edit"},
	function(data) {
  		var idResult = '#gallery_content';
		$j(idResult).html(data);
	});
}


function handleEditImageGallery(imgSrc,dx,dy,finalDiv,fromSession) {
 if (!fromSession) fromSession = false;
  var  fuseactionX = "gallery.edit";
  jQuery.post("index.php", { fuseaction: fuseactionX,src: imgSrc,width:dx,height:dy,imgDiv:finalDiv},
  function(data) {
     if (fromSession == true) {
       $j('#topframe').html(data);
       return;
     }
     showDialog(450,400,data);
  });
}

function updateImageInDivGallery(finalDiv) {
   var finalDivUse = "#"+finalDiv;
   resetEditorBg();
}

function deleteImage(image_id,site_id,segment){
	jQuery.post("index.php", { fuseaction: "gallery.delete",image: image_id, site: site_id,segment_name: segment},
	function(data) {
  		var idResult = '#gallery_content';
		$j(idResult).html(data);
	});
}


