//----------------------------------------------------
// indicate browser
//----------------------------------------------------
var isIE4 = (document.all ? true : false);
var isNS6 = ((document.rowsgetElementById && !isIE4) ? true : false);
var isNS4 = (document.layers ? true : false);
var isIE6 = (isIE4 && navigator.appVersion.match('MSIE [67]') ? true : false);

function getElement(id) {
        if (isNS6) return document.getElementById(id);
        if (isIE4) return document.all[id];
        if (isNS4) return document.layers[id];
        if (document.getElementById != 'undefined') return document.getElementById(id);
        return Null;
}
function getStyle(id) {
	return (isNS4 ? getElement(id) : getElement(id).style);
}

Array.prototype.append = function(value) {
    this[this.length] = value;
}

String.prototype.trim = function() {
  return this.replace(/^\s*|\s*$/g, "");
}

function checkEmail(text) {
    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9_\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    return filter.test(text.trim());
}

function checkPhone(text) {
    return text.match(/^[+]?[()/0-9. -]{6,50}$/);
}

function checkZIP(text) {
    return text.match(/^\d{3}\s?\d{2}$/);
}

function checkDate(text) {
    // dd.mm.yyyy OR yyyy-mm-dd
    return text.match(/^\d{1,2}[.]\s*\d{1,2}[.]\s*\d{4}$/) || text.match(/^\d{4}-\d{1,2}-\d{1,2}$/);
}


function _T(text) {
    // messages translation
    if(typeof(translation) == "undefined")
        return text;

    for (i=0; i < translation.length; i++) {
        if (translation[i][0] == text) return translation[i][1];
    }
    return text;
}

function checkInput(name, error_message) {
    return strip($(name).value) == '' ? error_message : ''
}

function checkInputPhone(name, error_message) {
    var phone = strip($(name).value);
    return phone == '' ? '' : (checkPhone(phone) ? '' : error_message);
}

function checkFormat(element_name, check_function) {
    // check input value only if it has any value
    var value = strip($(element_name).value);
    return value.length > 0 ? check_function(value) : true;
}


