Object.extend = function(destination, source) { for (property in source) { destination[property] = source[property]; } return destination; } Object.extend(String.prototype, { escapeHTML : function() { var _D = document.createElement("DIV"); var _T = document.createTextNode(this); _D.appendChild(_T); return(_D.innerHTML); }, unescapeHTML : function() { var _D = document.createElement("DIV"); _D.innerHTML = this.stripTags(); return(_D.childNodes[0] ? _D.childNodes[0].nodeValue : ''); }, stripTags: function() { return(this.replace(/<\/?[^>]+>/gi, '')); }, selectTextRange : function(_Start, _End) { if (this.setSelectionRange) this.setSelectionRange(_Start,_End); else if (this.createTextRange) { var range = this.createTextRange(); range.moveStart("character", _Start); range.moveEnd("character", _End-this.value.length); range.select(); } else this.select(); } }); Function.prototype.bind = function(obj) { var method = this; return function() { return method.apply(obj, arguments); } } var QueryString = new function() { this.init = function() { var parts = new Array(); parts = parts.concat(window.location.search.substring(1).split('&')); parts = parts.concat(window.location.hash.substring(1).split('&')); for (var i in parts) { var kv = parts[i].split('='); this[kv[0]] = unescape(kv[1]); } } this.combine = function() { var parts = new Array(); for (var i in this) { if (typeof(i)!='string' || !(i)) continue; if (typeof(this[i])!='string' && typeof(this[i])!='number') continue; parts.push(escape(i) + '=' + escape(this[i])); } return parts.join('&'); } this.init(); } function within (n, m) { var f = 150; //fuzziness amount m = parseInt(m); n = parseInt(n); //YAHOO.log(n + ">" + (m-f) + " && " + n + " < " + (m+f)); return (n > (m-f) && n < (m+f)); } function array_count(array) { var arrayCount = 0; if(isObj(array)) for( all in array ) arrayCount++; return arrayCount; } function array_find(string, haystack) { for( index in haystack ) if( haystack[index] == string ) return haystack[index]; else if( isObj( haystack[index] ) ) array_find(string, haystack[index]); } function array_first(array) { if(isObj(array)) for( first in array ) return array[first]; return false; } function array_inspect(array) { for(var i in array) ylog("Array["+i+"] : "+(typeof array[i]=='object'?'Array()':array[i])); } function trim(str) { str = this != window? this : str; return str.replace(/^\s+/g, '').replace(/\s+$/g, ''); } function selectTextRange(_T, zStart, zEnd) { if (_T.setSelectionRange) _T.setSelectionRange(zStart,zEnd); else if (_T.createTextRange) { var range = _T.createTextRange(); range.moveStart("character", zStart); range.moveEnd("character", zEnd-_T.value.length); range.select(); } else _T.select(); } function isIE6() { if( window.ActiveXObject && !( window.XMLHttpRequest ) ) return true; return false; } function isObj(what) { if(typeof what == 'object') return true; return false; } function el(type) { return document.createElement(type); } function createElement(e) { return document.createElement(e); } function isset(what) { if(typeof what != 'undefined') return true; return false; } function objToString(obj) { var string; for( o in obj ) string += o + ':' + obj[o] + "\r\n"; return(string); } function ylog(what) { YAHOO.widget.Logger.log(what); } function $() { var elements = new Array(); for (var i = 0; i < arguments.length; i++) { var element = arguments[i]; if (typeof element == 'string') element = document.getElementById(element); if (arguments.length == 1) return element; elements.push(element); } return elements; } function hasClass(el, _class) { return YAHOO.util.Dom.hasClass(el, _class); } function addClass(el, _class) { if(!hasClass(el, _class)) YAHOO.util.Dom.addClass(el, _class); } function removeClass(el, _class) { if(hasClass(el, _class)) YAHOO.util.Dom.removeClass(el, _class); } function toggleClass(el, _class) { if(hasClass(el, _class)) { YAHOO.util.Dom.removeClass(el, _class); return false; } else { YAHOO.util.Dom.addClass(el, _class); return true; } } function setStyle(el, _property, _value ) { YAHOO.util.Dom.setStyle(el, _property, _value); } function getStyle(el, _property) { return YAHOO.util.Dom.getStyle(el, _property); } function generateUniqueID(el, prefix) { return YAHOO.util.Dom.generateId(el, prefix); } function generateId(el, prefix) { return YAHOO.util.Dom.generateId(el, prefix); } function appendChildren(_el, children) { for (var i=0; i < children.length; i++) { _el.appendChild(children[i]); } } function cssVisibility(el, _vis) { el.style.visibility = _vis; } function cssDisplay(el, _disp) { el.style.display = _disp; } function swapClass(el, _class, _swap) { if(hasClass(el, _class)) { YAHOO.util.Dom.removeClass(el, _class); YAHOO.util.Dom.addClass(el, _swap); } else YAHOO.util.Dom.addClass(el, _swap); } function isElementInView(container, _el) { if (((_el.offsetTop-container.scrollTop)>=0) && ((_el.offsetTop-container.scrollTop)+_el.offsetHeight' + (step_no>=0 && step_no!=null ? step_no : ' ' )+ '' + ' ' + step_text + ''; // append to body append_to.appendChild(container); // no clickie! if (YAHOO.util.Event) YAHOO.util.Event.addListener(container, 'mousedown', function(evt) { YAHOO.util.Event.preventDefault(evt); }); } function str_truncate(str, max_length) { if((str) && (str.length>max_length)) return str.substr(0, max_length) + '...'; else return str; } // count how many times the needle (nedl) appears in the hayStack object // will work with objects, and multi-dimensional arrays ( obj[i] -> value OR obj[i]->obj.name) function countDupes(hayStack, nedl) { var dupes = 0; for( var i in hayStack ) { var name = isObj(hayStack[i]) ? hayStack[i].name : hayStack[i]; var nameTrunc = name.substr(0, nedl.length); if(nameTrunc.toLowerCase() == nedl) { var currentNum = name.substr( parseInt(nedl.length)+1 , name.length); if(currentNum > dupes) dupes = parseInt(currentNum)+1; if(currentNum == dupes) ++dupes; } } return dupes; } function clone(oo) { var buf = {}; for (var i in oo) buf[i] = oo[i]; return buf; } function page_size_str(page) { if (!(page.width)) return false; else if (within(page.width, 3600) && within(page.height, 3600)) return '12"x12"'; else if (within(page.width, 2400) && within(page.height, 2400)) return '8"x8"'; else return false; } function search_go() { var search_text = document.getElementById("headr-searchfrm").value; if (search_text) window.location="/php/project_search.php#page=0&terms=" + escape(search_text); } function notify( hedr, body, cfgPropType, cfgPropExtra, buttons, listeners ) { YAHOO.namespace("notify"); YAHOO.notify.dlg = new YAHOO.widget.SimpleDialog("dlg", { width: "20em", fixedcenter:true, modal:true, draggable:false,close:false,zIndex:100000 }); YAHOO.notify.dlg.setHeader(hedr); YAHOO.notify.dlg.setBody(body); YAHOO.notify.dlg.cfg.queueProperty(cfgPropType, cfgPropExtra); YAHOO.notify.dlg.cfg.queueProperty("buttons", buttons ); if(listeners) YAHOO.notify.dlg.cfg.queueProperty("keylisteners", listeners); YAHOO.notify.dlg.render(document.body); YAHOO.notify.dlg.mask.style.zIndex ='99996'; return YAHOO.notify.dlg; } function info_notify(header, body) { var handleOk = function(e) { this.hide(); this.destroy(); } var hedr = header?header:"Information"; var body = body?body:"body"; var cfgPropType = "icon"; var cfgPropExtra = YAHOO.widget.SimpleDialog.ICON_INFO; var buttons = [ { text:"OK", handler:handleOk, isDefault:true } ]; notify(hedr, body, cfgPropType, cfgPropExtra, buttons, null); } function err_panel(header, body) { var handleOk = function(e) { this.hide(); this.destroy(); } var hedr = header?header:"Error!"; var body = body?body:"An error as occurred."; var cfgPropType = "icon"; var cfgPropExtra = YAHOO.widget.SimpleDialog.ICON_ALERT; var buttons = [ { text:"OK", handler:handleOk, isDefault:true } ]; notify(hedr, body, cfgPropType, cfgPropExtra, buttons, null); } function confirm_panel(header, body, handleYes, handleCancel) { if (!(handleCancel)) { var handleCancel = function() { this.hide(); this.destroy(); } } var hedr = header?header:"Please confirm!"; var body = body?body:"body"; var cfgPropType = "icon"; var cfgPropExtra = YAHOO.widget.SimpleDialog.ICON_WARN; var buttons = [ { text:"Yes", handler:handleYes }, { text:"Cancel", handler:handleCancel, isDefault:true } ]; return notify(hedr, body, cfgPropType, cfgPropExtra, buttons, null); } function Dialog(headr, body, width, id, _listeners, _buttons, modal, draggable, close) { YAHOO.namespace("common"); YAHOO.common.Dialog = new YAHOO.widget.SimpleDialog(id?id:"common_dialog", { width:width, fixedcenter:true, modal:!modal?false:true, draggable:!draggable?false:true, close:!close?true:false }); YAHOO.common.Dialog.setHeader( headr ); YAHOO.common.Dialog.setBody( body ); if( _listeners ) { var listeners = new YAHOO.util.KeyListener(document, { keys : 27 }, {fn:handleCancel,scope:YAHOO.mp.dlg[bindTo],correctScope:true} ); YAHOO.common.Dialog.cfg.queueProperty("keylisteners", listeners); } if( _buttons ) YAHOO.common.Dialog.cfg.queueProperty("buttons", [ { text:"Submit", handler:handleSubmit } ]); var handleCancel = function() { this.cancel(); } var handleSubmit = function() { this.submit(); } var handleManual = function(type, args, obj) { alert("Manual submission of " + this.id + " detected"); } YAHOO.common.Dialog.manualSubmitEvent.subscribe(handleManual, YAHOO.common.Dialog, true); YAHOO.common.Dialog.render( document.body ); YAHOO.common.Dialog.show(); return YAHOO.common.Dialog; } function DialogAlert(message, width, title) { var dlg = new YAHOO.widget.SimpleDialog("common_dialogalert", {width: width ? width : "245px",fixedcenter:true,modal:true,draggable:false,visible:true,buttons:[{text:"OK",handler:function(){this.hide();this.destroy()}}]}); dlg.setHeader(title ? title : "Message"); dlg.setBody(message); dlg.render(document.body); } function zoomPanel(path) { var zoomPanel = new YAHOO.widget.Panel("zoomPanel", { fixedCenter: true, constraintoviewport: true, underlay: "shadow", close: true, visible: false, draggable: false, modal: true, zIndex: 50002 }); zoomPanel.setHeader(' '); zoomPanel.setBody('
 
'); zoomPanel.render(document.body); var img = el("img"); // EVENT YAHOO.util.Event.addListener(img, 'load', function (ev, zoomPanel) { YAHOO.util.Event.purgeElement(this); zoomPanel.setBody(this); zoomPanel.show(); }, zoomPanel, false ); img.src = path; zoomPanel.setBody(img); } function waitPanel(wait_msg) { var wait_dlg = new YAHOO.widget.Panel("wait", { width:"230px", fixedcenter:true, close:false, draggable:false, modal:true, visible:true, zIndex: 100000 } ); wait_dlg.setHeader(wait_msg?wait_msg:"Loading, please wait..."); wait_dlg.setBody(''); wait_dlg.render(document.body); return wait_dlg; } /* COOKIE OBJECT usage: write a cookie cookie.write('cookieName', value); both parameters are optionl read a cookie Cookie.read() var data = Cookie.data.cookieName; */ var Cookie = { data: {}, read: function() { var start = document.cookie.indexOf('PWDMEM='); var len = (start+7); var end = document.cookie.indexOf(";", len); this.data = JSON.decode(unescape(document.cookie.substring(len, end) || {})) || {}; return this.data; }, write: function(kookie, value) { this.read(); this.data[kookie] = value; document.cookie = "PWDMEM=" + escape(JSON.stringify(this.data)) + "; "; } } if (window.JSON) Cookie.read(); function Panel(pid, config) { return YAHOO.widget.Panel(pid, config); } function Dialog(did, config) { return YAHOO.widget.Dialog(did, config); } function SimpleDialog(sdid, config) { return YAHOO.widget.SimpleDialog(sdid, config); }