var myPane = null;
var	myForm = null;

function btnOvr(el)
{
	$(el).addClass('filterBtnHvr');
}

function btnOut(el)
{
	$(el).removeClass('filterBtnHvr');
}

function btnOvr2(input)
{
	$(input).addClass('SoftBtnHvr');
}

function btnOut2(input)
{
	$(input).removeClass('SoftBtnHvr');
}

function swOvr(el)
{
	$(el).addClass('SwListHvr');
}

function swOut(el)
{
	$(el).removeClass('SwListHvr');
}

function swClick(el)
{
	myForm.setUrl('softwareForm.html?SoftwareId='+el.id.slice(1));
	new Fx.Style('myForm', 'backgroundColor', {transition: Fx.Transitions.quadInOut, duration: 500}).custom('CCC', 'F4F4F4');
}

function tagOvr(el)
{
	$(el).addClass('TagListHvr');
}

function tagOut(el)
{
	$(el).removeClass('TagListHvr');
}

function tagClick(el)
{
	myForm.setUrl('tagForm.html?TagId='+el.id.slice(1));
//	new Fx.Color('SwInfoName', 'borderColor', {transition: fx.Transitions.quadInOut, duration: 500}).custom('CCC', 'F4F4F4');
}

function tabOvr(el)
{
	$(el).addClass('BoxTabHvr');
}

function tabOut(el)
{
	$(el).removeClass('BoxTabHvr');
}

function tabClick(el)
{
	myPane.url = el.id + '.html';
	filter($('iniFilter'));
	$(el.parentNode).getElements('td.BoxTabSel').each(function(el) {el.removeClass('BoxTabSel');});
	el.addClass('BoxTabSel');
}

function filter(el)
{
	var	prev = $(el.parentNode).getElement('.filterBtnSel');
	if (prev != null && prev != $(el))
		prev.removeClass('filterBtnSel');
//	new Fx.Style('myPane','opacity',{duration: 1000,wait:true,transition: fx.Transitions.linear}).custom(0.99,0.0);
//	$(myPane).setStyle('Opacity','0.0');
	var	page = myPane.url.split("?")[0];
//	alert(page + '?Filter='+el.getAttribute('name'));
	myPane.setUrl(page + '?Filter='+el.getAttribute('name'));
//	new Fx.Style('myPane','opacity',{duration: 1000,wait:true,transition: fx.Transitions.linear}).custom(0.0,1.0);
	if (prev != $(el))
		el.addClass('filterBtnSel');
}

function onSoftComplete(){
	myPane.reload();
}

var addSoftRemote = new Remote('addAccSoft.fnc.php5',{onComplete:onSoftComplete});
var remSoftRemote = new Remote('remAccSoft.fnc.php5',{onComplete:onSoftComplete});

function addSoft(el) {
	swClick(el.parentNode.parentNode);
	var args = [];
	args["SoftwareId"] = el.parentNode.parentNode.id.slice(1);
	addSoftRemote.call(args);
}

function remSoft(el) {
	swClick(el.parentNode.parentNode);
	if (confirm('Do you really want to remove this software from your personal list?') == false)
		return;
	var args = [];
	args["SoftwareId"] = el.parentNode.parentNode.id.slice(1);
	remSoftRemote.call(args);
}

var ScrollPaneEx = ScrollPane.extend({
	update: function() {
		this.parent();
		this.content.getElements('tr.SwInfo').each(function(el){el.onmouseover=swOvr.pass(el);el.onmouseout=swOut.pass(el);el.onclick=swClick.pass(el);});
		this.content.getElements('tr.TagInfo').each(function(el){el.onmouseover=tagOvr.pass(el);el.onmouseout=tagOut.pass(el);el.onclick=tagClick.pass(el);});
		this.content.getElements('input.SoftBtn').each(function(el){el.onmouseover=btnOvr2.pass(el);el.onmouseout=btnOut2.pass(el);});
	}
});

function pageInit()
{
	$('TabBox').getElements('td.BoxTab').each(function(el){el.onmouseover=tabOvr.pass(el);el.onmouseout=tabOut.pass(el);el.onclick=tabClick.pass(el);});
}

window.addEvent('domready',pageInit);