

//----------- start function DataExtract(); ----------//
//----- A Function to Spilt the Database Group -------//

function DataExtract ( str_li, sep1, sep2, arrayName) 
//str_li = string li ?? ; sep(n) = symbol as spliting; arrayName = name of array to create
//this function returns the search result's quantity.
{
	if ( str_li!="" ){
	
		var surf_mem=new Array();				//Search result memory (RAM)
		var sep_surf=new Array(sep1, sep2);	//string to search
	
		var resul_mem=new Array();				//Memory to allocate the resulr found
		function MEM_Result( rmem, nn ){ 		//rmem to store the resul from surf_mem; //nn :: which array~
			return(resul_mem[nn] = rmem);
		}	
		
		for ( i = 0; i < sep_surf.length; i = i + sep_surf.length ) 
		//i=i+2 :: loop with two charater skipping as now looking for 2 character based string
		{
			var ssf = sep_surf[i];		//Get item to search
			var n_mem = 0;				//Memory of string position
		
			surf_mem[i] = new Array("",0);	//Set first memory to empty string, second memory to 0 value

			while ( str_li.indexOf(ssf) != -1 )	//If found
			{
				var tem_stp_1 = str_li.indexOf(ssf);
				//Get first string position save in first temp string position
				
				str_li = str_li.substring(tem_stp_1+ssf.length, str_li.length);
				//Get new string (for avoid collision purposes)
		
				var ssf2 = sep_surf[i+1];		//Get second string's position
				var lssf2 = 0;					//Take or ignore second string. If take, set to ssf2.length, else set to 0 
				
				var tem_stp_2 = str_li.indexOf(ssf2);
				
				if ( tem_stp_2 != -1 )	//If second string is exists
				{
					surf_mem[i][0] = str_li.substring(0,tem_stp_2+lssf2); 	// TEMPORALLY save the found string 
					surf_mem[i][1]++; 										// TEMPORALLY save the n string found
	
					MEM_Result( surf_mem[i][0], surf_mem[i][1] );
				}
				str_li=str_li.substring(tem_stp_2+lssf2,str_li.length);
				n_mem = n_mem + tem_stp_2 + tem_stp_1 + lssf2 + 2;
			}
		}
		
		eval( arrayName + "=new Array();" );
		for ( j=0; j<resul_mem.length; j++ ){
			eval( arrayName + "[" + j + "]=" + "resul_mem["+j+"];");
		}
		return resul_mem.length;
		
	} else alert ("Error reading database.");
} 

//----------- end function DataExtract(); ----------//

