/*==================================================
 misjs
 basado en el code de ...
  ==================================================*/
  
function youtube_embed_code() {
     /* Grab the url and identify the target textbox */
     var vidUrl = document.getElementById('txtYouTubeURL').value;

     var textBox = document.getElementById("comment");

     /* Check for valid match */
     var regex=/http:\/\/([a-zA-Z0-9]+\.)?youtube\.com\/watch\?v=(.*)/ig;
     var m=regex.exec(vidUrl);

     /* If there is a match */
     if(m && m.length>2) {
		  
          /* Add the embed code to the textbox */
          textBox.value += "httpv://www.youtube.com/watch?v=" + m[2] + "[\/youtube]"; /*"[youtube " + m[2] + " " + vidUrl + " youtube]";   "[youtube]" + vidUrl + "[/youtube]"; */

          /* reset the regex */
          regex.lastIndex=0;

          /* Give focus to the text box */
          textBox.focus();

     }
     else
          /* Failed to match the url */
          alert('URL incorrecta');
};
