function prepText(fieldValue) { if(fieldValue != null) { fieldValue = fieldValue.toString(); } while( fieldValue.indexOf("`") > -1 || fieldValue.indexOf("’") > -1 || fieldValue.indexOf('“') > -1 || fieldValue.indexOf('”') > -1 || fieldValue.indexOf('—') > -1 || fieldValue.indexOf('´') > -1 || /\n\r/gi.test(fieldValue) == true || /\r\n/gi.test(fieldValue) == true || /\r/gi.test(fieldValue) == true || /\n/gi.test(fieldValue) == true ) { fieldValue = fieldValue.replace("`", "'"); fieldValue = fieldValue.replace("’", "'"); fieldValue = fieldValue.replace('“', '"'); fieldValue = fieldValue.replace('”', '"'); fieldValue = fieldValue.replace('—', '-'); fieldValue = fieldValue.replace('´', "'"); fieldValue = fieldValue.replace(/\n\r/gi, '
'); fieldValue = fieldValue.replace(/\r\n/gi, '
'); fieldValue = fieldValue.replace(/\r/gi, '
'); fieldValue = fieldValue.replace(/\n/gi, '
'); } return fieldValue; } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function daysInMonth(month,year) { var dd = new Date(year, month, 0); return dd.getDate(); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function AddSelectOption(selectObj, text, value, isSelected) { if (selectObj != null && selectObj.options != null) { selectObj.options[selectObj.options.length] = new Option(text, value, false, isSelected); } } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function adjustDropdownDays(selectID, month, year) { var numDaysPerMonth = daysInMonth(month, year); var numDaysInDropdown = $(selectID).select('option[value!=""]').length; //Must add days to dropdown. if ( numDaysPerMonth > numDaysInDropdown ) { for (var i = numDaysInDropdown + 1; i <= numDaysPerMonth; i++) { AddSelectOption($(selectID), i, i, false); } } //Must remove days from dropdown. else if (numDaysPerMonth < numDaysInDropdown ) { for (var i = numDaysPerMonth + 1; i <= numDaysInDropdown; i++) { $(selectID).select('option[value='+i+']')[0].remove(); } } } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function joinUsForm(formID) { var formObj = validateAParticularForm(formID); if(formObj == null) { alert('Error: Check formID'); return false; } if(!formObj.isValid) { displayErrors(formObj); return false; } else { joinUsFormInsert(formID, '/blimda/JoinUsFormInsert.asp', formID); return true; } } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function joinUsFormInsert(formID, actionPage, divID) { var jsonResult = ""; var serializedParams = Form.serializeElements( $(formID).getElements() ); var pars = serializedParams; new Ajax.Request(daDomain+actionPage, { parameters: pars, asynchronous: false, method: 'get', onSuccess: function(theResponse){ alert(theResponse.responseText); jsonResult = "{'successfulInsert':true, 'message':' '}".evalJSON();}, onFailure: function(theResponse){jsonResult = "{'successfulInsert':false, 'message':'There was an error when processing your form.'}".evalJSON();} }); if(jsonResult.successfulInsert) { // $(formID).update('

Thank you for your submission.

'); } else { alert("An error occurred during form submission. If the problem persists, contact the website administrator."); } } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function contactUsForm(formID) { var formObj = validateAParticularForm(formID); if(formObj == null) { alert('Error: Check formID'); return false; } if(!formObj.isValid) { displayErrors(formObj); return false; } else { contactUsFormInsert(formID, '/blimda/Common/NewContactFormInsert.asp', formID); return true; } } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function contactUsFormInsert(formID, actionPage, divID) { var jsonResult = ""; var serializedParams = Form.serializeElements( $(formID).getElements() ); var pars = serializedParams; new Ajax.Request(daDomain+actionPage, { parameters: pars, asynchronous: false, method: 'get', onSuccess: function(theResponse){jsonResult = "{'successfulInsert':true, 'message':' '}".evalJSON();}, onFailure: function(theResponse){jsonResult = "{'successfulInsert':false, 'message':'There was an error when processing your form.'}".evalJSON();} }); if(jsonResult.successfulInsert) { newContactFormSuccessSubmit(formID); } else { alert("An error occurred during form submission. If the problem persists, contact the website administrator."); } } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function newContactFormSuccessSubmit(divID) { var pars = ""; ajax = new Ajax.Updater( divID, daDomain+'/blimda/Common/NewContactFormSuccessSubmit.asp', // URL { // options method:'get', parameters: pars } ); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function newsletterForm(formID) { var formObj = validateAParticularForm(formID); if(formObj == null) { alert('Error: Check formID'); return false; } if(!formObj.isValid) { displayErrors(formObj); } else { newsletterFormInsert(formID, '/blimda/NewsletterFormInsert.asp', formID); } } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function newsletterFormInsert(formID, actionPage, divID) { var jsonResult = ""; var emailaddy = "____"; var jsonText = ""; var errorText; var serializedParams = Form.serializeElements( $(formID).getElements() ); var pars = serializedParams; new Ajax.Request(daDomain+actionPage, { parameters: pars, asynchronous: false, method: 'get', onSuccess: function(theResponse){ jsonResult = "{'successfulInsert':true, 'message':' '}".evalJSON(); jsonText = theResponse.responseText; jsonText = jsonText.evalJSON(); emailaddy = jsonText.authoremail; }, onFailure: function(theResponse){ jsonResult = "{'successfulInsert':false, 'message':'There was an error when processing your form.'}".evalJSON(); } }); if(jsonResult.successfulInsert) { $(formID).update('

' + emailaddy + ' has been added to our mailing list.

'); } else { alert("An error occurred during form submission. If the problem persists, contact the website administrator."); } } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;iThank you for your submission!.'); } else { alert("An error occurred during form submission. If the problem persists, contact the website administrator."); } } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function productUploadForm(productID, divID) { var pars = 'productID='+productID+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/Scenario/ProductUploadForm.asp', // URL { // options method:'get', parameters: pars, asynchronous: false, onSuccess: function(a){}, onFailure: function(a){alert(a.responseText); success = false;} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function addRetailer(entityName, entityAddress, entityCity, entityState, entityZip, entityPhone, entityEmail) { var success = 'j'; var pars = 'entityName='+entityName+'&entityAddress='+entityAddress+'&entityCity='+entityCity+'&entityZip='+entityZip+'&entityPhone='+entityPhone+'&entityEmail='+entityEmail+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/Scenario/AddRetailer.asp', { parameters: pars, asynchronous: false, onSuccess: function(a){success = true;}, onFailure: function(a){alert(a.responseText); success = false;} }); return success; } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function removeRetailer(entityID) { var success = 'j'; var pars = 'entityID='+entityID+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/Scenario/RemoveRetailer.asp', { parameters: pars, asynchronous: false, onSuccess: function(a){success = true;}, onFailure: function(a){alert(a.responseText); success = false;} }); return success; } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function displayRetailers(dType, divID) { var pars = 'dType='+dType+'&divID='+divID+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/Scenario/DisplayRetailers.asp', // URL { // options method:'get', parameters: pars, asynchronous: false, onSuccess: function(a){}, onFailure: function(a){alert(a.responseText); success = false;} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function displayRetailer(entityID, dType, divID) { dType = escape(dType); var pars = 'entityID='+entityID+'&dType='+dType+'&divID='+divID+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/Scenario/DisplayRetailer.asp', // URL { // options method:'get', parameters: pars, asynchronous: false, onSuccess: function(a){}, onFailure: function(a){alert(a.responseText); success = false;} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/function isValidZip(zip) { var result = usps('17579', zip, 1, 15, 'regular', 'Priority Mail', ''); if(result == null || result == '') { return false; } else { return true; } } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function usps(zipOrigination, zipDestination, pounds, ounces, size, service, additional) { zipOrigination = escape(zipOrigination); zipDestination = escape(zipDestination); pounds = escape(pounds); ounces = escape(ounces); size = escape(size); service = escape(service); var rate; var pars = 'Service='+service+'&ZipOrigination='+zipOrigination+'&ZipDestination='+zipDestination+'&Pounds='+pounds+'&Ounces='+ounces+'&Size='+size; if (additional != null && additional != '') { pars += '&' + additional; } pars += '&date='+Date(); new Ajax.Request(daDomain+'/blimda/cart/GetUSPSRateByParams.asp', { parameters: pars, method: 'GET', asynchronous: false, onSuccess: function(a){ rate = a.responseText; }, onFailure: function(a){ alert(a.responseText); rate = null; } }); return rate; } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function checkoutForm(formID, divID) { var formObj = validateAParticularForm(formID); if(formObj == null) { alert('Error: Check formID'); return false; } if(!formObj.isValid) { displayErrors(formObj); } else { checkoutFormInsert(formID, '/blimda/Cart/CheckoutFormInsert.asp', divID); } } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function checkoutFormInsert(formID, actionPage, divID) { var jsonResult = ""; var serializedParams = Form.serializeElements( $(formID).getElements() ); var pars = serializedParams; new Ajax.Request(daDomain+actionPage, { parameters: pars, asynchronous: false, method: 'get', onSuccess: function(a){jsonResult = "{'successfulInsert':true, 'message':' '}".evalJSON();}, onFailure: function(a){alert(a.responseText); jsonResult = "{'successfulInsert':false, 'message':'There was an error when processing your form.'}".evalJSON();} }); if(jsonResult.successfulInsert) { $(divID).update('

Thank you for your submission. A confirmation number has been sent to your E-mail address. You will be able to view your purchase with this confirmation number."

'); } else { alert("An error occurred during form submission. If the problem persists, contact the website administrator."); } } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function cartLogin(confirmationNumber) { var success; var pars = 'confirmationNumber='+confirmationNumber+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/Cart/CartLogin.asp', { parameters: pars, asynchronous: false, onSuccess: function(a){success = a.responseText; }, onFailure: function(a){alert("Server Error. Try Again."); alert(a.responseText);} }); return success; } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function clearCart(id) { var pars = 'id='+id+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/Cart/ClearCart.asp', { parameters: pars, asynchronous: false, onSuccess: function(a){}, onFailure: function(a){alert("Server Error. Try Again."); alert(a.responseText);} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function adjustCartItem(id, productID, quantity) { var pars = 'id='+id+'&productID='+productID+'&quantity='+quantity+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/Cart/AdjustCartItem.asp', { parameters: pars, asynchronous: false, onSuccess: function(a){}, onFailure: function(a){alert("Server Error. Try Again."); alert(a.responseText);} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function setCartItem(id, productID, quantity) { var pars = 'id='+id+'&productID='+productID+'&quantity='+quantity+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/Cart/SetCartItem.asp', { parameters: pars, asynchronous: false, onSuccess: function(a){}, onFailure: function(a){alert("Server Error. Try Again."); alert(a.responseText);} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function viewCart(id, divID) { var pars = 'id='+id+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/Cart/ViewCart.asp', // URL { // options method:'get', parameters: pars, asynchronous: false, onSuccess: function(a){}, onFailure: function(a){alert(a.responseText); success = false;} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**///PathChooser(ByVal inputID, ByVal inputName, ByVal inputClass, ByVal inputStyle, ByVal attributes, ByVal valueType, ByVal displayType, ByVal rootPathRelative, ByVal allowFiles, ByVal arrExtensionsInclude, ByVal arrExtensionsExclude, ByVal divID) function pathChooser(inputID, inputName, inputClass, inputStyle, attributes, valueType, displayType, rootPathRelative, allowFiles, arrExtensionsInclude, arrExtensionsExclude, divID) { inputID = escape(inputID); inputName = escape(inputName); inputClass = escape(inputClass); inputStyle = escape(inputStyle); attributes = escape(attributes); valueType = escape(valueType); displayType = escape(displayType); rootPathRelative = escape(rootPathRelative); allowFiles = escape(allowFiles); arrExtensionsInclude = escape(arrExtensionsInclude); arrExtensionsExclude = escape(arrExtensionsExclude); divID = escape(divID); var pars = 'inputID='+inputID+'&inputName='+inputName+'&inputClass='+inputClass+'&inputStyle='+inputStyle+'&attributes='+attributes+'&valueType='+valueType+'&displayType='+displayType+'&rootPathRelative='+rootPathRelative+'&allowFiles='+allowFiles+'&arrExtensionsInclude='+arrExtensionsInclude+'&arrExtensionsExclude='+arrExtensionsExclude+'&divID='+divID+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/Galleries/PathChooser.asp', // URL { // options method:'get', parameters: pars, asynchronous: false, onSuccess: function(a){}, onFailure: function(a){alert(a.responseText); success = false;} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ //PathChooser2(ByVal inputID, ByVal inputName, ByVal inputClass, ByVal inputStyle, ByVal attributes, ByVal valueType, ByVal displayType, ByVal rootPathRelative, ByVal allowFiles, ByVal arrExtensionsInclude, ByVal arrExtensionsExclude, ByVal stopPathRelative, ByVal onlyNews, ByVal divID) function pathChooser2(inputID, inputName, inputClass, inputStyle, attributes, valueType, displayType, rootPathRelative, allowFiles, arrExtensionsInclude, arrExtensionsExclude, stopPathRelative, onlyNews, divID) { inputID = escape(inputID); inputName = escape(inputName); inputClass = escape(inputClass); inputStyle = escape(inputStyle); attributes = escape(attributes); valueType = escape(valueType); displayType = escape(displayType); rootPathRelative = escape(rootPathRelative); allowFiles = escape(allowFiles); arrExtensionsInclude = escape(arrExtensionsInclude); arrExtensionsExclude = escape(arrExtensionsExclude); stopPathRelative = escape(stopPathRelative); onlyNews = escape(onlyNews); divID = escape(divID); var pars = 'inputID='+inputID+'&inputName='+inputName+'&inputClass='+inputClass+'&inputStyle='+inputStyle+'&attributes='+attributes+'&valueType='+valueType+'&displayType='+displayType+'&rootPathRelative='+rootPathRelative+'&allowFiles='+allowFiles+'&arrExtensionsInclude='+arrExtensionsInclude+'&arrExtensionsExclude='+arrExtensionsExclude+'&stopPathRelative='+stopPathRelative+'&onlyNews='+onlyNews+'&divID='+divID+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/Galleries/PathChooser2.asp', // URL { // options method:'get', parameters: pars, asynchronous: false, onSuccess: function(a){}, onFailure: function(a){alert(a.responseText); success = false;} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function uploadForm(divID) { var pars = 'divID='+divID+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/Uploader/UploadForm.asp', // URL { // options method:'get', parameters: pars, asynchronous: false, onSuccess: function(a){}, onFailure: function(a){alert(a.responseText); success = false;} }); } function fileUpload(form, action_url, div_id) { // Create the iframe... var iframe = document.createElement("iframe"); iframe.setAttribute("id", "upload_iframe"); iframe.setAttribute("name", "upload_iframe"); // iframe.setAttribute("width", "0"); // iframe.setAttribute("height", "0"); // iframe.setAttribute("border", "0"); // iframe.setAttribute("style", "width: 0; height: 0; border: none;"); // Add to document... form.parentNode.appendChild(iframe); window.frames['upload_iframe'].name="upload_iframe"; iframeId = document.getElementById("upload_iframe"); // Add event... var eventHandler = function() { if (iframeId.detachEvent) { iframeId.detachEvent("onload", eventHandler); } else { iframeId.removeEventListener("load", eventHandler, false); } // Message from server... if (iframeId.contentDocument) { content = iframeId.contentDocument.body.innerHTML; } else if (iframeId.contentWindow) { content = iframeId.contentWindow.document.body.innerHTML; } else if (iframeId.document) { content = iframeId.document.body.innerHTML; } document.getElementById(div_id).innerHTML = content; // Del the iframe... // setTimeout('iframeId.parentNode.removeChild(iframeId)', 250); } if (iframeId.addEventListener) { iframeId.addEventListener("load", eventHandler, true); } if (iframeId.attachEvent) { iframeId.attachEvent("onload", eventHandler); } // Set properties of form... form.setAttribute("target", "upload_iframe"); form.setAttribute("action", daDomain + action_url); form.setAttribute("method", "post"); form.setAttribute("enctype", "multipart/form-data"); form.setAttribute("encoding", "multipart/form-data"); // Submit the form... form.submit(); document.getElementById(div_id).innerHTML = "Uploading..."; }function archivePoll(spotID, pageID) { pageID = escape(pageID); if (pageID.charAt(0) != "/") { pageID = "/" + pageID; } var pars = 'spotID='+spotID+'&pageID='+pageID+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/QuickSurvey/ArchivePoll.asp', { parameters: pars, asynchronous: false, onSuccess: function(a){}, onFailure: function(a){alert("Server Error. Try Again."); alert(a.responseText);} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function chooseQuickSurveyAnswer(newsID, choiceNumber) { var pars = 'newsID='+newsID+'&choiceNumber='+choiceNumber+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/QuickSurvey/ChooseQuickSurveyAnswer.asp', { parameters: pars, asynchronous: false, onSuccess: function(a){}, onFailure: function(a){alert("Server Error. Try Again."); alert(a.responseText);} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function formatForQuickSurvey(newsID, dType, dType2, noMoreVoting, divID) { var pars = 'newsID='+newsID+'&dType='+dType+'&dType2='+dType2+'&noMoreVoting='+noMoreVoting+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/QuickSurvey/FormatForQuickSurvey.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function formatForQuickSurveyResults(newsID, dType, dType2, noMoreVoting, divID) { var pars = 'newsID='+newsID+'&dType='+dType+'&dType2='+dType2+'&noMoreVoting='+noMoreVoting+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/QuickSurvey/FormatForQuickSurveyResults.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/function isNumeric(val) { return !(isNaN(parseFloat(val))); } function makeElementList(arrList) { var strReturn; strReturn = ""; if (arrList.length - 1 == 0) { //There should be more than one element in a group, but... strReturn = getElementDisplayName(arrList[0]); } else if (arrList.length - 1 == 1) { //Only two elements in the group. strReturn = getElementDisplayName(arrList[0]) + ' or ' + getElementDisplayName(arrList[1]); } else { //More than two elements in the group. for (var i = 0; i < arrList.length - 1; i++) { strReturn += getElementDisplayName(arrList[i]) + ', '; } strReturn += 'or ' + getElementDisplayName(arrList[arrList.length - 1]); } return strReturn; } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function getGroupClass(element, generalGroup) { var classList; var groupClass; var re = new RegExp("group[\\d]", "gi"); classList = $(element).className; // classList = 'groupNotEmpty group1'; groupClass = re.exec(classList); return groupClass; } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function getElementDisplayName(element) { if (element == 'undefined' || !(element)) { return ''; } if ($(element).readAttribute('title') != null) { return $(element).readAttribute('title'); } else if ($(element).readAttribute('name') != null) { return $(element).readAttribute('name'); } else if ($(element).readAttribute('id') != null) { return $(element).readAttribute('id'); } else { return ''; } } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function serializeNonForm(elements, options) { if (typeof options != 'object') options = { hash: !!options }; else if (options.hash === undefined) options.hash = true; var key, value, submitted = false, submit = options.submit; var data = elements.inject({ }, function(result, element) { if (!element.disabled && element.name) { key = element.name; value = $(element).getValue(); if (value != null && (element.type != 'submit' || (!submitted && submit !== false && (!submit || key == submit) && (submitted = true)))) { if (key in result) { // a key is already present; construct an array of values if (!Object.isArray(result[key])) result[key] = [result[key]]; result[key].push(value); } else result[key] = value; } } return result; }); // return options.hash ? data : Hash.toQueryString(data); return Hash.toQueryString(data); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function getElementsOfNonForm(form) { return $A($(form).getElementsByTagName('*')).inject([], function(elements, child) { if (Form.Element.Serializers[child.tagName.toLowerCase()]) elements.push(Element.extend(child)); return elements; } ); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function radioIsSelected(radioGroupName) { return ( GetRadioVal(radioGroupName) != '' ); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function isDate(sDate) { var re = /^\d{1,2}\/\d{1,2}\/\d{4}$/ if (re.test(sDate)) { var dArr = sDate.split("/"); var d = new Date(sDate); return d.getMonth() + 1 == dArr[0] && d.getDate() == dArr[1] && d.getFullYear() == dArr[2]; } else { return false; } } /**--------------------------------------------------------------------------------------------------------**/ /**--------------------------------------------------------------------------------------------------------**/ function GetRadioVal(radioGroupName) { return $$("input:checked[type='radio'][name='"+radioGroupName+"']").pluck("value"); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function getRandomString() { var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; var string_length = 6; var randomstring = ''; for (var i=0; i 0); } else { return false; } } /**--------------------------------------------------------------------------------------------------------**/ /**--------------------------------------------------------------------------------------------------------**/ function isAtLeastLength(val, minLength) { return (val.length >= minLength); } /**--------------------------------------------------------------------------------------------------------**/ /**--------------------------------------------------------------------------------------------------------**/ function isAtLeastValue(val, minValue) { return (val >= minValue); } /**--------------------------------------------------------------------------------------------------------**/ /**--------------------------------------------------------------------------------------------------------**/ function isEmail(val) { if(val==''){ return true; } var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; // var emailRegEx = /^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,2}$/; return emailRegEx.test(val); } /**--------------------------------------------------------------------------------------------------------**/ /**--------------------------------------------------------------------------------------------------------**/ function isAuthorFieldUnique(fieldName, val) { var jsonResult = "helllllo"; // var jsonResult = null; var pars = 'fieldName='+fieldName+'&val='+val+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/AutoForm/IsAuthorFieldUnique.asp', { parameters: pars, asynchronous: false, onSuccess: function(theResponse){jsonResult = theResponse.responseText.evalJSON();}, onFailure: function(theResponse){alert("Server error. Try again."); alert(theResponse.responseText);} }); return jsonResult; } /**--------------------------------------------------------------------------------------------------------**/ /**--------------------------------------------------------------------------------------------------------**/ function isAuthorNameUnique(val1, val2) { var jsonResult = null; var pars = 'val1='+val1+'&val2='+val2+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/AutoForm/IsAuthorNameUnique.asp', { parameters: pars, asynchronous: false, onSuccess: function(theResponse){jsonResult = theResponse.responseText.evalJSON();}, onFailure: function(theResponse){alert("Server error. Try again.");} }); return jsonResult; } /**--------------------------------------------------------------------------------------------------------**/ /**--------------------------------------------------------------------------------------------------------**/ function isEntityFieldUnique(fieldName, val) { var jsonResult = null; var pars = 'fieldName='+fieldName+'&val='+val+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/AutoForm/IsEntityFieldUnique.asp', { parameters: pars, asynchronous: false, onSuccess: function(theResponse){jsonResult = theResponse.responseText.evalJSON();}, onFailure: function(theResponse){alert("Server error. Try again.");} }); return jsonResult; } /**--------------------------------------------------------------------------------------------------------**/ /**--------------------------------------------------------------------------------------------------------**/ function isAuthorFieldUniqueNotSelf(fieldName, val, primKeyVal) { var jsonResult = null; var pars = 'fieldName='+fieldName+'&val='+val+'&primKeyVal='+primKeyVal+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/AutoForm/IsAuthorFieldUniqueNotSelf.asp', { parameters: pars, asynchronous: false, onSuccess: function(theResponse){jsonResult = theResponse.responseText.evalJSON();}, onFailure: function(theResponse){alert("Server error. Try again.");} }); return jsonResult; } /**--------------------------------------------------------------------------------------------------------**/ /**--------------------------------------------------------------------------------------------------------**/ function isAuthorNameUniqueNotSelf(val1, val2, primKeyVal) { var jsonResult = null; var pars = 'val1='+val1+'&val2='+val2+'&primKeyVal='+primKeyVal+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/AutoForm/IsAuthorNameUniqueNotSelf.asp', { parameters: pars, asynchronous: false, onSuccess: function(theResponse){jsonResult = theResponse.responseText.evalJSON();}, onFailure: function(theResponse){alert("Server error. Try again.");} }); return jsonResult; } /**--------------------------------------------------------------------------------------------------------**/ /**--------------------------------------------------------------------------------------------------------**/ function isEntityFieldUniqueNotSelf(fieldName, val, primKeyVal) { var jsonResult = null; var pars = 'fieldName='+fieldName+'&val='+val+'&primKeyVal='+primKeyVal+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/AutoForm/IsEntityFieldUniqueNotSelf.asp', { parameters: pars, asynchronous: false, onSuccess: function(theResponse){jsonResult = theResponse.responseText.evalJSON();}, onFailure: function(theResponse){alert("Server error. Try again.");} }); return jsonResult; } /**--------------------------------------------------------------------------------------------------------**/ /**--------------------------------------------------------------------------------------------------------**/ function atLeastChecked(checkGroupName, min) { var numChecked = 0; $$('input[name='+checkGroupName+'][type=checkbox]').each(function(aCheckbox) {if (aCheckbox.checked){numChecked++;}}); return (numChecked >= min); } /**--------------------------------------------------------------------------------------------------------**/ /**--------------------------------------------------------------------------------------------------------**/ function handleAParticularForm(formID, actionPage, divID) { var jsonResult = ""; var serializedParams = Form.serializeElements( $(formID).getElements() ); var pars = serializedParams; new Ajax.Request(daDomain+actionPage, { parameters: pars, asynchronous: false, method: 'get', onSuccess: function(theResponse){jsonResult = theResponse.responseText.evalJSON();}, onFailure: function(theResponse){jsonResult = "{'successfulInsert':false, 'message':'There was an error when processing your form.'}".evalJSON();} }); if(jsonResult.successfulInsert) { $(divID).update(jsonResult.message) } else { $(divID).update(jsonResult.message); } return false; } /**--------------------------------------------------------------------------------------------------------**/ /**--------------------------------------------------------------------------------------------------------**/ function joinFormWrapper(formID) { var formObj = validateAParticularForm(formID); if(formObj == null) { alert('Error: Check formID'); return false; } if(!formObj.isValid) { displayErrors(formObj); } else { alert('congrats. valid form.'); } } /**--------------------------------------------------------------------------------------------------------**/ /**--------------------------------------------------------------------------------------------------------**/ function validateAParticularForm(formID) { var myForm; var myTruths; var shouldContinue = true; var serializedParams var jsonText; var ElGroup; var classList; var groupClass; if ($(formID).tagName.toLowerCase() == 'form') { myForm = $(formID).getElements(); myForm = $A(myForm); } else { myForm = getElementsOfNonForm(formID); myForm = $A(myForm); } jsonText = "{\"elements\" : ["; myForm.each(function(formEl, i) { jsonText += " {\"element\" : \""+$(formEl).readAttribute('name')+"\" , "; if ($F(formEl) == null || $F(formEl) == '') { jsonText += " \"elementValue\" : \""+"\", "; } else { if ($F(formEl).indexOf("\n") > -1 || $F(formEl).indexOf("\r") > -1) { jsonText += " \"elementValue\" : \""+$F(formEl).replace(/\n/gi, "\\n").replace(/\r/gi, "\\r")+"\", "; } } if ($(formEl).readAttribute('title') != '' && $(formEl).readAttribute('title') != null) { jsonText += " \"elementTitle\" : \""+$(formEl).readAttribute('title')+"\", "; } else { jsonText += " \"elementTitle\" : \""+formEl.name+"\", "; } jsonText += " \"errors\" : ["; if ($(formEl).hasClassName('isDate')) { if (!isDate($F(formEl))) { jsonText += "\"isDate\","; shouldContinue = false; } } if ($(formEl).hasClassName('isNumeric')) { if (!isNumeric($F(formEl))) { jsonText += "\"isNumeric\","; shouldContinue = false; } } if ($(formEl).hasClassName('entitynameUnique')) { if (!isEntityFieldUnique("entityname", $F(formEl)).isUnique) { jsonText += "\"entitynameUnique\","; shouldContinue = false; } } if ($(formEl).hasClassName('authoremailUnique')) { if (!isAuthorFieldUnique("authoremail", $F(formEl)).isUnique) { jsonText += "\"authoremailUnique\","; shouldContinue = false; } } if ($(formEl).hasClassName('usernameUnique')) { if (!isAuthorFieldUnique("username", $F(formEl)).isUnique) { jsonText += "\"usernameUnique\","; shouldContinue = false; } } if ($(formEl).hasClassName('isNotEmpty')) { if ($(formEl).type == 'radio') { if ( !radioIsSelected($(formEl).readAttribute('name')) ) { jsonText += "\"isNotEmpty\","; shouldContinue = false; } } else { if ( !isNotEmpty($F(formEl)) ) { jsonText += "\"isNotEmpty\","; shouldContinue = false; } } } if ($(formEl).hasClassName('isEmail')) { if (!isEmail($F(formEl))) { jsonText += "\"isEmail\","; shouldContinue = false; } } if ($(formEl).hasClassName('atLeastChecked')) { //$w(formEl.className) if (!atLeastChecked(formEl.name, 1)) { jsonText += "\"atLeastChecked\","; shouldContinue = false; } } if ($(formEl).hasClassName('isConfirmation')) { var otherEl = $(formID).select("[name="+formEl.name.replace('confirm', '')+"]")[0]; if($F(otherEl) != $F(formEl)) { jsonText += "\"isConfirmation\","; shouldContinue = false; } } if ($(formEl).hasClassName('groupNotEmpty')) { var re = new RegExp("group[\\d]", "gi"); classList = $(formEl).className; groupClass = re.exec(classList); if ( $(formID).select('groupNotEmpty', '.'+groupClass).find( function(i){return $(i).present();} ) == null ) { jsonText += "\"groupNotEmpty\","; shouldContinue = false; } } if ($(formEl).hasClassName('emailIsFamiliar')) { if (isAuthorFieldUnique("authoremail", $F(formEl)).isUnique) { jsonText += "\"emailIsFamiliar\","; shouldContinue = false; } } if ($(formEl).hasClassName('usernameIsFamiliar')) { if (isAuthorFieldUnique("username", $F(formEl)).isUnique) { jsonText += "\"usernameIsFamiliar\","; shouldContinue = false; } } if (jsonText.charAt(jsonText.length-1) == ",") { jsonText = jsonText.substring(0, jsonText.length-1); } jsonText += " ]},"; }); if (jsonText.charAt(jsonText.length-1) == ",") { jsonText = jsonText.substring(0, jsonText.length-1); } jsonText += "],"; jsonText += "\"isValid\" : "+shouldContinue+","; jsonText += "\"formID\" : \""+formID+"\""; jsonText += "}" jsonText = jsonText.evalJSON(); // return false; return jsonText; } /**--------------------------------------------------------------------------------------------------------**/ /**--------------------------------------------------------------------------------------------------------**/ function displayErrors(formObj) { var errorMessages = new Array(); errorMessages["entitynameUnique"] = "Name already exists."; errorMessages["authoremailUnique"] = "E-mail already exists."; errorMessages["usernameUnique"] = "Username already exists."; errorMessages["isNotEmpty"] = " cannot be empty."; errorMessages["isEmail"] = "'' is not a valid email address."; errorMessages["atLeastChecked"] = "Must check at least one."; errorMessages["isConfirmation"] = " Confirmation mismatch."; errorMessages["groupNotEmpty"] = "Either must not be empty."; errorMessages["isDate"] = "'' is not a recognized date. Try using the format mm/dd/yyyy"; errorMessages["isNumeric"] = "'' is not a recognized number."; var errorMessageFormatted; var formEl; var groupMembers; var groupClass; var membersList; var formElNameSelector; var errorCountNameSelector; formObj.elements.each(function(formEl) { formElNameSelector = $(formObj.formID).select('[name='+formEl.element+'Warning'+']')[0]; if ($(formEl.element+'Warning') != null || $(formElNameSelector) != null) { // $(formEl.element+'Warning').update(''); $(formElNameSelector).update(''); formEl.errors.each(function(elerror) { if (elerror == 'groupNotEmpty') { groupClass = getGroupClass($(formObj.formID).select('[name='+formEl.element+']')[0], 'groupNotEmpty'); groupMembers = $(formObj.formID).select('.'+groupClass); membersList = makeElementList(groupMembers); } errorMessageFormatted = errorMessages[elerror].replace("", formEl.elementValue); errorMessageFormatted = errorMessageFormatted.replace("", formEl.elementTitle); errorMessageFormatted = errorMessageFormatted.replace("", membersList); // $(formEl.element+'Warning').insert(errorMessageFormatted + '
'); $(formElNameSelector).insert(errorMessageFormatted + '
'); }); } }); errorCountNameSelector = $(formObj.formID).select('[name=errorCount]')[0]; if ($('errorCount') != null || $(errorCountNameSelector) != null) { if( $('errorCount') ) { $('errorCount').update('There are '+countErroneousElements(formObj)+' errors in your form.'); } else if( $(errorCountNameSelector) ) { $(errorCountNameSelector).update('There are '+countErroneousElements(formObj)+' errors in your form.'); } } return false; } /**--------------------------------------------------------------------------------------------------------**/ /**--------------------------------------------------------------------------------------------------------**/ function countErrors(formObj) { var errorCount; errorCount = 0; if (formObj == null) { errorCount = -1 } formObj.elements.each(function(formEl) { errorCount += formEl.errors.length }); return errorCount; } /**--------------------------------------------------------------------------------------------------------**/ /**--------------------------------------------------------------------------------------------------------**/ function countErroneousElements(formObj) { var errorCount; errorCount = 0; if (formObj == null) { errorCount = -1 } formObj.elements.each(function(formEl) { if (formEl.errors.length > 0) { errorCount += 1 } }); return errorCount; } /**--------------------------------------------------------------------------------------------------------**/ /**--------------------------------------------------------------------------------------------------------**/function setAuthorContest(authorID, contestID, lockValue) { var success = 'j'; var pars = 'authorID='+authorID+'&contestID='+contestID+'&lockValue='+lockValue+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/Contests/SetAuthorContest.asp', { parameters: pars, asynchronous: false, onSuccess: function(a){success = true;}, onFailure: function(a){alert(a.responseText); success = false;} }); return success; } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function setAuthorCategoryContest(authorID, categoryID, contestID, lockValue) { var success = 'j'; var pars = 'authorID='+authorID+'&categoryID='+categoryID+'&contestID='+contestID+'&lockValue='+lockValue+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/Contests/SetAuthorCategoryContest.asp', { parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function addAuthorCategoryContest(authorID, categoryID, contestID) { var success = 'j'; var pars = 'authorID='+authorID+'&categoryID='+categoryID+'&contestID='+contestID+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/Contests/AddAuthorCategoryContest.asp', { parameters: pars, asynchronous: false // onSuccess: function(a){success = a.responseText;}, // onFailure: function(a){alert(a.responseText); success = false;} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function moveThing(thingID, thingType, categoryID, contestID, offset) { var success = 'j'; var pars = 'thingID='+thingID+'&thingType='+thingType+'&categoryID='+categoryID+'&contestID='+contestID+'&offset='+offset+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/Contests/MoveThing.asp', { parameters: pars, asynchronous: false // onSuccess: function(a){alert(a.responseText);}, // onFailure: function(a){alert(a.responseText); success = false;} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function castVote(thingID, thingType, categoryID, contestID, voteAmount, authorID) { var pars = 'thingID='+thingID+'&thingType='+thingType+'&categoryID='+categoryID+'&contestID='+contestID+'&voteAmount='+voteAmount+'&authorID='+authorID+'&date='+Date(); ajax = new Ajax.Updater( '', daDomain+'/blimda/Contests/CastVote.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function editVote(voteID, newAmount) { var pars = 'voteID='+voteID+'&newAmount='+newAmount+'&date='+Date(); ajax = new Ajax.Updater( '', daDomain+'/blimda/Contests/EditVote.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function removeVote(voteID) { var pars='voteID='+voteID+'&date='+Date(); ajax = new Ajax.Updater( '', daDomain+'/blimda/Contests/RemoveVote.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function conditionalCastVote(thingID, thingType, categoryID, contestID, voteAmount, authorID) { var pars = 'thingID='+thingID+'&thingType='+thingType+'&categoryID='+categoryID+'&contestID='+contestID+'&voteAmount='+voteAmount+'&authorID='+authorID+'&date='+Date(); ajax = new Ajax.Updater( '', daDomain+'/blimda/Contests/ConditionalCastVote.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function toggleCategoryContest(categoryID, contestID) { var pars = 'categoryID='+categoryID+'&contestID='+contestID+'&date='+Date(); ajax = new Ajax.Updater( '', daDomain+'/blimda/Contests/ToggleCategoryContest.asp', // URL { // options method:'get', parameters: pars, onFailure: function(a){ alert(a.responseText); }, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function addContest(contestName, contestStartDate, contestStopDate) { var pars = 'contestName='+contestName+'&contestStartDate='+contestStartDate+'&contestStopDate='+contestStopDate+'&date='+Date(); ajax = new Ajax.Updater( '', daDomain+'/blimda/Contests/AddContest.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function addContestWithCategories(contestName, contestStartDate, contestStopDate, categories) { var pars = 'contestName='+contestName+'&contestStartDate='+contestStartDate+'&contestStopDate='+contestStopDate+'&categories='+categories+'&date='+Date(); ajax = new Ajax.Updater( '', daDomain+'/blimda/Contests/AddContestWithCategories.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function addCategory(categoryName) { var pars = 'categoryName='+categoryName+'&date='+Date(); ajax = new Ajax.Updater( '', daDomain+'/blimda/Contests/AddCategory.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function addAndAssociateCategory(categoryName, contestID) { var pars = 'categoryName='+categoryName+'&contestID='+contestID+'&date='+Date(); ajax = new Ajax.Updater( '', daDomain+'/blimda/Contests/AddAndAssociateCategory.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function toggleTCCAssociation(thingID, thingType, categoryID, contestID) { var pars = 'thingID='+thingID+'&thingType='+thingType+'&categoryID='+categoryID+'&contestID='+contestID+'&date='+Date(); ajax = new Ajax.Updater( '', daDomain+'/blimda/Contests/ToggleTCCAssociation.asp', // URL { // options method:'get', parameters: pars, onFailure: function(a){ alert(a.responseText); }, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function selectCategoriesForm(contestID) { var pars = 'contestID='+contestID+'&date='+Date(); ajax = new Ajax.Updater( '', daDomain+'/blimda/Contests/SelectCategoriesForm.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function categoryChooser(thingID, thingType, contestID, divID) { var pars = 'thingID='+thingID+'&thingType='+thingType+'&contestID='+contestID+'&divID='+divID+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/Contests/CategoryChooser.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function getScore(thingID, thingType, categoryID, contestID, divID) { var pars = 'thingID='+thingID+'&thingType='+thingType+'&categoryID='+categoryID+'&contestID='+contestID+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/Contests/GetScore.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function showElementContestForm(elementID, categoryID, contestID, divID) { var pars = 'elementID='+elementID+'&categoryID='+categoryID+'&contestID='+contestID+'&divID='+divID+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/Contests/ShowElementContestForm.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/function passwordAssistanceForm(formID) { var formObj = validateAParticularForm(formID); if(formObj == null) { alert('Error: Check formID'); return false; } if(!formObj.isValid) { displayErrors(formObj); return false; } else { return true; } } function doLogout() { var success; var pars = 'date='+Date(); new Ajax.Request(daDomain+'/blimda/Login/Logout.asp', { parameters: pars, asynchronous: false, onSuccess: function(a){success = true;}, onFailure: function(a){success = false;} }); return success; } function removeFromUsersNow() { if (window.event.clientX < 0 && window.event.clientY < 0) { var pars = 'date='+Date(); new Ajax.Request(daDomain+'/blimda/Login/RemoveFromUsersNow.asp', { parameters: pars, asynchronous: false }); } } function addToUsersNow() { var pars = 'date='+Date(); new Ajax.Request(daDomain+'/blimda/Login/AddToUsersNow.asp', { parameters: pars, asynchronous: false }); } function rememberUsername(shouldRemember, username) { var pars = 'shouldRemember='+shouldRemember+'&username='+username+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/Login/RememberUsername.asp', { parameters: pars, asynchronous: false }); } function doLogin(username, password) { if (username.length == 0 || password.length == 0) { return "{'isValid' : false}".evalJSON(); } else { var shouldContinue = false; var json; var pars = 'username='+username+'&password='+password+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/Login/ValidateAndPersist.asp', { parameters: pars, asynchronous: false, onSuccess: function(theResponse){json = theResponse.responseText.evalJSON();}, onFailure: function(theResponse){json = false;} }); return json; } } function loginBy(username, password) { username = escape(username); password = escape(password); var userJSON = doLogin(username, password); if (!userJSON) { $('loginErrors').update('Server error. Please try again or contact the administrator.'); return false; } if (userJSON.isValid) { return true; } else { if($F('username') == '' || $F('password') == '') { $('loginErrors').update('Username and password both required.'); } //If username isn't in DB... else if(isAuthorFieldUnique('username', $F('username')).isUnique && $F('username') != '') { $('loginErrors').update('Username not recognized.'); } //If username is in DB but still fails (due to password) else if (!isAuthorFieldUnique('username', $F('username')).isUnique) { $('loginErrors').update('Invalid password.'); } else { $('loginErrors').update('Invalid username and/or password.'); } return false; } }function QA_addAndAssociateCategory(categoryName, contestID) { categoryName = escape(categoryName); if (categoryName.length == '') { alert('Category name cannot be empty.'); return false; } var success = 'j'; var pars = 'categoryName='+categoryName+'&contestID='+contestID+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/QuestionAnswer/AddAndAssociateCategory.asp', { parameters: pars, asynchronous: false, onSuccess: function(a){success = a.responseText;}, onFailure: function(a){alert(a.responseText); success = false;} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function QA_addContest(contestName, startDate, stopDate) { contestName = escape(contestName); startDate = escape(startDate); stopDate = escape(stopDate); if (contestName.length == '') { alert('Contest name cannot be empty.'); return false; } var success = 'j'; var pars = 'contestName='+contestName+'&startDate='+startDate+'&stopDate='+stopDate+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/QuestionAnswer/AddContest.asp', { parameters: pars, asynchronous: false, onSuccess: function(a){success = a.responseText;}, onFailure: function(a){alert(a.responseText); success = false;} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function deleteQuestionAnswer(questionID, answerID) { var success = 'j'; var pars = 'questionID='+questionID+'&answerID='+answerID+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/QuestionAnswer/DeleteQuestionAnswer.asp', { parameters: pars, asynchronous: false // onSuccess: function(a){alert(a.responseText);}, // onFailure: function(a){alert(a.responseText); success = false;} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function moveAnswer(answerID, questionID, offset) { var success = 'j'; var pars = 'answerID='+answerID+'&questionID='+questionID+'&offset='+offset+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/QuestionAnswer/MoveAnswer.asp', { parameters: pars, asynchronous: false // onSuccess: function(a){alert(a.responseText);}, // onFailure: function(a){alert(a.responseText); success = false;} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function setCorrectAnswer(questionID, answerID) { var success = 'j'; var pars = 'questionID='+questionID+'&answerID='+answerID+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/QuestionAnswer/SetCorrectAnswer.asp', { parameters: pars, asynchronous: false // onSuccess: function(a){success = a.responseText;}, // onFailure: function(a){alert(a.responseText); success = false;} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function addAndAssociateQuestion(questionText, categoryID, contestID) { questionText = escape(questionText); var success = 'j'; var pars = 'questionText='+questionText+'&categoryID='+categoryID+'&contestID='+contestID+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/QuestionAnswer/AddAndAssociateQuestion.asp', { parameters: pars, asynchronous: false // onSuccess: function(a){success = a.responseText;}, // onFailure: function(a){alert(a.responseText); success = false;} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function addAndAssociateAnswer(answerText, questionID) { answerText = escape(answerText); var success = 'j'; var pars = 'answerText='+answerText+'&questionID='+questionID+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/QuestionAnswer/AddAndAssociateAnswer.asp', { parameters: pars, asynchronous: false // onSuccess: function(a){success = a.responseText;}, // onFailure: function(a){alert(a.responseText); success = false;} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function toggleQuestionAnswer(questionID, answerID) { var success = 'j'; var pars = 'questionID='+questionID+'&answerID='+answerID+'&date='+Date(); new Ajax.Request(daDomain+'/blimda/QuestionAnswer/ToggleQuestionAnswer.asp', { parameters: pars, asynchronous: false // onSuccess: function(a){success = a.responseText;}, // onFailure: function(a){alert(a.responseText); success = false;} }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function showQuestion(questionID, categoryID, contestID, divID) { var pars = 'questionID='+questionID+'&categoryID='+categoryID+'&contestID='+contestID+'&divID='+divID+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/QuestionAnswer/ShowQuestion.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function showCategoryOfQuestions(categoryID, contestID, baseUrl, divID) { var pars = 'categoryID='+categoryID+'&contestID='+contestID+'&baseUrl='+baseUrl+'&divID='+divID+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/QuestionAnswer/ShowCategoryOfQuestions.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function showCategoryReport(categoryID, contestID, baseUrl, divID) { var pars = 'categoryID='+categoryID+'&contestID='+contestID+'&baseUrl='+baseUrl+'&divID='+divID+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/QuestionAnswer/ShowCategoryReport.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function showTestResults(contestID, baseUrl, divID) { var pars = 'contestID='+contestID+'&baseUrl='+baseUrl+'&divID='+divID+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/QuestionAnswer/ShowTestResults.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function questionAnswerAdminCategory(categoryID, contestID, divID) { var pars = 'categoryID='+categoryID+'&contestID='+contestID+'&divID='+divID+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/QuestionAnswer/QuestionAnswerAdminCategory.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/ function questionAnswerAdmin(contestID, divID) { var pars = 'contestID='+contestID+'&divID='+divID+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/QuestionAnswer/QuestionAnswerAdmin.asp', // URL { // options method:'get', parameters: pars, asynchronous: false }); } /**------------------------------------------------------------------------------------------------------------------------------------**/ /**------------------------------------------------------------------------------------------------------------------------------------**/var myExecuter; document.observe("dom:loaded", function() { $$('div.periodicalUpdater').each(function(hiddenDiv){ var divToUpdate; var listOfRandomSpots; var arrRandomSpots; var rotatorSpot; var listOfPars; var chosenRandomSpot; var currentIndex; var myMatch; var currentSpot; currentIndex = 0; divToUpdate = $F($(hiddenDiv).select('[name="divToUpdate"]')[0]); listOfRandomSpots = $F($(hiddenDiv).select('[name="listOfRandomSpots"]')[0]); arrRandomSpots = listOfRandomSpots.split(","); for (var i = 0; i < arrRandomSpots.length; i++) { arrRandomSpots[i] = trim(arrRandomSpots[i]); } rotatorSpot = $F($(hiddenDiv).select('[name="rotatorSpot"]')[0]); var regex = new RegExp("^rotateCandidate([0-9]+)For"+rotatorSpot+"$"); // currentIndex = $(hiddenDiv).select('.rotateCandidate [display!="none"]')[0].readAttribute('id').match(regex).$1; // alert(currentIndex); $(hiddenDiv).select('.rotateCandidate').each(function(abc){ if ($(abc).visible()) { myMatch = regex.exec($(abc).readAttribute('id')); currentSpot = myMatch[1]; } }); for (var c = 0; c < arrRandomSpots.length; c++) { if (arrRandomSpots[c] == currentSpot) { currentIndex = c; } } myExecuter = new PeriodicalExecuter(function(pe){ // $(hiddenDiv).select('.rotateCandidate').invoke('hide'); currentIndex = (currentIndex + 1) % arrRandomSpots.length; chosenRandomSpot = arrRandomSpots[(currentIndex)]; $(hiddenDiv).select('.rotateCandidate').invoke('fade'); var appearDelay = function() { $('rotateCandidate'+chosenRandomSpot+'For'+rotatorSpot).appear({duration: 2.0}); } appearDelay.delay(1.5); $(hiddenDiv).select('div.PageTurner ul li img').invoke('removeClassName', 'pageTurnerSelected'); $(hiddenDiv).select('div.PageTurner ul li span').invoke('removeClassName', 'pageTurnerSelected'); $(hiddenDiv).select('div.PageTurner ul li div').invoke('removeClassName', 'pageTurnerSelected'); $(hiddenDiv).select('div.PageTurner ul li div').invoke('removeClassName', 'pageTurnerNotSelected'); $(hiddenDiv).select('div.PageTurner ul li div').invoke('addClassName', 'pageTurnerNotSelected'); $(hiddenDiv).select('div.PageTurner ul li img').invoke('addClassName', 'pageTurnerNotSelected'); $(hiddenDiv).select('div.PageTurner ul li span').invoke('addClassName', 'pageTurnerNotSelected'); if ($('pageTurnerLiFor'+chosenRandomSpot+'Of'+rotatorSpot) != null) { // alert('pageTurnerLiFor'+chosenRandomSpot+'Of'+rotatorSpot + '.........' + $('pageTurnerLiFor'+chosenRandomSpot+'Of'+rotatorSpot)); $('pageTurnerLiFor'+chosenRandomSpot+'Of'+rotatorSpot).select('div').invoke('addClassName', 'pageTurnerSelected'); $('pageTurnerLiFor'+chosenRandomSpot+'Of'+rotatorSpot).select('img').invoke('addClassName', 'pageTurnerSelected'); $('pageTurnerLiFor'+chosenRandomSpot+'Of'+rotatorSpot).select('span').invoke('addClassName', 'pageTurnerSelected'); $('pageTurnerLiFor'+chosenRandomSpot+'Of'+rotatorSpot).select('div').invoke('removeClassName', 'pageTurnerNotSelected'); $('pageTurnerLiFor'+chosenRandomSpot+'Of'+rotatorSpot).select('img').invoke('removeClassName', 'pageTurnerNotSelected'); $('pageTurnerLiFor'+chosenRandomSpot+'Of'+rotatorSpot).select('span').invoke('removeClassName', 'pageTurnerNotSelected'); } }, 10); }); }); function showASpotForRotator(newsID, newsIDChosen, divID) { pars = 'newsID='+newsID+'&newsIDChosen='+newsIDChosen+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/NewSpots/ShowASpotForRotator.asp', // URL { // options method:'get', parameters: pars } ); } function showASpot(newsID, divID) { pars = 'newsID='+newsID+'&date='+Date(); ajax = new Ajax.Updater( divID, daDomain+'/blimda/NewSpots/ShowASpot.asp', // URL { // options method:'get', parameters: pars } ); } function newsReturn(newsOrder, pageSection, pageID, maxNews, newsStatus, GOdirection) { pars = 'newsOrder=' + newsOrder +'&pageSection=' + pageSection +'&pageID=' + pageID +'&maxNews='+maxNews+'&newsStatus=' + newsStatus +'&GOdirection=' + GOdirection +'&date='+Date(); ajax = new Ajax.Updater( pageSection+newsOrder, daDomain+'/blimda/newsAdmin/newsReturn.asp', // URL { // options method:'get', parameters: pars } ); }/*! SWFObject v2.2 is released under the MIT License */ var swfobject = function() { var UNDEF = "undefined", OBJECT = "object", SHOCKWAVE_FLASH = "Shockwave Flash", SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash", FLASH_MIME_TYPE = "application/x-shockwave-flash", EXPRESS_INSTALL_ID = "SWFObjectExprInst", ON_READY_STATE_CHANGE = "onreadystatechange", win = window, doc = document, nav = navigator, plugin = false, domLoadFnArr = [main], regObjArr = [], objIdArr = [], listenersArr = [], storedAltContent, storedAltContentId, storedCallbackFn, storedCallbackObj, isDomLoaded = false, isExpressInstallActive = false, dynamicStylesheet, dynamicStylesheetMedia, autoHideShow = true, /* Centralized function for browser feature detection - User agent string detection is only used when no good alternative is possible - Is executed directly for optimal performance */ ua = function() { var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF, u = nav.userAgent.toLowerCase(), p = nav.platform.toLowerCase(), windows = p ? /win/.test(p) : /win/.test(u), mac = p ? /mac/.test(p) : /mac/.test(u), webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html playerVersion = [0,0,0], d = null; if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) { d = nav.plugins[SHOCKWAVE_FLASH].description; if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+ plugin = true; ie = false; // cascaded feature detection for Internet Explorer d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1"); playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10); playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10); playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0; } } else if (typeof win.ActiveXObject != UNDEF) { try { var a = new ActiveXObject(SHOCKWAVE_FLASH_AX); if (a) { // a will return null when ActiveX is disabled d = a.GetVariable("$version"); if (d) { ie = true; // cascaded feature detection for Internet Explorer d = d.split(" ")[1].split(","); playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; } } } catch(e) {} } return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac }; }(), /* Cross-browser onDomLoad - Will fire an event as soon as the DOM of a web page is loaded - Internet Explorer workaround based on Diego Perini's solution: http://javascript.nwbox.com/IEContentLoaded/ - Regular onload serves as fallback */ onDomLoad = function() { if (!ua.w3) { return; } if ((typeof doc.readyState != UNDEF && doc.readyState == "complete") || (typeof doc.readyState == UNDEF && (doc.getElementsByTagName("body")[0] || doc.body))) { // function is fired after onload, e.g. when script is inserted dynamically callDomLoadFunctions(); } if (!isDomLoaded) { if (typeof doc.addEventListener != UNDEF) { doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, false); } if (ua.ie && ua.win) { doc.attachEvent(ON_READY_STATE_CHANGE, function() { if (doc.readyState == "complete") { doc.detachEvent(ON_READY_STATE_CHANGE, arguments.callee); callDomLoadFunctions(); } }); if (win == top) { // if not inside an iframe (function(){ if (isDomLoaded) { return; } try { doc.documentElement.doScroll("left"); } catch(e) { setTimeout(arguments.callee, 0); return; } callDomLoadFunctions(); })(); } } if (ua.wk) { (function(){ if (isDomLoaded) { return; } if (!/loaded|complete/.test(doc.readyState)) { setTimeout(arguments.callee, 0); return; } callDomLoadFunctions(); })(); } addLoadEvent(callDomLoadFunctions); } }(); function callDomLoadFunctions() { if (isDomLoaded) { return; } try { // test if we can really add/remove elements to/from the DOM; we don't want to fire it too early var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span")); t.parentNode.removeChild(t); } catch (e) { return; } isDomLoaded = true; var dl = domLoadFnArr.length; for (var i = 0; i < dl; i++) { domLoadFnArr[i](); } } function addDomLoadEvent(fn) { if (isDomLoaded) { fn(); } else { domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+ } } /* Cross-browser onload - Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/ - Will fire an event as soon as a web page including all of its assets are loaded */ function addLoadEvent(fn) { if (typeof win.addEventListener != UNDEF) { win.addEventListener("load", fn, false); } else if (typeof doc.addEventListener != UNDEF) { doc.addEventListener("load", fn, false); } else if (typeof win.attachEvent != UNDEF) { addListener(win, "onload", fn); } else if (typeof win.onload == "function") { var fnOld = win.onload; win.onload = function() { fnOld(); fn(); }; } else { win.onload = fn; } } /* Main function - Will preferably execute onDomLoad, otherwise onload (as a fallback) */ function main() { if (plugin) { testPlayerVersion(); } else { matchVersions(); } } /* Detect the Flash Player version for non-Internet Explorer browsers - Detecting the plug-in version via the object element is more precise than using the plugins collection item's description: a. Both release and build numbers can be detected b. Avoid wrong descriptions by corrupt installers provided by Adobe c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports - Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available */ function testPlayerVersion() { var b = doc.getElementsByTagName("body")[0]; var o = createElement(OBJECT); o.setAttribute("type", FLASH_MIME_TYPE); var t = b.appendChild(o); if (t) { var counter = 0; (function(){ if (typeof t.GetVariable != UNDEF) { var d = t.GetVariable("$version"); if (d) { d = d.split(" ")[1].split(","); ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; } } else if (counter < 10) { counter++; setTimeout(arguments.callee, 10); return; } b.removeChild(o); t = null; matchVersions(); })(); } else { matchVersions(); } } /* Perform Flash Player and SWF version matching; static publishing only */ function matchVersions() { var rl = regObjArr.length; if (rl > 0) { for (var i = 0; i < rl; i++) { // for each registered object element var id = regObjArr[i].id; var cb = regObjArr[i].callbackFn; var cbObj = {success:false, id:id}; if (ua.pv[0] > 0) { var obj = getElementById(id); if (obj) { if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) { // Flash Player version >= published SWF version: Houston, we have a match! setVisibility(id, true); if (cb) { cbObj.success = true; cbObj.ref = getObjectById(id); cb(cbObj); } } else if (regObjArr[i].expressInstall && canExpressInstall()) { // show the Adobe Express Install dialog if set by the web page author and if supported var att = {}; att.data = regObjArr[i].expressInstall; att.width = obj.getAttribute("width") || "0"; att.height = obj.getAttribute("height") || "0"; if (obj.getAttribute("class")) { att.styleclass = obj.getAttribute("class"); } if (obj.getAttribute("align")) { att.align = obj.getAttribute("align"); } // parse HTML object param element's name-value pairs var par = {}; var p = obj.getElementsByTagName("param"); var pl = p.length; for (var j = 0; j < pl; j++) { if (p[j].getAttribute("name").toLowerCase() != "movie") { par[p[j].getAttribute("name")] = p[j].getAttribute("value"); } } showExpressInstall(att, par, id, cb); } else { // Flash Player and SWF version mismatch or an older Webkit engine that ignores the HTML object element's nested param elements: display alternative content instead of SWF displayAltContent(obj); if (cb) { cb(cbObj); } } } } else { // if no Flash Player is installed or the fp version cannot be detected we let the HTML object element do its job (either show a SWF or alternative content) setVisibility(id, true); if (cb) { var o = getObjectById(id); // test whether there is an HTML object element or not if (o && typeof o.SetVariable != UNDEF) { cbObj.success = true; cbObj.ref = o; } cb(cbObj); } } } } } function getObjectById(objectIdStr) { var r = null; var o = getElementById(objectIdStr); if (o && o.nodeName == "OBJECT") { if (typeof o.SetVariable != UNDEF) { r = o; } else { var n = o.getElementsByTagName(OBJECT)[0]; if (n) { r = n; } } } return r; } /* Requirements for Adobe Express Install - only one instance can be active at a time - fp 6.0.65 or higher - Win/Mac OS only - no Webkit engines older than version 312 */ function canExpressInstall() { return !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac) && !(ua.wk && ua.wk < 312); } /* Show the Adobe Express Install dialog - Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75 */ function showExpressInstall(att, par, replaceElemIdStr, callbackFn) { isExpressInstallActive = true; storedCallbackFn = callbackFn || null; storedCallbackObj = {success:false, id:replaceElemIdStr}; var obj = getElementById(replaceElemIdStr); if (obj) { if (obj.nodeName == "OBJECT") { // static publishing storedAltContent = abstractAltContent(obj); storedAltContentId = null; } else { // dynamic publishing storedAltContent = obj; storedAltContentId = replaceElemIdStr; } att.id = EXPRESS_INSTALL_ID; if (typeof att.width == UNDEF || (!/%$/.test(att.width) && parseInt(att.width, 10) < 310)) { att.width = "310"; } if (typeof att.height == UNDEF || (!/%$/.test(att.height) && parseInt(att.height, 10) < 137)) { att.height = "137"; } doc.title = doc.title.slice(0, 47) + " - Flash Player Installation"; var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn", fv = "MMredirectURL=" + win.location.toString().replace(/&/g,"%26") + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title; if (typeof par.flashvars != UNDEF) { par.flashvars += "&" + fv; } else { par.flashvars = fv; } // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it, // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work if (ua.ie && ua.win && obj.readyState != 4) { var newObj = createElement("div"); replaceElemIdStr += "SWFObjectNew"; newObj.setAttribute("id", replaceElemIdStr); obj.parentNode.insertBefore(newObj, obj); // insert placeholder div that will be replaced by the object element that loads expressinstall.swf obj.style.display = "none"; (function(){ if (obj.readyState == 4) { obj.parentNode.removeChild(obj); } else { setTimeout(arguments.callee, 10); } })(); } createSWF(att, par, replaceElemIdStr); } } /* Functions to abstract and display alternative content */ function displayAltContent(obj) { if (ua.ie && ua.win && obj.readyState != 4) { // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it, // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work var el = createElement("div"); obj.parentNode.insertBefore(el, obj); // insert placeholder div that will be replaced by the alternative content el.parentNode.replaceChild(abstractAltContent(obj), el); obj.style.display = "none"; (function(){ if (obj.readyState == 4) { obj.parentNode.removeChild(obj); } else { setTimeout(arguments.callee, 10); } })(); } else { obj.parentNode.replaceChild(abstractAltContent(obj), obj); } } function abstractAltContent(obj) { var ac = createElement("div"); if (ua.win && ua.ie) { ac.innerHTML = obj.innerHTML; } else { var nestedObj = obj.getElementsByTagName(OBJECT)[0]; if (nestedObj) { var c = nestedObj.childNodes; if (c) { var cl = c.length; for (var i = 0; i < cl; i++) { if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) { ac.appendChild(c[i].cloneNode(true)); } } } } } return ac; } /* Cross-browser dynamic SWF creation */ function createSWF(attObj, parObj, id) { var r, el = getElementById(id); if (ua.wk && ua.wk < 312) { return r; } if (el) { if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content attObj.id = id; } if (ua.ie && ua.win) { // Internet Explorer + the HTML object element + W3C DOM methods do not combine: fall back to outerHTML var att = ""; for (var i in attObj) { if (attObj[i] != Object.prototype[i]) { // filter out prototype additions from other potential libraries if (i.toLowerCase() == "data") { parObj.movie = attObj[i]; } else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword att += ' class="' + attObj[i] + '"'; } else if (i.toLowerCase() != "classid") { att += ' ' + i + '="' + attObj[i] + '"'; } } } var par = ""; for (var j in parObj) { if (parObj[j] != Object.prototype[j]) { // filter out prototype additions from other potential libraries par += ''; } } el.outerHTML = '' + par + ''; objIdArr[objIdArr.length] = attObj.id; // stored to fix object 'leaks' on unload (dynamic publishing only) r = getElementById(attObj.id); } else { // well-behaving browsers var o = createElement(OBJECT); o.setAttribute("type", FLASH_MIME_TYPE); for (var m in attObj) { if (attObj[m] != Object.prototype[m]) { // filter out prototype additions from other potential libraries if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword o.setAttribute("class", attObj[m]); } else if (m.toLowerCase() != "classid") { // filter out IE specific attribute o.setAttribute(m, attObj[m]); } } } for (var n in parObj) { if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // filter out prototype additions from other potential libraries and IE specific param element createObjParam(o, n, parObj[n]); } } el.parentNode.replaceChild(o, el); r = o; } } return r; } function createObjParam(el, pName, pValue) { var p = createElement("param"); p.setAttribute("name", pName); p.setAttribute("value", pValue); el.appendChild(p); } /* Cross-browser SWF removal - Especially needed to safely and completely remove a SWF in Internet Explorer */ function removeSWF(id) { var obj = getElementById(id); if (obj && obj.nodeName == "OBJECT") { if (ua.ie && ua.win) { obj.style.display = "none"; (function(){ if (obj.readyState == 4) { removeObjectInIE(id); } else { setTimeout(arguments.callee, 10); } })(); } else { obj.parentNode.removeChild(obj); } } } function removeObjectInIE(id) { var obj = getElementById(id); if (obj) { for (var i in obj) { if (typeof obj[i] == "function") { obj[i] = null; } } obj.parentNode.removeChild(obj); } } /* Functions to optimize JavaScript compression */ function getElementById(id) { var el = null; try { el = doc.getElementById(id); } catch (e) {} return el; } function createElement(el) { return doc.createElement(el); } /* Updated attachEvent function for Internet Explorer - Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks */ function addListener(target, eventType, fn) { target.attachEvent(eventType, fn); listenersArr[listenersArr.length] = [target, eventType, fn]; } /* Flash Player and SWF content version matching */ function hasPlayerVersion(rv) { var pv = ua.pv, v = rv.split("."); v[0] = parseInt(v[0], 10); v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0" v[2] = parseInt(v[2], 10) || 0; return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false; } /* Cross-browser dynamic CSS creation - Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php */ function createCSS(sel, decl, media, newStyle) { if (ua.ie && ua.mac) { return; } var h = doc.getElementsByTagName("head")[0]; if (!h) { return; } // to also support badly authored HTML pages that lack a head element var m = (media && typeof media == "string") ? media : "screen"; if (newStyle) { dynamicStylesheet = null; dynamicStylesheetMedia = null; } if (!dynamicStylesheet || dynamicStylesheetMedia != m) { // create dynamic stylesheet + get a global reference to it var s = createElement("style"); s.setAttribute("type", "text/css"); s.setAttribute("media", m); dynamicStylesheet = h.appendChild(s); if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) { dynamicStylesheet = doc.styleSheets[doc.styleSheets.length - 1]; } dynamicStylesheetMedia = m; } // add style rule if (ua.ie && ua.win) { if (dynamicStylesheet && typeof dynamicStylesheet.addRule == OBJECT) { dynamicStylesheet.addRule(sel, decl); } } else { if (dynamicStylesheet && typeof doc.createTextNode != UNDEF) { dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" + decl + "}")); } } } function setVisibility(id, isVisible) { if (!autoHideShow) { return; } var v = isVisible ? "visible" : "hidden"; if (isDomLoaded && getElementById(id)) { getElementById(id).style.visibility = v; } else { createCSS("#" + id, "visibility:" + v); } } /* Filter to avoid XSS attacks */ function urlEncodeIfNecessary(s) { var regex = /[\\\"<>\.;]/; var hasBadChars = regex.exec(s) != null; return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s; } /* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only) */ var cleanup = function() { if (ua.ie && ua.win) { window.attachEvent("onunload", function() { // remove listeners to avoid memory leaks var ll = listenersArr.length; for (var i = 0; i < ll; i++) { listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]); } // cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect var il = objIdArr.length; for (var j = 0; j < il; j++) { removeSWF(objIdArr[j]); } // cleanup library's main closures to avoid memory leaks for (var k in ua) { ua[k] = null; } ua = null; for (var l in swfobject) { swfobject[l] = null; } swfobject = null; }); } }(); return { /* Public API - Reference: http://code.google.com/p/swfobject/wiki/documentation */ registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr, callbackFn) { if (ua.w3 && objectIdStr && swfVersionStr) { var regObj = {}; regObj.id = objectIdStr; regObj.swfVersion = swfVersionStr; regObj.expressInstall = xiSwfUrlStr; regObj.callbackFn = callbackFn; regObjArr[regObjArr.length] = regObj; setVisibility(objectIdStr, false); } else if (callbackFn) { callbackFn({success:false, id:objectIdStr}); } }, getObjectById: function(objectIdStr) { if (ua.w3) { return getObjectById(objectIdStr); } }, embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) { var callbackObj = {success:false, id:replaceElemIdStr}; if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) { setVisibility(replaceElemIdStr, false); addDomLoadEvent(function() { widthStr += ""; // auto-convert to string heightStr += ""; var att = {}; if (attObj && typeof attObj === OBJECT) { for (var i in attObj) { // copy object to avoid the use of references, because web authors often reuse attObj for multiple SWFs att[i] = attObj[i]; } } att.data = swfUrlStr; att.width = widthStr; att.height = heightStr; var par = {}; if (parObj && typeof parObj === OBJECT) { for (var j in parObj) { // copy object to avoid the use of references, because web authors often reuse parObj for multiple SWFs par[j] = parObj[j]; } } if (flashvarsObj && typeof flashvarsObj === OBJECT) { for (var k in flashvarsObj) { // copy object to avoid the use of references, because web authors often reuse flashvarsObj for multiple SWFs if (typeof par.flashvars != UNDEF) { par.flashvars += "&" + k + "=" + flashvarsObj[k]; } else { par.flashvars = k + "=" + flashvarsObj[k]; } } } if (hasPlayerVersion(swfVersionStr)) { // create SWF var obj = createSWF(att, par, replaceElemIdStr); if (att.id == replaceElemIdStr) { setVisibility(replaceElemIdStr, true); } callbackObj.success = true; callbackObj.ref = obj; } else if (xiSwfUrlStr && canExpressInstall()) { // show Adobe Express Install att.data = xiSwfUrlStr; showExpressInstall(att, par, replaceElemIdStr, callbackFn); return; } else { // show alternative content setVisibility(replaceElemIdStr, true); } if (callbackFn) { callbackFn(callbackObj); } }); } else if (callbackFn) { callbackFn(callbackObj); } }, switchOffAutoHideShow: function() { autoHideShow = false; }, ua: ua, getFlashPlayerVersion: function() { return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] }; }, hasFlashPlayerVersion: hasPlayerVersion, createSWF: function(attObj, parObj, replaceElemIdStr) { if (ua.w3) { return createSWF(attObj, parObj, replaceElemIdStr); } else { return undefined; } }, showExpressInstall: function(att, par, replaceElemIdStr, callbackFn) { if (ua.w3 && canExpressInstall()) { showExpressInstall(att, par, replaceElemIdStr, callbackFn); } }, removeSWF: function(objElemIdStr) { if (ua.w3) { removeSWF(objElemIdStr); } }, createCSS: function(selStr, declStr, mediaStr, newStyleBoolean) { if (ua.w3) { createCSS(selStr, declStr, mediaStr, newStyleBoolean); } }, addDomLoadEvent: addDomLoadEvent, addLoadEvent: addLoadEvent, getQueryParamValue: function(param) { var q = doc.location.search || doc.location.hash; if (q) { if (/\?/.test(q)) { q = q.split("?")[1]; } // strip question mark if (param == null) { return urlEncodeIfNecessary(q); } var pairs = q.split("&"); for (var i = 0; i < pairs.length; i++) { if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) { return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1))); } } } return ""; }, // For internal usage only expressInstallCallback: function() { if (isExpressInstallActive) { var obj = getElementById(EXPRESS_INSTALL_ID); if (obj && storedAltContent) { obj.parentNode.replaceChild(storedAltContent, obj); if (storedAltContentId) { setVisibility(storedAltContentId, true); if (ua.ie && ua.win) { storedAltContent.style.display = "block"; } } if (storedCallbackFn) { storedCallbackFn(storedCallbackObj); } } isExpressInstallActive = false; } } }; }(); document.observe("dom:loaded", function() { var url = document.location.href; // url = url.replace(daDomain, ''); $$('a[href='+document.location.href+']', 'a[href='+document.location.href+'/default.asp]').invoke('addClassName', 'selected'); });//v1.7 // Flash Player Version Detection // Detect Client Browser type // Copyright 2005-2007 Adobe Systems Incorporated. All rights reserved. var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; function ControlVersion() { var version; var axo; var e; // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry try { // version will be set for 7.X or greater players axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); version = axo.GetVariable("$version"); } catch (e) { } if (!version) { try { // version will be set for 6.X players only axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); // installed player is some revision of 6.0 // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29, // so we have to be careful. // default to the first public version version = "WIN 6,0,21,0"; // throws if AllowScripAccess does not exist (introduced in 6.0r47) axo.AllowScriptAccess = "always"; // safe to call for 6.0r47 or greater version = axo.GetVariable("$version"); } catch (e) { } } if (!version) { try { // version will be set for 4.X or 5.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); version = axo.GetVariable("$version"); } catch (e) { } } if (!version) { try { // version will be set for 3.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); version = "WIN 3,0,18,0"; } catch (e) { } } if (!version) { try { // version will be set for 2.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); version = "WIN 2,0,0,11"; } catch (e) { version = -1; } } return version; } // JavaScript helper required to detect Flash Player PlugIn version information function GetSwfVer(){ // NS/Opera version >= 3 check for Flash plugin in plugin array var flashVer = -1; if (navigator.plugins != null && navigator.plugins.length > 0) { if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; var descArray = flashDescription.split(" "); var tempArrayMajor = descArray[2].split("."); var versionMajor = tempArrayMajor[0]; var versionMinor = tempArrayMajor[1]; var versionRevision = descArray[3]; if (versionRevision == "") { versionRevision = descArray[4]; } if (versionRevision[0] == "d") { versionRevision = versionRevision.substring(1); } else if (versionRevision[0] == "r") { versionRevision = versionRevision.substring(1); if (versionRevision.indexOf("d") > 0) { versionRevision = versionRevision.substring(0, versionRevision.indexOf("d")); } } var flashVer = versionMajor + "." + versionMinor + "." + versionRevision; } } // MSN/WebTV 2.6 supports Flash 4 else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4; // WebTV 2.5 supports Flash 3 else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3; // older WebTV supports Flash 2 else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2; else if ( isIE && isWin && !isOpera ) { flashVer = ControlVersion(); } return flashVer; } // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) { versionStr = GetSwfVer(); if (versionStr == -1 ) { return false; } else if (versionStr != 0) { if(isIE && isWin && !isOpera) { // Given "WIN 2,0,0,11" tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"] tempString = tempArray[1]; // "2,0,0,11" versionArray = tempString.split(","); // ['2', '0', '0', '11'] } else { versionArray = versionStr.split("."); } var versionMajor = versionArray[0]; var versionMinor = versionArray[1]; var versionRevision = versionArray[2]; // is the major.revision >= requested major.revision AND the minor version >= requested minor if (versionMajor > parseFloat(reqMajorVer)) { return true; } else if (versionMajor == parseFloat(reqMajorVer)) { if (versionMinor > parseFloat(reqMinorVer)) return true; else if (versionMinor == parseFloat(reqMinorVer)) { if (versionRevision >= parseFloat(reqRevision)) return true; } } return false; } } function AC_AddExtension(src, ext) { if (src.indexOf('?') != -1) return src.replace(/\?/, ext+'?'); else return src + ext; } function AC_Generateobj(objAttrs, params, embedAttrs) { var str = ''; if (isIE && isWin && !isOpera) { str += ' '; } str += ''; } else { str += '.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown, >.jScrollCap', $c).remove(); $this.css({'top':0}); } else { $this.data('originalStyleTag', $this.attr('style')); // Switch the element's overflow to hidden to ensure we get the size of the element without the scrollbars [http://plugins.jquery.com/node/1208] $this.css('overflow', 'hidden'); this.originalPadding = $this.css('paddingTop') + ' ' + $this.css('paddingRight') + ' ' + $this.css('paddingBottom') + ' ' + $this.css('paddingLeft'); this.originalSidePaddingTotal = (parseInt($this.css('paddingLeft')) || 0) + (parseInt($this.css('paddingRight')) || 0); paneWidth = $this.innerWidth(); paneHeight = $this.innerHeight(); $container = $('
') .attr({'className':'jScrollPaneContainer'}) .css( { 'height':paneHeight+'px', 'width':paneWidth+'px' } ); if (settings.enableKeyboardNavigation) { $container.attr( 'tabindex', settings.tabIndex ); } $this.wrap($container); $container = $this.parent(); // deal with text size changes (if the jquery.em plugin is included) // and re-initialise the scrollPane so the track maintains the // correct size $(document).bind( 'emchange', function(e, cur, prev) { $this.jScrollPane(settings); } ); } trackHeight = paneHeight; if (settings.reinitialiseOnImageLoad) { // code inspired by jquery.onImagesLoad: http://plugins.jquery.com/project/onImagesLoad // except we re-initialise the scroll pane when each image loads so that the scroll pane is always up to size... // TODO: Do I even need to store it in $.data? Is a local variable here the same since I don't pass the reinitialiseOnImageLoad when I re-initialise? var $imagesToLoad = $.data(paneEle, 'jScrollPaneImagesToLoad') || $('img', $this); var loadedImages = []; if ($imagesToLoad.length) { $imagesToLoad.each(function(i, val) { $(this).bind('load readystatechange', function() { if($.inArray(i, loadedImages) == -1){ //don't double count images loadedImages.push(val); //keep a record of images we've seen $imagesToLoad = $.grep($imagesToLoad, function(n, i) { return n != val; }); $.data(paneEle, 'jScrollPaneImagesToLoad', $imagesToLoad); var s2 = $.extend(settings, {reinitialiseOnImageLoad:false}); $this.jScrollPane(s2); // re-initialise } }).each(function(i, val) { if(this.complete || this.complete===undefined) { //needed for potential cached images this.src = this.src; } }); }); }; } var p = this.originalSidePaddingTotal; var realPaneWidth = paneWidth - settings.scrollbarWidth - settings.scrollbarMargin - p; var cssToApply = { 'height':'auto', 'width': realPaneWidth + 'px' } if(settings.scrollbarOnLeft) { cssToApply.paddingLeft = settings.scrollbarMargin + settings.scrollbarWidth + 'px'; } else { cssToApply.paddingRight = settings.scrollbarMargin + 'px'; } $this.css(cssToApply); var contentHeight = $this.outerHeight(); var percentInView = paneHeight / contentHeight; var isScrollable = percentInView < .99; $container[isScrollable ? 'addClass' : 'removeClass']('jScrollPaneScrollable'); if (isScrollable) { $container.append( $('
').addClass('jScrollCap jScrollCapTop').css({height:settings.topCapHeight}), $('
').attr({'className':'jScrollPaneTrack'}).css({'width':settings.scrollbarWidth+'px'}).append( $('
').attr({'className':'jScrollPaneDrag'}).css({'width':settings.scrollbarWidth+'px'}).append( $('
').attr({'className':'jScrollPaneDragTop'}).css({'width':settings.scrollbarWidth+'px'}), $('
').attr({'className':'jScrollPaneDragBottom'}).css({'width':settings.scrollbarWidth+'px'}) ) ), $('
').addClass('jScrollCap jScrollCapBottom').css({height:settings.bottomCapHeight}) ); var $track = $('>.jScrollPaneTrack', $container); var $drag = $('>.jScrollPaneTrack .jScrollPaneDrag', $container); var currentArrowDirection; var currentArrowTimerArr = [];// Array is used to store timers since they can stack up when dealing with keyboard events. This ensures all timers are cleaned up in the end, preventing an acceleration bug. var currentArrowInc; var whileArrowButtonDown = function() { if (currentArrowInc > 4 || currentArrowInc % 4 == 0) { positionDrag(dragPosition + currentArrowDirection * mouseWheelMultiplier); } currentArrowInc++; }; if (settings.enableKeyboardNavigation) { $container.bind( 'keydown.jscrollpane', function(e) { switch (e.keyCode) { case 38: //up currentArrowDirection = -1; currentArrowInc = 0; whileArrowButtonDown(); currentArrowTimerArr[currentArrowTimerArr.length] = setInterval(whileArrowButtonDown, 100); return false; case 40: //down currentArrowDirection = 1; currentArrowInc = 0; whileArrowButtonDown(); currentArrowTimerArr[currentArrowTimerArr.length] = setInterval(whileArrowButtonDown, 100); return false; case 33: // page up case 34: // page down // TODO return false; default: } } ).bind( 'keyup.jscrollpane', function(e) { if (e.keyCode == 38 || e.keyCode == 40) { for (var i = 0; i < currentArrowTimerArr.length; i++) { clearInterval(currentArrowTimerArr[i]); } return false; } } ); } if (settings.showArrows) { var currentArrowButton; var currentArrowInterval; var onArrowMouseUp = function(event) { $('html').unbind('mouseup', onArrowMouseUp); currentArrowButton.removeClass('jScrollActiveArrowButton'); clearInterval(currentArrowInterval); }; var onArrowMouseDown = function() { $('html').bind('mouseup', onArrowMouseUp); currentArrowButton.addClass('jScrollActiveArrowButton'); currentArrowInc = 0; whileArrowButtonDown(); currentArrowInterval = setInterval(whileArrowButtonDown, 100); }; $container .append( $('') .attr( { 'href':'javascript:;', 'className':'jScrollArrowUp', 'tabindex':-1 } ) .css( { 'width':settings.scrollbarWidth+'px', 'top':settings.topCapHeight + 'px' } ) .html('Scroll up') .bind('mousedown', function() { currentArrowButton = $(this); currentArrowDirection = -1; onArrowMouseDown(); this.blur(); return false; }) .bind('click', rf), $('') .attr( { 'href':'javascript:;', 'className':'jScrollArrowDown', 'tabindex':-1 } ) .css( { 'width':settings.scrollbarWidth+'px', 'bottom':settings.bottomCapHeight + 'px' } ) .html('Scroll down') .bind('mousedown', function() { currentArrowButton = $(this); currentArrowDirection = 1; onArrowMouseDown(); this.blur(); return false; }) .bind('click', rf) ); var $upArrow = $('>.jScrollArrowUp', $container); var $downArrow = $('>.jScrollArrowDown', $container); } if (settings.arrowSize) { trackHeight = paneHeight - settings.arrowSize - settings.arrowSize; trackOffset += settings.arrowSize; } else if ($upArrow) { var topArrowHeight = $upArrow.height(); settings.arrowSize = topArrowHeight; trackHeight = paneHeight - topArrowHeight - $downArrow.height(); trackOffset += topArrowHeight; } trackHeight -= settings.topCapHeight + settings.bottomCapHeight; $track.css({'height': trackHeight+'px', top:trackOffset+'px'}) var $pane = $(this).css({'position':'absolute', 'overflow':'visible'}); var currentOffset; var maxY; var mouseWheelMultiplier; // store this in a seperate variable so we can keep track more accurately than just updating the css property.. var dragPosition = 0; var dragMiddle = percentInView*paneHeight/2; // pos function borrowed from tooltip plugin and adapted... var getPos = function (event, c) { var p = c == 'X' ? 'Left' : 'Top'; return event['page' + c] || (event['client' + c] + (document.documentElement['scroll' + p] || document.body['scroll' + p])) || 0; }; var ignoreNativeDrag = function() { return false; }; var initDrag = function() { ceaseAnimation(); currentOffset = $drag.offset(false); currentOffset.top -= dragPosition; maxY = trackHeight - $drag[0].offsetHeight; mouseWheelMultiplier = 2 * settings.wheelSpeed * maxY / contentHeight; }; var onStartDrag = function(event) { initDrag(); dragMiddle = getPos(event, 'Y') - dragPosition - currentOffset.top; $('html').bind('mouseup', onStopDrag).bind('mousemove', updateScroll); if ($.browser.msie) { $('html').bind('dragstart', ignoreNativeDrag).bind('selectstart', ignoreNativeDrag); } return false; }; var onStopDrag = function() { $('html').unbind('mouseup', onStopDrag).unbind('mousemove', updateScroll); dragMiddle = percentInView*paneHeight/2; if ($.browser.msie) { $('html').unbind('dragstart', ignoreNativeDrag).unbind('selectstart', ignoreNativeDrag); } }; var positionDrag = function(destY) { $container.scrollTop(0); destY = destY < 0 ? 0 : (destY > maxY ? maxY : destY); dragPosition = destY; $drag.css({'top':destY+'px'}); var p = destY / maxY; $this.data('jScrollPanePosition', (paneHeight-contentHeight)*-p); $pane.css({'top':((paneHeight-contentHeight)*p) + 'px'}); $this.trigger('scroll'); if (settings.showArrows) { $upArrow[destY == 0 ? 'addClass' : 'removeClass']('disabled'); $downArrow[destY == maxY ? 'addClass' : 'removeClass']('disabled'); } }; var updateScroll = function(e) { positionDrag(getPos(e, 'Y') - currentOffset.top - dragMiddle); }; var dragH = Math.max(Math.min(percentInView*(paneHeight-settings.arrowSize*2), settings.dragMaxHeight), settings.dragMinHeight); $drag.css( {'height':dragH+'px'} ).bind('mousedown', onStartDrag); var trackScrollInterval; var trackScrollInc; var trackScrollMousePos; var doTrackScroll = function() { if (trackScrollInc > 8 || trackScrollInc%4==0) { positionDrag((dragPosition - ((dragPosition - trackScrollMousePos) / 2))); } trackScrollInc ++; }; var onStopTrackClick = function() { clearInterval(trackScrollInterval); $('html').unbind('mouseup', onStopTrackClick).unbind('mousemove', onTrackMouseMove); }; var onTrackMouseMove = function(event) { trackScrollMousePos = getPos(event, 'Y') - currentOffset.top - dragMiddle; }; var onTrackClick = function(event) { initDrag(); onTrackMouseMove(event); trackScrollInc = 0; $('html').bind('mouseup', onStopTrackClick).bind('mousemove', onTrackMouseMove); trackScrollInterval = setInterval(doTrackScroll, 100); doTrackScroll(); return false; }; $track.bind('mousedown', onTrackClick); $container.bind( 'mousewheel', function (event, delta) { delta = delta || (event.wheelDelta ? event.wheelDelta / 120 : (event.detail) ? -event.detail/3 : 0); initDrag(); ceaseAnimation(); var d = dragPosition; positionDrag(dragPosition - delta * mouseWheelMultiplier); var dragOccured = d != dragPosition; return !dragOccured; } ); var _animateToPosition; var _animateToInterval; function animateToPosition() { var diff = (_animateToPosition - dragPosition) / settings.animateStep; if (diff > 1 || diff < -1) { positionDrag(dragPosition + diff); } else { positionDrag(_animateToPosition); ceaseAnimation(); } } var ceaseAnimation = function() { if (_animateToInterval) { clearInterval(_animateToInterval); delete _animateToPosition; } }; var scrollTo = function(pos, preventAni) { if (typeof pos == "string") { // Legal hash values aren't necessarily legal jQuery selectors so we need to catch any // errors from the lookup... try { $e = $(pos, $this); } catch (err) { return; } if (!$e.length) return; pos = $e.offset().top - $this.offset().top; } ceaseAnimation(); var maxScroll = contentHeight - paneHeight; pos = pos > maxScroll ? maxScroll : pos; $this.data('jScrollPaneMaxScroll', maxScroll); var destDragPosition = pos/maxScroll * maxY; if (preventAni || !settings.animateTo) { positionDrag(destDragPosition); } else { $container.scrollTop(0); _animateToPosition = destDragPosition; _animateToInterval = setInterval(animateToPosition, settings.animateInterval); } }; $this[0].scrollTo = scrollTo; $this[0].scrollBy = function(delta) { var currentPos = -parseInt($pane.css('top')) || 0; scrollTo(currentPos + delta); }; initDrag(); scrollTo(-currentScrollPosition, true); // Deal with it when the user tabs to a link or form element within this scrollpane $('*', this).bind( 'focus', function(event) { var $e = $(this); // loop through parents adding the offset top of any elements that are relatively positioned between // the focused element and the jScrollPaneContainer so we can get the true distance from the top // of the focused element to the top of the scrollpane... var eleTop = 0; while ($e[0] != $this[0]) { eleTop += $e.position().top; $e = $e.offsetParent(); } var viewportTop = -parseInt($pane.css('top')) || 0; var maxVisibleEleTop = viewportTop + paneHeight; var eleInView = eleTop > viewportTop && eleTop < maxVisibleEleTop; if (!eleInView) { var destPos = eleTop - settings.scrollbarMargin; if (eleTop > viewportTop) { // element is below viewport - scroll so it is at bottom. destPos += $(this).height() + 15 + settings.scrollbarMargin - paneHeight; } scrollTo(destPos); } } ) if (settings.observeHash) { if (location.hash && location.hash.length > 1) { setTimeout(function(){ scrollTo(location.hash); }, $.browser.safari ? 100 : 0); } // use event delegation to listen for all clicks on links and hijack them if they are links to // anchors within our content... $(document).bind('click', function(e){ $target = $(e.target); if ($target.is('a')) { var h = $target.attr('href'); if (h && h.substr(0, 1) == '#' && h.length > 1) { setTimeout(function(){ scrollTo(h, !settings.animateToInternalLinks); }, $.browser.safari ? 100 : 0); } } }); } // Deal with dragging and selecting text to make the scrollpane scroll... function onSelectScrollMouseDown(e) { $(document).bind('mousemove.jScrollPaneDragging', onTextSelectionScrollMouseMove); $(document).bind('mouseup.jScrollPaneDragging', onSelectScrollMouseUp); } var textDragDistanceAway; var textSelectionInterval; function onTextSelectionInterval() { direction = textDragDistanceAway < 0 ? -1 : 1; $this[0].scrollBy(textDragDistanceAway / 2); } function clearTextSelectionInterval() { if (textSelectionInterval) { clearInterval(textSelectionInterval); textSelectionInterval = undefined; } } function onTextSelectionScrollMouseMove(e) { var offset = $this.parent().offset().top; var maxOffset = offset + paneHeight; var mouseOffset = getPos(e, 'Y'); textDragDistanceAway = mouseOffset < offset ? mouseOffset - offset : (mouseOffset > maxOffset ? mouseOffset - maxOffset : 0); if (textDragDistanceAway == 0) { clearTextSelectionInterval(); } else { if (!textSelectionInterval) { textSelectionInterval = setInterval(onTextSelectionInterval, 100); } } } function onSelectScrollMouseUp(e) { $(document) .unbind('mousemove.jScrollPaneDragging') .unbind('mouseup.jScrollPaneDragging'); clearTextSelectionInterval(); } $container.bind('mousedown.jScrollPane', onSelectScrollMouseDown); $.jScrollPane.active.push($this[0]); } else { $this.css( { 'height':paneHeight+'px', 'width':paneWidth-this.originalSidePaddingTotal+'px', 'padding':this.originalPadding } ); $this[0].scrollTo = $this[0].scrollBy = function() {}; // clean up listeners $this.parent().unbind('mousewheel').unbind('mousedown.jScrollPane').unbind('keydown.jscrollpane').unbind('keyup.jscrollpane'); } } ) }; $.fn.jScrollPaneRemove = function() { $(this).each(function() { $this = $(this); var $c = $this.parent(); if ($c.is('.jScrollPaneContainer')) { $this.css( { 'top':'', 'height':'', 'width':'', 'padding':'', 'overflow':'', 'position':'' } ); $this.attr('style', $this.data('originalStyleTag')); $c.after($this).remove(); } }); } $.fn.jScrollPane.defaults = { scrollbarWidth : 10, scrollbarMargin : 5, wheelSpeed : 18, showArrows : false, arrowSize : 0, animateTo : false, dragMinHeight : 1, dragMaxHeight : 99999, animateInterval : 100, animateStep: 3, maintainPosition: true, scrollbarOnLeft: false, reinitialiseOnImageLoad: false, tabIndex : 0, enableKeyboardNavigation: true, animateToInternalLinks: false, topCapHeight: 0, bottomCapHeight: 0, observeHash: true }; // clean up the scrollTo expandos $(window) .bind('unload', function() { var els = $.jScrollPane.active; for (var i=0; i * * Released under the MIT licence: * http://www.opensource.org/licenses/mit-license.php */ // Upon $(document).ready()… jQuery(function($) { // Configuration… var eventName = 'emchange'; // Set up default options. $.em = $.extend({ /** * The jQuery-Em version string. * * @example $.em.version; * @desc '1.0a' * * @property * @name version * @type String * @cat Plugins/Em */ version: '1.0', /** * The number of milliseconds to wait when polling for changes to the * font size. * * @example $.em.delay = 400; * @desc Defaults to 200. * * @property * @name delay * @type Number * @cat Plugins/Em */ delay: 200, /** * The element used to detect changes to the font size. * * @example $.em.element = $('
')[0]; * @desc Default is an empty, absolutely positioned, 100em-wide
. * * @private * @property * @name element * @type Element * @cat Plugins/Em */ element: $('
').css({ left: '-100em', position: 'absolute', width: '100em' }) .prependTo('body')[0], /** * The action to perform when a change in the font size is detected. * * @example $.em.action = function() { ... } * @desc The default action is to trigger a global “emchange” event. * You probably shouldn’t change this behaviour as other plugins may * rely on it, but the option is here for completion. * * @example $(document).bind('emchange', function(e, cur, prev) {...}) * @desc Any functions triggered on this event are passed the current * font size, and last known font size as additional parameters. * * @private * @property * @name action * @type Function * @cat Plugins/Em * @see current * @see previous */ action: function() { var currentWidth = $.em.element.offsetWidth / 100; // If the font size has changed since we last checked… if ( currentWidth != $.em.current ) { /** * The previous pixel value of the user agent’s font size. See * $.em.current for caveats. Will initially be undefined until * the “emchange” event is triggered. * * @example $.em.previous; * @result 16 * * @property * @name previous * @type Number * @cat Plugins/Em * @see current */ $.em.previous = $.em.current; /** * The current pixel value of the user agent’s font size. As * with $.em.previous, this value *may* be subject to minor * browser rounding errors that mean you might not want to * rely upon it as an absolute value. * * @example $.em.current; * @result 14 * * @property * @name current * @type Number * @cat Plugins/Em * @see previous */ $.em.current = currentWidth; $.event.trigger(eventName, [$.em.current, $.em.previous]); } } }, $.em ); /** * Bind a function to the emchange event of each matched element. * * @example $("p").emchange( function() { alert("Hello"); } ); * * @name emchange * @type jQuery * @param Function fn A function to bind to the emchange event. * @cat Plugins/Em */ /** * Trigger the emchange event of each matched element. * * @example $("p").emchange() * * @name emchange * @type jQuery * @cat Plugins/Em */ $.fn[eventName] = function(fn) { return fn ? this.bind(eventName, fn) : this.trigger(eventName); }; // Store the initial pixel value of the user agent’s font size. $.em.current = $.em.element.offsetWidth / 100; /** * While polling for font-size changes, $.em.iid stores the intervalID in * case you should want to cancel with clearInterval(). * * @example window.clearInterval( $.em.iid ); * * @property * @name iid * @type Number * @cat Plugins/Em */ $.em.iid = setInterval( $.em.action, $.em.delay ); }); /* * Easy Slider 1.5 - jQuery plugin * written by Alen Grakalic * http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding * * Copyright (c) 2009 Alen Grakalic (http://cssglobe.com) * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * * Built for jQuery library * http://jquery.com * */ /* * markup example for $("#slider").easySlider(); * *
*
    *
  • *
  • *
  • *
  • *
  • *
*
* */ (function($) { $.fn.easySlider = function(options){ // default configuration properties var defaults = { prevId: 'prevBtn', prevText: 'Previous', nextId: 'nextBtn', nextText: 'Next', controlsShow: true, controlsBefore: '', controlsAfter: '', controlsFade: true, firstId: 'firstBtn', firstText: 'First', firstShow: false, lastId: 'lastBtn', lastText: 'Last', lastShow: false, vertical: false, speed: 800, auto: false, pause: 2000, continuous: false }; var options = $.extend(defaults, options); this.each(function() { var obj = $(this); var s = $("li", obj).length; var w = $("li", obj).width(); var h = $("li", obj).height(); obj.width(w); obj.height(h); obj.css("overflow","hidden"); var ts = s-1; var t = 0; $("ul", obj).css('width',s*w); if(!options.vertical) $("li", obj).css('float','left'); if(options.controlsShow){ var html = options.controlsBefore; if(options.firstShow) html += ''+ options.firstText +''; html += ' '+ options.prevText +''; html += ' '+ options.nextText +''; if(options.lastShow) html += ' '+ options.lastText +''; html += options.controlsAfter; $(obj).after(html); }; $("a","#"+options.nextId).click(function(){ animate("next",true); }); $("a","#"+options.prevId).click(function(){ animate("prev",true); }); $("a","#"+options.firstId).click(function(){ animate("first",true); }); $("a","#"+options.lastId).click(function(){ animate("last",true); }); function animate(dir,clicked){ var ot = t; switch(dir){ case "next": t = (ot>=ts) ? (options.continuous ? 0 : ts) : t+1; break; case "prev": t = (t<=0) ? (options.continuous ? ts : 0) : t-1; break; case "first": t = 0; break; case "last": t = ts; break; default: break; }; var diff = Math.abs(ot-t); var speed = diff*options.speed; if(!options.vertical) { p = (t*w*-1); $("ul",obj).animate( { marginLeft: p }, speed ); } else { p = (t*h*-1); $("ul",obj).animate( { marginTop: p }, speed ); }; if(!options.continuous && options.controlsFade){ if(t==ts){ $("a","#"+options.nextId).hide(); $("a","#"+options.lastId).hide(); } else { $("a","#"+options.nextId).show(); $("a","#"+options.lastId).show(); }; if(t==0){ $("a","#"+options.prevId).hide(); $("a","#"+options.firstId).hide(); } else { $("a","#"+options.prevId).show(); $("a","#"+options.firstId).show(); }; }; if(clicked) clearTimeout(timeout); if(options.auto && dir=="next" && !clicked){; timeout = setTimeout(function(){ animate("next",false); },diff*options.speed+options.pause); }; }; // init var timeout; if(options.auto){; timeout = setTimeout(function(){ animate("next",false); },options.pause); }; if(!options.continuous && options.controlsFade){ $("a","#"+options.prevId).hide(); $("a","#"+options.firstId).hide(); }; }); }; })(jQuery); /* droplicious v.1.0 Created May 21, 2009 Copyright @2009 http://headfirstproductions.ca Author: Darren Terhune Contributors: Jan Sovak http://canada-jack.com, Mason Meyer http://www.masonmeyer.com This software is licensed under the Creative Commons Attribution 2.5 Canada License */ var dropliciousShowingUpDuration = 0.3; var dropliciousHidingDuration = 0.1; var dropliciousHideDelay = 0; function dropliciousShowingUpEffect(element){ if(!element.visible()){ new Effect.BlindDown(element, { duration: dropliciousShowingUpDuration, queue: { position: 'end', scope: element.identify(), limit:2 } }); } } function dropliciousHidingEffect(element){ new Effect.BlindUp(element, { duration: dropliciousHidingDuration, queue: { position: 'end', scope: element.identify(), limit: 2 } }); } function setDelayedHide(element){ element.addClassName('waitingtohide') if(!element.hasClassName('hidding')){ if (!element.hasClassName('hiddingtimerset')){ element.addClassName('hiddingtimerset'); setTimeout(function(){ delayedHide(element); }, dropliciousHideDelay * 1000); } } } function delayedHide(dropElement){ dropElement.removeClassName('hiddingtimerset'); if (dropElement.hasClassName('waitingtohide')){ dropliciousHidingEffect(dropElement); dropElement.addClassName('hidding'); setTimeout( function(){ dropElement.removeClassName('waitingtohide'); dropElement.removeClassName('hidding'); dropElement.removeClassName('active'); }, dropliciousHidingDuration * 1000); } } function linkMouseOut(id){ var dropElement = id.element().next(); if (dropElement && dropElement.hasClassName('active')){ setDelayedHide(dropElement); } } function linkMouseOver(id){ var dropElement = id.element().next(); if(dropElement){ if (!dropElement.hasClassName('hidding')){ dropElement.removeClassName('waitingtohide'); } if (!dropElement.hasClassName('active')){ dropElement.addClassName('active'); dropliciousShowingUpEffect(dropElement); } } } function submenuMouseOut(event){ var dropElement = event.findElement("ul"); if (dropElement && dropElement.hasClassName('active')){ setDelayedHide(dropElement); } } function submenuMouseOver(event){ var dropElement = event.findElement("ul"); if (dropElement && !dropElement.hasClassName('hidding')){ dropElement.removeClassName('waitingtohide'); } } document.observe('dom:loaded', function() { $$('a.drops').each(function(name) { name.observe('mousemove', linkMouseOver.bindAsEventListener(this)); name.observe('mouseout', linkMouseOut.bindAsEventListener(this)); }); $$('ul.scriptaculously').each(function(name){ name.observe('mousemove', submenuMouseOver.bindAsEventListener(this)); name.observe('mouseout', submenuMouseOut.bindAsEventListener(this)); }); })