/*
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
*/

// Functions
// Le cluster vars do meta que comecem com DPC.CLUSTER.
//XXX: Need Test
function dpc_meta_var(){
	var arrCluster = new Array();
	//Set cluster vars
	jQuery("meta[name^=DPC.CLUSTER.]").each(function(){
		arrCluster.push(this.name.toLowerCase().substring(12), this.content);
	});
	if(arrCluster.length>0) {
		dpc_cluster_array(arrCluster);
	}
}
var dpc_location_pathname = location.pathname;
if (dpc_location_pathname) dpc_location_pathname=dpc_location_pathname.toLowerCase();

//Flash
function dpcOpenSite(url, nome){
	if (dpc_pageview) dpc_pageview(nome);
	if (dpcTracker&&dpcTracker._getLinkerUrl)
		location.href=dpcTracker._getLinkerUrl(url);
	else
		location.href=url;
}

//
jQuery(document).ready(function(){
	dpc_meta_var(); 

	var sUrl = document.location.href.toLowerCase();
	var sReferer = document.referrer.toLowerCase();

	jQuery(".thickbox").click(function (e) {     
    dpc_pageview(dpc_location_pathname+"/"+dpc_encode(jQuery(this).attr('title'))+"/clique");
    });	
//passar os parametros para os outros sites
		jQuery("a[href*='metalifepilates'],[href*='revistapilates'],[href*='negociopilates'],[href*='metalife']").mousedown(function () {
            var _url = dpcTracker._getLinkerUrl(jQuery(this).attr("href"));
	    jQuery(this).attr("href",  _url);
});

//Formulários

//Contato
if (dpc_location_pathname.indexOf("/contato.php")>=0 || dpc_location_pathname.indexOf("/envia_contato.php")>=0 || dpc_location_pathname.indexOf("/contato_2.php")>=0){ 
	var dpc_estado;
	var dpc_cidade;
	jQuery("#form a").click(function(){
        if (jQuery(this).text().indexOf('Enviar')>=0){ 
			dpc_pageview(dpc_location_pathname+"/contato/enviar");
			dpc_estado = jQuery("#form #estado").val();
			dpc_cidade = jQuery("#form #cidade").val();
			dpc_cluster_var("cadastro","enviado","estado",dpc_estado,"cidade",dpc_cidade);
		}	
   });
   //Criando o campo hidden para enviar as origens
	if (jQuery("#form input[name='dpc_ga_origem']").length==0)
		jQuery("#form").append("<input type='hidden' name='dpc_ga_origem'>");

	jQuery("#form input[name='dpc_ga_origem']").val(dpc_ga_origem());
}

//Certifica
if (dpc_location_pathname.indexOf("/contato_certifica.php")>=0){ 
	var dpc_estado;
	var dpc_cidade;
	var dpc_cursorealizado;
	if(jQuery('#fm_contato').get(0)){
		dpc_autotag_form(jQuery('#fm_contato').get(0));
	}	
	jQuery("#fm_contato a").click(function(){
        if (jQuery(this).text().indexOf('Enviar')>=0){ 
			dpc_pageview(dpc_location_pathname+"/certifica/enviar");
			dpc_estado = jQuery("#fm_contato #Estado").val();
			dpc_cidade = jQuery("#fm_contato #Cidade").val();
			dpc_cursorealizado = jQuery("#fm_contato [name='CURSOS']").val();
			dpc_cluster_var("certifica","enviado","estado",dpc_estado,"cidade",dpc_cidade,"cursoRealizado",dpc_cursorealizado);
		}	
   });
   //Criando o campo hidden para enviar as origens
	if (jQuery("#fm_contato input[name='dpc_ga_origem']").length==0)
		jQuery("#fm_contato").append("<input type='hidden' name='dpc_ga_origem'>");

	jQuery("#fm_contato input[name='dpc_ga_origem']").val(dpc_ga_origem());   
}

});//fecha o ready








