function previewLit() { var litBody = $("#litBody").val(); $.ajax( { url: 'http://questional.com/literature.php', data: { fn: 'preview', 'body' : litBody }, type: 'POST', timeout: 20000, error: function() { alert("Could not complete that action. Please check your internet connection and try again.") }, success: function(data) { var myObject = eval('(' + data + ')'); if(myObject.success == '2'){ var error = myObject.error; alert(error); } else { var previewText = myObject.previewText; $("#litPreviewTarget").html(previewText); $("#litPreviewCont").show(); window.location = '#litPreview'; } } }); } function hidePreviewLit() { $("#litPreviewTarget").html(''); $("#litPreviewCont").hide(); } /*HEADER GROUPPED CAT FUNCTIONS*/ function showCatGroup(groupID) { i= "catgrouptimer_"; clearTimeout(window[i + groupID]); $(".catgroupholder").hide(); //hide all of the holders so they dont overlap the one we are opening $("#catGroup_" + groupID).show(); var offset = $("#grouptitle_" + groupID).offset(); var width = $("#grouptitle_" + groupID).width(); $("#catGroup_" + groupID).css('left',offset.left); $("#catGroup_" + groupID).css('min-width',width); } function hideCatGroup(groupID) { i= "catgrouptimer_"; window[i + groupID] = setTimeout("finalHideCatGroup('" + groupID + "')",250); } function finalHideCatGroup(groupID) { $("#catGroup_" + groupID).hide(); } function askCelebQuestion() { var name = $("#name").val(); var location = $("#location").val(); var email = $("#email").val(); var question = $("#sessionQuestionBox").val(); var celebID = $("#celebID").val(); if(question == 'Type your question here...') { systemOverlay(escape('Please enter a question before clicking submit.'),'0','questionForm_insert'); return false; } $.ajax( { url: 'http://questional.com/sessions.php', data: { fn: 'saveNewQuestion', name: name, location: location, email: email, question: question, celebID: celebID }, type: 'POST', timeout: 5000, error: function(){ askCelebQuestion()}, success: function(data){ var myObject = eval('(' + data + ')'); var success= myObject.success; if(success == 2) { var error = myObject.error; systemOverlay(escape(error),'0','questionForm_insert'); } else { $("#questionForm").hide(); $("#questionForm").html('Your question has been successfully received, thank you!').fadeIn('slow'); } } }); } /*FUNCTION TO COUNT AND LIMIT CHARACTERS*/ /** opt_countedTextBox: id of the object having its characters counted opt_countBody: id of the object listing how many characters have been counted opt_maxSize: how many characters to limit **/ function counterUpdate(opt_countedTextBox, opt_countBody, opt_maxSize) { var countedTextBox = opt_countedTextBox ? opt_countedTextBox : "counttxt"; var countBody = opt_countBody ? opt_countBody : "countBody"; var maxSize = opt_maxSize ? opt_maxSize : 1024; var field = document.getElementById(countedTextBox); if (field && field.value.length >= maxSize) { field.value = field.value.substring(0, maxSize); } var txtField = document.getElementById(countBody); if (txtField) { txtField.innerHTML = field.value.length; } } function toggleFavForum(forumID,status) { $.ajax( { url: 'http://questional.com/forum.php', data: 'fn=toggleFavForum&forumID=' + forumID + '&status=' + status, type: 'POST', timeout: 20000, error: function(){ toggleFavForum(forumID,status)}, success: function(data){ var myObject = eval('(' + data + ')'); var success= myObject.success; if(success == 2) { var error = myObject.error; systemOverlay(escape(error),'0','forumsub_insert'); } else { var status = myObject.status; if(status == 'OFF') { $("#subscribeForum").show(); $("#unsubscribeForum").hide(); } else if(status == 'ON') { $("#subscribeForum").hide(); $("#unsubscribeForum").show(); } } } }); } function deleteImageOverlay(type,imageID,connID) { if(type == '1') { $("#quest_imginsert").load("http://questional.com/image.php?fn=deleteOverlay&type=" + type + "&imageID=" + imageID); window.location = '#quest_imginsert'; } else if(type == '2') { $("#lit_imginsert" + connID).load("http://questional.com/image.php?fn=deleteOverlay&type=" + type + "&imageID=" + imageID); window.location = '#lit_imginsert' + connID; } else if(type == '3') { $("#sessioninsert_" + connID).load("http://questional.com/image.php?fn=deleteOverlay&type=" + type + "&imageID=" + imageID); window.location = '#sessioninsert_' + connID; } } function cancelDeleteImage(type,connID) { if(type == '1') { $("#quest_imginsert").html(''); } else if(type == '2') { $("#lit_imginsert" + connID).html(''); } else if(type == '3') { $("#sessioninsert_" + connID).html(''); } } function addImageOverlay(type,connID) { if(type == '1') { var hook = 'question_insert'; } else if(type == '2') { var hook = 'litinsert_' + connID; } else if(type == '3') { var hook = 'sessioninsert_' + connID; } $("#" + hook).load("http://questional.com/image.php?fn=addOverlay&type=" + type + "&connID=" + connID); } function cancelDeletePost(postID) { $("#postinsert" + postID).html(''); } function deletePost(postID) { $("#postinsert" + postID).load("http://questional.com/forum.php?fn=deletePost&postID=" + postID); } function saveEditPost(postID) { var body = $("#editpostbody" + postID).val(); var title = $("#editposttitle" + postID).val(); $.ajax( { url: 'http://questional.com/forum.php', /*data: 'fn=saveEditPost&postID=' + postID + '&body=' + escape(body) + '&title=' + escape(title),*/ data: { fn: 'saveEditPost', postID : postID, body: body, title: title }, type: 'POST', timeout: 20000, error: function(){ alert("Could not complete that action. Please check your internet connection and try again.") }, success: function(data){ var myObject = eval('(' + data + ')'); var success= myObject.success; if(success == 2) { var error = myObject.error; systemOverlay(escape(error),'0','postinsert' + postID); } else { var newBody = myObject.newBody; $("#postbody_" + postID).html(newBody); var newTitle = myObject.newTitle; if(newTitle != '') { $(".currThreadName").html(newTitle); } } } }); } function cancelPostEdit(postID) { var oldbody = $("#oldpostbody" + postID).html(); $("#postbody_" + postID).html(oldbody); } function editPost(postID) { $.ajax( { url: 'http://questional.com/forum.php', data: 'fn=editPost&postID=' + postID, type: 'POST', timeout: 20000, error: function(){ alert("Could not complete that action. Please check your internet connection and try again.") }, success: function(data){ var myObject = eval('(' + data + ')'); var success= myObject.success; if(success == 2) { var error = myObject.error; systemOverlay(escape(error),'0','postinsert' + postID); } else { var formTemp = myObject.formTemp; $("#postbody_" + postID).html(formTemp); } } }); } function newPostReplyOverlay(threadID){ $("#newreply_insert").load("http://questional.com/forum.php?fn=newReplyOverlay&threadID=" + threadID); window.location = "#newreplyarea"; } function newThreadOverlay(forumID){ $("#newthread_insert").load("http://questional.com/forum.php?fn=newThreadOverlay&forumID=" + forumID); window.location = "#newthreadarea"; } function saveNewThreadReply() { var threadID = $("#threadID").val(); var postBody = $("#postbody").val(); $.ajax( { url: 'http://questional.com/forum.php', data: 'fn=saveNewReply&threadID=' + threadID + '&postBody=' + escape(postBody), type: 'POST', timeout: 20000, error: function() { alert("Could not complete that action. Please check your internet connection and try again.") }, success: function(data) { var myObject = eval('(' + data + ')'); if(myObject.success == '2'){ var error = myObject.error; alert(error); } else { window.location = myObject.threadURL; } } }); } function saveNewThread() { var forumID = $("#forumID").val(); var threadTitle = $("#threadtitle").val(); var threadBody = $("#threadbody").val(); $.ajax( { url: 'http://questional.com/forum.php', data: 'fn=saveNewThread&forumID=' + forumID + '&title=' + escape(threadTitle) + '&body=' + escape(threadBody), type: 'POST', timeout: 20000, error: function() { alert("Could not complete that action. Please check your internet connection and try again.") }, success: function(data) { var myObject = eval('(' + data + ')'); if(myObject.success == '2'){ var error = myObject.error; alert(error); } else { window.location = myObject.threadURL; } } }); } /*ALIGNS THE ID OF WHATEVER ENTITY TO MIDDLE OF Y AXIS OF BROWSER SCREEN.*/ function yMiddleEntity(entityID) { var browserheight = $(window).height(); var boxheight = $("#" + entityID).height(); var top = (browserheight - boxheight) / 2; $("#" + entityID).css('top',top + 'px'); } function showElement(elementID) { $("#" + elementID).show(); } function loadBottomFriends() { $("#bottombar_rightblock").load("http://questional.com/bottombar.php?fn=buddies"); } function clearBottomBlock(side) { if(side == 'left') { $("#bottombar_leftblock").html(''); } else if(side == 'right') { $("#bottombar_rightblock").html(''); } } function loadNotifs() { $("#bottombar_rightblock").load("http://questional.com/bottombar.php?fn=grabNotifs"); $("#newnotif_count").html('').hide(); } function closeNotifs() { $.get("http://questional.com/bottombar.php?fn=closeNotifs"); clearBottomBlock('right'); } function deleteQuestionOverlay(questID) { $("#question_insert").load("http://questional.com/question.php?fn=deleteQuestionOverlay" + "&questID=" + questID).hide().fadeIn('slow'); } /*USED WHEN SAVING ABOUT, INTERESTS FROM AN OVERLAY*/ function saveEditQuestion(questID) { var title = $("textarea#title").val(); var body = $("textarea#body").val(); var type = $('input[name=questType]:checked').val(); $.ajax( { url: 'http://questional.com/question.php', data: 'fn=saveEditQuestion&questID=' + questID + '&title=' + escape(title) + '&body=' + escape(body) + '&type=' + escape(type), type: 'POST', timeout: 20000, error: function() { alert("Could not complete that action. Please check your internet connection and try again.") }, success: function(data) { var myObject = eval('(' + data + ')'); if(myObject.success == '2'){ var error = myObject.error; alert(error); } else { if(myObject.type == 'F') { $("#quest_type").html('Fact'); } else if(myObject.type == 'O') { $("#quest_type").html('Opinion'); } $("#quest_title").html(myObject.title); $("#quest_body").html(myObject.body); emptyoverlay('question_insert'); } } }); } function editQuestionOverlay(questID) { $("#question_insert").load("http://questional.com/question.php?fn=editQuestionOverlay" + "&questID=" + questID).hide().fadeIn('slow'); } function editQuestionTags(questID) { $("#question_insert").load("http://questional.com/question.php?fn=editTagsOverlay" + "&questID=" + questID).hide().fadeIn('slow'); } function saveQuestionTags(questID) { var tags = $("textarea#quest_tags").val(); $.ajax( { url: 'http://questional.com/question.php', data: 'fn=saveEditTags&questID=' + questID + '&tags=' + escape(tags), type: 'POST', timeout: 20000, error: function() { alert("Could not complete that action. Please check your internet connection and try again.") }, success: function(data) { var myObject = eval('(' + data + ')'); if(myObject.success == '2'){ var error = myObject.error; alert(error); } else { var tagBlock = myObject.tagBlock; $("#tags_insert").html(tagBlock); emptyoverlay('question_insert'); } } }); } function showQuestComments(uniqueID) { /*SHOW TEXT AREA AND COMMENT TABLE*/ $("#questionComments").show(); $("textarea." + uniqueID).show(); $("textarea." + uniqueID).focus(); if($("textarea." + uniqueID).val() != 'Add A New Comment...') { $("input." + uniqueID).show(); } /*TOGGLE LINKS*/ $("#hideCommentsLink").toggle(); $("#showCommentsLink").toggle(); } function hideQuestComments(uniqueID) { /*HIDE THE COMMENT TABLE*/ $("#questionComments").hide(); /*HIDE THE TEXT AREA AND SUBMIT*/ $("#questionComments").hide(); $("textarea." + uniqueID).hide(); $("input." + uniqueID).hide(); /*TOGGLE THE SHOW HIDE LINKS*/ $("#hideCommentsLink").toggle(); $("#showCommentsLink").toggle(); } function replyPM(keyID) { var body = $("textarea.addreply").val(); $.ajax( { url: 'http://questional.com/pm.php', data: 'fn=saveReply&keyID=' + keyID + '&body=' + escape(body), type: 'POST', timeout: 20000, error: function(){ alert("Could not complete that action. Please check your internet connection and try again.") }, success: function(data){ $("table.replies").append(data); /*$("textarea.addreply").css("height",16);*/ $("textarea.addreply").val('Reply...'); /*$("input.replyPM").hide();*/ } }); } function deleteInThreadPM(threadID) { $("#pmthread_insert").load("http://questional.com/pm.php?fn=deleteThread" + "&threadID=" + threadID).hide().fadeIn('slow'); } function cancelDeleteInThreadPM() { $("#pmthread_insert").html(''); } function deleteMailboxThreads() { $("#foo").submit(); } function cancelCommentReply(replyID) { $("#replycommentinsert_" + replyID).html(''); } function commentReply(replyID) { $("#replycommentinsert_" + replyID).load("http://questional.com/reply.php?fn=comment" + "&replyID=" + replyID).hide().fadeIn('slow'); } function deleteReply(replyID) { $("#replyinsert_" + replyID).load("http://questional.com/reply.php?fn=delete" + "&replyID=" + replyID).hide().fadeIn('slow'); } function saveDeleteReply(replyID) { $.ajax( { url: 'http://questional.com/reply.php', data: 'fn=saveDelete&replyID=' + replyID, type: 'POST', timeout: 20000, error: function(){ alert("Could not complete that action. Please check your internet connection and try again.") }, success: function(data){ var myObject = eval('(' + data + ')'); var success= myObject.success; if(success == 2) { var error = myObject.error; systemOverlay(escape(error),'0','replyinsert_' + replyID); } else { $("#replyblock" + replyID).remove(); } } }); } function cancelDeleteReply(replyID) { $("#replyinsert_" + replyID).html(''); } function editReply(replyID) { $.ajax( { url: 'http://questional.com/reply.php', data: 'fn=edit&replyID=' + replyID, type: 'GET', timeout: 20000, error: function(){ alert("Could not complete that action. Please check your internet connection and try again.") }, success: function(data){ var myObject = eval('(' + data + ')'); var success= myObject.success; if(success == 2) { var error = myObject.error; systemOverlay(escape(error),'0','replyinsert_' + replyID); } else { var formTemp = myObject.formTemp; $("#replybody" + replyID).html(formTemp); } } }); } function saveEditReply(replyID) { var body = $("#editreplybody" + replyID).val(); $.ajax( { url: 'http://questional.com/reply.php', data: { fn: 'saveEdit', replyID : replyID, body: body }, /*data: 'fn=saveEdit&replyID=' + replyID + '&body=' + escape(body),*/ type: 'POST', timeout: 20000, error: function(){ alert("Could not complete that action. Please check your internet connection and try again.") }, success: function(data){ var myObject = eval('(' + data + ')'); var success= myObject.success; if(success == 2) { var error = myObject.error; systemOverlay(escape(error),'0','replyinsert_' + replyID); } else { var newBody = myObject.newBody; $("#replybody" + replyID).html(newBody); } } }); } function cancelEditReply(replyID) { var oldbody = $("#oldreplybody" + replyID).html(); $("#replybody" + replyID).html(oldbody); } function addLiterature() { $("#litcp_insert").load("http://questional.com/literature.php?fn=newOverlay").hide().fadeIn('slow'); } function publishLiterature(litID) { $("#litinsert_" + litID).load("http://questional.com/literature.php?fn=publishOverlay&litID=" + litID).hide().fadeIn('slow'); } function unpublishLiterature(litID) { $("#litinsert_" + litID).load("http://questional.com/literature.php?fn=unpublishOverlay&litID=" + litID).hide().fadeIn('slow'); } function deleteLiterature(litID) { $("#litinsert_" + litID).load("http://questional.com/literature.php?fn=deleteOverlay&litID=" + litID).hide().fadeIn('slow'); } function litMiniPicOverlay(litID) { $("#litinsert_" + litID).load("http://questional.com/literature.php?fn=miniPicOverlay&litID=" + litID).hide().fadeIn('slow'); } /*RATES A QUESTION*/ function rateQuestion(questionID) { $.ajax( { url: 'http://questional.com/question.php', data: 'fn=rate&questionID=' + questionID, type: 'POST', timeout: 20000, error: function(){ alert("Could not complete that action. Please check your internet connection and try again.") }, success: function(data){ var myObject = eval('(' + data + ')'); var success= myObject.success; if(success == 1) { $("#q_rating_" + questionID).html(myObject.rating); $("#q_ratestatus_" + questionID).html('RATED'); } else { alert(myObject.error); } } }); } /*SHOWS THE CHANGE AVATAR OVERLAY*/ function changeavatar(userID) { $("#editavatar_insert").load("http://questional.com/member.php?fn=changeAvatarOverlay" + "&userID=" + userID).hide().fadeIn('slow'); } /*SHOWS THE EDIT PROFILE OVERLAY*/ function editmemberprofile(userID) { $("#editprofile_insert").load("http://questional.com/member.php?fn=editProfileOverlay" + "&userID=" + userID).hide().fadeIn('slow'); } /*USED WHEN SAVING ABOUT, INTERESTS FROM AN OVERLAY*/ function savememberprofile(userID) { var about = $("textarea#about").val(); var interests = $("textarea#interests").val(); var formdata = $("#editprofile").serialize(); $.ajax( { url: 'http://questional.com/member.php', data: 'fn=saveEditProfile&userID=' + userID + '&' + formdata, type: 'POST', timeout: 20000, error: function() { alert("Could not complete that action. Please check your internet connection and try again.") }, success: function(data) { if(data == 2) { alert('We encountered an error and could not save your profile.'); } else { var myObject = eval('(' + data + ')'); $("#aboutme").html(myObject.about); $("#interestsme").html(myObject.interests); emptyoverlay('editprofile_insert'); } } }); } /*IMMEDIATELY ADDS/REMOVES BUDDY STATUS*/ /*USED ON MEMBER PROFILE PAGE*/ function alterProfileBuddy(friendID,status) { $.ajax( { url: 'http://questional.com/member.php', data: 'fn=alterProfileBuddy&status=' + status + '&friendID=' + friendID, type: 'POST', timeout: 20000, error: function(){ alert("Could not complete that action. Please check your internet connection and try again.") }, success: function(data){ if(data == 'added') { $("#removeProfileBuddy").show(); $("#addProfileBuddy").hide(); systemOverlay('Buddy+added+to+your+friends+list!','2000','profileBuddy_insert'); } else if(data == 'removed') { $("#removeProfileBuddy").hide(); $("#addProfileBuddy").show(); systemOverlay('Buddy+removed+from+your+friends+list!','2000','profileBuddy_insert'); } else { systemOverlay(escape(data),'0','profileBuddy_insert'); } } }); } /*SYSTEM MESSAGE VIA LAYER*/ function systemOverlay(message,time,layerName) { if(time != '0') { setTimeout(function(){ $('#' + layerName).html(''); }, time); } $("#" + layerName).load("http://questional.com/page.php?view=systemLayer&message=" + message).hide().fadeIn('slow'); } /*DESTROYS THE OVERLAY INFO*/ function emptyoverlay(id) { /*$("#" + id).remove();*/ $("#" + id).html(''); } /*ADDS A REPLY. ANSWERS, SHOUTS, SESSION COMMENTS, ARTICLE/BLOG COMMENTS*/ function addReply(type,connID,uniqueID) { if(type < 6) { var body = $("textarea." + uniqueID).val(); } else { var body = $("#bodycomment_" + connID).val(); } $.ajax( { url: 'http://questional.com/reply.php', data: { fn: 'add', connID: connID, body: body, type: type }, /*data: 'fn=add&connID=' + connID + '&body=' + escape(body) + '&type=' + type,*/ type: 'POST', timeout: 20000, error: function(){ alert("Could not complete that action. Please check your internet connection and try again.") }, success: function(data){ var myObject = eval('(' + data + ')'); var success= myObject.success; if(success != 1) { alert(myObject.error); return false; } var block = myObject.blockContents; //this contains what we need to append if(type < 6) { /*APPEND THE DATA TO THE CORRECT REPLY TABLE*/ if(type == 1) { $("#questionAnswers").append(block); } else if(type == 5) { /*IF ADDING A COMMENT WHEN THE COMENTS ARE HIDDEN, SHOW THEM ALL*/ var displayStatus = $("#questionComments").css("display"); if(displayStatus == 'none') { showQuestComments(uniqueID); } $("#questionComments").append(block); } else { $("table.replies").append(block); } /*$("textarea." + uniqueID).css("height",16);*/ //shorten the height of text area /*$("input." + uniqueID).hide(); //hide submit button*/ $("textarea." + uniqueID).css("font-weight","bold"); /*FOR EACH TEXT AREA, MAKE THE VALUE ITS INITIAL VALUE*/ if($("textarea." + uniqueID).hasClass('addAnswer')){ $("textarea." + uniqueID).val('Add Answer...'); $(".noAnswerMsg").hide(); } else if($("textarea." + uniqueID).hasClass('homePreQuestion')){ $("textarea." + uniqueID).val('Type a new question here...'); } else if($("textarea." + uniqueID).hasClass('addShout')){ $("textarea." + uniqueID).val('Add A New Shout...'); } else if($("textarea." + uniqueID).hasClass('addComment')){ $("textarea." + uniqueID).val('Add A New Comment...'); $(".noCommentsMsg").hide(); } else if($("textarea." + uniqueID).hasClass('replyPM')){ $("textarea." + uniqueID).val('Reply...'); } /*NOT < 5 REPLY, WE'RE APPENDING TO UNIQUE DATA*/ } else { $("#replycomments_" + connID).append(block); $("#replycommentinsert_" + connID).html(''); } } }); } /*TO MAKE BLUR AND FOCUS WORK, MAKE SURE THE TEXT AREA HAS CLASS "addreply", and whatever type it is. Such as "addAnswer" if the default text is "Add Answer..."*/ $(document).ready(function() { /*WHEN YOU APPLY THIS TO A TEXTAREA OR INPUT BOX, IT WILL SELECT ALL THE TEXT*/ $(".selectMyText").focus( function() { // only select if the text has not changed if(this.value == this.defaultValue) { this.select(); } }) $("#sessionQuestionBox").focus(function () { if($(this).val() == 'Type your question here...') { $(this).val(''); } }); $("#sessionQuestionBox").blur(function () { if($(this).val() == '') { $(this).val('Type your question here...'); } }); $("textarea.addreply").focus(function () { var textval = $(this).val(); if(textval == 'Add Answer...' || textval == 'Type a new question here...' || textval == 'Add A New Shout...' || textval == 'Add A New Comment...' || textval == 'Reply...') { /*$(this).css("height",200);*/ $(this).val(''); $(this).css("font-weight","normal"); if($(this).hasClass('addAnswer')){ /*$("input.addAnswer").show();*/ } else if($(this).hasClass('homePreQuestion')){ $("input.addQuestion").show(); $(this).css("height",75); } else if($(this).hasClass('addShout')){ /*$("input.addShout").show();*/ } else if($(this).hasClass('addComment')){ /*$("input.addComment").show();*/ } else if($(this).hasClass('replyPM')){ /*$("input.replyPM").show();*/ } } }); $("textarea.addreply").blur(function () { if($(this).val() == '') { /*$(this).css("height",75);*/ $(this).css("font-weight","bold"); if($(this).hasClass('addAnswer')){ $(this).val('Add Answer...'); /*$("input.addAnswer").hide();*/ } else if($(this).hasClass('homePreQuestion')){ $(this).val('Type a new question here...'); $(this).css("height",16); $("input.addQuestion").hide(); } else if($(this).hasClass('addShout')){ $(this).val('Add A New Shout...'); /*$("input.addShout").hide();*/ } else if($(this).hasClass('addComment')){ $(this).val('Add A New Comment...'); /*$("input.addComment").hide();*/ } else if($(this).hasClass('replyPM')){ $(this).val('Reply...'); /*$("input.replyPM").hide();*/ } } }); });