/**
 * @package ezix.js.imgswitch
 * @version R6.3+
 * @author 	peter bliszko ^ ezix.eu . info@ezix.eu
 */

imgswitch = {
	menus : new Array(),
	types : new Array( 'on', 'off' ),
	lang  : 'en',
	dir   : '',
	ext	  : 'gif',
	prefx : '',

	init : function( params ) {
		this.dir = params.dir;
		this.lang = params.lang;
		if( params.menus ) {
			this.menus = params.menus;
		}
		if( params.types ) {
			this.types = params.types;
		}
		if( params.ext ) {
			this.ext = params.ext;
		}
		if( params.prefx ) {
			this.prefx = params.prefx;
		}

		for( j in this.menus ) {
			if( typeof( this.menus[j] ) == 'string' ) {
				for( k in this.types) {
					if( typeof( this.types[k] ) == 'string' ) {
						objStr = 'this.img_'+this.menus[j]+'_'+this.lang+'_'+this.types[k];
						eval( objStr +' = new Image();' );
						eval( objStr +'.src = "'+this.dir+'/'+this.prefx+this.menus[j]+'_'+this.types[k]+'_'+this.lang+'.'+this.ext+'";' );
					}
				}
			}
		}
	},

	isOn : function( p ) {
		obj = document.getElementById('menu_'+p)
	return ( obj.src.indexOf('_on_'+this.lang ) > -1 );
	},

	switchImg : function( p ) {
		if( obj = document.getElementById('menu_'+p) ) {
			type = this.isOn( p ) ? 'off' : 'on';
			str = 'obj.src = this.img_'+p+'_'+this.lang+'_'+type+'.src;';
			eval( str );
		}
	}
}