/* Copyright (c) 2007 WildFireWeb Inc.
* wildfireweb.com
* All rights reserved
* This copyright notice MUST stay intact
* Developed by Steve Sweet
*/
var wfw_range = null;
function blogCopyPost(post_id) {
var obj = document.getElementById('wfw_blogpost_'+post_id);
if (!obj)
return;
if (document.createRange) {
// IE9 and modern browsers
wfw_range = document.createRange();
wfw_range.setStartBefore(obj);
wfw_range.setEndAfter(obj);
wfw_range.selectNode(obj);
var sel = window.getSelection();
sel.addRange(wfw_range);
document.execCommand('Copy'); // does nothing on FF
} else {
// IE 8 and earlier. This stuff won't work on IE9.
// (unless forced into a backward compatibility mode,
// or selecting plain divs, not img or table).
wfw_range = document.body.createTextRange();
wfw_range.moveToElementText(obj);
wfw_range.select()
wfw_range.execCommand('Copy');
}
}
function addBlogComment(obj, post_id) {
blogComment.select(obj, post_id);
BlogComment_operation = '0';
}
function blogContactForm(obj, post_id, name) {
blogComment.select(obj, post_id);
document.getElementById('post_title').innerHTML = "Send an Email to "+name;
document.getElementById('message_row').innerHTML = "NOTE: Your Internet session is being recorded
and can be traced back to your Internet account.
SPAM will not be tollerated.";
document.getElementById('name_row').style.display='';
document.getElementById('website_row').style.display='none';
document.getElementById('comment_row').style.display='';
BlogComment_operation = '1';
}
function blogAddToNotifyList(obj, post_id, name) {
blogComment.select(obj, post_id);
document.getElementById('post_title').innerHTML = "Notify me when changes are made to:
"+name;
document.getElementById('message_row').innerHTML = "";
document.getElementById('name_row').style.display='';
document.getElementById('website_row').style.display='none';
document.getElementById('comment_row').style.display='none';
BlogComment_operation = '2';
}
function blogRemoveFromNotifyList(obj, post_id, name) {
blogComment.select(obj, post_id);
document.getElementById('post_title').innerHTML = "Remove me from notify list for:
"+name;
document.getElementById('message_row').innerHTML = "";
document.getElementById('name_row').style.display='none';
document.getElementById('website_row').style.display='none';
document.getElementById('comment_row').style.display='none';
BlogComment_operation = '3';
}
function blogSendNotifyList(post_id, url) {
var operation = '4';
var query = 'subsendnotify=1&post_id='+post_id+'&url='+url+'&stamp='+stamp+'&operation='+operation;
ajaxRequest('/blogrequest.php', query, commentResponse);
}
/*
function blogPublishPing(post_id) {
var operation = '5';
var query = 'subpublishping=1&post_id='+post_id+'&stamp='+stamp+'&operation='+operation;
ajaxRequest('/blogrequest.php', query, pingResponse);
}
*/
function blogPublished(post_id, obj) {
if (obj.checked)
published = '1';
else
published = '0';
var query = 'subblogpostpublished=1&site_id='+site_id+'&page='+page+'&post_id='+post_id+'&published='+published;
ajaxRequest('/process.php', query, nothingResponse);
}
function blogFavorite(post_id, obj) {
if (obj.checked)
favorite = '1';
else
favorite = '0';
var query = 'subblogpostfavorite=1&site_id='+site_id+'&page='+page+'&post_id='+post_id+'&favorite='+favorite;
ajaxRequest('/process.php', query, nothingResponse);
}
function showBlogArchive(obj, target) {
var top, left;
obj.style.display='block';
if (target) {
target.innerHTML = 'Hide Archive';
// measure relative to parent div
top = parseInt(target.offsetTop)+20;
left = parseInt(document.getElementById('wfw_blog_wrapper').offsetWidth)-parseInt(obj.offsetWidth);
obj.style.left=left+'px';
obj.style.top=top+'px';
}
}
function hideBlogArchive(obj, target) {
obj.style.display='none';
if (target)
target.innerHTML = 'View Archive';
}
function toggleBlogArchive() {
var obj = document.getElementById('wfw_archive');
if (obj) {
/*
// move archive into another div so it's position is relative to body
if (obj.parentNode.id != 'BlogArchiveDiv') {
var moveto = document.getElementById('BlogArchiveDiv');
moveto.insertBefore(obj, moveto.firstChild);
moveto.style.visibility='visible';
}
*/
var target = document.getElementById('archive_link');
(obj.style.display=='block') ? hideBlogArchive(obj,target) : showBlogArchive(obj,target);
}
}
// move the blog archive into a block specified by anchor
function moveBlogArchive(anchor) {
var archive = document.getElementById('wfw_archive');
if (archive) {
var moveto = document.getElementById(anchor);
if (moveto) {
moveto.insertBefore(archive, moveto.firstChild);
moveto.style.visibility='visible';
archive.style.display = 'block';
archive.style.position = 'relative';
var link = document.getElementById('archive_link');
link.style.display = 'none';
}
}
}
function blogShowHideUserForm() {
var newuser = document.getElementById('newuser');
if (document.forms.blog_user_form.user_id.value) {
newuser.style.display='none';
}
else {
newuser.style.display='block';
}
}
function blogShowHideAllowComments() {
var allow = document.forms.blog_settings_form.allow_comments.checked;
if (allow && isIE) {
document.getElementById('comment_1').style.display='block';
document.getElementById('comment_2').style.display='block';
document.getElementById('comment_3').style.display='block';
}
else if (allow) {
document.getElementById('comment_1').style.display='table-row';
document.getElementById('comment_2').style.display='table-row';
document.getElementById('comment_3').style.display='table-row';
}
else {
document.getElementById('comment_1').style.display='none';
document.getElementById('comment_2').style.display='none';
document.getElementById('comment_3').style.display='none';
}
}
function blogShowHideNotifyEmail() {
var allow_comments = document.forms.blog_settings_form.allow_comments.checked;
var allow_notify = document.forms.blog_settings_form.allow_notify.checked;
if (allow_comments || allow_notify) {
if (isIE)
document.getElementById('comment_2').style.display='block';
else
document.getElementById('comment_2').style.display='table-row';
}
else {
document.getElementById('comment_2').style.display='none';
}
}
function blogShowHidePagecount() {
var show_back_next = document.forms.blog_settings_form.show_back_next.checked;
if (show_back_next) {
if (isIE)
document.getElementById('pagecount').style.display='block';
else
document.getElementById('pagecount').style.display='table-row';
}
else {
document.getElementById('pagecount').style.display='none';
}
}
function blogShowHideDateFormat() {
var show = document.forms.blog_settings_form.show_date.checked;
if (show) {
document.getElementById('date_format_row').style.display='';
}
else {
document.getElementById('date_format_row').style.display='none';
}
}
function blogCancelForm(returnurl) {
window.location.href=returnurl;
}
var blogUrl;
function blogSubmitUserForm(returnurl) {
blogUrl = returnurl;
var myform = document.forms.blog_user_form;
var blog_id = '';
var post_id = '';
// slates assign users to individual slate posts
if (myform.post_id)
post_id = myform.post_id.value;
// blogs assign users to entire blog
if (myform.blog_id)
blog_id = myform.blog_id.value;
var user_id = myform.user_id.value;
var client_id = myform.client_id.value;
var salutation = myform.salutation.value;
var first = myform.first.value;
var last = myform.last.value;
var email = myform.email.value;
var username = myform.username.value;
var pass1 = myform.password.value;
var pass2 = myform.passwordagain.value;
first = salutation + ' ' + first;
var query = 'subsetbloguser=1&blog_id='+blog_id+'&post_id='+post_id+'&site_id='+site_id+'&page='+page+'&client_id='+client_id+'&user_id='+user_id+'&first='+first+'&last='+last+'&email='+email+'&username='+username+'&pass1='+pass1+'&pass2='+pass2;
ajaxRequest('/process.php', query, blogFormResponse);
}
function blogSubmitSettingsForm(returnurl) {
blogUrl = returnurl;
var myform = document.forms.blog_settings_form;
var blog_id = myform.blog_id.value;
var allow_comments = '0';
var show_comments = '0';
var moderated_comments = '0';
var notify = '0';
var notify_email = '';
var pagecount = '6';
var show_breadcrumb_list = '0';
var show_favorites = '0';
var showall = '0';
var is_directory = '0';
var share_this_key = '';
var share_this_facebook = '0';
var share_this_facebook_like = '0';
var share_this_google = '0';
var share_this_twitter = '0';
var share_this_linkedin = '0';
var share_this_pinterest = '0';
var share_this_reddit = '0';
var share_this_yahoo = '0';
var share_this_email = '0';
var add_to_top = '0';
var directory_type = 'Department';
var content_template = '';
// certain options aren't on both slate and blog form so check for object
if (myform.allow_comments)
allow_comments = myform.allow_comments.checked ? '1' : '0';
if (myform.show_comments)
show_comments = myform.show_comments.checked ? '1' : '0';
if (myform.moderated_comments)
moderated_comments = myform.moderated_comments.checked ? '1' : '0';
if (myform.notify)
notify = myform.notify.checked ? '1' : '0';
if (myform.notify_email)
notify_email = myform.notify_email.value;
if (myform.pagecount)
pagecount = myform.pagecount.value;
if (myform.show_breadcrumb_list)
show_breadcrumb_list = myform.show_breadcrumb_list.checked ? '1' : '0';
if (myform.is_directory)
is_directory = myform.is_directory.checked ? '1' : '0';
if (myform.directory_type)
directory_type = myform.directory_type.value;
if (myform.content_template)
content_template = myform.content_template.value;
if (myform.showall)
showall = myform.showall.checked ? '1' : '0';
if (myform.show_favorites)
show_favorites = myform.show_favorites.checked ? '1' : '0';
if (myform.add_to_top)
add_to_top = myform.add_to_top.checked ? '1' : '0';
var show_author = myform.show_author.checked ? '1' : '0';
var show_category = myform.show_category.checked ? '1' : '0';
var show_category_list = myform.show_category_list.checked ? '1' : '0';
var show_keywords = myform.show_keywords.checked ? '1' : '0';
var show_keywords_list = myform.show_keywords_list.checked ? '1' : '0';
var show_summary = myform.show_summary.checked ? '1' : '0';
var show_date = myform.show_date.checked ? '1' : '0';
var show_back_next = myform.show_back_next.checked ? '1' : '0';
var protect_files = myform.protect_files.checked ? '1' : '0';
var date_format = myform.date_format.value;
var time_zone = myform.time_zone.value;
//var ping_application_key = myform.ping_application_key.value;
//var ping_custom_url_key = myform.ping_custom_url_key.value;
if (myform.share_this_key)
share_this_key = myform.share_this_key.value;
if (myform.share_this_facebook)
share_this_facebook = myform.share_this_facebook.checked ? '1' : '0';
if (myform.share_this_facebook_like)
share_this_facebook_like = myform.share_this_facebook_like.checked ? '1' : '0';
if (myform.share_this_google)
share_this_google = myform.share_this_google.checked ? '1' : '0';
if (myform.share_this_twitter)
share_this_twitter = myform.share_this_twitter.checked ? '1' : '0';
if (myform.share_this_linkedin)
share_this_linkedin = myform.share_this_linkedin.checked ? '1' : '0';
if (myform.share_this_pinterest)
share_this_pinterest = myform.share_this_pinterest.checked ? '1' : '0';
if (myform.share_this_reddit)
share_this_reddit = myform.share_this_reddit.checked ? '1' : '0';
if (myform.share_this_yahoo)
share_this_yahoo = myform.share_this_yahoo.checked ? '1' : '0';
if (myform.share_this_email)
share_this_email = myform.share_this_email.checked ? '1' : '0';
if (myform.layout[1].checked)
layout = '1';
else if (myform.layout[2].checked)
layout = '2';
else
layout = '0';
var query = 'subsetblogsettings=1&blog_id='+blog_id+'&site_id='+site_id+'&page='+page+'&allow_comments='+allow_comments+'&show_comments='+show_comments+'¬ify='+notify+'¬ify_email='+notify_email+'&show_author='+show_author+'&show_category='+show_category+'&show_category_list='+show_category_list+'&show_keywords='+show_keywords+'&show_keywords_list='+show_keywords_list+'&show_summary='+show_summary+'&show_date='+show_date+'&date_format='+date_format+'&time_zone='+time_zone+'&layout='+layout+'&pagecount='+pagecount+'&show_breadcrumb_list='+show_breadcrumb_list+'&is_directory='+is_directory+'&directory_type='+directory_type+'&showall='+showall+'&show_back_next='+show_back_next+'&content_template='+content_template+'&moderated_comments='+moderated_comments+'&share_this_key='+share_this_key+'&share_this_facebook='+share_this_facebook+'&share_this_google='+share_this_google+'&share_this_twitter='+share_this_twitter+'&share_this_linkedin='+share_this_linkedin+'&share_this_yahoo='+share_this_yahoo+'&share_this_email='+share_this_email+'&share_this_facebook_like='+share_this_facebook_like+'&share_this_pinterest='+share_this_pinterest+'&share_this_reddit='+share_this_reddit+'&protect_files='+protect_files+'&show_favorites='+show_favorites+'&add_to_top='+add_to_top;
ajaxRequest('/process.php', query, blogFormResponse);
}
function blogFormResponse() {
if (xmlhttp.readyState==4) {
if (xmlhttp.responseText != 'OK') {
var errobj = document.getElementById('blog_errors');
if (errobj) errobj.innerHTML = xmlhttp.responseText;
else alert(xmlhttp.responseText);
}
else
window.location.href=blogUrl;
}
}
// everything below here is for the popup blog comment form
BlogComment_thisWindow = null;
BlogComment_thisObject = null;
BlogComment_post_id = null;
BlogComment_operation = '0'; // 0=blog post 1=contact form 2=notify list 3=remove notify list
function BlogComment_show(anchorname) {
this.showPopup(anchorname);
}
function BlogComment_doSubmit(url) {
var post_id = window.BlogComment_post_id;
var name = document.forms.blogform.elements['bcname'].value;
var email = document.forms.blogform.elements['bcemail'].value;
var website = document.forms.blogform.elements['bcwebsite'].value;
var comment = encodeURIComponent(document.forms.blogform.elements['bccomment'].value);
var errs = '';
var errcnt = 0;
var operation=BlogComment_operation;
if (operation == '0' || operation == '1' || operation == '2') {
// validate name
var validRegExp = /^[a-z -_]+$/i;
if (name.search(validRegExp) == -1) {
errcnt++;
errs += errcnt+') Please enter a valid name\n';
}
}
// validate email
validRegExp = /^([_+a-z0-9-]+\.)*[_+a-z0-9-]+@([_+a-z0-9-]+\.)*([_+a-z0-9-]+\.)*[a-z0-9-]+\.[a-z]{2,}$/i;
if (email.search(validRegExp) == -1) {
errcnt++;
errs += errcnt+') Please enter a valid email address\n';
}
validRegExp = /^((http|https)(:\/\/))?([a-z0-9-]+\.)*[a-z0-9-]+\.[a-z]{2,}$/i;
if (website.length > 0 && website.search(validRegExp) == -1) {
errcnt++;
errs += errcnt+') Enter a valid website address or none at all\n';
}
if (operation == '0' || operation == '1') {
// validate comment
if (comment.length === 0) {
errcnt++;
errs += errcnt+') Please enter a comment\n';
}
else {
// no html allowed
var validRegExp = /<[^>]*>/;
// validate comment
if (comment.search(validRegExp) != -1) {
errcnt++;
errs += errcnt+') Sorry, no HTML is allowed in comment\n';
}
}
}
if (errcnt) {
alert('THERE WERE SOME ERRORS IN THE FORM\n'+errs);
return false;
}
var query = 'post_id='+post_id+'&name='+name+'&email='+email+'&website='+website+'&stamp='+stamp+'&operation='+operation+'&comment='+comment+'&url='+url;
ajaxRequest('/blogrequest.php', query, commentResponse);
window.BlogComment_thisWindow.hidePopup();
alert("Thanks for your comment!\n\nYour comment may not appear\nuntil it is approved by the moderator.\n");
return false;
}
function commentResponse() {
if (xmlhttp.readyState==4) {
if (xmlhttp.responseText != 'OK')
alert(xmlhttp.responseText);
else
window.location.reload( false );
}
}
/*
function pingResponse() {
if (xmlhttp.readyState==4) {
if (xmlhttp.responseText != 'OK')
alert(xmlhttp.responseText);
else
alert('Published to ping.fm');
}
}
*/
function nothingResponse() {
}
function BlogComment_doCancel() {
window.BlogComment_thisWindow.hidePopup();
return false;
}
function BlogComment_select(anchorname,post_id) {
window.BlogComment_post_id = post_id;
this.show(anchorname);
// clear the form
document.forms.blogform.elements['bcname'].value='';
document.forms.blogform.elements['bcemail'].value='';
document.forms.blogform.elements['bcwebsite'].value='';
document.forms.blogform.elements['bccomment'].value='';
}
function BlogComment() {
var windowMode = false;
var divname, cp;
var loc = window.location.href;
// Create a new PopupWindow object
if (arguments.length===0) {
divname = "BlogCommentDiv";
}
else if (arguments[0] == "window") {
divname = '';
windowMode = true;
}
else {
divname = arguments[0];
}
if (divname !== "") {
cp = new PopupWindow(divname);
}
else {
cp = new PopupWindow();
cp.setSize(500,200);
}
// Object variables
cp.currentValue = "";
// Method Mappings
cp.show = BlogComment_show;
cp.select = BlogComment_select;
// this is our html for window
var cp_contents = "";
var windowRef = (windowMode)?"window.opener.":"";
window.BlogComment_thisWindow = cp;
window.BlogComment_thisObject = cp;
if (windowMode) {
cp_contents += '