    triggerArray = [], rollovers = [] ;
    defaultArray = [];

    defaultArray[ '#req_vorname' ]      = defaultArray[ '#liefervorname' ]      = defaultArray[ '#req_werber_vorname' ]         = defaultArray[ '#req_geworbener_vorname' ]         = defaultArray[ '#vorname_verloren' ]   = 'Vorname*';
    defaultArray[ '#txt_vorname' ]      = 'Vorname';
    defaultArray[ '#req_nachname' ]     = defaultArray[ '#liefernachname' ]     = defaultArray[ '#req_txt_nachname' ]       = defaultArray[ '#req_werber_nachname' ]       = defaultArray[ '#req_geworbener_nachname' ]       = defaultArray[ '#nachname_verloren' ]     = 'Nachname*';
    defaultArray[ '#firma' ]            = defaultArray[ '#lieferfirma' ]        = defaultArray[ '#txt_unternehmen' ]        = 'Firma';
    defaultArray[ '#req_strasse' ]      = defaultArray[ '#lieferstrasse' ]      = 'Straße, Nr.*';
    defaultArray[ '#txt_strasse' ]      = 'Straße, Nr.';
    defaultArray[ '#req_plz' ]          = defaultArray[ '#lieferplz' ]          = 'PLZ*';
    defaultArray[ '#txt_plz' ]          =  'PLZ';
    defaultArray[ '#req_ort' ]          = defaultArray[ '#lieferort' ]          = 'Ort*';
    defaultArray[ '#txt_ort' ]          = 'Ort';
    defaultArray[ '#geburtsdatum' ]     = 'Geburtsdatum (TT.MM.JJJJ)';
    defaultArray[ '#req_email' ]        = defaultArray[ '#req_txt_email' ]        = defaultArray[ '#req_werber_email' ]        = defaultArray[ '#req_geworbener_email' ]        = defaultArray[ '#email_verloren' ]   = 'E-Mail*';
    defaultArray[ '#telefon' ]          = 'Telefon';
    defaultArray[ '#req_txt_telefon' ]  = 'Telefon*';
    defaultArray[ '#fax' ]              = defaultArray[ '#txt_telefax' ]              = 'Telefax';
    defaultArray[ '#mobil' ]            = defaultArray[ '#txt_mobil' ]           = 'Mobil';
    defaultArray[ '#anderes_land_in' ]  = defaultArray[ '#anderes_lieferland' ]  = 'anderes Land';
    defaultArray[ '#Benutzername2' ]    = defaultArray[ '#ben' ]                 = 'Benutzername*';
    defaultArray[ '#aktionscode' ]      = 'Rabattcode';
    defaultArray[ '#txt_position' ]     = 'Position';
    defaultArray[ '#req_txt_dein_name' ]    = 'Dein Name*';
    defaultArray[ '#req_txt_name_empfaenger' ] = 'Name Empfänger*';
    defaultArray[ '#req_txt_email_empfaenger' ] = 'E-Mail empfänger*';
    defaultArray[ '#number' ]           = 'Nummer'; 
    defaultArray[ '#anforderung_email' ]= 'Ihre E-Mail Adresse*';
    defaultArray[ '#versandarten' ]= 'Land*';

$( document ).ready ( function () {
    initTriggers () ;
    if ( $( 'div.toStrech').is( '*' ) ) resizeTeaser();
    readyRollovers () ;
        
    if ( $( '.weezzleskast_hg_content' ).is( '*' ) ) {

        getWeezzleskastTitle ();
    }
    $( "#form_adresse, #weezzle_vorteile_formular, .seitenpicker, #wrong_ben, #shopcontent, #lieferanschrift, .kontakt_in, #suche_container2, #freunde_werben_formular, #kontakt_formulaire, #weiterempfehlen_formulaire, #restore_form, #kontakt_kundenkontodata" ).each ( function () {
        $ ( this ).jNice () ;
    } ) ;



    if ( $( "#req_anrede" ).is('*') ) $( "#req_anrede" ).val( $( "#req_anrede" ).val() != '' ? $( "#req_anrede" ).val() : 'Anrede*' ).focus( function () { this.value = this.value == 'Anrede*' ? '' : this.value } ).blur ( function () { this.value = this.value == '' ? 'Anrede*' : this.value } )  ;

    if ( $( "#passwort2" ).is('*') ) $( "#passwort2" ).val( '' ).focus( function () { if ( this.value == '' ) $( "#passwort2_cont" ).html('&nbsp;') } ).blur ( function () { if ( this.value == '' ) $( "#passwort2_cont" ).html( 'Passwort*' ) } )  ;
    if ( $( "#passwort_wdh" ).is('*') ) $( "#passwort_wdh" ).val( '' ).focus( function () { if ( this.value == '' ) $( "#passwort_wdh_cont" ).html('&nbsp;') } ).blur ( function () { if ( this.value == '' ) $( "#passwort_wdh_cont" ).html( 'Passwort wiederholen*' ) } )  ;

    if ( $( "#pass" ).is('*') ) $( "#pass" ).val( '' ).focus( function () { if ( this.value == '' ) $( "#pass_container" ).html('&nbsp;') } ).blur ( function () { if ( this.value == '' ) $( "#pass_container" ).html( 'Passwort*' ) } )  ;

    if ( $( "#livesearch" ).is('*') )  {
        $( "#livesearch" ).val( $( "#livesearch" ).val() != '' ? $( "#livesearch" ).val() : 'Suchbegriff' ).keypress( function () {liveSearchStart();
     } ).focus( function () { this.value = this.value == 'Suchbegriff' ? '' : this.value;var xx =  window.location.search.match( 'suche.php' );/*if ( !xx || xx.length <= 0 ) window.location.href="./content.php?seite=seiten/suche.php&navigation=navigation_korb.php";*/ } ).blur ( function () { this.value = this.value == '' ? 'Suchbegriff' : this.value; setTimeout('closeResults()',1000); } )  ;
    }
    for ( var i in defaultArray ) {
        initFields( i );
    }
    initRequiredFields () ;
} ) ;


/**
 * evaluate all trigger functions
 *
 * @return void
 */
function initTriggers () {
    for ( var i = 0 ; i < triggerArray.length ; i++ ) {
        eval ( triggerArray [ i ] ) ;
    }
}

/**
 * @return void
 */
function initRequiredFields () {
   $( "input, select, textarea" ).each ( function () {
        if ( this.name.match( 'req_' ) ) {
            updateFieldStatus ( this ) ;
            this.onchange = function () {
                updateFieldStatus ( this ) ;
            }
        }
    } ) ;
    $( "#form_adresse, #weezzle_vorteile_formular, .seitenpicker, #wrong_ben, #shopcontent, #lieferanschrift, .kontakt_in, #suche_container2, #freunde_werben_formular, #kontakt_formulaire" ).each ( function () {
       
        $( '.jNiceInputWrapper' ).find( 'input' ).each ( function () {
            if ( this.name.match( 'req_' ) ) {
                updateFieldStatus ( this ) ;
                this.onchange = function () {
                    updateFieldStatus ( this ) ;
                }
            }
        } ) ;

    } ) ;    
} ;

/**
 * @param  object   pField
 * @return void
 */
function updateFieldStatus ( pField ) {
    /*if ( pField.value.length == 0 || pField.value == '{txt_ausfuellen}' ) {*/
        $("label[@for=" + pField.name + "]").addClass('required') ;
        $(pField).addClass('required'); 
    /*} else {
        $("label[@for=" + pField.name + "]").removeClass('required') ;
        $(pField).removeClass('required');
    }*/
} ;

/**
 * set IDs for LI Elements and highlight the right elements
 *
 * @param  array    elements
 * @return void
 */
initRollovers = function ( elements ) {
    debugalert ( 'initRollovers: ' + elements ) ;

    $( ".navigation" ).find( "> li" ).each( function () {
        if ( this.id == '' ) {
            this.id = $( this ).find( '> a' ).text().toLowerCase() ;
        }

        debugalert ( 'ID zugewiesen:' + this.id ) ;
    } ) ;

    for ( var i = 0 ; i < elements.length ; i++ ) {
        if ( elements[ i ] != '' ){
            element = $( "#" + elements[ i ].toLowerCase() ) ;

            $( element ).addClass( 'active' ).find( "> a" ).addClass( 'active' ).find( "> img" ).addClass( 'active' ).end().parents( 'li' ).each( function () {
                $( this ).addClass( 'open' ).find("> a").addClass( 'open' ) ;
            } ) ;
        }
    }
}

/**
 * prepare images for rollover function and preload them
 * also removes flickering effect for background-images in Internet Explorer
 *
 * @return void
 */
readyRollovers = function () {
    imagesExp= /((\.jpg)|(\.png)|(\.gif))/ ;

    if ( jQuery.browser.ie == true ) {
        try {
            document.execCommand ( 'BackgroundImageCache' , false , true ) ;
        } catch ( e ) {

        }
    }

    $( "img.active" ).each( function () {
         this.src = this.src.replace ( imagesExp , '_f2$1' ) ;
    } ) ;

    $( "img.rollover:not(.active)" ).each( function () {
        $.preloadImages ( this.src.replace ( imagesExp , '_f2$1' ) ) ;
    } ).hover (
        function () { this.src = this.src.replace ( imagesExp , '_f2$1' ) ; } ,
        function () { this.src = this.src.replace ( /_f2/ , '' ) ; }
    ) ;
}

/**
 * remove the classes "open" and "active" from all elements
 *
 * @return void
 */
resetRollovers = function () {
    $ ( '.active' ).each ( function () { $( this ).removeClass( 'active' ) } ) ;
    $ ( '.open' ).each ( function () { $( this ).removeClass( 'open' ) } ) ;
};

/**
 * function to preload images
 *
 * @return void
 */
jQuery.preloadImages = function () {
	for ( var i = 0 ; i < arguments.length ; i++ ) {
		jQuery ( "<img>" ).attr ( "src" , arguments[ i ] ) ;
	}
}

/**
 * collect all function
 *
 * @param   string  objects
 * @return  void
 */
collectTriggers = function ( objects ) {
    triggerArray.push ( objects ) ;
}

/**
 * display custom error messages in the firebug extension (http://www.getfirebug.com)
 *
 * @param   string  outputtext
 * @return  void
 */
function debugalert(outputtext){
    try {
        if ( window.console ) {
            window.console.log ( outputtext ) ;
        } else {
             throw ( false ) ;
        }
    } catch ( e ) {

    }
}
/*
function resizeTeaser () {
    var heighest = 0;

    $( '#inhalt' ).find( 'div.toStrech' ).each ( function () {
        if ( this.offsetHeight > heighest) {
            heighest = this.offsetHeight;
        }
    } ) ;
    $( '#inhalt' ).find( 'div.toStrech' ).each ( function () {
        if ( this.offsetHeight == heighest) {
            // NOTHING TO DO
        } else {
            $( this ).find( 'div > div > .strech' ).css( 'height', (heighest -  this.offsetHeight) + 'px' );
        }
    } );

    $( '#inhalt' ).find( 'div.toStrech' ).each ( function () {
        if ( this.offsetHeight == heighest) {
            // NOTHING TO DO
        } else {
            $( this ).find( 'div > form > .strech' ).css( 'height', (heighest -  this.offsetHeight) + 'px' );
        }
    } ); 
    var county = 0;
    var classx = 'paddingRight10';
    $( '#inhalt' ).find( 'div.classToFind' ).each ( function () {
        classx = ( ( county%2 == 0 ) ) ? 'paddingRight10 clearleft' : 'noMargin';
        app = ( ( county%2 == 0 ) ) ? '<br clear="left" />' : '';
        county++;
        $( this ).addClass( classx );
        
    } ); 
}

*/
function resizeTeaser () {
    // produkte uebersicht
//     var heighest = 0;
//     var counttmp = 0;
//     var neuheitenCount = 0;
//     var cur;
//     if ( $( '#neuheitenKontainer' ).is ( '*' ) ) {
//         $( '#inhalt' ).find( 'div.toStrechNeuheiten' ).each ( function () {
//             if ( neuheitenCount % 2 == 0 ) {
//                 heighest = this.offsetHeight;
//                 cur = this;
//             } else {
//                 //alert( 'offsetHeight: ' + this.offsetHeight + ' heighest: ' + heighest );
//                 if ( this.offsetHeight == heighest ) { 
//     
//                 } else if ( this.offsetHeight > heighest ) {
//                     if ( $(cur).find( 'div > div > .strechNeuheiten' ).is('*') ) {
//                         $(cur).find( 'div > div > .strechNeuheiten' ).css( 'height', (this.offsetHeight + 20 - heighest) + 'px' );
//                         if ($( this ).find( 'div > div > .strechNeuheiten' ).is('*')) { $( this ).find( 'div > div > .strechNeuheiten' ).css( 'height', '20px' );}
//                     }
//                     if ( $(cur).find( 'div > form > .strechNeuheiten' ).is('*') ) {
//                         $(cur).find( 'div > form > .strechNeuheiten' ).css( 'height', (this.offsetHeight + 20 - heighest) + 'px' );
//                                                 if ($( this ).find( 'div > form > .strechNeuheiten' ).is('*')) { $( this ).find( 'div > div > .strechNeuheiten' ).css( 'height', '20px' );}
//                     }
//                 } else {
//                     // nothing to do
//                     if ($( this ).find( 'div > div > .strechNeuheiten' ).is('*')) { 
//                         $( this ).find( 'div > div > .strechNeuheiten' ).css( 'height', (heighest + 20 - this.offsetHeight) + 'px' );
//                         if ( $(cur).find( 'div > div > .strechNeuheiten' ).is('*') ) {
//                             $(cur).find( 'div > div > .strechNeuheiten' ).css( 'height', '20px' );
//                         }
//                     }
//                     if ($( this ).find( 'div > form > .strechNeuheiten' ).is('*')){ 
//                         $( this ).find( 'div > form > .strechNeuheiten' ).css( 'height', (heighest + 20 - this.offsetHeight) + 'px' );
//                         if ( $(cur).find( 'div > form > .strechNeuheiten' ).is('*') ) {
//                             $(cur).find( 'div > form > .strechNeuheiten' ).css( 'height', '20px' );
//                         }
//                     }
//                 }
//             }
//             neuheitenCount++;
//         } );
//     }
//     $( '#inhalt' ).find( 'div.toStrech' ).each ( function () {
//         if ( counttmp % 2 == 0 ) {
//             heighest = this.offsetHeight;
//             cur = this;
//         } else {
//             //alert( 'offsetHeight: ' + this.offsetHeight + ' heighest: ' + heighest );
//             if ( this.offsetHeight == heighest ) { 
// 
//             } else if ( this.offsetHeight > heighest ) {
//                 if ( $(cur).find( 'div > div > .strech' ).is('*') ) {
//                     $(cur).find( 'div > div > .strech' ).css( 'height', (this.offsetHeight + 20 - heighest) + 'px' );
//                     if ($( this ).find( 'div > div > .strech' ).is('*')) { $( this ).find( 'div > div > .strech' ).css( 'height', '20px' );}
//                 }
//                 if ( $(cur).find( 'div > form > .strech' ).is('*') ) {
//                     $(cur).find( 'div > form > .strech' ).css( 'height', (this.offsetHeight + 20 - heighest) + 'px' );
//                     if ($( this ).find( 'div > form > .strech' ).is('*')){ $( this ).find( 'div > form > .strech' ).css( 'height', '20px' );}
//                 }
//             } else {
//                 // nothing to do
//                 if ($( this ).find( 'div > div > .strech' ).is('*')) { 
//                     $( this ).find( 'div > div > .strech' ).css( 'height', (heighest + 20 - this.offsetHeight) + 'px' );
//                     if ( $(cur).find( 'div > div > .strech' ).is('*') ) {
//                         $(cur).find( 'div > div > .strech' ).css( 'height', '20px' );
//                     }
//                 }
//                 if ($( this ).find( 'div > form > .strech' ).is('*')){ 
//                     $( this ).find( 'div > form > .strech' ).css( 'height', (heighest + 20 - this.offsetHeight) + 'px' );
//                     if ( $(cur).find( 'div > form > .strech' ).is('*') ) {
//                         $(cur).find( 'div > form > .strech' ).css( 'height', '20px' );
//                     }
//                 }
//             }
//         }
//         counttmp++;
//     } ) ;
// 
//     // spielwaren
//     var county = 0;
//     var classx = 'paddingRight10';
//     $( '#inhalt' ).find( 'div.classToFind' ).each ( function () {
//         classx = ( ( county%2 == 0 ) ) ? 'paddingRight10 clearleft' : 'noMargin';
//         app = ( ( county%2 == 0 ) ) ? '<br clear="left" />' : '';
//         county++;
//         $( this ).addClass( classx );
//     } ); 
}

var categoriesShowed = false;

function showHideAllCategories () {
    if ( categoriesShowed == false ) {
         $( '.toShow > li, .toShow > li > ul' ).css( 'display', 'block' );
         $( '.toShow > li, .toShow > li > ul' ).css( 'visibility', 'visible' );
         //$( '.toShow > li > ul' ).css( 'display', 'block' );
         //$( '.toShow > li > ul' ).css( 'visibility', 'visible' );
         categoriesShowed = true;
    } else {
         $( '.toShow > li' ).css( 'display', 'none' );
         $( '.toShow > li' ).css( 'visibility', 'hidden' );
         /*$( '.toShow > li > ul' ).css( 'display', 'none' );
         $( '.toShow > li > ul' ).css( 'visibility', 'hidden' );*/
         $ ( '.active' ).each ( function () { 
            $( this ).css( 'display', 'block' ); 
            //$( this ).css( 'border', '1px solid #000' ); 
            $( this ).css( 'visibility', 'visible' );

            /*$( this ).find( '.toShow < li.active < ul ' ).css( 'display', 'block' ); 
            $( this ).find( '.toShowl < li.active < ul ' ).css( 'border', '1px solid #f00' ); 
            $( this ).find( '.toShowl < li.active < ul' ).css( 'visibility', 'visible' );*/
         } ) ;
         categoriesShowed = false;
    }
}
function resizeIframe() {
var heighest = 0;
$(window).css('height', 1500+'px');

var iframe = document.getElementById("TB_iframeContent");
var Window = iframe.window?iframe.window:iframe.contentWindow;
var Document=Window.document;


$( '#body_c' ).css('height', (Document.body.offsetHeight+200)+'px');
iframe.style.height=(Document.body.offsetHeight+20)+"px";

iframe.style.width=(Document.body.offsetWidth+0)+"px";
$('#TB_window').css({display:"block", overflow:"visible", height:(Document.body.offsetHeight+20)+'px'});
$ ( 'body' ).each ( function () { 
    $( this ).css( 'visibility', 'visible' );
    $( this ).css( 'height', (Document.body.offsetHeight+200)+'px');
});

/*$( '#TB_overlay' ).css('display', 'block');
$( '#TB_overlay' ).css('height', (Document.body.offsetHeight+200)+'px');
*/
  //$('#TB_iframeContent').css({display:"block", overflow:"visible", height:1010+'px'});
	//$('html').css({display:"block", overflow:"visible", (Document.body.offsetHeight+20)+'px'});
}

function showEinkaufskorb() {
    $(".einkaufskorb").buildContainers();
    $(".einkaufskorb").css('display', 'block');
}

function getWeezzleskastTitle () {
    var countTitle = 0;

    $( '#inhalt > .weezzleskast_hg_content > div > div, #inhalt > .weezzleskast_hg_content > div' ).find ( 'h2' ).each( function () {
        if ( countTitle == 0 ) {
            var h1Title = $( this ).html( );
             $( '#inhalt' ).each( function () {
                $( this ).prepend( '<h2>' + h1Title + '</h2>' );
            }) ;
            $( this ).remove( );
        }
        countTitle++;
    }) 
}

function initFields ( i ) {
    if ( $( i ).is('*') ) $( i ).val( $( i ).val() != '' ? $( i ).val() : defaultArray[ i ] ).focus( function () { this.value = this.value == defaultArray[ i ] ? '' : this.value } ).blur ( function () { this.value = this.value == '' ? defaultArray[ i ] : this.value } )  ;
}

function checkMe( ) {
    for ( var i in defaultArray ){
        if ( $( i ).is('*') && ( $( i ).val() == defaultArray[i] ) ) {
            $( i ).val( '' );
        }
    }
}

function FormateVersandTabelle ( selector ) {
    var count = 1;
    $( 'table' + selector + ' > tbody > tr' ).each( function () {
        $( this ).addClass ( ( count %2 == 0 ) ? 'versandStyle1' : 'versandStyle2' );
        count++;
    } );
    $( 'table' + selector + ' > tbody > tr:first' ).removeClass();
}
// Funktion zum Öffnen eines Popupfensters
var msgWindow;
function openWindow(newWindowURL, w, h,scroll,id) {
    if (scroll=='') scroll=0;
    var width=w, height=h;
    var left = (screen.width/2) - width/2;
    var top = (screen.height/2) - height/2;
    var styleStr = 'toolbar=no,location=no,directories=no,status=1,menubar=no,scrollbars='+scroll+',resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
    if (msgWindow != undefined ) msgWindow.close();
    msgWindow = window.open(newWindowURL,id,styleStr);
    msgWindow.focus();
}