/*******************************************************************************
    Filename        :   myformvalidation.js
    Created	        :   18 March 2008
    Created by		:   Markus Sommerfeld
    Company         :   Charamel GmbH 
    Last Updated	:   25 June 2008 (16:21:00)
    Version         :   1.0.2
    
    Comment         :   This file includes the necessary CORE files
                        - validation.class.js       OR compressed/validation.class.js
                        - validation.function.js    OR compressed/validation.function.js
                        
                        If you want to include the compressed files set the parameter
                        useCompressed       :   "true"
                        
                        To use a different Style to the default style set  
                        defaultStyle        :   "myStyle"
--------------------------------------------------------------------------------
    
    **********************
    * VALIDATION METHODS *
    **********************       
        -   req                     : field must not empty
        -   dependOn=FIELD_ID       : Field is require if "FIELD_ID" not empty
    
        #String Methods#
        -   contains=X              : Value must contain X
        -   equal=FIELD_ID          : Value of field must equal value of "FIELD_ID"
        -   isChar                  : only letters are OK
        -   isEmail                 : field must contains a Email regExp:"([\\w-.]+)@([\\w-]+)\\.([a-z]{2,5})"    
        -   isPhone                 : only PhoneNumbers like +49 (0) 1234-567-89 OR +49.(0).1234.567.89
        -   minOfChar=X             : minimal count of Characters
        -   maxOfChar=X             : maximal count of Characters
        -   regExp                  : Search vor given RegExp Bsp: ([\\w-]+)@([\\w-]+)\\.([a-z]{2,6}) (http://www.javascriptkit.com/jsref/regexp.shtml)
        -   withoutChar='X'         : Contains the field value "X", the function returns FALSE / Ex: X='test' ( 'this is a test' = FALSE | 'this is a example' = TRUE )
        -   unequal=FIELD_ID        : Value of field must unequal value of "FIELD_ID"
    
        #Numeric Methods#
        -   isNumber                : only numbers are OK
        -   min                     : Minimal size of number ( exp.: min=2000 / returs false if value <2000 )
        -   max                     : Maximal size of number ( exp.: max=2003 / returs false if value >2003 )
        
        #Date Methods#                                         
                      
*******************************************************************************/
_props_ = new Object();
_props_ = {
/**********************************
 * Properties for form validation
 *********************************/

    // JS Compression
    useCompressed       :   "false",

    // Default style
    defaultStyle        :   "stripes", // default, stripes
    
    // Path to the Validation Styles (default: styles/)
    styleUrl            :   "styles/",
    
    // Path to Validation JS
    jsValPath           :   "js/form_validation/",

    // This filename
    jsFileName          :   "myformvalidation.js",
   
    // Path to the Core JavaScript (default: core/)
    jsCoreUrl           :   "c/",
    
    // Path to the Compressed Core JavaScript (default: core/compressed/)
    jsCompressed        :   "core/compressed/",




    /********************  DO NOT CHANGE *******************************/
    // REQUIRE Validation Functions    
    reqFunctionVersion  :   "1.0.12",
    // REQUIRE Validation Class
    reqClassVersion     :   "1.0.16",
    
    allowedParameters   :   "style,compress"
    /********************  DON'T CHANGE *******************************/    
};

// Functions to SET Properties
_setUseCompressed   = function(_VALUE){ _props_.useCompressed = _VALUE };

// Functions to GET Properties
_getReqClass        = function(){ return _props_.reqClassVersion; };
_getReqFunction     = function(){ return _props_.reqFunctionVersion; };
_getJSValPath       = function(){ return _props_.jsValPath; };
_getJSFileName      = function(){ return _getJSValPath() + _props_.jsFileName; };
_getJSCoreUrl       = function(){ return _getJSValPath() + _props_.jsCoreUrl; };
_getJSCompressedUrl = function(){ return _getJSValPath() + _props_.jsCompressed; };
_getUseCompressed   = function(){ return _props_.useCompressed; };
_getStyleUrl        = function(){ return _getJSValPath() + _props_.styleUrl; };
_getDefaultStyle    = function(){ return _props_.defaultStyle; };
_getAllowedParas    = function(){ return _props_.allowedParameters; };


/*****************************************************************
 *  FUNCTION to generate <script ></script>
 *****************************************************************/ 
_getJavaScript = function(_fileName, _path){
    if (_getUseCompressed() == "true"){
        if (_path == undefined){ _path = _getJSCompressedUrl(); };
    }
    else{
        if (_path == undefined){ _path = _getJSCoreUrl(); };
    };
    var returnScript    = '<script type="text/javascript"'
                        + 'src="'+ _path  + _fileName + '" '
                        + '><\/script>';
    return returnScript;
};

/*****************************************************************
 *  FUNCTION to generate <style ></style>
 *****************************************************************/ 
_getStyle      = function(_fileName, _path){
    if (_path == undefined){ _path = _getStyleUrl() };
    var returnStyle    = '<style type="text/css">'
                        + '@import "'+ _path  + _fileName + '";'
                        + '<\/style>';
    return returnStyle;
};



/**************************************
 *  Include of
 *  - validation.function
 *  - validation.class
 *  - vaidation Style
 *************************************/ 
var styleToUse  = _getDefaultStyle();
var useCompress = _getUseCompressed();

document.write(_getJavaScript("validation.function.js"));
document.write(_getJavaScript("validation.class.js"));
document.write(_getStyle(styleToUse + "/style.css"));
