// JavaScript Document
function customradiobox(container, classname)
{
	this.container = container;
	this.classname = classname;
	this.active = '/images/vote_lia.gif';
	this.inactive = '/images/vote_li.gif';
	this.inputs = [];
	var thisobj = this;
	this.hidden = [];
	
	this.init = function(){
		var elements = this.container.getElementsByTagName('INPUT');
		var count = elements.length;
		for (var i=0; i<count; i++)
		{
			if (elements[i].className == this.classname)
			{
				var name = elements[i].name;
				if (typeof(this.inputs[name]) == 'undefined')
				{
					this.inputs.push(name);
					this.inputs[name] = [];
				}
				this.inputs[name].push(elements[i]);
			}
		}
		count = this.inputs.length;
		if (parseInt(count) == 0) return true;
		var sdom = new simpledom();
		for (var e in this.inputs)
		{
			if (e == 0) continue;
			var input = sdom.input({'type':'hidden', 'name':e});
			for (var es in this.inputs[e])
			{
				var img = sdom.img({
								   'src':this.inputs[e][es].checked?this.active:this.inactive, 
								   'value':this.inputs[e][es].value, 
								   'className':this.classname, 
								   'name':e, 
								   'onclick':this.check
								   });
				if (this.inputs[e][es].checked)
					input.value = this.inputs[e][es].value;
				var current = this.inputs[e][es];
				current.parentNode.replaceChild(img, current);
			}
			this.hidden[e] = input;
			this.container.appendChild(input);
		}
	}

	this.check = function()
	{
		thisobj.container[this.name].value = this.value;
		var imgs = thisobj.container.getElementsByTagName('IMG');
		var count = imgs.length;
		for (var i=0; i<count; i++)
		{
			if (imgs[i].className != thisobj.classname) continue;
			imgs[i].src = imgs[i].value == this.value?thisobj.active:thisobj.inactive;
		}
		return true;
	}
}

function simpledom()
{
	var elements = ['ul', 'li', 'img', 'input', 'select', 'option'];
	var count = elements.length;
	var isie = !!(navigator.appName == "Microsoft Internet Explorer");
	
	this.create = function (element){
		this[element] = function(attributes){
			if (isie && element == 'input')
			var obj = document.createElement('<INPUT type="'+attributes['type']+'" name="'+attributes['name']+'">');
			else
			var obj = document.createElement(element.toUpperCase());
			for (var a in attributes)
			{
				switch (a)
				{
					case 'name':
					case 'type':
						if (!(element == 'input' && isie))
						obj[a] = attributes[a];
					break;
					case 'className':
					case 'value':
						obj[a] = attributes[a];
					break;
					case 'onclick':
						obj.onclick = attributes[a];
					break;
					default:
						obj.setAttribute(a, attributes[a]);
					break;
				}
			}
			return obj;
		}
	}
	
	for (var i=0; i<count; i++)
	{
		switch(elements[i])
		{
			default:
				this.create(elements[i]);
			break;
		}
	}
	
	this.tn = function(value){
		return document.createTextNode(value);
	}
	
	this.addevent = function(obj, type, fn)
	{
		if (obj.attachEvent)
		{
			obj['e'+type+fn] = fn;
			obj[type+fn] = function(){obj['e'+type+fn](window.event);}
			obj.attachEvent( 'on'+type, obj[type+fn] );
		}
		else obj.addEventListener(type, fn, false);
	}

	this.removeevent = function(obj, type, fn)
	{
		if ( obj.detachEvent )
		{
			obj.detachEvent('on'+type, obj[type+fn]);
			obj[type+fn] = null;
		}
		else obj.removeEventListener(type, fn, false);
	}
}

function gebi(id) { return document.getElementById(id); }

var curr_frm = '';
function show_frm(frm) {
	if (curr_frm == frm) {
		gebi(frm).style.display = 'none';
		gebi(frm+'_lnk').className = '';
		frm = '';
	} else {
		if (curr_frm != '') {
			gebi(curr_frm).style.display = 'none';
			gebi(curr_frm+'_lnk').className = '';
		}
		gebi(frm).style.display = 'block';
		gebi(frm+'_lnk').className = 'act';
	}
	curr_frm = frm;
}