/* main functions */ var LemonMain={ //declare variables blnRunGoogleAnalytics:false, //define functions initializePage:function() { this.runGoogleAnalytics(); }, runGoogleAnalytics:function() { //check indicator if(this.blnRunGoogleAnalytics) { var pageTracker = _gat._getTracker("UA-368884-5"); pageTracker._initData(); pageTracker._trackPageview(); } }, //create a standard sized popup window popupWindow:function(url, windowname) { /* url: can be a url string, or an anchor object with an href attribute windowname: can be anything (containing only letters and underscore characters), description: every popup window should have a unique name; more than one link can target the same popup by using the same unique popup name. */ var href; var popupWin; //check for existence of window.focus method if(!window.focus) //if it doesn't exist, exit script, and open link in current window return true; //get the url from the url object if(typeof(url)=='string') href=url; else href=url.href; //open the popup window popupWin=window.open(href, windowname, "width=450,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes"); //set focus to popup window, in case it was in the background popupWin.focus(); //cancel the click on the link, so link isn't opened in current window return false; }, //return a style class as an object getStyleClass:function(strClassName) { //declare variables var returnValue=null; try { if(document.styleSheets) { for(var s=0;s" + strEmail + "<\/a>"); }, //checks for a valid email address format isValidEmailAddress:function(email) { //declare variables var atPos=email.indexOf("@"); var dotPos=email.lastIndexOf("."); var returnValue=true; if(email.length==0) //check if email is blank { returnValue=false; } else if(atPos<1) //check if there are any characters before the "@" sign { returnValue=false; } else if(email.length-dotPos<2) //check if there are any characters after the "." { returnValue=false; } else if(dotPos-atPos<2) //check if there are any characters between the "@" and the "." and make sure they're in the right order { returnValue=false; } return returnValue; }, //checks for a valid postal/zip code format isValidPostalZipCode:function(postalCode,countryName) { var returnValue=true; //validate specific content if(postalCode.length>0) { //verify postal code if(countryName=="Canada") { //ensure it is long enough if(postalCode.length<6) { returnValue=false; } //check for valid format else { var j=0; // Check for legal characters in string - note index starts at zero if('ABCEGHJKLMNPRSTVXY'.indexOf(postalCode.charAt(j)) < 0) { returnValue=false; } j++; if('0123456789'.indexOf(postalCode.charAt(j)) < 0) { returnValue=false; } j++; if('ABCEGHJKLMNPRSTVWXYZ'.indexOf(postalCode.charAt(j)) < 0) { returnValue=false; } j++; if(postalCode.charAt(j)==' ') { j++; } if('0123456789'.indexOf(postalCode.charAt(j)) < 0) { returnValue=false; } j++; if('ABCEGHJKLMNPRSTVWXYZ'.indexOf(postalCode.charAt(j)) < 0) { returnValue=false; } j++; if('0123456789'.indexOf(postalCode.charAt(j)) < 0) { returnValue=false; } } } //verify zip code else if(countryName=="United States") { //ensure it is long enough if(postalCode.length<5) { returnValue=false; } //check for valid format else { //check to make sure each character is numeric (or a space or hyphen) for(var i=0;i 0) { // if there are any cookies intOffset = document.cookie.indexOf(strSearch); if (intOffset != -1) // if cookie name exists { intOffset += strSearch.length // set index of beginning of value intEnd = document.cookie.indexOf(";", intOffset); // set index of end of cookie value if (intEnd == -1) { intEnd = document.cookie.length; } strCookie=unescape(document.cookie.substring(intOffset, intEnd)); } } //for browsers that return "undefined" when a cookie is not found, return an empty string instead, for consistent return values across browsers if(strCookie=="undefined") { strCookie=""; } return strCookie; }, //delete a cookie del:function(strName) { this.set(strName,"",-1); } }/* authentication functions */ // login class var LJLogin={ initializeForm:function(frm) { frm.email.focus(); frm.email.select(); }, isValidForm:function(frm) { //declare variables var returnValue=true; if(frm.email.value.length==0) { alert("Please enter your email address"); frm.email.focus(); returnValue=false; } else if(frm.email.value.length!=0 && !LemonMain.isValidEmailAddress(frm.email.value)) { alert("Please enter a valid email address"); frm.email.focus(); frm.email.select(); returnValue=false; } else if(frm.password.value.length==0) { alert("Please enter your password"); frm.password.focus(); frm.password.select(); returnValue=false; } //encode password if(returnValue) { //md5 encode the password frm.passwordHash.value=hex_md5(frm.email.value+frm.password.value); //clear the entered password field before submitting form data frm.password.value=""; } LemonMain.disableSubmit(frm,returnValue); return returnValue; } } var LJAccount={ initializeForm:function(frm) { //check if form exists (doesn't exist if this page is displayed while not logged in) if(frm) { //set focus frm.password.focus(); frm.password.select(); this.updatePasswordClick(frm); } }, isValidForm:function(frm) { //declare variables var returnValue=true; if(frm.password.value.length==0) { alert("Please enter your password to update your account information"); frm.password.focus(); frm.password.select(); returnValue=false; } else if(frm.firstName.value.length==0) { alert("Please enter your first name"); frm.firstName.focus(); returnValue=false; } else if(frm.lastName.value.length==0) { alert("Please enter your last name"); frm.lastName.focus(); returnValue=false; } else if(frm.updatePassword.checked) { if(frm.passwordNew.value.length==0) { alert("Please enter your new password"); frm.passwordNew.focus(); frm.passwordNew.select(); returnValue=false; } else if(frm.repeatPasswordNew.value.length==0) { alert("Please re-enter your new password to make sure you have entered it correctly"); frm.repeatPasswordNew.focus(); frm.repeatPasswordNew.select(); returnValue=false; } else if(frm.passwordNew.value!=frm.repeatPasswordNew.value) { alert("Your new passwords do not match\nPlease re-enter your passwords"); //clear passwords frm.passwordNew.value=""; frm.repeatPasswordNew.value=""; frm.passwordNew.focus(); frm.passwordNew.select(); returnValue=false; } } if(returnValue & frm.deleteAccount.checked) { if(!confirm("Are you sure you want to permanently delete your account?")) { frm.deleteAccount.checked=false; frm.deleteAccount.focus(); returnValue=false; } } if(returnValue) { //md5 encode the passwords, seeded with the email address frm.passwordHash.value=hex_md5(frm.email.value+frm.password.value); frm.passwordNewHash.value=hex_md5(frm.email.value+frm.passwordNew.value); //clear the entered password fields before submitting form data frm.password.value=""; frm.passwordNew.value=""; frm.repeatPasswordNew.value=""; } LemonMain.disableSubmit(frm,returnValue); return returnValue; }, updatePasswordClick:function(frm) { if(frm.updatePassword.checked) { frm.passwordNew.disabled=false; frm.repeatPasswordNew.disabled=false; frm.passwordNew.focus(); frm.passwordNew.select(); } else { frm.passwordNew.disabled=true; frm.repeatPasswordNew.disabled=true; } } } var LJNewAccount={ initializeForm:function(frm) { //check if form exists (doesn't exist if this page is displayed while logged in) if(frm) { //set focus frm.firstName.focus(); frm.firstName.select(); } }, isValidForm:function(frm) { //declare variables var returnValue=true; if(frm.firstName.value.length==0) { alert("Please enter your first name"); frm.firstName.focus(); returnValue=false; } else if(frm.lastName.value.length==0) { alert("Please enter your last name"); frm.lastName.focus(); returnValue=false; } else if(frm.email.value.length==0) { alert("Please enter your email address"); frm.email.focus(); returnValue=false; } else if(frm.email.value.length!=0 && !LemonMain.isValidEmailAddress(frm.email.value)) { alert("Please enter a valid email address"); frm.email.focus(); frm.email.select(); returnValue=false; } else if(frm.password.value.length==0) { alert("Please enter your password"); frm.password.focus(); frm.password.select(); returnValue=false; } else if(frm.repeatPassword.value.length==0) { alert("Please re-enter your password to make sure you have entered it correctly"); frm.repeatPassword.focus(); frm.repeatPassword.select(); returnValue=false; } else if(frm.password.value!=frm.repeatPassword.value) { alert("Your passwords do not match\nPlease re-enter your passwords"); //clear passwords frm.password.value=""; frm.repeatPassword.value=""; frm.password.focus(); frm.password.select(); returnValue=false; } if(returnValue) { //md5 encode the password, seeded with the email address frm.passwordHash.value=hex_md5(frm.email.value+frm.password.value); //clear the entered password fields before submitting form data frm.password.value=""; frm.repeatPassword.value=""; } LemonMain.disableSubmit(frm,returnValue); return returnValue; } }/* * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message * Digest Algorithm, as defined in RFC 1321. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet * Distributed under the BSD License * See http://pajhome.org.uk/crypt/md5 for more info. */ /* * Configurable variables. You may need to tweak these to be compatible with * the server-side, but the defaults work in most cases. */ var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ /* * These are the functions you'll usually want to call * They take string arguments and return either hex or base-64 encoded strings */ function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));} function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));} function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));} function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); } function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); } function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); } /* * Perform a simple self-test to see if the VM is working */ function md5_vm_test() { return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72"; } /* * Calculate the MD5 of an array of little-endian words, and a bit length */ function core_md5(x, len) { /* append padding */ x[len >> 5] |= 0x80 << ((len) % 32); x[(((len + 64) >>> 9) << 4) + 14] = len; var a = 1732584193; var b = -271733879; var c = -1732584194; var d = 271733878; for(var i = 0; i < x.length; i += 16) { var olda = a; var oldb = b; var oldc = c; var oldd = d; a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); c = md5_ff(c, d, a, b, x[i+10], 17, -42063); b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); a = safe_add(a, olda); b = safe_add(b, oldb); c = safe_add(c, oldc); d = safe_add(d, oldd); } return Array(a, b, c, d); } /* * These functions implement the four basic operations the algorithm uses. */ function md5_cmn(q, a, b, x, s, t) { return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); } function md5_ff(a, b, c, d, x, s, t) { return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); } function md5_gg(a, b, c, d, x, s, t) { return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); } function md5_hh(a, b, c, d, x, s, t) { return md5_cmn(b ^ c ^ d, a, b, x, s, t); } function md5_ii(a, b, c, d, x, s, t) { return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); } /* * Calculate the HMAC-MD5, of a key and some data */ function core_hmac_md5(key, data) { var bkey = str2binl(key); if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz); var ipad = Array(16), opad = Array(16); for(var i = 0; i < 16; i++) { ipad[i] = bkey[i] ^ 0x36363636; opad[i] = bkey[i] ^ 0x5C5C5C5C; } var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz); return core_md5(opad.concat(hash), 512 + 128); } /* * Add integers, wrapping at 2^32. This uses 16-bit operations internally * to work around bugs in some JS interpreters. */ function safe_add(x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); } /* * Bitwise rotate a 32-bit number to the left. */ function bit_rol(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)); } /* * Convert a string to an array of little-endian words * If chrsz is ASCII, characters >255 have their hi-byte silently ignored. */ function str2binl(str) { var bin = Array(); var mask = (1 << chrsz) - 1; for(var i = 0; i < str.length * chrsz; i += chrsz) bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32); return bin; } /* * Convert an array of little-endian words to a string */ function binl2str(bin) { var str = ""; var mask = (1 << chrsz) - 1; for(var i = 0; i < bin.length * 32; i += chrsz) str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask); return str; } /* * Convert an array of little-endian words to a hex string. */ function binl2hex(binarray) { var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; var str = ""; for(var i = 0; i < binarray.length * 4; i++) { str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); } return str; } /* * Convert an array of little-endian words to a base-64 string */ function binl2b64(binarray) { var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; var str = ""; for(var i = 0; i < binarray.length * 4; i += 3) { var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16) | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 ) | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF); for(var j = 0; j < 4; j++) { if(i * 8 + j * 6 > binarray.length * 32) str += b64pad; else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F); } } return str; }//home page functions var LemonHome={ initializeEditForm:function(frm) { //frm.title.focus(); //frm.title.select(); }, isValidEditForm:function(frm) { var blnReturnValue=true; LemonMain.disableSubmit(frm,blnReturnValue); return blnReturnValue; } }//quote functions var LemonQuotes={ initializeEditForm:function(frm) { frm.date.focus(); frm.date.select(); }, isValidEditForm:function(frm) { var blnReturnValue=true; LemonMain.disableSubmit(frm,blnReturnValue); return blnReturnValue; }, add:function(frm) { window.location.assign("/quotes/edit.php"); }, deleteQuote:function() { return confirm("Are you sure you want to delete this quote?"); } }//column functions var LemonColumns={ intRegularTypeId:0, intGuestTypeId:1, initializeEditForm:function(frm) { frm.title.focus(); frm.title.select(); }, isValidEditForm:function(frm) { var blnReturnValue=true; LemonMain.disableSubmit(frm,blnReturnValue); return blnReturnValue; }, add:function(intTypeId) { switch(Number(intTypeId)) { case(LemonColumns.intRegularTypeId): window.location.assign("/columns/column/edit.php"); break; case(LemonColumns.intGuestTypeId): window.location.assign("/guestcolumns/column/edit.php"); break; } }, deleteColumn:function() { blnReturnValue=false; if(confirm("Are you sure you want to delete this column and all its entries?")) { blnReturnValue=confirm("Really sure? You can't undo this."); } return blnReturnValue; } } var LemonColumnEntries={ initializeEditForm:function(frm) { frm.title.focus(); frm.title.select(); }, removeFormattingClick:function() { var eleFormatting=document.getElementById("removeFormatting"); if(eleFormatting.style.display=="none") { eleFormatting.style.display="block"; } else { eleFormatting.style.display="none"; } return false; }, isValidEditForm:function(frm) { var blnReturnValue=true; LemonMain.disableSubmit(frm,blnReturnValue); return blnReturnValue; }, add:function(intColumnId,intTypeId) { switch(Number(intTypeId)) { case(LemonColumns.intRegularTypeId): window.location.assign("/columns/entry/edit.php?columnid="+intColumnId.toString()); break; case(LemonColumns.intGuestTypeId): window.location.assign("/guestcolumns/entry/edit.php?columnid="+intColumnId.toString()); break; } }, deleteEntry:function() { return confirm("Are you sure you want to delete this entry?"); } }//photo attachment functions var LemonPhotoAttachment={ intFileCount:0, initializeEditForm:function(frm) { if(frm.credit) { frm.credit.focus(); frm.credit.select(); } }, isValidEditForm:function(frm) { var blnReturnValue=true; LemonMain.disableSubmit(frm,blnReturnValue); return blnReturnValue; }, attachPhotoClick:function() { this.intFileCount++; input=document.createElement("input"); input.setAttribute("type","file"); input.setAttribute("name","image"+this.intFileCount.toString()); input.className="formField30"; p=document.createElement("p"); p.appendChild(input); document.getElementById("photoAddContainer").appendChild(p); input.focus(); }, deletePhoto:function() { return confirm("Are you sure you want to delete this photo?"); } }//video attachment functions var LemonVideoAttachment={ intFileCount:0, initializeEditForm:function(frm) { if(frm.credit) { frm.credit.focus(); frm.credit.select(); } }, isValidEditForm:function(frm) { var blnReturnValue=true; LemonMain.disableSubmit(frm,blnReturnValue); return blnReturnValue; }, attachVideoClick:function() { this.intFileCount++; input=document.createElement("input"); input.setAttribute("type","file"); input.setAttribute("name","video"+this.intFileCount.toString()); input.className="formField30"; p=document.createElement("p"); p.appendChild(input); document.getElementById("videoAddContainer").appendChild(p); input.focus(); }, deleteVideo:function() { return confirm("Are you sure you want to delete this video?"); } }//contact functions var LemonContact={ initializeSubmitForm:function(frm) { //frm.name.focus(); //hide attachment field document.getElementById("attachmentLabel").style.display="none"; document.getElementById("attachmentInput").style.display="none"; }, isValidSubmitForm:function(frm) { //declare variables var returnValue=true; if(frm.name.value.length==0) { alert("Please enter your name"); frm.name.focus(); returnValue=false; } else if(frm.email.value.length==0) { alert("Please enter your email address"); frm.email.focus(); returnValue=false; } else if(!LemonMain.isValidEmailAddress(frm.email.value)) { alert("Please enter a valid email address"); frm.email.focus(); frm.email.select(); returnValue=false; } else if(frm.message.value.length==0 && frm.attachment && frm.attachment.value.length==0) { alert("Please enter a message or an attachment"); frm.message.focus(); returnValue=false; } else if(frm.verification.value.length==0) { alert("Please enter the verification code"); frm.verification.focus(); returnValue=false; } LemonMain.disableSubmit(frm,returnValue); return returnValue; }, addAttachment:function() { //declare variables var returnValue=false; //show attachment field document.getElementById("attachmentLabel").style.display="block"; document.getElementById("attachmentInput").style.display="block"; //hide attachment link document.getElementById("attachmentLink").style.display="none"; return returnValue; }, removeAttachment:function() { //declare variables var returnValue=false; //clear attachment field document.getElementById("attachment").value=""; //property is read only in some browsers, so this function should not be used (it is misleading) //hide attachment field document.getElementById("attachmentLabel").style.display="none"; document.getElementById("attachmentInput").style.display="none"; //show attachment link document.getElementById("attachmentLink").style.display="block"; return returnValue; }, initializeEditForm:function(frm) { frm.name.focus(); frm.name.select(); }, isValidEditForm:function(frm) { var blnReturnValue=true; LemonMain.disableSubmit(frm,blnReturnValue); return blnReturnValue; }, deleteSubmission:function() { return confirm("Are you sure you want to delete this submission?"); } }//column functions var LemonRecipeMain={ initializeEditForm:function(frm) { frm.title.focus(); frm.title.select(); }, isValidEditForm:function(frm) { var blnReturnValue=true; LemonMain.disableSubmit(frm,blnReturnValue); return blnReturnValue; } } var LemonRecipes={ initializeEditForm:function(frm) { frm.title.focus(); frm.title.select(); }, isValidEditForm:function(frm) { var blnReturnValue=true; LemonMain.disableSubmit(frm,blnReturnValue); return blnReturnValue; }, add:function(intRecipeMainId) { window.location.assign("/recipes/recipe/edit.php?recipemainid="+intRecipeMainId.toString()); }, deleteRecipe:function() { return confirm("Are you sure you want to delete this recipe?"); } }//functions for photo galleries within a page var LemonGallery={ initializeEditForm:function(frm) { frm.title.focus(); frm.title.select(); }, isValidEditForm:function(frm) { var blnReturnValue=true; LemonMain.disableSubmit(frm,blnReturnValue); return blnReturnValue; }, add:function() { window.location.assign("/photos/gallery/edit.php"); }, deleteGallery:function() { return confirm("Are you sure you want to delete this gallery and all its photos?"); } } var LemonPhoto={ addCount:0, initializeEditForm:function(frm) { frm.credit.focus(); frm.credit.select(); }, isValidEditForm:function(frm) { var blnReturnValue=true; LemonMain.disableSubmit(frm,blnReturnValue); return blnReturnValue; }, add:function(intGalleryId) { this.addCount++; //window.location.assign("/photos/gallery/edit.php?galleryid="+intGalleryId.toString()); input=document.createElement("input"); input.setAttribute("type","file"); input.setAttribute("name","file"+this.addCount.toString()); input.setAttribute("id","file"+this.addCount.toString()); input.className="formField30"; p=document.createElement("p"); p.appendChild(input); document.getElementById("photoAddContainer").appendChild(p); input.focus(); }, remove:function(intId) { alert("test"); return false; }, deletePhoto:function() { return confirm("Are you sure you want to delete this photo?"); }, createThumb:function() { return true; } } //declare photo variables var arrPhotoSrc; var arrPhotoThumbnailSrc; var arrPhotoCaption; var arrPhotoCredit; var arrAudioSrc; var strPhotoIdText; var strCaptionPrefix; var blnAudio; var blnAudioMute=false; var objAudioTimeUpdateInterval=null; //object containing interval during audio playback var intCurrentPhotoNum=1; //current photo being displayed var intPhotoFadeTime=750; //fade time in milliseconds var intPhotoFadeIncrement=5; //fade increment as percentage var intPhotoPlaySpeed=5000; //time to display each photo when playing all photos, the value here value is not used, as play speed is set from drop down box var objPhotoPlayInterval=null; //object containing interval during playback var objPhotoImageFore=null; //object holding foreground image var objPhotoImageBack=null; //object holding background image var objPhotoImageTransition=null; var strMediaPlayerObject=null; function initializePhotos() { //set image objects objPhotoImageFore=document.getElementById("photo1"); objPhotoImageBack=document.getElementById("photo2"); objPhotoHeightHolder=document.getElementById("photoHeightHolder"); //set media player object strMediaPlayerObject="document.QTPlayer"; //for some reason, document.QTPlayer cannot be assigned to an object, so I've used this method instead //preload second image photoPreload(intCurrentPhotoNum); //set play speed photoSetPlaySpeed(document.getElementById("photoPlaySpeed").value); //stop autoplay (when window is loaded and object is available) if(blnAudio) { window.onload=function() { audioStop(); eval(strMediaPlayerObject).SetTime(0); } } } //jump to a specific photo function photoGoto(intPhotoNum) { //make sure photo exists for intPhotoNum if(intPhotoNum<1 || intPhotoNum>arrPhotoSrc.length) { //do nothing //alert("Photo "+intPhotoNum+" does not exist"); } else { //define new image var img=document.createElement("img"); var strAltText=""; var blnTransitionComplete=true; //define actions to perform when image is loaded img.onload=function(evt) { //change caption photoSetCaption(intPhotoNum); //change credit photoSetCredit(intPhotoNum); //change display number photoSetNumber(intPhotoNum); //change next link photoSetNextLink(intPhotoNum); //change previous link photoSetPreviousLink(intPhotoNum); //change link to this photo link photoSetLinkToThisPhoto(intPhotoNum); //check if previous transition is complete blnTransitionComplete=(objPhotoImageBack.style.display=="none"); if(blnTransitionComplete) { //switch image objects objPhotoImageTransition=objPhotoImageBack; objPhotoImageBack=objPhotoImageFore; objPhotoImageFore=objPhotoImageTransition; } else { //hide fore image LemonAnimation.setOpacity(objPhotoImageFore,0); } //transfer new image properties to fore image objPhotoImageFore.src=this.src; objPhotoImageFore.width=this.width; objPhotoImageFore.height=this.height; //change image classes objPhotoImageFore.style.display="block"; //prevents twitching (height change) objPhotoImageFore.className="photoFore"; objPhotoImageBack.className="photoBack"; //remove size attributes in Safari, which sets them to 0 if(LemonAnimation.isSafari()) { objPhotoImageFore.removeAttribute("width"); objPhotoImageFore.removeAttribute("height"); } //chanage alt text (from caption) strAltText=arrPhotoCaption[intPhotoNum-1]; if(strAltText.length>30) { strAltText=strAltText.substring(0,27)+"..."; } objPhotoImageFore.alt=strAltText; //change title text objPhotoImageFore.title=""; if(blnTransitionComplete) { //fade out back image LemonAnimation.fadeOut(objPhotoImageBack,intPhotoFadeTime,intPhotoFadeIncrement); } //fade in fore image LemonAnimation.fadeIn(objPhotoImageFore,intPhotoFadeTime,intPhotoFadeIncrement); //change current photo number intCurrentPhotoNum=intPhotoNum; //preload next image photoPreload(intPhotoNum); } //load new image img.src=arrPhotoSrc[intPhotoNum-1]; //change audio file audioGoto(intPhotoNum); } } //go to a specific photo number, and stop playback function photoGotoClick(intPhotoNum) { //stop play, if necessary photoStopClick(); photoGoto(intPhotoNum); return false; //cancel href link } //go to the next photo, and stop playback function photoNextClick(objLink) { //stop play, if necessary photoStopClick(); photoGoto(intCurrentPhotoNum+1); //remove focus from link if(objLink) { objLink.blur(); } return false; //cancel href link } //go to the previous photo, and stop playback function photoPreviousClick(objLink) { //stop play, if necessary photoStopClick(); photoGoto(intCurrentPhotoNum-1); //remove focus from link if(objLink) { objLink.blur(); } return false; //cancel href link } //move to next photo, and start playback function photoPlayClick(objLink) { //start playback photoPlay(); if(!blnAudio) { //move to next photo photoPlayNext(); } //remove focus from link if(objLink) { objLink.blur(); } return false; //cancel href link } //start playback function photoPlay() { //switch available buttons document.getElementById("photoPlay").style.display="none"; document.getElementById("photoStop").style.display="block"; //play audio if available audioPlay(); if(!blnAudio) { //set interval for next photo objPhotoPlayInterval=setInterval(photoPlayNext,intPhotoPlaySpeed); } return false; //cancel href link } //go to the next photo during playback function photoPlayNext() { //if this function is called while on the last photo, and there is no audio available, restart from the beginning if(intCurrentPhotoNum>=arrPhotoSrc.length && !blnAudio) { //display first photo photoGoto(1); } else { //stop playback on transition to last photo, if no audio is available if(intCurrentPhotoNum==arrPhotoSrc.length-1 && !blnAudio) { //stop play photoStopClick(); } //check for more photos in the gallery if(intCurrentPhotoNum 0) { intInitialX=0; } obj.style.marginLeft=intInitialX.toString()+"px"; } //scroll on the y axis if(intY) { intInitialY=stripPx(obj.style.marginTop); intInitialY-=intY; //don't allow scrolling past the top if(intInitialY > 0) { intInitialY=0; } obj.style.marginTop=intInitialY.toString()+"px"; } } function stopScroll() { clearTimeout(objScrollTimer); objScroll=null; } //return the integer part of a passed style value function stripPx(str) { var intValue=parseInt(str.replace("px",""),10); if(isNaN(intValue)) { return 0; } else { return intValue; } } //audio functions function audioPlay() { if(blnAudio) { eval(strMediaPlayerObject).Play(); //update audio time display every second setAudioTimeDisplay(); objAudioTimeUpdateInterval=setInterval("setAudioTimeDisplay();",1000); } return false; //cancel href link } function audioStop() { if(blnAudio) { eval(strMediaPlayerObject).Stop(); //stop updating audio time display clearInterval(objAudioTimeUpdateInterval); } return false; //cancel href link } function audioMute(bln) { if(blnAudio) { eval(strMediaPlayerObject).SetMute(bln); } return false; //cancel href link } //jump to a specific audio file function audioGoto(intAudioNum) { if(blnAudio) { //make sure file exists for intAudioNum if(intAudioNum>0 && intAudioNum<=arrAudioSrc.length) { //check if file exists if(arrAudioSrc[intAudioNum-1].length>0) { //change URL eval(strMediaPlayerObject).SetURL(arrAudioSrc[intAudioNum-1]); //update audio time display setAudioTimeDisplay(); } //stop any automatic play eval(strMediaPlayerObject).Stop(); } } } function audioSetVolume(intAudioVolume) { if(blnAudio) { eval(strMediaPlayerObject).SetVolume(intAudioVolume); } } //declare audio scroll variables var objAudioStepTimer=null; var intAudioStepIncrement=2; //seconds var intAudioStepDelay=50; var intInitialAudioStepDelay=300; function audioForwardClick() { audioStep(intAudioStepIncrement); objAudioStepTimer=setTimeout("audioForward()",intInitialAudioStepDelay); setAudioTimeDisplay(); } function audioReverseClick() { audioStep(-intAudioStepIncrement); objAudioStepTimer=setTimeout("audioReverse()",intInitialAudioStepDelay); setAudioTimeDisplay(); } function audioForward() { audioStep(intAudioStepIncrement); objAudioStepTimer=setTimeout("audioForward()",intAudioStepDelay); setAudioTimeDisplay(); } function audioReverse() { audioStep(-intAudioStepIncrement); objAudioStepTimer=setTimeout("audioReverse()",intAudioStepDelay); setAudioTimeDisplay(); } function audioStep(intSeconds) { //declare variables blnPlaying=false; intStepUnits=0; //calculate step units intStepUnits=intSeconds * eval(strMediaPlayerObject).GetTimeScale()/150; if(eval(strMediaPlayerObject).GetRate()==1) { blnPlaying=true; } //check if nearing end of audio clip (do not allow to fast forward to end, or it will trigger the next audio file) //(if stepping backward, or the current position is less than one step from the end, then perform step) if(intSeconds < 0 || (eval(strMediaPlayerObject).GetTime() < (eval(strMediaPlayerObject).GetDuration()-intStepUnits * 150))) { eval(strMediaPlayerObject).Step(intStepUnits); } else { //stop stepping stopAudioStep(); } if(blnPlaying) { //resume play eval(strMediaPlayerObject).Play(); } } function stopAudioStep() { clearTimeout(objAudioStepTimer); } //audio time display functions function setAudioTimeDisplay() { if(blnAudio) { //declare variables dblAudioTime=0; dblAudioDuration=0; dblAudioTime=eval(strMediaPlayerObject).GetTime()/eval(strMediaPlayerObject).GetTimeScale(); dblAudioDuration=eval(strMediaPlayerObject).GetDuration()/eval(strMediaPlayerObject).GetTimeScale(); document.getElementById("audioTimeDisplay").innerHTML=formatTime(dblAudioTime)+" / "+formatTime(dblAudioDuration); } } function formatTime(dblSeconds,intFormatType) { /* intFormatType options: 1 = round to nearest hour 2 = round to nearest minute 3 = round to nearest second (default) 4 = round to nearest hundredth of a second 5 = round to nearest thousandth of a second */ //declare variables var intHours=0; var intMinutes=0; var intSeconds=0; var strTime=""; var blnNegative=false; //set default format type if none has been passed if(!intFormatType) { var intFormatType=3; } //check for negative value if(dblSeconds<0) { blnNegative=true; dblSeconds=dblSeconds*-1; } //calculate total minutes if(intFormatType>=3) { intMinutes=Math.floor(dblSeconds/60); } else { intMinutes=Math.round(dblSeconds/60); } //calculate total hours if(intFormatType>=2) { intHours=Math.floor(intMinutes/60); } else { intHours=Math.round(intMinutes/60); } dblSeconds=((dblSeconds/60)-intMinutes)*60; //calculate remainder seconds intMinutes=Math.round(((intMinutes/60)-intHours)*60); //calculate remainder minutes //add negative sign strTime=(blnNegative ? "-" : "") //add hours strTime+=leadingZeros(intHours.toString(),1); //add minutes if(intFormatType>=2) { strTime+=":"+leadingZeros(intMinutes.toString(),2); } //add seconds if(intFormatType>=3) { //round seconds switch(intFormatType) { case(3): dblSeconds=Math.round(dblSeconds); break; case(4): dblSeconds=(Math.round(dblSeconds*100)/100).toFixed(2); break; case(5): dblSeconds=(Math.round(dblSeconds*1000)/1000).toFixed(3); break; } //add seconds strTime+=":"+leadingZeros(dblSeconds.toString(),2); } return strTime; } function leadingZeros(strValue,intCharacters) { //declare variables intLength=0; //find decimal point intLength=(strValue.indexOf(".")<0 ? strValue.length : strValue.indexOf(".")); //check if number needs padding if(intLength=100) { clearInterval(this.arrFadeIntervals[intIndex]); } }, //set the opacity of an element setOpacity:function(ele, intOpacity) { //limit passed opacity value to between 0 and 100 if(intOpacity<0) { intOpacity=0; } else if(intOpacity>100) { intOpacity=100; } //set display if(intOpacity>0) { ele.style.display="block"; } else { ele.style.display="none"; } //set opacity //ele.style.filter="alpha(opacity="+intOpacity+")"; //IE deprecated ele.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+intOpacity+")"; //IE ele.style.MozOpacity=intOpacity/100; //Mozilla/Netscape ele.style.opacity=intOpacity/100; //Opera + W3C standard /* no longer necessary, safari bug has been fixed if(intOpacity==100) { if(this.isSafari()) { ele.style.opacity=.9999; //objects in Safari disappear at 100 opacity (for some unknown reason) } } */ }, //return the current opacity of an element getOpacity:function(ele) { //set default return opacity var intOpacity=100; //check if opacity attribute exists if(ele.style.opacity) { //get current opacity intOpacity=ele.style.opacity*100; } return intOpacity; }, //load an image into the browser's cache for faster access later imagePreload:function(strSrc) { var img=document.createElement("img"); img.src=strSrc; }, //detect if browser is Safari blnIsSafari:null, isSafari:function() { //declare variables var returnValue=false; //check if browser has been determined already if(this.blnIsSafari!=undefined) { returnValue=this.blnIsSafari; } else { if(navigator.vendor) { if(navigator.vendor.indexOf("Apple") != -1) { returnValue=true; } } } return returnValue; } }