// remote scripting library // (c) copyright 2005 modernmethod, inc var sajax_debug_mode = false; var sajax_request_type = "POST"; var sajax_target_id = ""; var sajax_failure_redirect = ""; function sajax_debug(text) { if (sajax_debug_mode) alert(text); } function sajax_init_object() { sajax_debug("sajax_init_object() called..") var A; var msxmlhttp = new Array( 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'); for (var i = 0; i < msxmlhttp.length; i++) { try { A = new ActiveXObject(msxmlhttp[i]); } catch (e) { A = null; } } if(!A && typeof XMLHttpRequest != "undefined") A = new XMLHttpRequest(); if (!A) sajax_debug("Could not create connection object."); return A; } var sajax_requests = new Array(); function sajax_cancel() { for (var i = 0; i < sajax_requests.length; i++) sajax_requests[i].abort(); } function sajax_do_call(func_name, args) { var i, x, n; var uri; var post_data; var target_id; sajax_debug("in sajax_do_call().." + sajax_request_type + "/" + sajax_target_id); target_id = sajax_target_id; if (typeof(sajax_request_type) == "undefined" || sajax_request_type == "") sajax_request_type = "GET"; uri = "/js/meatwave.js.php"; if (sajax_request_type == "GET") { if (uri.indexOf("?") == -1) uri += "?rs=" + escape(func_name); else uri += "&rs=" + escape(func_name); uri += "&rst=" + escape(sajax_target_id); uri += "&rsrnd=" + new Date().getTime(); for (i = 0; i < args.length-1; i++) uri += "&rsargs[]=" + escape(args[i]); post_data = null; } else if (sajax_request_type == "POST") { post_data = "rs=" + escape(func_name); post_data += "&rst=" + escape(sajax_target_id); post_data += "&rsrnd=" + new Date().getTime(); for (i = 0; i < args.length-1; i++) post_data = post_data + "&rsargs[]=" + escape(args[i]); } else { alert("Illegal request type: " + sajax_request_type); } x = sajax_init_object(); if (x == null) { if (sajax_failure_redirect != "") { location.href = sajax_failure_redirect; return false; } else { sajax_debug("NULL sajax object for user agent:\n" + navigator.userAgent); return false; } } else { x.open(sajax_request_type, uri, true); // window.open(uri); sajax_requests[sajax_requests.length] = x; if (sajax_request_type == "POST") { x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1"); x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); } x.onreadystatechange = function() { if (x.readyState != 4) return; sajax_debug("received " + x.responseText); var status; var data; var txt = x.responseText.replace(/^\s*|\s*$/g,""); status = txt.charAt(0); data = txt.substring(2); if (status == "") { // let's just assume this is a pre-response bailout and let it slide for now } else if (status == "-") alert("Error: " + data); else { if (target_id != "") document.getElementById(target_id).innerHTML = eval(data); else { try { var callback; var extra_data = false; if (typeof args[args.length-1] == "object") { callback = args[args.length-1].callback; extra_data = args[args.length-1].extra_data; } else { callback = args[args.length-1]; } callback(eval(data), extra_data); } catch (e) { sajax_debug("Caught error " + e + ": Could not eval " + data ); } } } } } sajax_debug(func_name + " uri = " + uri + "/post = " + post_data); x.send(post_data); sajax_debug(func_name + " waiting.."); delete x; return true; } // wrapper for getComments function x_getComments() { sajax_do_call("getComments", x_getComments.arguments); } // wrapper for postComment function x_postComment() { sajax_do_call("postComment", x_postComment.arguments); } // wrapper for makeCalendar function x_makeCalendar() { sajax_do_call("makeCalendar", x_makeCalendar.arguments); } // wrapper for submitReply function x_submitReply() { sajax_do_call("submitReply", x_submitReply.arguments); } // wrapper for createMeatlist function x_createMeatlist() { sajax_do_call("createMeatlist", x_createMeatlist.arguments); } // wrapper for submitNote function x_submitNote() { sajax_do_call("submitNote", x_submitNote.arguments); } // wrapper for getReplies function x_getReplies() { sajax_do_call("getReplies", x_getReplies.arguments); } // wrapper for logOut function x_logOut() { sajax_do_call("logOut", x_logOut.arguments); } // wrapper for createLoginForm function x_createLoginForm() { sajax_do_call("createLoginForm", x_createLoginForm.arguments); } // wrapper for createLogin function x_createLogin() { sajax_do_call("createLogin", x_createLogin.arguments); } // wrapper for doPasswordLogin function x_doPasswordLogin() { sajax_do_call("doPasswordLogin", x_doPasswordLogin.arguments); } // wrapper for inviteFriendsForm function x_inviteFriendsForm() { sajax_do_call("inviteFriendsForm", x_inviteFriendsForm.arguments); } // wrapper for addUser function x_addUser() { sajax_do_call("addUser", x_addUser.arguments); } // wrapper for changeEmailForm function x_changeEmailForm() { sajax_do_call("changeEmailForm", x_changeEmailForm.arguments); } // wrapper for changeEmail function x_changeEmail() { sajax_do_call("changeEmail", x_changeEmail.arguments); } // wrapper for changePasswordForm function x_changePasswordForm() { sajax_do_call("changePasswordForm", x_changePasswordForm.arguments); } // wrapper for changePassword function x_changePassword() { sajax_do_call("changePassword", x_changePassword.arguments); } // wrapper for createForgotPasswordForm function x_createForgotPasswordForm() { sajax_do_call("createForgotPasswordForm", x_createForgotPasswordForm.arguments); } // wrapper for lookUpPassword function x_lookUpPassword() { sajax_do_call("lookUpPassword", x_lookUpPassword.arguments); } // wrapper for unsubscribeUser function x_unsubscribeUser() { sajax_do_call("unsubscribeUser", x_unsubscribeUser.arguments); } $(function() { //var lightbox = $("#lightbox"); function displayLoading(obj) { $(obj).html("\"loading\""); } function updateContent(content) { $("#content").html(content); } $('a[rel*=external]').click( function() { window.open(this.href); return false; }); ///////////////////////////////////////// // Display Functions // ///////////////////////////////////////// function setMainColumnHeight() { var content = $("#content"); var contentHeight = content.outerHeight(); var rightHeight = $("#right").outerHeight(); if (contentHeight < rightHeight) { content.css({ height: rightHeight }); } } $(window).load(function() { $('#content img').each(function() { var currImg = $(this); if ($('.reviewBlock').height() == null) { currImg.attr("width",currImg.width()).attr("height",currImg.height()); } }); setMainColumnHeight(); }); ///////////////////////////////////////// // Lightbox Functions // ///////////////////////////////////////// function hideLightbox() { $("#lightbox").hide(); } function setLightboxPos(e) { $("#lightbox").css({ top: e. pageY+10, left: e.pageX+10 }); } function updateLightboxContent(html) { $("#lightbox").html(html); } function center() { var win = $(window); var lightbox = $("#lightbox"); var posY = win.height() / 2 - lightbox.outerHeight() / 2 + win.scrollTop(); var posX = win.width() / 2- lightbox.outerWidth() / 2; if (posY < 0) { posY = 0; } if (posX < 0) { posX = 0; } lightbox.clearQueue().animate({ top : posY, left : posX }); } function showLightbox() { var win = $(window); var lightbox = $("#lightbox"); displayLoading(lightbox); center(); $("#screen").css({ opacity: 0 }).show().animate({ opacity: .65 }, 250); lightbox.css({ opacity: 0 }).show().animate({ opacity: 1 }, 250, function() { win.resize(function(){ center(); }).trigger("resize"); win.scroll(function() { center(); }).trigger("scroll"); }); } function closeLightbox() { $("#screen").animate({ opacity: .0 }, 250, function() { $(this).hide(); }); $("#lightbox").animate({ opacity: 0 }, 250, function() { $(this).hide(); }); } $("a.cancel","#lightbox").live("click",function(e) { e.preventDefault(); closeLightbox(); }); $("a.close","#lightbox").live("click",function(e) { e.preventDefault(); closeLightbox(); }); ///////////////////////////////////////// // Review Functions // ///////////////////////////////////////// $(".label",".reviewNav").each(function(i) { var divHeight = $(this).outerHeight(); var yPos = (divHeight-$("p",this).outerHeight())*.5; $("p",this).css({ top: yPos }); $(this).parent().click(function() { var selectedID = $(this).attr("id"); setReviewNav(selectedID); }); }); $(".reviewBlock").css({ opacity: 0 }).hide(); function setReviewNav(selectedID) { $("li",".reviewNav").each(function() { var currID = $(this).attr("id"); if (currID == selectedID) { $(this).addClass("active"); $("."+currID,"#reviewLinks").css({ opacity: 0 }).show().animate({ opacity: 1 }, 200); } else { $(this).removeClass("active"); $("."+currID,"#reviewLinks").animate({ opacity: 0 }, 200, function() { $(this).hide(); }); } }); } setReviewNav("review9"); ///////////////////////////////////////// // Login Functions // ///////////////////////////////////////// $(".login").live("click",function() { var email = $("#loginEmail").val(); var password = $("#password").val(); x_doPasswordLogin(email,password,updateLogin); }); $(".logout").live("click",function() { x_logOut(updateLogin); }); function updateLogin(content) { if (content == "reload") { var url = window.location.toString(); url = url.split("#")[0]; url = url.split("?")[0]; setTimeout("window.location='"+url+"\'",100); } else { $("#login").html(content); } } $(".close","#login").live("click",function(e) { e.preventDefault(); x_createLogin(updateLogin); }); ///////////////////////////////////////// // Change Password Functions // ///////////////////////////////////////// $(".forgot-password").live("click",function(e) { e.preventDefault(); x_createForgotPasswordForm(updateLogin); }); $(".submitForgotPassword").live("click",function(e) { e.preventDefault(); var email = $("#forgotPasswordEmail").val(); x_lookUpPassword(email,updateLogin); }); ///////////////////////////////////////// // Invite Friends Functions // ///////////////////////////////////////// $(".invite").live("click",function(e) { e.preventDefault(); showLightbox(); x_inviteFriendsForm(updateLightboxContent); }); $(".inviteMore").live("click",function(e) { e.preventDefault(); displayLoading($("#lightbox")); x_inviteFriendsForm(updateLightboxContent); }); $(".submitInvite").live("click",function(e) { e.preventDefault(); var first_name = $("#first_name").val(); var last_name = $("#last_name").val(); var email = $("#inviteEmail").val(); var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; var error = ""; var errorField = $("#inviteError"); if (first_name == "") { error += "First name, "; } if (email == "") { error += "Email, "; } if (error != "") { errorText = "The following fields are required:
"+error.substr(0,(error.length-2)); errorField.html(errorText); } else { if(!emailReg.test(email)) { errorText = "Email address is not valid."; errorField.html(errorText); } else { errorField.html(""); displayLoading("#lightbox"); x_addUser(first_name,last_name,email,updateLightboxContent); } } }); ///////////////////////////////////////// // Change Email Functions // ///////////////////////////////////////// $(".changeEmail").live("click",function(e) { e.preventDefault(); showLightbox(); x_changeEmailForm(updateLightboxContent); }); $(".submitEmailChange").live("click",function(e) { e.preventDefault(); var newEmail1 = $("#newEmail1").val(); var newEmail2 = $("#newEmail2").val(); var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; var error = ""; var errorField = $("#emailError"); if (newEmail1 == "") { error += "New Email, "; } if (newEmail2 == "") { error += "Re-enter New Email, "; } if (error != "") { errorText = "The following fields are required:
"+error.substr(0,(error.length-2)); errorField.html(errorText); } else { if(!emailReg.test(newEmail1)) { errorText = "Email address is not valid."; errorField.html(errorText); } else if (newEmail1 != newEmail2) { errorText = "Email addresses don't match!"; errorField.html(errorText); } else { errorField.html(""); displayLoading("#lightbox"); x_changeEmail(newEmail1,updateLightboxContent); } } }); ///////////////////////////////////////// // Change Password Functions // ///////////////////////////////////////// $(".changePassword").live("click",function(e) { e.preventDefault(); showLightbox(); x_changePasswordForm(updateLightboxContent); }); $(".submitPasswordChange").live("click",function(e) { e.preventDefault(); var newPassword1 = $("#newPassword1").val(); var newPassword2 = $("#newPassword2").val(); var error = ""; var errorField = $("#passwordError"); if (newPassword1 == "") { error += "New Password, "; } if (newPassword2 == "") { error += "Re-enter New Password, "; } if (error != "") { errorText = "The following fields are required:
"+error.substr(0,(error.length-2)); errorField.html(errorText); } else { if (newPassword1.length < 6) { errorText = "Password my be at least 6 characters long!"; errorField.html(errorText); } else if (newPassword1 != newPassword2) { errorText = "Passwords don't match!"; errorField.html(errorText); } else { errorField.html(""); displayLoading("#lightbox"); x_changePassword(newPassword1,updateLightboxContent); } } }); ///////////////////////////////////////// // Unsubscribe Functions // ///////////////////////////////////////// $(".no",".unsubscribe").click(function(e) { e.preventDefault(); displayLoading($("#content")); x_unsubscribeUser("",updateContent); }); $(".yes",".unsubscribe").click(function(e) { e.preventDefault(); var ID = $("#ID").val(); displayLoading($("#content")); x_unsubscribeUser(ID,updateContent); }); ///////////////////////////////////////// // Meatlist Functions // ///////////////////////////////////////// $(".yes a").live({ click: function(e) { e.preventDefault(); showReplies("Y",e); }, mouseover: function(e) { showReplies("Y",e); }, mouseout: function(e) { hideLightbox(); }, mousemove: function(e) { setLightboxPos(e); } }); $(".maybe a").live({ click: function(e) { e.preventDefault(); showReplies("M",e); }, mouseover: function(e) { showReplies("M",e); }, mouseout: function(e) { hideLightbox(); }, mousemove: function(e) { setLightboxPos(e); } }); $(".no a").live({ click: function(e) { e.preventDefault(); showReplies("N",e); }, mouseover: function(e) { showReplies("N",e); }, mouseout: function(e) { hideLightbox(); }, mousemove: function(e) { setLightboxPos(e); } }); function showReplies(flag,e) { var lightbox = $("#lightbox"); var meatwaveID = e.currentTarget.name; displayLoading(lightbox); setLightboxPos(e); lightbox.css({ opacity: 0 }).show().animate({ opacity: 1 }, 250, function() { x_getReplies(flag,meatwaveID,updateLightboxContent); }); } $("a.yes").live("click",function(e) { e.preventDefault(); submitReply("Y"); }); $("a.maybe").live("click",function(e) { e.preventDefault(); submitReply("M"); }); $("a.no").live("click",function(e) { e.preventDefault(); submitReply("N"); }); $("a.submitNote").live("click",function(e) { e.preventDefault(); var note = $("#note").val(); var meateaveID = e.currentTarget.name; x_submitNote(note,meateaveID,updateMeatlist); $(".rsvp").html("
  • \"loading\"
  • "); }); $("a.changeReply").live("click",function(e) { e.preventDefault(); var meateaveID = e.currentTarget.name; x_createMeatlist(meateaveID,"y","n",updateMeatlist); }); $("a.changeNote").live("click",function(e) { e.preventDefault(); var meateaveID = e.currentTarget.name; x_createMeatlist(meateaveID,"n","y",updateMeatlist); }); function submitReply(reply) { var meatwaveID = $("a.yes").attr("name"); x_submitReply(reply,meatwaveID,updateMeatlist); $(".rsvp").html("
  • \"loading\"
  • "); } function updateMeatlist(content) { $(".meatlist").html(content); } ///////////////////////////////////////// // Comments Functions // ///////////////////////////////////////// $(".close",".feedbackMessage").click(function(e) { e.preventDefault(); $(".feedbackMessage").animate({ opacity: 0 }, 200, function() { $(this).hide(); }); }); function setCommentsHeight() { $(".comments ul").each(function(i){ $(this).css({ height: $("li:last",this).outerHeight() }); }); } function toggleFields() { $(".field").each(function (i) { var field = $(this); var id = field.attr("id"); var initVal = field.val(); if (initVal.toLowerCase() == id) { field.css({ color: "#666666" }); } field.focus(function() { var val = field.val(); if (val.toLowerCase() == id) { field.val("").css({ color: "#000000" }); } }); field.blur(function() { var val = field.val(); if (field.val() == "") { var value = id.charAt(0).toUpperCase() + id.slice(1); if (value == "Url") { value = "URL"; } field.val(value).css({ color: "#666666" }); } }); }); } setCommentsHeight(); toggleFields(); $("#preview").live("click", function(e) { e.preventDefault(); submitComment("preview"); }); $("#post").live("click", function(e) { e.preventDefault(); submitComment("post"); }); function submitComment(action){ var name = $("#name").val(); var email = $("#email").val(); var url = $("#url").val(); var comment = $("#comment").val(); var send_email = $("#send_email:checked").val(); var remember = $("#remember:checked").val(); var ID = $("#ID").val(); var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; var error = ""; var errorField = $("#commentError"); if ((name == "") || (name == "Name")) { error += "Name, "; } if ((email == "") || (email == "Email")) { error += "Email, "; } if ((comment == "") || (comment == "Comment")) { error += "Comment, "; } if (error != "") { errorText = "The following fields are required: "+error.substr(0,(error.length-2)); errorField.html(errorText); } else { if(!emailReg.test(email)) { errorText = "Email address is not valid."; errorField.html(errorText); } else { errorField.html(""); displayLoading("#commentButtons"); if (action == "preview") { x_getComments(ID,name,email,url,comment,send_email,remember,1,updateComments); } else if (action == "post") { x_postComment(ID,name,email,url,comment,send_email,remember,updateComments); } } } } function updateComments(content) { $(".comments").html(content); setCommentsHeight(); toggleFields(); } }); function empty() { } function updateCalendar(content) { $("#calendar").html(content); } function updateLogin(content) { $("#login").html(content); } var addthis_share = { templates : { twitter : "{{title}} {{url}} from @Meatwave" } }