function jamp() {

    var self = this;

    this.settings = {
        ajaxPath: 'ajax/',
        errorColor: '#019FFA',
        successColor: '#006633',
        defaultColor: '#ffffff',
        searchText: '',
        success: function() {
            
        }
    };

    this.isValidEmail = function(field) {
        var str = $(field).val();
        var filter = /^.+@.+\..{2,3}$/;

        if(filter.test(str)) {
            return true;
        } else {
            return false;
        }
    };

    this.flur = function(j,text) {
        if($(j).length>0) {
            this.searchText = text;

            $(j).val(text);

            $(j).focus(function() {
                if($(j).val()==text) {
                    $(j).val('');
                }
            });

            $(j).blur(function() {
                if($(j).val()=='') {
                    $(j).val(text);
                }
            });
        }
    };

    this.search = function(j,jInput) {
        if($(j).length>0) {
            $(j+' input').each(function() {
                if($(this).attr('type')=='button') {
                    $(this).click(function() {
                        if($(jInput).val()!='' && $(jInput).val()!=self.searchText) {
                            $(j).submit();
                        }
                    });
                }
            });
        }
    };

    /*
     *  Formartiert einen Preis, in dem . durch , ersetzt wird.
     *  Ebenso wird der Preis anhand von precision aufgerundet.
     *  Ist precision nicht angegeben, wird er automatisch auf 2 gesetzt.
     */
    this.formatPrice = function(wert,precision) {
        var x,x1,x2;

        if(precision==undefined) {
            precision = 2;
        }

        wert = (wert.toFixed) ? wert.toFixed(precision) : Math.floor(wert)+"."+(100+Math.round((wert-Math.floor(wert))*100)+"").substr(1,2);

        nStr = wert;

        nStr += '';
        x = nStr.split('.');
        x1 = x[0];
        x2 = x.length >= 1 ? ',' + x[1] : '';

        var rgx = /(\d+)(\d{3})/;
        while (rgx.test(x1)) {
            x1 = x1.replace(rgx, '$1' + '.' + '$2');
        }

        return x1 + x2;

    };

    /* returns actual page size as an array [width|height] */
    this.getPageSize = function() {
        var xScroll, yScroll;
        if (window.innerHeight && window.scrollMaxY) {
            xScroll = window.innerWidth + window.scrollMaxX;
            yScroll = window.innerHeight + window.scrollMaxY;
        } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
            xScroll = document.body.scrollWidth;
            yScroll = document.body.scrollHeight;
        } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
            xScroll = document.body.offsetWidth;
            yScroll = document.body.offsetHeight;
        }
        var windowWidth, windowHeight;
        if (self.innerHeight) {	// all except Explorer
            if(document.documentElement.clientWidth){
                windowWidth = document.documentElement.clientWidth;
            } else {
                windowWidth = self.innerWidth;
            }
            windowHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
            windowWidth = document.documentElement.clientWidth;
            windowHeight = document.documentElement.clientHeight;
        } else if (document.body) { // other Explorers
            windowWidth = document.body.clientWidth;
            windowHeight = document.body.clientHeight;
        }
        // for small pages with total height less then height of the viewport
        if(yScroll < windowHeight){
            pageHeight = windowHeight;
        } else {
            pageHeight = yScroll;
        }
        // for small pages with total width less then width of the viewport
        if(xScroll < windowWidth){
            pageWidth = xScroll;
        } else {
            pageWidth = windowWidth;
        }
        arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
        return arrayPageSize;
    };
}

var jamp = new jamp();

