// JavaScript Document
function linkCompartilhe(obj){
	var url		= '';
	var loc		=encodeURIComponent(window.location);
	var title	=encodeURIComponent(document.title); 
	var desc 	= '';
	
	if (window.getSelection){
		desc 	= window.getSelection();
	}else if (document.getSelection){
		desc 	= document.getSelection();
	}else if (document.selection){
		desc 	= document.selection.createRange().text;
	} 

	switch(obj.id){
		case "uebal":
			obj.href = 'http://ueba.com.br/NovoLink?url='+ loc +'&origem='+ title +'&origem='+ desc;
			break;
		
		case "digg":
			obj.href = 'http://www.digg.com/submit?phase=2&url='+ loc +'&title='+ title +'&media=';
			break;
		
		case "google":
			obj.href = 'http://www.google.com/bookmarks/mark?op=edit&bkmk='+ loc +'&title='+ title;
			break;
		
		case "technorati":
			obj.href = 'http://www.technorati.com/faves?add='+ loc;
			break;
		
		case "windows":
			obj.href = 'https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url='+ loc +'&title='+ title +'&top=1';
			break;
		
		case "reddit":
			obj.href = 'http://reddit.com/submit?url='+ loc +'&title='+ title;
			break;
		
		case "delicious":
			obj.href = 'http://del.icio.us/post?url='+ loc +'&title='+ title ;
			break;
		
		case "facebook":
			obj.href = 'http://www.facebook.com/share.php?u='+ loc;
			break;
		
		case "yahoo":
			obj.href = 'http://myweb2.search.yahoo.com/myresults/bookmarklet?u='+ loc +'&t='+ title ;
			break;
		
		case "stumbleupon":
			obj.href = 'http://www.stumbleupon.com/submit?url='+ loc +'&title='+ title ;
			break;
	}
}

function mudarACT(act){
	document.getElementById('act').value = act;
}

/*function processBox(box, height, height2, velocidade){
	acao_box = document.getElementById(box).getAttribute('action_box');
	
	if (document.getElementById('indicate').getAttribute('action_box') == "close"){
		closeBox('indicate', height, velocidade);
	}
	if (document.getElementById('comment').getAttribute('action_box') == "close"){
		closeBox('comment', height, velocidade);
	}
	if (document.getElementById('view_comment').getAttribute('action_box') == "close"){
		closeBox('view_comment', height, velocidade);
	}
	
	switch(acao_box){
		case "open":
			openBox(box, height, height2, velocidade);
			break;
			
		case "close":
			closeBox(box, height, velocidade);
			break;
	}

}

function openBox(box, height, height2, velocidade){
	document.getElementById('act').value = box;
	if ( height >= height2){
		height2										= height2+10;
		document.getElementById(box).style.display	= "block";
		document.getElementById(box).style.height	= height2+"px";
		setTimeout("openBox('"+box+"', "+height+", "+height2+")",velocidade);
	}
	
	if (height <= height2){
		document.getElementById(box).setAttribute('action_box', 'close');
	}
}

function closeBox(box, height2, velocidade){
	
	if (height2 > 0){
		height2										= height2-10;
		document.getElementById(box).style.height	= height2+"px";
		setTimeout("closeBox('"+box+"', "+height2+")", velocidade);
	}
	
	if (height2 <= 0){
		document.getElementById(box).style.display	= "none";
		document.getElementById(box).setAttribute('action_box', 'open');
	}
	
}*/

function limita_comentario(cmt) {
	var len 	= cmt.value.length;
	var max_len = 500;
	var cont	= document.getElementById("contador_comentario").innerHTML = max_len;
	
	if (len > max_len) {
		//alert("O limite de caracteres permitidos foi atingido.");
		cmt.value = cmt.value.substr(0,max_len);
		cont = 0;
	} else {
		cont = max_len - len;
	}
	
	document.getElementById("contador_comentario").innerHTML = cont;
	
}

/*function pegarURL(){
	document.getElementById('pag_origem').value = document.location.href;
}*/