
/*********************************************/

// 			Common JS functions
//
//			Created by Kow, 2008
//			http://skyweb.hu/kow

/*********************************************/

	function slideShow( Obj, thumbsEnabled ){
		var pass = this;
		// initializing
		this.curImg = 0;
		this.thumbsEnabled = ( $defined( thumbsEnabled ) )? thumbsEnabled :false;
		this.slides = Obj;
		this.slides.each( function( img, index ){ 
			if( index > 0 ) img.fade(); 
			img.set('morph', { duration: 'long' });
		}, this);
		
		this.next = function(){
			pass.curImg++;
			this.slides.each( function( img, index ){ 
				img.morph({ opacity: 0 });
			}, this);
			if( pass.curImg == this.slides.length ) pass.curImg = 0;
			this.slides[ pass.curImg ].morph({ opacity: 1 });
			if( this.thumbsEnabled ) this.updateThumbs();
		}
		this.prev = function(){
			pass.curImg--;
			this.slides.each( function( img, index ){ 
				img.morph({ opacity: 0 });
			}, this);
			if( pass.curImg < 0 ) pass.curImg = this.slides.length - 1;
			this.slides[ pass.curImg ].morph({ opacity: 1 });
			if( this.thumbsEnabled ) this.updateThumbs();
		}
		this.updateThumbs = function(){
			var prevUpdate = ( pass.curImg == 0 )?this.slides[ this.slides.length-1 ].src : this.slides[ pass.curImg-1 ].src;
			var mainUpdate = this.slides[ pass.curImg ].src;
			var nextUpdate = ( pass.curImg == this.slides.length-1 )?this.slides[ 0 ].src : this.slides[ pass.curImg+1 ].src;
			$('thumb1').setStyles({ 'background-image': 'url('+ this.getThumbUrl(prevUpdate)+')', 'opacity': 0.5 });
			$('thumb2').setStyle( 'background-image', 'url('+this.getThumbUrl(mainUpdate)+')' );
			$('thumb3').setStyles({ 'background-image': 'url('+this.getThumbUrl(nextUpdate)+')', 'opacity': 0.5 });
		}
		this.getThumbUrl = function( str ){
			var fileName = str.split('/').getLast();
			var linkArr = str.split('/');
			linkArr[ linkArr.indexOf( fileName ) ] = 'thumbs/' + fileName;
			return linkArr.join('/');
		}
		if( this.thumbsEnabled ) {
			this.updateThumbs();
			$('thumb1').addEvent( 'click', function(){ gall.prev(); });
			$('thumb3').addEvent( 'click', function(){ gall.next(); });
		}
	}
	
	window.addEvent( 'load', function(){ 
		$('right_panel').getElement('input').addEvent( 'keydown', function(e){ 
			if( e.key == 'enter' ) document.location = "kereses.php?q=" + this.value;
		});
		$('search_send').addEvent( 'click', function(e){ 
			document.location = "kereses.php?q=" + $('right_panel').getElement('input').value;
		});
		$$('.concon')[0].addEvent( 'click', function(e){ 
			document.location = "kapcsolat.php";
		});
		$('right_panel').getElement('input').addEvent( 'click', function(e){ 
			this.value='';
		});

		new Tips( '.icccon', { className: 'tippp', offsets: {'x': 16, 'y': 16} } );
	});

	function go( view ){
		document.location += ( document.location.href.indexOf( '?' ) == -1 ) ? '?mode=' + view : '&mode=' + view;
		return false;
	}

