/*
 * Author Krum Lozev
 * Script page is found at http://kik.dgd-bg.com,
 * there development version of this code can be found.
 * Use this code under the terms of GPL v3
 * and keep this note intact
 */
	var w		= 140;
	var h		= 100;
	var i_displayed	= 2;
	var i_middle	= 2;
	var trans_time	= 0.05;

	var pic_shrink_perc	= 0.85;

	items = new Array ();
	i_curly_mid = 0;

	function MagniItemi_Init () {
		i=0;
		while ( true ) {
			tmp = document.getElementById('MazenItem_' + i);
			if (!tmp)
				break;
			items[ items.length ] = new mazen_item(tmp, i);
			i++;
		}

		i_curly_mid = Math.floor ( i_displayed / i_middle );
		if ( i_curly_mid >= items.length )
			i_curly_mid = items.length -1;

		for ( j=0; j<items.length; j++ ) {
			var dist = Math.abs ( j - i_curly_mid );
			var to_w = ( dist <= i_displayed ) * ( w * ( ( i_displayed - dist ) /i_displayed ) );
			var to_h = ( dist <= i_displayed ) * ( h * ( ( i_displayed - dist ) /i_displayed ) );

			if ( to_w && to_h && dist ) {
				to_w = w*pic_shrink_perc;
				to_h = h*pic_shrink_perc;
			}

			items[j].resize ( to_w, to_h );
			items[j].CheckIfActive();
		}

	}

	function ScrollLeft () {
		if (i_curly_mid>=(items.length-1))
			return;

		i_curly_mid++;

		for ( j=0; j<items.length; j++ ) {
			var dist = Math.abs ( j - i_curly_mid );
			new_w = ( dist <= i_displayed ) * ( w * ( ( i_displayed - dist ) / i_displayed ));
			new_h = ( dist <= i_displayed ) * ( h * ( ( i_displayed - dist ) / i_displayed ));
			if ( new_w && new_h && dist ) {
				new_w = w*pic_shrink_perc;
				new_h = h*pic_shrink_perc;
			}
			items[j].Move ( new_w, new_h );
		}
	}

	function ScrollRight () {
		if (i_curly_mid<=0)
			return;
		i_curly_mid--;
		for ( j=0; j<items.length; j++ ) {
			var dist = Math.abs ( j - i_curly_mid );
			new_w = ( dist <= i_displayed ) * ( w * ( ( i_displayed - dist ) / i_displayed ) );
			new_h = ( dist <= i_displayed ) * ( h * ( ( i_displayed - dist ) /i_displayed ) );
			if ( new_w && new_h && dist ) {
				new_w = w*pic_shrink_perc;
				new_h = h*pic_shrink_perc;
			}

			items[j].Move ( new_w, new_h );
		}
	}

	function force_active ( j, url ) {
		offsets = j - i_curly_mid;
		if (offsets==0) {
			document.location.href=url;
			return true;
		}
		if (offsets>0)
			for ( i=0; i<offsets; i++ )
				setTimeout ('ScrollLeft()', 1000*(i*trans_time));
		else
			for ( i=0; i<offsets*-1; i++ )
				setTimeout ('ScrollRight()', 1000*(i*trans_time));
		return false;
	}

