// Class PHP Emulator
// (c) Iweb
// ----------
// v 0.2
// 11.03.2007
// base_name() function
// ----------
function Iweb_Php_Emulator()
{
    this.in_array = function(needle, haystack)
    {
        for (var i = 0; i < haystack.length; i++) {
            if (haystack[i] == needle) {
                return true;
            }
        }
        
        return false;
    }
    
    this.array_key_exists = function(needle, haystack)
    {
        for (key in haystack){
            if (key == needle){
                return true;
            }
        }
        
        return false;
    }

    this.array_push = function(a, value)
    {
        a[a.length] = value;
        return a.length;
    }
    
    this.array_first = function(a)
    {
        for (key in a){
            return a[key];
            break;
        }
    }
    
    this.array_keys = function(a)
    {
        var b = new Array();
        
        for (key in a){
            this.array_push(b, key);
        }
    }

    this.base_name = function(u)
    {
        var s = u.lastIndexOf('/');
        
        if (s != -1){
            u = u.substring(s + 1);
        }
        
        var e = u.indexOf('?');
        if (e != -1){
            u = u.substring(0, e);
        }
        
        return u;
    }
    
    this.is_numeric = function(d)
    {
        if ((isNaN(d)) || (d.length == 0)){
            return false;
        }

        return true;
    }
    
    this.explode = function(d, s)
    {
        return s.split(d);
    }
}

php = new Iweb_Php_Emulator(); 

