/**
 * @author dshaikh
 */

$(document).ready(function(){

$('img').each(function(){
			var ancho = $(this).width();
			if(ancho>330)
				$(this).width(330);
		});   
	$('a img').each(function(){
			var ancho = $(this).width();
			if(ancho>330)
				$(this).width(330);
		});
/*          $('div#profile_comments.section tr td a img').each(function(){
			var ancho = $(this).width();
			if(ancho>330)
				$(this).width(330);
		});   
         $('div#profile_comments.section tr td img').each(function(){
			var ancho = $(this).width();
			if(ancho>330)
				$(this).width(330);
		}); 

*/


$('div#profile_comments.section tr th a').each(function(){
			var str = $(this).text();
			var i=0;
				var cont=0;
				var mod = str;
				var len = str.length;
				var fin = str.indexOf(' ');
				mod = str.slice(i,fin);
				while((mod!=null)&&(fin!=0)){
					
					if(mod.length>12){
						var prim = mod.slice(0,12);
						var secun = mod.slice(7,mod.length);
						var fins = prim+"\n"+secun;
						mod.replace(aux,fins);
						$(this).text(prim+"\n"+secun);
					}
					cont+= fin
					aux = str.slice(cont,len);
					i = fin;
					fin = aux.indexOf(' ');
					fin++;
					mod = aux.slice(cont,fin);
				}//puede que se trate de una unica palabra
				if(aux.length>15){
			        	var prim = aux.slice(0,7);
						var secun = aux.slice(7,15);
						var fins = prim+"\n"+secun;
						$(this).text(prim+"\n"+secun);
						
						}
						
		}); 
		$('div#profile_comments.section tr td a').each(function(){
			var url = $(this).text();
			var l = url.length;
			if(url.length>40){
			    if(url.indexOf(' ')==-1)
			    var prim = url.slice(0,22);
				var secun = url.slice(22,l);
				$(this).text(prim+"\n"+secun);
				
			}
			
		});

 

/*$('div#profile_comments.section tr td').each(function(i){
			final = "";
			var texto = $(this).text();
			long = texto.length;
			aux2= texto;		
			var cont = 0;
			
			while (aux2.length != 0) {
				n = aux2.indexOf(" ");	
				
				if ((n > 40)||((n==-1)&&(aux2.length>40))) {
					if(n!=-1)					
					aux = aux2.slice(0,n);
					else aux=aux2;
				
					i = 0;
					while (aux != "") {
						aux = aux2.slice(i * 40, (i + 1) * 40);
						final = final + "\n" + aux;
						i++;
					}
				final = final + "\n";
				aux2 = aux;
				}
				else if(n==0){
					final += aux2.slice(0, 40)+" ";
					aux2 = aux2.slice(41, long);
				}
				else {
					final += aux2.slice(0, n)+" ";
					aux2 = aux2.slice(n+1, long);
					
				}
			}
				
			$(this).text(final);
				
			
		});*/

      
    });