function addEvent(element, type, handler) {
if (!handler.$$guid) handler.$$guid = addEvent.guid++;
if (!element.events) element.events = {};
var handlers = element.events[type];
if (!handlers) {
handlers = element.events[type] = {};
if (element["on" + type]) {
handlers[0] = element["on" + type];
}
}
handlers[handler.$$guid] = handler;
element["on" + type] = handleEvent;
};
addEvent.guid = 1;
function removeEvent(element, type, handler) {
if (element.events && element.events[type]) {
delete element.events[type][handler.$$guid];
}
};
function handleEvent(event) {
event = event || window.event;
var handlers = this.events[event.type];
for (var i in handlers) {
this.$$handleEvent = handlers[i];
this.$$handleEvent(event);
}
};
function getElementsByClassName(oElm, strTagName, strClassName){
var arrElements = (strTagName == "*" && oElm.all) ? oElm.all : oElm.getElementsByTagName(strTagName);
var arrReturnElements = new Array();
strClassName = strClassName.replace(/\-/g, "\\-");
var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
var oElement;
for(var i=0; i<arrElements.length; i++){
oElement = arrElements[i];
if(oRegExp.test(oElement.className)){
arrReturnElements.push(oElement);
}
}
return (arrReturnElements)
}
function addClassName(oEl, sClass) {
oEl.className += " " + sClass;
}
function removeClassName(oEl, sClass) {
var pattern = new RegExp(sClass);
oEl.className = oEl.className.replace(pattern, '');
}
function hasClassName(oEl, sClass) {
var pattern = new RegExp(sClass);
if (oEl.className && oEl.className.match(pattern)) {return true;}
return false;
}
function getParentByClassName(oEl, sClass) {
if (!sClass || !oEl) {return false};
while (hasClassName(oEl, sClass) == false) {
if (oEl.nodeName.toLowerCase() == 'html') {return false;}
oEl = oEl.parentNode;
}
return (oEl);
}
function show(element) {
var element = document.getElementById(element);
if (!element)	{alert('Unable to show an unspecified element');}
if (element && element.style.display == 'none')	{
element.style.position = "absolute";
element.style.display = "block";
}
}
function getElementText(el)
{
if (el.childNodes.length > 1)
{
return el.childNodes[1].nodeValue;
} else if (el.firstChild.nodeValue){
return el.firstChild.nodeValue;
} else {
return false;
}
}
function stripTags (string)
{
string.replace(/<\/?[^>]+>/gi, '');
return string;
}
function escapeHTML (string)
{
var div = document.createElement('div');
var text = document.createTextNode(string);
div.appendChild(text);
return div.innerHTML;
}
function scrollToBottom(divId)
{
document.getElementById(divId).scrollTop=document.getElementById(divId).scrollHeight-document.getElementById(divId).clientHeight;
}
var widgetRegistry = {};
function widgetLoader(registry, node) {
var liveElList = [];
node ? liveElList = node.getElementsByTagName("*") : liveElList = document.body.getElementsByTagName("*");
var aEls = [];
for (var i=0; i<liveElList.length; i++) {aEls.push(liveElList[i]);};
for (var i=0; i<aEls.length; i++) {
if(aEls[i].className !== "") {
var classNames = aEls[i].className.split(" ");
for (var j=0; j<classNames.length; j++)	{
if(typeof(registry[classNames[j]]) == "function") {registry[classNames[j]](aEls[i]);}
}
}
}
}
addEvent(window, "load", function(){widgetLoader(widgetRegistry);});
var jumpMenu = {
about: {
version: "1.0",
author: "Adam Hope",
date: "13/12/2006",
title: "Jump Menu",
description: "something something something"
},
register: function(reg)	{
reg.jump = function(inp){jumpMenu.configure(inp);};
},
configure:function(oEl)	{
var jumpMenu = oEl.getElementsByTagName('select')[0];
addEvent(jumpMenu, 'change', function(){
window.location.href = this.options[this.selectedIndex].value;
});
}
};
jumpMenu.register(widgetRegistry);
var tabGroup = {
register:function(reg)	{
reg.tabGroup = function(oEl){tabGroup.configure(oEl);};
},
configure:function(oEl)	{
var newTab = new YAHOO.widget.TabView(oEl);
}
};
tabGroup.register(widgetRegistry);
var links = {
register:function(reg)	{
reg.popup = function(inp){links.configure(inp);};
},
configure:function(a) {
a.onclick=function(){return(links.click(this));};
},
click: function(a) {
var configString = "toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,width=700,height=550, left=25, top=25";
window = window.open(a.href,a.href,configString);
return false;
}
};
links.register(widgetRegistry);
var clocks = {
register:function(reg)	{
reg.clock = function(el){new clock(el);};
}
};
clocks.register(widgetRegistry);
function clock(oInput) {
var wrapper = document.createElement('span');
var twelveHours = ['00','01','02','03','04','05','06','07','08','09','10','11','12'];
var minuteValues = ['00','05','10','15','20','25','30','35','40','45','50','55'];
var suffixs = ['a.m.','p.m.'];
var separator = ':';
var minutes = _createDropDown(minuteValues);
var hours = _createDropDown(twelveHours);
var suffix = _createDropDown(suffixs);
_init();
function _init() {
oInput.type = 'hidden';
wrapper.appendChild(hours);
wrapper.appendChild(_createSeparator());
wrapper.appendChild(minutes);
wrapper.appendChild(_createSeparator());
wrapper.appendChild(suffix);
if (oInput.value) {
var values = oInput.value.split(separator);
_selectValue(values[0] < 13 ? values[0] : values[0] - 12, hours);
_selectValue(Math.round(parseInt(values[1], 10) / 5) * 5, minutes);
}
oInput.parentNode.insertBefore(wrapper, oInput.nextSibling);
}
function _selectValue(v, oSelect) {
for (var i=0; i<oSelect.length; i++) {
if (v == oSelect.options[i].value) {
oSelect.selectedIndex = i;
return true;
}
}
}
function _createDropDown(values) {
var dropDown = _arrayToSelect(values);
dropDown.onchange = function(){_updateTime();};
return dropDown;
}
function _updateTime() {
var h = hours.value;
if(suffix.value == 'p.m.' && hours.value > 1) {
h = h * 1 + 12;
}
oInput.value = h + seperator + minutes.value;
}
function _createSeparator() {
return document.createTextNode(separator);
}
function _arrayToSelect(a) {
var oSelect;
oSelect = document.createElement('select');
for(var i=0; i<a.length; i++) {
var opt = document.createElement('option');
opt.value = a[i];
opt.text = a[i];
oSelect.appendChild(opt);
};
return oSelect;
}
}
if (window.attachEvent) {
window.attachEvent("onload", IEhover);
}
function IEhover() {
cssHover('navigation','li');
}
function cssHover(tagid, tagname) {
var sfEls = document.getElementById(tagid).getElementsByTagName(tagname);
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=" cssHover";
};
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" cssHover\\b"), "");
};
}
}
var rollUp = {
register: function(reg)	{
reg.rollup = function(inp){rollUp.configure(inp);};
},
configure: function(obj) {
var rContent, anchor;
rContent = obj.nextSibling;
while(rContent.nodeType != 1) {rContent = rContent.nextSibling;}
rContent.trigger = obj;
obj.rContent = rContent;
obj.onclick = function() {
rollUp.showHide(this.rContent);
return false;
};
},
showHide:function(rContent) {
if(rContent) {
if (rContent.className == 'rollup_content_hidden')	{
rContent.className = 'rollup_content';
rContent.trigger.className = 'rollup';
} else {
rContent.className = 'rollup_content_hidden';
rContent.trigger.className = 'rollup closed';
}
}
}
};
rollUp.register(widgetRegistry);
function pieng()	{
if (/MSIE [56].*Windows/.test(navigator.userAgent)) (function() {
var blank = new Image;
blank.src = '/z/style/default/images/pieng/blank.gif';
var imgs = document.getElementsByTagName("img");
for (var i = imgs.length; --i >= 0;) {
var img = imgs[i];
var src = img.src;
if (!/\.png$/.test(src)){continue;}
if (hiddenParent(img)) {continue;}
var s = img.runtimeStyle;
s.width = img.offsetWidth + "px";
s.height = img.offsetHeight + "px";
s.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
img.src = blank.src;
}
})();
}
function hiddenParent(obj) {
if (obj.style && obj.style.display == 'none') {return 1;}
if (obj.parentNode) {return hiddenParent(obj.parentNode);}
}
addEvent(window, 'load', pieng);
Date.parseFunctions = {count:0};
Date.parseRegexes = [];
Date.formatFunctions = {count:0};
Date.prototype.dateFormat = function(format) {
if (Date.formatFunctions[format] == null) {
Date.createNewFormat(format);
}
var func = Date.formatFunctions[format];
return this[func]();
}
Date.createNewFormat = function(format) {
var funcName = "format" + Date.formatFunctions.count++;
Date.formatFunctions[format] = funcName;
var code = "Date.prototype." + funcName + " = function(){return ";
var special = false;
var ch = '';
for (var i = 0; i < format.length; ++i) {
ch = format.charAt(i);
if (!special && ch == "\\") {
special = true;
}
else if (special) {
special = false;
code += "'" + String.escape(ch) + "' + ";
}
else {
code += Date.getFormatCode(ch);
}
}
eval(code.substring(0, code.length - 3) + ";}");
}
Date.getFormatCode = function(character) {
switch (character) {
case "d":
return "String.leftPad(this.getDate(), 2, '0') + ";
case "D":
return "Date.dayNames[this.getDay()].substring(0, 3) + ";
case "j":
return "this.getDate() + ";
case "l":
return "Date.dayNames[this.getDay()] + ";
case "S":
return "this.getSuffix() + ";
case "w":
return "this.getDay() + ";
case "z":
return "this.getDayOfYear() + ";
case "W":
return "this.getWeekOfYear() + ";
case "F":
return "Date.monthNames[this.getMonth()] + ";
case "m":
return "String.leftPad(this.getMonth() + 1, 2, '0') + ";
case "M":
return "Date.monthNames[this.getMonth()].substring(0, 3) + ";
case "n":
return "(this.getMonth() + 1) + ";
case "t":
return "this.getDaysInMonth() + ";
case "L":
return "(this.isLeapYear() ? 1 : 0) + ";
case "Y":
return "this.getFullYear() + ";
case "y":
return "('' + this.getFullYear()).substring(2, 4) + ";
case "a":
return "(this.getHours() < 12 ? 'am' : 'pm') + ";
case "A":
return "(this.getHours() < 12 ? 'AM' : 'PM') + ";
case "g":
return "((this.getHours() %12) ? this.getHours() % 12 : 12) + ";
case "G":
return "this.getHours() + ";
case "h":
return "String.leftPad((this.getHours() %12) ? this.getHours() % 12 : 12, 2, '0') + ";
case "H":
return "String.leftPad(this.getHours(), 2, '0') + ";
case "i":
return "String.leftPad(this.getMinutes(), 2, '0') + ";
case "s":
return "String.leftPad(this.getSeconds(), 2, '0') + ";
case "O":
return "this.getGMTOffset() + ";
case "T":
return "this.getTimezone() + ";
case "Z":
return "(this.getTimezoneOffset() * -60) + ";
default:
return "'" + String.escape(character) + "' + ";
}
}
Date.parseDate = function(input, format) {
if (Date.parseFunctions[format] == null) {
Date.createParser(format);
}
var func = Date.parseFunctions[format];
return Date[func](input);
}
Date.createParser = function(format) {
var funcName = "parse" + Date.parseFunctions.count++;
var regexNum = Date.parseRegexes.length;
var currentGroup = 1;
Date.parseFunctions[format] = funcName;
var code = "Date." + funcName + " = function(input){\n"
+ "var y = -1, m = -1, d = -1, h = -1, i = -1, s = -1;\n"
+ "var d = new Date();\n"
+ "y = d.getFullYear();\n"
+ "m = d.getMonth();\n"
+ "d = d.getDate();\n"
+ "var results = input.match(Date.parseRegexes[" + regexNum + "]);\n"
+ "if (results && results.length > 0) {"
var regex = "";
var special = false;
var ch = '';
for (var i = 0; i < format.length; ++i) {
ch = format.charAt(i);
if (!special && ch == "\\") {
special = true;
}
else if (special) {
special = false;
regex += String.escape(ch);
}
else {
obj = Date.formatCodeToRegex(ch, currentGroup);
currentGroup += obj.g;
regex += obj.s;
if (obj.g && obj.c) {
code += obj.c;
}
}
}
code += "if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n"
+ "{return new Date(y, m, d, h, i, s);}\n"
+ "else if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n"
+ "{return new Date(y, m, d, h, i);}\n"
+ "else if (y > 0 && m >= 0 && d > 0 && h >= 0)\n"
+ "{return new Date(y, m, d, h);}\n"
+ "else if (y > 0 && m >= 0 && d > 0)\n"
+ "{return new Date(y, m, d);}\n"
+ "else if (y > 0 && m >= 0)\n"
+ "{return new Date(y, m);}\n"
+ "else if (y > 0)\n"
+ "{return new Date(y);}\n"
+ "}return null;}";
Date.parseRegexes[regexNum] = new RegExp("^" + regex + "$");
eval(code);
}
Date.formatCodeToRegex = function(character, currentGroup) {
switch (character) {
case "D":
return {g:0,
c:null,
s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};
case "j":
case "d":
return {g:1,
c:"d = parseInt(results[" + currentGroup + "], 10);\n",
s:"(\\d{1,2})"};
case "l":
return {g:0,
c:null,
s:"(?:" + Date.dayNames.join("|") + ")"};
case "S":
return {g:0,
c:null,
s:"(?:st|nd|rd|th)"};
case "w":
return {g:0,
c:null,
s:"\\d"};
case "z":
return {g:0,
c:null,
s:"(?:\\d{1,3})"};
case "W":
return {g:0,
c:null,
s:"(?:\\d{2})"};
case "F":
return {g:1,
c:"m = parseInt(Date.monthNumbers[results[" + currentGroup + "].substring(0, 3)], 10);\n",
s:"(" + Date.monthNames.join("|") + ")"};
case "M":
return {g:1,
c:"m = parseInt(Date.monthNumbers[results[" + currentGroup + "]], 10);\n",
s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};
case "n":
case "m":
return {g:1,
c:"m = parseInt(results[" + currentGroup + "], 10) - 1;\n",
s:"(\\d{1,2})"};
case "t":
return {g:0,
c:null,
s:"\\d{1,2}"};
case "L":
return {g:0,
c:null,
s:"(?:1|0)"};
case "Y":
return {g:1,
c:"y = parseInt(results[" + currentGroup + "], 10);\n",
s:"(\\d{4})"};
case "y":
return {g:1,
c:"var ty = parseInt(results[" + currentGroup + "], 10);\n"
+ "y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",
s:"(\\d{1,2})"};
case "a":
return {g:1,
c:"if (results[" + currentGroup + "] == 'am') {\n"
+ "if (h == 12) { h = 0; }\n"
+ "} else { if (h < 12) { h += 12; }}",
s:"(am|pm)"};
case "A":
return {g:1,
c:"if (results[" + currentGroup + "] == 'AM') {\n"
+ "if (h == 12) { h = 0; }\n"
+ "} else { if (h < 12) { h += 12; }}",
s:"(AM|PM)"};
case "g":
case "G":
case "h":
case "H":
return {g:1,
c:"h = parseInt(results[" + currentGroup + "], 10);\n",
s:"(\\d{1,2})"};
case "i":
return {g:1,
c:"i = parseInt(results[" + currentGroup + "], 10);\n",
s:"(\\d{2})"};
case "s":
return {g:1,
c:"s = parseInt(results[" + currentGroup + "], 10);\n",
s:"(\\d{2})"};
case "O":
return {g:0,
c:null,
s:"[+-]\\d{4}"};
case "T":
return {g:0,
c:null,
s:"[A-Z]{3}"};
case "Z":
return {g:0,
c:null,
s:"[+-]\\d{1,5}"};
default:
return {g:0,
c:null,
s:String.escape(character)};
}
}
Date.prototype.getTimezone = function() {
return this.toString().replace(
/^.*? ([A-Z]{3}) [0-9]{4}.*$/, "$1").replace(
/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/, "$1$2$3");
}
Date.prototype.getGMTOffset = function() {
return (this.getTimezoneOffset() > 0 ? "-" : "+")
+ String.leftPad(Math.floor(this.getTimezoneOffset() / 60), 2, "0")
+ String.leftPad(this.getTimezoneOffset() % 60, 2, "0");
}
Date.prototype.getDayOfYear = function() {
var num = 0;
Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
for (var i = 0; i < this.getMonth(); ++i) {
num += Date.daysInMonth[i];
}
return num + this.getDate() - 1;
}
Date.prototype.getWeekOfYear = function() {
var now = this.getDayOfYear() + (4 - this.getDay());
var jan1 = new Date(this.getFullYear(), 0, 1);
var then = (7 - jan1.getDay() + 4);
document.write(then);
return String.leftPad(((now - then) / 7) + 1, 2, "0");
}
Date.prototype.isLeapYear = function() {
var year = this.getFullYear();
return ((year & 3) == 0 && (year % 100 || (year % 400 == 0 && year)));
}
Date.prototype.getFirstDayOfMonth = function() {
var day = (this.getDay() - (this.getDate() - 1)) % 7;
return (day < 0) ? (day + 7) : day;
}
Date.prototype.getLastDayOfMonth = function() {
var day = (this.getDay() + (Date.daysInMonth[this.getMonth()] - this.getDate())) % 7;
return (day < 0) ? (day + 7) : day;
}
Date.prototype.getDaysInMonth = function() {
Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
return Date.daysInMonth[this.getMonth()];
}
Date.prototype.getSuffix = function() {
switch (this.getDate()) {
case 1:
case 21:
case 31:
return "st";
case 2:
case 22:
return "nd";
case 3:
case 23:
return "rd";
default:
return "th";
}
}
String.escape = function(string) {
return string.replace(/('|\\)/g, "\\$1");
}
String.leftPad = function (val, size, ch) {
var result = new String(val);
if (ch == null) {
ch = " ";
}
while (result.length < size) {
result = ch + result;
}
return result;
}
Date.daysInMonth = [31,28,31,30,31,30,31,31,30,31,30,31];
Date.monthNames =
["January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"];
Date.dayNames =
["Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"];
Date.y2kYear = 50;
Date.monthNumbers = {
Jan:0,
Feb:1,
Mar:2,
Apr:3,
May:4,
Jun:5,
Jul:6,
Aug:7,
Sep:8,
Oct:9,
Nov:10,
Dec:11};
Date.patterns = {
ISO8601LongPattern:"Y-m-d H:i:s",
ISO8601ShortPattern:"Y-m-d",
ShortDatePattern: "n/j/Y",
LongDatePattern: "l, F d, Y",
FullDateTimePattern: "l, F d, Y g:i:s A",
MonthDayPattern: "F d",
ShortTimePattern: "g:i A",
LongTimePattern: "g:i:s A",
SortableDateTimePattern: "Y-m-d\\TH:i:s",
UniversalSortableDateTimePattern: "Y-m-d H:i:sO",
YearMonthPattern: "F, Y"};
function showChooser(obj, inputId, divId, start, end, format, isTimeChooser) {
if (document.getElementById) {
var input = document.getElementById(inputId);
var div = document.getElementById(divId);
if (input !== undefined && div !== undefined) {
if (input.DateChooser === undefined) {
input.DateChooser = new DateChooser(input, div, start, end, format, isTimeChooser);
}
input.DateChooser.setDate(Date.parseDate(input.value, format));
if (input.DateChooser.isVisible()) {
input.DateChooser.hide();
}
else {
input.DateChooser.show();
}
}
}
}
function dateChooserSetDate(inputId, value) {
var input = document.getElementById(inputId);
if (input !== undefined && input.DateChooser !== undefined) {
input.DateChooser.setDate(Date.parseDate(value, input.DateChooser._format));
if (input.DateChooser.isTimeChooser()) {
var theForm = input.form;
var prefix = input.DateChooser._prefix;
input.DateChooser.setTime(
parseInt(theForm.elements[prefix + 'hour'].options[
theForm.elements[prefix + 'hour'].selectedIndex].value)
+ parseInt(theForm.elements[prefix + 'ampm'].options[
theForm.elements[prefix + 'ampm'].selectedIndex].value),
parseInt(theForm.elements[prefix + 'min'].options[
theForm.elements[prefix + 'min'].selectedIndex].value));
}
input.value = input.DateChooser.getValue();
input.DateChooser.hide();
}
}
function dateChooserDateChange(theForm, prefix) {
var input = document.getElementById(
theForm.elements[prefix + 'inputId'].value);
var newDate = new Date(
theForm.elements[prefix + 'year'].options[
theForm.elements[prefix + 'year'].selectedIndex].value,
theForm.elements[prefix + 'month'].options[
theForm.elements[prefix + 'month'].selectedIndex].value,
1);
newDate.setDate(Math.max(1, Math.min(newDate.getDaysInMonth(),
input.DateChooser._date.getDate())));
input.DateChooser.setDate(newDate);
if (input.DateChooser.isTimeChooser()) {
input.DateChooser.setTime(
parseInt(theForm.elements[prefix + 'hour'].options[
theForm.elements[prefix + 'hour'].selectedIndex].value)
+ parseInt(theForm.elements[prefix + 'ampm'].options[
theForm.elements[prefix + 'ampm'].selectedIndex].value),
parseInt(theForm.elements[prefix + 'min'].options[
theForm.elements[prefix + 'min'].selectedIndex].value));
}
input.DateChooser.show();
}
function getAbsolutePosition(obj) {
var result = [0, 0];
while (obj != null) {
result[0] += obj.offsetTop;
result[1] += obj.offsetLeft;
obj = obj.offsetParent;
}
return result;
}
function DateChooser(input, div, start, end, format, isTimeChooser) {
this._input = input;
this._div = div;
this._start = start;
this._end = end;
this._format = format;
this._date = new Date();
this._isTimeChooser = isTimeChooser;
this._prefix = "";
var letters = ["a", "b", "c", "d", "e", "f", "h", "i", "j", "k", "l",
"m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
for (var i = 0; i < 10; ++i) {
this._prefix += letters[Math.floor(Math.random() * letters.length)];
}
}
DateChooser.prototype._isVisible = false;
DateChooser.prototype.isVisible = function() {
return this._isVisible;
}
DateChooser.prototype.isTimeChooser = function() {
return this._isTimeChooser;
}
DateChooser.prototype.getValue = function() {
return this._date.dateFormat(this._format);
}
DateChooser.prototype.hide = function() {
this._div.style.visibility = "hidden";
this._div.style.display = "none";
this._div.innerHTML = "";
this._isVisible = false;
}
DateChooser.prototype.show = function() {
var inputPos = getAbsolutePosition(this._input);
this._div.style.top = (inputPos[0] + this._input.offsetHeight) + "px";
this._div.style.left = (inputPos[1] + this._input.offsetWidth) + "px";
this._div.innerHTML = this.createChooserHtml();
this._div.style.display = "block";
this._div.style.visibility = "visible";
this._div.style.position = "absolute";
this._isVisible = true;
}
DateChooser.prototype.initializeDate = function() {
if (this._input.value != null && this._input.value != "") {
this._date = Date.parseDate(this._input.value, this._format);
}
else {
this._date = new Date();
}
}
DateChooser.prototype.setDate = function(date) {
this._date = date ? date : new Date();
}
DateChooser.prototype.setTime = function(hour, minute) {
this._date.setHours(hour);
this._date.setMinutes(minute);
}
DateChooser.prototype.createChooserHtml = function() {
var formHtml = "<input type=\"hidden\" name=\""
+ this._prefix + "inputId\" value=\""
+ this._input.getAttribute('id') + "\">"
+ "\r\n  <select name=\"" + this._prefix
+ "month\" onChange=\"dateChooserDateChange(this.form, '"
+ this._prefix + "');\">";
for (var monIndex = 0; monIndex <= 11; monIndex++) {
formHtml += "\r\n    <option value=\"" + monIndex + "\""
+ (monIndex == this._date.getMonth() ? " selected=\"1\"" : "")
+ ">" + Date.monthNames[monIndex] + "</option>";
}
formHtml += "\r\n  </select>\r\n  <select name=\""
+ this._prefix + "year\" onChange=\"dateChooserDateChange(this.form, '"
+ this._prefix + "');\">";
for (var i = this._start; i <= this._end; ++i) {
formHtml += "\r\n    <option value=\"" + i + "\""
+ (i == this._date.getFullYear() ? " selected=\"1\"" : "")
+ ">" + i + "</option>";
}
formHtml += "\r\n  </select>";
formHtml += this.createCalendarHtml();
if (this._isTimeChooser) {
formHtml += this.createTimeChooserHtml();
}
return formHtml;
}
DateChooser.prototype.createTimeChooserHtml = function() {
var result = "\r\n  <select name=\"" + this._prefix + "hour\">";
for (var i = 0; i < 12; ++i) {
result += "\r\n    <option value=\"" + i + "\""
+ (((this._date.getHours() % 12) == i) ? " selected=\"1\">" : ">")
+ i + "</option>";
}
result += "\r\n    <option value=\"0\">12</option>";
result += "\r\n  </select>";
result += "\r\n  <select name=\"" + this._prefix + "min\">";
for (var i = 0; i < 60; i += 15) {
result += "\r\n    <option value=\"" + i + "\""
+ ((this._date.getMinutes() == i) ? " selected=\"1\">" : ">")
+ String.leftPad(i, 2, '0') + "</option>";
}
result += "\r\n  </select>";
result += "\r\n  <select name=\"" + this._prefix + "ampm\">";
result += "\r\n    <option value=\"0\""
+ (this._date.getHours() < 12 ? " selected=\"1\">" : ">")
+ "AM</option>";
result += "\r\n    <option value=\"12\""
+ (this._date.getHours() >= 12 ? " selected=\"1\">" : ">")
+ "PM</option>";
result += "\r\n  </select>";
return result;
}
DateChooser.prototype.createCalendarHtml = function() {
var result = "\r\n<table cellspacing=\"0\" class=\"dateChooser\">"
+ "\r\n  <tr><th>S</th><th>M</th><th>T</th>"
+ "<th>W</th><th>T</th><th>F</th><th>S</th></tr>\r\n  <tr>";
var firstDay = this._date.getFirstDayOfMonth();
var lastDay = this._date.getLastDayOfMonth();
if (firstDay != 0) {
result += "<td colspan=\"" + firstDay + "\">&nbsp;</td>";
}
var i = 0;
while (i < this._date.getDaysInMonth()) {
if (((i++ + firstDay) % 7) == 0) {
result += "</tr>\r\n  <tr>";
}
var thisDay = new Date(
this._date.getFullYear(),
this._date.getMonth(), i);
var js = '"dateChooserSetDate(\''
+ this._input.getAttribute('id') + "', '"
+ thisDay.dateFormat(this._format) + '\');"'
result += "\r\n    <td class=\"dateChooserActive"
+ (i == this._date.getDate() ? " dateChooserActiveToday" : "")
+ "\" onClick=" + js + ">" + i + "</td>";
}
if (lastDay != 6) {
result += "<td colspan=\"" + (6 - lastDay) + "\">&nbsp;</td>";
}
return result + "\r\n  </tr>\r\n</table><!--[if lte IE 6.5]><iframe></iframe><![endif]-->";
}
var dualSelect = {
register:function(reg)	{
reg.dualselect = function(el){dualSelect.configure(el);};
},
configure:function(el) {
var selection = el.selectedIndex;
var originalSelectEl = el;
var eSelReference = originalSelectEl.cloneNode(true);
this.removeChildNodes(originalSelectEl);
var newSelectEl = document.createElement('select');
var labels = this.optGroupsToOpts(eSelReference);
var originalSelection = eSelReference.options[selection];
var selectNum = 0;
for (var i=0; i<labels.length; i++) {
var optEl = new Option(labels[i], labels[i]);
if (originalSelection.parentNode.label == labels[i]) {
optEl.selected = "selected";
selectNum = i;
}
newSelectEl.options[newSelectEl.length] = optEl;
}
newSelectEl.selectedIndex = selectNum;
newSelectEl.onchange = function(){
var newOptions = dualSelect.getOptGroupOptions(eSelReference , newSelectEl.value);
dualSelect.populateSelectEl(originalSelectEl, newOptions);
};
originalSelectEl.parentNode.insertBefore(newSelectEl, originalSelectEl);
originalSelectEl.parentNode.insertBefore(document.createElement('br'), originalSelectEl);
var newOptions = this.getOptGroupOptions(eSelReference , newSelectEl.value);
this.populateSelectEl(originalSelectEl, newOptions, originalSelection.text);
},
getOptGroupOptions:function(selectEl, optGroupLabel)    {
var optGroups = selectEl.getElementsByTagName('optgroup');
var opts = [];
for (var i=0; i < optGroups.length; i++)    {
if(optGroups[i].label == optGroupLabel) {
for(var j=0; j < optGroups[i].getElementsByTagName('option').length; j++)   {
opts[j] = optGroups[i].getElementsByTagName('option')[j].cloneNode(true);
}
}
}
return opts;
},
optGroupsToOpts:function(selEl) {
selEl = selEl.getElementsByTagName('optgroup');
var optGroupLabels = [];
for (var i=0; i<selEl.length; i++)  {
optGroupLabels[i] = selEl[i].label;
}
return optGroupLabels;
},
removeChildNodes:function(node)        {
while (node.hasChildNodes())    {
node.removeChild(node.firstChild);
}
},
populateSelectEl:function(selectEl, newOptions, selectedText) {
var selectNum = 0;
this.removeChildNodes(selectEl);
for (var i=0; i < newOptions.length; i++) {
if(selectedText) {
var groupItem = newOptions[i].value.split('/');
if (groupItem[1] && groupItem[1] == selectedText) {selectNum = i;}
}
selectEl.appendChild(newOptions[i]);
}
selectEl.selectedIndex = selectNum;
}
};
dualSelect.register(widgetRegistry);
var subsetterSetup = {
register:function(reg)	{
reg.subsetter = function(el){subsetterSetup.create(el);};
},
create:function(oEl) {
var aSelects = oEl.getElementsByTagName('select');
var aButtons = oEl.getElementsByTagName('input');
new subsetter(aSelects[0], aSelects[1], aButtons[0], aButtons[1]);
}
};
subsetterSetup.register(widgetRegistry);
function subsetter(l1, l2, b1, b2) {
if(arguments.length) {
var myself = this;
this.config(l1, l2, b1, b2, myself);
};
}
subsetter.prototype.config = function(list1, list2, addButton, removeButton, myself) {
list1.form.onsubmit = function(){myself.selectAllOptions(list2);};
addButton.onclick = function(){myself.moveSelection(list1, list2, true);};
list1.ondblclick = function(){myself.moveSelection(list1, list2, true);};
removeButton.onclick = function(){myself.deleteSelection(list2);};
list2.ondblclick = function(){myself.deleteSelection(list2);};
addEvent(Zaltana.Dom.getAncestorByTagName(list1, 'form'), 'submit', function(){subsetter.selectAllOptions(aSelects[1]);});
};
subsetter.prototype.moveSelection = function(source, target, copy) {
for (var i=source.options.length-1; i >= 0; i--) {
if (source.options[i].selected) {
if(this.duplicate(target, source.options[i])){break};
source.options[i].selected = false;
copy ? target.appendChild(source.options[i].cloneNode(true)) : target.appendChild(source.options[i]);
}
}
};
subsetter.prototype.duplicate = function(list, opt) {
for (var i=list.options.length-1; i >= 0; i--) {
if (list.options[i].value == opt.value) {
return true;
}
}
return false;
};
subsetter.prototype.deleteSelection = function(list) {
for (var i=list.options.length-1; i >= 0; i--) {
if (list.options[i].selected) {
list.remove(i);
}
}
};
subsetter.prototype.selectAllOptions = function(list) {
for (var i=list.options.length-1; i >= 0; i--) {
list.options[i].selected = true;
}
};
var swapperSetup = {
register:function(reg)	{
reg.swapper = function(el){swapperSetup.create(el);};
},
create:function(oEl) {
var aSelects = oEl.getElementsByTagName('select');
var aButtons = oEl.getElementsByTagName('input');
new swapper(aSelects[0], aSelects[1], aButtons[0], aButtons[1]);
addEvent(Zaltana.Dom.getAncestorByTagName(list1, 'form'), 'submit', function(){subsetter.selectAllOptions(aSelects[1]);});
}
};
swapperSetup.register(widgetRegistry);
swapper = function(l1, l2, b1, b2) {
if(arguments.length) {
var myself = this;
this.config(l1, l2, b1, b2, myself);
};
};
swapper.prototype = new subsetter();
swapper.prototype.config = function(list1, list2, addButton, removeButton, myself) {
list1.form.onsubmit = function(){myself.selectAllOptions(list2);};
addButton.onclick = function(){myself.moveSelection(list1, list2, false);};
list1.ondblclick = function(){myself.moveSelection(list1, list2, false);};
removeButton.onclick = function(){myself.moveSelection(list2, list1, false);};
list2.ondblclick = function(){myself.moveSelection(list2, list1, false);};
};
function createSwapper(oEl){
var aSelects = oEl.getElementsByTagName('select');
var aButtons = oEl.getElementsByTagName('input');
new swapper(aSelects[0], aSelects[1], aButtons[0], aButtons[1]);
};
var tableSort = {
register:function(reg)	{
reg.data = function(el){
var sortable = new TSorter();
sortable.init(el);
};
}
};
tableSort.register(widgetRegistry);
function TSorter(){
var table = Object;
var trs = Array;
var ths = Array;
var curSortCol = Object;
var prevSortCol = null;
var sortType = Object;
var tbody = Object;
function get(){}
function getCell(index){
return trs[index].cells[curSortCol];
}
this.init = function(oTable)
{
table = oTable;
ths = table.getElementsByTagName("th");
for (var i=0; i<ths.length; i++)
{
if (ths[i].className == 'sort')
{
ths[i].onclick = function()
{
sort(this);
};
}
}
return true;
};
function sort(oTH)
{
curSortCol = oTH.cellIndex;
sortType = oTH.abbr;
tbody = table.tBodies[0].cloneNode(true);
trs = tbody.getElementsByTagName("tr");
var fixedRows = [];
for (var i=0; i<trs.length; i++) {
if (trs[i].getAttribute('fixed') == 'true') {
fixedRows.push([trs[i], i+1]);
}
}
setGet(sortType);
if(prevSortCol == curSortCol)
{
oTH.className = (oTH.className != 'ascend' ? 'ascend' : 'descend' );
reverseTable();
}
else
{
oTH.className = 'ascend';
if(ths[prevSortCol]){ths[prevSortCol].className = '';}
quicksort(0, trs.length);
}
for (var i=0; i<fixedRows.length; i++) {
if (fixedRows[i][1] <= trs.length) {
tbody.insertBefore(fixedRows[i][0], trs[fixedRows[i][1]]);
} else {
tbody.appendChild(fixedRows[i][0]);
}
}
prevSortCol = curSortCol;
zebraStripe();
table.replaceChild(tbody, table.tBodies[0]);
}
function zebraStripe() {
for (var i=0; i<trs.length; i++) {
i % 2 ? trs[i].className = 'alternate' : trs[i].className = '';
}
}
function highlightCol(colNum) {
for (var i=0; i<trs.length; i++) {
trs[i].cells[colNum].className = 'sorted';
}
}
function removeHilight(colNum) {
if(colNum != null) {
for (var i=0; i<trs.length; i++) {
trs[i].cells[colNum].className = '';
}
}
}
function setGet(sortType)
{
switch(sortType)
{
case "link_column":
get = function(index){
return  getCell(index).firstChild.firstChild.nodeValue;
};
break;
case "key":
get = function (index){
};
break;
default:
get = function(index){
return getTextValue(getCell(index));
};
break;
};
}
function getTextValue(el) {
var s = "";
if(el) {
for (var i=0; i<el.childNodes.length; i++)	{
if (el.className == "sortdata")	{
s = el.childNodes[0].nodeValue;
break;
} else if (el.childNodes[i].nodeType == document.TEXT_NODE)	{
s += el.childNodes[i].nodeValue;
}   else if (el.childNodes[i].nodeType == document.ELEMENT_NODE && el.childNodes[i].tagName == "BR")	{
s += " ";
} else {
s += getTextValue(el.childNodes[i]);
}
}
}
return normalizeString(s);
}
function normalizeString(s) {
var whtSpEnds = new RegExp("^\\s*|\\s*$", "g");
var whtSpMult = new RegExp("\\s\\s+", "g");
s = s.replace(whtSpMult, " ");
s = s.replace(whtSpEnds, "");
return s;
}
function exchange(i, j)
{
if(i == j+1) {
tbody.insertBefore(trs[i], trs[j]);
} else if(j == i+1) {
tbody.insertBefore(trs[j], trs[i]);
} else {
var tmpNode = tbody.replaceChild(trs[i], trs[j]);
if(typeof(trs[i]) == "undefined") {
tbody.appendChild(tmpNode);
} else {
tbody.insertBefore(tmpNode, trs[i]);
}
}
}
function reverseTable()
{
for(var i=1; i<trs.length; i++)
{
tbody.insertBefore(trs[i], trs[0]);
}
}
function quicksort(lo, hi)
{
if(hi <= lo+1) return;
if((hi - lo) == 2) {
if(get(hi-1) > get(lo)) exchange(hi-1, lo);
return;
}
var i = lo + 1;
var j = hi - 1;
if(get(lo) > get(i)) exchange(i, lo);
if(get(j) > get(lo)) exchange(lo, j);
if(get(lo) > get(i)) exchange(i, lo);
var pivot = get(lo);
while(true) {
j--;
while(pivot > get(j)) j--;
i++;
while(get(i) > pivot) i++;
if(j <= i) break;
exchange(i, j);
}
exchange(lo, j);
if((j-lo) < (hi-j)) {
quicksort(lo, j);
quicksort(j+1, hi);
} else {
quicksort(j+1, hi);
quicksort(lo, j);
}
}
}
var disableContent = {
init:function()	{
addEvent(window, "load", disableContent.configure);
},
configure:function()	{
var previewAreas = Ext.query('div.disabled_content');
for (var i=0; i<previewAreas.length; i++)	{
var els = previewAreas[i].getElementsByTagName('*');
for (var j=0; j<els.length; j++){
if (typeof els[j].disabled != "undefined")	{els[j].disabled = true;}
else
if (typeof els[j].href != "undefined")	{els[j].removeAttribute('href');}
}
}
}
};
disableContent.init();
YAHOO.namespace("MI");
YAHOO.MI.window = function(id, sGroup, config) {
if (id) {
this.init(id, sGroup, config);
this.initFrame();
this.logger = this.logger || YAHOO;
}
var s = this.getDragEl().style;
s.backgroundColor = "#f6f5e5";
s.opacity = 0.76;
s.filter = "alpha(opacity=76)";
};
YAHOO.extend(YAHOO.MI.window, YAHOO.util.DDProxy);
YAHOO.MI.window.prototype.startDrag = function(x, y) {
this.logger.log(this.id + " startDrag");
var dragEl = this.getDragEl();
var clickEl = this.getEl();
var elLink = this.elLink = this.getEl();
this.createInsertionPoint(elLink);
dragEl.innerHTML = clickEl.innerHTML;
dragEl.className = clickEl.className;
dragEl.style.color = clickEl.style.color;
this.createBackfill(elLink);
clickEl.style.display = "none";
};
YAHOO.MI.window.prototype.endDrag = function(e) {
var insertionPoint = YAHOO.util.DDM.getElement('insertionPoint');
var eL = this.getEl();
var winCopy = eL.cloneNode(true);
this.removeBackfill();
insertionPoint.appendChild(winCopy);
winCopy.style.display = "block";
var myAnim2 = new YAHOO.util.Anim('insertionPoint');
myAnim2.attributes.height = { to: winCopy.scrollHeight };
myAnim2.duration = 0.5;
myAnim2.method = YAHOO.util.Easing.easeNone;
myAnim2.onComplete.subscribe(
function(){
eL.style.display = "block";
insertionPoint.parentNode.replaceChild(eL, insertionPoint);
windowManager.saveNewPosition(eL.id);
});
myAnim2.animate();
};
YAHOO.MI.window.prototype.onDrag = function(e, id) {};
YAHOO.MI.window.prototype.onDragOver = function(e, id) {
var el;
if ("string" == typeof id) {
el = YAHOO.util.DDM.getElement(id);
} else {
el = YAHOO.util.DDM.getBestMatch(id).getEl();
}
var mid = YAHOO.util.DDM.getPosY(el) + (Math.floor(el.offsetTop / 2));
this.logger.log("mid: " + mid);
if (YAHOO.util.Event.getPageY(e) < mid) {
var el2 = YAHOO.util.DDM.getElement('insertionPoint');
var p = el.parentNode;
p.insertBefore(el2, el);
}	else	{
var el2 = YAHOO.util.DDM.getElement('insertionPoint');
var p = el.parentNode;
insertAfter(p, el2, el);
}
};
YAHOO.MI.window.prototype.onDragEnter = function(e, id) {};
YAHOO.MI.window.prototype.onDragOut = function(e, id) {};
YAHOO.MI.window.prototype.toString = function() {
return "DDList " + this.id;
};
YAHOO.MI.window.prototype.createInsertionPoint = function(oldEl)	{
var insertionPoint = document.createElement('div');
insertionPoint.className = "insertionPoint";
insertionPoint.id = "insertionPoint";
oldEl.parentNode.insertBefore(insertionPoint, oldEl);
}
YAHOO.MI.window.prototype.createBackfill = function(oldEl) {
var backfillSpacer = document.createElement('div');
backfillSpacer.style.display = 'block';
backfillSpacer.style.position = 'static';
backfillSpacer.id = "backFill";
backfillSpacer.style.height = oldEl.scrollHeight + "px";
backfillSpacer.style.width = oldEl.scrollWidth + "px";
oldEl.parentNode.insertBefore(backfillSpacer, oldEl);
}
YAHOO.MI.window.prototype.removeBackfill =  function(){
var oBackFill = document.getElementById('backFill');
var myAnim = new YAHOO.util.Anim('backFill');
myAnim.attributes.height = { to: 0 };
myAnim.duration = 0.5;
myAnim.method = YAHOO.util.Easing.easeNone;
myAnim.onComplete.subscribe(function(){oBackFill.parentNode.removeChild(oBackFill);});
myAnim.animate();
}
YAHOO.MI.DDListBoundary = function(id, sGroup, config) {
if (id) {
this.init(id, sGroup, config);
this.logger = this.logger || YAHOO;
this.isBoundary = true;
}
};
YAHOO.extend(YAHOO.MI.DDListBoundary, YAHOO.util.DDTarget);
YAHOO.MI.DDListBoundary.prototype.toString = function() {
return "DDListBoundary " + this.id;
};
function insertAfter(parent, node, referenceNode) {
parent.insertBefore(node, referenceNode.nextSibling);
}
function removeNode(node)	{
node.parentNode.removeChild(node);
}
var windowManager = {
actionURL: '',
init: function()	{
addEvent(window, "load", windowManager.configure);
},
configure: function()	{
if(Ext.query('body div.window_manager').length > 0)	{
YAHOO.util.DDM.mode = "point";
windowManager.rootNode = Ext.query('body div.window_manager')[0];
windowManager.actionUrl = wm.action;
windowManager.windowMakeDraggable();
windowManager.changeViewSetup();
windowManager.removeButtonSetup();
windowManager.windowMenuSetup();
}
},
saveNewPosition: function(windowId) {
var targetSetId = document.getElementById(windowId).parentNode.id;
var windows = Ext.query('#' + targetSetId + ' div.window');
var windowPosition;
for (var i=0; i<windows.length; i++) {
if (windows[i].id == windowId) {
windowPosition = i;
break;
}
}
var params = 'zcommands=move&targetset=' + targetSetId + '&position=' + windowPosition + '&windowid=' + windowId;
windowManager.tellServer(windowManager.actionUrl, params);
},
getWindowArrangement: function()	{
var columns = Ext.query('div.window_manager div.column');
for (var i=0; i<columns.length; i++)	{
var params = 'zcommands=arrangement&setid=' + columns[i].id + '&windowlist=';
var windowsInColumn = Ext.query('#' + columns[i].id + ' .window');
for (var j=0; j<windowsInColumn.length; j++)	{
params += windowsInColumn[j].id;
if(j<windowsInColumn.length-1){params += ' ';}
}
windowManager.tellServer(windowManager.actionUrl, params);
}
},
windowMakeDraggable: function() {
var columns = Ext.query('div.window_manager div.column');
for (var i=0; i<columns.length; i++)	{
var windowEls = Ext.query('#' + columns[i].id + ' div.window.moveable');
for (var j=0; j<windowEls.length; j++)	{
var newWin =  new YAHOO.MI.window(windowEls[j].id);
newWin.setHandleElId(windowEls[j].id + "_tb");
};
var temp = document.createElement('div');
temp.id = "tmp_col_win_" + i;
temp.innerHTML = "<div>&nbsp;</div>";
columns[i].appendChild(temp);
var newWin =  new YAHOO.MI.window("tmp_col_win_" + i);
}
},
changeViewSetup: function()	{
var minMaxs = Ext.query('div.window_manager .min_max');
for (var i=0; i<minMaxs.length; i++) {
var minMax = minMaxs[i];
var win = getParentByClassName(minMax, 'window');
minMax.windowId = win.id;
minMax.removeAttribute('href');
addEvent(minMax, 'click', function() {
var windowId = this.windowId;
if (YAHOO.util.Dom.hasClass(this, 'minimised')) {
YAHOO.util.Dom.removeClass(this, 'minimised');
windowManager.getContent(this.windowId, 'zcommands=status,getcontent&status=maximised&windowid=' + this.windowId +'&getcontent=' + this.windowId);
this.title = "Collapse";
this.innerHTML = "Collapse";
} else {
YAHOO.util.Dom.addClass(this, 'minimised');
windowManager.getContent(this.windowId, 'zcommands=status,getcontent&status=minimised&windowid=' + this.windowId +'&getcontent=' + this.windowId);
this.title = "Expand";
this.innerHTML = "Expand";
}
});
}
},
removeButtonSetup: function()	{
var removeButtons = Ext.query('div.window_manager .remove');
for (var i=0; i<removeButtons.length; i++) {
var removeButton = removeButtons[i];
var win = getParentByClassName(removeButton, 'window');
removeButton.windowId = win.id;
removeButton.removeAttribute('href');
removeButton.title = "Remove";
addEvent(removeButton, 'click', function() {
if(confirm("Are you sure you want to remove this?")) {
document.getElementById(this.windowId).parentNode.removeChild(document.getElementById(this.windowId));
windowManager.tellServer(windowManager.actionUrl, 'zcommands=remove&windowid='+this.windowId);
}
});
}
},
windowMenuSetup: function() {
if (window.attachEvent)	{
var sfEls = Ext.query('div.window_manager ul.navigation li');
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover = function() {this.className+=" cssHover";};
sfEls[i].onmouseout = function() {this.className=this.className.replace(new RegExp(" cssHover\\b"), "");};
}
}
},
getContent: function(windowId, params)	{
var contentArea = getElementsByClassName(document.getElementById(windowId), 'div', 'win_content')[0];
contentArea.innerHTML = "Updating...";
windowManager.tellServer(
document.getElementById('href_' + windowId).value,
params,
{
success:function(o){
var temp = document.createElement('div');
temp.innerHTML = o.responseText;
contentArea.innerHTML = temp.getElementsByTagName('div')[0].innerHTML;
widgetLoader(widgetRegistry, contentArea);
}
}
);
},
tellServer: function(url, parameters, callBacks, onFailure)	{
YAHOO.util.Connect.initHeader("X-Requested-With", "XMLHttpRequest");
var transaction = YAHOO.util.Connect.asyncRequest(
'get',
url + '&' + parameters + '&zhttpredirect=' + window.location,
callBacks
);
}
};
windowManager.init();
