$(function(){	  	  	
	goSite();
	$('ul.lista-de-fotos').jcarousel();
	navegador=navigator.appVersion;
	if(navegador.match(/MSIE/g)){
		toggleMenu();
		ultimas();
	}
	redesSociais(document.URL);
})


function redesSociais(url){

	$("div.vcard div.social ul#redes-sociais li a.twitter").click(function(){
			window.open("https://twitter.com/intent/tweet?url="+url);
	});
	$("div.vcard div.social ul#redes-sociais li a.facebook").click(function(){
			window.open("http://www.facebook.com/sharer.php?u="+url);			
	});
	$("div.vcard div.social ul#redes-sociais li a.linkedin").click(function(){
			window.open("http://www.linkedin.com/shareArticle?url="+url);
	});
	$("div.vcard div.social ul#redes-sociais li a.identica").click(function(){
			window.open("http://identi.ca/index.php?action=newnotice&status_textarea="+url);
	});
	$("div.vcard div.social ul#redes-sociais li a.orkut").hide();

}

function goSite(){
	$("select#lojas").change(function(){
		$("select#lojas option:selected").each(function(){
			window.open($(this).val());
		})
	})
}

var ctr=0;
function abrePopUp(url){
	var winName = "win_"+(ctr++);
	windowWidth=760;
	windowHeight=500;
	myleft=(screen.width)?(screen.width-windowWidth)/2:100;
	mytop=(screen.height)?(screen.height-windowHeight)/2:100;
	properties = "width="+windowWidth+",height="+windowHeight+",STATUS=NO, TOOLBAR=NO, LOCATION=NO, DIRECTORIES=NO, RESISABLE=NO, SCROLLBARS=YES, top="+mytop+",left="+myleft;
	
	winpops=window.open(url,winName,properties);
}  

function toggleMenu(){
	itemMenu="div#menu ul#menu-principal li.menu-principal";
	subMenu="div#menu ul#menu-principal li.menu-principal ul";
	itemMenuDropdown="div#menu ul#menu-principal li.menu-principal.dropdown";
	itemSubmenu="div#menu ul#menu-principal li.menu-principal ul.submenu li";
	$(subMenu).css('margin-top','32px');

	$(itemMenu).each(function(){
		$(this).mouseover(function(){
			$(this).find('ul').css('left','0');
		});
		$(this).mouseout(function(){
			$(this).find('ul').css('left','-99999px');//esconde o menu novamente
		})
	})
	$(itemMenu).each(function(){
		$(this).mouseover(function(){
			$(this).css('background','url("imagem/bg-menu-dropdown-hover.png") left center no-repeat');
			$(this).find('a').css('color','#19A7D9');
		});
		$(this).mouseout(function(){
			$(this).css('background','url("imagem/bg-menu-dropdown.png") left center no-repeat');
			$(this).find('a').css('color','#FFF');
		});
	})
}
function ultimas(){
	$('.anuncio-destaque:last-child,.secoes:last-child').addClass('ultima'); // simula o last:child do css3 aplicando a classe ultima
}

