jQuery.noConflict();

jQuery(document).ready(function(){



    // clear label bei kommentarformular und gaestebuch
    jQuery('form#commentform input:text,form#commentform textarea').attr('value', '');
    if (jQuery('form#commentform input:text,form#commentform textarea').attr('value') !== '') {
        jQuery(this).next('label').hide();
    }
    
    jQuery('form#commentform input:text,form#commentform textarea').focus(function(){
        jQuery(this).next('label').fadeOut('fast');
        jQuery('form#commentform input:text,form#commentform textarea').blur(function(){
            if (jQuery(this).attr('value') === '') {
                jQuery(this).next('label').fadeIn('fast');
            }
        });
    });
    
    
    
    // clear label bei kontakt
    jQuery('form.wpcf7-form input:text,form.wpcf7-form textarea').attr('value', '');
    if (jQuery('form.wpcf7-form input:text,form.wpcf7-form textarea').attr('value') !== '') {
        jQuery(this).closest('label').hide();
    }
    
    jQuery('form.wpcf7-form input:text,form.wpcf7-form textarea').focus(function(){
        jQuery(this).parent().prev('label').fadeOut('fast');
        jQuery('form.wpcf7-form input:text,form.wpcf7-form textarea').blur(function(){
            if (jQuery(this).attr('value') === '') {
                jQuery(this).parent().prev('label').fadeIn('fast');
            }
        });
    });
    
    
    // schwarzes brett funktionen
    // var olheight = jQuery('#page ol#userPosts').css('height');
  	jQuery('#page ol#userPosts').css({
        'height': '208px'
    });
   
    jQuery('#page a#showAll').click(function(){
        var className = jQuery('#page ol#userPosts').attr('class');
        var liHeight = '210';
        var anzahl1 = jQuery('ol#userPosts').children().size();
		var anzahl = Math.round(anzahl1 / 2);

        if (className !== 'clearfix offen') {
            jQuery('#page ol#userPosts').animate({
            	'height':liHeight * anzahl + 'px'
            }).addClass('offen');
        }
        else {
            jQuery('#page ol#userPosts').animate({
                'height': '208px'
            }).removeClass('offen');
        }
    });
    
        jQuery("#page #userPosts li").draggable({
        stack: {
            group: 'li',
            min: 1
        },
        containment: '#userPosts',
        scroll: false
    });
    
    
    function limitChars(textid, limit, infodiv){
        var text = jQuery('#' + textid).val();
        var textlength = text.length;
        if (textlength > limit) {
            jQuery('#' + infodiv).html('Du darfst max. ' + limit + ' Zeichen schreiben...');
            jQuery('#' + textid).val(text.substr(0, limit));
            return false;
        }
        else {
            jQuery('#' + infodiv).html('Du hast noch  ' + (limit - textlength) + ' Zeichen &uuml;brig!');
            return true;
        }
    }
    
    jQuery('#page textarea#comment').keypress(function(){
        limitChars('comment', 170, 'zeichen');
        
    });
    jQuery('body').prepend('<div id="kinoDark"></div>');
    jQuery('li#kino').hover(function(){
    	jQuery('#kinoInfo,#kinoDark').fadeIn();
    	
    },function(){
    	jQuery('#kinoInfo,#kinoDark').fadeOut();
    });
    

    Cufon.replace('div#content h2,div#content h3,#kinoCount', {
        textShadow: '#111 2px 2px'
    });
});


// eigentlich nur ie hack
jQuery("input#submit,input#send").attr('value', '');



