

/* moo.toolkit: MIT LICENSE */

/*---------------------------------------------------------------------------------------------------------*/
//# [1kb] moo.ray: array functions
/*---------------------------------------------------------------------------------------------------------*/

function $S() {
	if (arguments.length == 1){
		if(typeof arguments[0] == 'string') {
			if (arguments[0].charAt(0) == '#' && arguments[0].indexOf(' ') == -1) 
				return $(arguments[0].slice(1)) || null;
			return dom.getSelector(arguments[0]);
		}
		else return arguments[0];
	}
	var elements = [];
	arguments.each(function(sel){
		if (typeof sel == 'string') {
			dom.getSelector(sel).each(function(el){
				elements.push(el);
			});
		}
		else elements.push(sel);
	});
	alert(elements)
	return elements;
}

function $e(array){
	var nArray = [];
	for (i=0;el=array[i];i++) nArray.push(el);
	return nArray;
}

Array.prototype.each = function(func){
	for(var i=0;ob=this[i];i++) func(ob, i);
}

Array.prototype.action = function(actions){
	this.each(function(el){
		if (actions.initialize) actions.initialize(el);
		for(action in actions){
			if (action.slice(0,2) == 'on') el[action] = actions[action];
		}
	});
}

Array.prototype.find = function(mode){
	var elements = [];
	this.each(function(el){
		el = el[mode];
		while (el.nodeType != 1) el = el[mode];
		elements.push(el);
	});
	if (elements.length == 1) return elements[0];
	return elements;
}

/*---------------------------------------------------------------------------------------------------------*/
//# [2kb] moo.dom:target html elements using css selectors
/*---------------------------------------------------------------------------------------------------------*/

dom = {
	getSelector: function(selector){		
		var params = [];
		selector.split(' ').each(function(arg, j){
			params[j] = param = [];
			if (arg.indexOf('#') > -1) {
				var bits = arg.split('#');
				param['tag'] = bits[0] || '*';
				param['id'] = bits[1];
			}
			else if (arg.indexOf('.') > -1) {
				var bits = arg.split('.');
				param['tag'] = bits[0] || '*';
				param['class'] = bits[1];
			}
			else param['tag'] = arg;
		});
		this.filter = [document];
		params.each(function(param, k){
			if (k == 0 && param['id']) {
				var id = $(param['id']);
				if (param['tag'] == '*' || id.tagName.toLowerCase() == param['tag'])
					this.filter = [id];
				else return [];
			}
			else {
				this.filter = this._getElementsWithTagName(param['tag']);
				if (param['class']) this.filter = this._getElementsWithClassName(param['class']);
				else if (param['id']) this.filter = this._getElementsWithId(param['id']);
			}
		}.bind(this));
		return this.filter;
	},

	sheets: [],

	append: function(sheet){
		this.sheets.push(sheet);
	},

	start: function(){
		this.sheets.each(function(sheet){
			this.update(sheet);
		}.bind(this));
	},
	
	//based on Behaviour by Ben Nolan (http://bennolan.com/behaviour/)
	update: function(sheet){ 
		for (selector in sheet){
			selector.split(',').each(function(comb){
				var elements = this.getSelector(comb.replace(/^\s*|\s*$/g,"")) || null;
				elements.each(function(element){
					sheet[selector](element);
				});
			}.bind(this));
		}
	},

	_getElementsWithId: function(id){
		var found = [];
		this.filter.each(function(el){
			if (el.id == id) found.push(el);
		});
		return found;
	},

	_getElementsWithClassName: function(className){
		var found = [];
		this.filter.each(function(el){
			if (Element.hasClassName(el, className)) found.push(el);
		});
		return found;
	},

	_getElementsWithTagName: function(tagName){
		var found = [];
		this.filter.each(function(el){
			$e(el.getElementsByTagName(tagName)).each(function(tn){
				found.push(tn);
			});
		});
		return found;
	}
};

/*---------------------------------------------------------------------------------------------------------*/
//# [2.5kb] prototype.lite: mini version of prototype, modified
/*---------------------------------------------------------------------------------------------------------*/

/*  Prototype JavaScript framework
 *  (c) 2005 Sam Stephenson <sam@conio.net>
 *  Prototype is freely distributable under the terms of an MIT-style license.
 *  For details, see the Prototype web site: http://prototype.conio.net/
/*--------------------------------------------------------------------------*/

var Class = {
	create: function() {
		return function() { 
			this.initialize.apply(this, arguments);
		}
	}
}

Object.extend = function(destination, source) {
	for (property in source) destination[property] = source[property];
	return destination;
}

Function.prototype.bind = function(object) {
	var __method = this;
	return function() {
		return __method.apply(object, arguments);
	}
}

Function.prototype.bindAsEventListener = function(object) {
var __method = this;
	return function(event) {
		__method.call(object, event || window.event);
	}
}

function $() {
	if (arguments.length == 1) return get$(arguments[0]);
	var elements = [];
	arguments.each(function(el){
		elements.push(get$(el));
	});
	return elements;
	
	function get$(el){
		if (typeof el == 'string') el = document.getElementById(el);
		return el;
	}
}

if (!window.Element) var Element = new Object();

Object.extend(Element, {
	remove: function(element) {
		element = $(element);
		element.parentNode.removeChild(element);
	},

	getStyle: function(element, style) {
		element = $(element);
		var value = element.style[style];
		if (!value) {
		  if (document.defaultView && document.defaultView.getComputedStyle) {
			var css = document.defaultView.getComputedStyle(element, null);
			value = css ? css.getPropertyValue(style) : null;
		  } else if (element.currentStyle) {
			value = element.currentStyle[style];
		  }
		}

		if (window.opera && ['left', 'top', 'right', 'bottom'].include(style))
		  if (Element.getStyle(element, 'position') == 'static') value = 'auto';

		return value == 'auto' ? null : value;
	},

	hide: function() {
		for (var i = 0; i < arguments.length; i++) {
		  var element = $(arguments[i]);
		  element.style.display = 'none';
		}
	},

	show: function() {
		for (var i = 0; i < arguments.length; i++) {
		  var element = $(arguments[i]);
		  element.style.display = '';
		}
	},

	hasClassName: function(element, className) {
		element = $(element);
		if (!element) return;
		var hasClass = false;
		element.className.split(' ').each(function(cn){
			if (cn == className) hasClass = true;
		});
		return hasClass;
	},

	addClassName: function(element, className) {
		element = $(element);
		Element.removeClassName(element, className);
		element.className += ' ' + className;
	},
  
	removeClassName: function(element, className) {
		element = $(element);
		if (!element) return;
		var newClassName = '';
		element.className.split(' ').each(function(cn, i){
			if (cn != className){
				if (i > 0) newClassName += ' ';
				newClassName += cn;
			}
		});
		element.className = newClassName;
	},

	cleanWhitespace: function(element) {
		element = $(element);
		if (!element) return;
		$e(element.childNodes).each(function(node){
			if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) Element.remove(node);
		});
	}
});

var Position = {
  clone: function(source, target) {
    var options = Object.extend({
      setLeft:    true,
      setTop:     true,
      setWidth:   true,
      setHeight:  true,
      offsetTop:  0,
      offsetLeft: 0
    }, arguments[2] || {})

    // find page position of source
    source = $(source);
    var p = Position.page(source);

    // find coordinate system to use
    target = $(target);
    var delta = [0, 0];
    var parent = null;
    // delta [0,0] will do fine with position: fixed elements,
    // position:absolute needs offsetParent deltas
    if (Element.getStyle(target,'position') == 'absolute') {
      parent = Position.offsetParent(target);
      delta = Position.page(parent);
    }

    // correct by body offsets (fixes Safari)
    if (parent == document.body) {
      delta[0] -= document.body.offsetLeft;
      delta[1] -= document.body.offsetTop;
    }

    // set position
    if(options.setLeft)   target.style.left  = (p[0] - delta[0] + options.offsetLeft) + 'px';
    if(options.setTop)    target.style.top   = (p[1] - delta[1] + options.offsetTop) + 'px';
    if(options.setWidth)  target.style.width = source.offsetWidth + 'px';
    if(options.setHeight) target.style.height = source.offsetHeight + 'px';
  },

  page: function(forElement) {
    var valueT = 0, valueL = 0;

    var element = forElement;
    do {
      valueT += element.offsetTop  || 0;
      valueL += element.offsetLeft || 0;

      // Safari fix
      if (element.offsetParent==document.body)
        if (Element.getStyle(element,'position')=='absolute') break;

    } while (element = element.offsetParent);

    element = forElement;
    do {
      valueT -= element.scrollTop  || 0;
      valueL -= element.scrollLeft || 0;
    } while (element = element.parentNode);

    return [valueL, valueT];
  },

  offsetParent: function(element) {
    if (element.offsetParent) return element.offsetParent;
    if (element == document.body) return element;

    while ((element = element.parentNode) && element != document.body)
      if (Element.getStyle(element, 'position') != 'static')
        return element;

    return document.body;
  },

	cumulativeOffset: function(element) {
		var valueT = 0, valueL = 0;
		do {
			valueT += element.offsetTop  || 0;
			valueL += element.offsetLeft || 0;
			element = element.offsetParent;
		} while (element);
		return [valueL, valueT];
	}
};

/* FROM FULL PROTOTYPE */

if (!window.Event) {
  var Event = new Object();
}

Object.extend(Event, {
  KEY_BACKSPACE: 8,
  KEY_TAB:       9,
  KEY_RETURN:   13,
  KEY_ESC:      27,
  KEY_LEFT:     37,
  KEY_UP:       38,
  KEY_RIGHT:    39,
  KEY_DOWN:     40,
  KEY_DELETE:   46,

  element: function(event) {
    return event.target || event.srcElement;
  },

  isLeftClick: function(event) {
    return (((event.which) && (event.which == 1)) ||
            ((event.button) && (event.button == 1)));
  },

  pointerX: function(event) {
    return event.pageX || (event.clientX +
      (document.documentElement.scrollLeft || document.body.scrollLeft));
  },

  pointerY: function(event) {
    return event.pageY || (event.clientY +
      (document.documentElement.scrollTop || document.body.scrollTop));
  },

  stop: function(event) {
    if (event.preventDefault) {
      event.preventDefault();
      event.stopPropagation();
    } else {
      event.returnValue = false;
      event.cancelBubble = true;
    }
  },

  // find the first node with the given tagName, starting from the
  // node the event was triggered on; traverses the DOM upwards
  findElement: function(event, tagName) {
    var element = Event.element(event);
    while (element.parentNode && (!element.tagName ||
        (element.tagName.toUpperCase() != tagName.toUpperCase())))
      element = element.parentNode;
    return element;
  },

  observers: false,

  _observeAndCache: function(element, name, observer, useCapture) {
    if (!this.observers) this.observers = [];
    if (element.addEventListener) {
      this.observers.push([element, name, observer, useCapture]);
      element.addEventListener(name, observer, useCapture);
    } else if (element.attachEvent) {
      this.observers.push([element, name, observer, useCapture]);
      element.attachEvent('on' + name, observer);
    }
  },

  unloadCache: function() {
    if (!Event.observers) return;
    for (var i = 0; i < Event.observers.length; i++) {
      Event.stopObserving.apply(this, Event.observers[i]);
      Event.observers[i][0] = null;
    }
    Event.observers = false;
  },

  observe: function(element, name, observer, useCapture) {
    var element = $(element);
    useCapture = useCapture || false;

    if (name == 'keypress' &&
        (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
        || element.attachEvent))
      name = 'keydown';

    this._observeAndCache(element, name, observer, useCapture);
  },

  stopObserving: function(element, name, observer, useCapture) {
    var element = $(element);
    useCapture = useCapture || false;

    if (name == 'keypress' &&
        (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
        || element.detachEvent))
      name = 'keydown';

    if (element.removeEventListener) {
      element.removeEventListener(name, observer, useCapture);
    } else if (element.detachEvent) {
      element.detachEvent('on' + name, observer);
    }
  }
});

/*---------------------------------------------------------------------------------------------------------*/
//# [1.5kb] moo.ajax: mini ajax class
/*---------------------------------------------------------------------------------------------------------*/
var status_ready;
ajax = Class.create();
ajax.prototype = {
	initialize: function(url, options){
		this.transport = this.getTransport();
		this.postBody = options.postBody || '';
		this.method = options.method || 'post';
		this.onComplete = options.onComplete || null;
		this.onLoading	=	options.onLoading || null;
		this.update = $(options.update) || null;
		this.request(url);
	},

	request: function(url){
		this.transport.open(this.method, url, true);
		this.transport.onreadystatechange = this.onStateChange.bind(this);
		if (this.method == 'post') {
			this.transport.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
			if (this.transport.overrideMimeType) this.transport.setRequestHeader('Connection', 'close');
		}
		this.transport.send(this.postBody);
	},

	onStateChange: function(){
		if (this.transport.readyState == 1){
			if (this.onLoading) 
				setTimeout(function(){this.onLoading(this.transport);}.bind(this), 10);
		}
		if (this.transport.readyState == 4 && this.transport.status == 200) {
			if (this.onComplete) 
				setTimeout(function(){this.onComplete(this.transport);}.bind(this), 10);
			if (this.update) 
				setTimeout(function(){this.update.innerHTML = this.transport.responseText;}.bind(this), 10);
			this.transport.onreadystatechange = function(){};
		}
		
	
	},

	getTransport: function() {
		if (window.ActiveXObject) return new ActiveXObject('Microsoft.XMLHTTP');
		else if (window.XMLHttpRequest) return new XMLHttpRequest();
		else return false;
	}
};

/*---------------------------------------------------------------------------------------------------------*/
//# [3kb] moo.fx: simple javascript effects
/*---------------------------------------------------------------------------------------------------------*/

var fx = new Object();
//base
fx.Base = function(){};
fx.Base.prototype = {
	setOptions: function(options) {
	this.options = {
		duration: 500,
		onComplete: '',
		transition: fx.sinoidal
	}
	Object.extend(this.options, options || {});
	},

	go: function() {
		this.startTime = (new Date).getTime();
		this.timer = setInterval (this.step.bind(this), 10);
	},

	step: function() {
		var time  = (new Date).getTime();
		if (time >= this.options.duration+this.startTime) {
			this.now = this.to;
			clearInterval (this.timer);
			this.timer = null;
			if (this.options.onComplete) setTimeout(this.options.onComplete.bind(this), 10);
		}
		else {
			var Tpos = (time - this.startTime) / (this.options.duration);
			this.now = this.options.transition(Tpos) * (this.to-this.from) + this.from;
		}
		this.increase();
	},

	custom: function(from, to) {
		if (this.timer != null) return;
		this.from = from;
		this.to = to;
		this.go();
	},

	hide: function() {
		this.now = 0;
		this.increase();
	},

	clearTimer: function() {
		clearInterval(this.timer);
		this.timer = null;
	}
}

//stretchers
fx.Layout = Class.create();
fx.Layout.prototype = Object.extend(new fx.Base(), {
	initialize: function(el, options) {
		this.el = $(el);
		this.el.style.overflow = "hidden";
		this.el.iniWidth = this.el.offsetWidth;
		this.el.iniHeight = this.el.offsetHeight;
		this.setOptions(options);
	}
});

fx.Height = Class.create();
Object.extend(Object.extend(fx.Height.prototype, fx.Layout.prototype), {	
	increase: function() {
		this.el.style.height = this.now + "px";
	},

	toggle: function() {
		if (this.el.offsetHeight > 0) this.custom(this.el.offsetHeight, 0);
		else this.custom(0, this.el.scrollHeight);
	}
});

fx.Width = Class.create();
Object.extend(Object.extend(fx.Width.prototype, fx.Layout.prototype), {	
	increase: function() {
		this.el.style.width = this.now + "px";
	},

	toggle: function(){
		if (this.el.offsetWidth > 0) this.custom(this.el.offsetWidth, 0);
		else this.custom(0, this.el.iniWidth);
	}
});

//fader
fx.Opacity = Class.create();
fx.Opacity.prototype = Object.extend(new fx.Base(), {
	initialize: function(el, options) {
		this.el = $(el);
		this.now = 1;
		this.increase();
		this.setOptions(options);
	},

	increase: function() {
		if (this.now == 1) this.now = 0.9999;
		if (this.now > 0 && this.el.style.visibility == "hidden") this.el.style.visibility = "visible";
		if (this.now == 0) this.el.style.visibility = "hidden";
		if (window.ActiveXObject) this.el.style.filter = "alpha(opacity=" + this.now*100 + ")";
		this.el.style.opacity = this.now;
	},

	toggle: function() {
		if (this.now > 0) this.custom(1, 0);
		else this.custom(0, 1);
	}
});

//transitions
fx.sinoidal = function(pos){
	return ((-Math.cos(pos*Math.PI)/2) + 0.5);
	//this transition is from script.aculo.us
}
fx.linear = function(pos){
	return pos;
}
fx.cubic = function(pos){
	return Math.pow(pos, 3);
}
fx.circ = function(pos){
	return Math.sqrt(pos);
}

/*---------------------------------------------------------------------------------------------------------*/
//# [6kb] moo.fx.pack: combined, cookie, array, scroll effects & additional transitions
/*---------------------------------------------------------------------------------------------------------*/

//text size modify, now works with pixels too.
fx.Text = Class.create();
fx.Text.prototype = Object.extend(new fx.Base(), {
	initialize: function(el, options) {
		this.el = $(el);
		this.setOptions(options);
		if (!this.options.unit) this.options.unit = "em";
	},

	increase: function() {
		this.el.style.fontSize = this.now + this.options.unit;
	}
});

//composition effect, calls Width and Height alltogheter
fx.Resize = Class.create();
fx.Resize.prototype = {
	initialize: function(el, options) {
		this.h = new fx.Height(el, options); 
		if (options) options.onComplete = null;
		this.w = new fx.Width(el, options);
		this.el = $(el);
	},

	toggle: function(){
		this.h.toggle();
		this.w.toggle();
	},

	modify: function(hto, wto) {
		this.h.custom(this.el.offsetHeight, this.el.offsetHeight + hto);
		this.w.custom(this.el.offsetWidth, this.el.offsetWidth + wto);
	},

	custom: function(hto, wto) {
		this.h.custom(this.el.offsetHeight, hto);
		this.w.custom(this.el.offsetWidth, wto);
	},

	hide: function(){
		this.h.hide();
		this.w.hide();
	}
}

//composition effect, calls Opacity and (Width and/or Height) alltogheter
fx.FadeSize = Class.create();
fx.FadeSize.prototype = {
	initialize: function(el, options) {
		this.el = $(el);
		this.el.o = new fx.Opacity(el, options);
		if (options) options.onComplete = null;
		this.el.h = new fx.Height(el, options);
		this.el.w = new fx.Width(el, options);
	},

	toggle: function() {
		this.el.o.toggle();
		for (var i = 0; arg = arguments[i]; i++) {
			if (arg == 'height') this.el.h.toggle();
			if (arg == 'width') this.el.w.toggle();
		}
	},

	hide: function(){
		this.el.o.hide();
		for (var i = 0; arg = arguments[i]; i++) {
			if (arg == 'height') this.el.h.hide();
			if (arg == 'width') this.el.w.hide();
		}
	}
}

//intended to work with arrays.
var Multi = new Object();
Multi = function(){};
Multi.prototype = {
	initialize: function(elements, options){
		this.options = options;
		this.el = elements;
		for (i=0;el=this.el[i];i++){
			this.effect($(el));
		}
	}
}

//Fadesize with arrays
fx.MultiFadeSize = Class.create();
fx.MultiFadeSize.prototype = Object.extend(new Multi(), {
	effect: function(el){
		el.fs = new fx.FadeSize(el, this.options);
	},

	showThisHideOpen: function(elm, delay, mode){
		for (i=0;el=$(this.el[i]);i++){
			if (el.offsetHeight > 0 && el != elm && el.h.timer == null && elm.h.timer == null){
				el.fs.toggle(mode);
				setTimeout(function(){elm.fs.toggle(mode);}.bind(elm), delay);
			}
		}
	},

	hide: function(el, mode){
		el.fs.hide(mode);
	}
});

var Remember = new Object();
Remember = function(){};
Remember.prototype = {
	initialize: function(el, options){
		this.el = $(el);
		this.days = 365;
		this.options = options;
		this.effect();
		var cookie = this.readCookie();
		if (cookie) {
			this.fx.now = cookie;
			this.fx.increase();
		}
	},

	//cookie functions based on code by Peter-Paul Koch
	setCookie: function(value) {
		var date = new Date();
		date.setTime(date.getTime()+(this.days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
		document.cookie = this.el+this.el.id+this.prefix+"="+value+expires+"; path=/";
	},

	readCookie: function() {
		var nameEQ = this.el+this.el.id+this.prefix + "=";
		var ca = document.cookie.split(';');
		for(var i=0;c=ca[i];i++) {
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return false;
	},

	custom: function(from, to){
		if (this.fx.now != to) {
			this.setCookie(to);
			this.fx.custom(from, to);
		}
	}
}

fx.RememberHeight = Class.create();
fx.RememberHeight.prototype = Object.extend(new Remember(), {
	effect: function(){
		this.fx = new fx.Height(this.el, this.options);
		this.prefix = 'height';
	},
	
	toggle: function(){
		if (this.el.offsetHeight == 0) this.setCookie(this.el.scrollHeight);
		else this.setCookie(0);
		this.fx.toggle();
	},
	
	resize: function(to){
		this.setCookie(this.el.offsetHeight+to);
		this.fx.custom(this.el.offsetHeight,this.el.offsetHeight+to);
	},

	hide: function(){
		if (!this.readCookie()) {
			this.fx.hide();
		}
	}
});

fx.RememberText = Class.create();
fx.RememberText.prototype = Object.extend(new Remember(), {
	effect: function(){
		this.fx = new fx.Text(this.el, this.options);
		this.prefix = 'text';
	}
});

//smooth scroll
fx.Scroll = Class.create();
fx.Scroll.prototype = Object.extend(new fx.Base(), {
	initialize: function(options) {
		this.setOptions(options);
	},

	scrollTo: function(el){
		var dest = Position.cumulativeOffset($(el))[1];
		var height = $(el).innerHeight || $(el).clientHeight;
		var client = window.innerHeight || document.documentElement.clientHeight;
		var full = document.documentElement.scrollHeight;
		var top = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;

		if (dest > client)
		{
			this.custom(top, dest - client + height + 15);
			return;
		}

		if (dest+client > full) this.custom(top, dest - client + (full-dest));
		else this.custom(top, dest);
	},

	increase: function(){
		window.scrollTo(0, this.now);
	}
});

//Easing Equations (c) 2003 Robert Penner, all rights reserved.
//This work is subject to the terms in http://www.robertpenner.com/easing_terms_of_use.html.

//expo
fx.expoIn = function(pos){
	return Math.pow(2, 10 * (pos - 1));
}
fx.expoOut = function(pos){
	return (-Math.pow(2, -10 * pos) + 1);
}

//quad
fx.quadIn = function(pos){
	return Math.pow(pos, 2);
}
fx.quadOut = function(pos){
	return -(pos)*(pos-2);
}

//circ
fx.circOut = function(pos){
	return Math.sqrt(1 - Math.pow(pos-1,2));
}
fx.circIn = function(pos){
	return -(Math.sqrt(1 - Math.pow(pos, 2)) - 1);
}

//back
fx.backIn = function(pos){
	return (pos)*pos*((2.7)*pos - 1.7);
}
fx.backOut = function(pos){
	return ((pos-1)*(pos-1)*((2.7)*(pos-1) + 1.7) + 1);
}

//sine
fx.sineOut = function(pos){
	return Math.sin(pos * (Math.PI/2));
}
fx.sineIn = function(pos){
	return -Math.cos(pos * (Math.PI/2)) + 1;
}
fx.sineInOut = function(pos){
	return -(Math.cos(Math.PI*pos) - 1)/2;
}



var Autocompleter = {}
Autocompleter.Base = function() {};
Autocompleter.Base.prototype = {
  baseInitialize: function(element, update, options) {
    this.element     = $(element); 
    this.update      = $(update);  
    this.hasFocus    = false; 
    this.changed     = false; 
    this.active      = false; 
    this.index       = 0;     
    this.entryCount  = 0;

    if (this.setOptions)
      this.setOptions(options);
    else
      this.options = options || {};

    this.options.paramName    = this.options.paramName || this.element.name;
    this.options.tokens       = this.options.tokens || [];
    this.options.frequency    = this.options.frequency || 0.4;
    this.options.minChars     = this.options.minChars || 1;
    this.options.onShow       = this.options.onShow || 
    function(element, update){ 
      if(!update.style.position || update.style.position=='absolute') {
        update.style.position = 'absolute';
        Position.clone(element, update, {setHeight: false, offsetTop: element.offsetHeight});
      }
	  update.style.display = 'block';
    };
    this.options.onHide = this.options.onHide || 
    function(element, update){ 
	  update.style.display = 'none';
	};

    if (typeof(this.options.tokens) == 'string') 
      this.options.tokens = new Array(this.options.tokens);

    this.observer = null;
    
    this.element.setAttribute('autocomplete','off');

    Element.hide(this.update);

    Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this));
    Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this));
  },

  show: function() {
    if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
    if(!this.iefix && 
      (navigator.appVersion.indexOf('MSIE')>0) &&
      (navigator.userAgent.indexOf('Opera')<0) &&
      (Element.getStyle(this.update, 'position')=='absolute')) {
      new Insertion.After(this.update, 
       '<iframe id="' + this.update.id + '_iefix" '+
       'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' +
       'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
      this.iefix = $(this.update.id+'_iefix');
    }
    if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
  },
  
  fixIEOverlapping: function() {
    Position.clone(this.update, this.iefix);
    this.iefix.style.zIndex = 1;
    this.update.style.zIndex = 2;
    Element.show(this.iefix);
  },

  hide: function() {
    this.stopIndicator();
    if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update);
    if(this.iefix) Element.hide(this.iefix);
  },

  startIndicator: function() {
    if(this.options.indicator) Element.show(this.options.indicator);
  },

  stopIndicator: function() {
    if(this.options.indicator) Element.hide(this.options.indicator);
  },

  onKeyPress: function(event) {
    if(this.active)
      switch(event.keyCode) {
       case Event.KEY_TAB:
       case Event.KEY_RETURN:
         this.selectEntry();
         Event.stop(event);
       case Event.KEY_ESC:
         this.hide();
         this.active = false;
         Event.stop(event);
         return;
       case Event.KEY_LEFT:
       case Event.KEY_RIGHT:
         return;
       case Event.KEY_UP:
         this.markPrevious();
         this.render();
         if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
         return;
       case Event.KEY_DOWN:
         this.markNext();
         this.render();
         if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
         return;
      }
     else 
       if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN || 
         (navigator.appVersion.indexOf('AppleWebKit') > 0 && event.keyCode == 0)) return;

    this.changed = true;
    this.hasFocus = true;
	this.setNonExistingCandidate();

    if(this.observer) clearTimeout(this.observer);
      this.observer = 
        setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
  },

  activate: function() {
    this.changed = false;
    this.hasFocus = true;
    this.getUpdatedChoices();
  },

  onHover: function(event) {
    var element = Event.findElement(event, 'LI');
    if(this.index != element.autocompleteIndex) 
    {
        this.index = element.autocompleteIndex;
        this.render();
    }
    Event.stop(event);
  },
  
  onClick: function(event) {
    var element = Event.findElement(event, 'LI');
    this.index = element.autocompleteIndex;
    this.selectEntry();
    this.hide();
  },
  
  onBlur: function(event) {
    // needed to make click events working
    setTimeout(this.hide.bind(this), 250);
    this.hasFocus = false;
    this.active = false;     
  }, 
  
  render: function() {
    if(this.entryCount > 0) {
      for (var i = 0; i < this.entryCount; i++)
        this.index==i ? 
          Element.addClassName(this.getEntry(i),"selected") : 
          Element.removeClassName(this.getEntry(i),"selected");
        
      if(this.hasFocus) { 
        this.show();
        this.active = true;
      }
    } else {
      this.active = false;
      this.hide();
    }
  },
  
  markPrevious: function() {
    if(this.index > 0) this.index--
      else this.index = this.entryCount-1;
  },
  
  markNext: function() {
    if(this.index < this.entryCount-1) this.index++
      else this.index = 0;
  },
  
  getEntry: function(index) {
	 if (index > -1)
	    return this.update.firstChild.childNodes[index];
  },
  
  getCurrentEntry: function() {
    return this.getEntry(this.index);
  },
  
  selectEntry: function() {
    this.active = false;
    this.updateElement(this.getCurrentEntry());
  },

  setExistingCandidate: function(img) {
	if (this.options.imgbox && img)
	{
		this.options.imgbox.innerHTML = img;
	}
  },

  setNonExistingCandidate: function() {
	if (this.options.imgbox)
	{
		this.options.imgbox.innerHTML = '';
	}
  },

  updateElement: function(selectedElement) {
    if (this.options.updateElement) {
      this.options.updateElement(selectedElement);
      return;
    }

	if (!selectedElement)
		return;

	this.setExistingCandidate();

    var img = selectedElement.firstChild;
//    var imgbox = document.getElementById(this.options.imgbox);
	this.options.imgbox.innerHTML = '';
	this.options.imgbox.appendChild(img.cloneNode(false));
	this.options.imgbox.innerHTML += '<input type="hidden" name="race[candidate][id_photo]" value="'+img.id+'" />';
    var value = selectedElement.lastChild.data;
    
    var lastTokenPos = this.findLastToken();
    if (lastTokenPos != -1) {
      var newValue = this.element.value.substr(0, lastTokenPos + 1);
      var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/);
      if (whitespace)
        newValue += whitespace[0];
      this.element.value = newValue + value;
    } else {
      this.element.value = value;
    }
    this.element.focus();
    
    if (this.options.afterUpdateElement)
      this.options.afterUpdateElement(this.element, selectedElement);
  },

  updateChoices: function(choices) {
	document.getElementById(this.options.info).innerHTML = '';

	if (this.options.fileupload)
	{
		if (choices.match(/class="exact">(<img[^>]+>)/))
		{
			this.setExistingCandidate(choices.match(/class="exact">(<img[^>]+>)/)[1]);
			this.hide();
			return;
		}
		else
			this.setNonExistingCandidate();
	}

    if(!this.changed && this.hasFocus) {
      this.update.innerHTML = choices;
      Element.cleanWhitespace(this.update);
      Element.cleanWhitespace(this.update.firstChild);

      if(this.update.firstChild && this.update.firstChild.childNodes) {
        this.entryCount = 
          this.update.firstChild.childNodes.length;
        for (var i = 0; i < this.entryCount; i++) {
          var entry = this.getEntry(i);
          entry.autocompleteIndex = i;
          this.addObservers(entry);
        }
      } else { 
        this.entryCount = 0;
      }

      this.stopIndicator();

      this.index = -1;
      this.render();
    }
  },

  addObservers: function(element) {
    Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this));
    Event.observe(element, "click", this.onClick.bindAsEventListener(this));
  },

  onObserverEvent: function() {
    this.changed = false;   
    if(this.getToken().length>=this.options.minChars) {
      this.startIndicator();
      this.getUpdatedChoices();
    } else {
      this.active = false;
      this.hide();
    }
  },

  getToken: function() {
    var tokenPos = this.findLastToken();
    if (tokenPos != -1)
      var ret = this.element.value.substr(tokenPos + 1).replace(/^\s+/,'').replace(/\s+$/,'');
    else
      var ret = this.element.value;

    return /\n/.test(ret) ? '' : ret;
  },

  findLastToken: function() {
    var lastTokenPos = -1;

    for (var i=0; i<this.options.tokens.length; i++) {
      var thisTokenPos = this.element.value.lastIndexOf(this.options.tokens[i]);
      if (thisTokenPos > lastTokenPos)
        lastTokenPos = thisTokenPos;
    }
    return lastTokenPos;
  }
}

Autocompleter.Ajax = Class.create();
Object.extend(Object.extend(Autocompleter.Ajax.prototype, Autocompleter.Base.prototype), {
  initialize: function(element, update, info, imgbox, autocomplete_big, url, options) {
    this.baseInitialize(element, update, options);
    this.options.info		   = info;
    this.options.autocomplete_big		   = autocomplete_big;
    this.options.imgbox		   = document.getElementById(imgbox);
    this.options.asynchronous  = true;
    this.options.onComplete    = this.onComplete.bind(this);
    this.options.defaultParams = this.options.parameters || null;
    this.url                   = url;
	this.options.fileupload = document.getElementById(element.replace(/_name/, "_photo"));
  },

  getUpdatedChoices: function() {
	if (this.options.imgbox)
		this.options.imgbox.innerHTML = '';

	if (this.options.autocomplete_big)
	{
		document.getElementById(this.options.info).innerHTML = 'Searching...';
		ServerCall({'c': 'autosuggest', 'bigpics': '1', 'name': encodeURIComponent(this.getToken())}, searchCandidateCB);
	}
	else
	{
		document.getElementById(this.options.info).innerHTML = 'Searching...';
		ServerCall({'c': 'autosuggest', 'name': encodeURIComponent(this.getToken())}, this.onComplete.bind(this));
	}

	return;

/*
    entry = encodeURIComponent(this.options.paramName) + '=' + 
      encodeURIComponent(this.getToken());

    this.options.parameters = this.options.callback ?
      this.options.callback(this.element, entry) : entry;

    if(this.options.defaultParams) 
      this.options.parameters += '&' + this.options.defaultParams;

    new Ajax.Request(this.url, this.options);

	new ajax (this.url, {
		postBody: entry, 
		onComplete: callback
	});
*/

  },

  onComplete: function(request) {
    this.updateChoices(request.responseText);
  }

});

// from scriptaculous 

Element.collectTextNodes = function(element) {  
  return $A($(element).childNodes).collect( function(node) {
    return (node.nodeType==3 ? node.nodeValue : 
      (node.hasChildNodes() ? Element.collectTextNodes(node) : ''));
  }).flatten().join('');
}

Element.collectTextNodesIgnoreClass = function(element, className) {  
  return $A($(element).childNodes).collect( function(node) {
    return (node.nodeType==3 ? node.nodeValue : 
      ((node.hasChildNodes() && !Element.hasClassName(node,className)) ? 
        Element.collectTextNodesIgnoreClass(node, className) : ''));
  }).flatten().join('');
}

// The local array autocompleter. Used when you'd prefer to
// inject an array of autocompletion options into the page, rather
// than sending out Ajax queries, which can be quite slow sometimes.
//
// The constructor takes four parameters. The first two are, as usual,
// the id of the monitored textbox, and id of the autocompletion menu.
// The third is the array you want to autocomplete from, and the fourth
// is the options block.
//
// Extra local autocompletion options:
// - choices - How many autocompletion choices to offer
//
// - partialSearch - If false, the autocompleter will match entered
//                    text only at the beginning of strings in the 
//                    autocomplete array. Defaults to true, which will
//                    match text at the beginning of any *word* in the
//                    strings in the autocomplete array. If you want to
//                    search anywhere in the string, additionally set
//                    the option fullSearch to true (default: off).
//
// - fullSsearch - Search anywhere in autocomplete array strings.
//
// - partialChars - How many characters to enter before triggering
//                   a partial match (unlike minChars, which defines
//                   how many characters are required to do any match
//                   at all). Defaults to 2.
//
// - ignoreCase - Whether to ignore case when autocompleting.
//                 Defaults to true.
//
// It's possible to pass in a custom function as the 'selector' 
// option, if you prefer to write your own autocompletion logic.
// In that case, the other options above will not apply unless
// you support them.

Autocompleter.Local = Class.create();
Autocompleter.Local.prototype = Object.extend(new Autocompleter.Base(), {
  initialize: function(element, update, array, options) {
    this.baseInitialize(element, update, options);
    this.options.array = array;
  },

  getUpdatedChoices: function() {
    this.updateChoices(this.options.selector(this));
  },

  setOptions: function(options) {
    this.options = Object.extend({
      choices: 10,
      partialSearch: true,
      partialChars: 2,
      ignoreCase: true,
      fullSearch: false,
      selector: function(instance) {
        var ret       = []; // Beginning matches
        var partial   = []; // Inside matches
        var entry     = instance.getToken();
        var count     = 0;

        for (var i = 0; i < instance.options.array.length &&  
          ret.length < instance.options.choices ; i++) { 

          var elem = instance.options.array[i];
          var foundPos = instance.options.ignoreCase ? 
            elem.toLowerCase().indexOf(entry.toLowerCase()) : 
            elem.indexOf(entry);

          while (foundPos != -1) {
            if (foundPos == 0 && elem.length != entry.length) { 
              ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" + 
                elem.substr(entry.length) + "</li>");
              break;
            } else if (entry.length >= instance.options.partialChars && 
              instance.options.partialSearch && foundPos != -1) {
              if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {
                partial.push("<li>" + elem.substr(0, foundPos) + "<strong>" +
                  elem.substr(foundPos, entry.length) + "</strong>" + elem.substr(
                  foundPos + entry.length) + "</li>");
                break;
              }
            }

            foundPos = instance.options.ignoreCase ? 
              elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) : 
              elem.indexOf(entry, foundPos + 1);

          }
        }
        if (partial.length)
          ret = ret.concat(partial.slice(0, instance.options.choices - ret.length))
        return "<ul>" + ret.join('') + "</ul>";
      }
    }, options || {});
  }
});



/* VK */

var VK = {}
/*
function vkonload()
{
	// prevent memory leaks in IE
	if (navigator.appVersion.match(/\bMSIE\b/)) {
		Event.observe(window, 'unload', Event.unloadCache, false);
	}

	var o = document.getElementById('focusme');
	if (o)
	{
		o.focus();

	}

	// let's find the autocomplete fields
	VK.Autocomplete = [];
	var o2 = $S('input.autocomplete');

	for (var i = 0; i < o2.length; i++)
	{
		var autocomplete_big = false;

		if (Element.hasClassName(o2[i], 'autocomplete_big'))
			autocomplete_big = true;

		var ac_img = document.createElement('div');
		ac_img.className = 'autocomplete_img';
		ac_img.id = o2[i].id+'_ac_img';
		if (!autocomplete_big)
			o2[i].parentNode.insertBefore(ac_img, o2[i]);

		var ac1 = document.createElement('div');
		ac1.className = 'autocomplete_info';
		ac1.id = o2[i].id+'_ac_info';
		o2[i].parentNode.appendChild(ac1);

		var ac = document.createElement('div');
		ac.className = 'autocomplete_box';
		ac.id = o2[i].id+'_ac';
		o2[i].parentNode.appendChild(ac);

		VK.Autocomplete[i] = new Autocompleter.Ajax(o2[i].id, ac.id, ac1.id, ac_img.id, autocomplete_big, '/vk/handle.php', { tokens: ',' });
	}
}

/*function searchCandidateCB(request)
{
	var o = document.getElementById('candidate_search_results');
	var o2 = document.getElementById('search_field_ac_info');

	o2.innerHTML = '';
	/*
	if (request.responseText != '')
		o2.innerHTML = '';
	else
		o2.innerHTML = 'No candidates found, sorry.';
	*/
/*
	o.firstChild.innerHTML = request.responseText;
	var el = o.firstChild.getElementsByTagName('LI');
	for (var i = 0; i < el.length; i++)
	{
		el[i].innerHTML = '<a href="#" onclick="return selectCandidate(this)">'+el[i].innerHTML+'</a>';
//		el[i].onclick=function() { selectCandidate(this) }
	}

	o.style.display = 'block';

//	o.firstChild.innerHTML += '<li><img src="/pics/default_candidate.gif" /><a href="#" onclick="return addCandidate()">Add new candidate</a></li>';
}

function searchCandidate()
{
	var o = document.getElementById('search_field');
	var o2 = document.getElementById('search_field_ac_info');
	o2.style.display = 'block'; o2.innerHTML = 'Searching...';
	return ServerCall({ 'c':'autosuggest', 'bigpics': '1', 'name': encodeURIComponent(o.value) }, searchCandidateCB);
}


function ServerCall(o, callback, showload)
{
	param = 'ajax=1';
	for (var i in o)
		param += "&"+i+"="+encodeURIComponent(o[i]);

	if (showload)
		showloading();

	new ajax ('/vk/handle.php', {
		postBody: param, 
		onComplete: showload? function(req) {hideloading(); callback(req)}: callback
	});

	return false;
}
*/
function showloading()
{
	document.getElementById('loading').style.display = 'block';
}

function hideloading()
{
	document.getElementById('loading').style.display = 'none';
}
/*
function Vote(link, race, candidate)
{
	link.innerHTML = 'voting';
	return ServerCall({ 'c':'vote', 'r':race, 'r_id':race, 'c_id':candidate }, VoteComplete);
}

function VoteComplete(request)
{
	try
	{
		eval ("var o = "+request.responseText);
	}
	catch (e) {	return;	}
	
	if (typeof(o) == 'string')
	{
		alert(o);
		return;
	}
	var c;
	for (var i in o)
	{
		if (i == parseInt(i))
		{
			try
			{
//				document.getElementById('vc_'+o[i][0]+'_'+o[i][1]).innerHTML = o[i][2];
				document.getElementById('vcp_'+o[i][0]+'_'+o[i][1]).innerHTML = o[i][3];

				var voteme = document.getElementById('vm_'+o[i][0]+'_'+o[i][1]);

				if (o[i][4]) // voted this?
				{
					voteme.firstChild.innerHTML = '<img style="width:58px; height:26px" src="../pics/vote.jpg" />';
					voteme.firstChild.style.display = 'none';
					voteme.lastChild.style.display = 'inline';
				}
				else
				{
					voteme.firstChild.style.display = 'inline';
					voteme.lastChild.style.display = 'none';
				}
			}
			catch (e) { }

		}
	}
}

function ServerCallback(request){
  alert(request.responseText);
}

function validateRace()
{
	var fields = 
		[['race_title', 'Race title'], 
		['ends', 'End date']];
	var o;

	for (var i = 0; i < fields.length; i++)
	{
		o = document.getElementById(fields[i][0]);
		if (!o || o.value.length == 0)
		{
			setFormError(o, fields[i][1]+' should be entered.');
			return false;
		}
	}

	return true;
}

function validateCandidate()
{
	var fields = 
		[['focusme', 'Candidate name']];
	var o;

	for (var i = 0; i < fields.length; i++)
	{
		o = document.getElementById(fields[i][0]);
		if (!o || o.value.length == 0)
		{
			setFormError(o, fields[i][1]+' should be entered.');
			return false;
		}
	}

	return true;
}

function validateComment()
{
	var fields = 
		[['comment_content', 'Comment']];
	var o;

	for (var i = 0; i < fields.length; i++)
	{
		o = document.getElementById(fields[i][0]);
		if (!o || o.value.length == 0)
		{
			setFormError(o, fields[i][1]+' should be entered.');
			return false;
		}
	}

	return true;
}
*/
function setFormError(o, msg)
{
	var errorObj = document.getElementById('error');

	if (!errorObj) {
		errorObj = document.createElement('div');
		errorObj.id = 'error';
	}

	if (errorObj.parentNode)
		errorObj.parentNode.removeChild(errorObj);

	errorObj.innerHTML = msg;

	var myEffect = new fx.Height(errorObj , {duration: 200, onComplete: function()
	  {
		o.focus();
	  }
	});

	myEffect.hide();
	o.parentNode.appendChild(errorObj);
	myEffect.toggle();
}

/*function deleteCommentReady(request)
{
	if (request.responseText != '')
	{
	}
}

function deleteComment(o)
{
	ServerCall({'c': 'autosuggest', 'name': encodeURIComponent(this.getToken())}, deleteCommentReady);

	return true;
}
*/
// slider
var Scroller = {}, myEffect = {};
var frmPage
function initScroller(id, nTried,frm) {
	frmPage	=	frm;
	if (!document.getElementById(id))
	{
		nTried = nTried? nTried++: 1;

		if (nTried < 500)
			window.setTimeout('initScroller('+id+', '+nTried+')', 100);
		return;
	}

//	Scroller[id] = document.getElementById(id);
//	Scroller.style.display = 'block';

	myEffect[id] = new fx.Scroller(id, {duration: 500, onComplete: function()
		{
			this.initButtons();
		}
	});

	myEffect[id].scroll();
}

fx.Scroller = Class.create();
fx.Scroller.prototype = Object.extend(new fx.Base(), {
	initialize: function(el, options) {
		this.el = $S('#'+el+' .scroller')[0];
		this.setOptions(options);
		this.scrollLeft = $S('#'+el+' .scroll_left')[0];
		this.scrollRight = $S('#'+el+' .scroll_right')[0];
		this.initButtons();
		this.now = -this.scrollAmount;
		this.addFade();
	},

	initButtons: function() {
		this.scrollAmount = Math.floor((this.el.parentNode.offsetWidth) / 123) * 123; 

		if (!this.scrollLeft)
		{
			alert('Oops! this.scrollLeft null');
			return;
		}

		var scrollLeft = this.el.firstChild.offsetHeight  > 190? true: false;

		for (var i = 0; i < this.el.firstChild.childNodes.length && !scrollLeft; i++)
		{
			if (this.el.firstChild.childNodes[i].offsetLeft + this.el.firstChild.childNodes[i].offsetWidth >= this.scrollAmount)
				scrollLeft = true;
		}

		if (scrollLeft)
			Element.removeClassName(this.scrollLeft, 'disabled');
		else
			Element.addClassName(this.scrollLeft, 'disabled');

		if (this.el.firstChild.offsetLeft < 0)
			Element.removeClassName(this.scrollRight, 'disabled');
		else
			Element.addClassName(this.scrollRight, 'disabled');

	},

	addFade: function(o)
	{
		var fade;
		fade = document.createElement('img');
		fade.className = 'fade';
		 if(frmPage == '' )
			fade.src='../pics/fade.gif';
    	 else
			fade.src = 'pics/fade.gif';
	
		this.el.parentNode.appendChild(fade);
	},

	increase: function() {
//		alert(this.el.firstChild.style.marginLeft);
		this.el.firstChild.style.marginLeft = - this.now + "px";
	},

	scroll: function(o){
		if (o && Element.hasClassName(o, 'disabled'))
			return false;
		Element.addClassName(this.scrollLeft, 'disabled');
		Element.addClassName(this.scrollRight, 'disabled');
		this.clearTimer();
		var dir = o == this.scrollRight? -1: 1;
		this.custom(this.now, this.now + dir * this.scrollAmount)
	}
});

// Functions
var divid,tot,hide,opt,optkey,optids;
function votecast(url,id,count,Id,ids)
{
	param	= 	"opt="+url;
	opt		=	url;	
	divid	=	id;
	tot		=	count;
	optids	=	ids;
	optkey	=	Id;
	new ajax ('handle.php', {
		postBody: param, 
		onComplete:function showResponse(request)
		{
				//put returned XML in the textarea
				p=request.responseText;
				
				val	=	p.split(',');
				idOpt	=	optids.split(',');
				
				for(i=1;i<=tot;i++){
					div	=	'res_'+ divid +'_'+ i;
					$(div).innerHTML =  val[i-1];
				}
				
				$('votelink_'+divid+'_'+optkey).style.display='none';
				onlod(divid,opt);
				hideShow();
				
				
		}
	});
	
	return false;
}



function hideShow(disp_id){
		val	=	optids.split(',');
		
		for(i=1;i<=tot;i++){
			if((val[i]!=opt)){
					disp_id	=	'votelink_'+ divid +'_'+ i;
					$(disp_id).style.display='block';
			}
			
		}
}

function onlod(topid,optid){
	if(optid == 0){
		return false;
	}
	param	= 	"topid="+topid;
	//value	=	optids.split(',');
	new ajax ('handle_votelink.php', {
		postBody: param, 
		onLoading:function(){
			if(optkey){
				dividstr	=	'votelink_'+ topid +'_'+ optkey;	
				$(dividstr).innerHTML	=	'<span class=errortext><br>Loading...</span>';
			}
		},
		onComplete:function(req)
		{
			links		=	req.responseText;
			links		=	links.split('@');
			for(j=1;j<links.length;j++){
					linkval		= '';
					dividstr	=	'votelink_'+ topid +'_'+ j;
					linkval = trimSpaces(links[j-1]);
					$(dividstr).innerHTML =  linkval;
			}
					
			
		}
	})
	
}
