https://www.icyphoenix.com/viewtopic.php?f=35&t=7652
-----------------------------------
batman
Fri 18 Feb, 2011 01:28

Bbcode Web Tags?
-----------------------------------
Could anybody please tell me how to ad a web tag to the bbcode list so I can post web pages within a post.
On my other portal system that I want to convert to Icy I have the feature which includes the below tags, but obviously doesn't work on Icy as its not included  :mrgreen: 
[code linenumbers=false]Insert web page: [web height=#]Page URL[/web][/code]

Cheers
Karl


-----------------------------------
mort
Fri 18 Feb, 2011 09:06

Re: Bbcode Web Tags?
-----------------------------------
There's something in the docs about how to add bbcode tags etc - might not be anything specific to what you actually want to do? But I do know one thing, and that's Icy Phoenix doesn't use the standard phpBB bbcode script.

I've looked at how the Icy bbcode is applied - if you get stuck - yell out, and I may be able to help!  :mryellow:

[b]Edit:[/b]

Thinking about this after a couple of beers! :lol: 

[web height=#]Page URL[/web] ?

[b]Page Url[/b] would have to equate to [b]<iframe src="Page URL" width X height[/b] etc, with the [b]no-scrolling[/b] attribute applied or something very similar.?

Because I can't see how else one could import a url and open it in the text area - Unless I'm missing something?

And from what I've read here - Icy Phoenix has no provision to allow <iframes. - In fact it appears they are dead set against it and don't cater or allow for it.

Could be wrong - But that's how I read it!  :P


-----------------------------------
batman
Fri 18 Feb, 2011 18:50

Re: Bbcode Web Tags?
-----------------------------------
The feature is used on integramod 2.
I was going to stick with them as have done since 06 i wanted to upgrade but integramod 3 has been in Beta for so long now and the actual download is deactivated due to upgrading or something, Ive been weighting about 2 years to up grade so had to make a decision and now here, its a shame as helter skelter on there works seriously hard and been a great help over the years  :cry:  :roll: 

The web tags are a really useful tool as it means members don't navigate away from your site, ill have a nosy see what I can find..

Thanks for your input  :wink:

Below is a pic of how it looks when you post a web page, if its not possible Ill seriously miss this feature as we use it a lot..

 [img]http://www.icyphoenix.com/files/images/9166/18_02_2011_16_57_58.jpg[/img]


-----------------------------------
spydie
Fri 18 Feb, 2011 20:13

Re: Bbcode Web Tags?
-----------------------------------
actualy, the new long awaited Icy version( svn at the moment), includes an personalized BBcode option.

something  like PhpBB


-----------------------------------
mort
Fri 18 Feb, 2011 23:49

Re: Bbcode Web Tags?
-----------------------------------
@batman.

It does look useful!  :mryellow: 

Stand by because I think I can run something to test if this is going to work with Icy Phoenix?






[b][i]I think! [/i][/b] :P


-----------------------------------
batman
Sat 19 Feb, 2011 00:02

Re: Bbcode Web Tags?
-----------------------------------
Look forward to it cheers  8)


-----------------------------------
mort
Sat 19 Feb, 2011 00:12

Re: Bbcode Web Tags?
-----------------------------------
Took 20 minutes - -  :mryellow: 

[b]BINGO![/b]

Have a play with this using the [flash] tags, see what you can come up with as the best optimal sizes etc, then it can be written up with its own bbcode script. ;)

Find in includes/bbcode.php

[code linenumbers=false]Find:

				if (($tag === 'flash') || ($tag === 'swf'))
				{
					$html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="' . $width . '" height="' . $height . '"><param name="movie" value="' . $content . '"><param name="quality" value="high"><param name="scale" value="noborder"><param name="wmode" value="transparent"><param name="bgcolor" value="#000000"><embed src="' . $content . '" quality="high" scale="noborder" wmode="transparent" bgcolor="#000000" width="' . $width . '" height="' . $height . '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object>';
				

Replace with: 

				if (($tag === 'flash') || ($tag === 'swf'))
				{
					$html = '<iframe src="' . $content . '" width="800" height="600" marginwidth="0" marginheight="0" frameborder="0" scrolling="yes"></iframe>';

[/code]

A couple of links that will help.

CUSTOMIZATION - Adding Video BBCode And Buttons To The Editor.

http://www.icyphoenix.com/viewtopic.php?p=44061#p44061


Though this one advocates NO IFRAMES - It appears it's directed at adding script in iframes to the text area, rather than just linking.  :?: 

BBCODE - CUSTOMIZATION - DANGEROUS - How To Allow IFRAME And Full HTML Parsing

http://www.icyphoenix.com/viewtopic.php?p=17045#p17045


Demo Pic.


-----------------------------------
batman
Sat 19 Feb, 2011 01:43

Re: Bbcode Web Tags?
-----------------------------------
Cheers ill have a nosy at that tomorrow  :wink:


-----------------------------------
mort
Sat 19 Feb, 2011 02:11

Re: Bbcode Web Tags?
-----------------------------------
Hehehe!

I'm not doing much at the moment, so I'll probably have it written up by the time you get to it. :P

Will let you know.  :mryellow:


-----------------------------------
Yros
Sat 19 Feb, 2011 03:35

Re: Bbcode Web Tags?
-----------------------------------
Instead of modifying the flash bbcode (which may lead to errors while using the TRUE flash tag for real flash content), why not simply add a new bbcode or upgrade your version in order to use the " custom bbcodes " available ?


-----------------------------------
mort
Sat 19 Feb, 2011 06:19

Re: Bbcode Web Tags?
-----------------------------------
[quote user="Yros" post="51644"]Instead of modifying the flash bbcode (which may lead to errors while using the TRUE flash tag for real flash content), why not simply add a new bbcode or upgrade your version in order to use the " custom bbcodes " available ?[/quote]

Yros,

It wasn't intended to modify the Flash Code, it was ONLY used as an example to see if Icy Phoenix would parse <iframes.

I've asked MG for some help because I'm having trouble parsing any changes I make to pop-up prompts by way of width and height.

It doesn't matter how I add the variables or change the arrays in bbcode.php - They parse into the post, but I cannot get the changes to parse into the db with the string changes.

And I've just realised that I was ONLY Previewing them - [b][i]Damn, maybe that's the problem! [/i][/b] :mryellow: 

Anyway - I'm open to any suggestions if anyone wants to add the extra code here while I'm trying to sort out bbcode.php.

This all works - But it's hard-code for height and width - That's what needs fixing!  :P 

[spoiler][code linenumbers=false]Open : includes/bbcb_mg.php

Find:

	'L_FLASH_H_ERROR' => $lang['s_flash_h_error'],


After Add:

	'L_WEB_INSERT' => $lang['s_web_insert'],
	'L_WEB_W_INSERT' => $lang['s_web_w_insert'],
	'L_WEB_W_ERROR' => $lang['s_web_w_error'],
	'L_WEB_H_INSERT' => $lang['s_web_h_insert'],
	'L_WEB_H_ERROR' => $lang['s_web_h_error'],

Find:

	'L_FLASH_HELP' => $lang['s_flash_help'],

After Add:

    	'L_WEB_HELP' => $lang['s_web_help'],


Open : includes/bbcode.php

Find:

		'flash'			=> array('nested' => true, 'inurl' => true, 'allow_empty' => false),

After Add:

		'web'			=> array('nested' => true, 'inurl' => true, 'allow_empty' => false),

Find:

($tag === 'flv')

Inline After Add: (Note the leading space)

 || ($tag === 'web')

Find:

				elseif (($tag === 'emff') || ($tag === 'mp3'))

Before Add:

				elseif ($tag === 'web')
				{
					$html = '<iframe src="' . $content . '" width="800" height="600" marginwidth="0" marginheight="0" frameborder="0" scrolling="yes"></iframe>';
				}
				
Open: templates/common/js/bbcb_mg.js

Find:

var flash = 0;

After Add:

var web = 0;

Find:

'[swf width=200 height=200]','[/swf]',

After Add:

'[web width=800 height=800]','[/web]',

Find:

function BBCflash()
{
	var FoundErrors = '';
	var enterFURL = prompt(s_flash_insert, s_url_insert_tip);
	if (!enterFURL)
	{
		FoundErrors += s_file_insert_error;
	}
	var enterW = prompt(s_flash_w_insert, "320");
	if (!enterW)
	{
		FoundErrors += s_flash_w_error;
	}
	var enterH = prompt(s_flash_h_insert, "240");
	if (!enterH)
	{
		FoundErrors += s_flash_h_error;
	}
	if (FoundErrors)
	{
		alert(s_gen_error + FoundErrors);
		return;
	}
	var ToAdd = "[b]Video File[/b][spoiler][flash width="+enterW+" height="+enterH+"]"+enterFURL + "[/flash][/spoiler]";
	PostWrite(ToAdd);
}


After Add:

function BBCweb()
{
	var FoundErrors = '';
	var enterFURL = prompt(s_web_insert, s_url_insert_tip);
	if (!enterFURL)
	{
		FoundErrors += s_file_insert_error;
	}
	var enterW = prompt(s_web_w_insert, "800");
	if (!enterW)
	{
		FoundErrors += s_web_w_error;
	}
	var enterH = prompt(s_web_h_insert, "800");
	if (!enterH)
	{
		FoundErrors += s_web_h_error;
	}
	if (FoundErrors)
	{
		alert(s_gen_error + FoundErrors);
		return;
	}
	var ToAdd = "[web width="+enterW+" height="+enterH+"]"+enterFURL + "[/web]";
	PostWrite(ToAdd);
}

Open:

templates/default/bbcb_mg.tpl

Find:

					<a href="javascript:BBCflash()"><img src="{BBCB_MG_IMG_PATH}flash{BBCB_MG_IMG_EXT}" name="flash" onmouseover="helpline('flash')" alt="L_BBCB_MG_FLSH}" 

title="{L_BBCB_MG_FLSH}" class="bbimages" /></a>


Before Add:

					<a href="javascript:BBCweb()"><img src="{BBCB_MG_IMG_PATH}web{BBCB_MG_IMG_EXT}" name="web" onmouseover="helpline('web')" alt="{L_BBCB_MG_WEB}" 

title="{L_BBCB_MG_WEB}" class="bbimages" /></a>

Open: language/lang_english/lang_bbcb_mg.php

Find:

	'bbcb_mg_flsh' => 'Flash',

After Add:

	'bbcb_mg_web' => 'Web',

Find:

$js_lang['s_flash_h_error'] = 'You didn\'t specify Flash file height';

After Add:

$js_lang['s_web_insert'] = 'Please write Web file URL';
$js_lang['s_web_w_insert'] = 'Please specify Web file width';
$js_lang['s_web_w_error'] = 'You didn\'t specify Web file width';
$js_lang['s_web_h_insert'] = 'Please specify Web file height';
$js_lang['s_web_h_error'] = 'You didn\'t specify Web file height';

Find:

$js_lang['s_flash_help'] = 'Insert flash file: [flash width=# height=#]flash URL[/flash]';

After Add:

$js_lang['s_web_help'] = 'Insert file URL: [web width=# height=#]File URL[/web]';

[/code][/spoiler]

[b]Edit 1:[/b]

Well It's working in a fashion as I can adjust the width but not the height. Time to give it a break for a while I think.  

But don't let that stop anyone who knows more than I do [b][i](Which is not much)[/i][/b] from helping with this.

[b]Edit 2:[/b]

This is the problem - [web width=450 height=450]http://www.gifbin.com[/web]

If I change either value above 450, the whole thing stuffs up - What's holding it down and where it is - I have not got a clue at this moment.

 :(

[b]Edit 3:[/b]

This appears to be the maximum....

[b]Anyone happy with that? [/b] :mryellow:  :mrorange:  :mrblue: 

[web width=600 height=450]http://www.gifbin.com[/web]


But if I hard-code it with this - width="800" height="600" - That's what you get! Though 700x700 fits better. :P


-----------------------------------
Mighty Gorgon
Sat 19 Feb, 2011 09:09

Re: Bbcode Web Tags?
-----------------------------------
Hi all,
Honestly I would not add such a BBCode unless in some way restricted to administrators or people you are trusting blindly.

The reason is that you can add almost anythin in an IFRAME even evil scripts which could harm your visitors... I wouldn't risk that honestly.

In dev version of Icy Phoenix it should be easier get what you need because I have coded (I hope properly, but not fully tested so far) an option to allow HTML to administrators... anyway, you are asking something for the old version.

Before going on in helping you I would like you to confirm that you are aware of the risks you are going to face... :mri:


-----------------------------------
mort
Sat 19 Feb, 2011 09:14

Re: Bbcode Web Tags?
-----------------------------------
Hi MG,

I could always add the code to it <!-- IF S_ADMIN This <iframes code -  <!-- Else Nothing etc or maybe echo ADMIN ONLY TAGS! etc, etc.

 :mryellow: 

Maybe add S_ADMIN_MOD too


All in php of course - not constants. ;)

[b]Edit:[/b]

I think that this should do it:

[code linenumbers=false]			elseif ($tag === 'web' && (($userdata['user_level'] == ADMIN) || ($userdata['user_level'] == MOD)))
				{
					$html = '<iframe src="' . $content . '" width="' . $width . '" height="' . $height . '" marginwidth="0" marginheight="0" frameborder="0" scrolling="yes"></iframe>';
				}[/code]

I also think I'll settle on this as the maximum because it's adjustable and it should be big enough!

[web width=600 height=450]http://www.mysite.com[/web]


-----------------------------------
Mighty Gorgon
Sat 19 Feb, 2011 09:41

Re: Bbcode Web Tags?
-----------------------------------
Unfortunately it would not be that easy... I know it's tricky, I've dealt with it in the past.

You know what will be the result of your code? Everyone could insert IFRAMES but only admins will get thet when they visit the topic... and it is not what we wants.

We need to check the permission when adding the BBCode to DB and then display to all users... we just need to check that who added the content had the right permission for doing that.

Anyway, the topic you linked "[url=http://www.icyphoenix.com/viewtopic.php?p=17045#p17045]BBCODE - CUSTOMIZATION - DANGEROUS - How To Allow IFRAME And Full HTML Parsing" should do the job properly (you can call it WEB if you don't like IFRAME, but the result is the same).

If you now just need help with the JS to add also Width and Height parameters, I'll have a look and report back.


-----------------------------------
mort
Sat 19 Feb, 2011 11:00

Re: Bbcode Web Tags?
-----------------------------------
Don't know MG?

As an unauthorised logged-in person trying to hack the web tags.

If I quote Admin.

[quote user="Admin" post="97"][web width=600 height=450]http://www.mysite.com[/web][/quote]

And strip the quote as well.

[web width=600 height=450]http://www.mysite.com[/web]


All I get in the post is.

     Admin wrote: [View Post]
     http://www.mysite.com

http://www.mysite.com 

If I change the quoted url to:

[web width=600 height=450]http://www.hotscripts.com/category/cgi-perl/scripts-programs/[/web]


All I get in the post is.

    Admin wrote: [View Post]
    http://www.hotscripts.com/category/cgi-perl/scripts-programs/


If I click the [web button as a user (Which can be hidden anyway with <!-- IF S_blah blah in the .tpl file.) and try to add the [web tags

All I get in return for the post is.

http://www.hotscripts.com/category/cgi-perl/scripts-programs/ 

So I can't see how it's going to parse the <iframe html into the code tags when I'm anything other than an ADMIN or MOD.

[quote=MG]You know what will be the result of your code? Everyone could insert IFRAMES but only admins will get thet when they visit the topic... and it is not what we wants.[/quote]

I tried that too with the user both adding tags and quoting Admin.

When the "User" posts or quotes the [web tags, they are invalid because he or she can't call the $html to add the <iframes whether it's quoted or not?

Am I missing something? :P

[b]Oh oh [/b]- Unless it's because I'm using 127.0.0.1 and being denied - but I have no way to test that live!  :(


-----------------------------------
Mighty Gorgon
Sat 19 Feb, 2011 11:23

Re: Bbcode Web Tags?
-----------------------------------
Maybe I didn't explain properly.

I'm referring to this part:
[quote user="mort" post="51652"]I think that this should do it:

[code linenumbers=false]			elseif ($tag === 'web' && (($userdata['user_level'] == ADMIN) || ($userdata['user_level'] == MOD)))
				{
					$html = '<iframe src="' . $content . '" width="' . $width . '" height="' . $height . '" marginwidth="0" marginheight="0" frameborder="0" scrolling="yes"></iframe>';
				}[/code][/quote]

Your code checks the permission with $userdata, but $userdata in bbcode.php just contains current user permission, and bbcode.php is not checking if the content is going to be added to DB or not... it just checks the level of the user viewing the parsed text.

Maybe an example will help.

If ME as an admin I add the [web]URL[/web] code, the code will be processed and shown to myself... but when a normal user try to display the post, when bbcode parses the text it checks against userdata, that means that the user won't see the content because it is not an admin... I don't know if you get my point.

On the opposite, if a normal user post the [web]URL[/web] tags, then only admins will be able to display that, not normal users... this is still leading to security issues, because any user can still inject HTML code and attack any admin or moderator who are able to display the code properly.

Instead of working on bbcode.php, you should instead work at a posting level, checking then which is the level of the user posting such a content, and remove or sanitize the unwanted tags at that stage... because it's only at that point that you can tell if the user is allowed to post such kind of content or not...

If you have a chance to test latest dev version of Icy Phoenix, there is a new option in ACP where you can allow administrators to add HTML to posts, and I'm confident that it is quite safe, because it checks the permissions when posting, and not when viewing. This just means that if a user has admin rights, can post HTML and it will be added to DB as HTML code... if the user is not an admin, any new post or post edit (because you have also to deal with post editing!) will be sanitized against any HTML markup and it will be shown as it is just text and not HTML.

Sorry, but it's tough for me trying to explain this, because it's not an easy matter. :sad:

Anyway if it is still not clear (or if I misunderstood your post), I can try to explain again.


-----------------------------------
mort
Sat 19 Feb, 2011 23:06

Re: Bbcode Web Tags?
-----------------------------------
I understand what you're saying and I knew that there was still a problem with permissions, but I was so tired last night I couldn't think back through it and rationalise it.

 :( 

@ batman

There you go my friend - read the changes here from the "original" script to make the height and width work with vars if required - Use it at your own risk - Maybe a dedicated forum with only Admin / Mod permissions to post iframes etc. Or wait until the release of the next version of Icy Phoenix.

I also think that this thread can be marked solved. ;)

But a least it got a workout!  :mryellow:

@ MG,

I will have a look at the dev version - only if I don't have to go and get it from SVN. Sooooooo, if you have a .zip available somewhere and hit me with a link to download it - That'd be nice.  :mricy:


-----------------------------------
TheSteffen
Sat 19 Feb, 2011 23:30

Re: Bbcode Web Tags?
-----------------------------------
[quote user="mort" post="51670"]I will have a look at the dev version - only if I don't have to go and get it from SVN. Sooooooo, if you have a .zip available somewhere and hit me with a link to download it - That'd be nice.  :mricy:[/quote]
Give me a second, I will send you last SVN


-----------------------------------
spydie
Sat 19 Feb, 2011 23:41

Re: Bbcode Web Tags?
-----------------------------------
here we go @mort


http://icy-mods.com/icy_new/icy_nuevo.zip

in english and spanish

gimme a shout when you got it, to delet the link


-----------------------------------
batman
Sun 20 Feb, 2011 00:11

Re: Bbcode Web Tags?
-----------------------------------
[quote user="Mighty Gorgon" post="51650"]Hi all,
Honestly I would not add such a BBCode unless in some way restricted to administrators or people you are trusting blindly.

The reason is that you can add almost anythin in an IFRAME even evil scripts which could harm your visitors... I wouldn't risk that honestly.

In dev version of Icy Phoenix it should be easier get what you need because I have coded (I hope properly, but not fully tested so far) an option to allow HTML to administrators... anyway, you are asking something for the old version.

Before going on in helping you I would like you to confirm that you are aware of the risks you are going to face... :mri:[/quote]

That's not a problem at all as most just post the link. it would be ideal if a mod or admin could edit the post to set it as a web tag so viewers don't need to navigate away from the site.


I don't know whether this helps or not but this code from the BBcode Javascript 2 different files  
[size=14][b]bbcode_box.js[/b][/size]

[spoiler][code linenumbers=true]var theSelection = false;

var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version

var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
                && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_moz = 0;

var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);

rtl_help = "Set textbox right to left";
ltr_help = "Set textbox left to right";
plain_help = "Remove BBCodes from the selected text";
fc_help = "Font color: [color=red]text[/color] (You can use HTML color=#FF0000)";
fs_help = "Font size: [size=9]Very Small[/size]";
ft_help = "Font type: [font=Andalus]text[/font]";
right_help = "Right align text: [align=right]text[/align]";
left_help = "Left align text: [align=left]text[/align]";
center_help = "Center align text: [align=center]text[/align]";
justify_help = "Justify text: [align=justify]text[/align]";
b_help = "Bold: [b]text[/b]";
i_help = "Italic: [i]text[/i]";
u_help = "Underline: [u]text[/u]";
strike_help = "Strike-through: [strike]text[/strike]";
sup_help = "Superscript: [sup]text[/sup]";
sub_help = "Subscript: [sub]text[/sub]";
grad_help ="Insert gradient text";
fade_help = "Fade text: [fade]text[/fade]";
list_help = "List: [list(=1|a)][*]item 1[*]item 2[/list]";
marqr_help = "Marquee right: [marq=right]text[/marq]";
marql_help = "Marquee left: [marq=left]text[/marq]";
marqu_help = "Marquee up: [marq=up]text[/marq]";
marqd_help = "Marquee down: [marq=down]text[/marq]";
quote_help = "Quote: [quote]text[/quote]";
code_help = "Code: [code]code[/code]";
php_help = "PHP: [php]php code[/php]";
spoil_help = "Spoiler: [spoil]text[/spoil]";
anchor_help = "Anchor: [anchor]name[/anchor]";
url_help = "Insert URL: http://Site URL or [url=http://Site URL]Site Name";
youtube_help = "Insert youtube image: [youtube]http://youtube URL[/youtube]";
mail_help = "Insert email: [email]Email Here[/email]";
gotopost_help = "Gotopost: [gotopost=post]text[/gotopost] [gotopost=name]text[/gotopost] [gotopost=post,name]text[/gotopost]";
photo_help = "Insert photo image: [photo]http://photo URL[/photo]";
img_help = "Insert image: [img(=left|right|center)]http://image path[/img] [albumimg(l|r|c)]AlbumImage#[/albumimg(l|r|c)]";
stream_help="Insert stream file: [stream]File URL[/stream]";
ram_help="Insert real media file: [ram]File URL[/ram]";
web_help="Insert web page: [web height=#]Page URL[/web]";
video_help="Insert video file: [video width=# height=#]file URL[/video]";
flash_help="Insert flash file: [flash width=# height=#]flash URL[/flash]";
spell_help = "Spell Check: Checks the spelling in the post";
hr_help="Insert H-Line: [hr]";
you_help = "Inserts username of the reader: [you]";
tab_help = "Inserts a tab into post: [tab]";
nbsp_help = "Inserts a non-breaking space into post: [nbsp]";
search_help = "Search site: [search]String to search for[/search]";
google_help = "Google: [google]String to search for[/google]";
table_help = "Creates a Table using BBCode";

var fade = 0;
var center = 0;
var left = 0;
var right = 0;
var justify = 0;
var bold = 0;
var italic = 0;
var underline = 0;
var strikeout = 0;
var superscript = 0;
var subscript = 0;
var marqd = 0;
var marqu = 0;
var marql = 0;
var marqr = 0;
var code = 0;
var quote = 0;
var php = 0;
var spoiler = 0;

// Fix a bug involving the TextRange object in IE. From
// http://www.frostjedi.com/terra/scripts/demo/caretBug.html
// (script by TerraFrost modified by reddog)
function initInsertions() {
	var baseHeight;
	document.post.message.focus();
	if (is_ie && typeof(baseHeight) != 'number') baseHeight = document.selection.createRange().duplicate().boundingHeight;
}

function helpline(help) {
	document.post.helpbox.value = eval(help + "_help");
	document.post.helpbox.readOnly = "true";
}

function checkForm() {
	formErrors = false;    
	if (document.post.message.value.length < 2) {
		formErrors = "You must enter a message when posting";
	}
	if (formErrors) {
		alert(formErrors);
		return false;
	} else {
		//formObj.preview.disabled = true;
		//formObj.submit.disabled = true;
		return true;
	}
}

function emoticon(text) {
	var txtarea = document.post.message;
	var baseHeight;
	if (is_ie && typeof(baseHeight) != 'number') baseHeight = document.selection.createRange().duplicate().boundingHeight;
	text = ' ' + text + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
		if (baseHeight != txtarea.caretPos.boundingHeight) {
			txtarea.focus();
			storeCaret(txtarea);
		}
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
		txtarea.focus();
	} else
	if (txtarea.selectionEnd && (txtarea.selectionStart | txtarea.selectionStart == 0))
	{ 
		mozWrap(txtarea, text, "");
		return;
	} else {
		txtarea.value  += text;
		txtarea.focus();
	}
}

function storeCaret(textEl) {
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

function PostWrite(text) {
	posttextarea = document.post.message;

	if (posttextarea.createTextRange && posttextarea.caretPos)
	{
		var caretPos = posttextarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?	text + ' ' : text;
		posttextarea.focus(caretPos)
	}
	else if (posttextarea.selectionStart)
	{
		posttextarea.focus();
		scrollTop = posttextarea.scrollTop;
		
		var selLength = posttextarea.textLength;
		var selStart = posttextarea.selectionStart;
		var s1 = (posttextarea.value).substring(0,selStart);
		var s2 = (posttextarea.value).substring(selStart,selLength);
		
		posttextarea.value = s1 + text + s2;
		posttextarea.selectionStart = selStart + text.length;
		posttextarea.selectionEnd = selStart + text.length;
		posttextarea.scrollTop = scrollTop;
		posttextarea.focus();
	}
	else
	{
		posttextarea.value += text;
		posttextarea.focus();
	}
}

function mozWrap(posttextarea, open, close)
{
	posttextarea.focus();
	scrollTop = posttextarea.scrollTop;
	
	var selLength = posttextarea.textLength;
	var selStart = posttextarea.selectionStart;
	var selEnd = posttextarea.selectionEnd;
	if (selEnd == 1 || selEnd == 2) 
		selEnd = selLength;

	var s1 = (posttextarea.value).substring(0,selStart);
	var s2 = (posttextarea.value).substring(selStart, selEnd)
	var s3 = (posttextarea.value).substring(selEnd, selLength);
	posttextarea.value = s1 + open + s2 + close + s3;

	posttextarea.selectionStart = selStart;
	posttextarea.selectionEnd = selEnd + open.length + close.length;
	posttextarea.scrollTop = scrollTop;
	posttextarea.focus();
	return;
}

function bbfontstyle(bbopen, bbclose) {
	var txtarea = document.post.message;

	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (!theSelection) {
			txtarea.value += bbopen + bbclose;
			txtarea.focus();
			return;
		}
		document.selection.createRange().text = bbopen + theSelection + bbclose;
		txtarea.focus();
		return;
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, bbopen, bbclose);
		return;
	}
	else
	{
		txtarea.value += bbopen + bbclose;
		txtarea.focus();
	}
	storeCaret(txtarea);
}

//----- Start: Prompt Control by Jason Sanborn
// promptMsg = Message to be displayed on Prompt Dialog Box
// promptDefault = Default text to be displayed in the Prompt Dialog Box
// promptReq = Data Required? 0-False, 1-True
// promptReqErr = Error message to display if Required data not entered
// promptRegEx = Regular Expression to validate data
// promptRegExErr = Error message to display if RegEx fails to validate data
function showPrompt(promptMsg,promptDefault,promptReq,promptReqErr,promptRegExp,promptRegExpErr)
{
	if (is_ie)
	{
		promptMsg = promptMsg.replace(/\n/gi," ");
		promptMsg = promptMsg.replace(/  /gi," ");
	}
	var promptVal = prompt(promptMsg,promptDefault);
	if (promptVal == null)
	{
		return "^pcncl-1";
	}
	else
	{
		var retVal = trim(promptVal);
		if (retVal == '' && promptReq == 1)
		{
			alert(promptReqErr);
			return "^perr-1";
		}
		else
		{
			if (retVal !='' && promptRegExp != '')
			{
				var regMatch = promptRegExp;
				if (regMatch.test(retVal))
				{
					return retVal;
				}
				else
				{
					alert(promptRegExpErr);
					return "^perr-1";
				}
			}
			else
			{
				return retVal;
			}
		}
	}
}

// JavaScript Trim: http://artlung.com/blog/2006/04/21/javascript-trim-function/
function trim(str)
{
while(''+str.charAt(0)==' ')
str=str.substring(1,str.length);
while(''+str.charAt(str.length-1)==' ')
str=str.substring(0,str.length-1);
return str;
}
//----- End: Prompt Control by Jason Sanborn

function BBCdir(dirc) {
       document.post.message.dir=(dirc);
}

function BBCplain() {
	if (is_ie)
	{
		theSelection = document.selection.createRange().text;
	}
	else
	{
		posttextarea = document.post.message;
		start = posttextarea.selectionStart;
		end = posttextarea.selectionEnd;
		scrollTop = posttextarea.scrollTop;
		theSelection=(posttextarea.value).substring(start,end);
	}
	if (theSelection == '')
	{
		var confirmDel = confirm("Are you sure that you want to erase all BBCodes in this post?\n\nThis action cannot be undone.");
		if (confirmDel)
		{
			posttextarea = document.post.message;
			posttextarea.select();
			if (is_ie)
			{
				theSelection = document.selection.createRange().text;
			}
			else
			{
				start = posttextarea.selectionStart;
				end = posttextarea.selectionEnd;
				scrollTop = posttextarea.scrollTop;
				theSelection=(posttextarea.value).substring(start,end);
			}
		}
	}
	if (theSelection != '')
	{
		temp = theSelection;
		temp = temp.replace(/\[FLASH=([^\]]*)\]WIDTH=[0-9]{0,4} HEIGHT=[0-9]{0,4}\[\/FLASH\]/gi,"$1");
		temp = temp.replace(/\[VIDEO=([^\]]*)\]WIDTH=[0-9]{0,4} HEIGHT=[0-9]{0,4}\[\/VIDEO\]/gi,"$1");
		temp = temp.replace(/\[[^\]]*\]/gi,"");
		if (is_ie)
		{
			document.selection.createRange().text = temp;
		}
		else
		{
			endtext=posttextarea.value.substring(end,posttextarea.textLength);
			starttext=posttextarea.value.substring(0,start);
			lendiff = theSelection.length - temp.length;
			posttextarea.value = starttext + temp + endtext;
			posttextarea.selectionStart = start;
			posttextarea.selectionEnd = end - lendiff;
			posttextarea.scrollTop = scrollTop;

			posttextarea.focus();
		}
	}
}

function BBCft() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[font="+document.post.ft.value+"]" + theSelection + "[/font]";
		document.post.message.focus();
		document.post.ft[0].selected = true;
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[font="+document.post.ft.value+"]", "[/font]");
		document.post.ft[0].selected = true;
		return;
	}
	ToAdd = "[font="+document.post.ft.value+"]"+" "+"[/font]";
	document.post.ft[0].selected = true;
	PostWrite(ToAdd);
}

function BBCfs() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[size="+document.post.fs.value+"]" + theSelection + "[/size]";
		document.post.message.focus();
		document.post.fs[0].selected = true;
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[size="+document.post.fs.value+"]", "[/size]");
		document.post.fs[0].selected = true;
		return;
	}
	ToAdd = "[size="+document.post.fs.value+"]"+" "+"[/size]";
	document.post.fs[0].selected = true;
	PostWrite(ToAdd);
}

function BBCfc() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[color="+document.post.fc.value+"]" + theSelection + "[/color]";
		document.post.message.focus();
		document.post.fc[0].selected = true;
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[color="+document.post.fc.value+"]", "[/color]");
		document.post.fc[0].selected = true;
		return;
	}
	ToAdd = "[color="+document.post.fc.value+"]"+" "+"[/color]";
	document.post.fc[0].selected = true;
	PostWrite(ToAdd);
}

function BBCfade() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[fade]" + theSelection + "[/fade]";
		document.post.message.focus();
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[fade]", "[/fade]");
		return;
	}
	if (fade == 0) {
		ToAdd = "[fade]";
		document.post.fade.src = "mods/bbcode_box/images/fade1.gif";
		fade = 1;
	} else {
		ToAdd = "[/fade]";
		document.post.fade.src = "mods/bbcode_box/images/fade.gif";
		fade = 0;
	}
	PostWrite(ToAdd);
}

function BBCgrad() {
    if ((clientVer >= 4) && is_ie && is_win)
	{
		var oSelect,oSelectRange;
	    document.post.message.focus();
	    oSelect = document.selection;
	    oSelectRange = oSelect.createRange();
	    if (oSelectRange.text.length < 1) {
			alert("Please select the text first");
			return;
		}
	    if (oSelectRange.text.length > 120) {
	      alert("This only works for less than 120 letters");
	      return;
	    }
	    showModalDialog("mods/bbcode_box/grad.htm",oSelectRange,"help:no; center:yes; status:no; dialogHeight:50px; dialogWidth:50px");
	}
	else
	{
		alert("Gradient is not available on your browser.");
		return;
	}
}

function BBClist() {
	var ToAdd = "";
	var Result1 = 0;
	while (Result1 == 0)
	{
		var Prompt1 = showPrompt("Enter list type:\n'1' for numbered list,\n'a' for alphabetical list,\n'unordered' for an unordered list","unordered",1,"Valid options are '1', 'a' or 'unordered'.",/(a|1|unordered|un-ordered)/i,"");
		if (Prompt1 == "^pcncl-1")
		{
			Result1 = 1;
		}
		else if (Prompt1 != "^perr-1")
		{
			ToAdd = "[list";
			if (Prompt1 == "1" || Prompt1 == "a" || Prompt1 == "A")
			{
				ToAdd += "="+Prompt1.toLowerCase();
			}
			ToAdd += "]";
			
			var Result2 = 0;
			while (Result2 == 0)
			{
				var Prompt2 = showPrompt("Enter the list item.\n\nPress 'Cancel' to End.","",1,"You didn't enter a list item.","","");
				if (Prompt2 == "^pcncl-1")
				{
					Result2 = 1;
				}
				else if (Prompt2 != "^perr-1")
				{
					ToAdd += "[*]"+Prompt2;
				}
			}
			ToAdd += "[/list]"
			Result1 = 1;
		}
	}
	PostWrite(ToAdd);
}

function BBCjustify() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[align=justify]" + theSelection + "[/align]";
		document.post.message.focus();
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[align=justify]", "[/align]");
		return;
	}
	if (justify == 0) {
		ToAdd = "[align=justify]";
		document.post.justify.src = "mods/bbcode_box/images/justify1.gif";
		justify = 1;
	} else {
		ToAdd = "[/align]";
		document.post.justify.src = "mods/bbcode_box/images/justify.gif";
		justify = 0;
	}
	PostWrite(ToAdd);
}

function BBCleft() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[align=left]" + theSelection + "[/align]";
		document.post.message.focus();
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[align=left]", "[/align]");
		return;
	}
	if (left == 0) {
		ToAdd = "[align=left]";
		document.post.left.src = "mods/bbcode_box/images/left1.gif";
		left = 1;
	} else {
		ToAdd = "[/align]";
		document.post.left.src = "mods/bbcode_box/images/left.gif";
		left = 0;
	}
	PostWrite(ToAdd);
}

function BBCright() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[align=right]" + theSelection + "[/align]";
		document.post.message.focus();
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[align=right]", "[/align]");
		return;
	}
	if (right == 0) {
		ToAdd = "[align=right]";
		document.post.right.src = "mods/bbcode_box/images/right1.gif";
		right = 1;
	} else {
		ToAdd = "[/align]";
		document.post.right.src = "mods/bbcode_box/images/right.gif";
		right = 0;
	}
	PostWrite(ToAdd);
}

function BBCcenter() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[align=center]" + theSelection + "[/align]";
		document.post.message.focus();
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[align=center]", "[/align]");
		return;
	}
	if (center == 0) {
		ToAdd = "[align=center]";
		document.post.center.src = "mods/bbcode_box/images/center1.gif";
		center = 1;
	} else {
		ToAdd = "[/align]";
		document.post.center.src = "mods/bbcode_box/images/center.gif";
		center = 0;
	}
	PostWrite(ToAdd);
}

function BBCbold() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[b]" + theSelection + "[/b]";
		document.post.message.focus();
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[b]", "[/b]");
		return;
	}
	if (bold == 0) {
		ToAdd = "[b]";
		document.post.bold.src = "mods/bbcode_box/images/bold1.gif";
		bold = 1;
	} else {
		ToAdd = "[/b]";
		document.post.bold.src = "mods/bbcode_box/images/bold.gif";
		bold = 0;
	}
	PostWrite(ToAdd);
}

function BBCitalic() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[i]" + theSelection + "[/i]";
		document.post.message.focus();
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[i]", "[/i]");
		return;
	}
	if (italic == 0) {
		ToAdd = "[i]";
		document.post.italic.src = "mods/bbcode_box/images/italic1.gif";
		italic = 1;
	} else {
		ToAdd = "[/i]";
		document.post.italic.src = "mods/bbcode_box/images/italic.gif";
		italic = 0;
	}
	PostWrite(ToAdd);
}

function BBCunder() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[u]" + theSelection + "[/u]";
		document.post.message.focus();
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[u]", "[/u]");
		return;
	}
	if (underline == 0) {
		ToAdd = "[u]";
		document.post.under.src = "mods/bbcode_box/images/under1.gif";
		underline = 1;
	} else {
		ToAdd = "[/u]";
		document.post.under.src = "mods/bbcode_box/images/under.gif";
		underline = 0;
	}
	PostWrite(ToAdd);
}

function BBCstrike() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[s]" + theSelection + "[/s]";
		document.post.message.focus();
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[s]", "[/s]");
		return;
	}
	if (strikeout == 0) {
		ToAdd = "[s]";
		document.strik.src = "mods/bbcode_box/images/strike1.gif";
		strikeout = 1;
	} else {
		ToAdd = "[/s]";
		document.strik.src = "mods/bbcode_box/images/strike.gif";
		strikeout = 0;
	}
	PostWrite(ToAdd);
}

function BBCsup() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[sup]" + theSelection + "[/sup]";
		document.post.message.focus();
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[sup]", "[/sup]");
		return;
	}
	if (superscript == 0) {
		ToAdd = "[sup]";
		document.supscript.src = "mods/bbcode_box/images/sup1.gif";
		superscript = 1;
	} else {
		ToAdd = "[/sup]";
		document.supscript.src = "mods/bbcode_box/images/sup.gif";
		superscript = 0;
	}
	PostWrite(ToAdd);
}

function BBCsub() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[sub]" + theSelection + "[/sub]";
		document.post.message.focus();
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[sub]", "[/sub]");
		return;
	}
	if (subscript == 0) {
		ToAdd = "[sub]";
		document.subs.src = "mods/bbcode_box/images/sub1.gif";
		subscript = 1;
	} else {
		ToAdd = "[/sub]";
		document.subs.src = "mods/bbcode_box/images/sub.gif";
		subscript = 0;
	}
	PostWrite(ToAdd);
}

function BBCmarqu() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[marq=up]" + theSelection + "[/marq]";
		document.post.message.focus();
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[marq=up]", "[/marq]");
		return;
	}
	if (marqu == 0) {
		ToAdd = "[marq=up]";
		document.post.marqu.src = "mods/bbcode_box/images/marqu1.gif";
		marqu = 1;
	} else {
		ToAdd = "[/marq]";
		document.post.marqu.src = "mods/bbcode_box/images/marqu.gif";
		marqu = 0;
	}
	PostWrite(ToAdd);
}

function BBCmarql() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[marq=left]" + theSelection + "[/marq]";
		document.post.message.focus();
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[marq=left]", "[/marq]");
		return;
	}
	if (marql == 0) {
		ToAdd = "[marq=left]";
		document.post.marql.src = "mods/bbcode_box/images/marql1.gif";
		marql = 1;
	} else {
		ToAdd = "[/marq]";
		document.post.marql.src = "mods/bbcode_box/images/marql.gif";
		marql = 0;
	}
	PostWrite(ToAdd);
}

function BBCmarqr() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[marq=right]" + theSelection + "[/marq]";
		document.post.message.focus();
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[marq=right]", "[/marq]");
		return;
	}
	if (marqr == 0) {
		ToAdd = "[marq=right]";
		document.post.marqr.src = "mods/bbcode_box/images/marqr1.gif";
		marqr = 1;
	} else {
		ToAdd = "[/marq]";
		document.post.marqr.src = "mods/bbcode_box/images/marqr.gif";
		marqr = 0;
	}
	PostWrite(ToAdd);
}

function BBCmarqd() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[marq=down]" + theSelection + "[/marq]";
		document.post.message.focus();
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[marq=down]", "[/marq]");
		return;
	}
	if (marqd == 0) {
		ToAdd = "[marq=down]";
		document.post.marqd.src = "mods/bbcode_box/images/marqd1.gif";
		marqd = 1;
	} else {
		ToAdd = "[/marq]";
		document.post.marqd.src = "mods/bbcode_box/images/marqd.gif";
		marqd = 0;
	}
	PostWrite(ToAdd);
}

function BBCcode() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[code]" + theSelection + "[/code]";
		document.post.message.focus();
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[code]", "[/code]");
		return;
	}	
	if (code == 0) {
		ToAdd = "[code]";
		document.post.code.src = "mods/bbcode_box/images/code1.gif";
		code = 1;
	} else {
		ToAdd = "[/code]";
		document.post.code.src = "mods/bbcode_box/images/code.gif";
		code = 0;
	}
	PostWrite(ToAdd);
}

function BBCphp() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[php]" + theSelection + "[/php]";
		document.post.message.focus();
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[php]", "[/php]");
		return;
	}	
	if (php == 0) {
		ToAdd = "[php]";
		document.post.php.src = "mods/bbcode_box/images/php1.gif";
		php = 1;
	} else {
		ToAdd = "[/php]";
		document.post.php.src = "mods/bbcode_box/images/php.gif";
		php = 0;
	}
	PostWrite(ToAdd);
}

function BBCquote() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[quote]" + theSelection + "[/quote]";
		document.post.message.focus();
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[quote]", "[/quote]");
		return;
	}
	if (quote == 0) {
		ToAdd = "[quote]";
		document.post.quote.src = "mods/bbcode_box/images/quote1.gif";
		quote = 1;
	} else {
		ToAdd = "[/quote]";
		document.post.quote.src = "mods/bbcode_box/images/quote.gif";
		quote = 0;
	}
	PostWrite(ToAdd);
}

function BBCspoil() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[spoil]" + theSelection + "[/spoil]";
		document.post.message.focus();
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[spoil]", "[/spoil]");
		return;
	}
	if (spoiler == 0) {
		ToAdd = "[spoil]";
		document.spoil.src = "mods/bbcode_box/images/spoil1.gif";
		spoiler = 1;
	} else {
		ToAdd = "[/spoil]";
		document.spoil.src = "mods/bbcode_box/images/spoil.gif";
		spoiler = 0;
	}
	PostWrite(ToAdd);
}

function BBCanchor() {
	var ToAdd = "";
	var Result1 = 0;
	while (Result1 == 0)
	{
		var Prompt1 = showPrompt("Enter the anchor name.\n\nAnchor name must be one word, alphanumeric","",1,"You didn't enter the anchor name.",/^[\w-\.]+$/,"Anchor name can only contain letters or numbers.");
		if (Prompt1 == "^pcncl-1")
		{
			Result1 = 1;
		}
		else if (Prompt1 != "^perr-1")
		{
			ToAdd = "[anchor]"+Prompt1+"[/anchor]";
			Result1 = 1;
		}
	}
	PostWrite(ToAdd);
}

function BBCurl() {
	var ToAdd = "";
	var Result1 = 0;
	while (Result1 == 0)
	{
		var Prompt1 = showPrompt("Enter the URL","http://",1,"You didn't enter the URL.","","");
		if (Prompt1 == "^pcncl-1")
		{
			Result1 = 1;
		}
		else if (Prompt1 != "^perr-1")
		{
			var Result2 = 0;
			while (Result2 == 0)
			{
				var Prompt2 = showPrompt("Enter the name of the page","",1,"You didn't enter the page name.","","");
				if (Prompt2 == "^pcncl-1")
				{
					Result2 = 1;
				}
				else if (Prompt2 != "^perr-1")
				{
					ToAdd = "[url="+Prompt1+"]"+Prompt2+"";
					Result2 = 1;
				}
			}
			Result1 = 1;
		}
	}
	PostWrite(ToAdd);
}

function BBCyoutube() {
	var ToAdd = "";
	var Result1 = 0;
	while (Result1 == 0)
	{
		var Prompt1 = showPrompt("Enter the YouTube URL","http://",1,"You didn't enter the YouTube URL.","","");
		if (Prompt1 == "^pcncl-1")
		{
			Result1 = 1;
		}
		else if (Prompt1 != "^perr-1")
		{
			ToAdd = "[youtube]"+Prompt1+"[/youtube]";
			Result1 = 1;
		}
	}
	PostWrite(ToAdd);
}

function BBCmail() {
	var ToAdd = "";
	var Result1 = 0;
	while (Result1 == 0)
	{
		var Prompt1 = showPrompt("Enter the email address.","",1,"You didn't enter an email address.","","");
		if (Prompt1 == "^pcncl-1")
		{
			Result1 = 1;
		}
		else if (Prompt1 != "^perr-1")
		{
			ToAdd = "[email]"+Prompt1+"[/email]";
			Result1 = 1;
		}
	}
	PostWrite(ToAdd);
}

function BBCgotopost() {
	var ToAdd = "";
	var Result1 = 0;
	while (Result1 == 0)
	{
		var Prompt1 = showPrompt("Enter the post number. (Optional)\nNote: Either a post number or an anchor name is required.","",0,"",/^[\d]+$/,"Only numbers are allowed.");
		if (Prompt1 == "^pcncl-1")
		{
			Result1 = 1;
		}
		else if (Prompt1 != "^perr-1")
		{
			var Result2 = 0;
			while (Result2 == 0)
			{
				var Prompt2 = showPrompt("Enter the anchor name. (Optional)\nAnchor name must be one word, alphanumeric.\nNote: Either a post number or an anchor name is required.","",0,"",/^[\w-\.]+$/,"Anchor name can only contain letters or numbers.");
				if (Prompt2 == "^pcncl-1")
				{
					Result2 = 1;
				}
				else if (Prompt2 != "^perr-1")
				{
					if (Prompt1 == "" && Prompt2 == "")
					{
						alert("You didn't enter a post number nor an anchor name.\nYou must enter either a post number, an anchor name, or both.");
						BBCgotopost();
						return false;
					}
					var Result3 = 0;
					while (Result3 == 0)
					{
						var Prompt3 = showPrompt("Enter the name of the page","",1,"You didn't enter the page name.","","");
						if (Prompt3 == "^pcncl-1")
						{
							Result3 =1;
						}
						else if (Prompt3 != "^perr-1")
						{
							ToAdd = "[gotopost="+Prompt1;
							if (Prompt1 && Prompt2)
							{
								ToAdd += ",";
							}
							if (Prompt2 != "")
							{
								ToAdd += Prompt2;
							}
							ToAdd += "]"+Prompt3+"[/gotopost]";
							Result3 = 1;
						}
					}
					Result2 = 1;
				}
			}
			Result1 = 1;
		}
	}
	PostWrite(ToAdd);
}

function BBCsearch() {
	var ToAdd = "";
	var Result1 = 0;
	while (Result1 == 0)
	{
		var Prompt1 = showPrompt("Enter text to search for.","",1,"You didn't enter a search string.","","");
		if (Prompt1 == "^pcncl-1")
		{
			Result1 = 1;
		}
		else if (Prompt1 != "^perr-1")
		{
			ToAdd = "[search]"+Prompt1+"[/search]";
			Result1 = 1;
		}
	}
	PostWrite(ToAdd);
}

function BBCgoogle() {
	var ToAdd = "";
	var Result1 = 0;
	while (Result1 == 0)
	{
		var Prompt1 = showPrompt("Enter text to search for.","",1,"You didn't enter a search string.","","");
		if (Prompt1 == "^pcncl-1")
		{
			Result1 = 1;
		}
		else if (Prompt1 != "^perr-1")
		{
			ToAdd = "[google]"+Prompt1+"[/google]";
			Result1 = 1;
		}
	}
	PostWrite(ToAdd);
}

function BBCphoto() {
	var ToAdd = "";
	var Result1 = 0;
	while (Result1 == 0)
	{
		var Prompt1 = showPrompt("Enter the photo URL","http://",1,"You didn't enter the photo URL.","","");
		if (Prompt1 == "^pcncl-1")
		{
			Result1 = 1;
		}
		else if (Prompt1 != "^perr-1")
		{
			ToAdd = "[photo]"+Prompt1+"[/photo]";
			Result1 = 1;
		}
	}
	PostWrite(ToAdd);
}

function BBCimg() {
	var ToAdd = "";
	var imgType = "img";
	var Result1 = 0;

	var confirmSiteimg = confirm("Do you want to display an album image?\n\nThis will display an image from\nthe image gallery.\n\nCancel will link to an external image.");

	while (Result1 == 0)
	{
		var Prompt1 = "";
		if (confirmSiteimg)
		{
			var confirmFullimg = confirm("Do you want the image to be displayed as a thumbnail?\n\nClick cancel if you want the image to be displayed at full size.");
			if (confirmFullimg)
			{
				Prompt1 = showPrompt("Enter the gallery image number","",1,"You didn't enter the image number.",/^[\d]+$/,"Only numbers are allowed.");
				imgType = "albumimg";
			}
			else
			{
				Prompt1 = showPrompt("Enter the gallery image number","",1,"You didn't enter the image number.",/^[\d]+$/,"Only numbers are allowed.");
				imgType = "fullalbumimg";
			}
		}
		else
		{
			Prompt1 = showPrompt("Enter the image URL","http://",1,"You didn't enter the image URL.","","");
		}
		if (Prompt1 == "^pcncl-1")
		{
			Result1 = 1;
		}
		else if (Prompt1 != "^perr-1")
		{
			var Result2 = 0;
			while (Result2 == 0)
			{
var Prompt2 = showPrompt("Enter image position.\nLEFT = Position to left of text.\nRIGHT = Position to right of text.\nCENTER = Center in line.\nLeave blank for no positioning.","",0,"",/(left|right|center)/i,"Valid options are 'left', 'right', 'center', or leave blank.");
            if (Prompt2 == "^pcncl-1")
            {
               Result2 = 1;
            }
            else if (Prompt2 != "^perr-1")
            {
                  if (Prompt2.toLowerCase() == 'left')
               {
                  if (imgType == "img")
                  {
                     Prompt2 = "=left";
                  }
                  else
                  {
                     Prompt2 = "=left";
                  }
               }
               if (Prompt2.toLowerCase() == 'right')
               {
                  if (imgType == "img")
                  {
                     Prompt2 = "=right";
                  }
                  else
                  {
                     Prompt2 = "=right";
                  }
               }
               if (Prompt2.toLowerCase() == 'center')
               {
                  if (imgType == "img")
                  {
                     Prompt2 = "=center";
                  }
                  else
                  {
                     Prompt2 = "=center";
                  }
               }
                  ToAdd = "";
               if (Prompt2 != '')
               {
               if (imgType == "img")
                {
                  ToAdd += "[img"+Prompt2.toLowerCase()+"]"+Prompt1+"[/"+imgType+"]";
                }
               else
                {
                  ToAdd += "[align"+Prompt2.toLowerCase()+"]["+imgType+"]"+Prompt1+"[/"+imgType+"][/align]";
                }
               
               }
               else
               {
               ToAdd += "["+imgType+"]"+Prompt1+"[/"+imgType+"]";
            }
            }
            Result2 = 1;
			}
			Result1 = 1;
		}
	}
	PostWrite(ToAdd);
}

function BBCram() {
	var ToAdd = "";
	var Result1 = 0;
	while (Result1 == 0)
	{
		var Prompt1 = showPrompt("Enter the URL to the Real Media stream.","http://",1,"You didn't enter the URL.","","");
		if (Prompt1 == "^pcncl-1")
		{
			Result1 = 1;
		}
		else if (Prompt1 != "^perr-1")
		{
			var Result2 = 0;
			while (Result2 == 0)
			{
				var Prompt2 = showPrompt("Enter the width of the control.","220",1,"You didn't enter a width.",/^[\d]+$/,"Only numbers are allowed.");
				if (Prompt2 == "^pcncl-1")
				{
					Result2 = 1;
				}
				else if (Prompt2 != "^perr-1")
				{
					var Result3 = 0;
					while (Result3 == 0)
					{
						var Prompt3 = showPrompt("Enter the height of the control.","140",1,"You didn't enter a height.",/^[\d]+$/,"Only numbers are allowed.");
						if (Prompt3 == "^pcncl-1")
						{
							Result3 =1;
						}
						else if (Prompt3 != "^perr-1")
						{
							ToAdd = "[ram width="+Prompt2+" height="+Prompt3+"]"+Prompt1+"[/ram]";
							Result3 = 1;
						}
					}
					Result2 = 1;
				}
			}
			Result1 = 1;
		}
	}
	PostWrite(ToAdd);
}

function BBCstream() {
	var ToAdd = "";
	var Result1 = 0;
	while (Result1 == 0)
	{
		var Prompt1 = showPrompt("Enter URL of sound file.","http://",1,"You didn't enter a valid URL.","","");
		if (Prompt1 == "^pcncl-1")
		{
			Result1 = 1;
		}
		else if (Prompt1 != "^perr-1")
		{
			ToAdd = "[stream]"+Prompt1+"[/stream]";
			Result1 = 1;
		}
	}
	PostWrite(ToAdd);
}

function BBCvideo() {
	var ToAdd = "";
	var Result1 = 0;
	while (Result1 == 0)
	{
		var Prompt1 = showPrompt("Enter the URL of the video file.","http://",1,"You didn't enter the URL.","","");
		if (Prompt1 == "^pcncl-1")
		{
			Result1 = 1;
		}
		else if (Prompt1 != "^perr-1")
		{
			var Result2 = 0;
			while (Result2 == 0)
			{
				var Prompt2 = showPrompt("Enter the width of the control.","400",1,"You didn't enter a width.",/^[\d]+$/,"Only numbers are allowed.");
				if (Prompt2 == "^pcncl-1")
				{
					Result2 = 1;
				}
				else if (Prompt2 != "^perr-1")
				{
					var Result3 = 0;
					while (Result3 == 0)
					{
						var Prompt3 = showPrompt("Enter the height of the control.","350",1,"You didn't enter a height.",/^[\d]+$/,"Only numbers are allowed.");
						if (Prompt3 == "^pcncl-1")
						{
							Result3 =1;
						}
						else if (Prompt3 != "^perr-1")
						{
							ToAdd = "[video width="+Prompt2+" height="+Prompt3+"]"+Prompt1+"[/video]";
							Result3 = 1;
						}
					}
					Result2 = 1;
				}
			}
			Result1 = 1;
		}
	}
	PostWrite(ToAdd);
}

function BBCweb() {
	var ToAdd = "";
	var Result1 = 0;
	while (Result1 == 0)
	{
		var Prompt1 = showPrompt("Enter URL of web page to include.","http://",1,"You didn't enter a valid URL.","","");
		if (Prompt1 == "^pcncl-1")
		{
			Result1 = 1;
		}
		else if (Prompt1 != "^perr-1")
		{
			var Result2 = 0;
			while (Result2 == 0)
			{
				var Prompt2 = showPrompt("Enter the height of the iframe.","350",1,"You didn't enter a height.",/^[\d]+$/,"Only numbers are allowed.");
				if (Prompt2 == "^pcncl-1")
				{
					Result2 =1;
				}
				else if (Prompt2 != "^perr-1")
				{
					ToAdd = "[web height="+Prompt2+"]"+Prompt1+"[/web]";
					Result2 = 1;
				}
			}
			Result1 = 1;
		}
	}
	PostWrite(ToAdd);
}

function BBCflash() {
	var ToAdd = "";
	var Result1 = 0;
	while (Result1 == 0)
	{
		var Prompt1 = showPrompt("Enter the URL of the Flash file.","http://",1,"You didn't enter the URL.","","");
		if (Prompt1 == "^pcncl-1")
		{
			Result1 = 1;
		}
		else if (Prompt1 != "^perr-1")
		{
			var Result2 = 0;
			while (Result2 == 0)
			{
				var Prompt2 = showPrompt("Enter the width of the control.","250",1,"You didn't enter a width.",/^[\d]+$/,"Only numbers are allowed.");
				if (Prompt2 == "^pcncl-1")
				{
					Result2 = 1;
				}
				else if (Prompt2 != "^perr-1")
				{
					var Result3 = 0;
					while (Result3 == 0)
					{
						var Prompt3 = showPrompt("Enter the height of the control.","250",1,"You didn't enter a height.",/^[\d]+$/,"Only numbers are allowed.");
						if (Prompt3 == "^pcncl-1")
						{
							Result3 =1;
						}
						else if (Prompt3 != "^perr-1")
						{
							ToAdd = "[flash width="+Prompt2+" height="+Prompt3+"]"+Prompt1+"[/flash]";
							Result3 = 1;
						}
					}
					Result2 = 1;
				}
			}
			Result1 = 1;
		}
	}
	PostWrite(ToAdd);
}

function BBChr() {
	ToAdd = "[hr]";
	PostWrite(ToAdd);
}

function BBCnbsp() {
	ToAdd = "[nbsp]";
	PostWrite(ToAdd);
}

function BBCtab() {
	ToAdd = "[tab]";
	PostWrite(ToAdd);
}

function BBCyou() {
	ToAdd = "[you]";
	PostWrite(ToAdd);
}

function BBCtable()
{
	var ToAdd = "";
	var cols = 0;
	var rows = 0;

	var confirmAdvanced = confirm("Do you want to create an advanced table?\n\nAdvanced tables allow you to specify the\nbackground color and font size for each cell.\n\nCancel will create a basic table.");
	var confirmHeader = confirm("Do you want a header row?\n\nCancel will not create a header row.")

	var Result1 = 0;
	while (Result1 == 0)
	{
		var Prompt1 = showPrompt("How many columns in your table?","",1,"You didn't enter a number.",/^[\d]+$/,"Only numbers are allowed.");
		if (Prompt1 == "^pcncl-1")
		{
			Result1 = 1;
		}
		else if (Prompt1 != "^perr-1")
		{
			if (Prompt1 < 1)
			{
				alert("You cannot have less than 1 column.");
			}
			else
			{
				var Result2 = 0;
				while (Result2 == 0)
				{
					var Prompt2  = showPrompt("How many rows in your table?","",1,"You didn't enter a number.",/^[\d]+$/,"Only numbers are allowed.");
					if (Prompt2 == "^pcncl-1")
					{
						Result2 = 1;
					}
					else if (Prompt2 != "^perr-1")
					{
						if (Prompt2 < 1)
						{
							alert("You cannot have less than 1 row.");
						}
						else
						{
							cols = Prompt1;
							rows = Prompt2;
							Result2 = 1;
						}
					}
				}
				Result1 = 1;
			}
		}
	}

	if (rows != 0 && cols != 0)
	{
		var rowIndex = 0;
		var colIndex = 0;
		
		ToAdd = "[table";
		if (confirmAdvanced)
		{
			ToAdd += tableColorFont("the table");
		}
		ToAdd += "]";
		
		if (confirmHeader)
		{
			while (colIndex < cols)
			{
				if (colIndex == 0)
				{
					ToAdd += "[mrow";
				}
				else
				{
					ToAdd += "[mcol";
				}
				if (confirmAdvanced)
				{
					ToAdd += tableColorFont("Column Header "+(colIndex+1));
				}
				ToAdd += "]";
				
				var Prompt3 = showPrompt("Column Header "+(colIndex+1)+" Value:","",0,"","","");
				if (Prompt3 == "^pcncl-1")
				{
					Prompt3 = "";
				}
				ToAdd += Prompt3;
				colIndex++
			}
			colIndex = 0;
		}
		
		while (rowIndex < rows)
		{
			while (colIndex < cols)
			{
				if (colIndex == 0)
				{
					ToAdd += "[row";
				}
				else
				{
					ToAdd += "[col";
				}
				if (confirmAdvanced)
				{
					ToAdd += tableColorFont("Row "+(rowIndex+1)+", Column "+(colIndex+1));
				}
				ToAdd += "]";
				
				var Prompt4 = showPrompt("Row "+(rowIndex+1)+", Column "+(colIndex+1)+" Value:","",0,"","","");
				if (Prompt4 == "^pcncl-1")
				{
					Prompt4 = "";
				}
				ToAdd += Prompt4;
				colIndex++
			}
			colIndex = 0;
			rowIndex++
		}
		
		ToAdd += "[/table]";
	}

	PostWrite(ToAdd);
}

function tableColorFont(item)
{
	var retVal = "";
	var Prompt1 = showPrompt("What is the color for "+item+"?\nLeave blank if you don't want to set a color.","",0,"","","");
	if (Prompt1 != "" && Prompt1 != "^pcncl-1")
	{
		retVal += " color="+Prompt1;
	}
	var Result2 = 0;
	while (Result2 == 0)
	{
		var Prompt2 = showPrompt("What is the font size for "+item+"?\nLeave blank if you don't want to set a font size.","",0,"",/^[\d]+$/,"Only numbers are allowed.");
		if (Prompt2 == "^pcncl-1" || Prompt2 == "")
		{
			Result2 = 1;
		}
		else if (Prompt2 != "^perr-1")
		{
			retVal += " fontsize="+Prompt2;
			Result2 = 1;
		}
	}
	return retVal;
}
[/code][/spoiler]

[size=14][b]bbcode_box_a.js[/b][/size]

[spoiler][code linenumbers=true]/*Temp admin fix to allow image location when used by several files stored in different locations*/
var theSelection = false;

var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version

var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
                && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_moz = 0;

var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);

rtl_help = "Set textbox right to left";
ltr_help = "Set textbox left to right";
plain_help = "Remove BBCodes from the selected text";
fc_help = "Font color: [color=red]text[/color] (You can use HTML color=#FF0000)";
fs_help = "Font size: [size=9]Very Small[/size]";
ft_help = "Font type: [font=Andalus]text[/font]";
right_help = "Right align text: [align=right]text[/align]";
left_help = "Left align text: [align=left]text[/align]";
center_help = "Center align text: [align=center]text[/align]";
justify_help = "Justify text: [align=justify]text[/align]";
b_help = "Bold: [b]text[/b]";
i_help = "Italic: [i]text[/i]";
u_help = "Underline: [u]text[/u]";
strike_help = "Strike-through: [strike]text[/strike]";
sup_help = "Superscript: [sup]text[/sup]";
sub_help = "Subscript: [sub]text[/sub]";
grad_help ="Insert gradient text";
fade_help = "Fade text: [fade]text[/fade]";
list_help = "List: [list(=1|a)][*]item 1[*]item 2[/list]";
marqr_help = "Marquee right: [marq=right]text[/marq]";
marql_help = "Marquee left: [marq=left]text[/marq]";
marqu_help = "Marquee up: [marq=up]text[/marq]";
marqd_help = "Marquee down: [marq=down]text[/marq]";
quote_help = "Quote: [quote]text[/quote]";
code_help = "Code: [code]code[/code]";
php_help = "PHP: [php]php code[/php]";
spoil_help = "Spoiler: [spoil]text[/spoil]";
anchor_help = "Anchor: [anchor]name[/anchor]";
url_help = "Insert URL: http://Site URL or [url=http://Site URL]Site Name";
youtube_help = "Insert youtube image: [youtube]http://youtube URL[/youtube]";
mail_help = "Insert email: [email]Email Here[/email]";
gotopost_help = "Gotopost: [gotopost=post]text[/gotopost] [gotopost=name]text[/gotopost] [gotopost=post,name]text[/gotopost]";
photo_help = "Insert photo image: [photo]http://photo URL[/photo]";
img_help = "Insert image: [img(=left|right|center)]http://image path[/img] [albumimg(l|r|c)]AlbumImage#[/albumimg(l|r|c)]";
stream_help="Insert stream file: [stream]File URL[/stream]";
ram_help="Insert real media file: [ram]File URL[/ram]";
web_help="Insert web page: [web height=#]Page URL[/web]";
video_help="Insert video file: [video width=# height=#]file URL[/video]";
flash_help="Insert flash file: [flash width=# height=#]flash URL[/flash]";
spell_help = "Spell Check: Checks the spelling in the post";
hr_help="Insert H-Line: [hr]";
you_help = "Inserts username of the reader: [you]";
tab_help = "Inserts a tab into post: [tab]";
nbsp_help = "Inserts a non-breaking space into post: [nbsp]";
search_help = "Search site: [search]String to search for[/search]";
google_help = "Google: [google]String to search for[/google]";
table_help = "Creates a Table using BBCode";

var fade = 0;
var center = 0;
var left = 0;
var right = 0;
var justify = 0;
var bold = 0;
var italic = 0;
var underline = 0;
var strikeout = 0;
var superscript = 0;
var subscript = 0;
var marqd = 0;
var marqu = 0;
var marql = 0;
var marqr = 0;
var code = 0;
var quote = 0;
var php = 0;
var spoiler = 0;

// Fix a bug involving the TextRange object in IE. From
// http://www.frostjedi.com/terra/scripts/demo/caretBug.html
// (script by TerraFrost modified by reddog)
function initInsertions() {
	var baseHeight;
	document.post.message.focus();
	if (is_ie && typeof(baseHeight) != 'number') baseHeight = document.selection.createRange().duplicate().boundingHeight;
}

function helpline(help) {
	document.post.helpbox.value = eval(help + "_help");
	document.post.helpbox.readOnly = "true";
}

function checkForm() {
	formErrors = false;    
	if (document.post.message.value.length < 2) {
		formErrors = "You must enter a message when posting";
	}
	if (formErrors) {
		alert(formErrors);
		return false;
	} else {
		//formObj.preview.disabled = true;
		//formObj.submit.disabled = true;
		return true;
	}
}

function emoticon(text) {
	var txtarea = document.post.message;
	var baseHeight;
	if (is_ie && typeof(baseHeight) != 'number') baseHeight = document.selection.createRange().duplicate().boundingHeight;
	text = ' ' + text + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
		if (baseHeight != txtarea.caretPos.boundingHeight) {
			txtarea.focus();
			storeCaret(txtarea);
		}
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
		txtarea.focus();
	} else
	if (txtarea.selectionEnd && (txtarea.selectionStart | txtarea.selectionStart == 0))
	{ 
		mozWrap(txtarea, text, "");
		return;
	} else {
		txtarea.value  += text;
		txtarea.focus();
	}
}

function storeCaret(textEl) {
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

function PostWrite(text) {
	posttextarea = document.post.message;

	if (posttextarea.createTextRange && posttextarea.caretPos)
	{
		var caretPos = posttextarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?	text + ' ' : text;
		posttextarea.focus(caretPos)
	}
	else if (posttextarea.selectionStart)
	{
		posttextarea.focus();
		scrollTop = posttextarea.scrollTop;
		
		var selLength = posttextarea.textLength;
		var selStart = posttextarea.selectionStart;
		var s1 = (posttextarea.value).substring(0,selStart);
		var s2 = (posttextarea.value).substring(selStart,selLength);
		
		posttextarea.value = s1 + text + s2;
		posttextarea.selectionStart = selStart + text.length;
		posttextarea.selectionEnd = selStart + text.length;
		posttextarea.scrollTop = scrollTop;
		posttextarea.focus();
	}
	else
	{
		posttextarea.value += text;
		posttextarea.focus();
	}
}

function mozWrap(posttextarea, open, close)
{
	posttextarea.focus();
	scrollTop = posttextarea.scrollTop;
	
	var selLength = posttextarea.textLength;
	var selStart = posttextarea.selectionStart;
	var selEnd = posttextarea.selectionEnd;
	if (selEnd == 1 || selEnd == 2) 
		selEnd = selLength;

	var s1 = (posttextarea.value).substring(0,selStart);
	var s2 = (posttextarea.value).substring(selStart, selEnd)
	var s3 = (posttextarea.value).substring(selEnd, selLength);
	posttextarea.value = s1 + open + s2 + close + s3;

	posttextarea.selectionStart = selStart;
	posttextarea.selectionEnd = selEnd + open.length + close.length;
	posttextarea.scrollTop = scrollTop;
	posttextarea.focus();
	return;
}

function bbfontstyle(bbopen, bbclose) {
	var txtarea = document.post.message;

	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (!theSelection) {
			txtarea.value += bbopen + bbclose;
			txtarea.focus();
			return;
		}
		document.selection.createRange().text = bbopen + theSelection + bbclose;
		txtarea.focus();
		return;
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, bbopen, bbclose);
		return;
	}
	else
	{
		txtarea.value += bbopen + bbclose;
		txtarea.focus();
	}
	storeCaret(txtarea);
}

//----- Start: Prompt Control by Jason Sanborn
// promptMsg = Message to be displayed on Prompt Dialog Box
// promptDefault = Default text to be displayed in the Prompt Dialog Box
// promptReq = Data Required? 0-False, 1-True
// promptReqErr = Error message to display if Required data not entered
// promptRegEx = Regular Expression to validate data
// promptRegExErr = Error message to display if RegEx fails to validate data
function showPrompt(promptMsg,promptDefault,promptReq,promptReqErr,promptRegExp,promptRegExpErr)
{
	if (is_ie)
	{
		promptMsg = promptMsg.replace(/\n/gi," ");
		promptMsg = promptMsg.replace(/  /gi," ");
	}
	var promptVal = prompt(promptMsg,promptDefault);
	if (promptVal == null)
	{
		return "^pcncl-1";
	}
	else
	{
		var retVal = trim(promptVal);
		if (retVal == '' && promptReq == 1)
		{
			alert(promptReqErr);
			return "^perr-1";
		}
		else
		{
			if (retVal !='' && promptRegExp != '')
			{
				var regMatch = promptRegExp;
				if (regMatch.test(retVal))
				{
					return retVal;
				}
				else
				{
					alert(promptRegExpErr);
					return "^perr-1";
				}
			}
			else
			{
				return retVal;
			}
		}
	}
}

// JavaScript Trim: http://artlung.com/blog/2006/04/21/javascript-trim-function/
function trim(str)
{
while(''+str.charAt(0)==' ')
str=str.substring(1,str.length);
while(''+str.charAt(str.length-1)==' ')
str=str.substring(0,str.length-1);
return str;
}
//----- End: Prompt Control by Jason Sanborn

function BBCdir(dirc) {
       document.post.message.dir=(dirc);
}

function BBCplain() {
	if (is_ie)
	{
		theSelection = document.selection.createRange().text;
	}
	else
	{
		posttextarea = document.post.message;
		start = posttextarea.selectionStart;
		end = posttextarea.selectionEnd;
		scrollTop = posttextarea.scrollTop;
		theSelection=(posttextarea.value).substring(start,end);
	}
	if (theSelection == '')
	{
		var confirmDel = confirm("Are you sure that you want to erase all BBCodes in this post?\n\nThis action cannot be undone.");
		if (confirmDel)
		{
			posttextarea = document.post.message;
			posttextarea.select();
			if (is_ie)
			{
				theSelection = document.selection.createRange().text;
			}
			else
			{
				start = posttextarea.selectionStart;
				end = posttextarea.selectionEnd;
				scrollTop = posttextarea.scrollTop;
				theSelection=(posttextarea.value).substring(start,end);
			}
		}
	}
	if (theSelection != '')
	{
		temp = theSelection;
		temp = temp.replace(/\[FLASH=([^\]]*)\]WIDTH=[0-9]{0,4} HEIGHT=[0-9]{0,4}\[\/FLASH\]/gi,"$1");
		temp = temp.replace(/\[VIDEO=([^\]]*)\]WIDTH=[0-9]{0,4} HEIGHT=[0-9]{0,4}\[\/VIDEO\]/gi,"$1");
		temp = temp.replace(/\[[^\]]*\]/gi,"");
		if (is_ie)
		{
			document.selection.createRange().text = temp;
		}
		else
		{
			endtext=posttextarea.value.substring(end,posttextarea.textLength);
			starttext=posttextarea.value.substring(0,start);
			lendiff = theSelection.length - temp.length;
			posttextarea.value = starttext + temp + endtext;
			posttextarea.selectionStart = start;
			posttextarea.selectionEnd = end - lendiff;
			posttextarea.scrollTop = scrollTop;

			posttextarea.focus();
		}
	}
}

function BBCft() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[font="+document.post.ft.value+"]" + theSelection + "[/font]";
		document.post.message.focus();
		document.post.ft[0].selected = true;
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[font="+document.post.ft.value+"]", "[/font]");
		document.post.ft[0].selected = true;
		return;
	}
	ToAdd = "[font="+document.post.ft.value+"]"+" "+"[/font]";
	document.post.ft[0].selected = true;
	PostWrite(ToAdd);
}

function BBCfs() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[size="+document.post.fs.value+"]" + theSelection + "[/size]";
		document.post.message.focus();
		document.post.fs[0].selected = true;
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[size="+document.post.fs.value+"]", "[/size]");
		document.post.fs[0].selected = true;
		return;
	}
	ToAdd = "[size="+document.post.fs.value+"]"+" "+"[/size]";
	document.post.fs[0].selected = true;
	PostWrite(ToAdd);
}

function BBCfc() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection != '') {
		document.selection.createRange().text = "[color="+document.post.fc.value+"]" + theSelection + "[/color]";
		document.post.message.focus();
		document.post.fc[0].selected = true;
		return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, "[color="+document.post.fc.value+"]", "[/color]");
		document.post.fc[0].selected = true;
		return;
	}
	ToAdd = "[color="+document.post.fc.value+"]"+" "+"[/color]";
	document.post.fc[0].selected = true;
	PostWrite(ToAdd);
}
[/code][/spoiler]


-----------------------------------
mort
Sun 20 Feb, 2011 05:12

Re: Bbcode Web Tags?
-----------------------------------
@ batman.

Jeeeze mate, what are you doing with that last post of yours?  :?: 


The damn thing is trying to load some microsoft stuff if one is using IE! Grrrrrrrrrrr!  :mrblue: 



Code tags mate and SPOILERS!  :P 

@ spydie and theSteffen - Thanks, I've got it.  :mryellow:


-----------------------------------
Joshua203
Sun 20 Feb, 2011 07:41

Re: Bbcode Web Tags?
-----------------------------------
small part of the last posted code by batman that made me edit this multiple times wthout succes:

[code linenumbers=false]
function BBCfade() {
	var txtarea = document.post.message;
	
	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.[/code]

more than this just was not there ...like it was n't enough already  :lol:

Edit:
OOooh and batman ..please try to post properly as Mort already asked you 

greetings,
.. your Hairdresser :lol:


-----------------------------------
batman
Sun 20 Feb, 2011 07:48

Re: Bbcode Web Tags?
-----------------------------------
Thanks for the edit Joshua203, i did put in code tags but didn't work for some reason  :?  :wink:


-----------------------------------
mort
Sun 20 Feb, 2011 08:08

Re: Bbcode Web Tags?
-----------------------------------
I can't see how the code is of any use anyway - it's like comparing apples and bananas.  :mryellow: 

Also - Back on-Topic:

You said back there you only wanted Admin's and Mods to be able to tag existing Url's?

It raises something interesting that I'm trying to get my head around and will have a look at - Not promising, because of the permissions to prevent users from exploiting it - as MG stated - ain't quite that easy.

 :(

[ot]
[quote=Joshua]greetings,
.. your Hairdresser[/quote]

Hehehe! I think that means he's sharpening up the cut-throat razor - because he probably never cut hair in his life! :mryellow: [/ot]


-----------------------------------
Joshua203
Sun 20 Feb, 2011 08:47

Re: Bbcode Web Tags?
-----------------------------------
[quote user="batman" post="51690"]Thanks for the edit Joshua203, i did put in code tags but didn't work for some reason  :?  :wink:[/quote]

Probably the character limit for posting was hit :wink:

EDIT:
@Mort ..hehehe I prefer not to explain the undertone of that joke  :wink:  :lol:


-----------------------------------
Mighty Gorgon
Sun 20 Feb, 2011 09:12

Re: Bbcode Web Tags?
-----------------------------------
[quote user="mort" post="51670"]@ MG,

I will have a look at the dev version - only if I don't have to go and get it from SVN. Sooooooo, if you have a .zip available somewhere and hit me with a link to download it - That'd be nice.  :mricy:[/quote]
Guys, there is no need to create a zip on your own... please use the GIT repository, since it is always synchronized with SVN (I update them at the same time) and it has some very nice features for quickly interact.

For example from here https://github.com/MightyGorgon/icy_phoenix you can download directly the package as ZIP by clicking on the top right button.

Regarding the permissions system and the possibility for ADMINS / MODS to edit other posts users, it is integrated in the latest dev version: there is a switch in ACP and some code in posting.php.

I just point you to a piece of code:
[codeblock]$html_on = (!empty($_POST['disable_html']) ? 0 : ((($userdata['user_level'] == ADMIN) && $config['allow_html_only_for_admins']) ? 1 : $html_on));[/codeblock]

I decided to move the check on the HTML switch instead of playing with the parsing itself, because it is easy.

If you just want to force that in old Icy Phoenix, you should be able to do that by just inserting something like this (without any needs to integrate ACP switch):

[codeblock]$html_on = (!empty($_POST['disable_html']) ? 0 : (($userdata['user_level'] == ADMIN) ? 1 : $html_on));[/codeblock]

Just after the check of HTML switch:

[codeblock]// Set toggles for various options
if (!$board_config['allow_html'])
{
	$html_on = 0;
}
else
{
	$html_on = ($submit || $refresh) ? ((!empty($_POST['disable_html'])) ? 0 : 1) : (($userdata['user_id'] == ANONYMOUS) ? $board_config['allow_html'] : $userdata['user_allowhtml']);
}[/codeblock]


-----------------------------------
mort
Sun 20 Feb, 2011 14:13

Re: Bbcode Web Tags?
-----------------------------------
Oh oh! I sent you a pm before I read this. :oops: 

But I still think I would like to destroy the web tags with something colourful if users try to use it.  :mryellow: 

And thanks for the github link.


-----------------------------------
batman
Mon 21 Feb, 2011 01:35

Re: Bbcode Web Tags?
-----------------------------------
[quote user="mort" post="51693"]I can't see how the code is of any use anyway - it's like comparing apples and bananas.  :mryellow: 

Also - Back on-Topic:

You said back there you only wanted Admin's and Mods to be able to tag existing Url's?

It raises something interesting that I'm trying to get my head around and will have a look at - Not promising, because of the permissions to prevent users from exploiting it - as MG stated - ain't quite that easy.

 :(

[ot]
[quote=Joshua]greetings,
.. your Hairdresser[/quote]

Hehehe! I think that means he's sharpening up the cut-throat razor - because he probably never cut hair in his life! :mryellow: [/ot][/quote][quote user="Joshua203" post="51695"][quote user="batman" post="51690"]Thanks for the edit Joshua203, i did put in code tags but didn't work for some reason  :?  :wink:[/quote]

Probably the character limit for posting was hit :wink:

EDIT:
@Mort ..hehehe I prefer not to explain the undertone of that joke  :wink:  :lol:[/quote]

OK Laurel and Hardy  [img]http://www.icyphoenix.com/files/images/9166/laurel_hardy.gif[/img] :P Im no coder so wouldn't know an apple from a banana  :wink:


