window.onload = init; var detailOpens = new Array(); // keep track of which jobs have loaded and opened var currentHighlightedJob; // which job was last opened and so is highlighted var jobCount = 0; // just used to check whether to show no jobs message /* Initialisation ------------------------------------------------------------- */ // called after page loaded function init(){ document.getElementById("loadingMsg").style.display = "none"; document.getElementById("filterForm").style.display = "block"; //initList(); document.forms["filterForm"].onsubmit = submitFilter; initFilter(); document.getElementById("fbutton").style.display = "none"; if(!anyShortlisted()) displayApplyLink("none"); else changeApplyButtons(); } function initFilter(){ // each item in the filter needs to trigger filtering var formEls = document.getElementById("filterForm"); for(var a=0; a -1){ jobCount++; } } } function afterAllLoaded(){ countJobs(); if(jobCount == 0) document.getElementById("noJobsMessage").style.display = "block"; } /* Job hiding/showing ------------------------------------------------------------- */ /* Only to be called from inline event handler (couldn't assign dynamically because they need to work while the page is still loading) */ function getJobDetails(link, linkNum){ //var linkNum = this.num; //if (!eventObj) var eventObj = window.event; //var target = getEventTarget(eventObj); var jobId = getJobIdFromURL(link.href); /* check if job is currently open or has been opened before */ if(!detailOpens[linkNum]) detailOpens[linkNum] = 0; if(detailOpens[linkNum] == 2){ // job is already open closeJob(linkNum); return false; }else if(detailOpens[linkNum] == 1){ // job has been opened before scrollToJob(jobId); setTimeout("openLoadedJob("+linkNum+", "+jobId+");", 800); return false; }else{ // job has not been shown before var detailDiv = document.getElementById("jobDetail"+linkNum); prepareDetailDiv(detailDiv); var textContainer = document.getElementById("jobDetailText"+linkNum); showWaitingText(textContainer); setTimeout("scrollToJob("+jobId+");", 500); setTimeout("loadJob("+linkNum+", "+jobId+", \""+link.href+"\");", 1300); return false; } } /* Open the details for a job that has been loaded previously */ function openLoadedJob(linkNum, jobId){ var detailDiv = document.getElementById("jobDetail"+linkNum); // was previously opened detailDiv.style.display = "block"; detailOpens[linkNum] = 2; // set to open if(jobId > 0){ highlightLastOpened(jobId); } } /* Load and show job details */ function loadJob(linkNum, jobId, href){ var textContainer = document.getElementById("jobDetailText"+linkNum); detailOpens[linkNum] = 2; var req = new DataRequestor(); req.setObjToReplace("jobDetailText"+linkNum); if(jobId > 0){ // get the rest of the URL var url = href.substring(0, href.lastIndexOf("/")) + "/index.php?cmd=JobDetails&id=" + jobId + "&frag=1"; req.getURL(url); highlightLastOpened(jobId); } } /* Given the URL to the job of the form http://..../Job-Name-ID.htm, extracts ID */ function getJobIdFromURL(url){ var whereIdSeparator = url.lastIndexOf("-"); var lastDot = url.lastIndexOf("."); var jobId = 0; if(whereIdSeparator > -1){ jobId = url.substring(whereIdSeparator+1, lastDot); } return jobId; } function closeJob(rowKey){ var detailDiv = document.getElementById("jobDetail"+rowKey); detailDiv.style.display = "none"; detailOpens[rowKey] = 1; var jobRow = detailDiv.parentNode; if(jobRow){ var jobRowId = jobRow.id.toString(); var jobId = jobRowId.replace(/jobRow/, ""); location.href = "#joba"+jobId; if(currentHighlightedJob === jobId) unhighlightJob(); } } function highlightLastOpened(jobId){ unhighlightJob(); var title = getJobTitle(jobId); if(title){ title.className = title.className + " jobHighlight"; currentHighlightedJob = jobId; } } function unhighlightJob(){ if(currentHighlightedJob){ var title = getJobTitle(currentHighlightedJob); if(title){ title.className = title.className.replace(/jobHighlight/, ""); currentHighlightedJob = null; // add visited class too if(title.className.indexOf("viewed") == -1){ title.style.color = "#F2A63A"; // need to use this instead of className to override everything else } } } } /* Return the job link element */ function getJobTitle(jobId){ var jobRow = document.getElementById("jobRow"+jobId); var jobLink = null; if(jobRow){ var innerRow = getFirstDIVChild(jobRow); if(innerRow){ var spans = innerRow.getElementsByTagName("span"); // check each column heading (spans) for(var a=0; a0; a--){ if(jobRow.childNodes[a-1].nodeName == "DIV"){ last = jobRow.childNodes[a-1]; break; } } if(last != null){ last.appendChild(newEl); var req = new DataRequestor(); req.setObjToReplace("sendFriendEl"); req.addArg(_POST, "frag", 1); req.onReplace = afterSendLoad; req.getURL("index.php?cmd=SendFriendForm&id="+jobID); }else{ location.href = "index.php?cmd=SendFriendForm&id="+jobID; } } function afterSendLoad(data, formEl){ // add an onSubmit var currentForm = document.getElementById("sendFriendForm"); currentForm.onSubmit = sendFriendSubmit; } function sendFriendSubmit(){ // validate client-side var senderName = document.getElementById("senderName").value; var friendName = document.getElementById("friendName").value; var friendEmail = document.getElementById("friendEmail").value; if(senderName == "" || friendName == "" || friendEmail == ""){ document.getElementById("sendFriendStatus").innerHTML = "Please fill in all the fields"; return false; } // send data to server var req = new DataRequestor(); req.addArgsFromForm("sendFriendForm"); req.addArg(_POST, "frag", 1); req.onload = afterSentFriend; req.getURL("index.php?cmd=SendFriend"); return false; } function afterSentFriend(data, obj){ if(data){ var status = data.substr(0,1); var message = data.substr(1); var statusBox = document.getElementById("sendFriendStatus"); if(status == 0) statusBox.className = statusBox.className + " positiveMsg"; else statusBox.className = statusBox.className + " status"; statusBox.innerHTML = message; } } /* Subscription ------------------------------------------------------------- */ function subscribe(){ setSubscribeStatus("Please wait...", false); var subEmail = document.getElementById("subEmail").value; if(subEmail == ""){ setSubscribeStatus("Please enter an email address", true); return false; } var req = new DataRequestor(); // doesn't get hidden cmd field because it doesn't have an ID (which is what we want) req.addArgsFromForm("filterForm"); req.addArg(_POST, "subEmail", subEmail); req.addArg(_POST, "frag", 1); req.onload = afterSubscribe; req.getURL("index.php?cmd=Subscribe"); return false; } function afterSubscribe(data, obj){ var text = ""; data = parseInt(data); switch(data){ case 0: text = "You are now subscribed"; break; case 1: text = "Please enter a valid email address"; break; case 2: text = "Sorry, there has been an error - could not subscribe you"; break; case 3: text = "You have been subscribed, but couldn't send you a confirmation email"; break; } setSubscribeStatus(text, true, data == 0); } var subTimeout; function setSubscribeStatus(msg, disappear, isGoodNews){ if(subTimeout) clearTimeout(subTimeout); var subStatus = document.getElementById("subStatus"); var textNode = document.createTextNode(msg); if(subStatus.childNodes.length == 1) subStatus.replaceChild(textNode, subStatus.childNodes[0]); else subStatus.appendChild(textNode); if(isGoodNews != undefined){ if(isGoodNews) subStatus.className = "positiveMsg"; else subStatus.className = "status"; } if(disappear) subTimeout = setTimeout("setSubscribeStatus(\"\")", 10000); } /* Utility functions ------------------------------------------------------------- */ // Removes leading whitespaces function LTrim( value ) { var re = /\s*((\S+\s*)*)/; return value.replace(re, "$1"); } // Removes ending whitespaces function RTrim( value ) { var re = /((\s*\S+)*)\s*/; return value.replace(re, "$1"); } // Removes leading and ending whitespaces function trim( value ) { return LTrim(RTrim(value)); } function getFirstDIVChild(el){ return getXDIVChild(el, 1); } function getXDIVChild(el, x){ var found = 0; for(var i=0; i * * ---------------------------------------- * Modification by Andy Tawse (andy.t@newmediacollective.com) * getURL - when iterating through argArray to get variables to GET/POST, I've stopped it * adding any functions that have been added to the array prototype * ---------------------------------------- * * * This class wraps the XMLHttpRequest object with a friendly API * that makes complicated data requests trivial to impliment in * your application. * * USAGE: * ---- * BASIC * To instantiate the object, simply call it as a constructor: * * var req = new DataRequestor(); * * Once you have the object instantiated, your usage will depend * on your needs. * * RETURNING TEXT * If you want to grab data, and shove it wholesale into an element * on the page (which I do 90% of the time), then tell the DataRequestor * object where to stick the info by passing setObjToReplace an * element ID or object reference, and call getURL to complete the * process: * * req.setObjToReplace('objID'); * req.getURL(url); * * * RETURNING A DOM OBJECT * By default, the contents of the requested file will be passed in as * plaintext, which can be simpler to work with than a real DOM object. * If you'd like a DOM object to work with, then call getURL with * _RETURN_AS_DOM as the second argument: * * req.getURL(url, _RETURN_AS_DOM); * * To avoid irritating problems, make sure you're sending a Content-type header * of "text/xml" when you'd like your data processed as a DOM object. IE gets * confused otherwise. * * RETURNING A JSON OBJECT * If you've no idea what JSON is, visit http://www.json.org/ * * To get a JavaScript object back from DataRequestor, call getURL with * with _RETURN_AS_JSON as the second parameter. * * req.getURL(url, _RETURN_AS_JSON); * * This, of course, assumes that you've generated a JSON string correctly * at the URL you've requested. * ---- * ARGUMENTS * * To pass in GET or POST variables along with your request, use the * addArg method: * * req.addArg(argType, argName, argValue); * e.g. * req.addArg(_GET, "argument_number", "1"); * * addArg will automatically call escape() on the name and value to * ensure they are URL escaped correctly. * * ARGUMENTS FROM A FORM * * To pass in all the arguments from a form, use the `addArgsFromForm` * method. This will automatically call `addArg` on each of the form * elements using the `method` attribute of the form to set the request * method for the arguments. Each form element *must* have an ID for this * method to function correctly. * * req.addArgsFromForm(formID); * e.g. * req.addArgsFromForm("myFormName"); * ---- * EVENT HANDLERS * * ON LOAD * * To take action when the data loads successfully, set onload to a function that * takes two arguments: data, and obj. This will be called upon successful retrieval * of the requested information, and will be passed the data retrieves and the object * that will be replaced (or null if no replacement has been requested). * * req.onload = function (data, obj) { * alert("Callback handler called with the following data: \n" + data); * } * * The first parameter (`data`) will be one of three things: * - text: If getURL was called without a second argument, or _RETURN_AS_TEXT, * then `data` contains the raw text returned by the page that you loaded. * * - DOM object: If getURL was called with _RETURN_AS_DOM as the second argument, then * `data` contains a DOM object, with blank whitespace nodes removed in order to * provide a consistant experience between browsers that support the DOM standard * and IE. * * - JavaScript object: If getURL was called with _RETURN_AS_JSON as the second argument, * then `data` contains a JavaScript object generated from the JSON text that was returned * by the page you loaded. * * ON REPLACE * * If you requested a replacement by setting an `objToReplace`, then this handler will * be called directly after the replacement occurs, and will be passed the same variables * as the `onload` method. * * req.onreplace = function (data, obj) { * alert("Callback handler called with the following data: \n" + data); * } * * ERROR HANDLING * * If the request fails, the XMLRequestor object defaults to simply throwing * an error. If that's not a great solution for you, then assign a function * to onfail that accepts a single variable: the XMLHttpRequest status * code. Do with it what you will: * * req.onfail = function (status) { * alert("The handler died with a status of " + status); * } * * PROGRESS * * In Mozilla, it's possible to dynamically retrieve the amount of data that * has been downloaded so far. If you'd like to take an action on that data * (e.g. set up some sort of progress bar) then set an onprogress handler that * accepts two arguments, currentLength and totalLength. Curiously enough, * these arguments will be populated with the current amount of data that's been * retrieved and the total size (or -1 if it can't be detected) * * req.onprogress = function (current, total) { * alert(current + " of " + total + " = " + ((total - current)/total) + "%"); * } * */ var _RETURN_AS_JSON = 2; var _RETURN_AS_TEXT = 1; var _RETURN_AS_DOM = 0; var _POST = 0; var _GET = 1; var _CACHE = 0; var _NO_CACHE = 1; function DataRequestor() { var self = this; // workaround for scope errors: see http://www.crockford.com/javascript/private.html /** * Create XMLHttpRequest object: handles branching between * versions of IE and other browers. Inital version from: * http://jibbering.com/2002/4/httprequest.html (GREAT resource) * * later version adapted from: * http://jpspan.sourceforge.net/wiki/doku.php?id=javascript:xmlhttprequest:behaviour:httpheaders * * @return the XMLHttpRequest object */ this.getXMLHTTP = function() { var xmlHTTP = null; try { xmlHTTP = new XMLHttpRequest(); } catch (e) { try { xmlHTTP = new ActiveXObject("Msxml2.XMLHTTP") } catch(e) { var success = false; var MSXML_XMLHTTP_PROGIDS = new Array( 'Microsoft.XMLHTTP', 'MSXML2.XMLHTTP', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0' ); for (var i=0;i < MSXML_XMLHTTP_PROGIDS.length && !success; i++) { try { xmlHTTP = new ActiveXObject(MSXML_XMLHTTP_PROGIDS[i]); success = true; } catch (e) { xmlHTTP = null; } } } } self._XML_REQ = xmlHTTP; return self._XML_REQ; } /** * Starts the request for a url. XMLHttpRequest will call * the default callback method when the request is complete * @param url the URL to request: absolute or relative will work * @param return optional arg: defaults to _RETURN_AS_TEXT. if set to _RETURN_AS_DOM, will return a DOM object instead of a string * @return true */ this.getURL = function(url) { self.userModifiedData = ""; // clear user modified data; // DID THE USER WANT A DOM OBJECT, OR JUST THE TEXT OF THE REQUESTED DOCUMENT? switch (arguments[1]) { case _RETURN_AS_DOM: case _RETURN_AS_TEXT: case _RETURN_AS_JSON: self.returnType = arguments[1]; break; default: self.returnType = _RETURN_AS_TEXT; } // CLEAR OUT ANY CURRENTLY ACTIVE REQUESTS if ((typeof self._XML_REQ.abort) != "undefined" && self._XML_REQ.readyState!=0) { // Opera can't abort(). self._XML_REQ.abort(); } // SET THE STATE CHANGE FUNCTION self._XML_REQ.onreadystatechange = self.callback; // GENERATE THE POST AND GET STRINGS var requestType = "GET"; var getUrlString = (url.indexOf("?") != -1)?"&":"?"; for (var i in self.argArray[_GET]) { if(typeof(self.argArray[_GET][i]) != "function") getUrlString += i + "=" + self.argArray[_GET][i] + "&"; } var postUrlString = ""; for (i in self.argArray[_POST]) { if(typeof(self.argArray[_GET][i]) != "function") postUrlString += i + "=" + self.argArray[_POST][i] + "&"; } if (postUrlString != "") { requestType = "POST"; // Only POST if we have post variables } // MAKE THE REQUEST self._XML_REQ.open(requestType, url + getUrlString, true); if ((typeof self._XML_REQ.setRequestHeader) != "undefined") { // Opera can't setRequestHeader() if (self.returnType == _RETURN_AS_DOM && typeof self._XML_REQ.overrideMimeType == "function") { self._XML_REQ.overrideMimeType('text/xml'); // Make sure we get XML if we're trying to process as DOM } self._XML_REQ.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); } self._XML_REQ.send(postUrlString); return true; } /** * The default callback method: this is called when the XMLHttpRequest object * changes state. * - If the readystate == 4 (done) and the status == 200 (OK), then * the request was successful, and we take some action: * - If the user has set an object to replace, we check to see if we recieved plaintext (default) * or if the text should be run through eval first. * * - If we recieved plaintext, we simply replace the relevant object on the page with the * text we received. * * - If we recieved text to evaluate, we call eval() on it, and then replace the object * wholesale with _DOM_OBJ (which resulted from the eval) using replaceChild() on * self.objToReplace's parentNode. * * - If the user has set an onLoad method, we call it. If they requested a DOM object, we * pass it responseXML with blank text nodes stripped (to normalize between mozilla and * IE. If not, we pass them back plaintext. * * - Else if the readystate is 3 (loading), and the user has set an onProgress handler, and * we're not in IE (which has a broken readyState 3: http://jpspan.sourceforge.net/wiki/doku.php?id=javascript:xmlhttprequest:behaviour) * then call it with two arguments: the current number of bytes we've downloaded, and the total size (or -1 if we can't tell). * * - Else if the readystate is 4, and the status isn't 200 (not OK), then we failed * somehow, so we either call the callbackFailure method, or throw an error. */ this.callback = function() { if (self.onLoad) { self.onload = self.onLoad; } if (self.onReplace) { self.onreplace = self.onReplace; } if (self.onProgress) { self.onprogress = self.onProgress; } if (self.onFail) { self.onfail = self.onFail; } if ( (self._XML_REQ.readyState == 4 && self._XML_REQ.status == 200) || (self._XML_REQ.readyState == 4 && self._XML_REQ.status == 0) // Uncomment for local (non-hosted files) /* || (self._XML_REQ.readyState == 4 && (typeof self._XML_REQ.status) == 'undefined') /* Safari 2.0/1.3 has a strange bug related to not returning the correct status */ ) { var obj = self.getObjToReplace(); if (self.onload) { switch (self.returnType) { case _RETURN_AS_TEXT: // We want text back, so send responseText self.onload(self._XML_REQ.responseText, obj); break; case _RETURN_AS_DOM: // We want a DOM object back, so send a normalized responseXML self.onload(self.normalizeWhitespace(self._XML_REQ.responseXML), obj); break; case _RETURN_AS_JSON: // We want a javascript object back, so give it: self.onload(eval('(' + self._XML_REQ.responseText + ')'), obj); break; } } if (obj) { // We're going to replace obj's content with the text returned from the XML_REQ. // The old content will be stored in self.objOldContent, the new content in // self.objNewContent // We treat TEXTAREA and INPUT nodes differently (because IE crashes if you // try to adjust a TEXTAREA's innerHTML). if (obj.nodeName == "TEXTAREA" || obj.nodeName == "INPUT") { self.objOldContent = obj.value; obj.value = (self.userModifiedData)?self.userModifiedData:self._XML_REQ.responseText; self.objNewContent = obj.value; } else { self.objOldContent = obj.innerHTML; obj.innerHTML = (self.userModifiedData)?self.userModifiedData:self._XML_REQ.responseText; self.objNewContent = obj.innerHTML; } if (self.onreplace) { self.onreplace(obj, self.objOldContent, self.objNewContent); } } } else if (self._XML_REQ.readyState == 3) { if (self.onprogress && !document.all) { // This would throw an error in IE. var contentLength = 0; // Depends on server. If content-length isn't set, catch the error try { contentLength = self._XML_REQ.getResponseHeader("Content-Length"); } catch (e) { contentLength = -1; } self.onprogress(self._XML_REQ.responseText.length, contentLength); } } else if (self._XML_REQ.readyState == 4) { if (self.onfail) { self.onfail(self._XML_REQ.status); } else { throw new Error("Data Request failed with an HTTP status of " + self._XML_REQ.status + "\nresponseText = " + self._XML_REQ.responseText); } } } /** * Normalizes whitespace between mozilla and IE * - removes blank text nodes (where "blank" is defined as "containing no non-space characters") * @param domObj the root of the DOM object to normalize */ this.normalizeWhitespace = function (domObj) { // with thanks to the kind folks in this thread: // http://www.codingforums.com/archive/index.php/t-7028 if (document.createTreeWalker) { var filter = { acceptNode: function(node) { if (/\S/.test(node.nodeValue)) { return NodeFilter.FILTER_SKIP; } return NodeFilter.FILTER_ACCEPT; } } var treeWalker = document.createTreeWalker(domObj, NodeFilter.SHOW_TEXT, filter, true); while (treeWalker.nextNode()) { treeWalker.currentNode.parentNode.removeChild(treeWalker.currentNode); treeWalker.currentNode = domObj; } return domObj; } else { return domObj; } } this.commitData = function (newData) { self.userModifiedData = newData; } /** * Sets the object to replace. If passed a string, it sets objToReplaceID, which * is evaluated at runtime. Else, it sets objToReplace to the object reference * it was passed. * @param obj a reference to the object to replace, or the object's ID */ this.setObjToReplace = function(obj) { if (typeof obj == "object") { self.objToReplace = obj; } else if (typeof obj == "string") { self.objToReplaceID = obj; } } /** * Returns a reference to the object set by objToReplace */ this.getObjToReplace = function() { if (self.objToReplaceID != "") { self.objToReplace = document.getElementById(self.objToReplaceID); self.objToReplaceID = ""; } return self.objToReplace; } /** * Adds an argument to the GET or POST strings. * @param type _GET or _POST * @param name the argument's name * @param value the argument's value */ this.addArg = function(type, name, value) { self.argArray[type][name] = escape(value); } /** * Clears the argument lists */ this.clearArgs = function() { self.argArray[_POST] = new Array(); self.argArray[_GET] = new Array(); } /** * Adds all the variables from an HTML form to the GET or * POST strings, based on the `method` attribute` of the * form * @param formID the ID of the form to be added */ this.addArgsFromForm = function(formID) { var theForm = document.getElementById(formID); // Get form method, default to GET var submitMethod = (theForm.getAttribute('method').toLowerCase() == 'post')?_POST:_GET; // Get all form elements and use `addArg` to add them to the GET/POST string // Andy Tawse MODIFICATION - using elements instead of getting childNodes so that we can get nested elements for (var i=0; i < theForm.elements.length; i++) { theNode = theForm.elements[i]; switch(theNode.nodeName.toLowerCase()) { case "input": if(theNode.type == "checkbox"){ // AT MOD - send only checked checkboxes if(theNode.checked){ this.addArg(submitMethod, theNode.id, theNode.value); } break; } case "textarea": this.addArg(submitMethod, theNode.id, theNode.value); break; case "select": // AT MOD - get all selected in a multi select box var selectedStr = ""; if(theNode.selectedIndex != -1){ for(var a=0; a 0){ // make job data into an array if it isn't already jobArr = makeArray(jobData[jobID][a]); if(chosenValues[a].intersection(jobArr) == null){ return false; } } } return true; } function resetFilter(){ // set last search to blank lastFingerprint = ""; // show all jobs var listEl = document.getElementById("jobs"); var divs = listEl.getElementsByTagName("div"); var rowCount = 0; for(var i=0; i 0) document.getElementById("noJobsMessage").style.display = "none"; // set job count text setJobCount(originalJobCount); unhighlightJob(); } function clearCheckboxes(formEl, prefix){ for(var a=0; a 0){ colEl.replaceChild(imgEl, colEl.childNodes[0]); }else{ colEl.appendChild(imgEl); } } function getStandardColValue(col){ var spanChild = col.childNodes[0]; if(spanChild) colValue = spanChild.nodeValue; else colValue = ""; return colValue; } function sortJobs(a,b){ if(a[1]b[1]) return 1; else return 0; } function numericalSort(a,b){ return(a[1]-b[1]); } var timeouts = new Array(null,null,null,null,null); var stage = -1; var interval = 10; var friction = new Array(.2,.2,.2); var damping = new Array(.9,.3,.9); var lastValue = 10000000; /* Called by main program Finds positions and decides whether to scroll */ function scrollToJob(jobId){ var jobAnchor = document.getElementById("joba"+jobId); if(jobAnchor){ var position = findPos(jobAnchor); if(getScrollY() < position[1]){ //window.scrollTo(0, position[1]); niceScroll(position[1]); } } } function move(curDirection, target){ current = getScrollY(); doneMove = false; if(curDirection == "down"){ if(lastValue != current){ lastValue = current; if(current >= target){ window.scrollTo(0, current + (((target-current)*friction[stage])*damping[stage])); timeouts[stage] = setTimeout("move(\"down\","+target+")", interval); }else doneMove = true; }else doneMove = true; } else if(curDirection == "up"){ if(lastValue != current){ lastValue = current; if(current <= target){ window.scrollTo(0, current - (((current-target)*friction[stage])*damping[stage])); timeouts[stage] = setTimeout("move(\"up\","+target+")", interval); }else{ doneMove = true; } }else{ doneMove = true; } } if(doneMove){ // move on to the next stage niceScroll(target); } } var direction; // move through scrolling stages // only proceeds to next stage when move() is finished function niceScroll(target){ if(stage == -1){ direction = "up"; } lastValue = 10000000; stage++; if(stage == 0){ // shoot past target move(direction, target+10); }else if(stage == 1){ // move opposite direction past target var oppDir = getOppDir(direction); move(oppDir, target-20); }else if(stage == 2){ // then hit the target move(direction, target+10); }else if(stage == 3){ stage = -1; } } function getOppDir(dir){ if(dir == "up") return "down"; else return "up"; } // thanks to http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html function getScrollY() { return f_filterResults ( window.pageYOffset ? window.pageYOffset : 0, document.documentElement ? document.documentElement.scrollTop : 0, document.body ? document.body.scrollTop : 0 ); } function f_filterResults(n_win, n_docel, n_body) { var n_result = n_win ? n_win : 0; if (n_docel && (!n_result || (n_result > n_docel))) n_result = n_docel; return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result; } /* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 0.11.0 */ var YAHOO=window.YAHOO||{};YAHOO.namespace=function(ns){if(!ns||!ns.length){return null;}var _2=ns.split(".");var _3=YAHOO;for(var i=(_2[0]=="YAHOO")?1:0;i<_2.length;++i){_3[_2[i]]=_3[_2[i]]||{};_3=_3[_2[i]];}return _3;};YAHOO.log=function(_5,_6,_7){var l=YAHOO.widget.Logger;if(l&&l.log){return l.log(_5,_6,_7);}else{return false;}};YAHOO.extend=function(_9,_10){var f=function(){};f.prototype=_10.prototype;_9.prototype=new f();_9.prototype.constructor=_9;_9.superclass=_10.prototype;if(_10.prototype.constructor==Object.prototype.constructor){_10.prototype.constructor=_10;}};YAHOO.namespace("util");YAHOO.namespace("widget");YAHOO.namespace("example"); /* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 0.11.0 */YAHOO.util.Dom=function(){var ua=navigator.userAgent.toLowerCase();var isOpera=(ua.indexOf('opera')>-1);var isSafari=(ua.indexOf('safari')>-1);var isIE=(window.ActiveXObject);var id_counter=0;var util=YAHOO.util;var property_cache={};var toCamel=function(property){var convert=function(prop){var test=/(-[a-z])/i.exec(prop);return prop.replace(RegExp.$1,RegExp.$1.substr(1).toUpperCase());};while(property.indexOf('-')>-1){property=convert(property);}return property;};var toHyphen=function(property){if(property.indexOf('-')>-1){return property;}var converted='';for(var i=0,len=property.length;i=this.left&®ion.right<=this.right&®ion.top>=this.top&®ion.bottom<=this.bottom);};YAHOO.util.Region.prototype.getArea=function(){return((this.bottom-this.top)*(this.right-this.left));};YAHOO.util.Region.prototype.intersect=function(region){var t=Math.max(this.top,region.top);var r=Math.min(this.right,region.right);var b=Math.min(this.bottom,region.bottom);var l=Math.max(this.left,region.left);if(b>=t&&r>=l){return new YAHOO.util.Region(t,r,b,l);}else{return null;}};YAHOO.util.Region.prototype.union=function(region){var t=Math.min(this.top,region.top);var r=Math.max(this.right,region.right);var b=Math.max(this.bottom,region.bottom);var l=Math.min(this.left,region.left);return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Region.prototype.toString=function(){return("Region {"+"top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+", left: "+this.left+"}");};YAHOO.util.Region.getRegion=function(el){var p=YAHOO.util.Dom.getXY(el);var t=p[1];var r=p[0]+el.offsetWidth;var b=p[1]+el.offsetHeight;var l=p[0];return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Point=function(x,y){if(x instanceof Array){y=x[1];x=x[0];}this.x=this.right=this.left=this[0]=x;this.y=this.top=this.bottom=this[1]=y;};YAHOO.util.Point.prototype=new YAHOO.util.Region(); /* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 0.11.0 */ YAHOO.util.CustomEvent=function(_1,_2,_3){this.type=_1;this.scope=_2||window;this.silent=_3;this.subscribers=[];if(YAHOO.util.Event){YAHOO.util.Event.regCE(this);}if(!this.silent){}};YAHOO.util.CustomEvent.prototype={subscribe:function(fn,_5,_6){this.subscribers.push(new YAHOO.util.Subscriber(fn,_5,_6));},unsubscribe:function(fn,_7){var _8=false;for(var i=0,len=this.subscribers.length;i=0){_60=_18[_59];}if(!el||!_60){return false;}if(el.removeEventListener){el.removeEventListener(_58,_60[this.WFN],false);}else{if(el.detachEvent){el.detachEvent("on"+_58,_60[this.WFN]);}}delete _18[_59][this.WFN];delete _18[_59][this.FN];delete _18[_59];return true;},getTarget:function(ev,_62){var t=ev.target||ev.srcElement;return this.resolveTextNode(t);},resolveTextNode:function(_64){if(_64&&_64.nodeName&&"#TEXT"==_64.nodeName.toUpperCase()){return _64.parentNode;}else{return _64;}},getPageX:function(ev){var x=ev.pageX;if(!x&&0!==x){x=ev.clientX||0;if(this.isIE){x+=this._getScrollLeft();}}return x;},getPageY:function(ev){var y=ev.pageY;if(!y&&0!==y){y=ev.clientY||0;if(this.isIE){y+=this._getScrollTop();}}return y;},getXY:function(ev){return [this.getPageX(ev),this.getPageY(ev)];},getRelatedTarget:function(ev){var t=ev.relatedTarget;if(!t){if(ev.type=="mouseout"){t=ev.toElement;}else{if(ev.type=="mouseover"){t=ev.fromElement;}}}return this.resolveTextNode(t);},getTime:function(ev){if(!ev.time){var t=new Date().getTime();try{ev.time=t;}catch(e){return t;}}return ev.time;},stopEvent:function(ev){this.stopPropagation(ev);this.preventDefault(ev);},stopPropagation:function(ev){if(ev.stopPropagation){ev.stopPropagation();}else{ev.cancelBubble=true;}},preventDefault:function(ev){if(ev.preventDefault){ev.preventDefault();}else{ev.returnValue=false;}},getEvent:function(e){var ev=e||window.event;if(!ev){var c=this.getEvent.caller;while(c){ev=c.arguments[0];if(ev&&Event==ev.constructor){break;}c=c.caller;}}return ev;},getCharCode:function(ev){return ev.charCode||((ev.type=="keypress")?ev.keyCode:0);},_getCacheIndex:function(el,_68,fn){for(var i=0,len=_18.length;i0);}var _73=[];for(var i=0,len=_19.length;i0){for(var i=0,len=_18.length;i0){for(i=0,len=_18.length;i=200&&httpStatus<300){responseObject=this.createResponseObject(o,callback.argument);if(callback.success){if(!callback.scope){callback.success(responseObject);} else{callback.success.apply(callback.scope,[responseObject]);}}} else{switch(httpStatus){case 12002:case 12029:case 12030:case 12031:case 12152:case 13030:responseObject=this.createExceptionObject(o.tId,callback.argument,isAbort);if(callback.failure){if(!callback.scope){callback.failure(responseObject);} else{callback.failure.apply(callback.scope,[responseObject]);}} break;default:responseObject=this.createResponseObject(o,callback.argument);if(callback.failure){if(!callback.scope){callback.failure(responseObject);} else{callback.failure.apply(callback.scope,[responseObject]);}}}} this.releaseObject(o);},createResponseObject:function(o,callbackArg) {var obj={};var headerObj={};try {var headerStr=o.conn.getAllResponseHeaders();var header=headerStr.split('\n');for(var i=0;i');if(secureUri){io.src=secureUri;}} else{var io=document.createElement('IFRAME');io.id='ioFrame';io.name='ioFrame';} io.style.position='absolute';io.style.top='-1000px';io.style.left='-1000px';document.body.appendChild(io);},uploadFile:function(id,callback,uri){this._formNode.action=uri;this._formNode.enctype='multipart/form-data';this._formNode.method='POST';this._formNode.target='ioFrame';this._formNode.submit();this._formNode=null;this._isFileUpload=false;this._isFormSubmit=false;var uploadCallback=function() {var oResponse={tId:id,responseText:document.getElementById("ioFrame").contentWindow.document.body.innerHTML,argument:callback.argument} if(callback.upload&&!callback.scope){callback.upload(oResponse);} else{callback.upload.apply(callback.scope,[oResponse]);} YAHOO.util.Event.removeListener("ioFrame","load",uploadCallback);window.ioFrame.location.replace('#');setTimeout("document.body.removeChild(document.getElementById('ioFrame'))",100);};YAHOO.util.Event.addListener("ioFrame","load",uploadCallback);},abort:function(o,callback,isTimeout) {if(this.isCallInProgress(o)){window.clearInterval(this._poll[o.tId]);this._poll.splice(o.tId);if(isTimeout){this._timeOut.splice(o.tId);} o.conn.abort();this.handleTransactionResponse(o,callback,true);return true;} else{return false;}},isCallInProgress:function(o) {if(o.conn){return o.conn.readyState!=4&&o.conn.readyState!=0;} else{return false;}},releaseObject:function(o) {o.conn=null;o=null;}}; /* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.txt version: 0.11.0 */ YAHOO.widget.AutoComplete=function(inputEl,containerEl,oDataSource,oConfigs){if(inputEl&&containerEl&&oDataSource){if(oDataSource&&(oDataSource instanceof YAHOO.widget.DataSource)){this.dataSource=oDataSource;} else{return;} if(YAHOO.util.Dom.inDocument(inputEl)){if(typeof inputEl=="string"){this._sName="instance"+YAHOO.widget.AutoComplete._nIndex+" "+inputEl;this._oTextbox=document.getElementById(inputEl);} else{this._sName=(inputEl.id)?"instance"+YAHOO.widget.AutoComplete._nIndex+" "+inputEl.id:"instance"+YAHOO.widget.AutoComplete._nIndex;this._oTextbox=inputEl;}} else{return;} if(YAHOO.util.Dom.inDocument(containerEl)){if(typeof containerEl=="string"){this._oContainer=document.getElementById(containerEl);} else{this._oContainer=containerEl;} if(this._oContainer.style.display=="none"){}} else{return;} if(typeof oConfigs=="object"){for(var sConfig in oConfigs){if(sConfig){this[sConfig]=oConfigs[sConfig];}}} this._initContainer();this._initProps();this._initList();this._initContainerHelpers();var oSelf=this;var oTextbox=this._oTextbox;var oContent=this._oContainer._oContent;YAHOO.util.Event.addListener(oTextbox,"keyup",oSelf._onTextboxKeyUp,oSelf);YAHOO.util.Event.addListener(oTextbox,"keydown",oSelf._onTextboxKeyDown,oSelf);YAHOO.util.Event.addListener(oTextbox,"keypress",oSelf._onTextboxKeyPress,oSelf);YAHOO.util.Event.addListener(oTextbox,"focus",oSelf._onTextboxFocus,oSelf);YAHOO.util.Event.addListener(oTextbox,"blur",oSelf._onTextboxBlur,oSelf);YAHOO.util.Event.addListener(oContent,"mouseover",oSelf._onContainerMouseover,oSelf);YAHOO.util.Event.addListener(oContent,"mouseout",oSelf._onContainerMouseout,oSelf);YAHOO.util.Event.addListener(oContent,"scroll",oSelf._onContainerScroll,oSelf);YAHOO.util.Event.addListener(oContent,"resize",oSelf._onContainerResize,oSelf);if(oTextbox.form){YAHOO.util.Event.addListener(oTextbox.form,"submit",oSelf._onFormSubmit,oSelf);} this.textboxFocusEvent=new YAHOO.util.CustomEvent("textboxFocus",this);this.textboxKeyEvent=new YAHOO.util.CustomEvent("textboxKey",this);this.dataRequestEvent=new YAHOO.util.CustomEvent("dataRequest",this);this.dataReturnEvent=new YAHOO.util.CustomEvent("dataReturn",this);this.dataErrorEvent=new YAHOO.util.CustomEvent("dataError",this);this.containerExpandEvent=new YAHOO.util.CustomEvent("containerExpand",this);this.typeAheadEvent=new YAHOO.util.CustomEvent("typeAhead",this);this.itemMouseOverEvent=new YAHOO.util.CustomEvent("itemMouseOver",this);this.itemMouseOutEvent=new YAHOO.util.CustomEvent("itemMouseOut",this);this.itemArrowToEvent=new YAHOO.util.CustomEvent("itemArrowTo",this);this.itemArrowFromEvent=new YAHOO.util.CustomEvent("itemArrowFrom",this);this.itemSelectEvent=new YAHOO.util.CustomEvent("itemSelect",this);this.unmatchedItemSelectEvent=new YAHOO.util.CustomEvent("unmatchedItemSelect",this);this.selectionEnforceEvent=new YAHOO.util.CustomEvent("selectionEnforce",this);this.containerCollapseEvent=new YAHOO.util.CustomEvent("containerCollapse",this);this.textboxBlurEvent=new YAHOO.util.CustomEvent("textboxBlur",this);oTextbox.setAttribute("autocomplete","off");YAHOO.widget.AutoComplete._nIndex++;} else{}};YAHOO.widget.AutoComplete.prototype.dataSource=null;YAHOO.widget.AutoComplete.prototype.minQueryLength=1;YAHOO.widget.AutoComplete.prototype.maxResultsDisplayed=10;YAHOO.widget.AutoComplete.prototype.queryDelay=0.5;YAHOO.widget.AutoComplete.prototype.highlightClassName="yui-ac-highlight";YAHOO.widget.AutoComplete.prototype.prehighlightClassName=null;YAHOO.widget.AutoComplete.prototype.delimChar=null;YAHOO.widget.AutoComplete.prototype.autoHighlight=true;YAHOO.widget.AutoComplete.prototype.typeAhead=false;YAHOO.widget.AutoComplete.prototype.animHoriz=false;YAHOO.widget.AutoComplete.prototype.animVert=true;YAHOO.widget.AutoComplete.prototype.animSpeed=0.3;YAHOO.widget.AutoComplete.prototype.forceSelection=false;YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete=true;YAHOO.widget.AutoComplete.prototype.alwaysShowContainer=false;YAHOO.widget.AutoComplete.prototype.useIFrame=false;YAHOO.widget.AutoComplete.prototype.iFrameSrc="about:blank";YAHOO.widget.AutoComplete.prototype.useShadow=false;YAHOO.widget.AutoComplete.prototype.getName=function(){return this._sName;};YAHOO.widget.AutoComplete.prototype.toString=function(){return"AutoComplete "+this._sName;};YAHOO.widget.AutoComplete.prototype.getListItems=function(){return this._aListItems;};YAHOO.widget.AutoComplete.prototype.getListItemData=function(oListItem){if(oListItem._oResultData){return oListItem._oResultData;} else{return false;}};YAHOO.widget.AutoComplete.prototype.setHeader=function(sHeader){if(sHeader){if(this._oContainer._oContent._oHeader){this._oContainer._oContent._oHeader.innerHTML=sHeader;this._oContainer._oContent._oHeader.style.display="block";}} else{this._oContainer._oContent._oHeader.innerHTML="";this._oContainer._oContent._oHeader.style.display="none";}};YAHOO.widget.AutoComplete.prototype.setFooter=function(sFooter){if(sFooter){if(this._oContainer._oContent._oFooter){this._oContainer._oContent._oFooter.innerHTML=sFooter;this._oContainer._oContent._oFooter.style.display="block";}} else{this._oContainer._oContent._oFooter.innerHTML="";this._oContainer._oContent._oFooter.style.display="none";}};YAHOO.widget.AutoComplete.prototype.setBody=function(sBody){if(sBody){if(this._oContainer._oContent._oBody){this._oContainer._oContent._oBody.innerHTML=sBody;this._oContainer._oContent._oBody.style.display="block";this._oContainer._oContent.style.display="block";}} else{this._oContainer._oContent._oBody.innerHTML="";this._oContainer._oContent.style.display="none";} this._maxResultsDisplayed=0;};YAHOO.widget.AutoComplete.prototype.formatResult=function(oResultItem,sQuery){var sResult=oResultItem[0];if(sResult){return sResult;} else{return"";}};YAHOO.widget.AutoComplete.prototype.sendQuery=function(sQuery){if(sQuery){this._sendQuery(sQuery);} else{return;}};YAHOO.widget.AutoComplete.prototype.textboxFocusEvent=null;YAHOO.widget.AutoComplete.prototype.textboxKeyEvent=null;YAHOO.widget.AutoComplete.prototype.dataRequestEvent=null;YAHOO.widget.AutoComplete.prototype.dataReturnEvent=null;YAHOO.widget.AutoComplete.prototype.dataErrorEvent=null;YAHOO.widget.AutoComplete.prototype.containerExpandEvent=null;YAHOO.widget.AutoComplete.prototype.typeAheadEvent=null;YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent=null;YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent=null;YAHOO.widget.AutoComplete.prototype.itemArrowToEvent=null;YAHOO.widget.AutoComplete.prototype.itemArrowFromEvent=null;YAHOO.widget.AutoComplete.prototype.itemSelectEvent=null;YAHOO.widget.AutoComplete.prototype.unmatchedItemSelectEvent=null;YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent=null;YAHOO.widget.AutoComplete.prototype.containerCollapseEvent=null;YAHOO.widget.AutoComplete.prototype.textboxBlurEvent=null;YAHOO.widget.AutoComplete._nIndex=0;YAHOO.widget.AutoComplete.prototype._sName=null;YAHOO.widget.AutoComplete.prototype._oTextbox=null;YAHOO.widget.AutoComplete.prototype._bFocused=true;YAHOO.widget.AutoComplete.prototype._oAnim=null;YAHOO.widget.AutoComplete.prototype._oContainer=null;YAHOO.widget.AutoComplete.prototype._bContainerOpen=false;YAHOO.widget.AutoComplete.prototype._bOverContainer=false;YAHOO.widget.AutoComplete.prototype._aListItems=null;YAHOO.widget.AutoComplete.prototype._nDisplayedItems=0;YAHOO.widget.AutoComplete.prototype._maxResultsDisplayed=0;YAHOO.widget.AutoComplete.prototype._sCurQuery=null;YAHOO.widget.AutoComplete.prototype._sSavedQuery=null;YAHOO.widget.AutoComplete.prototype._oCurItem=null;YAHOO.widget.AutoComplete.prototype._bItemSelected=false;YAHOO.widget.AutoComplete.prototype._nKeyCode=null;YAHOO.widget.AutoComplete.prototype._nDelayID=-1;YAHOO.widget.AutoComplete.prototype._initProps=function(){var minQueryLength=this.minQueryLength;if(isNaN(minQueryLength)||(minQueryLength<1)){minQueryLength=1;} var maxResultsDisplayed=this.maxResultsDisplayed;if(isNaN(this.maxResultsDisplayed)||(this.maxResultsDisplayed<1)){this.maxResultsDisplayed=10;} var queryDelay=this.queryDelay;if(isNaN(this.queryDelay)||(this.queryDelay<0)){this.queryDelay=0.5;} var aDelimChar=(this.delimChar)?this.delimChar:null;if(aDelimChar){if(typeof aDelimChar=="string"){this.delimChar=[aDelimChar];} else if(aDelimChar.constructor!=Array){this.delimChar=null;}} var animSpeed=this.animSpeed;if((this.animHoriz||this.animVert)&&YAHOO.util.Anim){if(isNaN(animSpeed)||(animSpeed<0)){animSpeed=0.3;} if(!this._oAnim){oAnim=new YAHOO.util.Anim(this._oContainer._oContent,{},this.animSpeed);this._oAnim=oAnim;} else{this._oAnim.duration=animSpeed;}} if(this.forceSelection&&this.delimChar){} if(this.alwaysShowContainer&&(this.useShadow||this.useIFrame)){} if(this.alwaysShowContainer){this._bContainerOpen=true;}};YAHOO.widget.AutoComplete.prototype._initContainerHelpers=function(){if(this.useShadow&&!this._oContainer._oShadow){var oShadow=document.createElement("div");oShadow.className="yui-ac-shadow";this._oContainer._oShadow=this._oContainer.appendChild(oShadow);} if(this.useIFrame&&!this._oContainer._oIFrame){var oIFrame=document.createElement("iframe");oIFrame.src=this.iFrameSrc;oIFrame.frameBorder=0;oIFrame.scrolling="no";oIFrame.style.position="absolute";oIFrame.style.width="100%";oIFrame.style.height="100%";this._oContainer._oIFrame=this._oContainer.appendChild(oIFrame);}};YAHOO.widget.AutoComplete.prototype._initContainer=function(){if(!this._oContainer._oContent){var oContent=document.createElement("div");oContent.className="yui-ac-content";oContent.style.display="none";this._oContainer._oContent=this._oContainer.appendChild(oContent);var oHeader=document.createElement("div");oHeader.className="yui-ac-hd";oHeader.style.display="none";this._oContainer._oContent._oHeader=this._oContainer._oContent.appendChild(oHeader);var oBody=document.createElement("div");oBody.className="yui-ac-bd";this._oContainer._oContent._oBody=this._oContainer._oContent.appendChild(oBody);var oFooter=document.createElement("div");oFooter.className="yui-ac-ft";oFooter.style.display="none";this._oContainer._oContent._oFooter=this._oContainer._oContent.appendChild(oFooter);} else{}};YAHOO.widget.AutoComplete.prototype._initList=function(){this._aListItems=[];while(this._oContainer._oContent._oBody.hasChildNodes()){var oldListItems=this.getListItems();if(oldListItems){for(var oldi=oldListItems.length-1;oldi>=0;i--){oldListItems[oldi]=null;}} this._oContainer._oContent._oBody.innerHTML="";} var oList=document.createElement("ul");oList=this._oContainer._oContent._oBody.appendChild(oList);for(var i=0;i0){var nDelayID=setTimeout(function(){oSelf._sendQuery(sText);},(oSelf.queryDelay*1000));if(oSelf._nDelayID!=-1){clearTimeout(oSelf._nDelayID);} oSelf._nDelayID=nDelayID;} else{oSelf._sendQuery(sText);}};YAHOO.widget.AutoComplete.prototype._isIgnoreKey=function(nKeyCode){if((nKeyCode==9)||(nKeyCode==13)||(nKeyCode==16)||(nKeyCode==17)||(nKeyCode>=18&&nKeyCode<=20)||(nKeyCode==27)||(nKeyCode>=33&&nKeyCode<=35)||(nKeyCode>=36&&nKeyCode<=38)||(nKeyCode==40)||(nKeyCode>=44&&nKeyCode<=45)){return true;} return false;};YAHOO.widget.AutoComplete.prototype._onTextboxFocus=function(v,oSelf){oSelf._oTextbox.setAttribute("autocomplete","off");oSelf._bFocused=true;oSelf.textboxFocusEvent.fire(oSelf);};YAHOO.widget.AutoComplete.prototype._onTextboxBlur=function(v,oSelf){if(!oSelf._bOverContainer||(oSelf._nKeyCode==9)){if(!oSelf._bItemSelected){if(!oSelf._bContainerOpen||(oSelf._bContainerOpen&&!oSelf._textMatchesOption())){if(oSelf.forceSelection){oSelf._clearSelection();} else{oSelf.unmatchedItemSelectEvent.fire(oSelf,oSelf._sCurQuery);}}} if(oSelf._bContainerOpen){oSelf._clearList();} oSelf._bFocused=false;oSelf.textboxBlurEvent.fire(oSelf);}};YAHOO.widget.AutoComplete.prototype._onFormSubmit=function(v,oSelf){if(oSelf.allowBrowserAutocomplete){oSelf._oTextbox.setAttribute("autocomplete","on");} else{oSelf._oTextbox.setAttribute("autocomplete","off");}};YAHOO.widget.AutoComplete.prototype._sendQuery=function(sQuery){var aDelimChar=(this.delimChar)?this.delimChar:null;if(aDelimChar){var nDelimIndex=-1;for(var i=aDelimChar.length-1;i>=0;i--){var nNewIndex=sQuery.lastIndexOf(aDelimChar[i]);if(nNewIndex>nDelimIndex){nDelimIndex=nNewIndex;}} if(aDelimChar[i]==" "){for(var j=aDelimChar.length-1;j>=0;j--){if(sQuery[nDelimIndex-1]==aDelimChar[j]){nDelimIndex--;break;}}} if(nDelimIndex>-1){var nQueryStart=nDelimIndex+1;while(sQuery.charAt(nQueryStart)==" "){nQueryStart+=1;} this._sSavedQuery=sQuery.substring(0,nQueryStart);sQuery=sQuery.substr(nQueryStart);} else if(sQuery.indexOf(this._sSavedQuery)<0){this._sSavedQuery=null;}} if(sQuery.length0)){for(var i=aItems.length-1;i>=0;i--){aItems[i].style.display="none";}} if(this._oCurItem){this._toggleHighlight(this._oCurItem,"from");} this._oCurItem=null;this._nDisplayedItems=0;this._sCurQuery=null;this._toggleContainer(false);};YAHOO.widget.AutoComplete.prototype._populateList=function(sQuery,aResults,oSelf){if(aResults===null){oSelf.dataErrorEvent.fire(oSelf,sQuery);} if(!oSelf._bFocused||!aResults){return;} var isOpera=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);var contentStyle=oSelf._oContainer._oContent.style;contentStyle.width=(!isOpera)?null:"";contentStyle.height=(!isOpera)?null:"";var sCurQuery=decodeURIComponent(sQuery);oSelf._sCurQuery=sCurQuery;oSelf._bItemSelected=false;if(oSelf._maxResultsDisplayed!=oSelf.maxResultsDisplayed){oSelf._initList();} var nItems=Math.min(aResults.length,oSelf.maxResultsDisplayed);oSelf._nDisplayedItems=nItems;if(nItems>0){oSelf._initContainerHelpers();var aItems=oSelf._aListItems;for(var i=nItems-1;i>=0;i--){var oItemi=aItems[i];var oResultItemi=aResults[i];oItemi.innerHTML=oSelf.formatResult(oResultItemi,sCurQuery);oItemi.style.display="list-item";oItemi._sResultKey=oResultItemi[0];oItemi._oResultData=oResultItemi;} for(var j=aItems.length-1;j>=nItems;j--){var oItemj=aItems[j];oItemj.innerHTML=null;oItemj.style.display="none";oItemj._sResultKey=null;oItemj._oResultData=null;} if(oSelf.autoHighlight){var oFirstItem=aItems[0];oSelf._toggleHighlight(oFirstItem,"to");oSelf.itemArrowToEvent.fire(oSelf,oFirstItem);oSelf._typeAhead(oFirstItem,sQuery);} else{oSelf._oCurItem=null;} oSelf._toggleContainer(true);} else{oSelf._clearList();} oSelf.dataReturnEvent.fire(oSelf,sQuery,aResults);};YAHOO.widget.AutoComplete.prototype._clearSelection=function(){var sValue=this._oTextbox.value;var sChar=(this.delimChar)?this.delimChar[0]:null;var nIndex=(sChar)?sValue.lastIndexOf(sChar,sValue.length-2):-1;if(nIndex>-1){this._oTextbox.value=sValue.substring(0,nIndex);} else{this._oTextbox.value="";} this._sSavedQuery=this._oTextbox.value;this.selectionEnforceEvent.fire(this);};YAHOO.widget.AutoComplete.prototype._textMatchesOption=function(){var foundMatch=false;for(var i=this._nDisplayedItems-1;i>=0;i--){var oItem=this._aListItems[i];var sMatch=oItem._sResultKey.toLowerCase();if(sMatch==this._sCurQuery.toLowerCase()){foundMatch=true;break;}} return(foundMatch);};YAHOO.widget.AutoComplete.prototype._typeAhead=function(oItem,sQuery){if(!this.typeAhead){return;} var oTextbox=this._oTextbox;var sValue=this._oTextbox.value;if(!oTextbox.setSelectionRange&&!oTextbox.createTextRange){return;} var nStart=sValue.length;this._updateValue(oItem);var nEnd=oTextbox.value.length;this._selectText(oTextbox,nStart,nEnd);var sPrefill=oTextbox.value.substr(nStart,nEnd);this.typeAheadEvent.fire(this,sQuery,sPrefill);};YAHOO.widget.AutoComplete.prototype._selectText=function(oTextbox,nStart,nEnd){if(oTextbox.setSelectionRange){oTextbox.setSelectionRange(nStart,nEnd);} else if(oTextbox.createTextRange){var oTextRange=oTextbox.createTextRange();oTextRange.moveStart("character",nStart);oTextRange.moveEnd("character",nEnd-oTextbox.value.length);oTextRange.select();} else{oTextbox.select();}};YAHOO.widget.AutoComplete.prototype._toggleContainerHelpers=function(bShow){var bFireEvent=false;var width=this._oContainer._oContent.offsetWidth+"px";var height=this._oContainer._oContent.offsetHeight+"px";if(this.useIFrame&&this._oContainer._oIFrame){bFireEvent=true;if(this.alwaysShowContainer||bShow){this._oContainer._oIFrame.style.width=width;this._oContainer._oIFrame.style.height=height;} else{this._oContainer._oIFrame.style.width=0;this._oContainer._oIFrame.style.height=0;}} if(this.useShadow&&this._oContainer._oShadow){bFireEvent=true;if(this.alwaysShowContainer||bShow){this._oContainer._oShadow.style.width=width;this._oContainer._oShadow.style.height=height;} else{this._oContainer._oShadow.style.width=0;this._oContainer._oShadow.style.height=0;}}};YAHOO.widget.AutoComplete.prototype._toggleContainer=function(bShow){if(this.alwaysShowContainer){if(bShow){this.containerExpandEvent.fire(this);} else{this.containerCollapseEvent.fire(this);} this._bContainerOpen=bShow;return;} var oContainer=this._oContainer;if(!bShow&&!this._bContainerOpen){oContainer._oContent.style.display="none";return;} var oAnim=this._oAnim;if(oAnim&&oAnim.getEl()&&(this.animHoriz||this.animVert)){if(!bShow){this._toggleContainerHelpers(bShow);} if(oAnim.isAnimated()){oAnim.stop();} var oClone=oContainer._oContent.cloneNode(true);oContainer.appendChild(oClone);oClone.style.top="-9000px";oClone.style.display="block";var wExp=oClone.offsetWidth;var hExp=oClone.offsetHeight;var wColl=(this.animHoriz)?0:wExp;var hColl=(this.animVert)?0:hExp;oAnim.attributes=(bShow)?{width:{to:wExp},height:{to:hExp}}:{width:{to:wColl},height:{to:hColl}};if(bShow&&!this._bContainerOpen){oContainer._oContent.style.width=wColl+"px";oContainer._oContent.style.height=hColl+"px";} else{oContainer._oContent.style.width=wExp+"px";oContainer._oContent.style.height=hExp+"px";} oContainer.removeChild(oClone);oClone=null;var oSelf=this;var onAnimComplete=function(){oAnim.onComplete.unsubscribeAll();if(bShow){oSelf.containerExpandEvent.fire(oSelf);} else{oContainer._oContent.style.display="none";oSelf.containerCollapseEvent.fire(oSelf);} oSelf._toggleContainerHelpers(bShow);};oContainer._oContent.style.display="block";oAnim.onComplete.subscribe(onAnimComplete);oAnim.animate();this._bContainerOpen=bShow;} else{if(bShow){oContainer._oContent.style.display="block";this.containerExpandEvent.fire(this);} else{oContainer._oContent.style.display="none";this.containerCollapseEvent.fire(this);} this._toggleContainerHelpers(bShow);this._bContainerOpen=bShow;}};YAHOO.widget.AutoComplete.prototype._toggleHighlight=function(oNewItem,sType){var sHighlight=this.highlightClassName;if(this._oCurItem){YAHOO.util.Dom.removeClass(this._oCurItem,sHighlight);} if((sType=="to")&&sHighlight){YAHOO.util.Dom.addClass(oNewItem,sHighlight);this._oCurItem=oNewItem;}};YAHOO.widget.AutoComplete.prototype._togglePrehighlight=function(oNewItem,sType){if(oNewItem==this._oCurItem){return;} var sPrehighlight=this.prehighlightClassName;if((sType=="mouseover")&&sPrehighlight){YAHOO.util.Dom.addClass(oNewItem,sPrehighlight);} else{YAHOO.util.Dom.removeClass(oNewItem,sPrehighlight);}};YAHOO.widget.AutoComplete.prototype._updateValue=function(oItem){var oTextbox=this._oTextbox;var sDelimChar=(this.delimChar)?this.delimChar[0]:null;var sSavedQuery=this._sSavedQuery;var sResultKey=oItem._sResultKey;oTextbox.focus();oTextbox.value="";if(sDelimChar){if(sSavedQuery){oTextbox.value=sSavedQuery;} oTextbox.value+=sResultKey+sDelimChar;if(sDelimChar!=" "){oTextbox.value+=" ";}} else{oTextbox.value=sResultKey;} if(oTextbox.type=="textarea"){oTextbox.scrollTop=oTextbox.scrollHeight;} var end=oTextbox.value.length;this._selectText(oTextbox,end,end);this._oCurItem=oItem;};YAHOO.widget.AutoComplete.prototype._selectItem=function(oItem){this._bItemSelected=true;this._updateValue(oItem);this.itemSelectEvent.fire(this,oItem,oItem._oResultData);this._clearList();};YAHOO.widget.AutoComplete.prototype._jumpSelection=function(){if(!this.typeAhead){return;} else{this._clearList();}};YAHOO.widget.AutoComplete.prototype._moveSelection=function(nKeyCode){if(this._bContainerOpen){var oCurItem=this._oCurItem;var nCurItemIndex=-1;if(oCurItem){nCurItemIndex=oCurItem._nItemIndex;} var nNewItemIndex=(nKeyCode==40)?(nCurItemIndex+1):(nCurItemIndex-1);if(nNewItemIndex<-2||nNewItemIndex>=this._nDisplayedItems){return;} if(oCurItem){this._toggleHighlight(oCurItem,"from");this.itemArrowFromEvent.fire(this,oCurItem);} if(nNewItemIndex==-1){if(this.delimChar&&this._sSavedQuery){if(!this._textMatchesOption()){this._oTextbox.value=this._sSavedQuery;} else{this._oTextbox.value=this._sSavedQuery+this._sCurQuery;}} else{this._oTextbox.value=this._sCurQuery;} this._oCurItem=null;return;} if(nNewItemIndex==-2){this._clearList();return;} var oNewItem=this._aListItems[nNewItemIndex];if((YAHOO.util.Dom.getStyle(this._oContainer._oContent,"overflow")=="auto")&&(nNewItemIndex>-1)&&(nNewItemIndex(this._oContainer._oContent.scrollTop+this._oContainer._oContent.offsetHeight)){this._oContainer._oContent.scrollTop=(oNewItem.offsetTop+oNewItem.offsetHeight)-this._oContainer._oContent.offsetHeight;} else if((oNewItem.offsetTop+oNewItem.offsetHeight)(this._oContainer._oContent.scrollTop+this._oContainer._oContent.offsetHeight)){this._oContainer._oContent.scrollTop=(oNewItem.offsetTop+oNewItem.offsetHeight)-this._oContainer._oContent.offsetHeight;}}} this._toggleHighlight(oNewItem,"to");this.itemArrowToEvent.fire(this,oNewItem);if(this.typeAhead){this._updateValue(oNewItem);}}};YAHOO.widget.DataSource=function(){};YAHOO.widget.DataSource.prototype.ERROR_DATANULL="Response data was null";YAHOO.widget.DataSource.prototype.ERROR_DATAPARSE="Response data could not be parsed";YAHOO.widget.DataSource.prototype.maxCacheEntries=15;YAHOO.widget.DataSource.prototype.queryMatchContains=false;YAHOO.widget.DataSource.prototype.queryMatchSubset=false;YAHOO.widget.DataSource.prototype.queryMatchCase=false;YAHOO.widget.DataSource.prototype.getName=function(){return this._sName;};YAHOO.widget.DataSource.prototype.toString=function(){return"DataSource "+this._sName;};YAHOO.widget.DataSource.prototype.getResults=function(oCallbackFn,sQuery,oParent){var aResults=this._doQueryCache(oCallbackFn,sQuery,oParent);if(aResults.length===0){this.queryEvent.fire(this,oParent,sQuery);this.doQuery(oCallbackFn,sQuery,oParent);}};YAHOO.widget.DataSource.prototype.doQuery=function(oCallbackFn,sQuery,oParent){};YAHOO.widget.DataSource.prototype.flushCache=function(){if(this._aCache){this._aCache=[];} if(this._aCacheHelper){this._aCacheHelper=[];} this.cacheFlushEvent.fire(this);};YAHOO.widget.DataSource.prototype.queryEvent=null;YAHOO.widget.DataSource.prototype.cacheQueryEvent=null;YAHOO.widget.DataSource.prototype.getResultsEvent=null;YAHOO.widget.DataSource.prototype.getCachedResultsEvent=null;YAHOO.widget.DataSource.prototype.dataErrorEvent=null;YAHOO.widget.DataSource.prototype.cacheFlushEvent=null;YAHOO.widget.DataSource._nIndex=0;YAHOO.widget.DataSource.prototype._sName=null;YAHOO.widget.DataSource.prototype._aCache=null;YAHOO.widget.DataSource.prototype._init=function(){var maxCacheEntries=this.maxCacheEntries;if(isNaN(maxCacheEntries)||(maxCacheEntries<0)){maxCacheEntries=0;} if(maxCacheEntries>0&&!this._aCache){this._aCache=[];} this._sName="instance"+YAHOO.widget.DataSource._nIndex;YAHOO.widget.DataSource._nIndex++;this.queryEvent=new YAHOO.util.CustomEvent("query",this);this.cacheQueryEvent=new YAHOO.util.CustomEvent("cacheQuery",this);this.getResultsEvent=new YAHOO.util.CustomEvent("getResults",this);this.getCachedResultsEvent=new YAHOO.util.CustomEvent("getCachedResults",this);this.dataErrorEvent=new YAHOO.util.CustomEvent("dataError",this);this.cacheFlushEvent=new YAHOO.util.CustomEvent("cacheFlush",this);};YAHOO.widget.DataSource.prototype._addCacheElem=function(resultObj){var aCache=this._aCache;if(!aCache||!resultObj||!resultObj.query||!resultObj.results){return;} if(aCache.length>=this.maxCacheEntries){aCache.shift();} aCache.push(resultObj);};YAHOO.widget.DataSource.prototype._doQueryCache=function(oCallbackFn,sQuery,oParent){var aResults=[];var bMatchFound=false;var aCache=this._aCache;var nCacheLength=(aCache)?aCache.length:0;var bMatchContains=this.queryMatchContains;if((this.maxCacheEntries>0)&&aCache&&(nCacheLength>0)){this.cacheQueryEvent.fire(this,oParent,sQuery);if(!this.queryMatchCase){var sOrigQuery=sQuery;sQuery=sQuery.toLowerCase();} for(var i=nCacheLength-1;i>=0;i--){var resultObj=aCache[i];var aAllResultItems=resultObj.results;var matchKey=(!this.queryMatchCase)?encodeURIComponent(resultObj.query.toLowerCase()):encodeURIComponent(resultObj.query);if(matchKey==sQuery){bMatchFound=true;aResults=aAllResultItems;if(i!=nCacheLength-1){aCache.splice(i,1);this._addCacheElem(resultObj);} break;} else if(this.queryMatchSubset){for(var j=sQuery.length-1;j>=0;j--){var subQuery=sQuery.substr(0,j);if(matchKey==subQuery){bMatchFound=true;for(var k=aAllResultItems.length-1;k>=0;k--){var aRecord=aAllResultItems[k];var sKeyIndex=(this.queryMatchCase)?encodeURIComponent(aRecord[0]).indexOf(sQuery):encodeURIComponent(aRecord[0]).toLowerCase().indexOf(sQuery);if((!bMatchContains&&(sKeyIndex===0))||(bMatchContains&&(sKeyIndex>-1))){aResults.unshift(aRecord);}} resultObj={};resultObj.query=sQuery;resultObj.results=aResults;this._addCacheElem(resultObj);break;}} if(bMatchFound){break;}}} if(bMatchFound){this.getCachedResultsEvent.fire(this,oParent,sOrigQuery,aResults);oCallbackFn(sOrigQuery,aResults,oParent);}} return aResults;};YAHOO.widget.DS_XHR=function(sScriptURI,aSchema,oConfigs){if(typeof oConfigs=="object"){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}} if(!aSchema||(aSchema.constructor!=Array)){return;} else{this.schema=aSchema;} this.scriptURI=sScriptURI;this._init();};YAHOO.widget.DS_XHR.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_XHR.prototype.TYPE_JSON=0;YAHOO.widget.DS_XHR.prototype.TYPE_XML=1;YAHOO.widget.DS_XHR.prototype.TYPE_FLAT=2;YAHOO.widget.DS_XHR.prototype.ERROR_DATAXHR="XHR response failed";YAHOO.widget.DS_XHR.prototype.connTimeout=0;YAHOO.widget.DS_XHR.prototype.scriptURI=null;YAHOO.widget.DS_XHR.prototype.scriptQueryParam="query";YAHOO.widget.DS_XHR.prototype.scriptQueryAppend="";YAHOO.widget.DS_XHR.prototype.responseType=YAHOO.widget.DS_XHR.prototype.TYPE_JSON;YAHOO.widget.DS_XHR.prototype.responseStripAfter="\n