/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function validateFloat(fNumber) {
    var sMatch = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/;

    return fNumber.match(sMatch) ? true : false;
}

function validateInt(fNumber) {
    var sMatch = /^\d+$/;

    return fNumber.match(sMatch) ? true : false;
}

function validateEmail(sEmail) {
    var sMatch = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

    return sEmail.match(sMatch) ? true : false;
}

function validateDate(sDate) {
    var sMatch = /^[0-9]{2}.[0-9]{2}.[0-9]{4}$/i;

    return sDate.match(sMatch) ? true : false;
}

function validateDateTime(sDate) {
    var sMatch = /^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$/i;

    return sDate.match(sMatch) ? true : false;
}

function validateUrl(sUrl) {
    var sMatch = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;

    return sUrl.match(sMatch) ? true : false;
}

function validatePhone(sPhone) {
    var sMatch = /^[0-9]{7,12}$/i;

    return sPhone.match(sMatch) ? true : false;
}

function validatePostal(sCode) {
    var sMatch = /^[0-9]{2}\-[0-9]{3}$/i;

    return sCode.match(sMatch) ? true : false;
}

function isNumber(n) {
    return !isNaN(parseInt(n)) && isFinite(n);
}

function trim(str) {
    if(str=="")
        return "";
    else
        return str.replace(/^\s+|\s+$/g, '') ;
}

function var_dump(obj) {
    if(typeof obj == "object") {
        return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+"\nValue: " + obj;
    } else {
        return "Type: "+typeof(obj)+"\nValue: "+obj;
    }
}


