// JavaScript Document
function _isDefined(_obj) {
	if (null == _obj) {
		return false;
	}
	if ("undefined" == typeof(_obj) ) {
		return false;
	}
	return true;
	
}

function showhide_tr(trId){
	trObj = $(trId);
	var cur	= trObj.style.display;	
	if ((cur == 'none')||(!_isDefined(trObj.style.display))){
		if (navigator.appName=="Netscape"){
			show = "table-row";
		}
		else{
			show = "block";
		}
	}	 
	else{
		show = "none";
	}
	trObj.style.display = show;
}

function showhide_tb(trId){
	trObj = $(trId);
	var cur	= trObj.style.display;	
	if ((cur == 'none')||(!_isDefined(trObj.style.display))){
		if (navigator.appName=="Netscape"){
			show = "table";
		}
		else{
			show = "block";
		}
	}	 
	else{
		show = "none";
	}
	trObj.style.display = show;
}

function showhide_td(trId){
	trObj = $(trId);
	var cur	= trObj.style.display;	
	if ((cur == 'none')||(!_isDefined(trObj.style.display))){
		if (navigator.appName=="Netscape"){
			show = "table-cell";
		}
		else{
			show = "block";
		}
	}	 
	else{
		show = "none";
	}
	trObj.style.display = show;
}


function rowShowHidden(_img,trId){
	trObj = window.document.getElementById(trId);
	var cur	= trObj.style.display;
	
	if ((cur == 'none')||(!_isDefined(trObj.style.display))){
		if (navigator.appName=="Netscape"){
			show = "table-row";
		}
		else{
			show = "block";
			
		}
		_img.src = "images/category_show.jpg";
	}	 
	else{
		show = "none";
		_img.src = "images/category_hidden.jpg";
	}	
	trObj.style.display = show;
}

function moveSelectList(_Source,_Target){
	_SObj = $(_Source);
	_TObj = $(_Target);	
	for (i=0;i<_SObj.options.length;i++){
		if ((_SObj.options[i].value != -1) && (_SObj.options[i].selected)){
			_Index = _TObj.options.length++;
			_TObj.options[_Index].value = _SObj.options[i].value;
			_TObj.options[_Index].text = _SObj.options[i].text;
		}
	}
	
	i=_SObj.options.length-1;
	while ((i>0)&&(_SObj.options.length>1)){
		if ((_SObj.options[i].value != -1) && (_SObj.options[i].selected)){
			_SObj.options[i].selected = false;
			if (i <_SObj.options.length-1){
				for(var AI=i;AI<_SObj.options.length-1;AI++){
					_SObj.options[AI].text = _SObj.options[AI+1].text;
					_SObj.options[AI].value = _SObj.options[AI+1].value;
				}
			}
			_SObj.options.length--;
		}
		i--;
	}
	createCodeRule("codeselected","codeRuleList");
}

function moveItemList(_Pos,_Source){
	_SObj = $(_Source);
	Index = _SObj.selectedIndex;
	if (_isDefined(_SObj.options[Index+_Pos])&& (_SObj.options[Index+_Pos].value != -1)){			
		_TempValue = _SObj.options[Index].value;
		_TempText = _SObj.options[Index].text;
		
		_SObj.options[Index].text = _SObj.options[Index+_Pos].text;
		_SObj.options[Index].value = _SObj.options[Index+_Pos].value;
		
		_SObj.options[Index+_Pos].text = _TempText;
		_SObj.options[Index+_Pos].value = _TempValue;
		
		_SObj.options[Index+_Pos].selected = true;
		_SObj.options[Index].selected = false;
	}
	createCodeRule("codeselected","codeRuleList");
}

function createCodeRule(_Source,_Target){
	_SObj = $(_Source);
	_TObj = $(_Target);	
	_TObj.innerHTML = "";
	_Cong = "";
	for (i=0;i<_SObj.options.length;i++){
		if (_SObj.options[i].value != -1){
			_TObj.innerHTML += _Cong + _SObj.options[i].text;
			_Cong = " + ";
		}
	}
}

function ajaxPost(_Url,_Form, _ResultContentId){
	new Ajax.Updater(_ResultContentId,_Url, {
		method: 'post',
		parameters: $(_Form).serialize(),
		onCreate: function(transport) { 
							$(_ResultContentId).innerHTML = '<span style="width:100%; text-align:center; background-color:#FFFFFF"><img src="images/ajax.gif" width="16" border="0" align="absmiddle"></span>';    
						}
	});
}
function ajaxLoad(_Url, _ResultContentId){
	new Ajax.Updater(_ResultContentId,_Url, {
					 	method: 'get',
						onCreate: function(transport) { 
							$(_ResultContentId).innerHTML = '<span style="width:100%; text-align:center; background-color:#FFFFFF"><img src="images/ajax.gif" width="16" border="0" align="absmiddle"></span>';    
						}						
					});
}


var _currentShowCat = "";
function UpdateDocumentSubject(_Url, _ResultContentId){
	if (_currentShowCat != _ResultContentId){
		new Ajax.Updater(_ResultContentId,_Url, {
					method: 'get',
					onCreate: function(transport) { 
						$(_ResultContentId).innerHTML = '<span style="width:100%; text-align:center; background-color:#FFFFFF"><img src="images/ajax.gif" width="16" border="0" align="absmiddle"></span>';    
					},
					onComplete:function(transport) { 
						if (_currentShowCat != ""){
							$(_currentShowCat).innerHTML = "";
						}
						_currentShowCat = _ResultContentId;
					}
				});		
	}
}

function showHidenSub(_objId){
	tbName = "tb_"+_objId;
	imgName = "img_"+_objId;
	var cur	= $(tbName).style.display;	
	if ((cur == 'none')||(cur=="")){
		if (navigator.appName=="Netscape"){
			show = "table";
		}
		else{
			show = "block";
		}
		if (typeListArr[_objId]){
			$(imgName).src = $(imgName).src.substring(0,$(imgName).src.indexOf("checked.gif")) + "openchecked.gif";
		}else{
			$(imgName).src = $(imgName).src.substring(0,$(imgName).src.indexOf(".gif")) + "open.gif";
		}
	}	 
	else{
		show = "none";
		if (typeListArr[_objId]){
			$(imgName).src = $(imgName).src.substring(0,$(imgName).src.indexOf("openchecked.gif")) + "checked.gif";
		}else{
			$(imgName).src = $(imgName).src.substring(0,$(imgName).src.indexOf("open.gif")) + ".gif";
		}
	}
	$(tbName).style.display = show;
}

// Slide image list for news
function slideit(){
	if (number_of_images >1){
		if (!document.images)
		return
		if (document.all)
			slide.filters.blendTrans.apply();
								
		document.images.slide.src=eval("image"+step+".src");								
		if (document.all)
			slide.filters.blendTrans.play()

		if (step<number_of_images)
			step++
		else
			step=0
		if 	(step==number_of_images){
			step=0
		}	
		if (document.all)
			setTimeout("slideit()",speed*1000+3000);
		else
			setTimeout("slideit()",speed*1000);
	}
}