$(function(){
    $('.print_link').click(function(e){
        e.preventDefault();
        var page_width = $(document).width();
        var page_height = $(document).width();
        var pop_width = 800;
        var left = pop_width;
        if(page_width > pop_width){
            left = (page_width - pop_width)/2;
        }
        var top = 20;       
        window.open(this.href,'print_window','scrollbars=1,toolbar=0,location=0,width='+pop_width+',top='+top+',left='+left);
        return false;
    });

    $(".sortable").tablesorter();
    
    
    var testimony_input = $('div.form_field textarea[name="Testimony"]');
    
    if(testimony_input.length > 0){ 
		var rem_span = $('div.form_field .rem_Testimony');
		var rem_span_c = rem_span.css('color');
		
		function check_testimony_length(len){
			if(len > 1500){
				testimony_input.val(testimony_input.val().substr(0, 1500));
				rem_span.css('color', 'red');
			}else{
				rem_span.css('color', rem_span_c);
			}
		}

		testimony_input.keydown(function(){
			check_testimony_length($(this).val().length)
		});
	}
    

});

function log(mssg){
	if(typeof console == 'undefined'){
		return false;
	}else{
		console.log(mssg);
	}
}

