$(function(){ $(window).bind('load', function() {
    adjustHeight();
    handleForm();
    $('#submitBtn').click(function(){ return validateForm(); });
    gallery();
}); });

function adjustHeight()
{
    var contentH = $('.adjust #contentBox').height();
    var sideBoxH = $('.adjust #imgBox').height() + $('.adjust #adrBox').height() + 26;
    if(contentH < sideBoxH) {
        $('.adjust #contentBox').height(sideBoxH - 12);
    } else {
        newH = contentH - $('.adjust #imgBox').height() - 26 + 12;
        $('.adjust #adrBox').height(newH);
    }
}

function gallery() {
    $('#gallery li a[rel=lightbox]').lightBox({
        overlayBgColor: '#F17E2D',
        overlayOpacity: 0.6,
        imageLoading: 'http://' + location.hostname + '/addons/lightbox/images/loading.gif',
        imageBtnClose: 'http://' + location.hostname + '/addons/lightbox/images/close.gif',
        imageBtnPrev: 'http://' + location.hostname + '/addons/lightbox/images/prev.png',
        imageBtnNext: 'http://' + location.hostname + '/addons/lightbox/images/next.png',
        imageBlank: 'http://' + location.hostname + '/addons/lightbox/images/blank.gif',
        containerResizeSpeed: 350,
        txtImage: 'Bild',
        txtOf: 'von'
    });
}

function handleForm() {
    disableConf();
    reqFields();
    function reqFields() {
        $('input.req').each(function(){
            $('label[for='+$(this).attr('id')+']').append('*');
        });
    }
    function disableConf() {
        $('input[id^="pwConf"]').attr('disabled',true);
        $('input[id^="pw"]').blur(function(){ if($(this).val()!='') { $(this).addClass('req'); $(this).next().next('input').removeAttr('disabled').addClass('req'); } else { $(this).removeClass('req mark'); $(this).next().next('input').attr('disabled',true).removeClass('req mark'); } });
    }
}

function validateForm() {
    valid = true;
    $('.req').each(function(){ if($(this).val() == ''){ mark($(this), false); valid = false; } else { mark($(this), true); } });
    function mark(obj, pos) { if(pos) { obj.removeClass('mark'); } else { obj.addClass('mark'); } }
    return valid;
}
