var ajaxObj;
var ajaxObjFilter;

function handle_load_news( id ){

										
	if ( !$defined(ajaxObj) ){
		
		var morph = new Fx.Morph('newsDisplay', {link: 'chain'}, {duration: 2000, transition: Fx.Transitions.Sine.easeOut});
		
		ajaxObj = new Request({
								method: 'post',
								url: 	'/ajax/news/show_news_entry.php',
								//data: 	{ 'id': id },
								onRequest: function(){
														var loader	=	new Element( 'img', {
																							'id':	'ajaxLoader',
																							'alt': 	'loader',
																							'src':	'/img/ico/loader.gif'										
																						} );								
														loader.injectAfter($('newsNav'));
														showLoader( true );
														//$('Submit').disabled = true;
														//$('newsDisplay').fade(out);
														$('newsDisplay').setStyle('opacity',0);
														//morph.start({'opacity': 0});
											},
								onComplete: function( ){
														//$('Submit').disabled = false;
														showLoader( false );
														morph.start({'opacity': 1});
														
											},
								onSuccess: 	function( response ){
									 			$('newsDisplay').set( 'html', response );
											},
								onFailure: 	function(){
												$('newsDisplay').set( 'text', 'An error occured!');		
											}
		});
	}
	
	ajaxObj.send('id='+id);

	$$('#newsNav .activeItem, #navFrame .activeItem').each(	function(el){
															el.removeClass( 'activeItem' );
	});
	$('nwdTitle_'+id).addClass( 'activeItem' );
	return true;	
}
function handle_filter( formId ){

	if ( !$defined(ajaxObjFilter) ){
		
		var morph = new Fx.Morph('archiveNav', {link: 'chain'}, {duration: 2000, transition: Fx.Transitions.Sine.easeOut});
		
		ajaxObjFilter = new Request({
								method: 'post',
								url: 	$(formId).action,
								data: 	$(formId),
								onRequest: function(){
														var loader	=	new Element( 'img', {
																							'id':	'ajaxLoader',
																							'alt': 	'loader',
																							'src':	'/img/ico/loader.gif'										
																						} );								
														loader.injectAfter($('archiveNav'));
														showLoader( true );
														//$('Submit').disabled = true;
														//$('archiveNav').fade(out);
														$('archiveNav').setStyle('opacity',0);
														//morph.start({'opacity': 0});
											},
								onComplete: function( ){
														//$('Submit').disabled = false;
														showLoader( false );
														morph.start({'opacity': 1});
														
											},
								onSuccess: 	function( response ){
									 			$('archiveNav').set( 'html', response );
											},
								onFailure: 	function(){
												$('archiveNav').set( 'text', 'An error occured!');		
											}
		});
	}
	
	ajaxObjFilter.send();	
}

function handle_show_filter(){
	
	var imgSrc1	=	"/img/ico/arrow_black.gif";
	var imgSrc2	=	"/img/ico/arrow_black_down.gif";
	
	var myFx = new Fx.Tween('archive');
	if ( $('filterArrow').getProperty('src') == imgSrc1 ) {
		//open
		$('filterArrow').setAttribute('src', imgSrc2 );
		$('archive').setStyle('opacity', '0');
		$('archive').setStyle('display', 'block' );
		myFx.start('opacity', '0', '1');
	}else{
		//close
		$('filterArrow').setAttribute('src', imgSrc1 );
		myFx.start('opacity', '1', '0');
		var myFunc	=	function(){ $('archive').setStyle('display', 'none' ); };
		myFunc.delay(600);
	}
}

/* event functions below */
function handle_load_events( id, url ){

	var morph = new Fx.Morph('newsDisplay', {link: 'chain'}, {duration: 1800, transition: Fx.Transitions.Sine.easeOut});
	
	var ajaxObj = new Request({
							method: 'post',
							url: 	url,
							//data: 	{ 'id': id },
							onRequest: function(){

													var loader	=	new Element( 'img', {
																						'id':	'ajaxLoader',
																						'alt': 	'loader',
																						'src':	'/img/ico/loader.gif'										
																					} );								
													$('titleRow').adopt(loader);
													showLoader( true );
													$('newsDisplay').setStyle('opacity',0);
										},
							onComplete: function( ){
													showLoader( false );
													morph.start({'opacity': 1});
										},
							onSuccess: 	function( response ){
								 			$('newsDisplay').set( 'html', response );
								 			$$('#newsDisplay .reflect').each(	function(img){
								 												Reflection.add(img, {'height': '0.4', 'opacity': '0.6'});
								 											})
										},
							onFailure: 	function(){
											$('newsDisplay').set( 'text', 'An error occured!');
										}
	});
	
	ajaxObj.send('id='+id);
	
	$$('#newsNav .activeItem, #navFrame .activeItem').each(	function(el){
															el.removeClass( 'activeItem' );
						 							});
	$('nwdTitle_'+id).addClass( 'activeItem' );


	return true;	
}

function openBigImg(img_url,img_width,img_height){

	if (typeof Ha_popup != "undefined" && !Ha_popup.closed){
		Ha_popup.close();
	}
	var url		=	"/download/popups/show_img.php?img_url="+img_url;	
	var name	=	"img";
	var properties=	"width="+ (img_width) +",height="+ (img_height) +",screenX=1,screenY=1,left=1,top=1,status,no ,yes";
	var openerName ="";
	var msg		=	name;
	
	Ha_popup	=	openWindow(url, name, properties, openerName);		
}

function handleImages(prvImg, curImg, nxtImg){
	//Wenn auf weiter geklickt wird.
	if (nxtImg != 'no'){
		document.getElementById(curImg).style.display	=	"none";
		document.getElementById(nxtImg).style.display	=	"inline";
		document.location.href							=	"#"+ (document.anchors["anch_"+ (nxtImg)].name);
	}
	//Wenn auf zurueck geklickt wird.
	if (prvImg != 'no'){
		document.getElementById(curImg).style.display	=	"none";
		document.getElementById(prvImg).style.display	=	"inline";
		document.location.href							=	"#"+ (document.anchors["anch_"+ (prvImg)].name);
	}

}
