/*
This code was developed at DirectPerformance (www.directperformance.com.br) and is distributed under the Creative Commons - Attribution-NonCommercial 3.0. More details: http://creativecommons.org/licenses/by-nc/3.0/legalcode
You can freely share, transmit and adapt, but you must attribute the work to the original author information and can not use for commercial purposes.
Original Author: DirectPerformance - Website: www.directperformance.com.br - E-mail: contato@directperformance.com.br
*/

//Wrapper para usar em window onload
dpc_tagpage = function(){

var sUrl = document.location.href.toLowerCase();
var sReferer = document.referrer.toLowerCase();


// Cadastro
if ( sUrl.indexOf("/contato.aspx") >= 0){
	var form1 = document.forms[0];
	var bSubmit = document.getElementById("ctl00_ContentPlaceHolder_btnSendForm");
	if (form1){
		dpcAttachEvent(bSubmit,"click", function(e){
			var resposta = "/contato/email/enviar?";	
			if (neoForm.validate('.mainpanel fieldset', function(success){})){
			if (select_field = document.getElementById("ctl00_ContentPlaceHolder_lstHouses")){//maxhaus mais gostei
				for (opt in select_field.options){
					if(select_field.options[opt].selected){
						resposta += "mais_gostei=" + select_field.options[opt].text;
						break;
			}}}
			dpc_pageview(resposta);
			}
		});
	}
}


// Escolha o seu
if (document.location.pathname.toLowerCase().indexOf("choose_your.aspx")>=0){
	dpc_pageview( '/escolha-o-seu/'+ dpc_getLocationParams() + '/' + location.hash.substring(1));
	$("#photos ul li a").click(function(e){
            var select = $(this).parent().attr('class').split(' ')[0].split('-');
			dpc_pageview( '/escolha-o-seu/'+ dpc_getLocationParams() + '/nav=' + select[1] + ',' + (select[2]?select[2]:0) + ',' + (select[3]?select[3]:0));            
        }
    );
}	


//URL Encode
var dpc_ue=encodeURIComponent||escape;
//Menu Inferior
$("#sitemap a").click(function(){dpc_pageview("/menu-inferior/"+dpc_ue($(this).text()))});
//Menu Superior
$("#nav a").click(function(){dpc_pageview("/menu-superior/"+dpc_ue($(this).text()))});
//Menu Bairro
$("#neighborhood-select a").click(function(){dpc_pageview("/menu-bairro/"+dpc_ue($(this).text()))});
//Menu Sidebar
$("#sidebar a").click(function(){dpc_pageview("/menu-sidebar/"+dpc_ue($(this).text()))});
//Menu Escolha o Bairro
$("#footer fieldset a").click(function(){dpc_pageview("/menu-inferior/escolha-o-bairro/"+dpc_ue($(this).text()))});



// Testimonials - mailto
if (document.location.pathname.toLowerCase().indexOf("concept_testimonials.aspx")>=0){
$('li[rel="mailto"]').click(function()
{
dpc_pageview('/idealizadores/seja-um/email-enviar');
});
}	

// Eventos - click para ver noticia
if (document.location.pathname.toLowerCase().indexOf("events.aspx")>=0){
$('#content .text a').click(function()
{
dpc_pageview('/eventos/noticia-clicou');
});
}

// Banner da Home
$('#banner .description').click(function(){
	dpc_pageview('/home/banner-interno/campanha-berrini/');
});



};

dpcAttachEvent(window,"load",dpc_tagpage);