Accordion.implement({
	display: function(index){

		index = ($type(index) == 'element') ? this.elements.indexOf(index) : index;

		if ((this.timer && this.options.wait) || (index === this.previous && !this.options.alwaysHide)) return this;

		this.previous = index;

		var obj = {};

		this.elements.each(function(el, i){

			obj[i] = {};

			var hide = (i != index) || (this.options.alwaysHide && (el.offsetHeight > 0));
			
			//added returning of index (i)
			this.fireEvent(hide ? 'background' : 'active', [this.togglers[i], el, i]);

			for (var fx in this.effects) obj[i][fx] = hide ? 0 : el[this.effects[fx]];

		}, this);

		return this.start(obj);

	}
});



var QS = new Class({
	initialize:function() {
		this.url = document.location.toString();
		this.vars = new Hash();
		var tmp = this.url.split('?');
		if(!$type(tmp[1])) return false;
		tmp = tmp[1].split('#');
		tmp = tmp[0].split('&');
		tmp.each(function(pair,x){
			pair = pair.split('=');
			if(!$type(pair[1])) pair[1] = null;
			this.vars[pair[0]] = pair[1];
		},this);
	},
	get:function(key) {
		return this.vars[key];
	},
	set:function(key,value) {
		this.vars[key]=value;
	},
	getQueryString:function() {
		var output = [];
		this.vars.each(function(value,key){
			if(value==null)	value=true;
			output.push(key+"="+value);
		});
		return "?"+output.join('&');
	}
});


function setPageHeader(title)
{
	$('header_title').set('text',title)
}

function sec_to_time(ms){ 
	ms=Math.floor(ms);
	days 		= Math.floor(ms/86400);
	remain_ms	= ms - days*86400;
	hrs			= Math.floor(remain_ms/3600);
	remain_ms	= remain_ms - hrs*3600;
	min			= Math.floor(remain_ms/60);
	remain_ms	= remain_ms - min*60;
	sec			= remain_ms;
	time = (days>0?days+' ':'')+(hrs==0&&days==0?'':cal_pad(hrs)+':')+cal_pad(min)+':'+cal_pad(sec);
	return time;
}
function cal_pad(value) {
	value = '0'+value;
	value = value.substr(value.length-2,2);
	return value;
}
