// JavaScript Document
function processImage(option,formName) {
    if(document.getElementById('Result')){
            document.getElementById("Result").style.display = "none";
            document.getElementById("Result").innerHTML = "";
            document.getElementById("Result").className = "";
    }
    window.scrollTo(0, 0);
    if(document.getElementById('Animation') || document.getElementById('AnimationAlt')){
        if(document.getElementById('AnimationPopUp')){
            document.getElementById('AnimationPopUp').style.display = 'block';
        }else if(document.getElementById('AnimationAlt')){
            document.getElementById('AnimationAlt').style.display = 'block';
        }else{
            document.getElementById('Animation').style.display = 'block';
        }
        if(document.getElementById('Submit_Paragraph')){
            document.getElementById('Submit_Paragraph').style.display = 'none';
        }
        if($('#DropZone').length > 0){            
            var myDropzone = Dropzone.forElement(".dropzone");
            if(myDropzone.getQueuedFiles().length > 0){
                myDropzone.processQueue();
            }else{
                setTimeout(function() {
                    imageProcessing(option,formName);
                }, 800);
            }
        }else{        
            setTimeout(function() {
                imageProcessing(option,formName);
            }, 800);
        } 
    }else{
        if($('#DropZone').length > 0){
            var myDropzone = Dropzone.forElement(".dropzone");
            if(myDropzone.getQueuedFiles().length > 0){
                myDropzone.processQueue();
            }else{
                setTimeout(function() {
                    imageProcessing(option,formName);
                }, 800);
            }
        }else{        
            setTimeout(function() {
                imageProcessing(option,formName);
            }, 800);
        } 
    }     
}

function imageProcessing(option,formName){
    var request = '';
    var cssClass = '';
    var msg = '';
    var status = '';
    var albumId = '';
    var categoryId = '';
    var albumName = '';
    var categoryName = '';    
    var destination = 'includes/ajax/processing-scripts/gallery/process-gallery.php';
    var data = new FormData();
    var now = new Date;
    data.append('Option',option);
    if(document.getElementById(formName)){
        var fields = document.getElementById(formName).elements;
        var field_name = '';
        var field_value = '';
        var field_type = '';
        var field_choice = '';
        for(var i=0; i<fields.length; i++){
            field_name = fields[i].name;
            field_type = fields[i].type;
            switch(field_type){
                case "text":
                field_value = document.getElementById(field_name).value;
                data.append(field_name,field_value);
                break;
                case "hidden":
                field_value = document.getElementById(field_name).value;
                data.append(field_name,field_value);
                break;                
                case "textarea":
                if(document.getElementById('cke_'+field_name)){
                    field_value = CKEDITOR.instances[field_name].getData();
                    data.append(field_name,field_value);
                    }else{
                    field_value = document.getElementById(field_name).value;
                    data.append(field_name,field_value);
                                }
                break;
                case "radio":
                    var rdoBtns = document.getElementById(formName).elements[field_name];                                    
                    for(var k=0;k<rdoBtns.length;k++){
                        if(rdoBtns[k].checked){
                            field_value = rdoBtns[k].value;
                            break;
                        }
                    }
                    data.append(field_name,field_value);
                break;                
                case "select-one":
                    field_choice = document.getElementById(field_name).selectedIndex;
                    field_value = document.getElementById(field_name).options[field_choice].value;
                    data.append(field_name,field_value);
                break;
                case "file":
                    if(document.getElementById(field_name).files.length > 0){
                        data.append(field_name, document.getElementById(field_name).files[0]);  
                    }
                break;
            }
        }
    }
    data.append('Now',now);
    request = new XMLHttpRequest();		
    request.open("POST",destination,true);
    request.send(data);
    request.onreadystatechange = function(){  
    if(request.readyState == 4 && request.status == 200){
        if(document.getElementById('AnimationPopUp')){
                document.getElementById('AnimationPopUp').style.display = 'none';
            }else if(document.getElementById('AnimationAlt')){
                document.getElementById('AnimationAlt').style.display = 'none';
            }else{
            if(document.getElementById('Animation')){
                document.getElementById('Animation').style.display = 'none';
            }
        }      
        if(document.getElementById('Submit_Paragraph')){
                document.getElementById('Submit_Paragraph').style.display = 'block';
        }                   
        if(document.getElementById('Result')){
            const result = JSON.parse(request.responseText);	
            cssClass = result.Class;
            msg = result.Msg;
            status = result.Status;
            albumId = result.AlbumId;                             
            albumName = result.AlbumName;
            categoryId = result.CategoryId;                             
            categoryName = result.CategoryName;                          
            document.getElementById("Result").className = cssClass;
            document.getElementById("Result").innerHTML = msg;
            document.getElementById("Result").style.display = "block";
            if(option == 'Change-Album-Name'){
                if(status == 1){
                    var id = $("#AlbumId").val();
                    var name = $("#AlbumName").val();
                    $("#Title_"+id).attr('title',name);
                    $("#Title_"+id).html(name);
                    $('#PopUp').popUpWindow({action: "close"});
                }
            }else if(option == 'Change-Album-Category-Name'){
                if(status == 1){
                    var id = $("#CategoryId").val();
                    var name = $("#CategoryName").val();
                    $("#Title_"+id).attr('title',name);
                    $("#Title_"+id).html(name);
                    $('#PopUp').popUpWindow({action: "close"});
                }                                
            } else if (option == 'Image-Edit-Desc') {
                $('#PopUp').popUpWindow({
                    action: "close"
                });  
            } else if (option == 'Change-Image-Status') {
                $('#PopUp').popUpWindow({
                    action: "close"
                });  
            }else if(option == 'Change-Album-Category'){
                galleryDisplay();
            } else if (option == 'Change-Album-Status') {
                $('#PopUp').popUpWindow({
                    action: "close"
                });                           
            } else if (option == 'Change-Album-Category-Status') {
                $('#PopUp').popUpWindow({
                    action: "close"
                });                                                                                                       
            }else if(option == 'Delete-Album'){
                var id = $("#AlbumId").val();
                if($("#Album_"+id)){
                    $("#Album_"+id).remove();
                    var defaultMsg = '<p class="empty_msg">You do not have any albums to display.</p>';
                    var images = $("#Image_Listing div").length;
                    if(images == 0){
                        $("#Image_Listing").append(defaultMsg);
                    }                                    
                    $('#PopUp').popUpWindow({action: "close"});
                }
            }else if(option == 'Delete-Album-Category'){
                var id = $("#CategoryId").val();
                if($("#Cat_"+id)){
                    $("#Cat_"+id).remove();
                    var defaultMsg = '<p class="empty_msg">You do not have any album categories to display.</p>';
                    var images = $("#Image_Listing div").length;
                    if(images == 0){
                        $("#Image_Listing").append(defaultMsg);
                    }                                    
                    $('#PopUp').popUpWindow({action: "close"});
                }                                
            } else if (option == 'Change-Album') {
                if(status == '1'){
                    var id = $("#ImageId").val();
                    var albumChoice = document.getElementById('Album').selectedIndex;
                    var newAlbum = document.getElementById('Album').options[albumChoice].value;
                    var oldAlbum = $("#AlbumId").val();
                    if ($("#Image_" + id) && newAlbum != oldAlbum) {
                        $("#Image_" + id).remove();
                        var defaultMsg = '<p style="width:100%;text-align:center;padding-top:25px;">You do not have any images to display for this album.</p>';
                        var images = $("#Image_Listing div").length;
                        if (images == 0) {
                            $("#Image_Listing").append(defaultMsg);
                        }
                        $('#PopUp').popUpWindow({
                            action: "close"
                        });
                    }
                }                             
            }else if(option == 'Delete-Image'){
                var id = $("#ImageId").val();
                if($("#Image_"+id)){
                    $("#Image_"+id).remove();
                    var defaultMsg = '<p style="width:100%;text-align:center;padding-top:25px;">You do not have any photos to display.</p>';
                    var images = $("#Image_Listing div").length;
                    if(images == 0){
                        $("#Image_Listing").append(defaultMsg);
                    }
                    $('#PopUp').popUpWindow({action: "close"});
                }
            }else if(option == 'Add-Album'){
                if(status == '1'){
                    if($("#Display_Type").val() == 'All_Albums' || ($("#Display_Type").val() == 'Categories' && $("#CategoryId").val() != undefined)){                                  ;
                        if($(".empty_msg")){                                        
                            $(".empty_msg").remove();
                        }
                        var listingArea = $("#Image_Listing");
                        var defaultAlbum = '<div class="img_container" id="Album_'+albumId+'" name="Album_'+albumId+'">'; 
                        defaultAlbum += '<figure>';
                        defaultAlbum += '<figcaption title="'+albumName+'" id="Title_'+albumId+'" name="Title_'+albumId+'">';
                        if(categoryName != '' && $("#Display_Type").val() == 'All_Albums'){
                            defaultAlbum += '<strong>'+categoryName+'</strong><br/>';
                        }
                        defaultAlbum += albumName.substring(0,14);
                        if(albumName.length > 14){

                            defaultAlbum += ' ...';

                        }
                        defaultAlbum += '</figcaption>';
                        defaultAlbum += '<img src="images/default-thumb.jpg"  class="thumb-img"/>';
                        defaultAlbum += '</figure>';
                        defaultAlbum += '<span>';
                        defaultAlbum += '<select id="Album_Options_'+albumId+'" onchange="initiateAlbumPopup(\''+albumId+'\');">';
                        defaultAlbum += '<option value="">Options</option>';
                        defaultAlbum += '<option value="album-view-images">View Images</option>';
                        defaultAlbum += '<option value="add-images">Add Images</option>';
                        defaultAlbum += '<option value="album-change-name">Change Name</option>';
                        defaultAlbum += '<option value="album-change-status">Change Status</option>';
                        defaultAlbum += '<option value="album-set-display-image">Set Display Image</option>';
                        defaultAlbum += '<option value="album-delete">Delete</option>';
                        defaultAlbum += '</select>';                    
                        defaultAlbum += '</span>';
                        defaultAlbum += '<input type="hidden" value="'+albumName+'" id="AlbumName_'+albumId+'" name="AlbumName_'+albumId+'">';
                        defaultAlbum += '</div>';                                     
                        $(listingArea).append(defaultAlbum);                                    
                    }else{   
                        if($("#Albums")){       
                            var newAlbumOption = '<option value="'+albumId+'">'+albumName+'</option>';
                            $("#Albums").append(newAlbumOption); 
                        }                                   
                    }
                    $('#PopUp').popUpWindow({action: "close"});
                }
            }else if(option == 'Add-Album-Category'){
                if($("#Display_Type").val() == 'Categories' && !document.getElementById('CategoryId')){                                    
                    if($(".empty_msg")){                                        
                        $(".empty_msg").remove();
                    }
                    var listingArea = $("#Image_Listing");
                    var defaultCategory = '<div class="img_container" id="Cat_'+categoryId+'" name="Cat_'+categoryId+'">'; 
                    defaultCategory += '<figure>';
                    defaultCategory += '<figcaption title="'+categoryName+'" id="Title_'+categoryId+'" name="Title_'+categoryId+'">';
                    defaultCategory += categoryName.substring(0,14);
                    if(categoryName.length > 14){

                        defaultCategory += ' ...';

                    }
                    defaultCategory += '</figcaption>';
                    defaultCategory += '<img src="images/default-thumb.jpg"  class="thumb-img"/>';
                    defaultCategory += '</figure>';
                    defaultCategory += '<span>';
                    defaultCategory += '<select id="Album_Category_Options_'+categoryId+'" onchange="initiateAlbumCategoryPopup(\''+categoryId+'\');">';
                    defaultCategory += '<option value="">Options</option>';
                    defaultCategory += '<option value="album-category-albums">View All Albums</option>';                 
                    defaultCategory += '<option value="album-category-view-images">View All Images</option>';
                    defaultCategory += '<option value="album-category-change-name">Change Name</option>';
                    defaultCategory += '<option value="album-category-change-status">Change Status</option>';
                    defaultCategory += '<option value="album-category-set-display-image">Set Display Image</option>';
                    defaultCategory += '<option value="album-category-delete">Delete</option>';
                    defaultCategory += '</select>';                    
                    defaultCategory += '</span>';
                    defaultCategory += '<input type="hidden" value="'+categoryName+'" id="CategoryName_'+categoryId+'" name="CategoryName_'+categoryId+'">';
                    defaultCategory += '</div>';                                     
                    $(listingArea).append(defaultCategory);                                    
                    }else{          
                    var newAlbumCategoryOption = '<option value="'+categoryId+'">'+categoryName+'</option>';
                    $("#Categories").append(newAlbumCategoryOption);                                    
                }
                $('#PopUp').popUpWindow({action: "close"});
            }
        }
        }
    }  
}

function clearImageForm(formName){
    if(document.getElementById(formName)){
        var fields = document.getElementById(formName).elements;
        var field_name = '';
        var field_type = '';
        var field_choice = '';
        for(var i=0; i<fields.length; i++){
            field_name = fields[i].name;
            field_type = fields[i].type;                        
            switch(field_type){
                case "text":
                    document.getElementById(field_name).value = '';
                break;
                case "textarea":
                    document.getElementById(field_name).value = '';
                break;
                case "select-one":
                    if(field_name != 'Album'){                               
                        if($("#"+field_name).val() == 'New'){                                   
                            $("#"+field_name+" option[value='']").attr('selected',true);  
                        }
                    }
                break;
            }
        }
    }
}

function galleryAlbum(){
    if($("#Album")){
        var type = $("#Album").val();
        if(type == 'New'){
            $("#AlbumName").css("display","block");
        }else{
            $("#AlbumName").css("display","none");
        }
    }
}

function galleryDisplay(categoryId){
    $( "#RowContainer" ).fadeOut( "slow", 0.0, function(){ 
         if(document.getElementById('Animation')){
                 document.getElementById('Animation').style.display = 'block'; 
                 setTimeout(function(){processGalleryDisplay(categoryId)},800);
         }else{
                 processGalleryDisplay(categoryId);
         }
    });        
}

function processGalleryDisplay(categoryId){    
    if(categoryId == undefined){
        var option = $("#Display_Type").val();
    }else if(categoryId != ''){
        var option = 'Albums_By_Category';
    }
    var destination = 'includes/ajax/processing-scripts/gallery/process-gallery-display.php';
    var data = new FormData();
    var now = new Date;
    data.append('Option',option);
    data.append('Now',now);
    if(option == 'Albums_By_Category' && categoryId != undefined){
        data.append('AlbumCategoryId',categoryId);
    }
    request = new XMLHttpRequest();		
    request.open("POST",destination,true);
    request.send(data);
    request.onreadystatechange = function(){              
        if(request.readyState == 4 && request.status == 200){
            if(document.getElementById('Animation')){
                    document.getElementById('Animation').style.display = 'none';
            }
            if(document.getElementById("RowContainer")){                    
                document.getElementById("RowContainer").innerHTML = request.responseText;
                $( "#RowContainer" ).fadeIn( "slow" );
            }
        }
    } 
}

function getImages(albumId,catId){
    $( "#RowContainer" ).fadeOut( "slow", 0.0, function(){ 
         if(document.getElementById('Animation')){
                 document.getElementById('Animation').style.display = 'block'; 
                 setTimeout(function(){processGetImages(albumId,'',catId)},800);
         }else{
                 processGetImages(albumId,'',catId);
         }
    });        
}

function getCategoryImages(categoryId){
    $( "#RowContainer" ).fadeOut( "slow", 0.0, function(){ 
         if(document.getElementById('Animation')){
                 document.getElementById('Animation').style.display = 'block'; 
                 setTimeout(function(){processGetCategoryImages(categoryId,'')},800);
         }else{
                 processGetCategoryImages(categoryId,'');
         }
    });        
}

function getAlbumsByCategory(albumCategoryId){
    $( "#RowContainer" ).fadeOut( "slow", 0.0, function(){ 
         if(document.getElementById('Animation')){
                 document.getElementById('Animation').style.display = 'block'; 
                 setTimeout(function(){processGetAlbumsByCategory(albumCategoryId)},800);
         }else{
            processGetAlbumsByCategory(albumCategoryId);
         }
    });        
}

function processGetImages(albumId,display,catId){
    var albumReturn = 0;
    if(albumId == ''){
        var album = $("#Albums").val();
    }else{
        album = albumId;
        albumReturn = 1;
    }
    var destination = 'includes/ajax/processing-scripts/gallery/process-gallery-display.php';
    var data = new FormData();
    var now = new Date;
    if(catId == '' || catId === undefined){

        data.append('Option','Album_Images');
    
    }else{

        data.append('Option','Category_Album_Images');
        data.append('AlbumCategoryId',catId);        

    }
    if(document.getElementById('All')){
        data.append('All','All');
    }
    data.append('Album',album);
    data.append('AlbumReturn',albumReturn);
    data.append('DisplayImage',display);
    data.append('Now',now);
    request = new XMLHttpRequest();		
    request.open("POST",destination,true);
    request.send(data);
    request.onreadystatechange = function(){              
        if(request.readyState == 4 && request.status == 200){
            if(document.getElementById('Animation')){
                   document.getElementById('Animation').style.display = 'none';
            }                    
            document.getElementById("RowContainer").innerHTML = request.responseText;
            $( "#RowContainer" ).fadeIn( "slow" );				
        }
    }  
}

function processGetCategoryImages(categoryId,display){
    var destination = 'includes/ajax/processing-scripts/gallery/process-gallery-display.php';
    var data = new FormData();
    var now = new Date;
    data.append('Option','Album_Category_Images');
    if(document.getElementById('All')){
        data.append('All','All');
    }
    data.append('AlbumCategoryId',categoryId);
    data.append('DisplayImage',display);
    data.append('Now',now);
    request = new XMLHttpRequest();		
    request.open("POST",destination,true);
    request.send(data);
    request.onreadystatechange = function(){              
        if(request.readyState == 4 && request.status == 200){
            if(document.getElementById('Animation')){
                   document.getElementById('Animation').style.display = 'none';
            }                    
            document.getElementById("RowContainer").innerHTML = request.responseText;
            $( "#RowContainer" ).fadeIn( "slow" );				
        }
    }  
}

function processGetAlbumsByCategory(albumCategoryId){
    var destination = 'includes/ajax/processing-scripts/gallery/process-gallery-display.php';
    var data = new FormData();
    var now = new Date;
    data.append('Option','Albums_By_Category');
    data.append('AlbumCategoryId',albumCategoryId);
    data.append('Now',now);
    request = new XMLHttpRequest();		
    request.open("POST",destination,true);
    request.send(data);
    request.onreadystatechange = function(){              
        if(request.readyState == 4 && request.status == 200){
            if(document.getElementById('Animation')){
                   document.getElementById('Animation').style.display = 'none';
            }                    
            document.getElementById("RowContainer").innerHTML = request.responseText;
            $( "#RowContainer" ).fadeIn( "slow" );				
        }
    }  
}

function initiateAlbumPopup(id){
    var album = $("#Album_Options_"+id).val();
    if(album != ''){
        switch(album){
            case "album-view-images":
                getImages(id);
            break;           
            case "album-change-name":
                initiatePopup(album,id);
                $("#Album_Options_"+id).prop('selectedIndex',0);
            break;
            case "album-change-status":
                initiatePopup(album,id);
                $("#Album_Options_"+id).prop('selectedIndex',0);
            break;
            case "album-change-category":
                initiatePopup(album,id);
                $("#Album_Options_"+id).prop('selectedIndex',0);
            break;            
            case "album-delete":
                initiatePopup(album,id);
                $("#Album_Options_"+id).prop('selectedIndex',0);
            break;
            case "album-set-display-image":
               processGetImages(id,'Display'); 
            break;          
            case "add-images":
                contentChanger('gallery/add-photos.php',id,'','gallery/gallery.php');
            break;
        }
    }
}

function setDisplayImage(imageId,albumId){
       if($('#Display_'+imageId).prop('checked')){
           $("input[type=checkbox]").each(function(){
               if($(this).attr('id') != ('Display_'+imageId)){
                    $(this).prop("checked", false);
               }
           });
       }
       var destination = 'includes/ajax/processing-scripts/gallery/process-gallery.php';
       var data = new FormData();
       var now = new Date;
       data.append('Option','Set-Display-Image');
       data.append('Now',now);
       data.append('ImageId',imageId);
       data.append('AlbumId',albumId);
        request = new XMLHttpRequest();		
        request.open("POST",destination,true);
        request.send(data);
        request.onreadystatechange = function(){  
                if(request.readyState == 4 && request.status == 200){  
                    
               }
        }
}

function setAlbumCategoryDisplayImage(imageId,categoryId){
    if($('#Display_'+imageId).prop('checked')){
        $("input[type=checkbox]").each(function(){
            if($(this).attr('id') != ('Display_'+imageId)){
                 $(this).prop("checked", false);
            }
        });
    }
    var destination = 'includes/ajax/processing-scripts/gallery/process-gallery.php';
    var data = new FormData();
    var now = new Date;
    data.append('Option','Set-Album-Category-Display-Image');
    data.append('Now',now);
    data.append('ImageId',imageId);
    data.append('CategoryId',categoryId);
     request = new XMLHttpRequest();		
     request.open("POST",destination,true);
     request.send(data);
     request.onreadystatechange = function(){  
             if(request.readyState == 4 && request.status == 200){  
                 
            }
     }
}

function initiateImagePopup(id){
    var image = $("#Image_Options_"+id).val();
    if(image != ''){
        switch(image){
            case "image-change-album":
                initiatePopup(image,id);
                $("#Image_Options_"+id).prop('selectedIndex',0);
            break;
            case "image-edit-description":
                initiatePopup(image,id);
                $("#Image_Options_"+id).prop('selectedIndex',0);
            break;
            case "image-change-status":
                initiatePopup(image,id);
                $("#Image_Options_"+id).prop('selectedIndex',0);
            break;
            case "image-delete":
                initiatePopup(image,id);
                $("#Image_Options_"+id).prop('selectedIndex',0);
            break;
        }
    }
}

function processGetAlbums(categoryId){
    var albumReturn = 0;
    var displayImage = '';
    if(categoryId == ''){
        var category = $("#Categories").val();
    }else{
        category = categoryId;
        categoryReturn = 1;
        displayImage = display;
    }
    var destination = 'includes/ajax/processing-scripts/gallery/process-gallery-display.php';
    var data = new FormData();
    var now = new Date;
    data.append('Option','Albums');
    data.append('Category',category);
    data.append('CategoryReturn',categoryReturn);
    data.append('DisplayImage',displayImage);
    data.append('Now',now);
    request = new XMLHttpRequest();		
    request.open("POST",destination,true);
    request.send(data);
    request.onreadystatechange = function(){              
        if(request.readyState == 4 && request.status == 200){
            if(document.getElementById('AnimationAlt')){
                   document.getElementById('AnimationAlt').style.display = 'none';
            }                    
            document.getElementById("Image_Listing").innerHTML = request.responseText;
            $( "#Image_Listing" ).fadeIn( "slow" );				
        }
    }  
}

function initiateAlbumCategoryPopup(id){
    var c = $("#Album_Category_Options_"+id).val();
    if(c != ''){
        switch(c){
            case "album-category-albums":
                getAlbumsByCategory(id);
            break;
            case "album-category-view-images":
                getCategoryImages(id,'');
            break;
            case "album-category-change-name":
                initiatePopup(c,id);
                $("#Album_Category_Options_"+id).prop('selectedIndex',0);
            break;
            case "album-category-change-status":
                initiatePopup(c,id);
                $("#Album_Category_Options_"+id).prop('selectedIndex',0);
            break;
            case "album-category-set-display-image":
               processGetCategoryImages(id,'Display'); 
            break; 
            case "album-category-delete":
                initiatePopup(c,id);
                $("#Album_Category_Options_"+id).prop('selectedIndex',0);
            break;
        }
    }
}

function updateAlbums(){
    if($("#AlbumName")){
        $("#AlbumName").css("display","none");
    }
    var destination = 'includes/ajax/processing-scripts/gallery/process-gallery-display.php';
    var data = new FormData();
    var now = new Date;
    var option = 'Update_Album_Menu';
    var category = document.getElementById('Category').value;
    data.append('CategoryId',category);
    data.append('Now',now);
    data.append('Option',option);
    request = new XMLHttpRequest();		
    request.open("POST",destination,true);
    request.send(data);
    request.onreadystatechange = function(){              
        if(request.readyState == 4 && request.status == 200){
			document.getElementById('Album-Menu').innerHTML = request.responseText;
        }
    }  
}

function initiateAlbumCategoryAlbumPopup(id){
    var album = $("#Album_Options_"+id).val();
    var catId = $("#CategoryId").val();
    if(album != ''){
        switch(album){
            case "album-view-images":
                getImages(id,catId);
            break;           
            case "album-change-name":
                initiatePopup(album,id);
                $("#Album_Options_"+id).prop('selectedIndex',0);
            break;
            case "album-change-status":
                initiatePopup(album,id);
                $("#Album_Options_"+id).prop('selectedIndex',0);
            break;
            case "album-change-category":
                initiatePopup(album,id);
                $("#Album_Options_"+id).prop('selectedIndex',0);
            break;            
            case "album-delete":
                initiatePopup(album,id);
                $("#Album_Options_"+id).prop('selectedIndex',0);
            break;
            case "album-set-display-image":
               processGetImages(id,'Display',catId); 
            break;          
            case "add-images":
                contentChanger('gallery/add-photos.php',id,'','gallery/gallery.php');
            break;
        }
    }
}