	// ------------------------------------------------------------------------------------------------- //
	// SET language 
	function set_language(lang,system)
	{
		if(lang != "")
		{
			$.get("../ajax_load/ajax_set_language.php?uLang=" + lang, 
			function(data)
			{
				if(data == "true")
				{
					if(system == "home")
						window.location = "../home/index.php";
					else
						location.reload(true);
				}
				else if(data == "false")
				{
					// SET language failed
				}
			});
		}
	}
	// ------------------------------------------------------------------------------------------------- //
	// SET company 
	function set_company(comp)
	{
		if(comp != "")
		{
			$.get("../ajax_load/ajax_set_company.php?uComp=" + comp, 
			function(data)
			{
				if(data == "true")
				{
					location.reload(true);
				}
				else if(data == "false")
				{
					// SET language failed
				}
			});
		}
	}
	// ------------------------------------------------------------------------------------------------- //
	function ajax_load_opt(url,objID)
	{
		$.getJSON(url,
	
			function(j)
			{
				var options = '';
				var selIndex = "";
				for (var i = 0; i < j.length; i++)
				{
					options += '<option value="' + j[i].optionValue + '"' ;
					if(j[i].selected == "SELECTED") {
						selIndex = j[i].optionValue;
						options += ' selected>' + j[i].optionDisplay + '</option>'; //selIndex = j[i].optionValue;
					}
					else
						options += ' >' + j[i].optionDisplay + '</option>';
					
				}
			   	
				$("select#"+objID).html(options);
				
				// this for firefox
				try
				{
					$("#"+objID).val(selIndex);
				}
				catch(ex)
				{}
			}
		)
	}
	// ------------------------------------------------------------------------------------------------- //
	function trim(stringToTrim)
	{
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}
	// ------------------------------------------------------------------------------------------------- //
	function redirect(url)
	{
		window.location = url;	
	}
	// ------------------------------------------------------------------------------------------------- //
	function left(str, n)
	{
		if (n <= 0)
			return "";
		else if (n > String(str).length)
			return str;
		else
			return String(str).substring(0,n);
	}
	// ------------------------------------------------------------------------------------------------- //
	function right(str, n)
	{
		if (n <= 0)
			return "";
		else if (n > String(str).length)
			return str;
		else
		{
			var iLen = String(str).length;
			return String(str).substring(iLen, iLen - n);
		}
	}
	// ------------------------------------------------------------------------------------------------- //
	function filter_id(value)
	{	
		value = value.replace(/\s{0,}/g,"");	// replace all whitespace to empty	
		value = value.replace(/\,{0,}$/g,"");	// replace ',' at the end of the string
		value = value.replace(/^\,{0,}/g,"");	// replace ',' at the front of the string
		value = value.replace(/\,{1,}/g,",");	// replace ',' at the front of the string
		
		return value
	}