/**
 * @classDescription Object contains javascript function equivalent to PHP
 */
var php = {
		
	//Strip whitespace (or other characters) from the beginning of a string
	ltrim : function (str, char) 
	{
		if (char != undefined) {
			for(var k = 0; k < str.length && (str.charAt(k) == char); k++);
			return str.substring(k, str.length);		
		} else {
			return str.replace(/^\s+|\s+$/g,"");
		}
	},
	
	//Strip whitespace (or other characters) from the end of a string
	rtrim : function (str, char) 
	{
		if (char != undefined) {
			for(var j=str.length-1; j>=0 && (str.charAt(k) == char); j--) ;
			return str.substring(0,j+1);
		} else {
			return str.replace(/\s+$/,"");
		}
	},
	
	//Strip whitespace (or other characters) from the beginning and end of a string
	trim : function (str, char) 
	{
		return ltrim(rtrim(str,char),char);
	},
	
	//Determine whether a variable is empty
	empty : function (mixed_var) {
	    // http://kevin.vanzonneveld.net
	    // +   original by: Philippe Baumann
	    // +      input by: Onno Marsman
	    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // +      input by: LH
	    // +   improved by: Onno Marsman
	    // +   improved by: Francesco
	    // +   improved by: Marc Jansen
	    // *     example 1: empty(null);
	    // *     returns 1: true
	    // *     example 2: empty(undefined);
	    // *     returns 2: true
	    // *     example 3: empty([]);
	    // *     returns 3: true
	    // *     example 4: empty({});
	    // *     returns 4: true
	    // *     example 5: empty({'aFunc' : function () { alert('humpty'); } });
	    // *     returns 5: false
	    
	    var key;
	    
	    if (mixed_var === "" ||
	        mixed_var === 0 ||
	        mixed_var === "0" ||
	        mixed_var === null ||
	        mixed_var === false ||
	        mixed_var === undefined
	    ){
	        return true;
	    }
	 
	    if (typeof mixed_var == 'object') {
	        for (key in mixed_var) {
	            return false;
	        }
	        return true;
	    }
	 
	    return false;
	}
};
