$(document).ready(function (){

    $.tools.addTipEffect("slidedown",   
        // opening animation 
        function() {  
            var opacity = this.getConf().opacity; 
            this.getTip().css({width:250, 'font-weight' : 'bold'}).animate({left: '+=5', opacity:opacity}, 300).show(); 
        },  
        // closing animation 
        function() { 
            this.getTip().animate({top: '+=1', opacity:0}, 300, function() {  
                    $(this).hide().animate({top: '+=1'}, 0); 
            }); 
        } 
    );
    
    $(function() {
    	$('#comment').keyup(function() {
    		limitChars('comment', 20, 'charlimitinfo');
    	})
    });

		
    $('.on_off :checkbox').iphoneStyle();
    $('.css_sized_container :checkbox').iphoneStyle({ resizeContainer: false, resizeHandle: false });
    $('.long_tiny :checkbox').iphoneStyle({ checkedLabel: 'Very Long Text', uncheckedLabel: 'Tiny' });
	$('textarea.expanding').autogrow();
});


function limitChars(textid, limit, infodiv)
{
	var text = $('#'+textid).val(); 
	var textlength = text.length;

	if(textlength > limit)
	{
		$('#' + infodiv).html('You cannot write more then '+limit+' characters!');
		$('#'+textid).val(text.substr(0,limit));
		return false;
	}
	else
	{
		$('#' + infodiv).html((limit - textlength) +' characters left.');
		return true;
	}
}
