/*
-------------------------------------------------------------------------------
code language:		js
package name:		files/js/
class name:		dcjs
class type:		dynamic
version:			4.0
date:			20101103
copyright:		massimo cardascia
url:				www.plustic.de / www.dot-control.com
-------------------------------------------------------------------------------
*/

///*	imports //////////////////////////////////////////////////////////////////

///* class definition /////////////////////////////////////////////////////////
	function DCJS_dataStorage($s_uniqueSearchKey)
		{
///*		class versionising //////////////////////////////////////////////////
		DCJS.__s_classVersion = "1.00";						///h	dclib intern class version
		DCJS.__s_className = "DCJS_dataStorage";				///h	dclib intern class name
		DCJS.__s_classType = "class";							///h	dclib intern class type ["class", "subclass"]

///*		class properties ////////////////////////////////////////////////////
		this.__s_uniqueSearchKey;							///h	stores search key
		this.__o_data;
		this.__i_elements;

///*		class system init ///////////////////////////////////////////////////
		DCJS_dataStorage.f_initSystem = function()
			{
			}

///*		class constructor ///////////////////////////////////////////////////
		this.f_constructor = function($s_uniqueSearchKey)
			{
			if($s_uniqueSearchKey)
				{
				this.f_initData($s_uniqueSearchKey);
				}
			}

///*		public static functions /////////////////////////////////////////////

///*		private static functions ////////////////////////////////////////////

///*		public functions ////////////////////////////////////////////////////

///*		get content height percentage ----------------------------------
		this.f_getData_byUniqueSearchKey = function($o_searchKey)
			{
			return(this.__o_data[$o_searchKey]);
			}

///*		get content height percentage ----------------------------------
		this.f_getData = function($o_data)
			{
///*			properties
			var $storage_data = null;
			var $s_storage_key;
			var $s_var_name;
			var $i_var_values;
			var $b_found;

///*			find object
			if($o_data[this.__s_uniqueSearchKey] != undefined)
				{
///*				normal behavior directly search by unique search key
				$storage_data = (this.__o_data[$o_data[this.__s_uniqueSearchKey]]);
				}
			else
				{
///*				check how many values transmitted
				$i_var_values = 0;
				for($s_var_name in $o_data)
					{
					$i_var_values++;
					}

///*				parse all data finding corresponding object
				for($s_storage_key in this.__o_data)
					{
///*					search storage
					$storage_data = this.__o_data[$s_storage_key];

///*					case a : one var name transmitted
					if($i_var_values == 1)
						{
///*						compare
						if($storage_data[$s_var_name] == $o_data[$s_var_name])
							{
							$b_found = true;
							break;
							}
						}
///*					case b : more var names transmitted
					else
						{
///*						compare
						for($s_var_name in $o_data)
							{
							if($storage_data[$s_var_name] == $o_data[$s_var_name])
								{
								$b_found = true;
								break;
								}
							}
						}
					}

///*				check valid storage
				if($b_found != true)
					{
					$storage_data = null;
					}
				}
			return($storage_data);
			}

///*		get content height percentage ----------------------------------
		this.f_addData = function($o_data)
			{
///*			properties
			var $s_storageID;
			var $storage_data;
			var $s_var_name;

///*			save
			$s_storageID = $o_data[this.__s_uniqueSearchKey];
			if(($storage_data = this.__o_data[$s_storageID]) == null)
				{
				$storage_data = this.__o_data[$s_storageID] = {};
				this.__i_elements ++;
				}

///*			update all data
			for($s_var_name in $o_data)
				{
				$storage_data[$s_var_name] = $o_data[$s_var_name];
				}
		
///*			return storage
			return($storage_data);
			}

///*		private functions ///////////////////////////////////////////////////

///*		init data ---------------------------------------------------------
		this.f_initData = function($s_uniqueSearchKey)
			{
			this.__o_data = {};
			this.__i_elements = 0;
			this.__s_uniqueSearchKey = $s_uniqueSearchKey;
			}

///*		construction
		this.f_constructor($s_uniqueSearchKey);
		}

///*	init system
var $o_class = new DCJS_dataStorage();
DCJS_dataStorage.f_initSystem();

