﻿// JScript File

function getPhoto(photo_id, gallery_id, par1, par2){


            myTarget = document.getElementById("please_wait"); 
            myTarget.innerHTML =  "<IMG SRC='../../images/icons/please_wait.gif' ALT=''><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>";


           if (par1 == 20)
           {
               var myPhotoRename = document.getElementById("rename_photo");
               par2 = myPhotoRename.value;
           }
           
           if (par1 == 30)
           {
               var myPhotoRename = document.getElementById("tag_photo");
               par2 = myPhotoRename.value;
           }
           
           if (par1 == 50)
           {
               var myPhotoRename = document.getElementById("reply_area");
               par2 = myPhotoRename.value;
               //alert(par2);
           }
           
           var myReturn = photo_id + "|" + gallery_id + "|" + par1  + "|" + par2;
           
          // alert("send: " + myReturn);

            UseCallback_photo(myReturn);
   

    
}

function GetPhotoFromServer(TotalStr, context){
    //alert(TotalStr)
    myTarget = document.getElementById("please_wait"); 
    myTarget.innerHTML =  "";
    
       var myRegExp = new RegExp(/\|/)
       photo_info_array = TotalStr.split(myRegExp);   
 
      switch (photo_info_array[0]) { 
      
        case "copied": 
                getGallery(photo_info_array[1], photo_info_array[2], 0, "")
                break;         
               

        case "tag_saved": 
                getGallery(photo_info_array[1], photo_info_array[2], 0, "")
                break;                  
                                        

        case "deleted": 
                getGallery(photo_info_array[1], photo_info_array[2], 0, "")
                break;                
                
        case "tag_retreved": 
        
                var myEditPhoto = document.getElementById("info_area"); 
                myEditPhoto.style.visibility = 'visible';
                var myEditString = "<table border='0' bgcolor='white' cellpadding='0' cellspacing='5' width='100%'><tr><td>";
                myEditString = myEditString + "<textarea id='tag_photo' type='text'  cols='50' rows='6' class='box_one'>" + photo_info_array[1] +"</textarea>&nbsp;<a href='javascript:getPhoto(&quot;" + photo_info_array[2] + "&quot;, &quot;" + myGalleryID + "&quot;, 30, &quot;&quot;);'>add tags</a>";
                myEditString = myEditString + "</td></tr></table>";
               myEditPhoto.innerHTML = myEditString 
                
                break; 
  
         case "info_retreved": 

                var myEditPhoto = document.getElementById("info_area"); 
                myEditPhoto.style.visibility = 'visible';
                var myEditString = "<table border='0' bgcolor='white' cellpadding='0' cellspacing='5' width='100%'><tr><td><table border='0' bgcolor='white' cellpadding='0' cellspacing='0' width='100%'>";
                if (photo_info_array[5] != ""){myEditString = myEditString + "<tr valign='top'><td><p class='edit_details' align='right'>uploaded by:&nbsp;</p></td><td><p class='edit_details' align='left'>" + photo_info_array[5] +" on " + photo_info_array[8] +"</p></td></tr>"}
                if (photo_info_array[7] != " "){myEditString = myEditString + "<tr valign='top'><td><p class='edit_details' align='right'>description:&nbsp;</p></td><td><p class='edit_details' align='left'>" + photo_info_array[7] +"</p></td></tr>"}
                if (photo_info_array[3] != ""){myEditString = myEditString + "<tr valign='top'><td><p class='edit_details' align='right'>dimensions:&nbsp;</p></td><td><p class='edit_details' align='left'>" + photo_info_array[3] +" wide&nbsp;&&nbsp; " + photo_info_array[4] +"&nbsp;high</p></td></tr>"}
                if (photo_info_array[6] != ""){myEditString = myEditString + "<tr valign='top'><td><p class='edit_details' align='right'>copyright&nbsp;status:&nbsp;</p></td><td><p class='edit_details' align='left'>" + photo_info_array[6] +"</p></td></tr>"}
               myEditString = myEditString + "</table>";

               myEditString = myEditString + "</td></tr></table>";
               myEditPhoto.innerHTML = myEditString 
                
                break; 
               
         case "comments":         

               var myEditPhoto = document.getElementById("info_area"); 
               myEditPhoto.style.visibility = 'visible';
               var myEditString = "<table border='0' bgcolor='white' cellpadding='0' cellspacing='20' width='100%'><tr><td>";
               myEditString = myEditString + photo_info_array[1];
               myEditString = myEditString + "</td></tr></table>";

               myEditPhoto.innerHTML = myEditString 
                  
                break; 
                
         case "default":         
              //  alert("default");
                var myEditPhoto = document.getElementById("info_area"); 
                myEditString = "<p class='body_text_7' style='color:white'>Default photo from gallery has been updated.</p>";
                myEditPhoto.innerHTML = myEditString 
               
                break; 
                
        default: 
        
                var myPhoto = photo_info_array[1]
                document.images["main_photo"].src = myPhoto;

                var myEditPhoto = document.getElementById("info_area"); 
                myEditPhoto.innerHTML = "<table border='0' bgcolor='white' cellpadding='0' cellspacing='5' width='100%'><tr><td><p class='photo_footer'><a href='javascript:getPhoto(&quot;" + photo_info_array[2] + "&quot;,&quot;" + myGalleryID + "&quot;, 3, &quot;" + photo_info_array[4] + "&quot;);' style='color:black' >accept rotation</a>&nbsp;&nbsp;&nbsp;<a href='javascript:getGallery(&quot;" + myGalleryID + "&quot;,&quot;"+ photo_info_array[3] + "&quot;, 0,&quot;&quot;);' style='color:black' >cancel rotation</a></p></td></tr></table>";
                  
                break;                               
      } 
 } 

function showEditFunctions(photo_id, gallery_id){

       var myEditPhoto = document.getElementById("info_area"); 

        if  (myEditPhoto.style.visibility == "visible"){

                myEditPhoto.style.visibility = 'hidden';

        }
        else
        {

               myEditPhoto.style.visibility = 'visible';
               var myEditString = "<table border='0' bgcolor='white' cellpadding='0' cellspacing='5' width='100%'><tr><td>";
               myEditString = myEditString + "<p class='edit_details'><a href='javascript:getPhoto(&quot;" + photo_details_array[2] + "&quot;, &quot;" + myGalleryID + "&quot;, 90, &quot;&quot;);' style='color:black' >rotate 90º</a>&nbsp;&nbsp;<a href='javascript:getPhoto(&quot;" + photo_details_array[2] + "&quot;, &quot;" + myGalleryID + "&quot;, 180, &quot;&quot;);' style='color:black' >rotate 180º</a>&nbsp;&nbsp;<a href='javascript:getPhoto(&quot;" + photo_details_array[2] + "&quot;, &quot;" + myGalleryID + "&quot;, 270, &quot;&quot;);' style='color:black' >rotate 270º</a>&nbsp;&nbsp;<a href='javascript:getPhoto(&quot;" + photo_details_array[2] + "&quot;, &quot;" + myGalleryID + "&quot;, 55, &quot;&quot;);' style='color:black' >[set&nbsp;as&nbsp;default]</a>&nbsp;&nbsp;</p>"
               myEditString = myEditString + "<input id='rename_photo' type='text' size=45 class='box_one' value='" + photo_details_array[1] +"' />&nbsp;<a href='javascript:getPhoto(&quot;" + photo_details_array[2] + "&quot;, &quot;" + myGalleryID + "&quot;, 20, &quot;&quot;);'>photo title</a>";
              myEditString = myEditString + "<p class='edit_details' align='center'><a href='javascript:getPhoto(&quot;" + photo_details_array[2] + "&quot;, &quot;" + myGalleryID + "&quot;, 2000, &quot;&quot;);'>delete photo</a></p>"; 
               myEditString = myEditString + "</td></tr></table>";

               //alert(myArray);
                myEditPhoto.innerHTML = myEditString

        }

} 


function showTagFunctions(){

       var myEditPhoto = document.getElementById("info_area"); 

        if  (myEditPhoto.style.visibility == "visible"){

                myEditPhoto.style.visibility = 'hidden';

        }
        else
        {
       
               getPhoto(photo_details_array[2], myGalleryID , 31, '');  

        }

} 

function showRateFunctions(){
       var myEditPhoto = document.getElementById("info_area"); 

        if  (myEditPhoto.style.visibility == "visible"){

                myEditPhoto.style.visibility = 'hidden';

        }
        else
        {
       
              showRateArea("info_area", photo_details_array[2], 8);

        }
        
}



function showReportFunctions(){

       var myEditPhoto = document.getElementById("info_area"); 

        if  (myEditPhoto.style.visibility == "visible"){

                myEditPhoto.style.visibility = 'hidden';

        }
        else
        {
             //  alert(photo_details_array[2]);
               showReportedArea(photo_details_array[2], "info_area",  8);

        }

}

function showInfoFunctions(){

       var myEditPhoto = document.getElementById("info_area"); 

        if  (myEditPhoto.style.visibility == "visible"){

                myEditPhoto.style.visibility = 'hidden';

        }
        else
        {
       
               getPhoto(photo_details_array[2], myGalleryID , 41, '');  

        }

} 


function showCommentsFunctions(){

       var myEditPhoto = document.getElementById("info_area"); 

        if  (myEditPhoto.style.visibility == "visible"){

                myEditPhoto.style.visibility = 'hidden';

        }
        else
        {
       
               getPhoto(photo_details_array[2], myGalleryID , 51, '');  

        }

} 

function clearNewComment(){

            var myCommentText = document.getElementById("reply_area"); 

            if (myCommentText.innerHTML == "new comment..."){

                myCommentText.innerHTML = ""
                
            }

}

function showNewComment(){

       var myEditPhoto = document.getElementById("new_comment"); 
       var myEditPhotoWord = document.getElementById("add_new_word"); 

        if  (myEditPhoto.style.display == "block"){

                myEditPhoto.style.display = "none";  
               myEditPhotoWord.innerHTML = "<p class='edit_details' align='left'><a href='javascript:showNewComment();'>add new comment</a></p>" 

        }
        else
        {
       
               myEditPhoto.style.display = "block";     
               myEditPhotoWord.innerHTML = "<p class='edit_details' align='left'><a href='javascript:showNewComment();'>hide new comment</a></p>" 

        }

} 
