﻿
function SubmitToPostlist(intGiID,strGoodMessage,strBadMessage,strDatamissing)
{
    // form name is "postlist_form"
    postlistForm = document.getElementById("postlist_form");

    strName = document.getElementById("postlist_name").value;
    strEmail = document.getElementById("postlist_email").value;
    strComment = document.getElementById("postlist_comment").value;

    if (strName.length == 0)
    {
        alert(strDatamissing);
        return;
    }

    if (strEmail.length == 0)
    {
        alert(strDatamissing);
        return;
    }

    $.ajax
            (
                {
                    type: "POST",
                    url: "/images/Functions.asmx/AddToPostlist",
                    data: "{'GI_ID':" + intGiID + ",'Name':'" + strName + "','Email':'" + strEmail + "','Comment':'" + strComment + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    error: function(objRequest, strTextStatus, errErrorThrown)
                    {
                        alert(strTextStatus + " " + errErrorThrown);
                    },
                    success: function(msg)
                    {
                        if (msg.d.substring(2, 0) == "OK")
                        {
                            document.getElementById("postlist_name").value = "";
                            document.getElementById("postlist_email").value = "";
                            document.getElementById("postlist_comment").value = "";

                            alert(strGoodMessage);
                        }
                        else
                        {
                            alert(strBadMessage);
                        }
                    }
                }
           )

}

		function shAddGuestBook()
		{			
			DisplayIt(true,document.getElementById('AddGuestBookRecord'));
		}
		
		function shAddComment(objToShow)
		{
			DisplayIt(true,objToShow);
		}
		
		function shComments(objToShow)
		{
			DisplayIt(true,objToShow);			
		}
		
		function ViewAccessForm()
		{			
			DisplayIt(true,document.getElementById('GiveAccessForm'));
		}
		
		function DisplayAlbumCat( cat_id )
		{
			obj = document.getElementById('Albums_' + cat_id);
			
			DisplayIt( (obj.style.display=='none'),obj);	
		}
		
		function DisplayFolder( objFolder )
		{						
			DisplayIt( (objFolder.style.display=='none'),objFolder);	
		}	
		
		function DisplayFolderInSecondNavbar( subPageUlId)
		{
			// Show the container
			DisplayIt( true ,document.getElementById('SecondNavBar'));							
			
			// Hide all first
			for(i=0;i<secondnavbar_array.length;i++)
			{				
				var tempObjUL = document.getElementById('SubFolder_' + secondnavbar_array[i]);
				DisplayIt( false,tempObjUL);					
			}
			
			// Show the one that was requested
			var objUL = document.getElementById('SubFolder_' + subPageUlId);
			DisplayIt( true,objUL);
			
		}

		function ValidateCommentBlogForm(formID,strErrMessage) 
		{
		    // Let's find the form
		    theForm = document.getElementById(formID);

		    if (theForm.guid_result.value.length == 0) 
		    {
		        theForm.guid_result.style.border = '1px solid red';
		        alert(strErrMessage);
		        return (false);
		    }
		    return (true);
		}