//
//  Name:  blog.js
//  Author:  drew.zimber@gmail.com
//  Description:  Javascript file for blog admin application.
//

// simple script that adds html img code to content for 
// a specified image url
function addBlogImage()
{
   var image = prompt("Type in the location of the image (http://domain.com/myimage.jpg):");
   
   if ( image != "" && image.indexOf("http://") > -1 )
   {
       var imageHTML = "<a href=\"" + image + "\" target=\"_blank\"><img src=\"" + image + "\" /></a>";
   
       var blogContent = document.getElementById("bc");
       blogContent.value = blogContent.value + imageHTML;
   }
   else
   {
       alert("Error:  Image must be a valid URL (http://foo.com/mypic.jpg)");
   }
}

// simple script that adds html link code to content for 
// a specified url
function addBlogLink()
{
   var link = prompt("Type in the location of the link ( http://domain.com/ ):");
   
   if ( link != "" && link.indexOf("http://") > -1 )
   {
       var linkHTML = "<a href=\"" + link + "\" target=\"_blank\" class=\"bloglink\">" + link + "</a>";
       
       var blogContent = document.getElementById("bc");
       blogContent.value = blogContent.value + linkHTML;
   }
   else
   {
       alert("Error:  Link must be a valid URL ( http://foo.com/somelink.html )");
   }
}

//  submits blog entry
function submitBlog()
{
    document.form1.submit();
}

// removes a blog entry
function removeBlog()
{
    document.form2.submit();
}
