 var base = document.getElementsByTagName('BASE');
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
$(document).ready(function(){	
	$("input#s").attr('value', 'Buscar'); // adds new class name 
	$("div.twtr-doc").remove();
	//$('div.wp-caption a').removeAttr('href');
	
	
	$("li#DonaFoca").addClass('ativo');
	$("li#DonaFoca").click(function(){
		$("#twitter-donafoca").css('display','block');
		$("#twitter-beachpark").css('display','none');
		$("li#DonaFoca").addClass('ativo');
		$("li#Beach_Park").removeClass('ativo');
	});
	
	$("li#Beach_Park").click(function(){
		$("#twitter-donafoca").css('display','none');
		$("#twitter-beachpark").css('display','block');
		$("li#Beach_Park").addClass('ativo');
		$("li#DonaFoca").removeClass('ativo');
	});
	

	/* Atribui classe para mostrar o dropdown - nível 1*/		
	$("#menu-principal ul li").each(function(){
		if($("ul", this).html() !== null){
			classe = this.className+" dropable";
			this.className=classe;
		}
	});
	$("ul#menu-menu-principal li:last").css('background-image', 'none');

	
	/*Mostra  menu */
	$(".dropable").hover(
		function() { $('div.dropdown', this).show() },
		function() { $('div.dropdown', this).hide() }
	);

	/* Atribui classe para mostrar o dropdown - nível 1*/		
	$("#menu-principal ul li").each(function(){
		if($("ul", this).html() !== null){
			classe = this.className+" dropable";
			this.className=classe;
		}
	});
	
		
	var chamadasBannersHeight = 0;	
	var menuLateralHeight = 0;	
	var contentHeight = 0;
	
	if(document.getElementById("chamadas-banners-sidebar-container")){
		chamadasBannersHeight = document.getElementById("chamadas-banners-sidebar-container").clientHeight + 180;
		
		if(document.getElementById("menu-lateral").clientHeight < document.getElementById("content").clientHeight){
			sidebarHeight = document.getElementById("content").clientHeight + chamadasBannersHeight - 245;
		}else{
			sidebarHeight = document.getElementById("content").clientHeight + chamadasBannersHeight - 130;
		}
		
		$("#sidebar-container").height(sidebarHeight);
	}
	
	
	
	
	var sidebarContentWidth = 0;	
	if(document.getElementById("sidebar-content") != null){
		$("#content").width(340);
	}
	
	/** Glauter - Erro nas página - Script sem comentário. 03 de novembro de 2011
	$("a[rel^='prettyPopin']").prettyPopin({
			modal : false, 
			width : 482, 
			height: 310, 
			opacity: 0.5, 
			animationSpeed: 'medium', 
			followScroll: true, 
			loader_path: '../imagens/prettyPopin/loader.gif', 
			callback: function(){} 
	});
	
	$("#ddd").mask("99");
	$("#telefone").mask("9999-9999");
	$("#cpf").mask("999.999.999-99");
	*/
	
})


function Sharer()
{	
	this.wrapper;
	this.orkutWrapper = "#singleBabyWrapper";
	this.orkutShareUrl = '';
	this.facebookShareUrl = 'http://www.facebook.com/sharer.php?';
	this.twitterShareUrl = 'http://twitter.com/?status='
	
	this.orkutShare = function(_title, _subtitle, _url, wrapper)
	{
	    var params = {};
	    params[google.orkut.share.Field.TITLE] = _title;
	    params[google.orkut.share.Field.DESTINATION_URL] = _url;
	    imgs = [];
	    
	    $( wrapper +' div span').each(function() {
	        imgs.push($(this).text().split("name=")[1]);

	    });
	    
	    
	    params[google.orkut.share.Field.CONTENT] = _subtitle;
	    params[google.orkut.share.Field.THUMBNAIL] = imgs;
	    var connection = new google.orkut.share.Connection(params);
	    connection.send('orkut.com', {}); 
	}
	
	/**
	 * Abre uma nova janela para compartilhar o conteúdo no twitter
	 */

	
	
	this.init = function(wrapper)
	{
		this.wrapper = wrapper;
		var _this = this;
		console.log('wrapper is ' + _this.wrapper);
		$(_this.wrapper + ' a').click(function(e){
	
			e.preventDefault();
			
			
			var myData = $(this).attr('rel').split(":::");
			
			console.log(myData);
			
			switch(myData[0])
			{
				case 'orkut':
					
					_this.orkutShare(myData[1], myData[2], myData[3], _this.orkutWrapper);
					console.log('Orkut');
				break;
				
				case 'facebook':
					console.log('abrindo '+ _this.facebookShareUrl+myData[1]);
					window.open(_this.facebookShareUrl+myData[1]);
				break;
				
				case 'twitter' : 
					console.log('abrindo '+ _this.twitterShareUrl+myData[1]);
					window.open(_this.twitterShareUrl + myData[1]);
			}			
		})
	}
}

