package com.squidder.base.baseLoader.business {
	import com.squidder.base.baseLoader.types.BinaryTextItem;
	import com.squidder.base.baseLoader.types.ImageItem;
	import com.squidder.base.baseLoader.types.SoundItem;
	import com.squidder.base.baseLoader.types.TextItem;		

	/**
	 * Support class for BaseLoader.
	 * @author Jon Reiling
	 */
	public class BaseLoaderTypeManager {
		
		public static const IMAGE_TYPES : String = ".jpg,.gif,.png,.swf";
		public static const SOUND_TYPES : String = ".mp3";
		public static const TEXT_TYPES : String = ".txt, xml";

		/**
		 * Returns the appropriate class type, depending on the type of file.
		 * @param url URL of the asset to examine.
		 * @return The class that corresponds with the url string.
		 */
		public static function getType( url:String ) : Class {
			
			var fileExtension : String = url.substring( url.lastIndexOf( "." ) , url.length );
			if ( IMAGE_TYPES.indexOf( fileExtension ) != -1 ) return ImageItem;			
			if ( SOUND_TYPES.indexOf( fileExtension ) != -1 ) return SoundItem;			
			if ( TEXT_TYPES.indexOf( fileExtension ) != -1 ) return TextItem;	
			if ( url == "Binary" ) return BinaryTextItem;
			
			return TextItem;		
			
		}
		
	}
}
