$(function(){

	var shopp = new ShoppingUOL;

	// redimensiona lista de departamentos e destaques
	var patrocina = $("#area-patrocinador").height() + $("#selo").height() + $("#ofertas-home").height();
	if($("#nav-menu-home").height() > patrocina){
		var captureHeight = $("#nav-menu-home").height() - 35;
		$("#ofertas-home").height(captureHeight);
	}
	
	// insere atributo target nos links de lojista e consumidor
	$('div#bloco-servicos ul li a, div.anunciante ul li a').click(function(e){
		$(this).attr('target','_blank');
	});
	
	if($('#carrosselHome').size() > 0 && shopp.check_shockwave_flash()){
	
		var par = location.href.match(/([a-z0-9]{1,})\.?shopping.uol.com.br/i);	
		var flashVars = ((par != null && par[1] != undefined) ? par[1] : '');
		
		swf = '<object type="application/x-shockwave-flash" data="/home.swf" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="560" height="625" style="outline:none">'+
					'<param name="movie" value="/home.swf" />'+
					'<param name="wmode" value="transparent" />'+
					'<param name="menu" value="false" />'+
					'<param name="quality" value="high" />'+
					'<param name="allowScriptAccess" value="always" />'+
					'<param name="flashVars" value="par='+ flashVars +'" />'+
					'<embed pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" src="http://shopping.uol.com.br/home.swf" wmode="transparent" menu="false" quality="high" allowScriptAccess="always" width="560" height="625" style="outline:none" flashVars="par='+ flashVars +'">'+
			  '</object>';
			  
		$('#flash-home').prepend(swf);
		
	}else if(!shopp.check_shockwave_flash()){
		
		no_flash_html = '<div class="noflash">'+
							'<div class="noflash_message">'+
								'Olá! O Flash Player do Adobe não está instalado ou sua versão é muito antiga.'+
								'<a href="http://www.adobe.com/go/getflashplayer/" target="_blank">Obtenha a última versão do Flash Player</a>.'+
							'</div>'+
						'</div>';
		$('#flash-home').prepend(no_flash_html);
		
	}
	
	$('div#tripaNatal').click(function(e){
		e.stopPropagation(); e.preventDefault();
		
		window.location.href = 'http://shopping.uol.com.br/especiais/index.html?hits=50';
	});
	
	$('div#tripaNatal a').click(function(e){
		e.stopPropagation(); e.preventDefault();
		
		window.location.href = $(this).attr('href');
	});
	
	$('div#bloco-servicos input[@name=emailbulletin]').click(function(){
		if($(this).val() == 'Digite seu e-mail') $(this).val('');
	});
	
	$('div#bloco-servicos input[@name=emailbulletin]').blur(function(){
		if($(this).val() == '') $(this).val('Digite seu e-mail');
	});
});