// Search field autocomplete
jQuery.autocomplete = function(input, options) {
(function($){
// Create a link to self
var me = this;
// Create jQuery object for input element
var $input = $(input).attr("autocomplete", "off");
// Apply inputClass if necessary
if (options.inputClass) $input.addClass(options.inputClass);
// Create results
var results = document.createElement("div");
// Create jQuery object for results
var $results = $(results);
$results.hide().addClass(options.resultsClass).css("position", "absolute");
if( options.width > 0 ) $results.css("width", options.width);
// Add to body element
$("body").append(results);
input.autocompleter = me;
var timeout = null;
var prev = "";
var active = -1;
var cache = {};
var keyb = false;
var hasFocus = false;
var lastKeyPressCode = null;
// flush cache
function flushCache(){
cache = {};
cache.data = {};
cache.length = 0;
};
// flush cache
flushCache();
// if there is a data array supplied
if( options.data != null ){
var sFirstChar = "", stMatchSets = {}, row = [];
// no url was specified, we need to adjust the cache length to make sure it fits the local data store
if( typeof options.url != "string" ) options.cacheLength = 1;
// loop through the array and create a lookup structure
for( var i=0; i < options.data.length; i++ ){
// if row is a string, make an array otherwise just reference the array
row = ((typeof options.data[i] == "string") ? [options.data[i]] : options.data[i]);
// if the length is zero, don't add to list
if( row[0].length > 0 ){
// get the first character
sFirstChar = row[0].substring(0, 1).toLowerCase();
// if no lookup array for this character exists, look it up now
if( !stMatchSets[sFirstChar] ) stMatchSets[sFirstChar] = [];
// if the match is a string
stMatchSets[sFirstChar].push(row);
}
}
// add the data items to the cache
for( var k in stMatchSets ){
// increase the cache size
options.cacheLength++;
// add to the cache
addToCache(k, stMatchSets[k]);
}
}
$input
.keydown(function(e) {
// track last key pressed
lastKeyPressCode = e.keyCode;
switch(e.keyCode) {
case 38: // up
e.preventDefault();
moveSelect(-1);
break;
case 40: // down
e.preventDefault();
moveSelect(1);
break;
case 9: // tab
case 13: // return
if( selectCurrent() ){
// make sure to blur off the current field
$input.get(0).blur();
e.preventDefault();
if (autocompleteEnter){
autocompleteEnter();
}
}
break;
default:
active = -1;
if (timeout) clearTimeout(timeout);
timeout = setTimeout(function(){onChange();}, options.delay);
break;
}
})
.focus(function(){
// track whether the field has focus, we shouldn't process any results if the field no longer has focus
hasFocus = true;
})
.blur(function() {
// track whether the field has focus
hasFocus = false;
hideResults();
});
hideResultsNow();
function onChange() {
// ignore if the following keys are pressed: [del] [shift] [capslock]
if( lastKeyPressCode == 46 || (lastKeyPressCode > 8 && lastKeyPressCode < 32) ) return $results.hide();
var v = $input.val();
if (v == prev) return;
prev = v;
if (v.length >= options.minChars) {
$input.addClass(options.loadingClass);
requestData(v);
} else {
$input.removeClass(options.loadingClass);
$results.hide();
}
};
function moveSelect(step) {
var lis = $("li", results);
if (!lis) return;
active += step;
if (active < 0) {
active = 0;
} else if (active >= lis.size()) {
active = lis.size() - 1;
}
lis.removeClass("ac-over");
$(lis[active]).addClass("ac-over");
// Weird behaviour in IE
// if (lis[active] && lis[active].scrollIntoView) {
// lis[active].scrollIntoView(false);
// }
};
function selectCurrent() {
var li = $("li.ac-over", results)[0];
if (!li) {
var $li = $("li", results);
if (options.selectOnly) {
if ($li.length == 1) li = $li[0];
} else if (options.selectFirst) {
li = $li[0];
}
}
if (li) {
selectItem(li);
return true;
} else {
return false;
}
};
function selectItem(li) {
if (!li) {
li = document.createElement("li");
li.extra = [];
li.selectValue = "";
}
var v = $.trim(li.selectValue ? li.selectValue : li.innerHTML);
input.lastSelected = v;
prev = v;
$results.html("");
$input.val(v);
hideResultsNow();
if (options.onItemSelect) setTimeout(function() { options.onItemSelect(li) }, 1);
};
// selects a portion of the input string
function createSelection(start, end){
// get a reference to the input element
var field = $input.get(0);
if( field.createTextRange ){
var selRange = field.createTextRange();
selRange.collapse(true);
selRange.moveStart("character", start);
selRange.moveEnd("character", end);
selRange.select();
} else if( field.setSelectionRange ){
field.setSelectionRange(start, end);
} else {
if( field.selectionStart ){
field.selectionStart = start;
field.selectionEnd = end;
}
}
field.focus();
};
// fills in the input box w/the first match (assumed to be the best match)
function autoFill(sValue){
// if the last user key pressed was backspace, don't autofill
if( lastKeyPressCode != 8 ){
// fill in the value (keep the case the user has typed)
$input.val($input.val() + sValue.substring(prev.length));
// select the portion of the value not typed by the user (so the next character will erase)
createSelection(prev.length, sValue.length);
}
};
function showResults() {
// get the position of the input field right now (in case the DOM is shifted)
var pos = findPos(input);
// either use the specified width, or autocalculate based on form element
var iWidth = $('.top-search').width()-2;
// reposition
$results.css({
width: parseInt(iWidth) + "px",
top: (pos.y + input.offsetHeight) + "px",
left: pos.x + "px"
}).show();
};
function hideResults() {
if (timeout) clearTimeout(timeout);
timeout = setTimeout(hideResultsNow, 200);
};
function hideResultsNow() {
if (timeout) clearTimeout(timeout);
$input.removeClass(options.loadingClass);
if ($results.is(":visible")) {
$results.hide();
}
if (options.mustMatch) {
var v = $input.val();
if (v != input.lastSelected) {
selectItem(null);
}
}
};
function receiveData(q, data) {
if (data) {
$input.removeClass(options.loadingClass);
results.innerHTML = "";
// if the field no longer has focus or if there are no matches, do not display the drop down
if( !hasFocus || data.length == 0 ) return hideResultsNow();
if ($.browser.msie) {
// we put a styled iframe behind the calendar so HTML SELECT elements don't show through
$results.append(document.createElement('iframe'));
}
results.appendChild(dataToDom(data));
// autofill in the complete box w/the first match as long as the user hasn't entered in more data
if( options.autoFill && ($input.val().toLowerCase() == q.toLowerCase()) ) autoFill(data[0][0]);
showResults();
} else {
hideResultsNow();
}
};
function parseData(data) {
if (!data) return null;
var parsed = [];
var rows = data.split(options.lineSeparator);
for (var i=0; i < rows.length; i++) {
var row = $.trim(rows[i]);
if (row) {
parsed[parsed.length] = row.split(options.cellSeparator);
}
}
return parsed;
};
function dataToDom(data) {
var ul = document.createElement("ul");
var num = data.length;
// limited results to a max number
if( (options.maxItemsToShow > 0) && (options.maxItemsToShow < num) ) num = options.maxItemsToShow;
for (var i=0; i < num; i++) {
var row = data[i];
if (!row) continue;
var li = document.createElement("li");
if (options.formatItem) {
li.innerHTML = options.formatItem(row, i, num);
li.selectValue = row[0];
} else {
li.innerHTML = row[0];
li.selectValue = row[0];
}
var extra = null;
if (row.length > 1) {
extra = [];
for (var j=1; j < row.length; j++) {
extra[extra.length] = row[j];
}
}
li.extra = extra;
ul.appendChild(li);
$(li).hover(
function() { $("li", ul).removeClass("ac-over"); $(this).addClass("ac-over"); active = $("li", ul).indexOf($(this).get(0)); },
function() { $(this).removeClass("ac-over"); }
).click(function(e) { e.preventDefault(); e.stopPropagation(); selectItem(this) });
}
return ul;
};
function requestData(q) {
if (!options.matchCase) q = q.toLowerCase();
var data = options.cacheLength ? loadFromCache(q) : null;
// recieve the cached data
if (data) {
receiveData(q, data);
// if an AJAX url has been supplied, try loading the data now
} else if( (typeof options.url == "string") && (options.url.length > 0) ){
$.get(makeUrl(q), function(data) {
data = parseData(data);
addToCache(q, data);
receiveData(q, data);
});
// if there's been no data found, remove the loading class
} else {
$input.removeClass(options.loadingClass);
}
};
function makeUrl(q) {
var url = options.url + "?q=" + encodeURI(q);
for (var i in options.extraParams) {
url += "&" + i + "=" + encodeURI(options.extraParams[i]);
}
return url;
};
function loadFromCache(q) {
if (!q) return null;
if (cache.data[q]) return cache.data[q];
if (options.matchSubset) {
for (var i = q.length - 1; i >= options.minChars; i--) {
var qs = q.substr(0, i);
var c = cache.data[qs];
if (c) {
var csub = [];
for (var j = 0; j < c.length; j++) {
var x = c[j];
var x0 = x[0];
if (matchSubset(x0, q)) {
csub[csub.length] = x;
}
}
return csub;
}
}
}
return null;
};
function matchSubset(s, sub) {
if (!options.matchCase) s = s.toLowerCase();
var i = s.indexOf(sub);
if (i == -1) return false;
return i == 0 || options.matchContains;
};
this.flushCache = function() {
flushCache();
};
this.setExtraParams = function(p) {
options.extraParams = p;
};
this.findValue = function(){
var q = $input.val();
if (!options.matchCase) q = q.toLowerCase();
var data = options.cacheLength ? loadFromCache(q) : null;
if (data) {
findValueCallback(q, data);
} else if( (typeof options.url == "string") && (options.url.length > 0) ){
$.get(makeUrl(q), function(data) {
data = parseData(data)
addToCache(q, data);
findValueCallback(q, data);
});
} else {
// no matches
findValueCallback(q, null);
}
}
function findValueCallback(q, data){
if (data) $input.removeClass(options.loadingClass);
var num = (data) ? data.length : 0;
var li = null;
for (var i=0; i < num; i++) {
var row = data[i];
if( row[0].toLowerCase() == q.toLowerCase() ){
li = document.createElement("li");
if (options.formatItem) {
li.innerHTML = options.formatItem(row, i, num);
li.selectValue = row[0];
} else {
li.innerHTML = row[0];
li.selectValue = row[0];
}
var extra = null;
if( row.length > 1 ){
extra = [];
for (var j=1; j < row.length; j++) {
extra[extra.length] = row[j];
}
}
li.extra = extra;
}
}
if( options.onFindValue ) setTimeout(function() { options.onFindValue(li) }, 1);
}
function addToCache(q, data) {
if (!data || !q || !options.cacheLength) return;
if (!cache.length || cache.length > options.cacheLength) {
flushCache();
cache.length++;
} else if (!cache[q]) {
cache.length++;
}
cache.data[q] = data;
};
function findPos(obj) {
var curleft = obj.offsetLeft || 0;
var curtop = obj.offsetTop || 0;
while (obj = obj.offsetParent) {
curleft += obj.offsetLeft
curtop += obj.offsetTop
}
return {x:curleft,y:curtop};
}
})(jQuery)
}
jQuery.fn.autocomplete = function(url, options, data) {
// Make sure options exists
options = options || {};
// Set url as option
options.url = url;
// set some bulk local data
options.data = ((typeof data == "object") && (data.constructor == Array)) ? data : null;
// Set default values for required options
options.inputClass = options.inputClass || "ac-input";
options.resultsClass = options.resultsClass || "ac-results";
options.lineSeparator = options.lineSeparator || "\n";
options.cellSeparator = options.cellSeparator || "|";
options.minChars = options.minChars || 1;
options.delay = options.delay || 400;
options.matchCase = options.matchCase || 0;
options.matchSubset = options.matchSubset || 1;
options.matchContains = options.matchContains || 0;
options.cacheLength = options.cacheLength || 1;
options.mustMatch = options.mustMatch || 0;
options.extraParams = options.extraParams || {};
options.loadingClass = options.loadingClass || "ac-loading";
options.selectFirst = options.selectFirst || false;
options.selectOnly = options.selectOnly || false;
options.maxItemsToShow = options.maxItemsToShow || -1;
options.autoFill = options.autoFill || false;
options.width = parseInt(options.width, 10) || 0;
this.each(function() {
var input = this;
new jQuery.autocomplete(input, options);
});
// Don't break the chain
return this;
}
jQuery.fn.autocompleteArray = function(data, options) {
return this.autocomplete(null, options, data);
}
jQuery.fn.indexOf = function(e){
for( var i=0; i element
this.select = select;
if (!this.select || this.select.tagName.toLowerCase() != 'select' || this.select.isInitialized)
return;
// puts current dropdown list into global collection
var i = 0;
while (i< DropDownList.selects.length) {
if (DropDownList.selects[i].select.id == elementID) {
DropDownList.selects[i] = this;
break;
}
i++;
}
if (i == DropDownList.selects.length)
DropDownList.selects.push(this);
options.width = options.width || getDimensions(this.select).width;
// hide the select field
this.select.style.display = 'none';
this.options = this.select.options;
// initialize options
this._initializeOptions(options);
this.select.isInitialized = true;
// create and build div structure
this.selectArea = document.createElement('div');
var leftDiv = document.createElement('div');
var rightDiv = document.createElement('div');
this.textContainer = document.createElement('div');
this.textContainer.id = this.select.id + 'Text';
this.textContainer.style.paddingLeft = '4px';
this.textContainer.style.cssFloat = 'left';
var text = document.createTextNode(this.emptyText);
this.selectArea.id = this.select.id + 'SelectArea';
this.selectArea.style.width = parseInt(this.width) + 'px';
this.selectArea.style.height = parseInt(this.height) + 'px';
addClass(this.selectArea, this.selectAreaStyle);
addClass(leftDiv, this.selectAreaLeftStyle);
addClass(rightDiv, this.selectAreaRightStyle);
addClass(this.textContainer, this.selectAreaCenterStyle)
this.textContainer.appendChild(text);
this.selectArea.appendChild(leftDiv);
this.selectArea.appendChild(rightDiv);
this.selectArea.appendChild(this.textContainer);
//insert select div
this.select.parentNode.insertBefore(this.selectArea, this.select);
var padding = 4;
if (navigator.appVersion.indexOf('MSIE 6') > 0)
padding = 10;
// fix IE6 bug
var containerWidth = this.width - padding - getDimensions(leftDiv).width - getDimensions(rightDiv).width;
this.textContainer.style.width = (containerWidth > 0) ? containerWidth + 'px': '0';
//build & place options div
this.optionsArea = document.createElement('ul');
this.optionsArea.id = this.select.id + 'Options';
if (this.dropDownSize > 0 && this.options.length > this.dropDownSize) {
this.optionsArea.style.height = (this.dropDownSize + 4) * this.optionHeight + 'px';
}
this.optionsArea.style.width = parseInt(this.width) - 2 + 'px';
this.optionsArea.className = this.optionsInvisibleStyle;
//get select's options and add to options div
for(var w = 0; w < this.options.length; w++) {
var optionHolder = document.createElement('li');
optionHolder.id = this.select.id + 'Option' + w;
optionHolder.style.paddingLeft = '4px';
if (this.options[w].text.length == 0)
this.options[w].text = this.emptyText;
if (w == 0)
this.defaultValue = this.options[w].text;
var optionTxt = document.createTextNode(this.options[w].text);
optionHolder.position = w;
optionHolder.onclick = function() {
self.selectOption(this.position);
self.close();
}
optionHolder.onmouseover = function() {
self.unhoverOption(self.hoveredIndex);
self.hoveredIndex = this.position;
self.hoverOption(self.hoveredIndex);
}
optionHolder.onmouseout = function() {
self.unhoverOption(this.position);
self.hoveredIndex = -1;
}
optionHolder.appendChild(optionTxt);
this.optionsArea.appendChild(optionHolder);
//check for pre-selected items
//r.aboltin disabled the pre-selected
//select behaviour
// because it was a redirection. And redirects on page refresh is not wanted
this.selectOption(0);
if(this.options[w].selected) {
//this.selectOption(w);
addClass(optionHolder, this.optionSelectedStyle);
}
}
//insert options div
//this.selectArea.appendChild(this.optionsArea);
this.select.parentNode.insertBefore(this.optionsArea, this.select);
// disables dropdown if it was disabled before creation
i = 0;
while (i< DropDownList.disable.length){
if (DropDownList.disable[i] == elementID){
this.disable();
DropDownList.disable.splice(i,1);
break;
}
i++;
}
this._initializeEventHandlers();
}
if (!DropDownList.selects)
DropDownList.selects = new Array();
if (!DropDownList.disable)
DropDownList.disable = new Array();
/*
* @description Returnd select entity.
* @method findControl
* @return {DropDownList entity}
*/
DropDownList.findControl = function(selectId){
for (var i = 0; i< DropDownList.selects.length; i++){
if (DropDownList.selects[i].select.id == selectId){
return DropDownList.selects[i];
}
}
return null;
};
/*
* @description disable select entity.
* @method disableControl
* @return {void}
*/
DropDownList.disableControl = function(selectId){
for (var i = 0; i< DropDownList.selects.length; i++){
if (DropDownList.selects[i].select.id == selectId){
DropDownList.selects[i].disable();
}
}
DropDownList.disable.push(selectId);
};
DropDownList.prototype = {
/**
* @description Initializes options.
* @method _initializeOptions
* @param {Array} options The options to initialize from.
* @return {void}
* @private
*/
_initializeOptions: function(options) {
// initialize CSS styles
var options = options || {};
this.selectAreaStyle = options.selectAreaStyle || 'select-area';
this.selectAreaOpenedStyle = options.selectAreaOpenedStyle || 'select-area-opened';
this.selectAreaLeftStyle = options.selectAreaLeftStyle || 'select-area-left';
this.selectAreaRightStyle = options.selectAreaRightStyle || 'select-area-right';
this.selectAreaCenterStyle = options.selectAreaCenterStyle || 'select-area-center';
this.optionsVisibleStyle = options.optionsVisibleStyle || 'select-options-visible';
this.optionsInvisibleStyle = options.optionsInvisibleStyle || 'select-options-invisible';
this.optionSelectedStyle = options.optionSelectedStyle || 'select-option-selected';
this.optionHoveredStyle = options.optionHoveredStyle || 'select-option-hovered';
// initialize other options
this.emptyText = options.emptyText || '-- Select --';
this.pleaseSelectText = options.pleaseSelectText || '';
this.optionsSeparator = options.optionsSeparator || ',';
this.optionsOverlap = options.optionsOverlap || 1;
this.width = options.width;
this.height = options.selectHeight || 21;
this.optionHeight = parseInt(options.optionHeight) || 15;
this.opened = false;
this.hoveredIndex = -1;
this.dropDownSize = parseInt(options.dropDownSize) || 0;
},
/**
* @description Initializes select event handlers.
* @method _initializeEventHandlers
* @return {void}
* @private
*/
_initializeEventHandlers: function() {
var self = this;
var body = document.getElementsByTagName('body')[0];
var selectKeyDownHandler = function(e) {
var e = e || window.event;
self._handleKeyDownEvent(e);
}
var bodyClickHandler = function() {
self.close();
if (self.addedKeyDownHandler) {
removeEventHandler(document, 'keydown', selectKeyDownHandler);
self.addedKeyDownHandler = false;
}
}
var selectAreaClickHandler = function() {
self.toggle();
if (self.opened) {
if (!self.addedKeyDownHandler) {
addEventHandler(document, 'keydown', selectKeyDownHandler);
self.addedKeyDownHandler = true;
}
}
else {
if (self.addedKeyDownHandler) {
removeEventHandler(document, 'keydown', selectKeyDownHandler);
self.addedKeyDownHandler = false;
}
}
}
var selectMouseOutHandler = function() {
if (!self.addedbodyClickHandler) {
addEventHandler(body, 'click', bodyClickHandler);
self.addedbodyClickHandler = true;
}
}
var selectMouseOverHandler = function() {
if (self.addedbodyClickHandler) {
removeEventHandler(body, 'click', bodyClickHandler);
self.addedbodyClickHandler = false;
}
}
addEventHandler(this.selectArea, 'click', selectAreaClickHandler);
addEventHandler(this.selectArea, 'mouseover', selectMouseOverHandler);
addEventHandler(this.selectArea, 'mouseout', selectMouseOutHandler);
addEventHandler(this.optionsArea, 'mouseover', selectMouseOverHandler);
addEventHandler(this.optionsArea, 'mouseout', selectMouseOutHandler);
},
/**
* @description Handles select key down events.
* @method _handleKeyDownEvent
* @param {Event} e The event to be handled from.
* @return {void}
* @private
*/
_handleKeyDownEvent: function(e) {
var keyCode = e.keyCode;
switch (keyCode) {
case 40: // down
this.unhoverOption(this.hoveredIndex);
this.hoveredIndex++;
if (this.hoveredIndex >= this.options.length)
this.hoveredIndex = 0;
this.hoverOption(this.hoveredIndex);
break;
case 38: // up
this.unhoverOption(this.hoveredIndex);
this.hoveredIndex--;
if (this.hoveredIndex < 0)
this.hoveredIndex = this.options.length - 1;
this.hoverOption(this.hoveredIndex);
break;
case 27: // escape
this.close();
break;
case 32: // space
this.selectOption(this.hoveredIndex);
break;
case 13: // enter
if (!this.options[this.hoveredIndex].selected)
this.selectOption(this.hoveredIndex);
this.close();
break;
default:
break;
}
},
/**
* @description Opens select.
* @method open
* @return {void}
*/
open: function() {
if (!this.disabled){
if (hasClass(this.optionsArea, this.optionsInvisibleStyle))
replaceClass(this.optionsArea, this.optionsInvisibleStyle, this.optionsVisibleStyle);
addClass(this.selectArea, this.selectAreaOpenedStyle);
if(this.pleaseSelectText)
{ this.textContainer.childNodes[0].nodeValue = this.pleaseSelectText; }
this.opened = true;
}
},
/**
* @description Closes select.
* @method close
* @return {void}
*/
close: function() {
if (hasClass(this.optionsArea, this.optionsVisibleStyle))
replaceClass(this.optionsArea, this.optionsVisibleStyle, this.optionsInvisibleStyle);
removeClass(this.selectArea, this.selectAreaOpenedStyle);
if(this.pleaseSelectText)
{
var text = '';
for (var k = 0; k < this.options.length; k++) {
if (this.options[k].selected)
text += this.options[k].text + this.optionsSeparator;
}
if (text.length > this.optionsSeparator.length)
text = text.substring(0, text.length - this.optionsSeparator.length);
else if (text.length == 0)
text = this.emptyText;
var newText = document.createTextNode(text);
this.textContainer.replaceChild(newText, this.textContainer.childNodes[0]);
}
this.opened = false;
},
/**
* @description Disables select.
* @method disable
* @return {void}
*/
disable: function(){
this.disabled = true;
this.textContainer.innerHTML = this.defaultValue;
},
/*
* @description Enables select.
* @method enable
* @return {void}
*/
enable: function(){
this.disabled = false;
},
/**
* @description Toggle select.
* @method toggle
* @return {void}
*/
toggle: function() {
this.opened ? this.close() : this.open();
},
/**
* @description Selects specified option.
* @method selectOption
* @param {int} selectedIndex The option index to be selected.
* @return {void}
*/
selectOption: function(selectedIndex) {
//feed selected option to the actual select field
if (this.select.multiple) {
var option = document.getElementById(this.select.id + 'Option' + selectedIndex);
if (option) {
this.options[selectedIndex].selected = !this.options[selectedIndex].selected;
this.options[selectedIndex].selected ? addClass(option, this.optionSelectedStyle) : removeClass(option, this.optionSelectedStyle);
}
// modify selected option
var text = '';
for (var k = 0; k < this.options.length; k++) {
if (this.options[k].selected)
text += this.options[k].text + this.optionsSeparator;
}
if (text.length > this.optionsSeparator.length)
text = text.substring(0, text.length - this.optionsSeparator.length);
else if (text.length == 0)
text = this.emptyText;
var newText = document.createTextNode(text);
this.textContainer.replaceChild(newText, this.textContainer.childNodes[0]);
if((selectedIndex>0)&&(this.options[selectedIndex].attributes["value"]))
document.location.href=this.options[selectedIndex].attributes["value"].nodeValue;
//open(his.options[selectedIndex].attributes["value"].nodeValue);
}
else {
for (var k = 0; k < this.options.length; k++) {
if (k == selectedIndex) {
this.options[k].selected = true;
this.select.selectedIndex = selectedIndex;
var option = document.getElementById(this.select.id + 'Option' + k);
if (option)
addClass(option, this.optionSelectedStyle);
}
else {
this.options[k].selected = false;
var option = document.getElementById(this.select.id + 'Option' + k);
if (option)
removeClass(option, this.optionSelectedStyle);
}
//show selected option
var newText = document.createTextNode(this.options[selectedIndex].text);
this.textContainer.replaceChild(newText, this.textContainer.childNodes[0]);
}
}
if((selectedIndex>0)&&(this.options[selectedIndex].attributes["value"]))
document.location.href=this.options[selectedIndex].attributes["value"].nodeValue;
//open(this.options[selectedIndex].attributes["value"].nodeValue);
if (this.select.onchange){
var oldDisplay = this.select.style.display;
this.select.style.display = 'block';
if ( this.select.fireEvent ) // IE 5.5(WIN)
{
this.select.fireEvent("onChange");
}
else // Mozilla, Safari etc.
{
var evt = document.createEvent("HTMLEvents");
evt.initEvent("change",true,true);
this.select.dispatchEvent( evt );
}
this.select.style.display = oldDisplay;
}
},
/**
* @description Hovers specified option.
* @method hoverOption
* @param {int} hoveredIndex The option index to be hovered.
* @return {void}
*/
hoverOption: function(hoveredIndex) {
if (hoveredIndex >= 0 && hoveredIndex < this.options.length) {
var hoveredOption = document.getElementById(this.select.id + 'Option' + hoveredIndex);
addClass(hoveredOption, this.optionHoveredStyle);
}
},
/**
* @description Unhovers specified option.
* @method unhoverOption
* @param {int} hoveredIndex The option index to be unhovered.
* @return {void}
*/
unhoverOption: function(hoveredIndex) {
if (hoveredIndex >= 0 && hoveredIndex < this.options.length) {
var hoveredOption = document.getElementById(this.select.id + 'Option' + hoveredIndex);
removeClass(hoveredOption, this.optionHoveredStyle);
}
}
}
//Useful functions
/**
* @description Returns element dimensions.
* @method getDimensions
* @param {HTMLElement} el The DOM elementement to get dimensions of.
* @return {Array} HTMLElement offset.
*/
function getDimensions(el) {
if (el.style.display != 'none' && el.style.display != null) // Safari bug
return {width: el.offsetWidth, height: el.offsetHeight};
// All *Width and *Height properties give 0 on els with display none,
// so enable the el temporarily
var els = el.style;
var originalVisibility = els.visibility;
var originalPosition = els.position;
var originalDisplay = els.display;
els.visibility = 'hidden';
els.position = 'absolute';
els.display = 'block';
var originalWidth = el.clientWidth;
var originalHeight = el.clientHeight;
els.display = originalDisplay;
els.position = originalPosition;
els.visibility = originalVisibility;
return {width: originalWidth, height: originalHeight};
}
/**
* @description Returns an HTMLElement offset.
* @method getOffset
* @param {HTMLElement} el The DOM element to get offset of.
* @return {Array} HTMLElement offset.
*/
function getOffset(el) {
var valueT = 0, valueL = 0;
do {
valueT += el.offsetTop || 0;
valueL += el.offsetLeft || 0;
el = el.offsetParent;
if (el) {
if (el.tagName.toLowerCase() == 'body')
break;
var pos = el.style.position;
if (pos == 'relative' || pos == 'absolute')
break;
}
} while (el);
return {left: valueL, top: valueT};
}
/**
* @description Determines whether an HTMLElement has the given className.
* @method hasClass
* @param {HTMLElement} el The DOM element to test.
* @param {String} className The class name to search for.
* @return {Boolean | Array} A boolean value or array of boolean values.
*/
function hasClass(el, className) {
var elClassName = el.className;
return (elClassName.length > 0 && (elClassName == className || new RegExp("(^|\\s)" + className + "(\\s|$)").test(elClassName)));
}
/**
* @description Adds a class name to a given el.
* @method addClass
* @param {HTMLElement} el The DOM element to add the class to.
* @param {String} className The class name to add to the class attribute.
* @return {void}
*/
function addClass(el, className) {
if (!hasClass(el, className))
el.className += (el.className ? ' ' : '') + className;
}
/**
* @description Removes a class name from a given el.
* @method removeClass
* @param {HTMLElement} el The DOM element or to remove the class from.
* @param {String} className The class name to remove from the class attribute.
* @return {void}
*/
function removeClass(el, className) {
el.className = el.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').replace(/^\s+/, '').replace(/\s+$/, '');
}
/**
* @description Replaces a class name fom a given el.
* @method removeClass
* @param {HTMLElement} el The DOM elementement to remove the class from.
* @param {String} oldClassName The class name to remove from the class attribute.
* @param {String} newClassName The class name to add to the class attribute.
* @return {void}
*/
function replaceClass(el, oldClassName, newClassName) {
removeClass(el, oldClassName);
addClass(el, newClassName);
}
/**
* @description Adds a DOM event directly without the caching, cleanup, scope adj, etc.
* @method addEventHandler
* @param {HTMLElement} el The DOM element to bind the handler to.
* @param {String} name The name of event handler.
* @param {function} handler The callback to invoke.
* @return {void}
*/
function addEventHandler(el, name, handler) {
el.addEventListener ? el.addEventListener(name, handler, false) : el.attachEvent('on' + name, handler);
}
/**
* @description Removes a DOM event.
* @method removeEventHandler
* @param {HTMLElement} el The DOM element to bind the handler to.
* @param {String} name The name of event handler.
* @param {function} handler The callback to invoke.
* @return {void}
*/
function removeEventHandler(el, name, handler) {
el.removeEventListener ? el.removeEventListener(name, handler, false) : el.detachEvent('on' + name, handler);
}
// MainMenu
(function($){
var Menu = function( el, settings ){
var $menu = $(el);
var $container = $( settings.container );
var menuLeftOffset = $menu.offset().left;
var menuTopOffset = $menu.offset().top;
// add hover classes
$('li', $menu).hover(function(){ $(this).addClass('hover'); },function(){ $(this).removeClass('hover') });
//$menu.children().hover(function(){ $(this).addClass('hover') },function(){ $(this).removeClass('hover') });
// fix bottom li
$('ul', $menu).each(function(){
$(this).children('li:last').addClass('last');
});
var showInner = function(){
var self = this;
var $parent = $(this).parent();
var $inner = $(this).children('ul');
this.position = function(){
var deltaX = settings.relatived ? -($parent.offset().left) : 0;
var deltaY = settings.relatived ? 0 : $(self).offset().top;
var vertical = false;
for( var i = 0; i < settings.vertical.length; i++ ){
if( $inner.is( settings.vertical[i] ) ){
vertical = true;
if( ($inner.width() + $(self).offset().left) > $container.width() + $container.offset().left )
$inner.css({ left: $(self).offset().left + deltaX - $inner.width() + $(self).width(), top: $(self).height() + deltaY });
else
$inner.css({ left: $(self).offset().left + deltaX, top: $(self).height() + deltaY });
}
}
if( ! vertical ){
for( var i = 0; i < settings.horizontal.length; i++ ){
if( $inner.is( settings.horizontal[i] ) ){
if( ($inner.width() + $(self).width() + $(self).offset().left) > $container.width() + $container.offset().left )
$inner.css({ left: -( $inner.width() + settings.rightOffset + 1 ), top: $(self).offset().top - $parent.offset().top });
else
$inner.css({ left: $parent.width() + settings.leftOffset , top: $(self).offset().top - $parent.offset().top });
}
}
}
};
if(typeof this.timer != 'undefined' && typeof this.$inner != 'undefined'){
clearTimeout( this.timer );
}else{
self.$inner = $inner;
this.timer = false;
this.resized = false;
var width = self.$inner.width();
$inner.children('li').each(function(){
$(this).width( width );
$(this).children('a').each(function(){
$(this).width( width - 34 );
});
});
this.position();
$inner.mousemove( function(){ showInner.apply( self ) } );
}
if( typeof this.resized == 'undefined' || this.resized ){
this.resized = false;
this.position();
}
this.$inner.css('visibility','visible');
if( settings.showAnimation )
this.$inner.fadeIn( settings.showAnimation );
else
this.$inner.show();
};
var hideInner = function( ){
var self = this;
var $inner = this.$inner;
if( ! $inner )
return;
var hide = function(){
if( settings.hideAnimation )
$inner.fadeOut( settings.hideAnimation, function(){ $(this).css('visibility','hidden') } );
else {
$inner.hide().css('visibility','hidden');
}
};
this.timer = setTimeout( hide, settings.hideTimeout );
};
// show inner on hover
$('li:has(ul)', $menu).mousemove( showInner ).mouseout( hideInner );
$(window).resize(function(){
$('li:has(ul)', $menu).each(function(){
this.resized = true;
});
});
};
$.extend($.fn, {
menu: function( settings ){
var settings = $.extend({
showAnimation: false,
hideAnimation: 100,
hideTimeout: 100,
container: 'body',
horizontal: [],
vertical: [],
relatived: false,
rightOffset: -1,
leftOffset: 0
}, settings);
return $(this).each(function(){ new Menu( this, settings); });
}
});
// provide backwards compability
$.fn.Menu = $.fn.menu;
})(jQuery);
(function($) {
$(function(){
if ($.browser.msie || $.browser.opera) {
$('input.searchinput').keydown (checkForSearchEnter);
$('input.searchinput').keypress ( function () {
// Opera is fun
}
);
} else {
$('input.searchinput').keypress (checkForSearchEnter);
}
function checkForSearchEnter (event) {
if (event.keyCode == 13){
if ($.browser.opera){
$('form').submit(function(){
return false; });
}
event.preventDefault();
$('input.searchbutton').click();
return false;
}
}
});
})
(jQuery);
function autocompleteEnter () {
jQuery('input.searchbutton').click();
}
// Other files are attached here
// sifr/sifr.js
/* sIFR 2.0.2
Copyright 2004 - 2006 Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben
This software is licensed under the CC-GNU LGPL
*/
var hasFlash=function(){var a=6;if(navigator.appVersion.indexOf("MSIE")!=-1&&navigator.appVersion.indexOf("Windows")>-1){document.write(' \n');if(window.hasFlash!=null)return window.hasFlash}if(navigator.mimeTypes&&navigator.mimeTypes["application/x-shockwave-flash"]&&navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){var b=(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description;return parseInt(b.charAt(b.indexOf(".")-1))>=a}return false}();String.prototype.normalize=function(){return this.replace(/\s+/g," ")};if(Array.prototype.push==null){Array.prototype.push=function(){var i=0,a=this.length,b=arguments.length;while(i`]*)(#|\.|\>|\`)(.+)$/;function r(s,t){var u=s.split(/\s*\,\s*/);var v=[];for(var i=0;i")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i":if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i");l=l.concat(j)}return l;case "`":h=m(d,f[1]);for(i=0,n=h.length;i")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i-1,b:g.indexOf("safari")>-1,c:navigator.product!=null&&navigator.product.toLowerCase().indexOf("konqueror")>-1,d:g.indexOf("opera")>-1,e:al.contentType!=null&&al.contentType.indexOf("xml")>-1,f:true,g:true,h:null,i:null,j:null,k:null};f.l=f.a||f.c;f.m=!f.a&&navigator.product!=null&&navigator.product.toLowerCase()=="gecko";if(f.m&&g.match(/.*gecko\/(\d{8}).*/))f.j=new Number(g.match(/.*gecko\/(\d{8}).*/)[1]);f.n=g.indexOf("msie")>-1&&!f.d&&!f.l&&!f.m;f.o=f.n&&g.match(/.*mac.*/)!=null;if(f.d&&g.match(/.*opera(\s|\/)(\d+\.\d+)/))f.i=new Number(g.match(/.*opera(\s|\/)(\d+\.\d+)/)[2]);if(f.n||(f.d&&f.i<7.6))f.g=false;if(f.a&&g.match(/.*applewebkit\/(\d+).*/))f.k=new Number(g.match(/.*applewebkit\/(\d+).*/)[1]);if(am.hasFlash&&(!f.n||f.o)){var aj=(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description;f.h=parseInt(aj.charAt(aj.indexOf(".")-1))}if(g.match(/.*(windows|mac).*/)==null||f.o||f.c||(f.d&&(g.match(/.*mac.*/)!=null||f.i<7.6))||(f.b&&f.h<7)||(!f.b&&f.a&&f.k<312)||(f.m&&f.j<20020523))f.f=false;if(!f.o&&!f.m&&al.createElementNS)try{al.createElementNS(a,"i").innerHTML=""}catch(e){f.e=true}f.p=f.c||(f.a&&f.k<312);return f}();function at(){return{bIsWebKit:f.a,bIsSafari:f.b,bIsKonq:f.c,bIsOpera:f.d,bIsXML:f.e,bHasTransparencySupport:f.f,bUseDOM:f.g,nFlashVersion:f.h,nOperaVersion:f.i,nGeckoBuildDate:f.j,nWebKitVersion:f.k,bIsKHTML:f.l,bIsGecko:f.m,bIsIE:f.n,bIsIEMac:f.o,bUseInnerHTMLHack:f.p}}if(am.hasFlash==false||!al.getElementsByTagName||!al.getElementById||(f.e&&(f.p||f.n)))return{UA:at()};function af(e){if((!k.bAutoInit&&(am.event||e)!=null)||!l(e))return;b=true;for(var i=0,h=ah.length;i';s++}else if(as(v,"br"))u+="
";if(v.hasChildNodes()){y=o(v,null,r,s,t);u+=y.u;s=y.s;t=y.t}if(as(v,"a"))u+=""}w=v;v=v.nextSibling;if(q!=null){x=w.parentNode.removeChild(w);q.appendChild(x)}}return{"u":u,"s":s,"t":t}}function A(B){if(al.createElementNS&&f.g)return al.createElementNS(a,B);return al.createElement(B)}function C(D,E,z){var p=A("param");p.setAttribute("name",E);p.setAttribute("value",z);D.appendChild(p)}function F(p,G){var H=p.className;if(H==null)H=G;else H=H.normalize()+(H==""?"":" ")+G;p.className=H}function aq(ar){var a=ak;if(k.bHideBrowserText==false)a=al.getElementsByTagName("body")[0];if((k.bHideBrowserText==false||ar)&&a)if(a.className==null||a.className.match(/\bsIFR\-hasFlash\b/)==null)F(a, "sIFR-hasFlash")}function j(I,J,K,L,M,N,O,P,Q,R,S,r,T){if(!l())return ah.push(arguments);aq();named.extract(arguments,{sSelector:function(ap){I=ap},sFlashSrc:function(ap){J=ap},sColor:function(ap){K=ap},sLinkColor:function(ap){L=ap},sHoverColor:function(ap){M=ap},sBgColor:function(ap){N=ap},nPaddingTop:function(ap){O=ap},nPaddingRight:function(ap){P=ap},nPaddingBottom:function(ap){Q=ap},nPaddingLeft:function(ap){R=ap},sFlashVars:function(ap){S=ap},sCase:function(ap){r=ap},sWmode:function(ap){T=ap}});var U=parseSelector(I);if(U.length==0)return false;if(S!=null)S="&"+S.normalize();else S="";if(K!=null)S+="&textcolor="+K;if(M!=null)S+="&hovercolor="+M;if(M!=null||L!=null)S+="&linkcolor="+(L||K);if(O==null)O=0;if(P==null)P=0;if(Q==null)Q=0;if(R==null)R=0;if(N==null)N="#FFFFFF";if(T=="transparent")if(!f.f)T="opaque";else N="transparent";if(T==null)T="";var p,V,W,X,Y,Z,aa,ab,ac;var ad=null;for(var i=0,h=U.length;i'].join("");else p.innerHTML=[''].join('')}else{if(f.d){ab=A("object");ab.setAttribute("data",J);C(ab,"quality","best");C(ab,"wmode",T);C(ab,"bgcolor",N)}else{ab=A("embed");ab.setAttribute("src",J);ab.setAttribute("quality","best");ab.setAttribute("flashvars",Z);ab.setAttribute("wmode",T);ab.setAttribute("bgcolor",N)}ab.setAttribute("sifr","true");ab.setAttribute("type","application/x-shockwave-flash");ab.className="sIFR-flash";if(!f.l||!f.e)ad=ab.cloneNode(true)}}else ab=ad.cloneNode(true);if(f.g){if(f.d)C(ab,"flashvars",Z);else ab.setAttribute("flashvars",Z);ab.setAttribute("width",V);ab.setAttribute("height",W);ab.style.width=V+"px";ab.style.height=W+"px";p.appendChild(ab)}p.appendChild(aa);if(f.p)p.innerHTML+=""}if(f.n&&k.bFixFragIdBug)setTimeout(function(){al.title=d},0)}function ai(){d=al.title}function ae(){if(k.bIsDisabled==true)return;c=true;if(k.bHideBrowserText)aq(true);if(am.attachEvent)am.attachEvent("onload",af);else if(!f.c&&(al.addEventListener||am.addEventListener)){if(f.a&&f.k>=132&&am.addEventListener)am.addEventListener("load",function(){setTimeout("sIFR({})",1)},false);else{if(al.addEventListener)al.addEventListener("load",af,false);if(am.addEventListener)am.addEventListener("load",af,false)}}else if(typeof am.onload=="function"){var ag=am.onload;am.onload=function(){ag();af()}}else am.onload=af;if(!f.n||am.location.hash=="")k.bFixFragIdBug=false;else ai()}k.UA=at();k.bAutoInit=true;k.bFixFragIdBug=true;k.replaceElement=j;k.updateDocumentTitle=ai;k.appendToClassName=F;k.setup=ae;k.debug=function(){aq(true)};k.debug.replaceNow=function(){ae();k()};k.bIsDisabled=false;k.bHideBrowserText=true;return k}();
if(typeof sIFR == "function" && !sIFR.UA.bIsIEMac){
sIFR.setup();
};
// sifr/setsifr.js
if(typeof sIFR == "function"){
sIFR.replaceElement(".main-site-content h1", applicationPath +"/files/js/sifr/myriad.swf", "#0d0d0d", null, null, null, 0, 0, 0, 0, null, null, 'transparent');
};
// interface.js
function setClass(obj, cl){
if (obj != null && obj.className!=cl) {
obj.className = cl;
}
}
function makeGray (obj, state, text){
if (state && (obj.value == '')){
obj.value = text;
} else if (!state && (obj.value == text)){
obj.value = '';
}
}
function changeDisplayById(objId){
for (c = 0; c < changeDisplayById.arguments.length; c++){
obj = document.getElementById(changeDisplayById.arguments[c]);
if (obj.style.display == 'none') obj.style.display = 'block';
else obj.style.display = 'none';
}
}
function gotoURL(url, target, callback){
if (!url) url = "/";
if(typeof callback == "function")
callback(url);
if(target && target!='_self'){
popupURL(url, target);
}
else{
if (window.event){
var src = window.event.srcElement;
if((src.tagName != 'A') && ((src.tagName != 'IMG') || (src.parentElement.tagName != 'A'))){
if (window.event.shiftKey) window.open(url);
else document.location = url;
}
} else document.location = url;
}
}
function popupURL(url, options){
window.open(url, 'CoolWindow', options);
}
function getLeftPos(obj){
var res = 0;
while (obj){
res += obj.offsetLeft;
obj = obj.offsetParent;
}
return res;
}
function getTopPos(obj){
var res = 0;
while (obj){
res += obj.offsetTop;
obj = obj.offsetParent;
}
return res;
}
function CheckAll(formObj, checkName, checkVal){
var el = formObj.elements;
for (count = 0; count < el.length; count++)
if (el[count].name == checkName + '[]')
if (!el[count].disabled) el[count].checked = checkVal;
}
function ExamAll(formObj, checkName, resName){
var checkCount = 0;
var boxCount = 0;
var el = formObj.elements;
for (count = 0; count < el.length; count++)
if (el[count].name == checkName + '[]'){
boxCount++;
if (el[count].checked || el[count].disabled) checkCount++;
}
formObj.elements[resName].checked = (checkCount == boxCount);
}
function CheckAll(checkName, checkVal)
{
var checkCount = 0;
var el = document.forms[0].elements;
for (count = 0; count < el.length; count++)
{
if (el[count].name == checkName)
{
if (!el[count].disabled)
{
el[count].checked = checkVal;
}
checkCount++;
}
}
}
function checkAllByPrefix(checkName, checkVal)
{
var checkCount = 0;
var el = document.forms[0].elements;
for (count = 0; count < el.length; count++)
{
if (el[count].name != null && el[count].name.indexOf(checkName) == 0)
{
if (!el[count].disabled)
{
el[count].checked = checkVal;
}
checkCount++;
}
}
}
function ExamAll(checkName, resName)
{
var checkCount = 0;
var boxCount = 0;
var el = document.forms[0].elements;
for (count = 0; count < el.length; count++)
{
if (el[count].name == checkName)
{
boxCount++;
if (el[count].checked || el[count].disabled) checkCount++;
}
}
if (document.forms[0].elements[resName])
document.forms[0].elements[resName].checked = (checkCount == boxCount);
}
function examAllByPrefix(checkName, resName)
{
var checkCount = 0;
var boxCount = 0;
var el = document.forms[0].elements;
for (count = 0; count < el.length; count++)
{
if (el[count].name != null && el[count].name.trim() != '' && el[count].name.indexOf(checkName) == 0)
{
boxCount++;
if (el[count].checked || el[count].disabled) checkCount++;
}
}
if (document.forms[0].elements[resName])
document.forms[0].elements[resName].checked = (checkCount == boxCount);
}
function chbIsAllEmpty(formObj, checkName){
var checkCount = 0;
var boxCount = 0;
var el = formObj.elements;
for (count = 0; count < el.length; count++)
if (el[count].name == checkName + '[]'){
boxCount++;
if (el[count].checked) checkCount++;
}
return(checkCount == 0);
}
function chbIsOnlyOne(formObj, checkName){
var checkCount = 0;
var boxCount = 0;
var el = formObj.elements;
for (count = 0; count < el.length; count++){
if (el[count].name == checkName + '[]'){
boxCount++;
if (el[count].checked) checkCount++;
}
}
return(checkCount == 1);
}
function disableAll(){
for (c1 = 0; c1 < document.forms.length; c1++){
var formElements = document.forms[c1].elements;
for (c2 = 0; c2 < formElements.length; c2++) formElements[c2].disabled = true;
}
}
// name - cookie name
// value - cookie value
// [expires] - Date object (by default cookie expires at the end of browser session)
// [path]
// [domain]
// [secure]
function setCookie(name, value, expires, path, domain, secure)
{
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "")
if ( (name + "=" + escape(value)).length <= 4000)
document.cookie = curCookie
}
// name - cookie name
function getCookie(name)
{
var prefix = name + "="
var cookieStartIndex = document.cookie.indexOf(prefix)
if (cookieStartIndex == -1)
return null
var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
if (cookieEndIndex == -1)
cookieEndIndex = document.cookie.length
return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}
// name - cookie name
// [path]
// [domain]
function deleteCookie(name, path, domain)
{
if (getCookie(name))
{
document.cookie = name+"="+
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT"
}
}
function preLoad() {
if(document.images) {
var argLen = arguments.length;
for(var i = 0; i < argLen; i++) {
var arg = arguments[i];
self[arg] = new Image();
self[arg].src = arg;
}
}
}
function ch_img(obj, img ) {
if (self[img]) {
obj.src = self[img].src;
}
}
function mm_act(obj,img,cl,num,selected){
if ( cl == 'item act' )
showMenu(obj, num);
else
hideMenu(obj, num);
if ( selected ) return;
while (obj) {
obj = obj.childNodes[0];
if ( obj && obj.tagName == 'IMG') {
ch_img(obj,img);
break;
}
}
while (obj && cl!='') {
obj = obj.parentNode;
if ( obj && obj.tagName == 'DIV') {
obj.className = cl;
break;
}
}
}
function popup_view_image (url, w, h, wname) {
scr_left = 0;
scr_top = 0;
w *= 1.4;
h *= 1.4;
wname = wname;
new_window = window.open (url, wname , "title=image,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,width="+w+",height="+h+",top="+scr_top+",left="+scr_left);
new_window.focus();
return new_window;
}
function popup_view (url, w, h, wname) {
scr_left = 0;
scr_top = 0;
wname = wname;
new_window = window.open (url, wname , "title=image,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,width="+w+",height="+h+",top="+scr_top+",left="+scr_left);
new_window.focus();
return new_window;
}
function openPopupWithARgs (url, w, h, wname, openArgs) {
scr_left = 0;
scr_top = 0;
new_window = window.open (url, wname , "title=image,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,width="+w+",height="+h+",top="+scr_top+",left="+scr_left);
window.setTimeout(function() {
try {
new_window.setOpenArgs(openArgs);
}
catch(e) {
new_window.close();
}
}, 3000);
new_window.focus();
return new_window;
}
function LTrim(str)
{
var whitespace = new String(" \t\n\r");
var s = new String(str);
if (whitespace.indexOf(s.charAt(0)) != -1) {
var j=0, i = s.length;
while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
j++;
s = s.substring(j, i);
}
return s;
}
function RTrim(str)
{
var whitespace = new String(" \t\n\r");
var s = new String(str);
if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
var i = s.length - 1;
while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
i--;
s = s.substring(0, i+1);
}
return s;
}
function Trim(str)
{
return RTrim(LTrim(str));
}
function headerKeydown(Url, Header)
{
var reg = /[\x21-\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5e\x60\x7b\x7d\xa3]/ig;
var regAnd = /&/ig;
var regS = /[\s\x2f]/ig;
var val = Trim(Header.value.toLowerCase()).replace(reg,"").replace(regAnd,"and").replace(regS,"-").replace(/\x2D{2,}/ig,'-');
//Url.value = (val.length > 0) ? val + ".aspx" : "";
Url.value = val;
}
function headerKeydownCMS(Url, Header, Postfix)
{
var reg = /[\x21-\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5e\x60\x7b\x7d\xa3]/ig;
var regAnd = /&/ig;
var regS = /[\s\x2f]/ig;
var val = Trim(Header.value.toLowerCase()).replace(reg,"").replace(regAnd,"and").replace(regS,"-").replace(/\x2D{2,}/ig,'-');
//Url.value = (val.length > 0) ? val + ".aspx" : "";
Url.value = val + Postfix;
}
function checkSelection(checkName) {
var checkCount = 0;
var el = document.forms[0].elements;
for (count = 0; count < el.length; count++)
{
if (el[count].name != null && el[count].name.indexOf(checkName) == 0)
{
if (!el[count].disabled)
{
if (el[count].checked) {
checkCount++;
}
}
}
}
if (checkCount == 0) {
alert('You must check any item!');
return false;
}
return true;
}
function deleteConfirmation(checkName) {
if (!checkSelection(checkName)) {
return false;
}
if (!confirm('You are trying to delete item(s). \n\nAre you sure you wish to continue?')) {
return false;
}
else {
return true;
}
}
function deleteContactConfirmation() {
if (!confirm('You are trying to delete item(s). \n\nAre you sure you wish to continue?')) {
return false;
}
else {
return true;
}
}
function showConfirmation(text) {
return confirm(text);
}
var checkedCount = 0;
function updateCheckedCount(checkBox) {
if (checkBox.checked) {
checkedCount += 1;
}
else {
checkedCount -= 1;
}
}
var allCheckedChildren = null;
function checkAllChild(id, checked) {
var cell = document.getElementById('subItems' + id);
if (cell != null) {
checkChild(cell, checked);
}
}
function checkChild(element, checked) {
if (element.tagName != 'TABLE' && element.tagName != 'TBODY' && element.tagName != 'TR' && element.tagName != 'TD' && element.tagName != 'DIV') {
return;
}
if (element.childNodes != null) {
var i = 0;
for (i = 0; i < element.childNodes.length; i++) {
if (element.childNodes[i].type == 'checkbox') {
element.childNodes[i].checked = checked;
element.childNodes[i].disabled = checked;
}
checkChild(element.childNodes[i], checked);
}
}
}
function deleteFromTreeConfirmation() {
if (checkedCount <= 0) {
alert('You must check any item!');
return false;
}
if (!confirm('You are trying to delete item(s). \n\nAre you sure you wish to continue?')) {
return false;
}
else {
return true;
}
}
function checkedChanged(id, list)
{
if (typeof list[id] != "undefined" && list[id].checked)
{
for (var i=0; i 0) {
textAreas += ",";
}
textAreas += textAreaId;
}
function getFrameContent(frame) {
return frame.contentDocument;
}
function fckEditorOnFocus(editorInstance) {
changeSaveButtonEnabled(true);
}
function initializetextArea(textAreaId) {
if (isOpera()) {
for (i = 0; i < 10; i++) {
textAreaId = textAreaId.replace('_', '$');
}
textArea = document.getElementById(textAreaId);
if (textArea == null) {
return true;
}
textArea.setAttribute('onkeyup','changeSaveButtonEnabled(true)');
return true;
}
if (window.FCKeditorAPI == null) {
return false;
}
var editorInstance = FCKeditorAPI.GetInstance(textAreaId) ;
if (editorInstance != null) {
editorInstance.Events.AttachEvent( 'OnFocus', fckEditorOnFocus ) ;
}
return true;
}
function setTabItemVisibility(idElement, visible) {
element = document.getElementById(idElement);
if (element == null) {
return false;
}
if (visible) {
displayValue = '';
}
else {
displayValue = 'none';
}
element.style.display = displayValue;
tabRow = document.getElementById('TabMenuTableRow');
var i = 0;
var offSet = 1;
if (isFirefox()) {
offSet = 2;
}
for (;i < tabRow.childNodes.length; i++) {
if (tabRow.childNodes[i] == element) {
if (i > offSet) {
tabRow.childNodes[i - offSet].style.display = displayValue;
}
else {
tabRow.childNodes[i + offSet].style.display = displayValue;
}
return true;
}
}
return true;
}
function removeFile(UploadRowId, PreviewRowId, StateId) {
uploadRow = document.getElementById(UploadRowId);
previewRow = document.getElementById(PreviewRowId);
stateField = document.getElementById(StateId);
if (uploadRow == null || previewRow == null || stateField == null) {
return;
}
uploadRow.style.display = '';
previewRow.style.display = 'none';
stateField.value = 'True';
}
function findLink(parentElement, text) {
if (parentElement.childNodes != null) {
var i = 0;
for (i = 0; i < parentElement.childNodes.length; i++) {
if (parentElement.childNodes[i].tagName == 'A' && parentElement.childNodes[i].innerHTML == text) {
return parentElement.childNodes[i];
}
else {
result = findLink(parentElement.childNodes[i], text);
if (result != null) {
return result;
}
}
}
return null;
}
}
function changeTreeNodeVisibility(linkElement, visibile) {
if (linkElement == null) {
return;
}
temp = linkElement;
while (temp != null && temp.tagName != 'TABLE') {
temp = temp.parentNode;
}
if (temp != null) {
if (visibile) {
temp.style.display = '';
}
else {
temp.style.display = 'none';
}
}
}
function hideElement(id) {
hidedEelement = document.getElementById(id);
if (hidedEelement != null) {
hidedEelement.style.display = 'none';
}
}
function doCustomPostBack(controlID, eventArgs) {
document.getElementById('CustomPostBackEventArgs').value = eventArgs;
__doPostBack(controlID, '');
}
function doAjaxControlPostBack(containerID, controlID, eventArgs) {
document.getElementById('CustomPostBackEventArgs' + containerID).value = eventArgs;
__doPostBack(controlID, '');
}
function initLoadingHint(){
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(showLoadingHint);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(hideLoadingHint);
}
function showLoadingHint()
{
setClass(document.getElementById('LoadingHint'), 'PreloaderImageActive');
loadingHintBackground = document.getElementById('LoadingBackground');
if (loadingHintBackground != null)
{
loadingHintBackground.style.display = '';
loadingHintBackground.style.width = document.body.offsetWidth + 'px';
loadingHintBackground.style.height = document.body.offsetHeight + 'px';
loadingHintBackground.width = 10;
loadingHintBackground.height = 10;
}
}
var goOnPageTop = false;
function hideLoadingHint()
{
if (goOnPageTop)
{
window.setTimeout(function() {
try {
scroll(0,0);
}
catch(e) {
new_window.close();
}
}, 1000);
goOnPageTop = false;
}
setClass(document.getElementById('LoadingHint'), 'PreloaderImageInactive');
loadingHintBackground = document.getElementById('LoadingBackground');
if (loadingHintBackground != null)
{
loadingHintBackground.style.display = 'none';
loadingHintBackground.style.width = '0px';
loadingHintBackground.style.height = '0px';
}
}
function keyUpHandler (eventArgs, containerID, controlID, postBackEventArgs) {
key = eventArgs.which;
if (key == 13) {
doAjaxControlPostBack(containerID, controlID, postBackEventArgs);
return false;
}
return true;
}
function MyClass()
{
this.UpdateEditorFormValue = function()
{
for ( i = 0; i < parent.frames.length; ++i )
if ( parent.frames[i].FCK )
parent.frames[i].FCK.UpdateLinkedField();
}
this.UpdateEditorFormValueParent = function(site)
{
for ( i = 0; i < site.parent.frames.length; ++i )
{
if ( site.parent.frames[i].FCK ) {
site.parent.frames[i].FCK.UpdateLinkedField();
}
}
}
}
var MyObject = new MyClass();
function setRelatedPosition(parentControlID, controlID) {
parentControl = document.getElementById(parentControlID);
control = document.getElementById(controlID);
if (control != null && parentControl != null) {
leftOffset = control.offsetWidth + 180;
topOffset = 0;
control.style.left = control.offsetLeft + leftOffset + 'px';
control.style.top = control.offsetTop + topOffset + 'px';
}
}
function switchEditors(editorDivID, sType)
{
oNode = document.getElementById(editorDivID);
if (oNode != null) {
var i=0;
for (i=0;i= 3 check for Flash plugin in plugin array
var flashVer = -1;
if (navigator.plugins != null && navigator.plugins.length > 0) {
if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
var descArray = flashDescription.split(" ");
var tempArrayMajor = descArray[2].split(".");
var versionMajor = tempArrayMajor[0];
var versionMinor = tempArrayMajor[1];
var versionRevision = descArray[3];
if (versionRevision == "") {
versionRevision = descArray[4];
}
if (versionRevision[0] == "d") {
versionRevision = versionRevision.substring(1);
} else if (versionRevision[0] == "r") {
versionRevision = versionRevision.substring(1);
if (versionRevision.indexOf("d") > 0) {
versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
}
}
var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
}
}
// MSN/WebTV 2.6 supports Flash 4
else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
// WebTV 2.5 supports Flash 3
else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
// older WebTV supports Flash 2
else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
else if ( isIE && isWin && !isOpera ) {
flashVer = ControlVersion();
}
return flashVer;
}
// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
versionStr = GetSwfVer();
if (versionStr == -1 ) {
return false;
} else if (versionStr != 0) {
if(isIE && isWin && !isOpera) {
// Given "WIN 2,0,0,11"
tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"]
tempString = tempArray[1]; // "2,0,0,11"
versionArray = tempString.split(","); // ['2', '0', '0', '11']
} else {
versionArray = versionStr.split(".");
}
var versionMajor = versionArray[0];
var versionMinor = versionArray[1];
var versionRevision = versionArray[2];
// is the major.revision >= requested major.revision AND the minor version >= requested minor
if (versionMajor > parseFloat(reqMajorVer)) {
return true;
} else if (versionMajor == parseFloat(reqMajorVer)) {
if (versionMinor > parseFloat(reqMinorVer))
return true;
else if (versionMinor == parseFloat(reqMinorVer)) {
if (versionRevision >= parseFloat(reqRevision))
return true;
}
}
return false;
}
}
// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
// But always return false if version is 9.0.28
function DistinctiveDetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
versionStr = GetSwfVer();
if (versionStr == -1 ) {
return false;
} else if (versionStr != 0) {
if(isIE && isWin && !isOpera) {
// Given "WIN 2,0,0,11"
tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"]
tempString = tempArray[1]; // "2,0,0,11"
versionArray = tempString.split(","); // ['2', '0', '0', '11']
} else {
versionArray = versionStr.split(".");
}
var versionMajor = versionArray[0];
var versionMinor = versionArray[1];
var versionRevision = versionArray[2];
if (9 == parseFloat(reqMajorVer) && 0 == parseFloat(reqMinorVer) && 28 == parseFloat(reqRevision)){
return false;
}
// is the major.revision >= requested major.revision AND the minor version >= requested minor
if (versionMajor > parseFloat(reqMajorVer)) {
return true;
} else if (versionMajor == parseFloat(reqMajorVer)) {
if (versionMinor > parseFloat(reqMinorVer))
return true;
else if (versionMinor == parseFloat(reqMinorVer)) {
if (versionRevision >= parseFloat(reqRevision))
return true;
}
}
return false;
}
}
function AC_AddExtension(src, ext)
{
if (src.indexOf('?') != -1)
return src.replace(/\?/, ext+'?');
else
return src + ext;
}
function AC_Generateobj(objAttrs, params, embedAttrs)
{
var str = '';
if (isIE && isWin && !isOpera)
{
str += '';
}
else
{
str += '';
}
document.write(str);
}
function AC_FL_RunContent(){
var ret =
AC_GetArgs
( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
, "application/x-shockwave-flash"
);
AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}
function AC_SW_RunContent(){
var ret =
AC_GetArgs
( arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
, null
);
AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}
function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
var ret = new Object();
ret.embedAttrs = new Object();
ret.params = new Object();
ret.objAttrs = new Object();
for (var i=0; i < args.length; i=i+2){
var currArg = args[i].toLowerCase();
switch (currArg){
case "classid":
break;
case "pluginspage":
ret.embedAttrs[args[i]] = args[i+1];
break;
case "src":
case "movie":
args[i+1] = AC_AddExtension(args[i+1], ext);
ret.embedAttrs["src"] = args[i+1];
ret.params[srcParamName] = args[i+1];
break;
case "onafterupdate":
case "onbeforeupdate":
case "onblur":
case "oncellchange":
case "onclick":
case "ondblclick":
case "ondrag":
case "ondragend":
case "ondragenter":
case "ondragleave":
case "ondragover":
case "ondrop":
case "onfinish":
case "onfocus":
case "onhelp":
case "onmousedown":
case "onmouseup":
case "onmouseover":
case "onmousemove":
case "onmouseout":
case "onkeypress":
case "onkeydown":
case "onkeyup":
case "onload":
case "onlosecapture":
case "onpropertychange":
case "onreadystatechange":
case "onrowsdelete":
case "onrowenter":
case "onrowexit":
case "onrowsinserted":
case "onstart":
case "onscroll":
case "onbeforeeditfocus":
case "onactivate":
case "onbeforedeactivate":
case "ondeactivate":
case "type":
case "codebase":
case "id":
ret.objAttrs[args[i]] = args[i+1];
break;
case "width":
case "height":
case "align":
case "vspace":
case "hspace":
case "class":
case "title":
case "accesskey":
case "name":
case "tabindex":
ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
break;
default:
ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
}
}
ret.objAttrs["classid"] = classid;
if (mimeType) ret.embedAttrs["type"] = mimeType;
return ret;
}
jQuery(function(){ jQuery('.top-search input').attr('disabled', ''); });