var SMS = {

   init: function()
   {

      // Comment logic
      $("a.smsCommentLink").click(function(){
         //$(this).parent().next().slideToggle();
         $('.smsCommentForm').slideToggle();
         return false;
      });

      // Auto-focus on search
      $("#sSearchStr").focus();


   }

}



$(document).ready(function(){
   SMS.init();

   flowplayer("a.flowPlayer", "flowplayer/flowplayer-3.1.5.swf", {

      clip:  {
         autoPlay: false,
         autoBuffering: true
      }

   });

});


function viewImgLrg(imgSrc)
{

   $("#smsPicDialog").html("<img src='"+imgSrc+"'>");
   $("#smsPicDialog").dialog({
      open: function(event, ui)
      {
         $("#smsPicDialog").dialog('option', 'height', 'auto');
         $("#smsPicDialog").dialog('option', 'width', 'auto');
      },
      close:   function(event, ui)
      {

         $("#smsPicDialog").dialog('destroy');

      }

   });


}







function AjaxComment(iPostId)
{


   if(iPostId !="")
   {

      var sAlias = $("#Comment_Alias").val();
      var sComment = $("#Comment_Textarea").val();

      sSerialize = $("#SMS_CommentForm").serialize();

      if((sComment != "") && (sAlias != ""))
      {
         var sData = "sRequest=Ajax&sType=Post&Post_Id="+ iPostId +"&sAction=addComment&" + sSerialize;

         $.ajax({

            type:   "POST",
            url:    "pgManual.php",
            data:   sData,
            success: function(msg)
            {
               $("#commentDesc div.error").remove();
               $("#commentDesc div.success").remove();
               $("#commentDesc").append("<div class='success'>Din kommentar &auml;r nu tillagd och kommer att granskas av en administrat&ouml;r.</div>");
            }

         });
      }
      else
      {
         $("#commentDesc div.error").remove();
         $("#commentDesc div.success").remove();
         $("#commentDesc").append("<div class='error'>Du m&aring;ste ange b&aring;de alias och kommentar!</div>");
      }
   }
   else
   {
      alert("Din kommentar kunde inte l&auml;ggas till. F&ouml;rs&ouml;k igen senare.")
   }

   return false;
}







function ScrollToAnchor()
{

   var sUrlAnchor = self.document.location.hash;

   sUrlAnchor = sUrlAnchor.replace("#", "");

   $.scrollTo("a[name='"+sUrlAnchor+"']");
}
