/* --------------------------------- Simple:Press Forum - Version 3.1 Base Javascript ------------------------------------ */ /* ----------------------------------*/ /* General Forum Validation */ /* ----------------------------------*/ function sfjvalidatePMForm(theForm, editor, msg0, msg1, msg2, msg3) { var reason = ""; reason += sfjvalidateThis(theForm.pmtoidlist, " - " + msg1); reason += sfjvalidateThis(theForm.pmtitle, " - " + msg2); if(editor == 'QT') { reason += sfjvalidateThis(theForm.newpmpost, " - " + msg3); } else { reason += sfjvalidateTiny('newpmpost', " - " + msg3); } if (reason != "") { var target = document.getElementById('sfvalid'); target.innerHTML = "
" + msg0 + ":

" + reason + "

"; var box = hs.htmlExpand(document.getElementById('sfsave'), {contentId: 'my-content', preserveContent: false}); return false; } return true; } function sfjvalidatePostForm(theForm, editor, msg0, msg1, msg2, msg3, msg4, msg5) { var reason = ""; if(msg1 != '') reason += sfjvalidateThis(theForm.guestname, " - " + msg1); if(msg2 != '') reason += sfjvalidateThis(theForm.guestemail, " - " + msg2); if(msg3 != '') reason += sfjvalidateThis(theForm.newtopicname, " - " + msg3); if(msg4 != '') reason += sfjvalidateThis(theForm.sfvalue1, " - " + msg4); if(editor == 'QT') { if(msg5 != '') reason += sfjvalidateThis(theForm.newtopicpost, " - " + msg5); } else { if(msg5 != '') reason += sfjvalidateTiny('newtopicpost', " - " + msg5); } if (reason != "") { var target = document.getElementById('sfvalid'); target.innerHTML = "
" + msg0 + ":

" + reason + "

"; var box = hs.htmlExpand(document.getElementById('sfsave'), {contentId: 'my-content', preserveContent: false}); return false; } return true; } function sfjvalidateThis(theField, errorMsg) { var error = ""; if (theField.value.length == 0) { error = "" + errorMsg + "
"; } return error; } function sfjvalidateTiny(thisField, errorMsg) { var error = ""; var stuff = tinyMCE.get(thisField).getContent(); if(stuff == '') { error = "" + errorMsg + "
"; } return error; } /* ----------------------------------*/ /* Display Users Email Address */ /* ----------------------------------*/ function sfjshowUserMail(label, address, id) { var param1 = 'sfmail'+id; var param2 = 'mail-content'+id; var param3 = 'sfshowmail'+id; var target = document.getElementById(param1); target.innerHTML = label + "
" + address; var box = hs.htmlExpand(document.getElementById(param3), {contentId: param2}); } function sfjshowPostLink(label, url, id) { var param1 = 'sfpostlink'+id; var param2 = 'link-content'+id; var param3 = 'sfshowlink'+id; var target = document.getElementById(param1); target.innerHTML = label + "

" + url + "

"; var box = hs.htmlExpand(document.getElementById(param3), {contentId: param2}); } /* ----------------------------------*/ /* Open and Close of hidden divs */ /* ----------------------------------*/ function sfjtoggleLayer(whichLayer) { if (document.getElementById) { var style2 = document.getElementById(whichLayer).style; style2.display = style2.display? "":"block"; } else if (document.all) { var style2 = document.all[whichLayer].style; style2.display = style2.display? "":"block"; } else if (document.layers) { var style2 = document.layers[whichLayer].style; style2.display = style2.display? "":"block"; } var obj = document.getElementById(whichLayer); if (whichLayer == 'sfpostform') { obj.scrollIntoView(top); } } /* ----------------------------------*/ /* Quote Post insertion */ /* ----------------------------------*/ function sfjquotePost(postid, intro, rte) { sfjtoggleLayer('sfpostform'); var postcontent = document.getElementById(postid).innerHTML; document.addpost.newtopicpost.value = '
'+intro+postcontent+'

'; if (rte) { tinyMCE.get('newtopicpost').getBody().innerHTML = '
'+intro+postcontent+'


'; } } /* ----------------------------------*/ /* Enable Save button on Math entry */ /* ----------------------------------*/ function sfjsetPostButton(buttontext) { var button = document.addpost.newpost; button.disabled=false; button.value = buttontext; } function sfjsetTopicButton(buttontext) { var button = document.addtopic.newtopic; button.disabled=false; button.value = buttontext; } /* ----------------------------------*/ /* Trigger redirect on drop down */ /* ----------------------------------*/ function sfjchangeURL(menuObj) { var i = menuObj.selectedIndex; if(i > 0) { if(menuObj.options[i].value != '#') { window.location = menuObj.options[i].value; } } } /* ----------------------------------*/ /* redirect */ /* ----------------------------------*/ function sfjreDirect(url) { window.location = url; } /* ----------------------------------*/ /* post moderation and unread */ /* ----------------------------------*/ function sfjmoderatePost(posturl, url, canRemove, postid, forumid, action) { if(posturl != '' && action == 9) { window.location = posturl; return; } var modpostid = 'modp' + postid; var modrowid = 'modrow' + postid; var modpostrowid = 'modpostrow' + postid; var modicon = 'modicon' + postid; var topics = 'tcount' + forumid; var forum = 'modf' + forumid; var topicCount = document.getElementById(topics); topicCount.value--; document.getElementById(modicon).innerHTML = ''; var target1 = document.getElementById(modpostrowid); var target2 = document.getElementById(modrowid); var targetf = document.getElementById(forum); if (navigator.appName == "Microsoft Internet Explorer") { sfjopacity(target1.style,9,0,10,function(){sfjremoveIt(target1);}); sfjopacity(target2.style,9,0,10,function(){sfjremoveIt(target2);}); if(topicCount.value == 0) { sfjopacity(targetf.style,9,0,10,function(){sfjremoveIt(targetf);}); } } else { sfjopacity(target1.style,199,0,10,function(){sfjhideIt(target1);}); sfjopacity(target2.style,199,0,10,function(){sfjhideIt(target2);}); if(topicCount.value == 0) { sfjopacity(targetf.style,199,0,10,function(){sfjhideIt(targetf);}); } } ahahRequest(url, modpostid); if(canRemove) { if(action == 1) { var counter = document.getElementById('sfunread'); } if(action == 0 || action == 9) { var counter = document.getElementById('sfmod'); } var pcount = parseInt(counter.innerHTML); if(isNaN(pcount)) { pcount = 0; } else { pcount--; } counter.style.color = '#ffffff'; counter.innerHTML = pcount; } if(posturl != '') { window.location = posturl; } } function sfjremoveIt(target) { target.style.height="0px"; target.style.display="none"; } /* ----------------------------------*/ /* Load up categories for linking */ /* ----------------------------------*/ function sfjgetCategories(imageFile, url, checked) { var cat = document.getElementById('sfcats'); if(checked) { cat.style.display="block"; cat.innerHTML = '


'; ahahRequest(url, 'sfcats'); } else { cat.style.display="none"; } } /* ----------------------------------*/ /* Load up admins new post list */ /* ----------------------------------*/ function sfjgetNewPostList(imageFile, url, numbersurl) { // newpost counts var targetID = document.getElementById("sfpostnumbers"); if(targetID != null) { var newPostsUrl = numbersurl + "?target=newposts"; jah(newPostsUrl, 'sfpostnumbers'); } var postdiv = document.getElementById('sfadminpostlist'); postdiv.style.display = "block"; postdiv.innerHTML = '


'; jah(url, 'sfadminpostlist'); } /* ----------------------------------*/ /* Load PM message text in inbox */ /* ----------------------------------*/ function sfjgetPMText(imageFile, url, pmId, rowIndex) { var target = 'sfpm'+pmId; var content = document.getElementById(target); var pmTable = document.getElementById('sfmainpmtable'); if (content.innerHTML == '') { content.style.backgroundColor="#FFFFFF"; content.style.color="#000000"; content.style.border="thin dotted silver"; content.style.margin="3px"; content.style.padding="10px"; content.style.visibility = 'visible'; content.style.fontWeight = 'normal'; content.style.overflow = "hidden"; content.innerHTML = '


'; ahahRequest(url, target); } else { content.innerHTML = ''; content.style.margin="0px"; content.style.padding="0px"; content.style.visibility = 'hidden'; pmTable.rows[rowIndex].setAttribute("class", "sfpmread"); } } /* ----------------------------------*/ /* Send pm to selected user */ /* ----------------------------------*/ function sfjsendPMTo(recipient, name, title, reply) { var toField = document.getElementById('pmmembers'); var titleField = document.getElementById('pmtitle'); var isreply = document.getElementById('pmreply'); toField.value = recipient; titleField.value = title; isreply.value = reply; sfjaddpmUser('pmmembers'); sfjtoggleLayer('sfpostform'); } /* ----------------------------------*/ /* Delete a pm */ /* ----------------------------------*/ function sfjdeletePM(id, url, rowIndex) { var pmTable = document.getElementById('sfmainpmtable'); var target = pmTable.rows[rowIndex]; if (navigator.appName == "Microsoft Internet Explorer") { sfjopacity(target.style,9,0,10,function(){sfjremoveIt(target);}); } else { sfjopacity(target.style,199,0,10,function(){sfjhideIt(target);}); } ahahRequest(url, 'sfdummy'); } function sfjremovePMRow(pmTable, rowIndex) { pmTable.deleteRow(rowIndex); } function sfjhideIt(target) { target.style.visibility="collapse"; } function sfjdeleteMassPM(url) { var pmTable = document.getElementById('sfmainpmtable'); if (navigator.appName == "Microsoft Internet Explorer") { sfjopacity(pmTable.style,9,0,10,function(){sfjremoveIt(pmTable);}); } else { sfjopacity(pmTable.style,199,0,10,function(){sfjhideIt(pmTable);}); } ahahRequest(url, 'sfdummy'); } /* ----------------------------------*/ /* Select Add recipients for pm */ /* ----------------------------------*/ function sfjaddpmUser(source) { var source = document.getElementById(source); var targetnames = document.getElementById('pmtonamelist'); var targetids = document.getElementById('pmtoidlist'); var found = false; /* first entry will be blasnk first time in (HTML validation) */ // if(targetnames.options[0].value == '') // { // targetnames.remove(targetnames.options[0]); // } for(i=targetnames.options.length-1;i>=0;i--) { if (targetnames.options[i].value == source.value) { found = true; } } if(!found) { var thisOption = new Option(source.options[source.selectedIndex].text, source.value, true, true); var positionOption = targetnames.length; targetnames.options[positionOption] = thisOption; if (targetids.value.length > 0) { targetids.value += ", "; } targetids.value += source.value; if(targetnames.options[0].value == '') { targetnames.remove(targetnames.options[0]); } } } /* ----------------------------------*/ /* Select Remove recipients for pm */ /* ----------------------------------*/ function sfjremovepmUser() { var targetnames = document.getElementById('pmtonamelist'); var targetids = document.getElementById('pmtoidlist'); var i; targetnames.remove(targetnames.selectedIndex); targetids.value = ''; for(i=targetnames.options.length-1;i>=0;i--) { targetnames.options[i].selected = true; if (targetids.value.length > 0) { targetids.value += ", "; } targetids.value += targetnames.options[i].value; } } /* ----------------------------------*/ /* Error and Success message line */ /* ----------------------------------*/ function sfjmDisplay() { var d=document; var commDiv = d.getElementById('sfcomm'); sfjtoggleLayer('sfcomm'); if (navigator.appName == "Microsoft Internet Explorer") { sfjopacity(commDiv.style,99,0,10,function(){ commDiv.parentNode.removeChild(commDiv);}); } else { sfjopacity(commDiv.style,399,0,10,function(){commDiv.parentNode.removeChild(commDiv);}); } } function sfjopacity(ss,s,e,m,f){ if(s>e){ s--; }else if(s' ,'' ,'b' ); edButtons[edButtons.length] = new sfjedButton('ed_em' ,'i' ,'' ,'' ,'i' ); edButtons[edButtons.length] = new sfjedButton('ed_link' ,'link' ,'' ,'' ,'a' ); edButtons[edButtons.length] = new sfjedButton('ed_block' ,'quote' ,'\n\n
' ,'
\n\n' ,'q' ); edButtons[edButtons.length] = new sfjedButton('ed_ul' ,'ul' ,'\n\n' ,'u' ); edButtons[edButtons.length] = new sfjedButton('ed_ol' ,'ol' ,'
    \n' ,'
\n\n' ,'o' ); edButtons[edButtons.length] = new sfjedButton('ed_li' ,'li' ,'\t
  • ' ,'
  • \n' ,'l' ); edButtons[edButtons.length] = new sfjedButton('ed_code' ,'code' ,'' ,'' ,'c' ); function sfjedLink() { this.display = ''; this.URL = ''; this.newWin = 0; } function sfjedShowButton(button, i) { if (button.id == 'ed_img') { document.write(''); } else if (button.id == 'ed_link') { document.write(''); } else { document.write(''); } } function sfjedShowLinks() { var tempStr = ''; document.write(tempStr); } function sfjedAddTag(button) { if (edButtons[button].tagEnd != '') { edOpenTags[edOpenTags.length] = button; document.getElementById(edButtons[button].id).value = '/' + document.getElementById(edButtons[button].id).value; } } function sfjedRemoveTag(button) { for (i = 0; i < edOpenTags.length; i++) { if (edOpenTags[i] == button) { edOpenTags.splice(i, 1); document.getElementById(edButtons[button].id).value = document.getElementById(edButtons[button].id).value.replace('/', ''); } } } function sfjedCheckOpenTags(button) { var tag = 0; for (i = 0; i < edOpenTags.length; i++) { if (edOpenTags[i] == button) { tag++; } } if (tag > 0) { return true; } else { return false; } } function sfjedCloseAllTags() { var count = edOpenTags.length; for (o = 0; o < count; o++) { sfjedInsertTag(edCanvas, edOpenTags[edOpenTags.length - 1]); } } function sfjedQuickLink(i, thisSelect) { if (i > -1) { var newWin = ''; if (edLinks[i].newWin == 1) { newWin = ' target="_blank"'; } var tempStr = '' + edLinks[i].display + ''; thisSelect.selectedIndex = 0; sfjedInsertContent(edCanvas, tempStr); } else { thisSelect.selectedIndex = 0; } } function sfjedToolbar() { document.write('
    '); for (i = 0; i < edButtons.length; i++) { sfjedShowButton(edButtons[i], i); } document.write(''); document.write('
    '); } function sfjedInsertTag(myField, i) { if (document.selection) { myField.focus(); sel = document.selection.createRange(); if (sel.text.length > 0) { sel.text = edButtons[i].tagStart + sel.text + edButtons[i].tagEnd; } else { if (!sfjedCheckOpenTags(i) || edButtons[i].tagEnd == '') { sel.text = edButtons[i].tagStart; sfjedAddTag(i); } else { sel.text = edButtons[i].tagEnd; sfjedRemoveTag(i); } } myField.focus(); } else if (myField.selectionStart || myField.selectionStart == '0') { var startPos = myField.selectionStart; var endPos = myField.selectionEnd; var cursorPos = endPos; var scrollTop = myField.scrollTop; if (startPos != endPos) { myField.value = myField.value.substring(0, startPos) + edButtons[i].tagStart + myField.value.substring(startPos, endPos) + edButtons[i].tagEnd + myField.value.substring(endPos, myField.value.length); cursorPos += edButtons[i].tagStart.length + edButtons[i].tagEnd.length; } else { if (!sfjedCheckOpenTags(i) || edButtons[i].tagEnd == '') { myField.value = myField.value.substring(0, startPos) + edButtons[i].tagStart + myField.value.substring(endPos, myField.value.length); sfjedAddTag(i); cursorPos = startPos + edButtons[i].tagStart.length; } else { myField.value = myField.value.substring(0, startPos) + edButtons[i].tagEnd + myField.value.substring(endPos, myField.value.length); sfjedRemoveTag(i); cursorPos = startPos + edButtons[i].tagEnd.length; } } myField.focus(); myField.selectionStart = cursorPos; myField.selectionEnd = cursorPos; myField.scrollTop = scrollTop; } else { if (!sfjedCheckOpenTags(i) || edButtons[i].tagEnd == '') { myField.value += edButtons[i].tagStart; sfjedAddTag(i); } else { myField.value += edButtons[i].tagEnd; sfjedRemoveTag(i); } myField.focus(); } } function sfjedInsertContent(myField, myValue) { if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; myField.focus(); } else if (myField.selectionStart || myField.selectionStart == '0') { var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); myField.focus(); myField.selectionStart = startPos + myValue.length; myField.selectionEnd = startPos + myValue.length; } else { myField.value += myValue; myField.focus(); } } function sfjedInsertLink(myField, i, defaultValue) { if (!defaultValue) { defaultValue = 'http://'; } if (!sfjedCheckOpenTags(i)) { var URL = prompt('Enter the URL' ,defaultValue); if (URL) { edButtons[i].tagStart = ''; sfjedInsertTag(myField, i); } } else { sfjedInsertTag(myField, i); } }