function t2()
{
window.open("http://www.abovetopsecret.com/forum/tutorial.html","tutorial","width=660,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no");
}

function c2()
{
window.open("http://www.abovetopsecret.com/forum/ats4chat","newchat","width=750,height=550,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no");
}


function Popup(url, window_name, window_width, window_height)
{settings=
"toolbar=no,location=no,directories=no,"+
"status=no,menubar=no,scrollbars=yes,"+
"resizable=yes,width="+window_width+",height="+window_height;
NewWindow=window.open(url,window_name,settings); 
}

function messagepop(variables){
settings="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=350,height=250";
url="http://www.abovetopsecret.com/forum/ats_viewmessage.php?"+variables;
window.open(url,"viewmessage",settings);
}

function denypop(){
settings="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=520,height=520";
url="http://www.abovetopsecret.com/forum/deny.html";
window.open(url,"deny",settings);
}

function filepop(){
settings="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=520,height=600";
url="http://www.abovetopsecret.com/forum/ats_uploads.php?";
window.open(url,"upload",settings);
}

function storepop(){
settings="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=520,height=600";
url="ats_store.php?";
window.open(url,"store",settings);
}

function colorpop(){
settings="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=130,height=400";
url="http://www.abovetopsecret.com/forum/atscolor.html?";
window.open(url,"color",settings);
}

function compop(){
settings="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=450,height=450";
url="http://www.abovetopsecret.com/forum/ats_complain.php?";
window.open(url,"complain",settings);
}

function icon(theicon) {
document.input.message.value += theicon;
document.input.message.focus();
}

<!--Begin Template: functions_bbcode -->


defmode = "normalmode"; // default mode. either normalmode, advmode, or helpmode


if (defmode == "advmode") {
        helpmode = false;
        normalmode = false;
        advmode = true;
} else if (defmode == "helpmode") {
        helpmode = true;
        normalmode = false;
        advmode = false;
} else {
        helpmode = false;
        normalmode = true;
        advmode = false;
}
function chmode(swtch){
        if (swtch == 1){
                advmode = false;
                normalmode = false;
                helpmode = true;
                alert("Help Mode\nClick on any of the formatting buttons for a description and instructions.");
        } else if (swtch == 0) {
                helpmode = false;
                normalmode = false;
                advmode = true;
                alert("Advanced Mode\nThe BB Code will be inserted without options as soon as you hit the button.");
        } else if (swtch == 2) {
                helpmode = false;
                advmode = false;
                normalmode = true;
                alert("Normal Mode\nPopups will bring you step by step through the process of inserting BB Code.");
        }
}


function AddTextOld(NewCode) {
        if(document.all && !document.getElementById){ 
        insertAtCaret(document.input.message,NewCode);
        setfocus();
        }else{
        document.input.message.value+=NewCode;
        setfocus();
        }
}
function storeCaret (textEl){
        if(textEl.createTextRange){
                textEl.caretPos = document.selection.createRange().duplicate();
        }
}


function insertAtCaret (textEl, text){
        if (textEl.createTextRange && textEl.caretPos){
                var caretPos = textEl.caretPos;
                caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
        }else{
                textEl.value  = text;
        }
}

function email() {
        if (helpmode) {
                alert("Email Tag\nTurns an email address into a mailto hyperlink.\nUsage: [email]someone@anywhere.com[/email]\nUsage: [email=someone@anywhere.com]link text[/email]");
        } else if (advmode) {
                AddTxt="[email] [/email]";
                AddText(AddTxt);
        } else {
                txt2=prompt("What name should be shown\nIf this field is empty the email address will be visible","");
                if (txt2!=null) {
                        txt=prompt("Please enter an email address.","name@domain.com");
                        if (txt!=null) {
                                if (txt2=="") {
                                        AddTxt="[email]"+txt+"[/email]";

                                } else {
                                        AddTxt="[email="+txt+"]"+txt2+"[/email]";
                                }
                                AddText(AddTxt);
                        }
                }
        }
}


function yvid() {
        if (helpmode) {
                alert("Includes a YouTube Video.");
        } else if (advmode) {
                AddTxt="[b] [/b]";
                AddText(AddTxt);
        } else {
                txt=prompt("Please enter the YouTube video number.","");
                if (txt!=null) {
                        AddTxt="[yvid]"+txt+"[/yvid]";
                        AddText(AddTxt);
                }
        }
}

function gvid() {
        if (helpmode) {
                alert("Includes a Google Video.");
        } else if (advmode) {
                AddTxt="[b] [/b]";
                AddText(AddTxt);
        } else {
                txt=prompt("Please enter the Google Video DocID number.","");
                if (txt!=null) {
                        AddTxt="[gvid]"+txt+"[/gvid]";
                        AddText(AddTxt);
                }
        }
}


function chsize(size) {
        if (helpmode) {
                alert("0");
        } else if (advmode) {
                AddTxt="[size="+size+"] [/size]";
                AddText(AddTxt);
        } else {
                txt=prompt("Please enter the text to be size  "+size,"Text");
                if (txt!=null) {
                        AddTxt="[size="+size+"]"+txt+"[/size]";
                        AddText(AddTxt);
                }
        }
}

function chfont(font) {
        if (helpmode){
                alert("Font Tag\nSets the font face for the enclosed text.\nUsage: [font="+font+"]The font of this text is");
        } else if (advmode) {
                AddTxt="[font="+font+"] [/font]";
                AddText(AddTxt);
        } else {
                txt=prompt("Please enter the text to be in  "+font,"Text");
                if (txt!=null) {
                        AddTxt="[font="+font+"]"+txt+"[/font]";
                        AddText(AddTxt);
                }
        }
}



function bold() {
        if (helpmode) {
                alert("Bold Tag\nMakes the enlosed text bold.\nUsage: [b]This is some bold text[/b]");
        } else if (advmode) {
                AddTxt="[b] [/b]";
                AddText(AddTxt);
        } else {
                txt=prompt("Please enter the text that should be bolded.","Text");
                if (txt!=null) {
                        AddTxt="[b]"+txt+"[/b]";
                        AddText(AddTxt);
                }
        }
}

function external() {
        if (helpmode) {
                alert("External Content Tag\nIdentifies the enlosed text as being content external to ATS.\nUsage: [ex]This is some external text[/ex]");
        } else if (advmode) {
                AddTxt="[ex] [/ex]";
                AddText(AddTxt);
        } else {
                txt=prompt("Please enter the text that should be quoted as external content.","Text");
                if (txt!=null) {
                        AddTxt="[ex]"+txt+"[/ex]";
                        AddText(AddTxt);
                }
        }
}

function head() {
        if (helpmode) {
                alert("H1 HTML Headline Tag\nCreates an H1 headline in HTML.\nUsage: [headline]This Is Your Headline[/headline]");
        } else if (advmode) {
                AddTxt="[headline] [/headline]";
                AddText(AddTxt);
        } else {
                txt=prompt("Please enter your headline text.","Text");
                if (txt!=null) {
                        AddTxt="[headline]"+txt+"[/headline]";
                        AddText(AddTxt);
                }
        }
}

function newspic() {
        if (helpmode){
                alert("Image Tag\nInserts an image identified as a news source into the post.\nUsage: [im]http:\www.anywhere.comimage.gif[/im]");
        } else if (advmode) {
                AddTxt="[im] [/im]";
                AddText(AddTxt);
        } else {
                txt=prompt("Please enter the URL to the image you wish to insert.","http://");
                if(txt!=null) {
                        AddTxt="\r[im]"+txt+"[/im]";
                        AddText(AddTxt);
                }
        }
}


function italicize() {
        if (helpmode) {
                alert("Italicize Tag\nMakes the enlosed text italicized.\nUsage: [i]This is some italicized text[/i]");
        } else if (advmode) {
                AddTxt="[i] [/i]";
                AddText(AddTxt);
        } else {
                txt=prompt("Please enter the text that should be italicized.","Text");
                if (txt!=null) {
                        AddTxt="[i]"+txt+"[/i]";
                        AddText(AddTxt);
                }
        }
}


function quote() {
        if (helpmode){
                alert("Quote tag\nQuotes the enclosed text to reference something specific that someone has posted.\nUsage: [quote]This is a quote[/quote]");
        } else if (advmode) {
                AddTxt="\r[quote]\r[/quote]";
                AddText(AddTxt);
        } else {
                txt=prompt("Please enter the text you want quoted.","Text");
                if(txt!=null) {
                        AddTxt="\r[quote]\r"+txt+"\r[/quote]";
                        AddText(AddTxt);
                }
        }
}


function chcolor(color) {
        if (helpmode) {
                alert("Color Tag\nSets the text color.  Any named color can be used.\nUsage: [color="+color+"]This is some "+color+" text[/color]");
        } else if (advmode) {
                AddTxt="[color="+color+"] [/color]";
                AddText(AddTxt);
        } else {
        txt=prompt("Please enter the text that should be "+color,"Text "+color,"Text");
                if(txt!=null) {
                        AddTxt="[color="+color+"]"+txt+"[/color]";
                        AddText(AddTxt);
                }
        }
}


function center() {
        if (helpmode) {
                alert("Centered tag\nCenters the enclosed text.\nUsage: [align=center]This text is centered[/align]");
        } else if (advmode) {
                AddTxt="[align=center] [/align]";
                AddText(AddTxt);
        } else {
                txt=prompt("Please enter the text that should be centered.","Text");
                if (txt!=null) {
                        AddTxt="\r[align=center]"+txt+"[/align]";
                        AddText(AddTxt);
                }
        }
}


function hyperlink() {
        if (helpmode) {
                alert("Hyperlink Tag\nTurns an url into a hyperlink.\nUsage: [url]http://www.anywhere.com[/url]\nUsage: [url=http://www.anywhere.com]link text[/url]");
        } else if (advmode) {
                AddTxt="[url] [/url]";
                AddText(AddTxt);
        } else {
                txt2=prompt("What name should be shown?\nIf this Field is blank the URL would be visible","");
                if (txt2!=null) {
                        txt=prompt("Please enter the url for the hyperlink.","http://");
                        if (txt!=null) {
                                if (txt2=="") {
                                        AddTxt="[url]"+txt+"[/url]";
                                        AddText(AddTxt);
                                } else {
                                        AddTxt="[url="+txt+"]"+txt2+"[/url]";
                                        AddText(AddTxt);
                                }
                        }
                }
        }
}


function image() {
        if (helpmode){
                alert("Image Tag\nInserts an image into the post.\nUsage: [img]http:\www.anywhere.comimage.gif[/img]");
        } else if (advmode) {
                AddTxt="[img] [/img]";
                AddText(AddTxt);
        } else {
                txt=prompt("Please enter the URL to the image you wish to insert.","http://");
                if(txt!=null) {
                        AddTxt="\r[img]"+txt+"[/img]";
                        AddText(AddTxt);
                }
        }
}


function code() {
        if (helpmode) {
                alert("Code Tag\nBlockquotes the text you reference and preserves the formatting.\nUsefull for posting code.\nUsage: [code]This is formated text[/code]");
        } else if (advmode) {
                AddTxt="\r[code]\r[/code]";
                AddText(AddTxt);
        } else {
                txt=prompt("Please enter the text you wanted blockquoted.","");
                if (txt!=null) {
                        AddTxt="\r[code]"+txt+"[/code]";
                        AddText(AddTxt);
                }
        }
}


function list() {
        if (helpmode) {
                alert("List Tag\nBuilds a bulleted, numbered, or alphabetical list.\nUsage: [list]\n[*]item1\n[*]item2\n[*]item3\n[/list]");
        } else if (advmode) {
                AddTxt="\r[list]\r[*]\r[*]\r[*]\r[/list]";
                AddText(AddTxt);
        } else {  
                txtstart=prompt("Please select your list type\n ('A' for aplhabetic, '1' for nummeric) You can leave this field blank","");               
                while ((txtstart!="") && (txtstart!="A") && (txtstart!="a") && (txtstart!="1") && (txtstart!=null)) {
                        txtstart=prompt("ERROR!\nThe only possible values for type of list are blank 'A' and '1'.","");               
                }
                if (txtstart!=null) {
                        if (txtstart=="") {
                                AddTxt="\r[list]\r\n";
                        } else {
                                AddTxt="\r[list="+txtstart+"]\r";
                        } 
                        txtend="1";
                        while ((txtend!="") && (txtend!=null)) {
                                txtend=prompt("List Item:\nLeave it blank to End the List",""); 
                                if (txtend!="") {             
                                        AddTxt+="[*]"+txtend+"\r"; 
                                }                   
                        }
                        if (txtstart=="") {
                                AddTxt+="[/list]\r\n";
                        } else {
                                AddTxt+="[/list="+txtstart+"]\r";
                        } 
                        AddText(AddTxt); 
                }
        }
}

function underline() {
        if (helpmode) {
                alert("Underline Tag\nUnderlines the enclosed text.\nUsage: [u]This text is underlined[/u]");
        } else if (advmode) {
                AddTxt="[u] [/u]";
                AddText(AddTxt);
        } else {
                txt=prompt("Please enter the text that should be underlined.","Text");
                if (txt!=null) {
                        AddTxt="[u]"+txt+"[/u]";
                        AddText(AddTxt);
                }
        }
}


function setfocus() {
        document.input.message.focus();
}

function AddText(myValue) {
  if (document.selection) {
    document.input.message.focus();
    sel = document.selection.createRange();
    sel.text = myValue;
  }
  else if (document.input.message.selectionStart || document.input.message.selectionStart == '0') {
    var startPos = document.input.message.selectionStart;
    var endPos = document.input.message.selectionEnd;
    document.input.message.value = document.input.message.value.substring(0, startPos)
                  + myValue
                  + document.input.message.value.substring(endPos, document.input.message.value.length);
  } else {
    document.input.message.value += myValue;
  }
}

