
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.c.addOnLoadHandler(function() {
if ($("layout_link_back")) { 
addEvent($("layout_link_back"), 'click', function(e) {
history.back();
cancelEvent(e);
});
};
});





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);
};
}


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';
}

function Selection(element) {
this._element = element;
if (document.selection) {
this._selection = new SelectionIE(element);
} else {
this._selection = new SelectionMozilla(element);
};
}
Selection.prototype.empty = function() {
return this._selection.empty();
}
Selection.prototype.getCaretPos = function() {
this._element.focus();
if (this._element.selectionStart) {
return this._element.selectionStart;
} else if (document.selection) {
var sel = document.selection.createRange();
var clone = sel.duplicate();
sel.collapse(true);
clone.moveToElementText(this._element);
clone.setEndPoint('EndToEnd', sel);
return clone.text.length;
}
return 0;
}

function SelectionIE(element) {
this._element = element;
}
SelectionIE.prototype.empty = function() {
var range = document.selection.createRange();
return range.text == '';
}

function SelectionMozilla(element) {
this._element = element;
}
SelectionMozilla.prototype.empty = function() {
return this._element.selectionStart == this._element.selectionEnd;
}










Class.extend(Combo, Object);
function Combo() {
this._options = [];
this._groups = {};
this._groupNames = [];
this._filtered = [];
this._selected = null;
this._hovered = null;
this._autocompleted = false;
this._eCombo = null;
this._eComboControl = null;
this._eComboText = null;
this._eComboArrow = null;
this._eComboOptions = null;
this._eOld = null;
this._optionsPane = null;
}
Combo.prototype.addOption = function(value, text, group) {
var groupObj = this._groups[group];
if (!groupObj) {
groupObj = { name: group, options: [] };
this._groups[group] = groupObj;
this._groupNames.push(group);
};
var option = { value: value, text: text, element: null, group: groupObj };
this._options.push(option);
groupObj.options.push(option);
return option;
}
Combo.prototype.checkValue = function(value) {
var filtered = _this.filterOptions(value);
if (filtered.length != 1) {
_this.select(null);
_this.filterOptions("");
} else {
_this.select(filtered[0]);
};
}
Combo.prototype.filterOptions = function(text) {
var _this = this;
this._filtered = [];
this._options.each(function(option) {
var display;
if (option.text.substr(0, text.length) == text) {
display = "block";
_this._filtered.push(option);
} else {
display = "none";
};
option.element.style.display = display;
});

this._groupNames.each(function(groupName) {
var group = _this._groups[groupName];
var visibleElements = group.options.filter(function(option) { return option.element.style.display != "none"; });
group.element.style.display = visibleElements.length == 0 ? "none" : "block";
});

var visibleGroups = this._groupNames.filter(function(groupName) { return _this._groups[groupName].element.style.display != "none"; });
if (visibleGroups.length == 0) {
this._optionsPane.hide();
} else {
this._optionsPane.show();
};
return this._filtered;
}
Combo.prototype.hilightOption = function(option) {
this._options.each(function(option) {
rc(option.element, "hover");
});
ac(option.element, "hover");
this._hovered = option;
this._optionsPane.show();
}
Combo.prototype.replace = function(selectObj) {


this._eOld = selectObj;

var selectedOption = null;
for (var i=0; i<selectObj.options.length; i++) {
var option = selectObj.options[i];
var group = null;
if (option.parentNode.tagName == "OPTGROUP") {
group = option.parentNode.getAttribute("label");
};
if (option.text != "") {
var optionObj = this.addOption(option.value, option.text, group);
if (option.selected) {
selectedOption = optionObj;
};
};
};
this.setup();
this.setupOptions();
this.select(selectedOption);

this._filtered = this._options;

var oldWidth = getElementComputedStyle(this._eOld, "width");
this._eComboControl.style.width = oldWidth;
var parent = this._eOld.parentNode;
parent.replaceChild(this._eCombo, this._eOld);
this._eOld.style.display = "none";
parent.appendChild(this._eOld);
return this;
}
Combo.prototype.select = function(option) {
this._selected = option;
this._optionsPane.hide();
if (option == null) {
this._eComboText.value = "";
this._eOld.value = "";
} else {
this._eComboText.value = option.text;
this._eOld.value = option.value;
};
}
Combo.prototype.setup = function() {
var _this = this;
this._eCombo = document.createElement("div");
this._eCombo.className = "rapid_php_combo";
this._eComboControl = document.createElement("div");
this._eComboControl.className = "control";
this._eComboText = document.createElement("input");
this._eComboArrow = document.createElement("img");
this._eComboArrow.src = Links.image("rapid_php_combo_arrow.gif");
this._eComboArrow.alt = _("Show list");
this._eComboOptions = document.createElement("div");
this._eComboOptions.className = "options";
this._eComboControl.appendChild(this._eComboText);
this._eComboControl.appendChild(this._eComboArrow);
this._eCombo.appendChild(this._eComboControl);
this._eCombo.appendChild(this._eComboOptions);
this._optionsPane = new Pane(this._eComboOptions);
this._optionsPane._showCallback = function() {
_this.showOptionsPaneCallback();
};
this.setupBindings();
}
Combo.prototype.setupBindings = function() {
var _this = this;
addEvent(this._eComboArrow, "click", function() { 
_this._optionsPane.toggle();
});
addEvent(this._eComboText, "focus", function() { 
_this._optionsPane.show();
textBoxSelect(_this._eComboText, 0, _this._eComboText.value.length);
});
addEvent(this._eComboText, "blur", function() { 



setTimeout(function() { 
var newValue = _this._eComboText.value;
_this.checkValue(newValue);
_this._optionsPane.hide(); 
}, 100);
});
addEvent(this._eComboText, "keydown", function(e) { _this.onTextKeyDown(e); });
addEvent(this._eComboText, "keyup", function(e) { _this.onTextKeyUp(e); });
}
Combo.prototype.setupOptions = function() {
var _this = this;
this._eComboOptions.innerHTML = "";
var group = null;
var groupNode = null;
this._options.each(function(option) {
var eOption = document.createElement("div");
eOption.className = "option";
eOption.innerHTML = option.text;
addEvent(eOption, "click", function(e) { _this.onOptionClick(e, option) });
addEvent(eOption, "mouseover", function(e) { _this.onOptionOver(e, option) });
addEvent(eOption, "mouseout", function(e) { _this.onOptionOut(e, option) });
option.element = eOption;

if (option.group != group) {
if (groupNode) {
_this._eComboOptions.appendChild(groupNode);
};
group = option.group;
groupNode = document.createElement("div");
groupNode.className = "optgroup";
var groupHeader = document.createElement("div");
groupHeader.className = "label";
groupHeader.appendChild(document.createTextNode(option.group.name));
groupNode.appendChild(groupHeader);
option.group.element = groupNode;
};
if (groupNode) {
groupNode.appendChild(eOption);
} else {
_this._eComboOptions.appendChild(eOption);
};
});
if (groupNode) {
_this._eComboOptions.appendChild(groupNode);
};
}
Combo.prototype.showOptionsPaneCallback = function() {
var _this = this;
setTimeout(function() {
var top = getBottom(_this._eComboControl) - getTopParent(_this._eComboOptions) + 2;
_this._eComboOptions.style.top = top.toString() + "px";
var left = getLeft(_this._eComboControl) - getLeftParent(_this._eComboOptions);
_this._eComboOptions.style.left = left.toString() + "px";
_this._eComboOptions.style.width = _this._eComboControl.clientWidth.toString() + "px";
}, 1);
}

Combo.prototype.onOptionClick = function(e, option) {
this.select(option);
}
Combo.prototype.onOptionOut = function(e, option) {}
Combo.prototype.onOptionOver = function(e, option) {
this.hilightOption(option)
}
Combo.prototype.onTextKeyDown = function(e) {
var _this = this;
var key = e.charCode || e.keyCode;

if (key == 13 && this._optionsPane.isVisible()) {
cancelEvent(e);
};
}
Combo.prototype.onTextKeyUp = function(e) {
var _this = this;
var key = e.charCode || e.keyCode;


setTimeout(function() { 


if (key == 38) {
if (_this._filtered.length > 0) {
var hoverIndex = _this._filtered.indexOf(_this._hovered);
if (hoverIndex == -1) {
hoverIndex = 0;
} else {
hoverIndex = hoverIndex > 0 ? hoverIndex - 1 : 0;
};
_this.hilightOption(_this._filtered[hoverIndex]);
};
};    

if (key == 40) {
if (_this._filtered.length > 0) {
var hoverIndex = _this._filtered.indexOf(_this._hovered);
if (hoverIndex == -1) {
hoverIndex = 0;
} else {
hoverIndex = hoverIndex < _this._filtered.length - 1? hoverIndex + 1 : _this._filtered.length - 1;
};
_this.hilightOption(_this._filtered[hoverIndex]);
};
};    

if (key == 13) {
_this.select(_this._hovered);
};    

if (key == 8) {
if (_this._autocompleted) {
_this._eComboText.value = _this._eComboText.value.substr(0, _this._eComboText.value.length - 1);
};
};
var filtered = _this.filterOptions(_this._eComboText.value);
_this._autocompleted = false;
if (filtered.length == 1) {
var oldLength = _this._eComboText.value.length;

var selection = new Selection(_this._eComboText);
if (selection.empty() && oldLength != filtered[0].text.length) {
_this._eComboText.value = filtered[0].text;
textBoxSelect(_this._eComboText, oldLength, _this._eComboText.value.length);
} else if (oldLength != filtered[0].text.length) {
_this._eComboText.value = filtered[0].text;
};
_this._autocompleted = true;
};
}, 1);
}


Class.extend(ComboEditable, Combo);
function ComboEditable() {
ComboEditable.baseConstructor.call(this);
}
ComboEditable.prototype.checkValue = function(value) {
var _this = this;
var filtered = _this.filterOptions(value);
if (filtered.length != 1) {
_this.select(null);
_this._eComboText.value = value;
_this.filterOptions("");
} else {
_this.select(filtered[0]);
};
}
ComboEditable.prototype.setCustomValue = function(value) {
this._eComboText.value = value;
return this;
}

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._waypointElements = [];
page.m.getWaypointsSelected = function() {
var waypoints = [];
page.m._waypointElements.each(function(waypointElement) {
waypoints.push([waypointElement.standard.value, waypointElement.custom.value]);
});
return waypoints;
}
page.m.makeWaypoint = function(options, combo) {
return { standard: options, custom: combo._eComboText };
}

page.c.addOnLoadHandler(function() {
addEvent($("service_search_1"), "submit", function (e) { cancelEvent(e); page.c.onStep1Submit(); });
[$("service_search_1_type"), $("service_search_1_location"), $("service_search_1_city")].each(function(e) {
addEvent(e, "change", page.c.onServiceTypeOrLocationChange);
});
});
page.c.makeComboReplaceCallback = function(options) {
return function() {
var combo = new ComboEditable();
combo.replace(options);
var old_select = combo.select;
combo.select = function(option) {
old_select.call(combo, option);

rc(combo._eComboText, "help");
};
new FeatureInputHelpValue(combo._eComboText, _("Enter or Select your Location"));
page.m._waypointElements.push(page.m.makeWaypoint(options, combo));
};
}
page.c.onServiceTypeOrLocationChange = function(e) {
var type = $F("service_search_1_type");
var location = $F("service_search_1_location");
var city = $F("service_search_1_city");
if (type == "" || location == "" || city == "") {
$("service_search_1_additional_fields").innerHTML = "";
return;
};
function onSuccess(response) {
$("service_search_1_additional_fields").innerHTML = "";
page.m._waypointElements = [];
var fieldsTable = document.createElement("table");
for (var i=0; i<response.param.length; i++) {
var waypoint = response.param[i];

var row = fieldsTable.insertRow(i);
var cell = row.insertCell(0);
cell.innerHTML = waypoint.name + " :";
cell.className = "name";
var cell = row.insertCell(1);
cell.className = "value";
var options = document.createElement("select");
options.id = waypoint.id;
cell.appendChild(options);
var opt = $A(waypoint.options);
opt.unshift({ text: "", value: ""});
AJAX.loadSelectOptionsDirect(options, opt);




setTimeout(page.c.makeComboReplaceCallback(options), 1);
};
$("service_search_1_additional_fields").appendChild(fieldsTable);
};
XMLRPC.call(Links.xmlrpc(), onSuccess, null, null, "service.waypoints", [type, location, city]);
}
page.c.onStep1Submit = function() {
if (page.getForm("service_search_1").validate()) {
return;
};

var base_element_id = "service_search_1_date";
var date = new Date();
date.setTime(date.getTime() + 24 * 60 * 60 * 1000);
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) {
if (!confirm("You're asking for a quotation 24 hours or less from your date of service.\nAre you sure you've chose correct date?")) {
return;
};
};
XMLRPC.call("xmlrpc.php", page.c.onStep1SubmitSuccess, page.c.onFailure, page.c.onFailure, "find.cars", 
[sprintf("%s-%s-%s",$F("service_search_1_date_yy"),$F("service_search_1_date_mm"),$F("service_search_1_date_dd")),
$F("service_search_1_type"),
$F("service_search_1_location"),
$F("service_search_1_city"),
$F("service_search_1_passengers")]);
page.v.showLoading();
}
page.c.onStep1SubmitSuccess = function(response) {
page.m.step2Data = []
for (var i=0; i<response.param.length; i++) {  
page.m.step2Data.push(response.param[i]);
};  
page.v.renderStep2Data();
page.v.showStep(2);
}
page.m.step1 = {};
page.m.step1._serviceTypes = {};
page.m.step1.addServiceType = function(id, name, mode) {
page.m.step1._serviceTypes[id] = { id: id, name:name, mode: mode };
}
page.v.step1 = {};
page.v.step1.refreshServiceTypeModeFields = function() {
$("table_round_trip").style.display = "none";
$("table_pickup").style.display = "none";
$("table_arrival").style.display = "none";
var type = page.m.step1._serviceTypes[$F("service_search_1_type")];
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 ($("service_search_1_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;
};
}
page.c.step1 = {};
page.c.addOnLoadHandler(function(e) {
addEvent($("service_search_1_type"), "change", page.c.step1.onServiceTypeChange);
addEvent($("service_search_1_round_trip"), "click", page.c.step1.onRoundTripChange);
});
page.c.step1.onRoundTripChange = function(e) {
page.v.step1.refreshServiceTypeModeFields();
}
page.c.step1.onServiceTypeChange = function(e) {
page.v.step1.refreshServiceTypeModeFields();
}


page.m.getSelectedCars = function() {
var selectedCars = [];
for (var i=0; i<page.m.step2Data.length; i++) {
var item = page.m.step2Data[i];
if (item.selected) { 
selectedCars.push(item.id);
};
}; 
return selectedCars;
}
page.v.step2 = {};
page.v.renderStep2Data = function() {
page.v.step2.clear();
if (page.m.step2Data.length > 0) {
page.v.step2.renderServices($A(page.m.step2Data));
} else {
page.v.step2.renderSorryMessage();
};
}
page.c.onStep2SubmitSuccess = function(response) {
page.m.step3Data = []
for (var i=0; i<response.param.length; i++) {  
page.m.step3Data.push(response.param[i]);
};  
page.v.renderStep3Data();
page.v.showStep(3);
}
page.v.step2.clear = function() {
var table = $("service_search_2_table");
var body = table.tBodies[0];
while (body.rows.length > 0) {
body.deleteRow(0);
};
}
page.v.step2.renderService = function(item, index) { 
var body = $("service_search_2_table").tBodies[0];
var row = body.insertRow(body.rows.length);
addEvent(row, "click", page.c.makeStep2RowClickCallback(index));
var cellName = row.insertCell(0);
var categoryLink = document.createElement("span");
categoryLink.innerHTML = "(" + item.category_name + ")";
cellName.appendChild(categoryLink);
cellName.appendChild(document.createTextNode(" "));
var carLink = document.createElement("a");
carLink.href = "#"; // Links.action("car.view", { id: item.id });
carLink.innerHTML = item.name;
addEvent(carLink, "click", page.c.makeOnCarClickHandler(item.id));
cellName.appendChild(carLink);
var cellCapacity = row.insertCell(1);
if (item.capacity_min != item.capacity_max) {
cellCapacity.innerHTML = item.capacity_min.toString() + "&ndash;" + item.capacity_max.toString();
} else {
cellCapacity.innerHTML = item.capacity_min;
};
var cellPhoto = row.insertCell(2);
}
page.v.step2.renderServices = function(data) {

$("service_search_2_table").tHead.style.visibility = "visible";
data.each(page.v.step2.renderService);
}
page.v.step2.renderSorryMessage = function() {

$("service_search_2_table").tHead.style.visibility = "hidden";
var body = $("service_search_2_table").tBodies[0];
var row = body.insertRow(body.rows.length);
var cellSorry = row.insertCell(0);
cellSorry.colSpan = "2";
var text1 = document.createTextNode("I'm sorry, it doesnt look like there are any providers that offer those services in this area - please try broadening your search. ");
cellSorry.appendChild(text1);
var returnLink = document.createElement("a");
returnLink.href = "#";
returnLink.appendChild(document.createTextNode("Click here"));
addEvent(returnLink, "click", function(e) { 
page.v.showStep(1);
cancelEvent(e);
});
cellSorry.appendChild(returnLink);
var text2 = document.createTextNode(" to return to the homepage");
cellSorry.appendChild(text2);
}
page.c.onStep2Submit = function() {
var selectedCars = page.m.getSelectedCars();
if (selectedCars.length == 0) {
showErrorPopupNoSelect($("service_search_2_table"), "Select at least one car type");
return;
};
XMLRPC.call("xmlrpc.php", page.c.onStep2SubmitSuccess, page.c.onFailure, page.c.onFailure, "find.providers", 
[sprintf("%s-%s-%s",$F("service_search_1_date_yy"),$F("service_search_1_date_mm"),$F("service_search_1_date_dd")),
$F("service_search_1_type"),
$F("service_search_1_location"),
$F("service_search_1_city"),
$F("service_search_1_passengers"),
selectedCars.join(",")]);
page.v.showLoading();
}


Class.extend(Control, Object);
function Control() {
Control.baseConstructor.call(this);  
this._classes = [];
}
Control.prototype.addClass = function(className) {
this._classes.push(className);
}
Control.prototype.replace = function(object) {
var control = document.createElement('div');
control.className = this._classes.join(" ");  
this.setup(control);
var parent = object.parentNode;
parent.replaceChild(control, object);
}
Control.prototype.setup = function(control) {
}


Class.extend(Gauge, Control);
function Gauge(max, value) {
Gauge.baseConstructor.call(this);
this._max = max;
this._value = value;
}
Gauge.prototype.getMax = function() {
return this._max;
}
Gauge.prototype.getValue = function() {
return this._value;
}
Gauge.prototype.getPercent = function() {
return Math.round(this._value / this._max * 100);
}

Class.extend(GaugeHorizontal, Gauge);
function GaugeHorizontal(max, value) {
GaugeHorizontal.baseConstructor.call(this, max, value);
this._eFull = null;
this._eValue = null;
}
GaugeHorizontal.prototype.setup = function(control) {
this._eFull = document.createElement('div');
this._eFull.className = 'full';
this._eValue = document.createElement('div');
this._eValue.className = 'value';
this.updateValue();
this._eFull.appendChild(this._eValue);
control.appendChild(this._eFull);
}
GaugeHorizontal.prototype.updateValue = function() {
this._eValue.style.width = this.getPercent().toString() + "%";
}



page.v.step3 = {};
page.v.renderStep3Data = function() {
page.v.step3.clear();
if (page.m.step3Data.length > 0) {
page.v.step3.renderServices($A(page.m.step3Data));
} else {
page.v.step3.renderSorryMessage();
};
}
page.v.step3.clear = function() {
var table = $("service_search_3_table");
var body = table.tBodies[0];
while (body.rows.length > 0) {
body.deleteRow(0);
};
}
page.v.step3.renderServices = function(data) {
var body = $("service_search_3_table").tBodies[0];
data.each(function(item, index) {
var row = body.insertRow(body.rows.length);
addEvent(row, "click", page.c.makeStep3RowClickCallback(index));
var cellName = row.insertCell(0);
cellName.innerHTML = item.name;
var cellRating = row.insertCell(1);
var div = document.createElement("div");
cellRating.appendChild(div);
var gauge = new GaugeHorizontal(10, item.rating);
gauge.addClass("rating_gauge");
gauge.replace(div);    
});
}
page.c.onStep3Submit = function() {
var selectedServices = page.m.getSelectedServices();
if (selectedServices.length == 0) {
showErrorPopupNoSelect($("service_search_2_table"), "Select at least one service");
return;
};
XMLRPC.call("xmlrpc.php", page.c.onStep3SubmitSuccess, page.c.onFailure, page.c.onFailure, "find.step4", 
[$F("service_search_1_location")]);
}
page.c.onStep3SubmitSuccess = function(response) {
page.m.step4Data = response.param;
page.v.renderStep4Data();
page.v.showStep(4);
}
page.c.onStep3RowToggle = function(i) {
page.m.step3Data[i].selected = !page.m.step3Data[i].selected;
var table = $("service_search_3_table");
if (page.m.step3Data[i].selected) {
ac(table.tBodies[0].rows[i], "selected");
} else {
rc(table.tBodies[0].rows[i], "selected");
};
}
page.v.step3.renderSorryMessage = function() {
var body = $("service_search_3_table").tBodies[0];
var row = body.insertRow(body.rows.length);
var cellSorry = row.insertCell(0);
cellSorry.colSpan = "2";
var text1 = document.createTextNode("I'm sorry, it doesnt look like there are any providers that offer those services in this area - please try broadening your search. ");
cellSorry.appendChild(text1);
var returnLink = document.createElement("a");
returnLink.href = "#";
returnLink.appendChild(document.createTextNode("Click here"));
addEvent(returnLink, "click", function(e) { 
page.v.showStep(1);
cancelEvent(e);
});
cellSorry.appendChild(returnLink);
var text2 = document.createTextNode(" to return to the homepage");
cellSorry.appendChild(text2);
}


page.v.renderStep4Data = function() {

if (page.m._waypointElements.length > 0) {
$("service_search_4_address").value = page.m._waypointElements[0].custom.value;
$("service_search_4_destination").value = page.m._waypointElements[page.m._waypointElements.length - 1].custom.value;
};
$("service_search_4_location").value = page.m.step4Data.location_name;
$("service_search_4_location").disabled = true;
$("service_search_4_email").value = page.m.step4Data.email;
$("service_search_4_email_confirm").value = page.m.step4Data.email;
}

page.c.onStep4SubmitSuccess = function() {
page.v.showDone();  
}
page.c.onStep4Submit = function() {
if (page.getForm("service_search_4").validate()) {
return;
};
var selectedServices = page.m.getSelectedServices();
XMLRPC.call("xmlrpc.php", page.c.onStep4SubmitSuccess, page.c.onFailure, page.c.onFailure, "request.quotes",
[sprintf("%s-%s-%s",$F("service_search_1_date_yy"),$F("service_search_1_date_mm"),$F("service_search_1_date_dd")),
{ type: $F("service_search_1_type"),
round_trip: $("service_search_1_round_trip").checked,
pickup: $F("service_search_1_pickup"),
arrival: $F("service_search_1_arrival") },
$F("service_search_1_city"),
$F("service_search_1_passengers"),
selectedServices.join(","),
$F("service_search_4_location"),
$F("service_search_4_address"),
$F("service_search_4_destination"),
$F("service_search_4_comments"),
$("service_search_4_contact_mode_1").checked ? 1 : 2,
$F("service_search_4_first_name"),
$F("service_search_4_last_name"),
$F("service_search_4_email"),
$F("service_search_4_phone"),
page.m.getSelectedCars()]);
}

page.v.showDone = function() {
page.v.hideLoading();
page.v.hideSteps();
$("service_search_block_stage_done").style.display = "block";
var list = $("search_done_provider_list");
list.innerHTML = "";
page.m.step3Data.each(function(provider) {
if (provider.selected) {
var li = document.createElement("li");
li.innerHTML = provider.name;
list.appendChild(li);
};
});
page.m.currentStep = 5;
}


;(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; }
var CONSTANTS = {
SEARCH_CONTENT_GAP: 10
}

page.m.currentStep = 1;
page.m.step2Data = [];
page.m.getSelectedServices = function() {
var selectedServices = [];
for (var i=0; i<page.m.step3Data.length; i++) {
var item = page.m.step3Data[i];
if (item.selected) { 
selectedServices.push(item.id);
};
}; 
return selectedServices;
}

page.c.makeStep2RowClickCallback = function(index) {
return function (e) { page.c.onStep2RowToggle(index); };
}
page.c.makeStep3RowClickCallback = function(index) {
return function (e) { page.c.onStep3RowToggle(index); };
}
page.c.onFailure = function() {
alert("Error fetching data from server. Please reload the page and retry");
}
page.c.addOnLoadHandler(function() {

addEvent($("service_search_2"), "submit", function (e) { cancelEvent(e); page.c.onStep2Submit(); });
addEvent($("service_search_3"), "submit", function (e) { cancelEvent(e); page.c.onStep3Submit(); });
addEvent($("service_search_4"), "submit", function (e) { cancelEvent(e); page.c.onStep4Submit(); });
[1,2,3,4].each(function(step, i) {
addEvent($("service_search_progress_bar_" + step.toString()), "click", function(e) { 
if (i >= page.m.currentStep) { return }; 
page.v.showStep(step); 
});
});
addEvent($("link_search_again"), "click", function(e) { cancelEvent(e); page.v.showStep(1); });

addEvent(window, "beforeunload", page.c.onUnload);

addEvent($("search_back"), "click", function(e) {
if (page.m.currentStep > 1) {
page.v.showStep(page.m.currentStep - 1);
};
});
});
page.c.onStep2RowToggle = function(i) {
page.m.step2Data[i].selected = !page.m.step2Data[i].selected;
var table = $("service_search_2_table");
if (page.m.step2Data[i].selected) {
ac(table.tBodies[0].rows[i], "selected");
} else {
rc(table.tBodies[0].rows[i], "selected");
};
}

page.v.hideDone = function() {
$("service_search_block_stage_done").style.display = "none";
}
page.v.hideLoading = function() {
$("service_search_block_stage_loading").style.display = "none";
}
page.v.hideSteps = function() {
[1,2,3,4].each(function(step) {
$("service_search_block_stage_"+step.toString()).style.display = "none";
rc($("service_search_progress_bar_"+step.toString()), "current");
});
}
page.v.showLoading = function() {
page.v.hideSteps();
page.v.hideDone();
$("service_search_block_stage_loading").style.display = "block";
}
page.v.showStep = function(number) {

$("layout_footer_custom").style.display = "none";
page.v.hideSteps();
var blockId = "service_search_block_stage_" + number.toString();
page.v.hideLoading();
page.v.hideDone();
$(blockId).style.display = "block";
ac($("service_search_progress_bar_" + number.toString()), "current");
$("step_image").src = Links.image(sprintf("step%s.gif", number.toString()));
page.m.currentStep = number;
}

page.c.makeOnCarClickHandler = function(id) {
return function(e) { 
page.c.onCarClick(e, id);
};
};
page.c.onUnload = function(e) {
if (page.m.currentStep > 1 && page.m.currentStep < 5) { 
var msg = "You have unfinished search in progress.\nIf you leave the page, you'll need to start searching from scratch.";
e.returnValue = msg;
return msg;
};
}
page.c.onCarClick = function(e, carId) {
XMLRPC.call(Links.xmlrpc(), page.c.onCarClickResponse, null, null,
"html.view.car.photo.bycar", [carId]);
cancelEvent(e);
}
page.c.onCarClickResponse = function(response) {
if (!response.isError()) {
var popup = new PopupCarPhotoDisplay(response.param.html, _("<b>Disclaimer:</b> The images on this slideshow are generic car photos and may differ from actual car model, type, body and make of the car and its color. If you need to view the actual photos of the car offered by the limo companies on this area, please see our <a href=\"http://www.limoquoter.com/directory/\">limo provider directory</a>."));
popup.show();
};
}






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';
}





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();
}

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.integer_range = function(element, minvalue, maxvalue, messages) {
var integerValue = parseInt(element.value);
if (isNaN(integerValue)) {
element.value = 0;
integerValue = 0;
};
var vars = { max_value: maxvalue == null ? "" : maxvalue.toString(), 
min_value: minvalue == null ? "" : minvalue.toString() };
if (minvalue != null && integerValue < minvalue) {
this.handleError(element, messages.too_small.subst(vars));
return false;
};
if (maxvalue != null && integerValue > maxvalue) {
this.handleError(element, messages.too_big.subst(vars));
return false;
};
return true;
}



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.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;
}











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;
}






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); });
};
};


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;
}






Validators.pair = function(element, element2, messages) {


if (element.value == "") {
return true;
};
if (element.value != element2.value) {
this.handleError(element, messages.pair_not_matched);
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;
};


