var arrTags = 
[
	{google:"Index", predicta:"embratel_pme_home_html", addInteligence:""},
	{google:"Index/Video", predicta:"embratel_pme_home_video", addInteligence:""},
	{google:"Index/Video/Pular", predicta:"embratel_pme_home_video_pular", addInteligence:""},
	{google:"Index/Video/EnviaEmail", predicta:"embratel_pme_home_video_enviar-email", addInteligence:""},
	{google:"Index/Video/SemEnviarEmail", predicta:"embratel_pme_home_video_nao-enviar-email", addInteligence:""},
	{google:"Index/Home", predicta:"embratel_pme_home", addInteligence:""},
	{google:"Index/Produto", predicta:"embratel_pme_produto", addInteligence:""},
	{google:"Index/Beneficios", predicta:"embratel_pme_beneficios", addInteligence:""},
	{google:"Index/Abrangencia", predicta:"embratel_pme_abrangencia", addInteligence:""},
	{google:"Index/Abrangencia/NaoDisponivel", predicta:"embratel_pme_abrangencia_nao-disponivel", addInteligence:""},
	{google:"Index/Abrangencia/NaoDisponivel/EnviarDados", predicta:"embratel_pme_abrangencia_nao-disponivel_enviar-dados", addInteligence:""},
	{google:"Index/Abrangencia/Disponivel", predicta:"embratel_pme_abrangencia_disponivel", addInteligence:""},
	{google:"Index/Abrangencia/Disponivel/Comprar", predicta:"embratel_pme_abrangencia_disponivel_comprar", addInteligence:""},
	{google:"Index/ComoComprar", predicta:"embratel_pme_como-comprar", addInteligence:""},
	{google:"Index/ComoComprar/Enviar", predicta:"embratel_pme_como-comprar_enviar", addInteligence:""},
	{google:"Index/Promocoes", predicta:"embratel_pme_promocoes", addInteligence:""},
	{google:"Index/LinksUteis", predicta:"embratel_pme_links-uteis", addInteligence:""},
	{google:"Index/FaleConosco", predicta:"embratel_pme_faleconosco", addInteligence:""},
	{google:"Index/FaleConosco/Enviar", predicta:"embratel_pme_faleconosco_enviar", addInteligence:""},
	{google:"Index/MapaSite", predicta:"embratel_pme_mapa-do-site", addInteligence:""}
];

// Quando aplicar no site, utilizar trackDebug = false;
var trackDebug = false;

// Dimensões padrões para abrir pop-up quando não espeficiada na função.
var nPopDefaultWidth = 400;
var nPopDefaultHeight = 400;


//function atmCLL(strTag){}
//function urchinTracker( strTag ) {}

function getTag ( strGoogleTag, strReturnTag )
{
	for( var i=0; i<arrTags.length; i++ ) 
	{
		if (arrTags[i].google == strGoogleTag)
		{
			return arrTags[i][strReturnTag];
		}
	}
	return "";
}


//function track( strTag, strURL, strWindow, nWidth, nHeight )
function track( arParams )
{
	strTag = arParams[0];
	strURL = arParams[1];
	strWindow = arParams[2];
	nWidth = arParams[3];
	nHeight = arParams[4];

	if(strTag == "null" || strTag == "undefined") strTag = "";
	if(strURL == "null" || strURL == "undefined") strURL = "";
	if(strWindow == "null" || strWindow == "undefined") strWindow = "";
	if(nWidth == "null" || nWidth == "undefined") nWidth = "";
	if(nHeight == "null" || nHeight == "undefined") nHeight = "";

	// Predicta
	var strPredictaTag = getTag(strTag, "predicta");
	if (strPredictaTag!="")
	{
		void( atmCLL(strPredictaTag) );
		if ( trackDebug ) alert( strPredictaTag );
	}
	
	// addInteligence
	var strAddInteligenceTag = getTag(strTag, "addInteligence");
	if (strAddInteligenceTag!="")
	{
		// verificar se existe imagem com id de "image_tracker".
		if(document.getElementById("image_tracker") == null){
			alert("Image tracker missing.\n AddInteligence won't work");
		}else{
			void( document.getElementById("image_tracker").src = strAddInteligenceTag );
			if ( trackDebug ) alert( strAddInteligenceTag );
		}
	}
	
	// google analytics
	void( urchinTracker(strTag) );
	if ( trackDebug ) alert( strTag );
	
	if ( strURL )
	{
		switch ( strWindow )
		{
			case "pop_full":
				popFull( strURL );
				break;
			
			case "pop":
				if ( !nWidth ) nWidth = nPopDefaultWidth;
				if ( !nHeight ) nHeight = nPopDefaultHeight;
				pop( strURL, nWidth, nHeight );
				break;
			
			case "_blank":
				window.open(strURL);
				break;

			default:
				window.location = strURL;
		}				
	}
}

function GE(objid){ return document.getElementById(objid); }

// Funções auxiliares de Pop-up
function pop( x, w, h, full )
{
	if ( full == 1 ){
		l = 0;
		t = 0;
	} else {
		l = ( (window.screen.width  - w) / 2 );
		t = ( (window.screen.height - h) / 2 );
	}
	
    popUpTracker = window.open(x,'popUpWindowTracker','leftmargin=0,topmargin=0,marginheight=0,marginwidth=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,top='+t+',left='+l+',screenX='+l+',screenY='+t+',copyhistory=no,height='+h+',width='+w+'');
	popUpTracker.focus();
}

function popFull( x )
{
	pop( x, screen.availWidth-7, screen.availHeight-8, 1 );
}
