'******************************************
'*** Format YouTube File Support ***
'******************************************
'This function formats falsh codes
Function formatYouTube(ByVal strMessage)
'Declare variables
Dim lngStartPos 'Holds search start postions
Dim lngEndPos 'Holds end start postions
Dim saryYouTubeAttributes 'Holds the features of the input YouTube file
Dim intAttrbuteLoop 'Holds the attribute loop counter
Dim strYouTubeWidth 'Holds the string value of the width of the YouTube file
Dim intYouTubeWidth 'Holds the interger value of the width of the YouTube file
Dim strYouTubeHeight 'Holds the string value of the height of the YouTube file
Dim intYouTubeHeight 'Holds the interger value of the height of the YouTube file
Dim strBuildYouTubeLink 'Holds the converted BBcode for the YouTube file
Dim strTempYouTubeMsg 'Tempoary store for the BBcode
Dim strYouTubeLink 'Holds the link to the YouTube file
'Loop through all the codes in the message and convert them to formated YouTube links
Do While InStr(1, strMessage, "[YOUTUBE]", 1) > 0 AND InStr(1, strMessage, "[/YOUTUBE]", 1) > 0
'Initiliase variables
intYouTubeWidth = 425
intYouTubeHeight = 350
strYouTubeLink = ""
strBuildYouTubeLink = ""
strTempYouTubeMsg = ""
'Get the YouTube BBcode from the message
lngStartPos = InStr(1, strMessage, "[YOUTUBE]", 1)
lngEndPos = InStr(lngStartPos, strMessage, "[/YOUTUBE]", 1) + 10
'Make sure the end position is not in error
If lngEndPos < lngStartPos Then lngEndPos = lngStartPos + 9
'Get the original YouTube BBcode from the message
strTempYouTubeMsg = Trim(Mid(strMessage, lngStartPos, lngEndPos-lngStartPos))
'Get the link to the YouTube file
lngStartPos = InStr(1, strTempYouTubeMsg, "]", 1) + 1
lngEndPos = InStr(lngStartPos, strTempYouTubeMsg, "[/YOUTUBE]", 1)
'Make sure the end position is not in error
If lngEndPos < lngStartPos Then lngEndPos = lngStartPos + 8
'Read in the code to be converted into a hyperlink from the message
strYouTubeLink = Trim(Mid(strTempYouTubeMsg, lngStartPos, (lngEndPos - lngStartPos)))
'Build the HTML for the displying of the YouTube file
If strYouTubeLink <> "" Then
strBuildYouTubeLink = "<embed src=""
http://www.youtube.com/v/" & strYouTubeLink & """"
strBuildYouTubeLink = strBuildYouTubeLink & " quality=high width=" & intYouTubeWidth & " height=" & intYouTubeHeight & " type=""application/x-shockwave-flash"" pluginspage=""
'>http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash""></embed>"
End If
If strBuildYouTubeLink <> "" Then
strMessage = Replace(strMessage, strTempYouTubeMsg, strBuildYouTubeLink, 1, -1, 1)
Else
strMessage = Replace(strMessage, strTempYouTubeMsg, Replace(strTempYouTubeMsg, "[", "[", 1, -1, 1), 1, -1, 1)
End If
Loop
'Return the function
formatYouTube = strMessage
End Function