/* 
 * JavaScript
 * 
 * Created on: 2007.09.19
 *
 * Project: Domovoj JavaScript Framework
 * File:    domovoj.js
 * 
 * @autor Artur Wied
 * @version 0.04a lite
 *
 * Copyright (c) 2007, Artur Wied
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

var Domovoj = {
    version: '0.4a',
    requiredPrototype: '1.5.1.1',
    requiredScriptaculous: '1.7.1_beta3'
};

Domovoj.Client = {
    _getVersion: function (stre) {
       if(typeof stre == 'string') {
          var exp = eval("/^.*" + stre + "\\/([0-9\\.]+) .*$/i");
          return exp.exec(navigator.userAgent)[1];
       } else
           return false;
    }
}

if(!!(window.attachEvent && !window.opera)) {
    Domovoj.Client.engine = 'MSIE';
    var _exp = /^.*MSIE ([0-9\.]+); .*$/i;
    Domovoj.Client.version = _exp.exec(navigator.userAgent)[1];
    delete _exp;
} else if(!!window.opera) {
    Domovoj.Client.engine = 'Opera';
    Domovoj.Client.version = Domovoj.Client._getVersion('Opera');
} else if(navigator.userAgent.indexOf('AppleWebKit') > -1) {
    Domovoj.Client.engine = 'WebKit';
    Domovoj.Client.version = Domovoj.Client._getVersion('AppleWebKit');
} else if(navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1) {
    Domovoj.Client.engine = 'Gecko';
    Domovoj.Client.version = Domovoj.Client._getVersion('Gecko');
} else if(navigator.userAgent.indexOf('KHTML') > -1 && navigator.userAgent.indexOf('AppleWebKit') == -1) {
    Domovoj.Client.engine = 'KHTML';
    Domovoj.Client.version = Domovoj.Client._getVersion('KHTML');
}

Domovoj.String = {
    expression: function(str, exp) {
        if(typeof exp == 'function' || typeof exp == 'object') {
            return exp.test(str);
        } else
            return false;
    },
    isEmail: function(str) {
        var exp = /^[a-z0-9_-]+(\.[a-z0-9_\-]+)*@([a-z0-9]+[\.a-z0-9\-]*[a-z0-9]+\.)+([a-z]{2,4}|museum|travel)$/i;
        return this.expression(str, exp);
    },
    isPhone: function(str) {
        var exp = /^\+*[0-9\(\) \/-]+$/;
        return this.expression(str, exp);
    },
    isFileName: function(str) {
        //erwietern;
        var exp = /^.*[\/\\\:\*\?"<>\|]+.*$|^\s+.*$|^-+\s+$/;
        return !this.expression(exp, str);
    }
}
