function jamp() {

    var self = this;

    this.settings = {
        ajaxPath: 'ajax/',
        errorColor: '#DB6400',
        successColor: '#006633',
        defaultColor: '#191919',
        success: function() {

        }
    };
    
    this.switchLanguage = function() {
        var id = '.sprache-waehlen';

        if($(id).css('display')=='none') {
            $(id).slideDown('fast');
        } else {
            $(id).slideUp('fast');
        }
    };

    this.country = function(val) {
        
        if(val!='') {
			
            if(val.indexOf('http')>-1) {
                var win = window.open(val,'','');

            } else {
				
                jQuery.ajax({
                    url: self.settings.ajaxPath+'country.php',
                    data: 'id='+val,
                    type: 'post',
                    success: function(html) {
                        if(html!='') {
                            jQuery('.wistra-country').remove();
                            jQuery('.content-left').append(html);
                            jQuery('.wistra-country').slideDown('fast');
                        }
                    }
                });
            }
        }
    };

    this.close = function() {
        jQuery('.wistra-country').slideUp('fast').remove();
		if(jQuery('form[name=wistra-country]')) jQuery('form[name=wistra-country] select[name=country] option:first').attr('selected','selected');
    };

    this.suche = function(value) {
        if(jQuery.trim(value)!='' && value!='Website durchsuchen...') {
            window.location.href='suche.php?suchbegriff='+value;
        }
    };

    this.isValidEmail = function(field) {
        var str = $(field).val();
        var filter = /^.+@.+\..{2,3}$/;

        if(filter.test(str)) {
            return true;
        } else {
            return false;
        }
    };

    this.loginfield = function(obj, std_txt, type){
        obj.onfocus = function(){
            if(obj.value==std_txt) obj.value = "";
        }
        obj.onblur = function(){
            if(obj.value == "") obj.value = std_txt;
        }
    };

    this.toggleSlide = function( self, idElement ) {
        if( $( self ).css('display')=='none' ){
            $( self ).stop(true, true).slideDown('fast');
        } else {
            $( self).stop(true, true).slideUp('fast');
        }

        if( $( idElement ).css('display')=='none' ){
            $( idElement ).stop(true, true).slideDown('fast');
        } else {
            $( idElement ).stop(true, true).slideUp('fast');
        }
    };

    /*
     *  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();

