
function $A(arrayish) {
var arr = [];
for (var i=0; i<arrayish.length; i++) {
arr.push(arrayish[i]);
};
return arr;
}


Array.prototype.each = function(callback) {
for (var i=0; i<this.length; i++) {
callback(this[i], i);
};
}

function addEvent(obj, type, fn) {



if (obj instanceof Array) {
obj.each(function(item) { addEvent(item, type, fn) });
return;
};

if (type instanceof Array) {
type.each(function(item) { addEvent(obj, item, fn); });
return;
};
if (obj.addEventListener) {
switch (obj.tagName) { 
case 'body':
var mappings = { mousewheel: 'DOMMouseScroll', load: 'DOMContentLoaded' };
default:
var mappings = { mousewheel: 'DOMMouseScroll' };
};
if (mappings[type]) {
type = mappings[type];
};
obj.addEventListener( type, fn, false );
} else if (obj.attachEvent) {
var eName = "e"+type+fn;
var name = type+fn;

while (obj[eName]) {
eName += "_";
name += "_";
};
obj[eName] = fn;
obj[name] = function() { obj[eName]( window.event ); }
obj.attachEvent( "on" + type, obj[name] );
}
}
function cancelBubble(e) {
if (e.stopPropagation) {
e.stopPropagation();
} else {
e.cancelBubble = true;
};
}
function cancelEvent(e) {
if (e.preventDefault) { 
e.preventDefault();
} else {
e.returnValue = false;
};
}
function getEventTarget(e) {
var target;
if (e.target) {
target = e.target;
} else if (e.srcElement) {
target = e.srcElement;
};
if (target.nodeType == 3) { // fix for Safari bug
target = target.parentNode;  
};
return target;
}
function removeEvent(obj, type, fn) {
if (obj.removeEventListener) {
if (type == 'mousewheel') {
type = 'DOMMouseScroll';
};
obj.removeEventListener( type, fn, false );
} else if (obj.detachEvent) {
obj.detachEvent( "on"+type, obj[type+fn] );
obj[type+fn] = null;
obj["e"+type+fn] = null;
}
};


function $(id) {
return document.getElementById(id);
}
function $T(id, tag) {
return $(id).getElementsByTagName(tag);
}
function $F(id) {
return $(id).value;
}
var page = new Object();
page.m = new Object();
page.v = new Object();
page.c = new Object();


page._forms = {};
page._inputFeatures = [];
page.addForm = function(id, form) {
page._forms[id] = form;
var target = form.getTarget();
if (target) {
addEvent($(target), "load", function(e) { form.onTargetLoad(e); });
};
}
page.getForm = function(id) {
return page._forms[id];
}
page.addInputFeature = function(feature) {
page._inputFeatures.push(feature);
}






page._loadHandlers = [];
page.c.addOnLoadHandler = function(callback) {
var env = { m: {}, v: {}, c: {} };
page._loadHandlers.push({ callback: callback, env: env });
}
page.c.onLoad = function() {

};
page.c.onUnload = function() {

};
page.getXMLRPCGateway = function() {
return "xmlrpc.php";
};
addEvent(window, "unload", page.c.onUnload );
page.init = function() {
if (page._done) return;
page._done = true;
page._loadHandlers.each(function(handler) {
handler.callback(handler.env);
});
};
/* Mozilla/Firefox/Opera 9 */
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", page.init, false);
}
/* Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
document.write("<script id=\"__ie_onload\" defer=\"defer\" src=\"javascript:void(0)\"><\/script>");
var script = document.getElementById("__ie_onload");
if (script) {
script.onreadystatechange = function() {
if (this.readyState == "complete") {
page.init(); 
}
};
};
/*@end @*/
/* Safari */
if (/WebKit/i.test(navigator.userAgent)) {
var _timer = setInterval(function() {
if (/loaded|complete/.test(document.readyState)) {
clearInterval(_timer);
page.init();
}
}, 10);
}
window.onload = page.init;

/* Function printf(format_string,arguments...)
* Javascript emulation of the C printf function (modifiers and argument types 
*    "p" and "n" are not supported due to language restrictions)
*
* Copyright 2003 K&L Productions. All rights reserved
* http://www.klproductions.com 
*
* Terms of use: This function can be used free of charge IF this header is not
*               modified and remains with the function code.
* 
* Legal: Use this code at your own risk. K&L Productions assumes NO resposibility
*        for anything.
********************************************************************************/
function sprintf(fstring)
{ var pad = function(str,ch,len)
{ var ps='';
for(var i=0; i<Math.abs(len); i++) ps+=ch;
return len>0?str+ps:ps+str;
}
var processFlags = function(flags,width,rs,arg)
{ var pn = function(flags,arg,rs)
{ if(arg>=0)
{ if(flags.indexOf(' ')>=0) rs = ' ' + rs;
else if(flags.indexOf('+')>=0) rs = '+' + rs;
}
else
rs = '-' + rs;
return rs;
}
var iWidth = parseInt(width,10);
if(width.charAt(0) == '0')
{ var ec=0;
if(flags.indexOf(' ')>=0 || flags.indexOf('+')>=0) ec++;
if(rs.length<(iWidth-ec)) rs = pad(rs,'0',rs.length-(iWidth-ec));
return pn(flags,arg,rs);
}
rs = pn(flags,arg,rs);
if(rs.length<iWidth)
{ if(flags.indexOf('-')<0) rs = pad(rs,' ',rs.length-iWidth);
else rs = pad(rs,' ',iWidth - rs.length);
}    
return rs;
}
var converters = new Array();
converters['c'] = function(flags,width,precision,arg)
{ if(typeof(arg) == 'number') return String.fromCharCode(arg);
if(typeof(arg) == 'string') return arg.charAt(0);
return '';
}
converters['d'] = function(flags,width,precision,arg)
{ return converters['i'](flags,width,precision,arg); 
}
converters['u'] = function(flags,width,precision,arg)
{ return converters['i'](flags,width,precision,Math.abs(arg)); 
}
converters['i'] =  function(flags,width,precision,arg)
{ var iPrecision=parseInt(precision);
var rs = ((Math.abs(arg)).toString().split('.'))[0];
if(rs.length<iPrecision) rs=pad(rs,' ',iPrecision - rs.length);
return processFlags(flags,width,rs,arg); 
}
converters['E'] = function(flags,width,precision,arg) 
{ return (converters['e'](flags,width,precision,arg)).toUpperCase();
}
converters['e'] =  function(flags,width,precision,arg)
{ iPrecision = parseInt(precision);
if(isNaN(iPrecision)) iPrecision = 6;
rs = (Math.abs(arg)).toExponential(iPrecision);
if(rs.indexOf('.')<0 && flags.indexOf('#')>=0) rs = rs.replace(/^(.*)(e.*)$/,'$1.$2');
return processFlags(flags,width,rs,arg);        
}
converters['f'] = function(flags,width,precision,arg)
{ iPrecision = parseInt(precision);
if(isNaN(iPrecision)) iPrecision = 6;
rs = (Math.abs(arg)).toFixed(iPrecision);
if(rs.indexOf('.')<0 && flags.indexOf('#')>=0) rs = rs + '.';
return processFlags(flags,width,rs,arg);
}
converters['G'] = function(flags,width,precision,arg)
{ return (converters['g'](flags,width,precision,arg)).toUpperCase();
}
converters['g'] = function(flags,width,precision,arg)
{ iPrecision = parseInt(precision);
absArg = Math.abs(arg);
rse = absArg.toExponential();
rsf = absArg.toFixed(6);
if(!isNaN(iPrecision))
{ rsep = absArg.toExponential(iPrecision);
rse = rsep.length < rse.length ? rsep : rse;
rsfp = absArg.toFixed(iPrecision);
rsf = rsfp.length < rsf.length ? rsfp : rsf;
}
if(rse.indexOf('.')<0 && flags.indexOf('#')>=0) rse = rse.replace(/^(.*)(e.*)$/,'$1.$2');
if(rsf.indexOf('.')<0 && flags.indexOf('#')>=0) rsf = rsf + '.';
rs = rse.length<rsf.length ? rse : rsf;
return processFlags(flags,width,rs,arg);        
}  
converters['o'] = function(flags,width,precision,arg)
{ var iPrecision=parseInt(precision);
var rs = Math.round(Math.abs(arg)).toString(8);
if(rs.length<iPrecision) rs=pad(rs,' ',iPrecision - rs.length);
if(flags.indexOf('#')>=0) rs='0'+rs;
return processFlags(flags,width,rs,arg); 
}
converters['X'] = function(flags,width,precision,arg)
{ return (converters['x'](flags,width,precision,arg)).toUpperCase();
}
converters['x'] = function(flags,width,precision,arg)
{ var iPrecision=parseInt(precision);
arg = Math.abs(arg);
var rs = Math.round(arg).toString(16);
if(rs.length<iPrecision) rs=pad(rs,' ',iPrecision - rs.length);
if(flags.indexOf('#')>=0) rs='0x'+rs;
return processFlags(flags,width,rs,arg); 
}
converters['s'] = function(flags,width,precision,arg)
{ var iPrecision=parseInt(precision);
var rs = arg;
if(rs.length > iPrecision) rs = rs.substring(0,iPrecision);
return processFlags(flags,width,rs,0);
}
farr = fstring.split('%');
retstr = farr[0];
fpRE = /^([-+ #]*)(\d*)\.?(\d*)([cdieEfFgGosuxX])(.*)$/;
for(var i=1; i<farr.length; i++)
{ fps=fpRE.exec(farr[i]);
if(!fps) continue;
if(arguments[i]!=null) retstr+=converters[fps[4]](fps[1],fps[2],fps[3],arguments[i]);
retstr += fps[5];
}
return retstr;
}
/* Function printf() END */

var Opacity = new Object();
Opacity.set = function(object, opacity) {
object.style.opacity = opacity;
var ieOpacity = Math.round(opacity*100);
object.style.filter = sprintf("progid:DXImageTransform.Microsoft.Alpha(opacity=%s)", ieOpacity);
}


function isPNGHackNeeded() {
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
return (version > 5.5 && version < 7.0 && document.body.filters);
}

function correctPNG() {
if (!isPNGHackNeeded()) { return; };
for (var i=0; i<document.images.length; i++) {
var img = document.images[i]
var imgName = img.src.toUpperCase()
if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
if (correctPNGNode(img)) { i = i-1; };
}
}
}
function correctPNGNode(node) {
if (!isPNGHackNeeded()) { return false; };
switch (node.tagName) {
case "IMG":
return correctPNGNodeImg(node);
case "INPUT":
if (node.type != "image") { return false; };
return correctPNGNodeInput(node);
default:
return false;
};
if (img.tagName != "IMG") {
return false;
};
}
function correctPNGNodeImg(img) {
if (!isPNGHackNeeded()) { return false; };
var width = (img.width || parseInt(img.currentStyle.width));
var height = (img.height || parseInt(img.currentStyle.height)); 
if (isNaN(width) || isNaN(height)) {
return false;
};  


var newNode = document.createElement("span");
newNode.id = img.id;
newNode.className = img.className;
newNode.title = img.title || img.alt;
newNode.style.cssText = img.style.cssText;
newNode.style.display = "inline-block";
if (img.align == "left") { newNode.style.styleFloat = "left"; };
if (img.align == "right") { newNode.style.styleFloat = "right"; };
newNode.style.width = width.toString() + "px";
newNode.style.height = height.toString() + "px";
newNode.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='scale')";
newNode.style.cursor = "pointer";
newNode.style.fontSize = "1px";
img.parentNode.replaceChild(newNode, img);
return true;
}
function correctPNGNodeBg(div) {
if (!isPNGHackNeeded()) { return false; };
var fullSrc = div.currentStyle.backgroundImage;
var matches = fullSrc.match(/\(["'](.*)["']\)/);
if (!matches) {
return;
};
var src = matches[1];
div.style.backgroundImage = "none";  
if (div.currentStyle.position != "absolute" && div.currentStyle.position != "relative") {
div.style.position = "relative";
};
var overlay = document.createElement("div");
overlay.style.width = div.offsetWidth.toString() + "px";
overlay.style.height = div.offsetHeight.toString() + "px";
overlay.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + src + "\', sizingMethod='crop')";
var overlayContainer = document.createElement("div");
overlayContainer.style.position = "absolute";
overlayContainer.style.top = div.offsetTop.toString() + "px";
overlayContainer.style.left = div.offsetLeft.toString() + "px";
overlayContainer.style.fontSize = div.currentStyle.fontSize;
if (div.currentStyle.backgroundPositionX != "left") {
overlayContainer.style.paddingLeft = div.currentStyle.backgroundPositionX;
};
if (div.currentStyle.backgroundPositionY != "top") {
overlayContainer.style.paddingTop = div.currentStyle.backgroundPositionY;
};
var newZIndex = div.currentStyle.zIndex - 1;
if (newZIndex >= 0) {
overlayContainer.style.zIndex = newZIndex;
};
overlayContainer.appendChild(overlay);
div.offsetParent.appendChild(overlayContainer);
return true;
}
function correctPNGNodeInput(input) {
if (!isPNGHackNeeded()) { return false; };
if (input.offsetWidth == 0) {
return false;
};  
input.style.position = "relative";
var src = input.src;
var overlay = document.createElement("div");
overlay.style.position = "absolute";
overlay.style.top = (input.offsetTop + 1).toString() + "px";
overlay.style.left = (input.offsetLeft + 1).toString() + "px";
overlay.style.width = (input.offsetWidth - 6).toString() + "px";
overlay.style.height = (input.offsetHeight - 6).toString() + "px";
overlay.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + src + "\', sizingMethod='crop')";
overlay.style.zIndex = input.currentStyle.zIndex - 1;
input.offsetParent.appendChild(overlay);
Opacity.set(input, 0);
return true;
}



page.c.addOnLoadHandler(function(e) {
correctPNG();
});




page.m._layoutSearchKeywordCleared = false;
page.c.addOnLoadHandler(function() {
addEvent($("layout_search_keyword"), "focus", function() {
if (!page.m._layoutSearchKeywordCleared) {
$("layout_search_keyword").value = "";
};
});
if ($("layout_link_back")) { 
addEvent($("layout_link_back"), "click", function(e) {
history.back();
cancelEvent(e);
});
};
});

var Geometry = {
place: function(element, point) {
element.style.left = point.x.toString() + 'px';
element.style.top  = point.y.toString() + 'px';
}
};
function center(popup, noreshedule) {


if (popup.clientWidth == 0 && !noreshedule) {
setTimeout(function() { center(popup, 1); }, 200);
return;
};
center_x(popup);
center_y(popup);
}
function centerWindow(popup, noreshedule) {


if (popup.clientWidth == 0 && !noreshedule) {
setTimeout(function() { center(popup, 1); }, 200);
return;
};
center_x(popup);
centerWindow_y(popup);
}
function centerIn(popup, target) {
centerIn_x(popup, target);
centerIn_y(popup, target);
}
function centerIn_x(popup, target) {
var left = getLeft(target) + (target.clientWidth - popup.clientWidth) / 2;
popup.style.left = left.toString() + 'px';
}
function centerIn_y(popup, target) {
var top = getTop(target) + (target.clientHeight - popup.clientHeight) / 2;
popup.style.top = top.toString() + 'px';
}
function center_x(popup) {
var left = (document.body.offsetWidth - popup.offsetWidth) / 2;
popup.style.left = left.toString() + 'px';
}
function center_y(popup) {
var top = (document.documentElement.clientHeight - popup.offsetHeight) / 2;
var offset = getWindowTopOffset() + top;

if (offset < 0) {
offset = 0;
};
popup.style.top = offset.toString() + 'px';
}
function centerWindow_y(popup) {
var windowHeight = window.innerHeight || document.documentElement.offsetHeight;
var top = (windowHeight - popup.offsetHeight) / 2;
var offset = getWindowTopOffset() + top;

if (offset < 0) {
offset = 0;
};
popup.style.top = offset.toString() + 'px';
}
function getScrollXY() {
var scrOfX = 0, scrOfY = 0;
if( typeof( window.pageYOffset ) == 'number' ) {

scrOfY = window.pageYOffset;
scrOfX = window.pageXOffset;
} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {

scrOfY = document.body.scrollTop;
scrOfX = document.body.scrollLeft;
} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {

scrOfY = document.documentElement.scrollTop;
scrOfX = document.documentElement.scrollLeft;
}
return { x: scrOfX, y: scrOfY };
}
function getWindowTopOffset() {
var offsets = getScrollXY();
return offsets.y;
}
function getPositionParent(element) {
var parent = element.parentNode;
while (parent && parent.style.position == "static") {
parent = parent.parentNode;
};
if (parent == null) {
return document.body;
};
return parent;
}
function getDocumentHeight() {
return document.documentElement.scrollHeight || document.body.scrollHeight;
}
function getWindowHeight() {
return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
}
function getWindowWidth() {
return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
}
function getLeft(item) {
var parent = item.offsetParent;
var scrollDelta = (item.tagName != "HTML") ? item.scrollLeft : 0;
if (parent) {
return item.offsetLeft + getLeft(parent) - scrollDelta;
} { 
return item.offsetLeft - scrollDelta;
};
}
function getTop(item) {
var parent = item.offsetParent;
var scrollDelta = (item.tagName != "HTML") ? item.scrollTop : 0;
if (parent) {
return item.offsetTop + getTop(parent) - scrollDelta;
} { 
return item.offsetTop - scrollDelta;
};
}
function getBottom(item) {
if (item.tagName == "SELECT") {
return getTop(item) + item.offsetHeight;
} else {
return getTop(item) + item.clientHeight;
};
}
function getRight(item) {
var width = item.clientWidth || item.scrollWidth;
return getLeft(item) + width;
}
function getLeftParent(item) {
var parent = item.offsetParent;
if (parent) {
return getLeft(parent);
} { 
return 0;
};
}
function getTopParent(item) {
var parent = item.offsetParent;
if (parent) {
return getTop(parent);
} { 
return 0;
};
}
function getPosition(e) {
var cursor = {x:0, y:0};
if (e.pageX || e.pageY) {
cursor.x = e.pageX;
cursor.y = e.pageY;
} 
else {
var de = document.documentElement;
var b = document.body;
cursor.x = e.clientX + 
(de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
cursor.y = e.clientY + 
(de.scrollTop || b.scrollTop) - (de.clientTop || 0);
}
return cursor;
}

function textBoxSelect(item, from, to) {
if (item.setSelectionRange) {

item.setSelectionRange(from, to);
} else if (item.createTextRange) {

var range = item.createTextRange();
range.moveStart("character", from);
range.moveEnd("character", to - item.value.length);
range.select();
};
};

function getElementComputedStyle(element, property) {
if (document.defaultView && document.defaultView.getComputedStyle) {
return getElementComputedStyleMozilla(element, property);
}

if (element.currentStyle) {
return getElementComputedStyleIE(element, property);
}
return "";
}
function getElementComputedStyleIE(element, property) {
return element.currentStyle[propertyCssToPropertyDom(property)];
}
function getElementComputedStyleMozilla(element, property) {
return document.defaultView.getComputedStyle(element, "").getPropertyValue(property);
}
function propertyCssToPropertyDom(property) {
var i;
while ((i = property.indexOf("-")) != -1) {
property = property.substr(0, i) + property.substr(i+1,1).toUpperCase() + property.substr(i+2);
};
return property;
}
var I18N = new Object();
I18N.strings = [];
function _(string) {
return I18N.strings[string] || string;
}
Lang = {
NOMINATIVE: 1,
getWordForm: function(word, value, wordCase) {

if (value == 1) {
return word;
};

var last = word[word.length - 1];
var suffix2 = word.substr(word.length - 2, 2);
if (suffix2 == "ay") { // e.g. day, gay
return word + "s";
};
if (suffix2[1] == "y") {
return word.substr(0, word.length - 1) + "ies";   
};
if (suffix2[1] == "h") {
return word + "es";
};
return word + "s";
}
}






var Validators = {
POPUP_BOTTOM: 0,
POPUP_TOP: 1,
POPUP_LEFT: 2,
POPUP_RIGHT: 3,
errorPopup: null,
hideCallback: null,
offsetX: 3,
offsetY: 3,
timeout: 3000,
_errorPopupVisible: false
};
Validators.handleError = function(element, text) {
this.showErrorPopup(element, text);
}
Validators.showErrorPopup = function(element, text) {
if (Validators._errorPopupVisible) {
return;
};
try {
element.focus();
textBoxSelect(element, 0, element.value.length);
} catch (e) {


};
Validators.showErrorPopupNoSelect(element, text);
}
Validators.getErrorPopup = function() {
if (this.errorPopup == null) {
this.errorPopup = this.createErrorPopup();
};
return this.errorPopup;
}
Validators.getErrorPopupContent = function() {
if (this.errorPopup == null) {
this.errorPopup = this.createErrorPopup();
};
return this.errorPopup;
}
Validators.createErrorPopup = function() {
var errorPopup = document.createElement('div');
errorPopup.className = 'errorpopup';
document.body.appendChild(errorPopup);
addEvent(errorPopup, 'click', function(e) { Validators.hideErrorPopup(); });
return errorPopup;
}
Validators.hideErrorPopup = function() {
if (this.hideCallback != null) {
clearTimeout(this.hideCallback);
this.hideCallback = null;
};
this.doHideErrorPopup();
this._errorPopupVisible = false;
}
Validators.doHideErrorPopup = function() {
this.getErrorPopup().style.visibility = 'hidden';
}
Validators.showErrorPopupNoSelect = function(element, text) { 
if (this._errorPopupVisible) {
return;
};

this.hideErrorPopup();
try {
element.focus();
} catch (e) {

};
this.updateErrorPopup(text);
this.positionErrorPopup(element);
this.displayErrorPopup();
if (this.timeout) {
this.hideCallback = setTimeout(function() { Validators.hideCallback = null; Validators.hideErrorPopup(); }, this.timeout);
};
this._errorPopupVisible = true;
};
Validators.displayErrorPopup = function() {
var error_item = this.getErrorPopup();
error_item.style.visibility = 'visible';
error_item.style.position = 'absolute';
}
Validators.updateErrorPopup = function(text) {
var error_item = this.getErrorPopupContent();
error_item.innerHTML = text + "<div class='comment'>" + _("Click to Close the Window") + "</div>";
}
Validators.positionErrorPopup = function(element) {
var error_item = this.getErrorPopup();

var popupBase = element;
if (getElementComputedStyle(popupBase, "display") == "none") {
popupBase = $(element.id + "___Frame");
};

var popupPosition = this.POPUP_BOTTOM;
var top;
var left;
switch (popupPosition) {
case this.POPUP_TOP:
left = getLeft(popupBase) + this.offsetX;
top = (getTop(popupBase) - error_item.clientHeight - this.offsetY);
break;
case this.POPUP_BOTTOM:
left = getLeft(popupBase) + this.offsetX;
top = getBottom(popupBase) + this.offsetY;
break;
case this.POPUP_LEFT:
top  = getTop(popupBase);
left = getLeft(popupBase) - 150 - this.offsetX;
break;
case this.POPUP_RIGHT:
top  = getTop(popupBase);
left = getRight(popupBase) + this.offsetX;
break;
};
if (top < 0) { top = 0; };

if (left + 150 > document.body.clientWidth) {
left = document.body.clientWidth - 150;
};
if (left < 0) { left = 0; };
error_item.style.left = left.toString() + 'px';
error_item.style.top  = top.toString() + 'px';
}
String.prototype.subst = function (vars) {
var result = this;
for (var key in vars) {
var ref = "\\${" + key.toString() + "}";
var value = vars[key].toString();
result = result.replace(new RegExp(ref, "g"), value);
};
return result;
}



Validators.string_length = function(element, minlength, maxlength, messages) {


if (element.value == "") {
return true;
};
var vars = { max_length: maxlength == null ? "" : maxlength.toString(), 
min_length: minlength == null ? "" : minlength.toString() };
if (minlength != null && element.value.length < minlength) {
this.handleError(element, messages.too_short.subst(vars));
return false;
}
if (maxlength != null && element.value.length > maxlength) {
this.handleError(element, messages.too_long.subst(vars));
return false;
};
return true;
};
Bindings.prototype = new Object();
Bindings.prototype.add = Bindings_add;
Bindings.prototype.handle = Bindings_handle;
Bindings.prototype.handleGroup = Bindings_handleGroup;
Bindings.prototype.remove = Bindings_remove;
function Bindings() {
this._bindings = {};
this.GROUPS = ['element', 'group', 'all'];
for (var i=0; i<this.GROUPS.length; i++) {
this._bindings[this.GROUPS[i]] = { sequence: [], hash: {} };
};
}
function Bindings_add(fun, group) {
this.remove(fun, group);
this._bindings[group].sequence.push(fun);
this._bindings[group].hash[fun] = this._bindings[group].sequence.length - 1;
}
function Bindings_handle(event) {
var handled = false;
for (var i=0; i<this.GROUPS.length; i++) {
var data = this.handleGroup(this.GROUPS[i], event);
handled = handled || data.handled;
if (data.terminated) {
break;
};
};
if (handled) {

};
}
function Bindings_handleGroup(group, event) {
var binding = this._bindings[group];
if (!binding || binding.sequence.length == 0) { 
return { handled: false, terminated: false };
};
for (var i = binding.sequence.length - 1; i >= 0; i--) {
if (!binding.sequence[i](event)) {
return { handled: true, terminated: true };
};
};
return { handled: true, terminated: false };
}
function Bindings_remove(fun, group) {
var index = this._bindings[group].hash[fun];
if (index == null) {
return;
};
this._bindings[group].sequence.splice(index, 1);
this._bindings[group].hash[fun] = null;
}
var Event = new Object();
Event.addElement = function(eventType, element, handler) {
Event.initBindings(element, eventType);
element._eventBindings[eventType].add(handler, 'element');
};
Event.addGroup = function(eventType, element, handler) {
Event.initBindings(element, eventType);
element._eventBindings[eventType].add(handler, 'group');
};
Event.initBindings = function(element, eventType) {
if (!element._eventBindings) {
element._eventBindings = {};
};
if (!element._eventBindings[eventType]) { 
element._eventBindings[eventType] = new Bindings();
addEvent(element, eventType, function(e) { element._eventBindings[eventType].handle(e); });
};
};
var Class = {};
Class.extend = function(subClass, baseClass) {
function inheritance() {};
inheritance.prototype = baseClass.prototype;
subClass.prototype = new inheritance();
subClass.prototype.constructor = subClass;
subClass.baseConstructor = baseClass;
subClass.superClass = baseClass.prototype;
}



function $F(id) {
if ($(id)) {
if ($(id).getAttribute("multiple")) {
return $FM(id);
};
return $(id).value;
};
if ($(id + "_yy") && 
$(id + "_mm") && 
$(id + "_dd")) {
return $FD(id);
};
}


function $FD(id) {
return sprintf("%s-%02s-%02s", $F(id + "_yy"), $F(id + "_mm"), $F(id + "_dd"));
}


function $FM(id) {
var result = [];
$A($(id).options).each(function(option) {
if (option.selected) {
result.push(option.value);
};
});
return result;
}



Array.prototype.reduce = function(callback, seed) {
var result = seed;
this.each(function(item) {
result = callback(result, item);
});
return result;
}

Array.prototype.forall = function(callback) {
return this.reduce(function(a,b) { return a && callback(b); }, true);
}



Array.prototype.findFirst = function(predicate) {
for (var i = 0; i < this.length; i++) {
var item = this[i];
if (predicate(item)) {
return item;
};
};
return null;
}





Class.extend(FormControl, Object);
function FormControl(id, initialValue, validators, filters) {
FormControl.baseConstructor.call(this);
this.id = id;
this.initialValue = initialValue;
this.validators = validators;
this.filters = filters;
}
FormControl.prototype.validate = function() {
var validationResult;
if ($(this.id)) {
var oldValue = this.getValue();
this.setValue(this.filter(oldValue));
validationResult = !this.validators.findFirst(function(validator) { return !validator(); });
this.setValue(oldValue);
} else {
validationResult = !this.validators.findFirst(function(validator) { return !validator(); });
};
return validationResult;
}
FormControl.prototype.filter = function(value) {
return this.filters.reduce(function(value, f) { return f.apply(value); }, value);
}
FormControl.prototype.getName = function() {
return $(this.id).name;
}
FormControl.prototype.getValue = function() {
return $(this.id).value;
}
FormControl.prototype.setValue = function(value) {
$(this.id).value = value;
}
Class.extend(FormControlRadio, FormControl);
function FormControlRadio(id, initialValue, ids, validators, filters) {
FormControlRadio.baseConstructor.call(this, id, initialValue, validators, filters);
this.ids = ids;
}
FormControlRadio.prototype.getName = function() {
return $(this.ids[0]).name;
}
FormControlRadio.prototype.getValue = function() {
var checked = this.ids.findFirst(function(id) { return $(id) && $(id).checked; });
if (!checked) return null;
return $(checked).value;
}




Array.prototype.map = function(callback) {
var result = [];
this.each(function(item) {
result.push(callback(item));
});
return result;
}

Array.prototype.flatten = function() {
return this.reduce(function(result, item) {
return result.concat(item);
}, []);
}



Array.prototype.unique = function() {
var result = this.reduce(function(res, item) {
if (!res.found[item]) {
res.values.push(item);
res.found[item] = 1;
};
return res;
}, { values: [], found: {}});
return result.values;
}

function $A(item) {
if (item instanceof Array) {
return item;
};
var newItem = [];
for (var i=0; i<item.length; i++) {
newItem.push(item[i]);
};
return newItem;
} 



Array.prototype.filter = function(predicate) {
var filtered = this.reduce(function(result, item) {
if (predicate && predicate(item) || !predicate && item) {
result.push(item);
};
return result;
}, []);
return filtered;
}
function isAncestorOf(parent, child) {
if (child.parentNode == parent) {
return true;
};
if (!child.parentNode) {
return false;
};
return isAncestorOf(parent, child.parentNode);
}







var Selector = {

find: function(compositeSelector, context) {
var selectorParts = compositeSelector.split(/\s*,\s*/);
var matches = selectorParts.map(function(simpleSelector) { return Selector.findSimple(simpleSelector, context); });
return matches.flatten();
},

findSimple: function(simpleSelector, context) {
var subselectors = simpleSelector.split(/\s+/);
return subselectors.reduce(Selector.applySubselector, [context || document.body])
},
applySubselector: function(nodes, subselector) {
var matches = subselector.match(/^(.*?)(?:([.#])(.*?))?$/);
var tagName = matches[1];
var subselectorType = matches[2];
var subselectorData = matches[3];
if (tagName != "") {
var keptNodes = nodes.filter(function(node) { return node.tagName == tagName; });
nodes = nodes.map(function(node) { return $A(node.getElementsByTagName(tagName)); }).flatten();
nodes = nodes.concat(keptNodes);
};
switch (subselectorType) {
case ".":
var matchRegexp = new RegExp("\\b" + subselectorData + "\\b");
nodes = nodes.filter(function(node) { 
return node.className.match(matchRegexp);
});
break;
case "#":
nodes = nodes.map(function(node) { 
if (node.getAttribute("id") == subselectorData) {
return [node];
};
var newNode = $(subselectorData);


if (!newNode ||
!isAncestorOf(node, newNode)) {
return [];
};
return [newNode];
}).flatten().unique();
break;
};
return nodes;
}
}

function $$(selector, context) {
var matches = Selector.find(selector, context);
return matches.length > 0 ? matches[0] : null;
}










Class.extend(InputForm, Object);
function InputForm() {
this._id = null;
this._validatedHandlers = [];
this._controls = [];
this._target = null;
this._targetLoaded = false;
this._submitting = false;
}
InputForm.prototype.getId = function() {
return this._id;
}
InputForm.prototype.addControl = function(control) {
this._controls.push(control);
}
InputForm.prototype.addValidatedHandler = function(handler) {
this._validatedHandlers.push(handler);
}
InputForm.prototype.beforeValidated = function(e) {
if (window.FCKeditorAPI) {
this._controls.each(function(control) {
var editor = FCKeditorAPI.GetInstance(control.id);
if (editor) {
$(control.id).value = editor.GetXHTML(true);
};
});
}
}
InputForm.prototype.getTarget = function() {
return this._target;
}
InputForm.prototype.getSubmitting = function() {
return this._submitting;
}
InputForm.prototype.isModified = function() {
var notModified = this._controls.forall(function(control) { 
return control.initialValue == $F(control.id); 
});
return !notModified;
}
InputForm.prototype.saveState = function() {
this._controls.each(function(control) { 
control.initialValue = $F(control.id);
});
}
InputForm.prototype.validate = function() {
return this._controls.findFirst(function(control) { return !control.validate(); });
}
InputForm.prototype.setId = function(id) {
this._id = id;
}
InputForm.prototype.setSubmitting = function(value) {
this._submitting = value;
}
InputForm.prototype.setTarget = function(target) {
this._target = target;
}
InputForm.prototype.setupEvents = function() {
var form = this;
addEvent($(this.getId()), "submit", function(e) {
page._inputFeatures.each(function(feature) { feature.cleanup(); });
form.setSubmitting(true);
form.beforeValidated(e);

var badField = null;
var forceSend = false;
var status;

badField = form.validate();




if (badField || forceSend) {
form.setSubmitting(false);
page._inputFeatures.each(function(feature) { 
if (!badField || $(badField.id) !== feature._element) {
feature.restore();
};
});
cancelEvent(e);
} else {
form.onValidated(e);
};
});
}
InputForm.prototype.onValidated = function(e) {
this._validatedHandlers.each(function(handler) {
handler(e);
});
}
InputForm.prototype.onTargetLoad = function(e) {
if (!this._targetLoaded) {
this._targetLoaded = true;
return;
};
this.onTargetLoadCustom(e);
}
InputForm.prototype.onTargetLoadCustom = function() {
}
InputForm.prototype.toHash = function() {
var result = this._controls.reduce(function(result, control) { 
result[control.getName()] = control.getValue(); 
return result; 
}, {});
return result;
}

Autoscroll.prototype = new Object();
Autoscroll.prototype.run = Autoscroll_run;
Autoscroll.prototype.step = Autoscroll_step;
Autoscroll.prototype.stop = Autoscroll_stop;
function Autoscroll(eContainer, eScroll, eData) {
this._eContainer = eContainer;
this._eData = eData;
this._eScroll = eScroll;
eScroll.style.position = 'relative';
eData.style.cssFloat = 'left';
eData.style.width = 'auto';
this._pos = 0;
this._stepValue = -1;
this._timeoutValue = 1000 / 20; // 1/20 of second
this._timeoutHandle = null;
}
function Autoscroll_run() {
this.stop();
this.step();
}
function Autoscroll_step() {
var scroll = this;
this._pos += this._stepValue;
if (this._eData.clientWidth + this._pos <= 0) {
this._pos = this._eContainer.clientWidth;
};
this._eScroll.style.left = this._pos.toString() + 'px';
this._timeoutHandle = setTimeout(function() { scroll.step(); }, this._timeoutValue);
}
function Autoscroll_stop() {
if (this._timeoutHandle) {
clearTimeout(this._timeoutHandle);
};
this._timeoutHandle = null;
}



Class.extend(Pane, Object);
function Pane(paneElement) {
this._element = paneElement;
this._hideCallback = function() { };
this._showCallback = function() { };
}
Pane.prototype.hide = function() {
this._hideCallback(); 
this.doHide(this._element);
}
Pane.prototype.isVisible = function() {
return (getElementComputedStyle(this._element, 'display') == 'block');
}
Pane.prototype.show = function() {
this._showCallback(); 
this.doShow(this._element);
}
Pane.prototype.toggle = function() {
if (this.isVisible()) {
this.hide();
} else { 
this.show();
};
}

Pane.prototype.doHide = function(element) {
element.style.display = 'none';
}
Pane.prototype.doShow = function(element) {
element.style.display = 'block';
}



String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/, "");
}

function ac(element, cls) {
if (!element.className.match(cls)) {
element.className += " " + cls;
};
}
function rc(element, cls) {
element.className = element.className.replace(new RegExp('\s*'+cls+'\s*'),"").trim();
}
function hasClass(element, cls) {
return element.className.match(cls);
}
function addRemoveClass(element, cls, guard) {
if (guard) {
ac(element, cls);
} else {
rc(element, cls);
};
}

if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(val, fromIndex) {
if (typeof(fromIndex) != 'number') { 
fromIndex = 0; 
}
for (var index = fromIndex,len = this.length; index < len; index++) {
if (this[index] == val) { return index; };
}
return -1;
};
}





GuiSwitch.prototype = new Object;
GuiSwitch.prototype.bind = GuiSwitch_bind;
GuiSwitch.prototype.switchTo = GuiSwitch_switchTo;
GuiSwitch.makeDispatcher = GuiSwitch_makeDispatcher;
function GuiSwitch(elements, callback) {
this._callback = callback;
this._elements = elements;
this.bind();
}
function GuiSwitch_bind() {
var _this = this;
this._elements.each(function(element, index) {
addEvent(element, "click", function(e) {
_this.switchTo(element, index);
});
}); 
}
function GuiSwitch_makeDispatcher(callbacks) {
return function(element) {
var index = this._elements.indexOf(element);
callbacks[index]();
};
}
function GuiSwitch_switchTo(element, index) {
this._elements.each(function(element) {
rc(element, "current");
});  
ac(element, "current");
this._callback(element, index);
}


function isSelectHackRequiredForPopups() {
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
return (version > 5.5 && version < 7.0);
}
function isAncestorOf(parent, node) {
while (node.parentNode && node.parentNode != parent) {
node = node.parentNode;
};
return node.parentNode;
}
function hideSelects(popup) {
var nodeList = $A(document.getElementsByTagName("SELECT"));
nodeList.each(function(node) {
if (!isAncestorOf(popup, node)) { 
node.style.visibility = 'hidden';
};
});   
return nodeList;
}
function showSelects(nodeList) {
nodeList.each(function(node) {
node.style.visibility = '';
}); 
}






Class.extend(GuiPopupGeneric, Object);
function GuiPopupGeneric() {
this._overlay = null;
this._popup = null;
this._selectHackData = [];
}
GuiPopupGeneric.prototype.getOverlay = function() {
if (!this._overlay) {
this._overlay = document.createElement("div");
document.body.appendChild(this._overlay);
this._overlay.id = "system_gui_popup_overlay";
var docHeight = document.documentElement.scrollHeight || document.body.scrollHeight
var windowHeight = window.innerHeight || document.documentElement.offsetHeight
var height = docHeight > windowHeight ? docHeight : windowHeight;
this._overlay.style.height = height.toString() + "px";
this._overlay.style.width = "100%"; // getWindowWidth().toString() + "px";
};
return this._overlay;
}
GuiPopupGeneric.prototype.getPopup = function() {
if (!this._popup) {
this._popup = document.createElement("div");
this._popup.className = "system_gui_popup";
document.body.appendChild(this._popup);
this.setup(this._popup);
};
return this._popup;
}
GuiPopupGeneric.prototype.hide = function() {
var popup = this.getPopup();
popup.style.visibility = "hidden";
var overlay = this.getOverlay();
overlay.style.visibility = "hidden";  
if (isSelectHackRequiredForPopups()) {
showSelects(this._selectHackData);
this._selectHackData = [];
};
}
GuiPopupGeneric.prototype.setupVisual = function() {
}
GuiPopupGeneric.prototype.show = function() {
var popup = this.getPopup();
var _t = this;
setTimeout(function() {
centerWindow(popup);
_t.setupVisual();
}, 100);
popup.style.visibility = "visible";
popup.style.left = "-100000px";
popup.style.top = "-100000px";
var overlay = this.getOverlay();
overlay.style.visibility = "visible";
if (isSelectHackRequiredForPopups()) {
this._selectHackData = hideSelects(popup);
};
}



var Links = new Object();
Links.baseUrl = window.location.href.replace(/\/[^\/]*$/i, "/");
Links.skin = "default";
Links.action = function(action, params) {
if (!params) { params = {}; };
params.a = action;
return this.link_to(params);
}
Links.controller = function() {
return Links.baseUrl + "index.php";
}
Links.image = function(name) {
return sprintf("%sskins/%s/images/%s", Links.baseUrl, Links.skin, name);
}
Links.link_to = function(params) {
return Links.link_to_normal(params);
}
Links.link_to_normal = function(params) {
var query_string = this.make_query_string(params);
if (query_string.length == 0) {
return Links.baseUrl + "index.php";
};
return Links.baseUrl + "index.php?" + query_string;
}
Links.make_param_string = function(key, value) {
if (value instanceof Function) {
return "";
};
if (value instanceof Array) {
var param_strings = [];
if (value.length > 0) {
for (var i=0; i<value.length; i++) {
param_strings.push(Links.make_param_string(key + "[" + i.toString() + "]", value[i]));
};
} else {
for (var subkey in value) {
param_strings.push(Links.make_param_string(key + "[" + subkey + "]", value[subkey]));
};
};
var result = param_strings.filter().join("&");
return result;
};
return sprintf("%s=%s", escape(key), escape(value));
}
Links.make_query_string = function(params) {
var param_strings = [];
for (var param_name in params) {
param_strings.push(this.make_param_string(param_name, params[param_name]));
};
return param_strings.filter().join("&");
}
Links.update_url = function(url, param, value) {
url = url.replace(new RegExp(sprintf("([\?&])%s=[^&#]+(&|$)", param), "g"), "$1");
if (url.match(/\?/)) { 
url = url + "&" + escape(param) + "=" + escape(value);
} else {
url = url + "?" + escape(param) + "=" + escape(value);
};
return url;
}
Links.uploaded_file = function(file) {
return Links.baseUrl + "dynamic/uploaded/" + file;
}
Links.xml = function(name, params) {
var query_string = this.make_query_string(params);
if (query_string.length == 0) {
return "xml.php?_xml=" + escape(name);
};
return "xml.php?_xml=" + escape(name) + "&" + query_string;
}
Links.xmlrpc = function() {
return Links.baseUrl + "xmlrpc.php";
}
Links.json = function() {
return Links.baseUrl + "json.php";
}
Links.xslt = function(name, params) {
var query_string = this.make_query_string(params);
if (query_string.length == 0) {
return "xslt.php?_xslt=" + escape(name);
};
return "xslt.php?_xslt=" + escape(name) + "&" + query_string;
}


var RPC = {
gateway: null,
uri_cb: null,  
call: function(success, fail, error, method, params) {
this.gateway.call(this.uri_cb(), success, fail, error, method, params);
}
}
function createXMLHttpRequest() {
var xmlhttp;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = new XMLHttpRequest();
};
};
return {
xmlhttp: xmlhttp,
readyState: 0,
responseXML: null,
responseText: "",
onsuccess: null,
url: "",
sent: "",
async: 1,
onsuccesscalled: false,
error: function(text) {
alert(error);
return true;
},
onreadystatechange: function() {
},
open: function(method, url, mode) { 
var obj = this;
this.xmlhttp.onreadystatechange = function () {
obj.readyState = obj.xmlhttp.readyState;
if (obj.xmlhttp.readyState == 4) {
obj.responseXML  = obj.xmlhttp.responseXML;
obj.responseText = obj.xmlhttp.responseText;
if (obj.onsuccess) { 
obj.onsuccesscalled = true;
obj.onsuccess(); 
};
};
obj.onreadystatechange();
};
var ts = new Date;
if (url.indexOf('?') == -1) {
url = url + "?_ts=" + ts.getTime();
} else {
url = url + "&_ts=" + ts.getTime();
};
this.url = url;
this.async = mode;
this.xmlhttp.open(method, url, mode);
this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
},
send: function(data) {
this.sent = data;
this.xmlhttp.send(data);




if (!this.async && !this.onsuccesscalled && this.xmlhttp.readyState == 4) {
this.responseXML  = this.xmlhttp.responseXML;
this.responseText = this.xmlhttp.responseText;
this.onsuccesscalled = true;
if (this.onsuccess) {
this.onsuccess();
};
};
},
handleError: function(callbacks) { 




if (this.xmlhttp.responseText == "" && this.xmlhttp.responseXML == null) {
return false;
};
if (!this.xmlhttp.responseXML) {
return this.error("Error; server responded with '"+this.xmlhttp.responseText+"'");
};
if (!this.xmlhttp.responseXML.documentElement) {
return this.error("Error; server responded with '"+this.xmlhttp.responseText+"'");
};
if (this.xmlhttp.responseXML.documentElement.tagName == "parsererror") {
return this.error("Error; server responded with '"+this.xmlhttp.responseText+"'");
};
var root = this.xmlhttp.responseXML.documentElement;
if (root.tagName == 'error') {
var handler = null;
var code = root.getAttribute('code');
var text = root.text ? root.text : root.textContent;
if (callbacks != null) {
handler = callbacks[code];
};
if (handler) {
return handler(code, text);
} else {
var query_text = this.sent.replace(/&/g, "\n");
return this.error("ERROR: " + code + " " + text + "\n" + query_text);
};
};
return false;
}
} 
};

function getInnerText (node) {
if (typeof node.textContent != 'undefined') {
return node.textContent;
} else if (typeof node.innerText != 'undefined') {
return node.innerText;
} else if (typeof node.text != 'undefined') {
return node.text;
} else {
switch (node.nodeType) {
case 3:
case 4:
return node.nodeValue;
break;
case 1:
case 11:
var innerText = '';
for (var i = 0; i < node.childNodes.length; i++) {
innerText += getInnerText(node.childNodes[i]);
}
return innerText;
break;
default:
return '';
}
}
}



Array.prototype.fmap = function(data) {
var result = [];
this.each(function(item) {
result.push(item(data));
});
return result;
}







XMLRPCPending.prototype = new Object;
function XMLRPCPending(xmlrpc, name, params) {
this._xmlrpc = xmlrpc;
this._name = name;
this._params = params;
this._success = [];
this._error = [];
this._failure = [];
}
XMLRPCPending.prototype.add = function(success, error, failure) {
this._success.push(success);
this._error.push(error);
this._failure.push(failure);
}
XMLRPCPending.prototype.success = function(r) {
this._success.fmap(r);
this.completed(function(s, e, f) { s(r); });
}
XMLRPCPending.prototype.error = function(r) {
this._error.fmap(r);
this.completed(function(s, e, f) { e(r); });
}
XMLRPCPending.prototype.failure = function(r) {
this._failure.fmap(r);
this.completed(function(s, e, f) { f(r); });
}
XMLRPCPending.prototype.completed = function(r) {
if (!this._xmlrpc._cached[this._name]) { this._xmlrpc._cached[this._name] = {}; };
this._xmlrpc._cached[this._name][this._params] = r;
this._xmlrpc._pending[this._name][this._params] = null;
}
XMLRPCResponse.prototype = new Object;
XMLRPCResponse.prototype.isError = XMLRPCResponse_isError;
function XMLRPCResponse(param) {
this.param = param;
}
function XMLRPCResponse_isError() {
return false;
}
/* ---------- */
XMLRPCError.prototype = new Object;
XMLRPCError.prototype.isError = XMLRPCError_isError;
XMLRPCError.prototype.getMessage = XMLRPCError_getMessage;
function XMLRPCError(code, message) {
this._message = message;
this._code    = code;
}
function XMLRPCError_getMessage() {
return this._message;
}
function XMLRPCError_isError() {
return true;
}
/* ---------- */
var XMLRPC = new Object;
XMLRPC._cacheEnabled = {};
XMLRPC._cached = {};
XMLRPC._pending = {};

XMLRPC.enableCache = function(methodList) {
this._cacheEnabled = {};
var _t = this;
methodList.each(function(method) {
_t._cacheEnabled[method] = true;
});
};
XMLRPC.prepare = function(name, params) {
var methodName = "<methodName>"+name+"</methodName>\n";
var paramsText = "<params>\n";
for (var i=0; i<params.length; i++) {
paramsText += this._prepareParam(params[i]);
};
paramsText += "</params>\n";
return "<methodCall>\n"+methodName+paramsText+"</methodCall>\n";
};
XMLRPC._prepareParam = function(value) {
var paramText;
paramText  = "<param>";
paramText += this._prepareValue(value);
paramText += "</param>\n";
return paramText;
}
XMLRPC._prepareValue = function(value) {
var paramText = "<value>";
switch (typeof value) {
case "object":
if (value instanceof Array) {
paramText += this._prepareArray(value);
} else {
paramText += this._prepareObject(value);
};
break;
case "boolean":
paramText += this._prepareBoolean(value);
break;
case "undefined":
throw "Undefined parameter value";
default:
paramText += this._prepareString(value);
break;
};
paramText += "</value>";
return paramText;
}
XMLRPC._prepareArray = function(value) {
var valueText = "";
for (var i=0; i<value.length; i++) {
valueText += XMLRPC._prepareValue(value[i]);
};
return "<array><data>"+valueText+"</data></array>";
}
XMLRPC._prepareBoolean = function(value) {
return "<boolean>" + (value ? 1 : 0) + "</boolean>";
}
XMLRPC._prepareObject = function(value) {
var valueText = "";
for (var key in value) {
if (!(value[key] instanceof Function)) {
valueText += "<member><name>"+key+"</name>"+this._prepareValue(value[key])+"</member>\n"
};
};
return "<struct>"+valueText+"</struct>";
}
XMLRPC._prepareString = function(value) {
return "<string>"+value.toString().replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;")+"</string>";
}
XMLRPC.parseResponse = function(responseXML) {
if (!responseXML) { 
return new XMLRPCError(null, null);
};

var faultElement = responseXML.getElementsByTagName('fault')[0];

if (faultElement) {
var code    = getInnerText(faultElement.getElementsByTagName('int')[0]);
var message = getInnerText(faultElement.getElementsByTagName('string')[0]);
var response = new XMLRPCError(code, message);
return response;
};





var paramXML = responseXML.getElementsByTagName('param')[0];
if (paramXML) {
return new XMLRPCResponse(this._parseResponseParam(paramXML));
} else {
return new XMLRPCResponse(null);
};
};
XMLRPC._parseResponseParam = function(element) {
for (var i=0; i<element.childNodes.length; i++) {
var node = element.childNodes[i];
if (node.tagName == "value") {
return this._parseValue(node);
};
};
}
XMLRPC._parseValue = function(element) {
for (var i=0; i<element.childNodes.length; i++) {
var node = element.childNodes[i];
switch (node.tagName) {
case "int":
case "i4":
return this._parseInt(node);
case "boolean":
return this._parseBoolean(node);
case "string":
return this._parseString(node);
case "double":
return this._parseDouble(node);
case "dateTime.iso8601":
return this._parseDateTime(node);
case "base64":
return this._parseBase64(node);
case "struct":
return this._parseStruct(node);
case "array":
return this._parseArray(node);
};
};  
}
XMLRPC._parseInt = function(element) {
return parseInt(getInnerText(element));
}
XMLRPC._parseBoolean = function(element) {
var text = getInnerText(element);
if (!text) { 
return false;
};
if (text == 'false') {
return false;
};
if (text == 'no') {
return false;
};
if (text == '0') {
return false;
};
return true;
}
XMLRPC._parseString = function(element) {
return getInnerText(element);
}
XMLRPC._parseDouble = function(element) {
return parseFloat(getInnerText(element));
}
XMLRPC._parseDateTime = function(element) {

return getInnerText(element);
}
XMLRPC._parseBase64 = function(element) {
return getInnerText(element);
}
XMLRPC._parseStruct = function(element) {
var struct = new Object;
for (var i=0; i<element.childNodes.length; i++) {
var node = element.childNodes[i];
if (node.tagName == "member") {
var member = this._parseMember(node);
struct[member.name] = member.value;
};
};
return struct;  
}
XMLRPC._parseMember = function(element) {
var member = new Array();
for (var i=0; i<element.childNodes.length; i++) {
var node = element.childNodes[i];
switch (node.tagName) {
case "name":
member.name = this._parseName(node);
break;
case "value":
member.value = this._parseValue(node); 
break;
};
};
return member;
}
XMLRPC._parseName = function(element) {
return getInnerText(element);
}
XMLRPC._parseArray = function(element) {
for (var i=0; i<element.childNodes.length; i++) {
var node = element.childNodes[i];
if (node.tagName == "data") {
return this._parseData(node);
};
};
}
XMLRPC._parseData = function(element) {
var data = new Array();
for (var i=0; i<element.childNodes.length; i++) {
var node = element.childNodes[i];
if (node.tagName == "value") {
data.push(this._parseValue(node));
};
};
return data;
}
XMLRPC.callSync = function(url, successCallback, errorCallback, failureCallback, name, params) {
var request = this.prepareRequest(url, successCallback, errorCallback, failureCallback, name, params);

request.open('POST', url, 0);
var query = this.prepare(name, params);
request.send(query);
}
XMLRPC.call = function(url, successCallback, errorCallback, failureCallback, name, params) {

if (this._cacheEnabled[name] && this._cached[name] && this._cached[name][params]) {
this._cached[name][params](successCallback, errorCallback, failureCallback);
return;
};

if (this._cacheEnabled[name] && this._pending[name] && this._pending[name][params]) {
this._pending[name][params].add(successCallback, errorCallback, failureCallback);
return;
};
var request;
if (this._cacheEnabled[name]) {
var callback = new XMLRPCPending(this, name, params);
callback.add(successCallback, errorCallback, failureCallback);
if (!this._pending[name]) { this._pending[name] = {}; };
this._pending[name][params] = callback;
request = this.prepareRequest(url, 
function(r) { callback.success(r); }, 
function(r) { callback.error(r); },
function(r) { callback.failure(r); }, 
name, params);
} else {
request = this.prepareRequest(url, successCallback, errorCallback, failureCallback, name, params);
};

request.open('POST',url,1);
var query = this.prepare(name, params);
request.send(query);
};
XMLRPC.prepareRequest = function(url, successCallback, errorCallback, failureCallback, name, params) {
var request = createXMLHttpRequest();
request.error = XMLRPC._ajaxErrorHandler; 
request.onsuccess = function() { 
if (request.handleError()) { 
if (failureCallback) {
failureCallback();
};
return false; 
}; 
var response = XMLRPC.parseResponse(request.xmlhttp.responseXML);
if (response.isError()) {
if (errorCallback) {
errorCallback(response); 
}; 
} else {
if (successCallback) {
successCallback(response); 
};
};
};
return request;
}
XMLRPC._ajaxErrorHandler = function(text) {
alert(text);
return true;
};
RPC.gateway = XMLRPC;
RPC.uri_cb = Links.xmlrpc;
;(function(){
/*
* jQuery 1.2.1 - New Wave Javascript
*
* Copyright (c) 2007 John Resig (jquery.com)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* $Date: 2007-09-16 23:42:06 -0400 (Sun, 16 Sep 2007) $
* $Rev: 3353 $
*/

if ( typeof jQuery != "undefined" )
var _jQuery = jQuery;
var jQuery = window.jQuery = function(selector, context) {

return this instanceof jQuery ?
this.init(selector, context) :
new jQuery(selector, context);
};

if ( typeof $ != "undefined" )
var _$ = $;

window.$ = jQuery;
var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/;
jQuery.fn = jQuery.prototype = {
init: function(selector, context) {

selector = selector || document;

if ( typeof selector  == "string" ) {
var m = quickExpr.exec(selector);
if ( m && (m[1] || !context) ) {

if ( m[1] )
selector = jQuery.clean( [ m[1] ], context );

else {
var tmp = document.getElementById( m[3] );
if ( tmp )


if ( tmp.id != m[3] )
return jQuery().find( selector );
else {
this[0] = tmp;
this.length = 1;
return this;
}
else
selector = [];
}

} else
return new jQuery( context ).find( selector );


} else if ( jQuery.isFunction(selector) )
return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( selector );
return this.setArray(

selector.constructor == Array && selector ||


(selector.jquery || selector.length && selector != window && !selector.nodeType && selector[0] != undefined && selector[0].nodeType) && jQuery.makeArray( selector ) ||

[ selector ] );
},
jquery: "1.2.1",
size: function() {
return this.length;
},
length: 0,
get: function( num ) {
return num == undefined ?

jQuery.makeArray( this ) :

this[num];
},
pushStack: function( a ) {
var ret = jQuery(a);
ret.prevObject = this;
return ret;
},
setArray: function( a ) {
this.length = 0;
Array.prototype.push.apply( this, a );
return this;
},
each: function( fn, args ) {
return jQuery.each( this, fn, args );
},
index: function( obj ) {
var pos = -1;
this.each(function(i){
if ( this == obj ) pos = i;
});
return pos;
},
attr: function( key, value, type ) {
var obj = key;

if ( key.constructor == String )
if ( value == undefined )
return this.length && jQuery[ type || "attr" ]( this[0], key ) || undefined;
else {
obj = {};
obj[ key ] = value;
}

return this.each(function(index){

for ( var prop in obj )
jQuery.attr(
type ? this.style : this,
prop, jQuery.prop(this, obj[prop], type, index, prop)
);
});
},
css: function( key, value ) {
return this.attr( key, value, "curCSS" );
},
text: function(e) {
if ( typeof e != "object" && e != null )
return this.empty().append( document.createTextNode( e ) );
var t = "";
jQuery.each( e || this, function(){
jQuery.each( this.childNodes, function(){
if ( this.nodeType != 8 )
t += this.nodeType != 1 ?
this.nodeValue : jQuery.fn.text([ this ]);
});
});
return t;
},
wrapAll: function(html) {
if ( this[0] )

jQuery(html, this[0].ownerDocument)
.clone()
.insertBefore(this[0])
.map(function(){
var elem = this;
while ( elem.firstChild )
elem = elem.firstChild;
return elem;
})
.append(this);
return this;
},
wrapInner: function(html) {
return this.each(function(){
jQuery(this).contents().wrapAll(html);
});
},
wrap: function(html) {
return this.each(function(){
jQuery(this).wrapAll(html);
});
},
append: function() {
return this.domManip(arguments, true, 1, function(a){
this.appendChild( a );
});
},
prepend: function() {
return this.domManip(arguments, true, -1, function(a){
this.insertBefore( a, this.firstChild );
});
},
before: function() {
return this.domManip(arguments, false, 1, function(a){
this.parentNode.insertBefore( a, this );
});
},
after: function() {
return this.domManip(arguments, false, -1, function(a){
this.parentNode.insertBefore( a, this.nextSibling );
});
},
end: function() {
return this.prevObject || jQuery([]);
},
find: function(t) {
var data = jQuery.map(this, function(a){ return jQuery.find(t,a); });
return this.pushStack( /[^+>] [^+>]/.test( t ) || t.indexOf("..") > -1 ?
jQuery.unique( data ) : data );
},
clone: function(events) {

var ret = this.map(function(){
return this.outerHTML ? jQuery(this.outerHTML)[0] : this.cloneNode(true);
});



var clone = ret.find("*").andSelf().each(function(){
if ( this[ expando ] != undefined )
this[ expando ] = null;
});

if (events === true)
this.find("*").andSelf().each(function(i) {
var events = jQuery.data(this, "events");
for ( var type in events )
for ( var handler in events[type] )
jQuery.event.add(clone[i], type, events[type][handler], events[type][handler].data);
});

return ret;
},
filter: function(t) {
return this.pushStack(
jQuery.isFunction( t ) &&
jQuery.grep(this, function(el, index){
return t.apply(el, [index]);
}) ||
jQuery.multiFilter(t,this) );
},
not: function(t) {
return this.pushStack(
t.constructor == String &&
jQuery.multiFilter(t, this, true) ||
jQuery.grep(this, function(a) {
return ( t.constructor == Array || t.jquery )
? jQuery.inArray( a, t ) < 0
: a != t;
})
);
},
add: function(t) {
return this.pushStack( jQuery.merge(
this.get(),
t.constructor == String ?
jQuery(t).get() :
t.length != undefined && (!t.nodeName || jQuery.nodeName(t, "form")) ?
t : [t] )
);
},
is: function(expr) {
return expr ? jQuery.multiFilter(expr,this).length > 0 : false;
},
hasClass: function(expr) {
return this.is("." + expr);
},
val: function( val ) {
if ( val == undefined ) {
if ( this.length ) {
var elem = this[0];

if ( jQuery.nodeName(elem, "select") ) {
var index = elem.selectedIndex,
a = [],
options = elem.options,
one = elem.type == "select-one";

if ( index < 0 )
return null;

for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
var option = options[i];
if ( option.selected ) {

var val = jQuery.browser.msie && !option.attributes["value"].specified ? option.text : option.value;

if ( one )
return val;

a.push(val);
}
}
return a;

} else
return this[0].value.replace(/\r/g, "");
}
} else
return this.each(function(){
if ( val.constructor == Array && /radio|checkbox/.test(this.type) )
this.checked = (jQuery.inArray(this.value, val) >= 0 ||
jQuery.inArray(this.name, val) >= 0);
else if ( jQuery.nodeName(this, "select") ) {
var tmp = val.constructor == Array ? val : [val];
jQuery("option", this).each(function(){
this.selected = (jQuery.inArray(this.value, tmp) >= 0 ||
jQuery.inArray(this.text, tmp) >= 0);
});
if ( !tmp.length )
this.selectedIndex = -1;
} else
this.value = val;
});
},
html: function( val ) {
return val == undefined ?
( this.length ? this[0].innerHTML : null ) :
this.empty().append( val );
},
replaceWith: function( val ) {
return this.after( val ).remove();
},
eq: function(i){
return this.slice(i, i+1);
},
slice: function() {
return this.pushStack( Array.prototype.slice.apply( this, arguments ) );
},
map: function(fn) {
return this.pushStack(jQuery.map( this, function(elem,i){
return fn.call( elem, i, elem );
}));
},
andSelf: function() {
return this.add( this.prevObject );
},
domManip: function(args, table, dir, fn) {
var clone = this.length > 1, a; 
return this.each(function(){
if ( !a ) {
a = jQuery.clean(args, this.ownerDocument);
if ( dir < 0 )
a.reverse();
}
var obj = this;
if ( table && jQuery.nodeName(this, "table") && jQuery.nodeName(a[0], "tr") )
obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody"));
jQuery.each( a, function(){
var elem = clone ? this.cloneNode(true) : this;
if ( !evalScript(0, elem) )
fn.call( obj, elem );
});
});
}
};
function evalScript(i, elem){
var script = jQuery.nodeName(elem, "script");
if ( script ) {
if ( elem.src )
jQuery.ajax({ url: elem.src, async: false, dataType: "script" });
else
jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
if ( elem.parentNode )
elem.parentNode.removeChild(elem);
} else if ( elem.nodeType == 1 )
jQuery("script", elem).each(evalScript);
return script;
}
jQuery.extend = jQuery.fn.extend = function() {

var target = arguments[0] || {}, a = 1, al = arguments.length, deep = false;

if ( target.constructor == Boolean ) {
deep = target;
target = arguments[1] || {};
}

if ( al == 1 ) {
target = this;
a = 0;
}
var prop;
for ( ; a < al; a++ )

if ( (prop = arguments[a]) != null )

for ( var i in prop ) {

if ( target == prop[i] )
continue;

if ( deep && typeof prop[i] == 'object' && target[i] )
jQuery.extend( target[i], prop[i] );

else if ( prop[i] != undefined )
target[i] = prop[i];
}

return target;
};
var expando = "jQuery" + (new Date()).getTime(), uuid = 0, win = {};
jQuery.extend({
noConflict: function(deep) {
window.$ = _$;
if ( deep )
window.jQuery = _jQuery;
return jQuery;
},


isFunction: function( fn ) {
return !!fn && typeof fn != "string" && !fn.nodeName && 
fn.constructor != Array && /function/i.test( fn + "" );
},

isXMLDoc: function(elem) {
return elem.documentElement && !elem.body ||
elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
},


globalEval: function( data ) {
data = jQuery.trim( data );
if ( data ) {
if ( window.execScript )
window.execScript( data );
else if ( jQuery.browser.safari )

window.setTimeout( data, 0 );
else
eval.call( window, data );
}
},
nodeName: function( elem, name ) {
return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
},
cache: {},
data: function( elem, name, data ) {
elem = elem == window ? win : elem;
var id = elem[ expando ];

if ( !id ) 
id = elem[ expando ] = ++uuid;


if ( name && !jQuery.cache[ id ] )
jQuery.cache[ id ] = {};

if ( data != undefined )
jQuery.cache[ id ][ name ] = data;

return name ? jQuery.cache[ id ][ name ] : id;
},
removeData: function( elem, name ) {
elem = elem == window ? win : elem;
var id = elem[ expando ];

if ( name ) {
if ( jQuery.cache[ id ] ) {

delete jQuery.cache[ id ][ name ];

name = "";
for ( name in jQuery.cache[ id ] ) break;
if ( !name )
jQuery.removeData( elem );
}

} else {

try {
delete elem[ expando ];
} catch(e){


if ( elem.removeAttribute )
elem.removeAttribute( expando );
}

delete jQuery.cache[ id ];
}
},

each: function( obj, fn, args ) {
if ( args ) {
if ( obj.length == undefined )
for ( var i in obj )
fn.apply( obj[i], args );
else
for ( var i = 0, ol = obj.length; i < ol; i++ )
if ( fn.apply( obj[i], args ) === false ) break;

} else {
if ( obj.length == undefined )
for ( var i in obj )
fn.call( obj[i], i, obj[i] );
else
for ( var i = 0, ol = obj.length, val = obj[0]; 
i < ol && fn.call(val,i,val) !== false; val = obj[++i] ){}
}
return obj;
},
prop: function(elem, value, type, index, prop){

if ( jQuery.isFunction( value ) )
value = value.call( elem, [index] );

var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;

return value && value.constructor == Number && type == "curCSS" && !exclude.test(prop) ?
value + "px" :
value;
},
className: {

add: function( elem, c ){
jQuery.each( (c || "").split(/\s+/), function(i, cur){
if ( !jQuery.className.has( elem.className, cur ) )
elem.className += ( elem.className ? " " : "" ) + cur;
});
},

remove: function( elem, c ){
elem.className = c != undefined ?
jQuery.grep( elem.className.split(/\s+/), function(cur){
return !jQuery.className.has( c, cur );	
}).join(" ") : "";
},

has: function( t, c ) {
return jQuery.inArray( c, (t.className || t).toString().split(/\s+/) ) > -1;
}
},
swap: function(e,o,f) {
for ( var i in o ) {
e.style["old"+i] = e.style[i];
e.style[i] = o[i];
}
f.apply( e, [] );
for ( var i in o )
e.style[i] = e.style["old"+i];
},
css: function(e,p) {
if ( p == "height" || p == "width" ) {
var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
jQuery.each( d, function(){
old["padding" + this] = 0;
old["border" + this + "Width"] = 0;
});
jQuery.swap( e, old, function() {
if ( jQuery(e).is(':visible') ) {
oHeight = e.offsetHeight;
oWidth = e.offsetWidth;
} else {
e = jQuery(e.cloneNode(true))
.find(":radio").removeAttr("checked").end()
.css({
visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
}).appendTo(e.parentNode)[0];
var parPos = jQuery.css(e.parentNode,"position") || "static";
if ( parPos == "static" )
e.parentNode.style.position = "relative";
oHeight = e.clientHeight;
oWidth = e.clientWidth;
if ( parPos == "static" )
e.parentNode.style.position = "static";
e.parentNode.removeChild(e);
}
});
return p == "height" ? oHeight : oWidth;
}
return jQuery.curCSS( e, p );
},
curCSS: function(elem, prop, force) {
var ret, stack = [], swap = [];

function color(a){
if ( !jQuery.browser.safari )
return false;
var ret = document.defaultView.getComputedStyle(a,null);
return !ret || ret.getPropertyValue("color") == "";
}
if (prop == "opacity" && jQuery.browser.msie) {
ret = jQuery.attr(elem.style, "opacity");
return ret == "" ? "1" : ret;
}
if (prop.match(/float/i))
prop = styleFloat;
if (!force && elem.style[prop])
ret = elem.style[prop];
else if (document.defaultView && document.defaultView.getComputedStyle) {
if (prop.match(/float/i))
prop = "float";
prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
var cur = document.defaultView.getComputedStyle(elem, null);
if ( cur && !color(elem) )
ret = cur.getPropertyValue(prop);


else {

for ( var a = elem; a && color(a); a = a.parentNode )
stack.unshift(a);


for ( a = 0; a < stack.length; a++ )
if ( color(stack[a]) ) {
swap[a] = stack[a].style.display;
stack[a].style.display = "block";
}


ret = prop == "display" && swap[stack.length-1] != null ?
"none" :
document.defaultView.getComputedStyle(elem,null).getPropertyValue(prop) || "";

for ( a = 0; a < swap.length; a++ )
if ( swap[a] != null )
stack[a].style.display = swap[a];
}
if ( prop == "opacity" && ret == "" )
ret = "1";
} else if (elem.currentStyle) {
var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
ret = elem.currentStyle[prop] || elem.currentStyle[newProp];




if ( !/^\d+(px)?$/i.test(ret) && /^\d/.test(ret) ) {
var style = elem.style.left;
var runtimeStyle = elem.runtimeStyle.left;
elem.runtimeStyle.left = elem.currentStyle.left;
elem.style.left = ret || 0;
ret = elem.style.pixelLeft + "px";
elem.style.left = style;
elem.runtimeStyle.left = runtimeStyle;
}
}
return ret;
},
clean: function(a, doc) {
var r = [];
doc = doc || document;
jQuery.each( a, function(i,arg){
if ( !arg ) return;
if ( arg.constructor == Number )
arg = arg.toString();

if ( typeof arg == "string" ) {

arg = arg.replace(/(<(\w+)[^>]*?)\/>/g, function(m, all, tag){
return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area)$/i)? m : all+"></"+tag+">";
});

var s = jQuery.trim(arg).toLowerCase(), div = doc.createElement("div"), tb = [];
var wrap =

!s.indexOf("<opt") &&
[1, "<select>", "</select>"] ||
!s.indexOf("<leg") &&
[1, "<fieldset>", "</fieldset>"] ||
s.match(/^<(thead|tbody|tfoot|colg|cap)/) &&
[1, "<table>", "</table>"] ||
!s.indexOf("<tr") &&
[2, "<table><tbody>", "</tbody></table>"] ||

(!s.indexOf("<td") || !s.indexOf("<th")) &&
[3, "<table><tbody><tr>", "</tr></tbody></table>"] ||
!s.indexOf("<col") &&
[2, "<table><tbody></tbody><colgroup>", "</colgroup></table>"] ||

jQuery.browser.msie &&
[1, "div<div>", "</div>"] ||
[0,"",""];

div.innerHTML = wrap[1] + arg + wrap[2];

while ( wrap[0]-- )
div = div.lastChild;

if ( jQuery.browser.msie ) {

if ( !s.indexOf("<table") && s.indexOf("<tbody") < 0 ) 
tb = div.firstChild && div.firstChild.childNodes;

else if ( wrap[1] == "<table>" && s.indexOf("<tbody") < 0 )
tb = div.childNodes;
for ( var n = tb.length-1; n >= 0 ; --n )
if ( jQuery.nodeName(tb[n], "tbody") && !tb[n].childNodes.length )
tb[n].parentNode.removeChild(tb[n]);

if ( /^\s/.test(arg) )	
div.insertBefore( doc.createTextNode( arg.match(/^\s*/)[0] ), div.firstChild );
}
arg = jQuery.makeArray( div.childNodes );
}
if ( 0 === arg.length && (!jQuery.nodeName(arg, "form") && !jQuery.nodeName(arg, "select")) )
return;
if ( arg[0] == undefined || jQuery.nodeName(arg, "form") || arg.options )
r.push( arg );
else
r = jQuery.merge( r, arg );
});
return r;
},
attr: function(elem, name, value){
var fix = jQuery.isXMLDoc(elem) ? {} : jQuery.props;


if ( name == "selected" && jQuery.browser.safari )
elem.parentNode.selectedIndex;

if ( fix[name] ) {
if ( value != undefined ) elem[fix[name]] = value;
return elem[fix[name]];
} else if ( jQuery.browser.msie && name == "style" )
return jQuery.attr( elem.style, "cssText", value );
else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName(elem, "form") && (name == "action" || name == "method") )
return elem.getAttributeNode(name).nodeValue;

else if ( elem.tagName ) {
if ( value != undefined ) {
if ( name == "type" && jQuery.nodeName(elem,"input") && elem.parentNode )
throw "type property can't be changed";
elem.setAttribute( name, value );
}
if ( jQuery.browser.msie && /href|src/.test(name) && !jQuery.isXMLDoc(elem) ) 
return elem.getAttribute( name, 2 );
return elem.getAttribute( name );

} else {

if ( name == "opacity" && jQuery.browser.msie ) {
if ( value != undefined ) {


elem.zoom = 1; 

elem.filter = (elem.filter || "").replace(/alpha\([^)]*\)/,"") +
(parseFloat(value).toString() == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
}
return elem.filter ? 
(parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() : "";
}
name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
if ( value != undefined ) elem[name] = value;
return elem[name];
}
},
trim: function(t){
return (t||"").replace(/^\s+|\s+$/g, "");
},
makeArray: function( a ) {
var r = [];

if ( typeof a != "array" )
for ( var i = 0, al = a.length; i < al; i++ )
r.push( a[i] );
else
r = a.slice( 0 );
return r;
},
inArray: function( b, a ) {
for ( var i = 0, al = a.length; i < al; i++ )
if ( a[i] == b )
return i;
return -1;
},
merge: function(first, second) {




if ( jQuery.browser.msie ) {
for ( var i = 0; second[i]; i++ )
if ( second[i].nodeType != 8 )
first.push(second[i]);
} else
for ( var i = 0; second[i]; i++ )
first.push(second[i]);
return first;
},
unique: function(first) {
var r = [], done = {};
try {
for ( var i = 0, fl = first.length; i < fl; i++ ) {
var id = jQuery.data(first[i]);
if ( !done[id] ) {
done[id] = true;
r.push(first[i]);
}
}
} catch(e) {
r = first;
}
return r;
},
grep: function(elems, fn, inv) {


if ( typeof fn == "string" )
fn = eval("false||function(a,i){return " + fn + "}");
var result = [];


for ( var i = 0, el = elems.length; i < el; i++ )
if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
result.push( elems[i] );
return result;
},
map: function(elems, fn) {


if ( typeof fn == "string" )
fn = eval("false||function(a){return " + fn + "}");
var result = [];


for ( var i = 0, el = elems.length; i < el; i++ ) {
var val = fn(elems[i],i);
if ( val !== null && val != undefined ) {
if ( val.constructor != Array ) val = [val];
result = result.concat( val );
}
}
return result;
}
});
var userAgent = navigator.userAgent.toLowerCase();

jQuery.browser = {
version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
safari: /webkit/.test(userAgent),
opera: /opera/.test(userAgent),
msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
};
var styleFloat = jQuery.browser.msie ? "styleFloat" : "cssFloat";
jQuery.extend({

boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat",
styleFloat: jQuery.browser.msie ? "styleFloat" : "cssFloat",
props: {
"for": "htmlFor",
"class": "className",
"float": styleFloat,
cssFloat: styleFloat,
styleFloat: styleFloat,
innerHTML: "innerHTML",
className: "className",
value: "value",
disabled: "disabled",
checked: "checked",
readonly: "readOnly",
selected: "selected",
maxlength: "maxLength"
}
});
jQuery.each({
parent: "a.parentNode",
parents: "jQuery.dir(a,'parentNode')",
next: "jQuery.nth(a,2,'nextSibling')",
prev: "jQuery.nth(a,2,'previousSibling')",
nextAll: "jQuery.dir(a,'nextSibling')",
prevAll: "jQuery.dir(a,'previousSibling')",
siblings: "jQuery.sibling(a.parentNode.firstChild,a)",
children: "jQuery.sibling(a.firstChild)",
contents: "jQuery.nodeName(a,'iframe')?a.contentDocument||a.contentWindow.document:jQuery.makeArray(a.childNodes)"
}, function(i,n){
jQuery.fn[ i ] = function(a) {
var ret = jQuery.map(this,n);
if ( a && typeof a == "string" )
ret = jQuery.multiFilter(a,ret);
return this.pushStack( jQuery.unique(ret) );
};
});
jQuery.each({
appendTo: "append",
prependTo: "prepend",
insertBefore: "before",
insertAfter: "after",
replaceAll: "replaceWith"
}, function(i,n){
jQuery.fn[ i ] = function(){
var a = arguments;
return this.each(function(){
for ( var j = 0, al = a.length; j < al; j++ )
jQuery(a[j])[n]( this );
});
};
});
jQuery.each( {
removeAttr: function( key ) {
jQuery.attr( this, key, "" );
this.removeAttribute( key );
},
addClass: function(c){
jQuery.className.add(this,c);
},
removeClass: function(c){
jQuery.className.remove(this,c);
},
toggleClass: function( c ){
jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this, c);
},
remove: function(a){
if ( !a || jQuery.filter( a, [this] ).r.length ) {
jQuery.removeData( this );
this.parentNode.removeChild( this );
}
},
empty: function() {

jQuery("*", this).each(function(){ jQuery.removeData(this); });
while ( this.firstChild )
this.removeChild( this.firstChild );
}
}, function(i,n){
jQuery.fn[ i ] = function() {
return this.each( n, arguments );
};
});
jQuery.each( [ "Height", "Width" ], function(i,name){
var n = name.toLowerCase();
jQuery.fn[ n ] = function(h) {
return this[0] == window ?
jQuery.browser.safari && self["inner" + name] ||
jQuery.boxModel && Math.max(document.documentElement["client" + name], document.body["client" + name]) ||
document.body["client" + name] :
this[0] == document ?
Math.max( document.body["scroll" + name], document.body["offset" + name] ) :
h == undefined ?
( this.length ? jQuery.css( this[0], n ) : null ) :
this.css( n, h.constructor == String ? h : h + "px" );
};
});
var chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ?
"(?:[\\w*_-]|\\\\.)" :
"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",
quickChild = new RegExp("^>\\s*(" + chars + "+)"),
quickID = new RegExp("^(" + chars + "+)(#)(" + chars + "+)"),
quickClass = new RegExp("^([#.]?)(" + chars + "*)");
jQuery.extend({
expr: {
"": "m[2]=='*'||jQuery.nodeName(a,m[2])",
"#": "a.getAttribute('id')==m[2]",
":": {

lt: "i<m[3]-0",
gt: "i>m[3]-0",
nth: "m[3]-0==i",
eq: "m[3]-0==i",
first: "i==0",
last: "i==r.length-1",
even: "i%2==0",
odd: "i%2",

"first-child": "a.parentNode.getElementsByTagName('*')[0]==a",
"last-child": "jQuery.nth(a.parentNode.lastChild,1,'previousSibling')==a",
"only-child": "!jQuery.nth(a.parentNode.lastChild,2,'previousSibling')",

parent: "a.firstChild",
empty: "!a.firstChild",

contains: "(a.textContent||a.innerText||jQuery(a).text()||'').indexOf(m[3])>=0",

visible: '"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"',
hidden: '"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden"',

enabled: "!a.disabled",
disabled: "a.disabled",
checked: "a.checked",
selected: "a.selected||jQuery.attr(a,'selected')",

text: "'text'==a.type",
radio: "'radio'==a.type",
checkbox: "'checkbox'==a.type",
file: "'file'==a.type",
password: "'password'==a.type",
submit: "'submit'==a.type",
image: "'image'==a.type",
reset: "'reset'==a.type",
button: '"button"==a.type||jQuery.nodeName(a,"button")',
input: "/input|select|textarea|button/i.test(a.nodeName)",

has: "jQuery.find(m[3],a).length",

header: "/h\\d/i.test(a.nodeName)",

animated: "jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length"
}
},

parse: [

/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,

/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,

new RegExp("^([:.#]*)(" + chars + "+)")
],
multiFilter: function( expr, elems, not ) {
var old, cur = [];
while ( expr && expr != old ) {
old = expr;
var f = jQuery.filter( expr, elems, not );
expr = f.t.replace(/^\s*,\s*/, "" );
cur = not ? elems = f.r : jQuery.merge( cur, f.r );
}
return cur;
},
find: function( t, context ) {

if ( typeof t != "string" )
return [ t ];

if ( context && !context.nodeType )
context = null;

context = context || document;

var ret = [context], done = [], last;


while ( t && last != t ) {
var r = [];
last = t;
t = jQuery.trim(t);
var foundToken = false;


var re = quickChild;
var m = re.exec(t);
if ( m ) {
var nodeName = m[1].toUpperCase();

for ( var i = 0; ret[i]; i++ )
for ( var c = ret[i].firstChild; c; c = c.nextSibling )
if ( c.nodeType == 1 && (nodeName == "*" || c.nodeName.toUpperCase() == nodeName.toUpperCase()) )
r.push( c );
ret = r;
t = t.replace( re, "" );
if ( t.indexOf(" ") == 0 ) continue;
foundToken = true;
} else {
re = /^([>+~])\s*(\w*)/i;
if ( (m = re.exec(t)) != null ) {
r = [];
var nodeName = m[2], merge = {};
m = m[1];
for ( var j = 0, rl = ret.length; j < rl; j++ ) {
var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild;
for ( ; n; n = n.nextSibling )
if ( n.nodeType == 1 ) {
var id = jQuery.data(n);
if ( m == "~" && merge[id] ) break;
if (!nodeName || n.nodeName.toUpperCase() == nodeName.toUpperCase() ) {
if ( m == "~" ) merge[id] = true;
r.push( n );
}
if ( m == "+" ) break;
}
}
ret = r;

t = jQuery.trim( t.replace( re, "" ) );
foundToken = true;
}
}


if ( t && !foundToken ) {

if ( !t.indexOf(",") ) {

if ( context == ret[0] ) ret.shift();

done = jQuery.merge( done, ret );

r = ret = [context];

t = " " + t.substr(1,t.length);
} else {

var re2 = quickID;
var m = re2.exec(t);

if ( m ) {
m = [ 0, m[2], m[3], m[1] ];
} else {


re2 = quickClass;
m = re2.exec(t);
}
m[2] = m[2].replace(/\\/g, "");
var elem = ret[ret.length-1];

if ( m[1] == "#" && elem && elem.getElementById && !jQuery.isXMLDoc(elem) ) {

var oid = elem.getElementById(m[2]);



if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && typeof oid.id == "string" && oid.id != m[2] )
oid = jQuery('[@id="'+m[2]+'"]', elem)[0];


ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
} else {

for ( var i = 0; ret[i]; i++ ) {

var tag = m[1] == "#" && m[3] ? m[3] : m[1] != "" || m[0] == "" ? "*" : m[2];

if ( tag == "*" && ret[i].nodeName.toLowerCase() == "object" )
tag = "param";
r = jQuery.merge( r, ret[i].getElementsByTagName( tag ));
}

if ( m[1] == "." )
r = jQuery.classFilter( r, m[2] );

if ( m[1] == "#" ) {
var tmp = [];

for ( var i = 0; r[i]; i++ )
if ( r[i].getAttribute("id") == m[2] ) {
tmp = [ r[i] ];
break;
}
r = tmp;
}
ret = r;
}
t = t.replace( re2, "" );
}
}

if ( t ) {

var val = jQuery.filter(t,r);
ret = r = val.r;
t = jQuery.trim(val.t);
}
}


if ( t )
ret = [];

if ( ret && context == ret[0] )
ret.shift();

done = jQuery.merge( done, ret );
return done;
},
classFilter: function(r,m,not){
m = " " + m + " ";
var tmp = [];
for ( var i = 0; r[i]; i++ ) {
var pass = (" " + r[i].className + " ").indexOf( m ) >= 0;
if ( !not && pass || not && !pass )
tmp.push( r[i] );
}
return tmp;
},
filter: function(t,r,not) {
var last;

while ( t  && t != last ) {
last = t;
var p = jQuery.parse, m;
for ( var i = 0; p[i]; i++ ) {
m = p[i].exec( t );
if ( m ) {

t = t.substring( m[0].length );
m[2] = m[2].replace(/\\/g, "");
break;
}
}
if ( !m )
break;


if ( m[1] == ":" && m[2] == "not" )
r = jQuery.filter(m[3], r, true).r;

else if ( m[1] == "." )
r = jQuery.classFilter(r, m[2], not);
else if ( m[1] == "[" ) {
var tmp = [], type = m[3];
for ( var i = 0, rl = r.length; i < rl; i++ ) {
var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ];
if ( z == null || /href|src|selected/.test(m[2]) )
z = jQuery.attr(a,m[2]) || '';
if ( (type == "" && !!z ||
type == "=" && z == m[5] ||
type == "!=" && z != m[5] ||
type == "^=" && z && !z.indexOf(m[5]) ||
type == "$=" && z.substr(z.length - m[5].length) == m[5] ||
(type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0) ^ not )
tmp.push( a );
}
r = tmp;

} else if ( m[1] == ":" && m[2] == "nth-child" ) {
var merge = {}, tmp = [],
test = /(\d*)n\+?(\d*)/.exec(
m[3] == "even" && "2n" || m[3] == "odd" && "2n+1" ||
!/\D/.test(m[3]) && "n+" + m[3] || m[3]),
first = (test[1] || 1) - 0, last = test[2] - 0;
for ( var i = 0, rl = r.length; i < rl; i++ ) {
var node = r[i], parentNode = node.parentNode, id = jQuery.data(parentNode);
if ( !merge[id] ) {
var c = 1;
for ( var n = parentNode.firstChild; n; n = n.nextSibling )
if ( n.nodeType == 1 )
n.nodeIndex = c++;
merge[id] = true;
}
var add = false;
if ( first == 1 ) {
if ( last == 0 || node.nodeIndex == last )
add = true;
} else if ( (node.nodeIndex + last) % first == 0 )
add = true;
if ( add ^ not )
tmp.push( node );
}
r = tmp;

} else {
var f = jQuery.expr[m[1]];
if ( typeof f != "string" )
f = jQuery.expr[m[1]][m[2]];

f = eval("false||function(a,i){return " + f + "}");

r = jQuery.grep( r, f, not );
}
}


return { r: r, t: t };
},
dir: function( elem, dir ){
var matched = [];
var cur = elem[dir];
while ( cur && cur != document ) {
if ( cur.nodeType == 1 )
matched.push( cur );
cur = cur[dir];
}
return matched;
},
nth: function(cur,result,dir,elem){
result = result || 1;
var num = 0;
for ( ; cur; cur = cur[dir] )
if ( cur.nodeType == 1 && ++num == result )
break;
return cur;
},
sibling: function( n, elem ) {
var r = [];
for ( ; n; n = n.nextSibling ) {
if ( n.nodeType == 1 && (!elem || n != elem) )
r.push( n );
}
return r;
}
});
/*
* A number of helper functions used for managing events.
* Many of the ideas behind this code orignated from 
* Dean Edwards' addEvent library.
*/
jQuery.event = {


add: function(element, type, handler, data) {


if ( jQuery.browser.msie && element.setInterval != undefined )
element = window;

if ( !handler.guid )
handler.guid = this.guid++;

if( data != undefined ) { 

var fn = handler; 

handler = function() { 

return fn.apply(this, arguments); 
};

handler.data = data;

handler.guid = fn.guid;
}

var parts = type.split(".");
type = parts[0];
handler.type = parts[1];

var events = jQuery.data(element, "events") || jQuery.data(element, "events", {});
var handle = jQuery.data(element, "handle", function(){

var val;


if ( typeof jQuery == "undefined" || jQuery.event.triggered )
return val;
val = jQuery.event.handle.apply(element, arguments);
return val;
});

var handlers = events[type];

if (!handlers) {
handlers = events[type] = {};	

if (element.addEventListener)
element.addEventListener(type, handle, false);
else
element.attachEvent("on" + type, handle);
}

handlers[handler.guid] = handler;

this.global[type] = true;
},
guid: 1,
global: {},

remove: function(element, type, handler) {
var events = jQuery.data(element, "events"), ret, index;

if ( typeof type == "string" ) {
var parts = type.split(".");
type = parts[0];
}
if ( events ) {

if ( type && type.type ) {
handler = type.handler;
type = type.type;
}
if ( !type ) {
for ( type in events )
this.remove( element, type );
} else if ( events[type] ) {

if ( handler )
delete events[type][handler.guid];

else
for ( handler in events[type] )

if ( !parts[1] || events[type][handler].type == parts[1] )
delete events[type][handler];

for ( ret in events[type] ) break;
if ( !ret ) {
if (element.removeEventListener)
element.removeEventListener(type, jQuery.data(element, "handle"), false);
else
element.detachEvent("on" + type, jQuery.data(element, "handle"));
ret = null;
delete events[type];
}
}

for ( ret in events ) break;
if ( !ret ) {
jQuery.removeData( element, "events" );
jQuery.removeData( element, "handle" );
}
}
},
trigger: function(type, data, element, donative, extra) {

data = jQuery.makeArray(data || []);

if ( !element ) {

if ( this.global[type] )
jQuery("*").add([window, document]).trigger(type, data);

} else {
var val, ret, fn = jQuery.isFunction( element[ type ] || null ),

evt = !data[0] || !data[0].preventDefault;

if ( evt )
data.unshift( this.fix({ type: type, target: element }) );

data[0].type = type;

if ( jQuery.isFunction( jQuery.data(element, "handle") ) )
val = jQuery.data(element, "handle").apply( element, data );

if ( !fn && element["on"+type] && element["on"+type].apply( element, data ) === false )
val = false;

if ( evt )
data.shift();

if ( extra && extra.apply( element, data ) === false )
val = false;

if ( fn && donative !== false && val !== false && !(jQuery.nodeName(element, 'a') && type == "click") ) {
this.triggered = true;
element[ type ]();
}
this.triggered = false;
}
return val;
},
handle: function(event) {

var val;

event = jQuery.event.fix( event || window.event || {} ); 

var parts = event.type.split(".");
event.type = parts[0];
var c = jQuery.data(this, "events") && jQuery.data(this, "events")[event.type], args = Array.prototype.slice.call( arguments, 1 );
args.unshift( event );
for ( var j in c ) {


args[0].handler = c[j];
args[0].data = c[j].data;

if ( !parts[1] || c[j].type == parts[1] ) {
var tmp = c[j].apply( this, args );
if ( val !== false )
val = tmp;
if ( tmp === false ) {
event.preventDefault();
event.stopPropagation();
}
}
}

if (jQuery.browser.msie)
event.target = event.preventDefault = event.stopPropagation =
event.handler = event.data = null;
return val;
},
fix: function(event) {


var originalEvent = event;
event = jQuery.extend({}, originalEvent);


event.preventDefault = function() {

if (originalEvent.preventDefault)
originalEvent.preventDefault();

originalEvent.returnValue = false;
};
event.stopPropagation = function() {

if (originalEvent.stopPropagation)
originalEvent.stopPropagation();

originalEvent.cancelBubble = true;
};

if ( !event.target && event.srcElement )
event.target = event.srcElement;

if (jQuery.browser.safari && event.target.nodeType == 3)
event.target = originalEvent.target.parentNode;

if ( !event.relatedTarget && event.fromElement )
event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;

if ( event.pageX == null && event.clientX != null ) {
var e = document.documentElement, b = document.body;
event.pageX = event.clientX + (e && e.scrollLeft || b.scrollLeft || 0);
event.pageY = event.clientY + (e && e.scrollTop || b.scrollTop || 0);
}

if ( !event.which && (event.charCode || event.keyCode) )
event.which = event.charCode || event.keyCode;

if ( !event.metaKey && event.ctrlKey )
event.metaKey = event.ctrlKey;


if ( !event.which && event.button )
event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
return event;
}
};
jQuery.fn.extend({
bind: function( type, data, fn ) {
return type == "unload" ? this.one(type, data, fn) : this.each(function(){
jQuery.event.add( this, type, fn || data, fn && data );
});
},
one: function( type, data, fn ) {
return this.each(function(){
jQuery.event.add( this, type, function(event) {
jQuery(this).unbind(event);
return (fn || data).apply( this, arguments);
}, fn && data);
});
},
unbind: function( type, fn ) {
return this.each(function(){
jQuery.event.remove( this, type, fn );
});
},
trigger: function( type, data, fn ) {
return this.each(function(){
jQuery.event.trigger( type, data, this, true, fn );
});
},
triggerHandler: function( type, data, fn ) {
if ( this[0] )
return jQuery.event.trigger( type, data, this[0], false, fn );
},
toggle: function() {

var a = arguments;
return this.click(function(e) {

this.lastToggle = 0 == this.lastToggle ? 1 : 0;

e.preventDefault();

return a[this.lastToggle].apply( this, [e] ) || false;
});
},
hover: function(f,g) {

function handleHover(e) {

var p = e.relatedTarget;

while ( p && p != this ) try { p = p.parentNode; } catch(e) { p = this; };

if ( p == this ) return false;

return (e.type == "mouseover" ? f : g).apply(this, [e]);
}

return this.mouseover(handleHover).mouseout(handleHover);
},
ready: function(f) {

bindReady();

if ( jQuery.isReady )

f.apply( document, [jQuery] );

else

jQuery.readyList.push( function() { return f.apply(this, [jQuery]); } );
return this;
}
});
jQuery.extend({
/*
* All the code that makes DOM Ready work nicely.
*/
isReady: false,
readyList: [],

ready: function() {

if ( !jQuery.isReady ) {

jQuery.isReady = true;

if ( jQuery.readyList ) {

jQuery.each( jQuery.readyList, function(){
this.apply( document );
});

jQuery.readyList = null;
}

if ( jQuery.browser.mozilla || jQuery.browser.opera )
document.removeEventListener( "DOMContentLoaded", jQuery.ready, false );

if( !window.frames.length ) // don't remove if frames are present (#1187)
jQuery(window).load(function(){ jQuery("#__ie_init").remove(); });
}
}
});
jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
"mousedown,mouseup,mousemove,mouseover,mouseout,change,select," + 
"submit,keydown,keypress,keyup,error").split(","), function(i,o){

jQuery.fn[o] = function(f){
return f ? this.bind(o, f) : this.trigger(o);
};
});
var readyBound = false;
function bindReady(){
if ( readyBound ) return;
readyBound = true;

if ( jQuery.browser.mozilla || jQuery.browser.opera )

document.addEventListener( "DOMContentLoaded", jQuery.ready, false );


else if ( jQuery.browser.msie ) {

document.write("<scr" + "ipt id=__ie_init defer=true " + 
"src=//:><\/script>");

var script = document.getElementById("__ie_init");

if ( script ) 
script.onreadystatechange = function() {
if ( this.readyState != "complete" ) return;
jQuery.ready();
};

script = null;

} else if ( jQuery.browser.safari )

jQuery.safariTimer = setInterval(function(){

if ( document.readyState == "loaded" || 
document.readyState == "complete" ) {

clearInterval( jQuery.safariTimer );
jQuery.safariTimer = null;

jQuery.ready();
}
}, 10); 

jQuery.event.add( window, "load", jQuery.ready );
}
jQuery.fn.extend({
load: function( url, params, callback ) {
if ( jQuery.isFunction( url ) )
return this.bind("load", url);
var off = url.indexOf(" ");
if ( off >= 0 ) {
var selector = url.slice(off, url.length);
url = url.slice(0, off);
}
callback = callback || function(){};

var type = "GET";

if ( params )

if ( jQuery.isFunction( params ) ) {

callback = params;
params = null;

} else {
params = jQuery.param( params );
type = "POST";
}
var self = this;

jQuery.ajax({
url: url,
type: type,
data: params,
complete: function(res, status){

if ( status == "success" || status == "notmodified" )

self.html( selector ?

jQuery("<div/>")


.append(res.responseText.replace(/<script(.|\s)*?\/script>/g, ""))

.find(selector) :

res.responseText );

setTimeout(function(){
self.each( callback, [res.responseText, status, res] );
}, 13);
}
});
return this;
},
serialize: function() {
return jQuery.param(this.serializeArray());
},
serializeArray: function() {
return this.map(function(){
return jQuery.nodeName(this, "form") ?
jQuery.makeArray(this.elements) : this;
})
.filter(function(){
return this.name && !this.disabled && 
(this.checked || /select|textarea/i.test(this.nodeName) || 
/text|hidden|password/i.test(this.type));
})
.map(function(i, elem){
var val = jQuery(this).val();
return val == null ? null :
val.constructor == Array ?
jQuery.map( val, function(val, i){
return {name: elem.name, value: val};
}) :
{name: elem.name, value: val};
}).get();
}
});

jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){
jQuery.fn[o] = function(f){
return this.bind(o, f);
};
});
var jsc = (new Date).getTime();
jQuery.extend({
get: function( url, data, callback, type ) {

if ( jQuery.isFunction( data ) ) {
callback = data;
data = null;
}
return jQuery.ajax({
type: "GET",
url: url,
data: data,
success: callback,
dataType: type
});
},
getScript: function( url, callback ) {
return jQuery.get(url, null, callback, "script");
},
getJSON: function( url, data, callback ) {
return jQuery.get(url, data, callback, "json");
},
post: function( url, data, callback, type ) {
if ( jQuery.isFunction( data ) ) {
callback = data;
data = {};
}
return jQuery.ajax({
type: "POST",
url: url,
data: data,
success: callback,
dataType: type
});
},
ajaxSetup: function( settings ) {
jQuery.extend( jQuery.ajaxSettings, settings );
},
ajaxSettings: {
global: true,
type: "GET",
timeout: 0,
contentType: "application/x-www-form-urlencoded",
processData: true,
async: true,
data: null
},

lastModified: {},
ajax: function( s ) {
var jsonp, jsre = /=(\?|%3F)/g, status, data;


s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s));

if ( s.data && s.processData && typeof s.data != "string" )
s.data = jQuery.param(s.data);

if ( s.dataType == "jsonp" ) {
if ( s.type.toLowerCase() == "get" ) {
if ( !s.url.match(jsre) )
s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?";
} else if ( !s.data || !s.data.match(jsre) )
s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
s.dataType = "json";
}

if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) {
jsonp = "jsonp" + jsc++;

if ( s.data )
s.data = s.data.replace(jsre, "=" + jsonp);
s.url = s.url.replace(jsre, "=" + jsonp);


s.dataType = "script";

window[ jsonp ] = function(tmp){
data = tmp;
success();
complete();

window[ jsonp ] = undefined;
try{ delete window[ jsonp ]; } catch(e){}
};
}
if ( s.dataType == "script" && s.cache == null )
s.cache = false;
if ( s.cache === false && s.type.toLowerCase() == "get" )
s.url += (s.url.match(/\?/) ? "&" : "?") + "_=" + (new Date()).getTime();

if ( s.data && s.type.toLowerCase() == "get" ) {
s.url += (s.url.match(/\?/) ? "&" : "?") + s.data;

s.data = null;
}

if ( s.global && ! jQuery.active++ )
jQuery.event.trigger( "ajaxStart" );


if ( !s.url.indexOf("http") && s.dataType == "script" ) {
var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script");
script.src = s.url;

if ( !jsonp && (s.success || s.complete) ) {
var done = false;

script.onload = script.onreadystatechange = function(){
if ( !done && (!this.readyState || 
this.readyState == "loaded" || this.readyState == "complete") ) {
done = true;
success();
complete();
head.removeChild( script );
}
};
}
head.appendChild(script);

return;
}
var requestDone = false;


var xml = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();

xml.open(s.type, s.url, s.async);

if ( s.data )
xml.setRequestHeader("Content-Type", s.contentType);

if ( s.ifModified )
xml.setRequestHeader("If-Modified-Since",
jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" );

xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");

if ( s.beforeSend )
s.beforeSend(xml);
if ( s.global )
jQuery.event.trigger("ajaxSend", [xml, s]);

var onreadystatechange = function(isTimeout){

if ( !requestDone && xml && (xml.readyState == 4 || isTimeout == "timeout") ) {
requestDone = true;

if (ival) {
clearInterval(ival);
ival = null;
}
status = isTimeout == "timeout" && "timeout" ||
!jQuery.httpSuccess( xml ) && "error" ||
s.ifModified && jQuery.httpNotModified( xml, s.url ) && "notmodified" ||
"success";
if ( status == "success" ) {

try {

data = jQuery.httpData( xml, s.dataType );
} catch(e) {
status = "parsererror";
}
}

if ( status == "success" ) {

var modRes;
try {
modRes = xml.getResponseHeader("Last-Modified");
} catch(e) {} // swallow exception thrown by FF if header is not available
if ( s.ifModified && modRes )
jQuery.lastModified[s.url] = modRes;

if ( !jsonp )
success();	
} else
jQuery.handleError(s, xml, status);

complete();

if ( s.async )
xml = null;
}
};
if ( s.async ) {

var ival = setInterval(onreadystatechange, 13); 

if ( s.timeout > 0 )
setTimeout(function(){

if ( xml ) {

xml.abort();
if( !requestDone )
onreadystatechange( "timeout" );
}
}, s.timeout);
}

try {
xml.send(s.data);
} catch(e) {
jQuery.handleError(s, xml, null, e);
}

if ( !s.async )
onreadystatechange();

return xml;
function success(){

if ( s.success )
s.success( data, status );

if ( s.global )
jQuery.event.trigger( "ajaxSuccess", [xml, s] );
}
function complete(){

if ( s.complete )
s.complete(xml, status);

if ( s.global )
jQuery.event.trigger( "ajaxComplete", [xml, s] );

if ( s.global && ! --jQuery.active )
jQuery.event.trigger( "ajaxStop" );
}
},
handleError: function( s, xml, status, e ) {

if ( s.error ) s.error( xml, status, e );

if ( s.global )
jQuery.event.trigger( "ajaxError", [xml, s, e] );
},

active: 0,

httpSuccess: function( r ) {
try {
return !r.status && location.protocol == "file:" ||
( r.status >= 200 && r.status < 300 ) || r.status == 304 ||
jQuery.browser.safari && r.status == undefined;
} catch(e){}
return false;
},

httpNotModified: function( xml, url ) {
try {
var xmlRes = xml.getResponseHeader("Last-Modified");

return xml.status == 304 || xmlRes == jQuery.lastModified[url] ||
jQuery.browser.safari && xml.status == undefined;
} catch(e){}
return false;
},
httpData: function( r, type ) {
var ct = r.getResponseHeader("content-type");
var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0;
var data = xml ? r.responseXML : r.responseText;
if ( xml && data.documentElement.tagName == "parsererror" )
throw "parsererror";

if ( type == "script" )
jQuery.globalEval( data );

if ( type == "json" )
data = eval("(" + data + ")");
return data;
},


param: function( a ) {
var s = [];


if ( a.constructor == Array || a.jquery )

jQuery.each( a, function(){
s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) );
});

else

for ( var j in a )

if ( a[j] && a[j].constructor == Array )
jQuery.each( a[j], function(){
s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );
});
else
s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) );

return s.join("&").replace(/%20/g, "+");
}
});
jQuery.fn.extend({
show: function(speed,callback){
return speed ?
this.animate({
height: "show", width: "show", opacity: "show"
}, speed, callback) :
this.filter(":hidden").each(function(){
this.style.display = this.oldblock ? this.oldblock : "";
if ( jQuery.css(this,"display") == "none" )
this.style.display = "block";
}).end();
},
hide: function(speed,callback){
return speed ?
this.animate({
height: "hide", width: "hide", opacity: "hide"
}, speed, callback) :
this.filter(":visible").each(function(){
this.oldblock = this.oldblock || jQuery.css(this,"display");
if ( this.oldblock == "none" )
this.oldblock = "block";
this.style.display = "none";
}).end();
},

_toggle: jQuery.fn.toggle,
toggle: function( fn, fn2 ){
return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
this._toggle( fn, fn2 ) :
fn ?
this.animate({
height: "toggle", width: "toggle", opacity: "toggle"
}, fn, fn2) :
this.each(function(){
jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
});
},
slideDown: function(speed,callback){
return this.animate({height: "show"}, speed, callback);
},
slideUp: function(speed,callback){
return this.animate({height: "hide"}, speed, callback);
},
slideToggle: function(speed, callback){
return this.animate({height: "toggle"}, speed, callback);
},
fadeIn: function(speed, callback){
return this.animate({opacity: "show"}, speed, callback);
},
fadeOut: function(speed, callback){
return this.animate({opacity: "hide"}, speed, callback);
},
fadeTo: function(speed,to,callback){
return this.animate({opacity: to}, speed, callback);
},
animate: function( prop, speed, easing, callback ) {
var opt = jQuery.speed(speed, easing, callback);
return this[ opt.queue === false ? "each" : "queue" ](function(){
opt = jQuery.extend({}, opt);
var hidden = jQuery(this).is(":hidden"), self = this;
for ( var p in prop ) {
if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
return jQuery.isFunction(opt.complete) && opt.complete.apply(this);
if ( p == "height" || p == "width" ) {

opt.display = jQuery.css(this, "display");

opt.overflow = this.style.overflow;
}
}
if ( opt.overflow != null )
this.style.overflow = "hidden";
opt.curAnim = jQuery.extend({}, prop);
jQuery.each( prop, function(name, val){
var e = new jQuery.fx( self, opt, name );
if ( /toggle|show|hide/.test(val) )
e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
else {
var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
start = e.cur(true) || 0;
if ( parts ) {
var end = parseFloat(parts[2]),
unit = parts[3] || "px";

if ( unit != "px" ) {
self.style[ name ] = (end || 1) + unit;
start = ((end || 1) / e.cur(true)) * start;
self.style[ name ] = start + unit;
}

if ( parts[1] )
end = ((parts[1] == "-=" ? -1 : 1) * end) + start;
e.custom( start, end, unit );
} else
e.custom( start, val, "" );
}
});

return true;
});
},
queue: function(type, fn){
if ( jQuery.isFunction(type) ) {
fn = type;
type = "fx";
}
if ( !type || (typeof type == "string" && !fn) )
return queue( this[0], type );
return this.each(function(){
if ( fn.constructor == Array )
queue(this, type, fn);
else {
queue(this, type).push( fn );
if ( queue(this, type).length == 1 )
fn.apply(this);
}
});
},
stop: function(){
var timers = jQuery.timers;
return this.each(function(){
for ( var i = 0; i < timers.length; i++ )
if ( timers[i].elem == this )
timers.splice(i--, 1);
}).dequeue();
}
});
var queue = function( elem, type, array ) {
if ( !elem )
return;
var q = jQuery.data( elem, type + "queue" );
if ( !q || array )
q = jQuery.data( elem, type + "queue", 
array ? jQuery.makeArray(array) : [] );
return q;
};
jQuery.fn.dequeue = function(type){
type = type || "fx";
return this.each(function(){
var q = queue(this, type);
q.shift();
if ( q.length )
q[0].apply( this );
});
};
jQuery.extend({
speed: function(speed, easing, fn) {
var opt = speed && speed.constructor == Object ? speed : {
complete: fn || !fn && easing || 
jQuery.isFunction( speed ) && speed,
duration: speed,
easing: fn && easing || easing && easing.constructor != Function && easing
};
opt.duration = (opt.duration && opt.duration.constructor == Number ? 
opt.duration : 
{ slow: 600, fast: 200 }[opt.duration]) || 400;

opt.old = opt.complete;
opt.complete = function(){
jQuery(this).dequeue();
if ( jQuery.isFunction( opt.old ) )
opt.old.apply( this );
};
return opt;
},
easing: {
linear: function( p, n, firstNum, diff ) {
return firstNum + diff * p;
},
swing: function( p, n, firstNum, diff ) {
return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
}
},
timers: [],
fx: function( elem, options, prop ){
this.options = options;
this.elem = elem;
this.prop = prop;
if ( !options.orig )
options.orig = {};
}
});
jQuery.fx.prototype = {

update: function(){
if ( this.options.step )
this.options.step.apply( this.elem, [ this.now, this ] );
(jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );

if ( this.prop == "height" || this.prop == "width" )
this.elem.style.display = "block";
},

cur: function(force){
if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null )
return this.elem[ this.prop ];
var r = parseFloat(jQuery.curCSS(this.elem, this.prop, force));
return r && r > -10000 ? r : parseFloat(jQuery.css(this.elem, this.prop)) || 0;
},

custom: function(from, to, unit){
this.startTime = (new Date()).getTime();
this.start = from;
this.end = to;
this.unit = unit || this.unit || "px";
this.now = this.start;
this.pos = this.state = 0;
this.update();
var self = this;
function t(){
return self.step();
}
t.elem = this.elem;
jQuery.timers.push(t);
if ( jQuery.timers.length == 1 ) {
var timer = setInterval(function(){
var timers = jQuery.timers;
for ( var i = 0; i < timers.length; i++ )
if ( !timers[i]() )
timers.splice(i--, 1);
if ( !timers.length )
clearInterval( timer );
}, 13);
}
},

show: function(){

this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
this.options.show = true;

this.custom(0, this.cur());


if ( this.prop == "width" || this.prop == "height" )
this.elem.style[this.prop] = "1px";

jQuery(this.elem).show();
},

hide: function(){

this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
this.options.hide = true;

this.custom(this.cur(), 0);
},

step: function(){
var t = (new Date()).getTime();
if ( t > this.options.duration + this.startTime ) {
this.now = this.end;
this.pos = this.state = 1;
this.update();
this.options.curAnim[ this.prop ] = true;
var done = true;
for ( var i in this.options.curAnim )
if ( this.options.curAnim[i] !== true )
done = false;
if ( done ) {
if ( this.options.display != null ) {

this.elem.style.overflow = this.options.overflow;

this.elem.style.display = this.options.display;
if ( jQuery.css(this.elem, "display") == "none" )
this.elem.style.display = "block";
}

if ( this.options.hide )
this.elem.style.display = "none";

if ( this.options.hide || this.options.show )
for ( var p in this.options.curAnim )
jQuery.attr(this.elem.style, p, this.options.orig[p]);
}

if ( done && jQuery.isFunction( this.options.complete ) )

this.options.complete.apply( this.elem );
return false;
} else {
var n = t - this.startTime;
this.state = n / this.options.duration;

this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration);
this.now = this.start + ((this.end - this.start) * this.pos);

this.update();
}
return true;
}
};
jQuery.fx.step = {
scrollLeft: function(fx){
fx.elem.scrollLeft = fx.now;
},
scrollTop: function(fx){
fx.elem.scrollTop = fx.now;
},
opacity: function(fx){
jQuery.attr(fx.elem.style, "opacity", fx.now);
},
_default: function(fx){
fx.elem.style[ fx.prop ] = fx.now + fx.unit;
}
};



jQuery.fn.offset = function() {
var left = 0, top = 0, elem = this[0], results;
if ( elem ) with ( jQuery.browser ) {
var	absolute     = jQuery.css(elem, "position") == "absolute", 
parent       = elem.parentNode, 
offsetParent = elem.offsetParent, 
doc          = elem.ownerDocument,
safari2      = safari && parseInt(version) < 522;

if ( elem.getBoundingClientRect ) {
box = elem.getBoundingClientRect();

add(
box.left + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
box.top  + Math.max(doc.documentElement.scrollTop,  doc.body.scrollTop)
);



if ( msie ) {
var border = jQuery("html").css("borderWidth");
border = (border == "medium" || jQuery.boxModel && parseInt(version) >= 7) && 2 || border;
add( -border, -border );
}

} else {

add( elem.offsetLeft, elem.offsetTop );

while ( offsetParent ) {

add( offsetParent.offsetLeft, offsetParent.offsetTop );


if ( mozilla && /^t[d|h]$/i.test(parent.tagName) || !safari2 )
border( offsetParent );

if ( safari2 && !absolute && jQuery.css(offsetParent, "position") == "absolute" )
absolute = true;

offsetParent = offsetParent.offsetParent;
}

while ( parent.tagName && !/^body|html$/i.test(parent.tagName) ) {

if ( !/^inline|table-row.*$/i.test(jQuery.css(parent, "display")) )

add( -parent.scrollLeft, -parent.scrollTop );

if ( mozilla && jQuery.css(parent, "overflow") != "visible" )
border( parent );

parent = parent.parentNode;
}

if ( safari2 && absolute )
add( -doc.body.offsetLeft, -doc.body.offsetTop );
}

results = { top: top, left: left };
}
return results;
function border(elem) {
add( jQuery.css(elem, "borderLeftWidth"), jQuery.css(elem, "borderTopWidth") );
}
function add(l, t) {
left += parseInt(l) || 0;
top += parseInt(t) || 0;
}
};
})();

/**
* jQuery jqGalViewII Plugin
* Examples and documentation at: http://benjaminsterling.com/2007/10/02/jquery-jqgalviewii-photo-gallery/
*
* @author: Benjamin Sterling
* @version: 0.5
* @copyright (c) 2007 Benjamin Sterling, KenzoMedia
*
* Dual licensed under the MIT and GPL licenses:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html
*   
* @requires jQuery v1.2.1 or later
* 
* 
* @name jqGalViewII
* @example $('ul').jqGalViewII();
* 
* @Semantic requirements:
* 				The structure fairly simple and should be unobtrusive, you
* 				basically only need a parent container with a list of imgs
* 
* 	<ul>
*		<li><img src="common/img/dsc_0003.thumbnail.JPG"/></li>
*		<li><img src="common/img/dsc_0012.thumbnail.JPG"/></li>
*	</ul>
*
*  -: or :-
* 
* <div>
* 		<img src="common/img/dsc_0003.thumbnail.JPG"/>
* 		<img src="common/img/dsc_0012.thumbnail.JPG"/>
* </div>
* 
* @param Integer getUrlBy
* 					By default, it is set to 0 (zero) and the plugin will
* 					get the url of the full size img from the images 
* 					parent A tag, or you can set it to 1 will and provide
* 					the fullSizePath param with the path to the full size
* 					images.  Finally, you can set it to 2 and provide text
* 					to prefix param and have that prefix removed from the
* 					src tag of the thumbnail to create the path to the
* 					full sized image
* 
* @example $('#gallery').jqGalViewII({getUrlBy:1,fullSizePath:'fullPath/to/fullsize/folder'});
* 
* @example $('#gallery').jqGalViewII({getUrlBy:2, prefix:'.tn'});
* 					".tn" gets removed from the src attribute of your image
* 
* @param String fullSizePath
* 					Set to null by default, but if you are going to set
* 					getUrlBy param to 1, you need to provide the full path
* 					to the full size image.
* 
* @example $('#gallery').jqGalViewII({getUrlBy:1,fullSizePath:'fullPath/to/fullsize/folder'});
* 
* @param String prefix
* 					Set to null by default, but if you are going to set
* 					getUrlBy param to 2, you need to provide text you
* 					want to remove from the src attribute of the thumbnail
* 					to get create the full size image name
* 
* @example $('ul').jqGalViewII({getUrlBy:2, prefix:'.tn'});
* 					".tn" gets removed from the src attribute of your image
* 
* @styleClasses
* 		gvIIContainer:  overall holder of thumbnails and gvIIHolder div, the
* 						gvIILoader div and the gvIIImgContainer div
* 		gvIIHolder: contains the thumbnails divs
*		gvIIItem: contains the thumbnail img, the gvLoaderMini div and the gvOpen div
*		gvIILoaderMini :empty but styled with a loader images as background image.
* 		gvIIImgContainer: the full size image container and the gvDescText div
* 		gvIILoader: empty but styled with a loader images as background image.
* 
* 
* changes:
*
*/
(function($){
$.fn.jqGalViewII = function(options){
return this.each(function(index){
var el = this, $_ = $(this); $img = $('img', $_);
el.opts = $.extend({}, $.fn.jqGalViewII.defaults, options);

var $this = $.fn.jqGalViewII.swapOut($_);
var $container = $('<div class="gvIIContainer">').appendTo($this);
el.mainImgContainer = $('<div class="gvIIImgContainer">').appendTo($container);
el.image = $('<img/>').appendTo(el.mainImgContainer);
el.loader = $('<div class="gvIILoader"/>').appendTo(el.mainImgContainer);

var $holder = $('<div class="gvIIHolder"/>').appendTo($container);
var $arrow = $('<div class="gvIIArrow"/>');
$img.each(function(i){
var $image = $(this);
var $div = $('<div id="gvIIID'+i+'" class="gvIIItem">')
.appendTo($holder)
.append('<div class="gvIILoaderMini">');// end : $div
if(el.opts.getUrlBy == 0)
this.altImg = $image.parent().attr('href');
else if(el.opts.getUrlBy == 1)
this.altImg = el.opts.fullSizePath + this.src.split('/').pop();
else if(el.opts.getUrlBy == 2)
this.altImg = $this.src.replace(el.opts.prefix,'');
this.altTxt = $image.attr('alt');
var image = new Image();
image.onload = function(){
image.onload = null;
$div.empty().append($image);
$('<div class="gvIIFlash">').appendTo($div).css({opacity:".01"})
.mouseover(
function(){
var $f = $(this);
$f.css({opacity:".75"}).stop().animate({opacity:".01"},500);
/*

var offSet = $f.offset();
var osLeft = offSet.left + ($f.width()/2);
var osTop = offSet.top;
$arrow.stop().animate({left:osLeft,top:osTop}, 100, el.opts.arrowEase);
*/
}
)
.click(
function(){
$image.trigger('click');
}
);
$image.click(function(){
$.fn.jqGalViewII.view(this,el);		   
});
if(i==0){
$image.trigger('click');
$image.siblings().trigger('mouseover');
}
};// end : image.onload 
image.src = this.src;
});
$arrow.appendTo($holder);

$(this).after($this).remove();
});
};
$.fn.jqGalViewII.view = function(img,el){
if(typeof img.altImg == 'undefined') return false;
var url = /\?imgmax/.test(img.altImg) ? img.altImg : img.altImg+'?imgmax=800';
var $i_wh = {}; // 
var $i_whFinal = {}; // 
var wContainer, hContainer;
var $w, $h, $wOrg, $hOrg, isOver = false; 
el.loader.show();
wContainer = el.mainImgContainer.width();
hContainer = el.mainImgContainer.height();
el.mainImgContainer.show();
el.image.attr({src:url}).css({top:0,left:0,position:'absolute'}).hide();
$img = new Image();
$img.onload = function(){
$img.onload = null;
$w = $wOrg = $img.width;
$h = $hOrg = $img.height;
if ($w > wContainer) {
$h = $h * (wContainer / $w); 
$w = wContainer; 
if ($h > wContainer) { 
$w = $w * (hContainer / $h); 
$h = hContainer; 
}
} else if ($h > hContainer) { 
$w = $w * (hContainer / $h); 
$h = hContainer; 
if ($w > wContainer) { 
$h = $h * (wContainer / $w); 
$w = wContainer;
}
}
el.image.css({width:$w,height:$h, marginLeft:(wContainer-$w)*.5,marginTop:(hContainer-$h)*.5})
el.loader.fadeOut('fast',function(){el.image.fadeIn();});
};
$img.src = url;
};
$.fn.jqGalViewII.swapOut = function($el){
var id = $el.attr('id') ? (' id="'+$el.attr('id')+'"') : '';
var $this = $('<div' + id + '>');
return $this;
};
$.fn.jqGalViewII.defaults = {
getUrlBy : 0, // 0 == from parent A tag | 1 == the full size resides in another folder
fullSizePath : null,
prefix: 'thumbnail.',
arrowEase:'easeout'
};
})(jQuery);









var $j = jQuery.noConflict();
Class.extend(PopupCarPhotoDisplay, GuiPopupGeneric);
function PopupCarPhotoDisplay(html, comment) {
PopupCarPhotoDisplay.baseConstructor.call(this);
this._html = html;
this._comment = comment;
}
PopupCarPhotoDisplay.prototype.show = function() {
GuiPopupGeneric.prototype.show.call(this);
var list = $j("ul#photo_list");
list.jqGalViewII();
}
PopupCarPhotoDisplay.prototype.setup = function(block) {
var div = document.createElement("div");
if (this._comment) {
div.innerHTML = "<p style=\"width: 639px;\">" + this._comment + "</p>" + this._html; 
} else {
div.innerHTML = this._html; 
};
div.className = "car_popup";
div.id = "car_popup";
var close = document.createElement("span");
close.className = "car_popup_close";
close.innerHTML = "Close [X]";
var closeComment = document.createElement("div")
closeComment.className = "car_popup_close_comment";
closeComment.innerHTML = "Click here to close the window";
block.appendChild(close);
block.appendChild(div);
block.appendChild(closeComment);
var _this = this;
[close, closeComment].each(function(el) { 
addEvent(el, "click", function(e) { _this.hide() }); 
});
}




XMLRPC._ajaxErrorHandler = function(text) { return true; }
page.m.addRatingBlock = function(providerId) {
var ratingBg = $('rating_bg_'+providerId);
var ratingHover = $('rating_hover_'+providerId);
var ratingActual = $('rating_actual_'+providerId);
[ratingBg, ratingHover, ratingActual].each(function(item, index) { 
addEvent(item, "mousemove", function(e) {
var cur = getPosition(e);
var offset = cur.x - getLeft(ratingBg);
var ratingInt = Math.ceil(offset / 23);
ratingHover.className = "rating_hover " + "rating_" + ratingInt.toString();
});
});
addEvent(ratingBg, "click", function(e) {
var cur = getPosition(e);
var offset = cur.x - getLeft(ratingBg);
var ratingInt = Math.ceil(offset / 23);
XMLRPC.call(Links.xmlrpc(),
page.c.onProviderRateSuccess,
page.c.onProviderRateFailure, 
page.c.onProviderRateFailure, 
'provider.rate',
[providerId, ratingInt*2]);
});
addEvent(ratingBg, "mouseout", function(e) {
ratingHover.className = "rating_hover";
});
}
page.c.onProviderRateSuccess = function(response) {
if (!response.param) { 
alert("You've already voted for a provider in last 24 hours.");
return;
};
var providerId = response.param.id;
var rating = response.param.rating;
var ratingActual = $('rating_actual_'+providerId);
ratingActual.className = "rating_actual rating_" + Math.round(rating/2).toString();
alert("Thank you for your feedback. Your vote has been accepted");
}
page.c.onProviderRateFailure = function(response) {
alert("There was an error submitting your vote.\nPlease try again later");
};


















XMLRPC._ajaxErrorHandler = function(text) { return true; }
page.m.quotePopup = null;
page.m.map = null;
page.m.provider = { 
longitude: null,
latitude: null,
name: null,
id: null
};
page.m.reviews = [];
page.m._captchaId = null;
page.m._photos = [];
page.m.addPhoto = function(carId) {
page.m._photos.push({ id: carId });
};

page.v.hideCarSlideshow = function() {
$('car_photos_wrapper_slideshow').style.display = 'none';
};
page.v.hideCarThumbnails = function() {
$('car_photos_wrapper_thumbnails').style.display = 'none';
};
page.v.showCarSlideshow = function() {
$('car_photos_wrapper_slideshow').style.display = 'block';
};
page.v.showCarThumbnails = function() {
$('car_photos_wrapper_thumbnails').style.display = 'block';
};
page.v.updateCaptcha = function() {
page.m._captchaId = new Date().getTime();
$("quote_request_simple_form_captcha_code_image").src = Links.action('captcha', {id: page.m._captchaId});
};

page.c.addOnLoadHandler(function(env) {

page.m._photos.each(function(photo) {
var linkElementId = sprintf("car_photo_%s", photo.id);
var linkElement = $(linkElementId);
addEvent(linkElement, "click", function(e) { page.c.onPhotoClick(e, photo.id); });
var linkElementId = sprintf("car_thumbnail_%s", photo.id);
var linkElement = $(linkElementId);
addEvent(linkElement, "click", function(e) { page.c.onPhotoClick(e, photo.id); });
});

if (GBrowserIsCompatible()) {
var provider = page.m.provider;
var icon = new GIcon();
icon.image = Links.image("map_marker.png");
icon.shadow = Links.image("map_marker_shadow.png");
icon.iconSize = new GSize(32, 32);
icon.shadowSize = new GSize(32, 32);
icon.iconAnchor = new GPoint(16, 28);
icon.infoWindowAnchor = new GPoint(16, 28);
var marker = new GMarker(new GLatLng(provider.latitude, provider.longitude), icon);
page.m.map = new GMap2($("location_map"));
page.m.map.setCenter(new GLatLng(provider.latitude, provider.longitude), 13);
page.m.map.addControl(new GSmallMapControl());
page.m.map.addControl(new GMapTypeControl());
page.m.map.addOverlay(marker);
var infoHtml = sprintf('<p><b>%s</b></p><p>%s %s %s</p>', provider.name, provider.building, provider.street, provider.office);
marker.openInfoWindowHtml(infoHtml);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(infoHtml);
});
};

page.m.reviews.each(function(review) {
var link = $('link-review-' + review.id.toString());
if (link) {
addEvent(link, "click", page.c.makeReviewLinkCallback(link, review));
};
}); 

if ($('car_photos_scroll_data')) {
$('car_photos').style.width = $('car_photos').parentNode.scrollWidth.toString() + 'px';
var autoscroll = new Autoscroll($('car_photos'), $('car_photos_scroll'), $('car_photos_scroll_data'));
addEvent($('car_photos'), 'mouseover', function() { autoscroll.stop(); });
addEvent($('car_photos'), 'mouseout', function() { autoscroll.step(); });
autoscroll.run();
};

if ($("link_car_list_mode_hide")) {
var sw = new GuiSwitch(["link_car_list_mode_hide", "link_car_list_mode_slideshow", "link_car_list_mode_thumbnail"].map($), 
GuiSwitch.makeDispatcher([page.c.onCarParkModeHideClick, 
page.c.onCarParkModeSlideshowClick, 
page.c.onCarParkModeThumbnailsClick]));
};

env.m.setupQuotePopup = function() {
var quotePopup = new GuiPopupGeneric();
page.m.quotePopup = quotePopup;
quotePopup.setup = function(popup) {
$("quote_request_content").style.display = "block";
popup.appendChild($("quote_request_content"));
};
addEvent($("quote_request_button"), "click", function(e) {
cancelEvent(e);
quotePopup.show();
correctPNGNode($("quote_request_form_close_img"));
});
addEvent($("quote_request_form_close"), "click", function(e) {
cancelEvent(e);
quotePopup.hide();
});
page.getForm("quote_request_simple_form").addValidatedHandler(page.c.onQuoteRequestSimpleFormValidated);
page.v.updateCaptcha();
};
$("quote_request_button") && env.m.setupQuotePopup();
});
page.c.makeReviewLinkCallback = function(link, review) {
return function(e) {
cancelEvent(e);
var text = $('review-text-' + review.id.toString());
if (review.visible) {
link.innerHTML = "Show full text";
text.innerHTML = review.textShort;
} else { 
var updateCallback = function(response) {
link.innerHTML = "Hide full text";
if (!review.textShort) {
review.textShort = text.innerHTML;
};
text.innerHTML = response.param.text;
review.text = response.param.text;
};
if (review.text) {
updateCallback({ param: { text: review.text } });
} else {
XMLRPC.call(Links.xmlrpc(), updateCallback, null, null, 'find.review', [review.id]);
};
};
review.visible = !review.visible;
};
};
page.c.onCarParkModeHideClick = function(e) {
page.v.hideCarSlideshow();
page.v.hideCarThumbnails();
};
page.c.onCarParkModeSlideshowClick = function(e) {
page.v.hideCarSlideshow();
page.v.hideCarThumbnails();
page.v.showCarSlideshow();
};
page.c.onCarParkModeThumbnailsClick = function(e) {
page.v.hideCarSlideshow();
page.v.hideCarThumbnails();
page.v.showCarThumbnails();
};
page.c.onPhotoClick = function(e, carPhotoId) {
XMLRPC.call(Links.xmlrpc(), page.c.onPhotoClickResponse, null, null,
'html.view.car.photo', [carPhotoId, page.m._providerId]);
cancelEvent(e);
}
page.c.onPhotoClickResponse = function(response) {
if (!response.isError()) {
var popup = new PopupCarPhotoDisplay(response.param.html);
popup.show();
};
}
page.c.onQuoteRequestSimpleFormValidated = function(e) {
cancelEvent(e);
var call = {
method: "request.quote.simple",
params: [$F("quote_request_simple_form_first_name"),
$F("quote_request_simple_form_last_name"),
$F("quote_request_simple_form_email"),
$F("quote_request_simple_form_phone"),
$FD("quote_request_simple_form_date"),
$FM("quote_request_simple_form_car"),
$F("quote_request_simple_form_enquiry"),
$F("quote_request_simple_form_service"),
$F("quote_request_simple_form_pickup"),
$F("quote_request_simple_form_arrival"),
$("quote_request_simple_form_round_trip").checked,
page.m._providerId]
};
XMLRPC.call(Links.xmlrpc(),
function(response) { 
page.v.updateCaptcha();
if (!response.isError()) {
alert(sprintf("Thank you, your quote request has been delivered to %s", page.m._providerName)); 
page.m.quotePopup.hide();                 
} else {
alert(response.getMessage()); 
};
},
null, null,
"captcha.check",
[page.m._captchaId, $F("quote_request_simple_form_captcha_code"), call]);
};
page.c.onUnload = function(e) {
GUnload();
};






page.m.getDeleteFormId = function() {
if (!page.m._deleteFormId) {
var id = document.createElement("input");
id.type = "hidden";
id.name = "id";
id.value = 0;
page.m._deleteFormId =  id;
};
return page.m._deleteFormId;
}
page.m.getDeleteForm = function() {
if (!page.m._deleteForm) {
var form = document.createElement("form");
form.action = Links.controller();
form.method = "post";
var action = document.createElement("input");
action.type = "hidden";
action.name = "a";
action.value = page.m.actionPrefix + page.m.metaclass + ".delete"; 
form.appendChild(action);
var ret = document.createElement("input");
ret.type = "hidden";
ret.name = "return";
ret.value = Links.action(page.m.actionPrefix + page.m.metaclass + ".list"); 
form.appendChild(ret);
var submit = document.createElement("input");
submit.type = "hidden";
submit.name = "delete";
submit.value = "1";
form.appendChild(submit);
form.appendChild(page.m.getDeleteFormId());
document.body.appendChild(form);
page.m._deleteForm = form;
};
return page.m._deleteForm;
}
page.c.addOnLoadHandler(function(env) {
var eLink = $("link_delete");
if (eLink) {
addEvent(eLink, "click", page.c.onDeleteLinkClick);
};
})
page.c.onDeleteLinkClick = function(e) {

cancelEvent(e);
if (!confirm(_("Delete this item?"))) {
return;
};
var deleteFormId = page.m.getDeleteFormId();
deleteFormId.value = page.m.objectId;
var deleteForm = page.m.getDeleteForm();
deleteForm.submit();
}
var System = new Object();
System.isIE = function(v1, v2) {
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
return ((v1 == null || version > v1) && 
(v2 == null || version < v2) && 
document.body.filters);
}
System.needHoverHack = function() {
return System.isIE(5.5, 7.0);
}
System.needRoundedCornersHack = function() {
return System.isIE(5.5, 7.0);
}
System.hasDisplayTable = function() {
return !System.isIE(null, 8.0);
}





page.m.quoteRequest = {};
page.c.quoteRequest = {};
page.v.quoteRequest = {};
page.m.quoteRequest._serviceTypes = [];
page.m.quoteRequest.addServiceType = function(id, name, mode) {
page.m.quoteRequest._serviceTypes[id] = { id: id, name:name, mode: mode };
}
page.c.addOnLoadHandler(function(e) {
if ($("quote_request_simple_form_service")) {
addEvent($("quote_request_simple_form_service"), "change", page.c.quoteRequest.onServiceChange);
addEvent($("quote_request_simple_form_round_trip"), "click", page.c.quoteRequest.onRoundTripClick);
};
});
page.c.quoteRequest.onRoundTripClick = function(e) {
page.v.quoteRequest.refreshServiceTypeModeFields();
}
page.c.quoteRequest.onServiceChange = function(e) {
page.v.quoteRequest.refreshServiceTypeModeFields();
}
page.v.quoteRequest.refreshServiceTypeModeFields = function() {
$("table_round_trip").style.display = "none";
$("table_pickup").style.display = "none";
$("table_arrival").style.display = "none";
var type = page.m.quoteRequest._serviceTypes[$F("quote_request_simple_form_service")];
if (!type) {
return;
};
switch (type.mode) {
case 1: // SERVICE_TYPE_MODE_TRANSFER
$("table_round_trip").style.display = System.hasDisplayTable() ? "table" : "block";
$("table_pickup").style.display = System.hasDisplayTable() ? "table" : "block";
if ($("quote_request_simple_form_round_trip").checked) {
$("table_arrival").style.display = System.hasDisplayTable() ? "table" : "block";
} else {
$("table_arrival").style.display = "none";
};
break;
case 2: // SERVICE_TYPE_MODE_HOURLY_SERVICE
default:
$("table_pickup").style.display = System.hasDisplayTable() ? "table" : "block";
$("table_arrival").style.display = System.hasDisplayTable() ? "table" : "block";
break;
};
}



Validators.emailValidate = function(value) {
return value.match(/^[a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$/i);
}
Validators.email = function(element, messages) {


if (element.value == '') {
return true;
};
if (!this.emailValidate(element.value)) {
this.handleError(element, messages.invalid_email);
return false;
};
return true;
}


InputFilterTrim.prototype = new Object();
InputFilterTrim.prototype.apply = InputFilterTrim_apply;
function InputFilterTrim() {
}
function InputFilterTrim_apply(value) {
return value.trim();
}

Filter.prototype = new Object();
function Filter() {
}


Validators.string_regexp = function(element, regexp, messages) {


if (element.value == '') {
return true;
};
if (!messages) {
messages = {};
};
if (!messages.no_match) {
messages.no_match = messages.generic ? messages.generic : _("Incorrect value format");
};
if (!element.value.match(regexp)) {
this.handleError(element, messages.no_match);
return false;
}
return true;
};





Validators.date_future = function(base_element_id, messages) {
var date = new Date();
var baseDate = new Date(date);
date.setFullYear($F(base_element_id + '_yy'));
date.setMonth($F(base_element_id + '_mm') - 1);
date.setDate($F(base_element_id + '_dd'));
if (date < baseDate) {
this.handleError($(base_element_id + '_yy'), messages.date_future);
return false;
};
return true;
}


Calendar = function (firstDayOfWeek, dateStr, onSelected, onClose) {
this.activeDiv = null;
this.currentDateEl = null;
this.getDateStatus = null;
this.getDateToolTip = null;
this.getDateText = null;
this.timeout = null;
this.onSelected = onSelected || null;
this.onClose = onClose || null;
this.dragging = false;
this.hidden = false;
this.minYear = 1970;
this.maxYear = 2050;
this.dateFormat = Calendar._TT["DEF_DATE_FORMAT"];
this.ttDateFormat = Calendar._TT["TT_DATE_FORMAT"];
this.weekNumbers = true;
this.firstDayOfWeek = typeof firstDayOfWeek == "number" ? firstDayOfWeek : Calendar._FD; // 0 for Sunday, 1 for Monday, etc.
this.showsOtherMonths = false;
this.dateStr = dateStr;
this.ar_days = null;
this.showsTime = false;
this.time24 = true;
this.yearStep = 2;
this.hiliteToday = true;
this.multiple = null;

this.table = null;
this.element = null;
this.tbody = null;
this.firstdayname = null;

this.monthsCombo = null;
this.yearsCombo = null;
this.hilitedMonth = null;
this.activeMonth = null;
this.hilitedYear = null;
this.activeYear = null;

this.dateClicked = false;

if (typeof Calendar._SDN == "undefined") {

if (typeof Calendar._SDN_len == "undefined")
Calendar._SDN_len = 3;
var ar = new Array();
for (var i = 8; i > 0;) {
ar[--i] = Calendar._DN[i].substr(0, Calendar._SDN_len);
}
Calendar._SDN = ar;

if (typeof Calendar._SMN_len == "undefined")
Calendar._SMN_len = 3;
ar = new Array();
for (var i = 12; i > 0;) {
ar[--i] = Calendar._MN[i].substr(0, Calendar._SMN_len);
}
Calendar._SMN = ar;
}
};


Calendar._C = null;

Calendar.is_ie = ( /msie/i.test(navigator.userAgent) &&
!/opera/i.test(navigator.userAgent) );
Calendar.is_ie5 = ( Calendar.is_ie && /msie 5\.0/i.test(navigator.userAgent) );

Calendar.is_opera = /opera/i.test(navigator.userAgent);

Calendar.is_khtml = /Konqueror|Safari|KHTML/i.test(navigator.userAgent);


Calendar.isRelated = function (el, evt) {
var related = evt.relatedTarget;
if (!related) {
var type = evt.type;
if (type == "mouseover") {
related = evt.fromElement;
} else if (type == "mouseout") {
related = evt.toElement;
}
}
while (related) {
if (related == el) {
return true;
}
related = related.parentNode;
}
return false;
};
Calendar.removeClass = function(el, className) {
if (!(el && el.className)) {
return;
}
var cls = el.className.split(" ");
var ar = new Array();
for (var i = cls.length; i > 0;) {
if (cls[--i] != className) {
ar[ar.length] = cls[i];
}
}
el.className = ar.join(" ");
};
Calendar.addClass = function(el, className) {
Calendar.removeClass(el, className);
el.className += " " + className;
};

Calendar.getElement = function(ev) {
var f = Calendar.is_ie ? window.event.srcElement : ev.currentTarget;
while (f.nodeType != 1 || /^div$/i.test(f.tagName))
f = f.parentNode;
return f;
};
Calendar.getTargetElement = function(ev) {
var f = Calendar.is_ie ? window.event.srcElement : ev.target;
while (f.nodeType != 1)
f = f.parentNode;
return f;
};
Calendar.stopEvent = function(ev) {
ev || (ev = window.event);
if (Calendar.is_ie) {
ev.cancelBubble = true;
ev.returnValue = false;
} else {
ev.preventDefault();
ev.stopPropagation();
}
return false;
};
Calendar.addEvent = function(el, evname, func) {
if (el.attachEvent) { // IE
el.attachEvent("on" + evname, func);
} else if (el.addEventListener) { // Gecko / W3C
el.addEventListener(evname, func, true);
} else {
el["on" + evname] = func;
}
};
Calendar.removeEvent = function(el, evname, func) {
if (el.detachEvent) { // IE
el.detachEvent("on" + evname, func);
} else if (el.removeEventListener) { // Gecko / W3C
el.removeEventListener(evname, func, true);
} else {
el["on" + evname] = null;
}
};
Calendar.createElement = function(type, parent) {
var el = null;
if (document.createElementNS) {


el = document.createElementNS("http://www.w3.org/1999/xhtml", type);
} else {
el = document.createElement(type);
}
if (typeof parent != "undefined") {
parent.appendChild(el);
}
return el;
};


/** Internal -- adds a set of events to make some element behave like a button. */
Calendar._add_evs = function(el) {
with (Calendar) {
addEvent(el, "mouseover", dayMouseOver);
addEvent(el, "mousedown", dayMouseDown);
addEvent(el, "mouseout", dayMouseOut);
if (is_ie) {
addEvent(el, "dblclick", dayMouseDblClick);
el.setAttribute("unselectable", true);
}
}
};
Calendar.findMonth = function(el) {
if (typeof el.month != "undefined") {
return el;
} else if (typeof el.parentNode.month != "undefined") {
return el.parentNode;
}
return null;
};
Calendar.findYear = function(el) {
if (typeof el.year != "undefined") {
return el;
} else if (typeof el.parentNode.year != "undefined") {
return el.parentNode;
}
return null;
};
Calendar.showMonthsCombo = function () {
var cal = Calendar._C;
if (!cal) {
return false;
}
var cal = cal;
var cd = cal.activeDiv;
var mc = cal.monthsCombo;
if (cal.hilitedMonth) {
Calendar.removeClass(cal.hilitedMonth, "hilite");
}
if (cal.activeMonth) {
Calendar.removeClass(cal.activeMonth, "active");
}
var mon = cal.monthsCombo.getElementsByTagName("div")[cal.date.getMonth()];
Calendar.addClass(mon, "active");
cal.activeMonth = mon;
var s = mc.style;
s.display = "block";
if (cd.navtype < 0)
s.left = cd.offsetLeft + "px";
else {
var mcw = mc.offsetWidth;
if (typeof mcw == "undefined")

mcw = 50;
s.left = (cd.offsetLeft + cd.offsetWidth - mcw) + "px";
}
s.top = (cd.offsetTop + cd.offsetHeight) + "px";
};
Calendar.showYearsCombo = function (fwd) {
var cal = Calendar._C;
if (!cal) {
return false;
}
var cal = cal;
var cd = cal.activeDiv;
var yc = cal.yearsCombo;
if (cal.hilitedYear) {
Calendar.removeClass(cal.hilitedYear, "hilite");
}
if (cal.activeYear) {
Calendar.removeClass(cal.activeYear, "active");
}
cal.activeYear = null;
var Y = cal.date.getFullYear() + (fwd ? 1 : -1);
var yr = yc.firstChild;
var show = false;
for (var i = 12; i > 0; --i) {
if (Y >= cal.minYear && Y <= cal.maxYear) {
yr.innerHTML = Y;
yr.year = Y;
yr.style.display = "block";
show = true;
} else {
yr.style.display = "none";
}
yr = yr.nextSibling;
Y += fwd ? cal.yearStep : -cal.yearStep;
}
if (show) {
var s = yc.style;
s.display = "block";
if (cd.navtype < 0)
s.left = cd.offsetLeft + "px";
else {
var ycw = yc.offsetWidth;
if (typeof ycw == "undefined")

ycw = 50;
s.left = (cd.offsetLeft + cd.offsetWidth - ycw) + "px";
}
s.top = (cd.offsetTop + cd.offsetHeight) + "px";
}
};

Calendar.tableMouseUp = function(ev) {
var cal = Calendar._C;
if (!cal) {
return false;
}
if (cal.timeout) {
clearTimeout(cal.timeout);
}
var el = cal.activeDiv;
if (!el) {
return false;
}
var target = Calendar.getTargetElement(ev);
ev || (ev = window.event);
Calendar.removeClass(el, "active");
if (target == el || target.parentNode == el) {
Calendar.cellClick(el, ev);
}
var mon = Calendar.findMonth(target);
var date = null;
if (mon) {
date = new Date(cal.date);
if (mon.month != date.getMonth()) {
date.setMonth(mon.month);
cal.setDate(date);
cal.dateClicked = false;
cal.callHandler();
}
} else {
var year = Calendar.findYear(target);
if (year) {
date = new Date(cal.date);
if (year.year != date.getFullYear()) {
date.setFullYear(year.year);
cal.setDate(date);
cal.dateClicked = false;
cal.callHandler();
}
}
}
with (Calendar) {
removeEvent(document, "mouseup", tableMouseUp);
removeEvent(document, "mouseover", tableMouseOver);
removeEvent(document, "mousemove", tableMouseOver);
cal._hideCombos();
_C = null;
return stopEvent(ev);
}
};
Calendar.tableMouseOver = function (ev) {
var cal = Calendar._C;
if (!cal) {
return;
}
var el = cal.activeDiv;
var target = Calendar.getTargetElement(ev);
if (target == el || target.parentNode == el) {
Calendar.addClass(el, "hilite active");
Calendar.addClass(el.parentNode, "rowhilite");
} else {
if (typeof el.navtype == "undefined" || (el.navtype != 50 && (el.navtype == 0 || Math.abs(el.navtype) > 2)))
Calendar.removeClass(el, "active");
Calendar.removeClass(el, "hilite");
Calendar.removeClass(el.parentNode, "rowhilite");
}
ev || (ev = window.event);
if (el.navtype == 50 && target != el) {
var pos = { x: getLeft(el) };
var w = el.offsetWidth;
var x = ev.clientX;
var dx;
var decrease = true;
if (x > pos.x + w) {
dx = x - pos.x - w;
decrease = false;
} else
dx = pos.x - x;
if (dx < 0) dx = 0;
var range = el._range;
var current = el._current;
var count = Math.floor(dx / 10) % range.length;
for (var i = range.length; --i >= 0;)
if (range[i] == current)
break;
while (count-- > 0)
if (decrease) {
if (--i < 0)
i = range.length - 1;
} else if ( ++i >= range.length )
i = 0;
var newval = range[i];
el.innerHTML = newval;
cal.onUpdateTime();
}
var mon = Calendar.findMonth(target);
if (mon) {
if (mon.month != cal.date.getMonth()) {
if (cal.hilitedMonth) {
Calendar.removeClass(cal.hilitedMonth, "hilite");
}
Calendar.addClass(mon, "hilite");
cal.hilitedMonth = mon;
} else if (cal.hilitedMonth) {
Calendar.removeClass(cal.hilitedMonth, "hilite");
}
} else {
if (cal.hilitedMonth) {
Calendar.removeClass(cal.hilitedMonth, "hilite");
}
var year = Calendar.findYear(target);
if (year) {
if (year.year != cal.date.getFullYear()) {
if (cal.hilitedYear) {
Calendar.removeClass(cal.hilitedYear, "hilite");
}
Calendar.addClass(year, "hilite");
cal.hilitedYear = year;
} else if (cal.hilitedYear) {
Calendar.removeClass(cal.hilitedYear, "hilite");
}
} else if (cal.hilitedYear) {
Calendar.removeClass(cal.hilitedYear, "hilite");
}
}
return Calendar.stopEvent(ev);
};
Calendar.tableMouseDown = function (ev) {
if (Calendar.getTargetElement(ev) == Calendar.getElement(ev)) {
return Calendar.stopEvent(ev);
}
};
Calendar.calDragIt = function (ev) {
var cal = Calendar._C;
if (!(cal && cal.dragging)) {
return false;
}
var posX;
var posY;
if (Calendar.is_ie) {
posY = window.event.clientY + document.body.scrollTop;
posX = window.event.clientX + document.body.scrollLeft;
} else {
posX = ev.pageX;
posY = ev.pageY;
}
cal.hideShowCovered();
var st = cal.element.style;
st.left = (posX - cal.xOffs) + "px";
st.top = (posY - cal.yOffs) + "px";
return Calendar.stopEvent(ev);
};
Calendar.calDragEnd = function (ev) {
var cal = Calendar._C;
if (!cal) {
return false;
}
cal.dragging = false;
with (Calendar) {
removeEvent(document, "mousemove", calDragIt);
removeEvent(document, "mouseup", calDragEnd);
tableMouseUp(ev);
}
cal.hideShowCovered();
};
Calendar.dayMouseDown = function(ev) {
var el = Calendar.getElement(ev);
if (el.disabled) {
return false;
}
var cal = el.calendar;
cal.activeDiv = el;
Calendar._C = cal;
if (el.navtype != 300) with (Calendar) {
if (el.navtype == 50) {
el._current = el.innerHTML;
addEvent(document, "mousemove", tableMouseOver);
} else
addEvent(document, Calendar.is_ie5 ? "mousemove" : "mouseover", tableMouseOver);
addClass(el, "hilite active");
addEvent(document, "mouseup", tableMouseUp);
} else {
cal._dragStart(ev);
}
if (el.navtype == -1 || el.navtype == 1) {
if (cal.timeout) clearTimeout(cal.timeout);
cal.timeout = setTimeout("Calendar.showMonthsCombo()", 250);
} else if (el.navtype == -2 || el.navtype == 2) {
if (cal.timeout) clearTimeout(cal.timeout);
cal.timeout = setTimeout((el.navtype > 0) ? "Calendar.showYearsCombo(true)" : "Calendar.showYearsCombo(false)", 250);
} else {
cal.timeout = null;
}
return Calendar.stopEvent(ev);
};
Calendar.dayMouseDblClick = function(ev) {
Calendar.cellClick(Calendar.getElement(ev), ev || window.event);
if (Calendar.is_ie) {
document.selection.empty();
}
};
Calendar.dayMouseOver = function(ev) {
var el = Calendar.getElement(ev);
if (Calendar.isRelated(el, ev) || Calendar._C || el.disabled) {
return false;
}
if (el.ttip) {
if (el.ttip.substr(0, 1) == "_") {
el.ttip = el.caldate.print(el.calendar.ttDateFormat) + el.ttip.substr(1);
}
el.calendar.tooltips.innerHTML = el.ttip;
}
if (el.navtype != 300) {
Calendar.addClass(el, "hilite");
if (el.caldate) {
Calendar.addClass(el.parentNode, "rowhilite");
}
}
return Calendar.stopEvent(ev);
};
Calendar.dayMouseOut = function(ev) {
with (Calendar) {
var el = getElement(ev);
if (isRelated(el, ev) || _C || el.disabled)
return false;
removeClass(el, "hilite");
if (el.caldate)
removeClass(el.parentNode, "rowhilite");
if (el.calendar)
el.calendar.tooltips.innerHTML = _TT["SEL_DATE"];
return stopEvent(ev);
}
};
/**
*  A generic "click" handler :) handles all types of buttons defined in this
*  calendar.
*/
Calendar.cellClick = function(el, ev) {
var cal = el.calendar;
var closing = false;
var newdate = false;
var date = null;
if (typeof el.navtype == "undefined") {
if (cal.currentDateEl) {
Calendar.removeClass(cal.currentDateEl, "selected");
Calendar.addClass(el, "selected");
closing = (cal.currentDateEl == el);
if (!closing) {
cal.currentDateEl = el;
}
}
cal.date.setDateOnly(el.caldate);
date = cal.date;
var other_month = !(cal.dateClicked = !el.otherMonth);
if (!other_month && !cal.currentDateEl)
cal._toggleMultipleDate(new Date(date));
else
newdate = !el.disabled;

if (other_month)
cal._init(cal.firstDayOfWeek, date);
} else {
if (el.navtype == 200) {
Calendar.removeClass(el, "hilite");
cal.callCloseHandler();
return;
}
date = new Date(cal.date);
if (el.navtype == 0)
date.setDateOnly(new Date()); // TODAY




cal.dateClicked = false;
var year = date.getFullYear();
var mon = date.getMonth();
function setMonth(m) {
var day = date.getDate();
var max = date.getMonthDays(m);
if (day > max) {
date.setDate(max);
}
date.setMonth(m);
};
switch (el.navtype) {
case 400:
Calendar.removeClass(el, "hilite");
var text = Calendar._TT["ABOUT"];
if (typeof text != "undefined") {
text += cal.showsTime ? Calendar._TT["ABOUT_TIME"] : "";
} else {

text = "Help and about box text is not translated into this language.\n" +
"If you know this language and you feel generous please update\n" +
"the corresponding file in \"lang\" subdir to match calendar-en.js\n" +
"and send it back to <mihai_bazon@yahoo.com> to get it into the distribution  ;-)\n\n" +
"Thank you!\n" +
"http://dynarch.com/mishoo/calendar.epl\n";
}
alert(text);
return;
case -2:
if (year > cal.minYear) {
date.setFullYear(year - 1);
}
break;
case -1:
if (mon > 0) {
setMonth(mon - 1);
} else if (year-- > cal.minYear) {
date.setFullYear(year);
setMonth(11);
}
break;
case 1:
if (mon < 11) {
setMonth(mon + 1);
} else if (year < cal.maxYear) {
date.setFullYear(year + 1);
setMonth(0);
}
break;
case 2:
if (year < cal.maxYear) {
date.setFullYear(year + 1);
}
break;
case 100:
cal.setFirstDayOfWeek(el.fdow);
return;
case 50:
var range = el._range;
var current = el.innerHTML;
for (var i = range.length; --i >= 0;)
if (range[i] == current)
break;
if (ev && ev.shiftKey) {
if (--i < 0)
i = range.length - 1;
} else if ( ++i >= range.length )
i = 0;
var newval = range[i];
el.innerHTML = newval;
cal.onUpdateTime();
return;
case 0:

if ((typeof cal.getDateStatus == "function") &&
cal.getDateStatus(date, date.getFullYear(), date.getMonth(), date.getDate())) {
return false;
}
break;
}
if (!date.equalsTo(cal.date)) {
cal.setDate(date);
newdate = true;
} else if (el.navtype == 0)
newdate = closing = true;
}
if (newdate) {
ev && cal.callHandler();
}
if (closing) {
Calendar.removeClass(el, "hilite");
ev && cal.callCloseHandler();
}
};


/**
*  This function creates the calendar inside the given parent.  If _par is
*  null than it creates a popup calendar inside the BODY element.  If _par is
*  an element, be it BODY, then it creates a non-popup calendar (still
*  hidden).  Some properties need to be set before calling this function.
*/
Calendar.prototype.create = function (_par) {
var parent = _par || document.getElementsByTagName("body")[0];
this.date = this.dateStr ? new Date(this.dateStr) : new Date();
var table = Calendar.createElement("table");
this.table = table;
table.cellSpacing = 0;
table.cellPadding = 0;
table.calendar = this;
Calendar.addEvent(table, "mousedown", Calendar.tableMouseDown);
var div = Calendar.createElement("div");
this.element = div;
div.className = "calendar";
div.style.position = "absolute";
div.style.visibility = "hidden";
div.style.zIndex = 5;
div.appendChild(table);
var thead = Calendar.createElement("thead", table);
var cell = null;
var row = null;
var cal = this;
var hh = function (text, cs, navtype) {
cell = Calendar.createElement("td", row);
cell.colSpan = cs;
cell.className = "button";
if (navtype != 0 && Math.abs(navtype) <= 2)
cell.className += " nav";
Calendar._add_evs(cell);
cell.calendar = cal;
cell.navtype = navtype;
cell.innerHTML = "<div unselectable='on'>" + text + "</div>";
return cell;
};
row = Calendar.createElement("tr", thead);
var title_length = 6;
--title_length;
(this.weekNumbers) && ++title_length;
hh("?", 1, 400).ttip = Calendar._TT["INFO"];
this.title = hh("", title_length, 300);
this.title.className = "title";
this.title.ttip = Calendar._TT["DRAG_TO_MOVE"];
this.title.style.cursor = "move";
hh("&#x00d7;", 1, 200).ttip = Calendar._TT["CLOSE"];
row = Calendar.createElement("tr", thead);
row.className = "headrow";
this._nav_py = hh("&#x00ab;", 1, -2);
this._nav_py.ttip = Calendar._TT["PREV_YEAR"];
this._nav_pm = hh("&#x2039;", 1, -1);
this._nav_pm.ttip = Calendar._TT["PREV_MONTH"];
this._nav_now = hh(Calendar._TT["TODAY"], this.weekNumbers ? 4 : 3, 0);
this._nav_now.ttip = Calendar._TT["GO_TODAY"];
this._nav_nm = hh("&#x203a;", 1, 1);
this._nav_nm.ttip = Calendar._TT["NEXT_MONTH"];
this._nav_ny = hh("&#x00bb;", 1, 2);
this._nav_ny.ttip = Calendar._TT["NEXT_YEAR"];

row = Calendar.createElement("tr", thead);
row.className = "daynames";
if (this.weekNumbers) {
cell = Calendar.createElement("td", row);
cell.className = "name wn";
cell.innerHTML = Calendar._TT["WK"];
}
for (var i = 7; i > 0; --i) {
cell = Calendar.createElement("td", row);
if (!i) {
cell.navtype = 100;
cell.calendar = this;
Calendar._add_evs(cell);
}
}
this.firstdayname = (this.weekNumbers) ? row.firstChild.nextSibling : row.firstChild;
this._displayWeekdays();
var tbody = Calendar.createElement("tbody", table);
this.tbody = tbody;
for (i = 6; i > 0; --i) {
row = Calendar.createElement("tr", tbody);
if (this.weekNumbers) {
cell = Calendar.createElement("td", row);
}
for (var j = 7; j > 0; --j) {
cell = Calendar.createElement("td", row);
cell.calendar = this;
Calendar._add_evs(cell);
}
}
if (this.showsTime) {
row = Calendar.createElement("tr", tbody);
row.className = "time";
cell = Calendar.createElement("td", row);
cell.className = "time";
cell.colSpan = 2;
cell.innerHTML = Calendar._TT["TIME"] || "&nbsp;";
cell = Calendar.createElement("td", row);
cell.className = "time";
cell.colSpan = this.weekNumbers ? 4 : 3;
(function(){
function makeTimePart(className, init, range_start, range_end) {
var part = Calendar.createElement("span", cell);
part.className = className;
part.innerHTML = init;
part.calendar = cal;
part.ttip = Calendar._TT["TIME_PART"];
part.navtype = 50;
part._range = [];
if (typeof range_start != "number")
part._range = range_start;
else {
for (var i = range_start; i <= range_end; ++i) {
var txt;
if (i < 10 && range_end >= 10) txt = '0' + i;
else txt = '' + i;
part._range[part._range.length] = txt;
}
}
Calendar._add_evs(part);
return part;
};
var hrs = cal.date.getHours();
var mins = cal.date.getMinutes();
var t12 = !cal.time24;
var pm = (hrs > 12);
if (t12 && pm) hrs -= 12;
var H = makeTimePart("hour", hrs, t12 ? 1 : 0, t12 ? 12 : 23);
var span = Calendar.createElement("span", cell);
span.innerHTML = ":";
span.className = "colon";
var M = makeTimePart("minute", mins, 0, 59);
var AP = null;
cell = Calendar.createElement("td", row);
cell.className = "time";
cell.colSpan = 2;
if (t12)
AP = makeTimePart("ampm", pm ? "pm" : "am", ["am", "pm"]);
else
cell.innerHTML = "&nbsp;";
cal.onSetTime = function() {
var pm, hrs = this.date.getHours(),
mins = this.date.getMinutes();
if (t12) {
pm = (hrs >= 12);
if (pm) hrs -= 12;
if (hrs == 0) hrs = 12;
AP.innerHTML = pm ? "pm" : "am";
}
H.innerHTML = (hrs < 10) ? ("0" + hrs) : hrs;
M.innerHTML = (mins < 10) ? ("0" + mins) : mins;
};
cal.onUpdateTime = function() {
var date = this.date;
var h = parseInt(H.innerHTML, 10);
if (t12) {
if (/pm/i.test(AP.innerHTML) && h < 12)
h += 12;
else if (/am/i.test(AP.innerHTML) && h == 12)
h = 0;
}
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
date.setHours(h);
date.setMinutes(parseInt(M.innerHTML, 10));
date.setFullYear(y);
date.setMonth(m);
date.setDate(d);
this.dateClicked = false;
this.callHandler();
};
})();
} else {
this.onSetTime = this.onUpdateTime = function() {};
}
var tfoot = Calendar.createElement("tfoot", table);
row = Calendar.createElement("tr", tfoot);
row.className = "footrow";
cell = hh(Calendar._TT["SEL_DATE"], this.weekNumbers ? 8 : 7, 300);
cell.className = "ttip";
cell.ttip = Calendar._TT["DRAG_TO_MOVE"];
cell.style.cursor = "move";
this.tooltips = cell;
div = Calendar.createElement("div", this.element);
this.monthsCombo = div;
div.className = "combo";
for (i = 0; i < Calendar._MN.length; ++i) {
var mn = Calendar.createElement("div");
mn.className = Calendar.is_ie ? "label-IEfix" : "label";
mn.month = i;
mn.innerHTML = Calendar._SMN[i];
div.appendChild(mn);
}
div = Calendar.createElement("div", this.element);
this.yearsCombo = div;
div.className = "combo";
for (i = 12; i > 0; --i) {
var yr = Calendar.createElement("div");
yr.className = Calendar.is_ie ? "label-IEfix" : "label";
div.appendChild(yr);
}
this._init(this.firstDayOfWeek, this.date);
parent.appendChild(this.element);
};
/** keyboard navigation, only for popup calendars */
Calendar._keyEvent = function(ev) {
var cal = window._dynarch_popupCalendar;
if (!cal || cal.multiple)
return false;
(Calendar.is_ie) && (ev = window.event);
var act = (Calendar.is_ie || ev.type == "keypress"),
K = ev.keyCode;
if (ev.ctrlKey) {
switch (K) {
case 37: // KEY left
act && Calendar.cellClick(cal._nav_pm);
break;
case 38: // KEY up
act && Calendar.cellClick(cal._nav_py);
break;
case 39: // KEY right
act && Calendar.cellClick(cal._nav_nm);
break;
case 40: // KEY down
act && Calendar.cellClick(cal._nav_ny);
break;
default:
return false;
}
} else switch (K) {
case 32: // KEY space (now)
Calendar.cellClick(cal._nav_now);
break;
case 27: // KEY esc
act && cal.callCloseHandler();
break;
case 37: // KEY left
case 38: // KEY up
case 39: // KEY right
case 40: // KEY down
if (act) {
var prev, x, y, ne, el, step;
prev = K == 37 || K == 38;
step = (K == 37 || K == 39) ? 1 : 7;
function setVars() {
el = cal.currentDateEl;
var p = el.pos;
x = p & 15;
y = p >> 4;
ne = cal.ar_days[y][x];
};setVars();
function prevMonth() {
var date = new Date(cal.date);
date.setDate(date.getDate() - step);
cal.setDate(date);
};
function nextMonth() {
var date = new Date(cal.date);
date.setDate(date.getDate() + step);
cal.setDate(date);
};
while (1) {
switch (K) {
case 37: // KEY left
if (--x >= 0)
ne = cal.ar_days[y][x];
else {
x = 6;
K = 38;
continue;
}
break;
case 38: // KEY up
if (--y >= 0)
ne = cal.ar_days[y][x];
else {
prevMonth();
setVars();
}
break;
case 39: // KEY right
if (++x < 7)
ne = cal.ar_days[y][x];
else {
x = 0;
K = 40;
continue;
}
break;
case 40: // KEY down
if (++y < cal.ar_days.length)
ne = cal.ar_days[y][x];
else {
nextMonth();
setVars();
}
break;
}
break;
}
if (ne) {
if (!ne.disabled)
Calendar.cellClick(ne);
else if (prev)
prevMonth();
else
nextMonth();
}
}
break;
case 13: // KEY enter
if (act)
Calendar.cellClick(cal.currentDateEl, ev);
break;
default:
return false;
}
return Calendar.stopEvent(ev);
};
/**
*  (RE)Initializes the calendar to the given date and firstDayOfWeek
*/
Calendar.prototype._init = function (firstDayOfWeek, date) {
var today = new Date(),
TY = today.getFullYear(),
TM = today.getMonth(),
TD = today.getDate();
var year = date.getFullYear();
if (year < this.minYear) {
year = this.minYear;
date.setFullYear(year);
} else if (year > this.maxYear) {
year = this.maxYear;
date.setFullYear(year);
}
this.firstDayOfWeek = firstDayOfWeek;
this.date = new Date(date);
var month = date.getMonth();
var mday = date.getDate();
var no_days = date.getMonthDays();



date.setDate(1);
var day1 = (date.getDay() - this.firstDayOfWeek) % 7;
if (day1 < 0)
day1 += 7;
date.setDate(-day1);
date.setDate(date.getDate() + 1);
var row = this.tbody.firstChild;
var MN = Calendar._SMN[month];
var ar_days = this.ar_days = new Array();
var weekend = Calendar._TT["WEEKEND"];
var dates = this.multiple ? (this.datesCells = {}) : null;
for (var i = 0; i < 6; ++i, row = row.nextSibling) {
var cell = row.firstChild;
if (this.weekNumbers) {
cell.className = "day wn";
cell.innerHTML = date.getWeekNumber();
cell = cell.nextSibling;
}
row.className = "daysrow";
var hasdays = false, iday, dpos = ar_days[i] = [];
for (var j = 0; j < 7; ++j, cell = cell.nextSibling, date.setDate(iday + 1)) {
iday = date.getDate();
var wday = date.getDay();
cell.className = "day";
cell.pos = i << 4 | j;
dpos[j] = cell;
var current_month = (date.getMonth() == month);
if (!current_month) {
if (this.showsOtherMonths) {
cell.className += " othermonth";
cell.otherMonth = true;
} else {
cell.className = "emptycell";
cell.innerHTML = "&nbsp;";
cell.disabled = true;
continue;
}
} else {
cell.otherMonth = false;
hasdays = true;
}
cell.disabled = false;
cell.innerHTML = this.getDateText ? this.getDateText(date, iday) : iday;
if (dates)
dates[date.print("%Y%m%d")] = cell;
if (this.getDateStatus) {
var status = this.getDateStatus(date, year, month, iday);
if (this.getDateToolTip) {
var toolTip = this.getDateToolTip(date, year, month, iday);
if (toolTip)
cell.title = toolTip;
}
if (status === true) {
cell.className += " disabled";
cell.disabled = true;
} else {
if (/disabled/i.test(status))
cell.disabled = true;
cell.className += " " + status;
}
}
if (!cell.disabled) {
cell.caldate = new Date(date);
cell.ttip = "_";
if (!this.multiple && current_month
&& iday == mday && this.hiliteToday) {
cell.className += " selected";
this.currentDateEl = cell;
}
if (date.getFullYear() == TY &&
date.getMonth() == TM &&
iday == TD) {
cell.className += " today";
cell.ttip += Calendar._TT["PART_TODAY"];
}
if (weekend.indexOf(wday.toString()) != -1)
cell.className += cell.otherMonth ? " oweekend" : " weekend";
}
}
if (!(hasdays || this.showsOtherMonths))
row.className = "emptyrow";
}
this.title.innerHTML = Calendar._MN[month] + ", " + year;
this.onSetTime();
this._initMultipleDates();


};
Calendar.prototype._initMultipleDates = function() {
if (this.multiple) {
for (var i in this.multiple) {
var cell = this.datesCells[i];
var d = this.multiple[i];
if (!d)
continue;
if (cell)
cell.className += " selected";
}
}
};
Calendar.prototype._toggleMultipleDate = function(date) {
if (this.multiple) {
var ds = date.print("%Y%m%d");
var cell = this.datesCells[ds];
if (cell) {
var d = this.multiple[ds];
if (!d) {
Calendar.addClass(cell, "selected");
this.multiple[ds] = date;
} else {
Calendar.removeClass(cell, "selected");
delete this.multiple[ds];
}
}
}
};
Calendar.prototype.setDateToolTipHandler = function (unaryFunction) {
this.getDateToolTip = unaryFunction;
};
/**
*  Calls _init function above for going to a certain date (but only if the
*  date is different than the currently selected one).
*/
Calendar.prototype.setDate = function (date) {
if (!date.equalsTo(this.date)) {
this._init(this.firstDayOfWeek, date);
}
};
/**
*  Refreshes the calendar.  Useful if the "disabledHandler" function is
*  dynamic, meaning that the list of disabled date can change at runtime.
*  Just * call this function if you think that the list of disabled dates
*  should * change.
*/
Calendar.prototype.refresh = function () {
this._init(this.firstDayOfWeek, this.date);
};
/** Modifies the "firstDayOfWeek" parameter (pass 0 for Synday, 1 for Monday, etc.). */
Calendar.prototype.setFirstDayOfWeek = function (firstDayOfWeek) {
this._init(firstDayOfWeek, this.date);
this._displayWeekdays();
};
/**
*  Allows customization of what dates are enabled.  The "unaryFunction"
*  parameter must be a function object that receives the date (as a JS Date
*  object) and returns a boolean value.  If the returned value is true then
*  the passed date will be marked as disabled.
*/
Calendar.prototype.setDateStatusHandler = Calendar.prototype.setDisabledHandler = function (unaryFunction) {
this.getDateStatus = unaryFunction;
};
/** Customization of allowed year range for the calendar. */
Calendar.prototype.setRange = function (a, z) {
this.minYear = a;
this.maxYear = z;
};
/** Calls the first user handler (selectedHandler). */
Calendar.prototype.callHandler = function () {
if (this.onSelected && this.dateClicked) {
this.onSelected(this, this.date.print(this.dateFormat));
}
};
/** Calls the second user handler (closeHandler). */
Calendar.prototype.callCloseHandler = function () {
if (this.onClose) {
this.onClose(this);
}
this.hideShowCovered();
};
/** Removes the calendar object from the DOM tree and destroys it. */
Calendar.prototype.destroy = function () {
var el = this.element.parentNode;
el.removeChild(this.element);
Calendar._C = null;
window._dynarch_popupCalendar = null;
};
/**
*  Moves the calendar element to a different section in the DOM tree (changes
*  its parent).
*/
Calendar.prototype.reparent = function (new_parent) {
var el = this.element;
el.parentNode.removeChild(el);
new_parent.appendChild(el);
};



Calendar._checkCalendar = function(ev) {
var calendar = window._dynarch_popupCalendar;
if (!calendar) {
return false;
}
var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev);
for (; el != null && el != calendar.element; el = el.parentNode);
if (el == null) {

window._dynarch_popupCalendar.callCloseHandler();
return Calendar.stopEvent(ev);
}
};
/** Shows the calendar. */
Calendar.prototype.show = function () {
var rows = this.table.getElementsByTagName("tr");
for (var i = rows.length; i > 0;) {
var row = rows[--i];
Calendar.removeClass(row, "rowhilite");
var cells = row.getElementsByTagName("td");
for (var j = cells.length; j > 0;) {
var cell = cells[--j];
Calendar.removeClass(cell, "hilite");
Calendar.removeClass(cell, "active");
}
}
this.element.style.visibility = "visible";
this.hidden = false;
window._dynarch_popupCalendar = this;
Calendar.addEvent(document, "keydown", Calendar._keyEvent);
Calendar.addEvent(document, "keypress", Calendar._keyEvent);
Calendar.addEvent(document, "mousedown", Calendar._checkCalendar);
this.hideShowCovered();
};
/**
*  Hides the calendar.  Also removes any "hilite" from the class of any TD
*  element.
*/
Calendar.prototype.hide = function () {
Calendar.removeEvent(document, "keydown", Calendar._keyEvent);
Calendar.removeEvent(document, "keypress", Calendar._keyEvent);
Calendar.removeEvent(document, "mousedown", Calendar._checkCalendar);
this.element.style.visibility = "hidden";
this.hidden = true;
this.hideShowCovered();
};
/**
*  Shows the calendar at a given absolute position (beware that, depending on
*  the calendar element style -- position property -- this might be relative
*  to the parent's containing rectangle).
*/
Calendar.prototype.showAt = function (x, y) {
var s = this.element.style;
s.left = x + "px";
s.top = y + "px";
this.show();
};
/** Shows the calendar near a given element. */
Calendar.prototype.showAtElement = function (el) {
var p = { x: getLeft(el), y: getTop(el) };
var dx = this.element.offsetParent ? getLeft(this.element.offsetParent) : 0;
var dy = this.element.offsetParent ? getTop(this.element.offsetParent) : 0;
this.showAt(p.x - dx, 
p.y + el.offsetHeight - dy);
return true;
};
/** Customizes the date format. */
Calendar.prototype.setDateFormat = function (str) {
this.dateFormat = str;
};
/** Customizes the tooltip date format. */
Calendar.prototype.setTtDateFormat = function (str) {
this.ttDateFormat = str;
};
/**
*  Tries to identify the date represented in a string.  If successful it also
*  calls this.setDate which moves the calendar to the given date.
*/
Calendar.prototype.parseDate = function(str, fmt) {
if (!fmt)
fmt = this.dateFormat;
this.setDate(Date.parseDate(str, fmt));
};
Calendar.prototype.hideShowCovered = function () {
if (!Calendar.is_ie && !Calendar.is_opera)
return;
function getVisib(obj){
var value = obj.style.visibility;
if (!value) {
if (document.defaultView && typeof (document.defaultView.getComputedStyle) == "function") { // Gecko, W3C
if (!Calendar.is_khtml)
value = document.defaultView.
getComputedStyle(obj, "").getPropertyValue("visibility");
else
value = '';
} else if (obj.currentStyle) { // IE
value = obj.currentStyle.visibility;
} else
value = '';
}
return value;
};
var tags = new Array("applet", "iframe", "select");
var el = this.element;
var p = { x: getLeft(el), y: getTop(el) };
var EX1 = p.x;
var EX2 = el.offsetWidth + EX1;
var EY1 = p.y;
var EY2 = el.offsetHeight + EY1;
for (var k = tags.length; k > 0; ) {
var ar = document.getElementsByTagName(tags[--k]);
var cc = null;
for (var i = ar.length; i > 0;) {
cc = ar[--i];
p = { x: getLeft(el), y: getTop(el) };
var CX1 = p.x;
var CX2 = cc.offsetWidth + CX1;
var CY1 = p.y;
var CY2 = cc.offsetHeight + CY1;
if (this.hidden || (CX1 > EX2) || (CX2 < EX1) || (CY1 > EY2) || (CY2 < EY1)) {
if (!cc.__msh_save_visibility) {
cc.__msh_save_visibility = getVisib(cc);
}
cc.style.visibility = cc.__msh_save_visibility;
} else {
if (!cc.__msh_save_visibility) {
cc.__msh_save_visibility = getVisib(cc);
}
cc.style.visibility = "hidden";
}
}
}
};
/** Internal function; it displays the bar with the names of the weekday. */
Calendar.prototype._displayWeekdays = function () {
var fdow = this.firstDayOfWeek;
var cell = this.firstdayname;
var weekend = Calendar._TT["WEEKEND"];
for (var i = 0; i < 7; ++i) {
cell.className = "day name";
var realday = (i + fdow) % 7;
if (i) {
cell.ttip = Calendar._TT["DAY_FIRST"].replace("%s", Calendar._DN[realday]);
cell.navtype = 100;
cell.calendar = this;
cell.fdow = realday;
Calendar._add_evs(cell);
}
if (weekend.indexOf(realday.toString()) != -1) {
Calendar.addClass(cell, "weekend");
}
cell.innerHTML = Calendar._SDN[(i + fdow) % 7];
cell = cell.nextSibling;
}
};
/** Internal function.  Hides all combo boxes that might be displayed. */
Calendar.prototype._hideCombos = function () {
this.monthsCombo.style.display = "none";
this.yearsCombo.style.display = "none";
};
/** Internal function.  Starts dragging the element. */
Calendar.prototype._dragStart = function (ev) {
if (this.dragging) {
return;
}
this.dragging = true;
var posX;
var posY;
if (Calendar.is_ie) {
posY = window.event.clientY + document.body.scrollTop;
posX = window.event.clientX + document.body.scrollLeft;
} else {
posY = ev.clientY + window.scrollY;
posX = ev.clientX + window.scrollX;
}
var st = this.element.style;
this.xOffs = posX - parseInt(st.left);
this.yOffs = posY - parseInt(st.top);
with (Calendar) {
addEvent(document, "mousemove", calDragIt);
addEvent(document, "mouseup", calDragEnd);
}
};

/** Adds the number of days array to the Date object. */
Date._MD = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
/** Constants used for time computations */
Date.SECOND = 1000 /* milliseconds */;
Date.MINUTE = 60 * Date.SECOND;
Date.HOUR   = 60 * Date.MINUTE;
Date.DAY    = 24 * Date.HOUR;
Date.WEEK   =  7 * Date.DAY;
Date.parseDate = function(str, fmt) {
var today = new Date();
var y = 0;
var m = -1;
var d = 0;
var a = str.split(/\W+/);
var b = fmt.match(/%./g);
var i = 0, j = 0;
var hr = 0;
var min = 0;
for (i = 0; i < a.length; ++i) {
if (!a[i])
continue;
switch (b[i]) {
case "%d":
case "%e":
d = parseInt(a[i], 10);
break;
case "%m":
m = parseInt(a[i], 10) - 1;
break;
case "%Y":
case "%y":
y = parseInt(a[i], 10);
(y < 100) && (y += (y > 29) ? 1900 : 2000);
break;
case "%b":
case "%B":
for (j = 0; j < 12; ++j) {
if (Calendar._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { m = j; break; }
}
break;
case "%H":
case "%I":
case "%k":
case "%l":
hr = parseInt(a[i], 10);
break;
case "%P":
case "%p":
if (/pm/i.test(a[i]) && hr < 12)
hr += 12;
else if (/am/i.test(a[i]) && hr >= 12)
hr -= 12;
break;
case "%M":
min = parseInt(a[i], 10);
break;
}
}
if (isNaN(y)) y = today.getFullYear();
if (isNaN(m)) m = today.getMonth();
if (isNaN(d)) d = today.getDate();
if (isNaN(hr)) hr = today.getHours();
if (isNaN(min)) min = today.getMinutes();
if (y != 0 && m != -1 && d != 0)
return new Date(y, m, d, hr, min, 0);
y = 0; m = -1; d = 0;
for (i = 0; i < a.length; ++i) {
if (a[i].search(/[a-zA-Z]+/) != -1) {
var t = -1;
for (j = 0; j < 12; ++j) {
if (Calendar._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { t = j; break; }
}
if (t != -1) {
if (m != -1) {
d = m+1;
}
m = t;
}
} else if (parseInt(a[i], 10) <= 12 && m == -1) {
m = a[i]-1;
} else if (parseInt(a[i], 10) > 31 && y == 0) {
y = parseInt(a[i], 10);
(y < 100) && (y += (y > 29) ? 1900 : 2000);
} else if (d == 0) {
d = a[i];
}
}
if (y == 0)
y = today.getFullYear();
if (m != -1 && d != 0)
return new Date(y, m, d, hr, min, 0);
return today;
};
/** Returns the number of days in the current month */
Date.prototype.getMonthDays = function(month) {
var year = this.getFullYear();
if (typeof month == "undefined") {
month = this.getMonth();
}
if (((0 == (year%4)) && ( (0 != (year%100)) || (0 == (year%400)))) && month == 1) {
return 29;
} else {
return Date._MD[month];
}
};
/** Returns the number of day in the year. */
Date.prototype.getDayOfYear = function() {
var now = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
var then = new Date(this.getFullYear(), 0, 0, 0, 0, 0);
var time = now - then;
return Math.floor(time / Date.DAY);
};
/** Returns the number of the week in year, as defined in ISO 8601. */
Date.prototype.getWeekNumber = function() {
var d = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
var DoW = d.getDay();
d.setDate(d.getDate() - (DoW + 6) % 7 + 3); // Nearest Thu
var ms = d.valueOf(); // GMT
d.setMonth(0);
d.setDate(4); // Thu in Week 1
return Math.round((ms - d.valueOf()) / (7 * 864e5)) + 1;
};
/** Checks date and time equality */
Date.prototype.equalsTo = function(date) {
return ((this.getFullYear() == date.getFullYear()) &&
(this.getMonth() == date.getMonth()) &&
(this.getDate() == date.getDate()) &&
(this.getHours() == date.getHours()) &&
(this.getMinutes() == date.getMinutes()));
};
/** Set only the year, month, date parts (keep existing time) */
Date.prototype.setDateOnly = function(date) {
var tmp = new Date(date);
this.setDate(1);
this.setFullYear(tmp.getFullYear());
this.setMonth(tmp.getMonth());
this.setDate(tmp.getDate());
};
/** Prints the date in a string according to the given format. */
Date.prototype.print = function (str) {
var m = this.getMonth();
var d = this.getDate();
var y = this.getFullYear();
var wn = this.getWeekNumber();
var w = this.getDay();
var s = {};
var hr = this.getHours();
var pm = (hr >= 12);
var ir = (pm) ? (hr - 12) : hr;
var dy = this.getDayOfYear();
if (ir == 0)
ir = 12;
var min = this.getMinutes();
var sec = this.getSeconds();
s["%a"] = Calendar._SDN[w]; // abbreviated weekday name [FIXME: I18N]
s["%A"] = Calendar._DN[w]; // full weekday name
s["%b"] = Calendar._SMN[m]; // abbreviated month name [FIXME: I18N]
s["%B"] = Calendar._MN[m]; // full month name

s["%C"] = 1 + Math.floor(y / 100); // the century number
s["%d"] = (d < 10) ? ("0" + d) : d; // the day of the month (range 01 to 31)
s["%e"] = d; // the day of the month (range 1 to 31)


s["%H"] = (hr < 10) ? ("0" + hr) : hr; // hour, range 00 to 23 (24h format)
s["%I"] = (ir < 10) ? ("0" + ir) : ir; // hour, range 01 to 12 (12h format)
s["%j"] = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy; // day of the year (range 001 to 366)
s["%k"] = hr;    // hour, range 0 to 23 (24h format)
s["%l"] = ir;    // hour, range 1 to 12 (12h format)
s["%m"] = (m < 9) ? ("0" + (1+m)) : (1+m); // month, range 01 to 12
s["%M"] = (min < 10) ? ("0" + min) : min; // minute, range 00 to 59
s["%n"] = "\n";    // a newline character
s["%p"] = pm ? "PM" : "AM";
s["%P"] = pm ? "pm" : "am";


s["%s"] = Math.floor(this.getTime() / 1000);
s["%S"] = (sec < 10) ? ("0" + sec) : sec; // seconds, range 00 to 59
s["%t"] = "\t";    // a tab character

s["%U"] = s["%W"] = s["%V"] = (wn < 10) ? ("0" + wn) : wn;
s["%u"] = w + 1;  // the day of the week (range 1 to 7, 1 = MON)
s["%w"] = w;    // the day of the week (range 0 to 6, 0 = SUN)


s["%y"] = ('' + y).substr(2, 2); // year without the century (range 00 to 99)
s["%Y"] = y;    // year with the century
s["%%"] = "%";    // a literal '%' character
var re = /%./g;
if (!Calendar.is_ie5 && !Calendar.is_khtml)
return str.replace(re, function (par) { return s[par] || par; });
var a = str.match(re);
for (var i = 0; i < a.length; i++) {
var tmp = s[a[i]];
if (tmp) {
re = new RegExp(a[i], 'g');
str = str.replace(re, tmp);
}
}
return str;
};
Date.prototype.__msh_oldSetFullYear = Date.prototype.setFullYear;
Date.prototype.setFullYear = function(y) {
var d = new Date(this);
d.__msh_oldSetFullYear(y);
if (d.getMonth() != this.getMonth())
this.setDate(28);
this.__msh_oldSetFullYear(y);
};


window._dynarch_popupCalendar = null;










Calendar._DN = new Array
("Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday");












Calendar._SDN = new Array
("Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
"Sun");


Calendar._FD = 0;

Calendar._MN = new Array
("January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December");

Calendar._SMN = new Array
("Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec");

Calendar._TT = {};
Calendar._TT["INFO"] = "About the calendar";
Calendar._TT["ABOUT"] =
"DHTML Date/Time Selector\n" +
"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
"Distributed under GNU LGPL.  See http://gnu.org/licenses/lgpl.html for details." +
"\n\n" +
"Date selection:\n" +
"- Use the \xab, \xbb buttons to select year\n" +
"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" +
"- Hold mouse button on any of the above buttons for faster selection.";
Calendar._TT["ABOUT_TIME"] = "\n\n" +
"Time selection:\n" +
"- Click on any of the time parts to increase it\n" +
"- or Shift-click to decrease it\n" +
"- or click and drag for faster selection.";
Calendar._TT["PREV_YEAR"] = "Prev. year (hold for menu)";
Calendar._TT["PREV_MONTH"] = "Prev. month (hold for menu)";
Calendar._TT["GO_TODAY"] = "Go Today";
Calendar._TT["NEXT_MONTH"] = "Next month (hold for menu)";
Calendar._TT["NEXT_YEAR"] = "Next year (hold for menu)";
Calendar._TT["SEL_DATE"] = "Select date";
Calendar._TT["DRAG_TO_MOVE"] = "Drag to move";
Calendar._TT["PART_TODAY"] = " (today)";


Calendar._TT["DAY_FIRST"] = "Display %s first";



Calendar._TT["WEEKEND"] = "0,6";
Calendar._TT["CLOSE"] = "Close";
Calendar._TT["TODAY"] = "Today";
Calendar._TT["TIME_PART"] = "(Shift-)Click or drag to change value";

Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d";
Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
Calendar._TT["WK"] = "wk";
Calendar._TT["TIME"] = "Time:";

var oldLink = null;


function selected(cal, date) {
cal.sel.value = date; // just update the date in the input field.
if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3"))



cal.callCloseHandler();
}



function closeHandler(cal) {
cal.hide();                        // hide the calendar

_dynarch_popupCalendar = null;
}



function showCalendar(id, format, showsTime, showsOtherMonths, date, handlers, base) {
if (!handlers) { handlers = {}; };
var el = document.getElementById(id);
if (_dynarch_popupCalendar != null) {

_dynarch_popupCalendar.hide();                 // so we hide it first.
} else {

var cal = new Calendar(1, null, handlers.selected || selected, handlers.close || closeHandler);


if (typeof showsTime == "string") {
cal.showsTime = true;
cal.time24 = (showsTime == "24");
}
if (showsOtherMonths) {
cal.showsOtherMonths = true;
}
_dynarch_popupCalendar = cal;                  // remember it in the global var
cal.setRange(1900, 2070);        // min/max year allowed.
cal.create(base);
}
_dynarch_popupCalendar.onSelected = handlers.selected || selected;
_dynarch_popupCalendar.onClose = handlers.close || closeHandler;
_dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
_dynarch_popupCalendar.setDate(date);



_dynarch_popupCalendar.showAtElement(el);        // show the calendar
return false;
}





Class.extend(ControlCalendar, Object);
function ControlCalendar(eYear, eMonth, eDay, eButton) {
this._elementYear = eYear;
this._elementMonth = eMonth;
this._elementDay = eDay;
this._elementButton = eButton;
this._buttonClickHandler = function() { 
return showCalendar(eButton.id, "%A, %B %e, %Y", null, null, new Date(), 
{ selected: function(c, date) { cal.onSelected(c, date); }, 
close: function(c) { cal.onClose(c); } },
eButton.offsetParent); 
}
this.bindEvents();
var cal = this;
this._resultCallback = function(date) { 
cal._elementYear.value = date.getFullYear();
cal._elementMonth.value = date.getMonth() + 1;
cal._elementDay.value = date.getDate();
};
};
ControlCalendar.prototype.bindEvents = function() {
this._elementButton && addEvent(this._elementButton, "click", this._buttonClickHandler);
};
ControlCalendar.prototype.onClose = function(cal) {
cal.hide();
this._resultCallback(cal.date);
};
ControlCalendar.prototype.onSelected = function(cal, date) {  
if (cal.dateClicked) {
cal.callCloseHandler();
};
};
ControlCalendar.prototype.unbindEvents = function() {
removeEvent(this._elementButton, "click", this._buttonClickHandler);
};


Array.prototype.all = function() {
return this.reduce(function(a,b) { return a && b; }, true);
}







Validators.not_empty = function(elements, messages) {
var _t = this;
var result = elements.map(function(element) {
if (element.value == "") {
_t.handleError(element, messages.value_missing);
return false;
} else {
return true;
};
});
return result.all();
}




