// JavaScript Document
//
////////////////
// highlight_me
////////////////
//
// Create a "Link to Video Using HTML Code" text box with "Highlight HTML" button 
// Note: use this script only once per page so ID access is not duplicated
//
//		Example usage:
//			title_tag: "h3"
//			subtitle_tag: "tt"
//			video_link: "http://www.lecturemaker.com/2011/02/rhipe/#video"
//			display_text_title: "RHIPE: An Interface Between Hadoop and R"
//			display_text_subtitle: "Presented by Saptarshi Guha"
//			image_link: "http://www.lecturemaker.com/lectures/RMeetUp2010/RHIPE_Lecture.jpg"
//			image_width: "300"
//			image_height: "169"
//			textarea_width: "80"
//			textarea_height: "5"
function highlight_me (title_tag, subtitle_tag, video_link, display_text_title, display_text_subtitle, image_link, image_width, image_height, textarea_width, textarea_height) {

  // test these variables as they have been added after script was already deployed
  textarea_width = (typeof textarea_width == 'undefined') ? 60 : textarea_width;
  textarea_height = (typeof textarea_height == 'undefined') ? 4 : textarea_height;
  
  document.write("<"+title_tag+">Share Link to Video Using HTML Code</"+title_tag+">");
  //document.write("      <div id=\"served-html\">");
  document.write("      <" + subtitle_tag + ">Highlight the HTML code and copy it to your web page</" + subtitle_tag + "><br/>");
  document.write("<textarea readonly=\"readonly\"");
  document.write("          id=\"served_html_box\"");
  document.write("          cols=\""+textarea_width+"\""); 
  document.write("          rows=\""+textarea_height+"\"><div><strong>");
  document.write("<a href=\"" + video_link + "\" title=\"Click link to go to the video page\">" + display_text_title + "</a>");
  document.write("</strong><br/>" + display_text_subtitle + "</div>");
  document.write("<a href=\"" + video_link + "\"><img src=\"" + image_link + "\" alt=\"Video Link\" width=\"" + image_width + "\" height=\"" + image_height + "\" border=\"0\" title=\"Click image to go to the video page\" /></a>");
  document.write("          </textarea>");
  document.write("<div>");
  document.write("          <img alt=\"[ Highlight HTML ]\"");
  document.write("          type=\"image\" ");
  document.write("    onclick=\"document.getElementById('served_html_box').focus();document.getElementById('served_html_box').select(); return false;\" ");
  document.write("       src=\"http://www.lecturemaker.com/images/highlight_html.gif\" ");
  document.write("       style=\"display:none;width:104px;height:22px;margin-top:1em;\" ");
  document.write("       border=\"0\" ");
  document.write("       id=\"served_html_box-img\"/>");
  document.write("</div>");
  
  document.getElementById('served_html_box-img').style.display = '';
}
