// define variable
img_rollovers = [];

function isUndefined(a)
{
	return typeof a == 'undefined';
} 

/////////////////////////////////////////////////////////////////////

function showList(id)
{
	var className = document.getElementById(id).className;

	if(className == 'Hide')
		document.getElementById(id).className = 'Show';
	else if(className == 'Show')
		document.getElementById(id).className = 'Hide';
}

/////////////////////////////////////////////////////////////////////

function textField(t, text)
{
	if(t.value==text)
		t.value='';
	else if(t.value=='')
		t.value=text;
}

/////////////////////////////////////////////////////////////////////

function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if(typeof window.onload != 'function')
    		window.onload = func;
	else
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}

/////////////////////////////////////////////////////////////////////

function submit_form(child)
{
	while(child = child.parentNode)
	{
		if(child.tagName.toLowerCase() == 'form')
		{
			child.submit();
			break;
		}
	}
}

/////////////////////////////////////////////////////////////////////

function tabs()
{
	if(!isUndefined(tabs_list))
	{
		tab_count = tabs_list.length;

		for(i=0;tab_count>i;i++)
		{
			id = tabs_list[i];
			if(document.getElementById(id))
				document.getElementById(id).onclick = function() { tab_display(this); }
		}
	}
}

/////////////////////////////////////////////////////////////////////

function tab_display(_this)
{
	id = _this.id.replace(/tab/,'');
	index = tab_hide[id];

	// disable tab
	if(document.getElementById('tab'+index))
	{
		var parent = document.getElementById('tab'+index).parentNode;
		if(parent.className.search(/hLight/)>-1)
			parent.className = parent.className.replace(/hLight/,'');
	}

	// hide content
	if(document.getElementById('content'+index))
	{
		content_class = document.getElementById('content'+index).className;
		if(content_class.search(/closed/) == -1)
			document.getElementById('content'+index).className = content_class + ' closed';
	}


	// enable tab
	parent = document.getElementById('tab'+id).parentNode;
	if(parent.className.search(/hLight/) == -1)
		parent.className+= ' hLight';

	content_class = document.getElementById('content'+id).className;
	if(content_class.search(/closed/)>-1)
		document.getElementById('content'+id).className = content_class.replace(/closed/,'');
}

/////////////////////////////////////////////////////////////////////

function widgets()
{
	if($chk($('relWidgets')))
	{
		var div = $('relWidgets').getElements('div.closed');
		var div2 = $('relWidgets').getElements('div.open');
		div.merge(div2);

		div.each(function(el){
			var link = el.getElement('a',el.getElements('h3')[0]);

			link.onclick = function()
			{
				el.toggleClass('closed');
				el.toggleClass('open');
				return false;
			}
		});
	}
}

/////////////////////////////////////////////////////////////////////

function open_window(url, width, height)
{
			var window_date = new Date().getDate();
			eval('page = window.open(\''+url+'\','+window_date+', \'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+width+',height='+height+',left=50%,top=50%\');');
}

/////////////////////////////////////////////////////////////////////

runFlash = false;

function non_flash()
{
	if(runFlash)
	{
		var count = hide_flash.length;
		for(var i=0;count>i;i++)
			$(hide_flash[i]).setStyle('display','none');
	}
}

/////////////////////////////////////////////////////////////////////

function select_auto_submit()
{
	select_fields.each(function(el){
		if($chk($$('select[name='+el+']')[0]))
		{
			$$('select[name='+el+']')[0].addEvent('change',function(){
				var parent = this;

				while(parent = parent.parentNode)
				{
					//alert($(parent).getTag());
					if($(parent).getTag() == 'form')
					{
						item = parent;
						break;
					}
				}

				if(item)
					item.submit();
			});
		}
	});
}

/////////////////////////////////////////////////////////////////////
