// JavaScript Document

//function document.onkeypress(){
 document.onkeypress = function(){	
	//desabilita as teclas fora do range do regExpress, evento onkeypress
	s = event.srcElement.teclas;
	if(s) {
		re=new RegExp(s);
		sKey=String.fromCharCode(event.keyCode);
		if (!re.test(sKey)) event.returnValue = false;
	}
}//function

var nun = 0
function fncPrepararImpressao(){
	var pH = 400
	var pW = 700
	var T = (screen.Height - pH)/2
	var L = (screen.Width - pW)/2
	var settings = 'width='+ pW +',height='+ pH +',top='+ T +',left=' + L + ',scrollbars,status,resizable'
	var popPrint = window.open('about:blank','print' + num,settings)
	popPrint.document.write("<html><title>Preparar impressão</title><body>")
	popPrint.document.write("</head><body><div style='width:700px'>")
	popPrint.document.write(document.getElementById("conteudo").innerHTML)
	popPrint.document.write("</div></body></html><script>window.print();</scr"+"ipt>")
	num =+ 1
	popPrint.location.reload();
}//function

function fncFormato(pPath,pPrograma,pPK,pLegenda,pCampo) {
	var pH = 100
	var pW = 250
	var T = (screen.Height - pH)/2
	var L = (screen.Width - pW)/2
	var settings = 'width='+ pW +',height='+ pH +',top='+ T +',left=' + L + ',scrollbars,status,resizable'
	var popPrint = window.open('about:blank',pPrograma + num,settings)
	popPrint.document.write("<html><title>Preparar formato</title><body>")
	popPrint.document.write("</head><body><form style='display:none' name='form1' method='post' action='"+ pPath +"include/popup.asp'>")
	popPrint.document.write("<textarea name='programa'>" + pPrograma + "</textarea>")
	popPrint.document.write("<textarea name='PK'>" + pPK + "</textarea>")
	popPrint.document.write("<textarea name='legendaLista'>" + pLegenda + "</textarea>")
	popPrint.document.write("<textarea name='camposLista'>" + pCampo + "</textarea>")
	//popPrint.document.write("<input type=submit>")
	popPrint.document.write("</form><img src='"+ pPath +"imagens/icon_" + pPrograma + ".gif' align='left'><font face=arial><b> Formatando dados...</body></html>")
	popPrint.document.write("<script>setTimeout('document.form1.submit()',1000)</scr"+"ipt>")
	num =+ 1
}//function

function fncViaXML(pURL,pQueryString){
	//tenta recuperar todos os tipos de XML's possíveis
	try{//1
		var objXML = new XMLHttpRequest();
	}catch(ee){
		try{//2
			var objXML = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{//3
				var objXML = new ActiveXObject("Microsoft.xmlhttp");
			}catch(E){
				var objXML = false;
			}//3
		}//2
	}//1
	objXML.open("post", pURL + "?" + pQueryString ,false);
	objXML.send();
	return objXML.responseText;
}//function


function fncRefresh(pPath){
	try{
		var str_retorno = fncViaXML(pPath+"include/xmlHttp.asp","str_acao=refreshIM")
		if(str_retorno != ''){
			num = num +1
			arr_retorno = str_retorno.split('|')
			
			chr_apelido = arr_retorno[0]
			ID_LOGON = arr_retorno[1]
			chr_msg = arr_retorno[2]
			if (ID_LOGON =! ''){
				popUp = window.open('about:blank','avisoIM' + num,'top='+ (screen.Height-200) +',left='+ (screen.Width-250) +',height=100,width=240')
				popUp.document.write('<html><title>IM diz ::.. </title><head>')
				popUp.document.write('<link href="'+ pPath +'include/estilos_template.css" rel="stylesheet" type="text/css" />')
				popUp.document.write('<sc'+'ript src="'+ pPath +'include/geral.js" type="text/javascript"></sc'+'ript>')
				popUp.document.write("</head><body>")
				popUp.document.write("	  <table stule='cursor:hands' onclick=\"javascript:fncAbrePopUp('im"+ num +"','"+ pPath +"sys/im.asp?id_interlocutor="+ ID_LOGON +"','250','350','resizable,status','','');window.close();\" width='100%' height='100%' border='0' cellpadding='0' cellspacing='0' class='tabelaDados'>")
				popUp.document.write('        <tr>')
				popUp.document.write('          <td class="bgCorEscura" height=1><b class="fontCorClara"> '+ chr_apelido +' diz</b>:</td>')
				popUp.document.write('        </tr>')
				popUp.document.write('        <tr>')
				popUp.document.write('          <td class="bgCorClara"> '+ chr_msg +'</td>')
				popUp.document.write('        </tr>')
				popUp.document.write('      </table>	')  
				popUp.document.write("</body></html>");
				popUp.focus();
				setTimeout("popUp.close()",15000)
			}
		}//if
	}catch(e){}
}//function

function fncAtualizaDataHora(pCampo){
	try{
		h = window.parent.document.getElementById("hora_"+pCampo).value
		m = window.parent.document.getElementById("minuto_"+pCampo).value
		d = window.parent.document.getElementById("legenda_"+pCampo).innerText
		//alert(d + ' ' +h+ ':' + m)
		if ((h != '') && (m != '')){
			window.parent.document.getElementById(pCampo).value = d + ' ' +h+ ':' + m
		}else{
			window.parent.document.getElementById(pCampo).value = d 
		}
	}catch(ee){}
	//existe uma versaõ desta funcção em geral.asp
}//function

function fncAtualizaCampo(pEscopo,pObj){
	// a página xmlHttp.asp, na função  fncBlocoProjeto() que monta a chamada para a função geral.js > fncCarregaCampo .
	// que printa na tela um objeto para edição que ao perder o foco invoca a função geral.js > fncAtualizaCampo
	// que pega os valores e envia via XMLHTTP para xmlHttp.asp que aciona a subrotina subAtualizaCampo no servidor e
	// atualiza o campo com o valor difitado na tabela requerida
	var id = pObj.id.replace("input_","")
	var id_nome = pObj.id_nome.replace("input_","")
	var campo = pObj.name
	var valor = pObj.value
	var escopo = pObj.escopo
	
	//window.status = id + ';' +  campo + ';' +  valor + ';' +  escopo
	
	var string = "str_acao=AtualizaCampo"
	var string = string + "&id=" + id
	var string = string + "&id_nome=" + id_nome
	var string = string + "&campo=" + campo
	var string = string + "&valor=" + valor
	var string = string + "&escopo=" + escopo
	var str_retorno = fncViaXML("../include/xmlHttp.asp",string )
	document.getElementById(id).innerHTML = str_retorno
	qtde_clique = 0
}//function

var qtde_clique = 0
function fncCarregaCampo(pEscopo,pObj){
	// a página xmlHttp.asp, na função  fncBlocoProjeto() que monta a chamada para a função geral.js > fncCarregaCampo .
	// que printa na tela um objeto para edição que ao perder o foco invoca a função geral.js > fncAtualizaCampo
	// que pega os valores e envia via XMLHTTP para xmlHttp.asp que aciona a subrotina subAtualizaCampo no servidor e
	// atualiza o campo com o valor difitado na tabela requerida
	if (qtde_clique != 0){
		//este if impede que se o usuário clicar 4 vezes o objeto se chama em html.. isso dá pau....
		qtde_clique = 1;
		return false;
	}
	qtde_clique = 1
	
	var id = pObj.id
	var id_nome = pObj.id_nome
	var nome = pObj.name
	var valor = pObj.innerHTML
	var texto = pObj.innerText
	var tipo = pObj.tipo
	//window.status = id + ';' +  nome + ';' +  valor + ';' +  texto + ';' +  tipo + ';' +  id_nome
	if (tipo == 'texto'){
		pObj.innerHTML = "<input type='text' name='"+ nome +"' id='input_"+ id +"' id_nome='input_"+ id_nome +"' escopo="+ pEscopo +" class='inputTransparente' value='"+ valor +"' size='"+ texto.length +"' onBlur=\"fncAtualizaCampo('"+ pEscopo+"',this)\">"
	}else if (tipo == 'textarea'){
		pObj.innerHTML = "<textarea style='width:100%;height:100px;' type='text' name='"+ nome +"' id='input_"+ id +"' id_nome='input_"+ id_nome +"' escopo="+ pEscopo +" class='inputTransparente' value='"+ valor +"' size='"+ texto.length +"' onBlur=\"fncAtualizaCampo('"+ pEscopo+"',this)\">"+ valor +"</textarea>"
	}else if (tipo == 'select'){
		var array = pObj.array
		var str = "<select name='"+ nome +"' id='input_"+ id +"' id_nome='input_"+ id_nome +"' escopo="+ pEscopo +" class='inputTransparente' value='"+ valor +"' onChange=\"fncAtualizaCampo('"+ pEscopo+"',this)\">"
		str = str + "<option value=''></option>"
		array = array.split("|")
		var i = 0
		while(i < array.length){
			var campos = array[i].split(";")
			str = str + "<option value='"+ campos[0] + "|" + campos[1]  +"'>"+ campos[1] +"</option>"
			i++;
		}//for		
		pObj.innerHTML = str + "</select>"
	}else{
		qtde_clique = 0
	}//if
		
}//function

function fncCarregaBloco(pID,pFuncao){
	var div = document.getElementById("id_conteudo_" + pID)
	div.innerHTML = "Carregando..."	
	var str_conteudo = fncViaXML("../include/xmlHttp.asp","str_acao=carregaBlocos&chr_funcao=" + pFuncao)
	div.innerHTML = str_conteudo	
}//function

function fncDesCarregaBloco(pID,pFuncao){
	if(confirm("Confirma exclusão deste bloco da sua home-page?\n\n Você pode adicioná-lo clicando em Meu Desktop > Minha Home-page.")){
		var div = document.getElementById("id_bloco_" + pID)
		var arr = pID.split("_")
		var str_conteudo = fncViaXML("../include/xmlHttp.asp","str_acao=descarregaBlocos&id_bloco="+ arr[1] +"&chr_funcao=" + pFuncao)
		div.innerHTML = str_conteudo	
	}
}//function

function show(pDiv){
	//utilizada em vários locais
	document.getElementById(pDiv).style.display=''
}//function

function hide(pDiv){
	//utilizada em vários locais
	document.getElementById(pDiv).style.display='none'
}//function

function fncExpandir(pImg,pDiv){
	var img = document.getElementById(pImg)
	var div = document.getElementById(pDiv)

	if (div.style.display == 'none'){
		img.src= '../imagens/icon_menos.gif'
		div.style.display = ''
	}else{
		img.src= '../imagens/icon_mais.gif'
		div.style.display = 'none'
	}

}//function
var x
function fncMenu(pDiv,pSentido){
	//o menu principal usa esta função.
	
	//document.getElementById(pDiv).style.clip.width = '25px'
	//rect(left,width,height,top)
	//document.getElementById("+pDiv+").style.clip = 'rect(auto, auto, auto, auto)'
	//x=document.getElementById(pDiv).style.clip
	//window.status = x
	//document.getElementById("debug").innerHTML = "<font color='white'>@#$:" + x

	if(pSentido == 'over'){
		show(pDiv)
		document.getElementById(pDiv + '_label').className = '';
	}else if(pSentido == 'out'){
		hide(pDiv)
		document.getElementById(pDiv + '_label').className = '';
	}else if(pSentido == 'overMenu'){
		show(pDiv)
		document.getElementById(pDiv + '_label').className = 'categoria over';
	}else if(pSentido == 'outMenu'){
		hide(pDiv)
		document.getElementById(pDiv + '_label').className = 'categoria';
	}
	
}//function

var pop_num = 0
var popUp

function fncAbrePopUp(pName, pURL, pH,pW,pSettings,pTitulo,pConteudo){
	// abre uma popup centralizada
	// o conteudo deve ser passado como parametro, pois não há arquivo fisico de carregamento
	// sintaxe	: fncAbrePopUp('popname', 'le.asp', 450, 250,'resizable,statusbar','Title da janela','')
	// 	ou
	// sintaxe	: fncAbrePopUp('popname', '', 450, 250,'resizable,statusbar','Title da janela','Bom dia meu amigo')
	if (pH == '')			{pH = 300}
	if (pW == '')			{pW = 250}
	if (pSettings != '')	{pSettings = ',' + pSettings}
	var T = (screen.Height - pH)/2
	var L = (screen.Width - pW)/2
	var settings = 'width='+ pW +',height='+ pH +',top='+ T +',left=' + L + '' + pSettings
	pop_num = pop_num +1
	if (pURL == ''){
		var popUp = window.open('about:blank',pName + pop_num,settings)
		popUp.document.write('<html><title>'+ pTitulo +'</title><head>')
		popUp.document.write('<link href="include/estilos_template.css" rel="stylesheet" type="text/css" />')
		popUp.document.write('<link href="../include/estilos_template.css" rel="stylesheet" type="text/css" />')
		popUp.document.write('<link href="../../include/estilos_template.css" rel="stylesheet" type="text/css" />')
		popUp.document.write('<link href="../../../include/estilos_template.css" rel="stylesheet" type="text/css" />')
		popUp.document.write('<link href="../../../../include/estilos_template.css" rel="stylesheet" type="text/css" />')
		popUp.document.write("</head><body>")
		popUp.document.write(pConteudo)
		popUp.document.write("</body></html>")
	}else{
		var popUp = window.open(pURL,pName + pop_num,settings)
	}
	popUp.focus()
}//function

function fncSair(pPath){
	var str_retorno = fncViaXML(pPath + 'include/xmlHttp.asp','str_acao=logon')
	//document.getElementById("debug").innerHTML = str_retorno
	window.location.reload()
}//function

function fncVisualizar(pTipo){
	if(pTipo == 'print'){
		var conteudo = document.getElementById('conteudo').innerHTML 
	}
}//function

function fncExcluir(){
	if(confirm("Confirme exclusão dos registros selecionados.")){
		document.getElementById("str_acao").value = 'excluir'
		document.formList.submit()
	}
}//function

function fncOrdem(pSentido,pCampo){
	document.getElementById("orderBy").value = pCampo + ' ' + pSentido
	document.formList.submit()
}//function








//************************************************//
//                                                //
/*
	funções de validção de formulário e campos
*/                                                //
//                                                //
//************************************************//

function fncAviso(pQtde,pCampo,pAlerta){
	//esta funcção printa na tela o aviso de erro se qtde = 0
	if (pQtde ==0){
		if(pAlerta == ''){pAlerta = 'Campo obrigatório'}
		document.getElementById('lbl_'+ pCampo).innerHTML = '<div class="msgValidacao">' + pAlerta + '</div>'
		erroValidacao = erroValidacao + 1
	}else{
		try{
			document.getElementById('lbl_'+ pCampo).innerHTML = ''
		}catch(e){
		}//catch
	}//if
}					 

function fncCampoObrigatorio(pCampo,pAlerta){
	if (document.getElementById(pCampo).value==''){
		fncAviso(0,pCampo,pAlerta)
	}else{
		fncAviso(1,pCampo,pAlerta)
	}//if
}//function fncCampoObrigatorio
					 
function fncCampoTextarea(pCampo,pAlerta,pDe,pAte){
	var obj = document.getElementById(pCampo)
	var caracter = obj.value.length
	if(pAlerta == ''){pAlerta = 'Este campo requer mínimo de '+ pDe+' e máximo de '+ pAte +' caracteres'}
	
	if (caracter < pDe || caracter > pAte){
		fncAviso(0,pCampo,pAlerta + '. Atual:' + caracter )
	}else{
		fncAviso(1,pCampo,pAlerta + '. Atual:' + caracter )
	}//if
	
}					 

function fncCampoObrigatorioMultiplo(pCampo,pAlerta){
	var obj = eval("document.formFormulario." + pCampo)
	var qtde_selecionada = 0
	for (var i = 0; i<obj.length; i++) {
		if (obj[i].checked) {
			qtde_selecionada = qtde_selecionada + 1
		}//if
	}//for
	fncAviso(qtde_selecionada,pCampo,pAlerta)
}//function
					 































































































//cod antigos....refs!!

function fncSubmit(pForm){
	pForm.submit()	
}//function

function fncSubmit2(pObj,pForm){
	/*
	Esta função varre todos os objetos do documento e filtra os que precisam de valiadação.
	pObj = id html do botão em questão
	pForm = objeto do tipo form que será postado
	OBS: os campos com validação deverão ter + 2 parâmetros em html, o msgAlert e o tipoValidacao.
	O tipoValidacao determina qual o tipo de validação que o valor do objeto terá. 
		E deverá estar dentro do IF da função fncValidar
	O msgAlert é a msg que será exibida no alert se a validação retornar erro.
	exemplo: <input type="text" value="" name="NONON" msgAlert="O campo NONON não foi preenchido" tipoValidacao="text">
	
	TODA validação envocará uma outra função relativa ao parâmetro solicitado, portanto esta DEVE estar declarada.
	*/
	var f = pForm
	try{
		var qtdeObj = f.elements.length -1
		var alerta = "undefined"
		for(var i = 0; i <= qtdeObj; i++){
			alerta = f.elements(i).msgAlert + '';
			if (alerta != 'undefined'){
				if (fncValidar(f.elements(i).tipoValidacao,f.elements(i).value)){
					alert(alerta)
					//fncWinModal(1,alerta,"p")
					f.elements(i).focus()
					window.status = "Erros encontrados no preenchimento."
					return false;
				}// if validacao
			}else{
				window.status = "Validando..."
			}
				window.status = "Aguardando correções do usuário."
		}//for
		window.status = "Validado"
	}
	catch(err){
		//window.status = "Erro de validação no script JS."
		return false;
	}
	window.status = "Validado, enviando dados, por favor aguarde."
	//document.getElementById(pObj).style.display = 'none';
	//document.getElementById(pObj + "_Final").style.display = '';
	alert('To testando a validação, num reclama!')
	//f.submit()
	
}//funciton

function fncValidaData(data) {
	//formto brasileiro
	var formato = "[0-3][0-9]/[0-1][0-9]/[0-9][0-9][0-9][0-9]";
	var reg = new RegExp(formato);
	var formato_ok = reg.test(data);
	var dia = data.substring(0,2);
	var mes = data.substring(3,5);
	var ano = data.substring(6,10);
	var nova_data = new Date(ano, mes - 1, dia);
	var dia_ok = (nova_data.getDate() == dia);
	var mes_ok = (nova_data.getMonth() + 1 == mes);
	return (formato_ok && dia_ok && mes_ok)
}


function fncFormataData(vDate, vEvent) {
//exemplo de uso: onkeypress="fncFormataData(this, event)" 
  isNav4 = navigator.appName == "Netscape" && navigator.appVersion < "5";
  strSeperator = '/';

  if (!isNav4) {
	if ((vDate.value.length == 2 || vDate.value.length == 5)  ) 
	  if (vEvent.keyCode != 46)    // Del 
		if (vEvent.keyCode != 8)   // Back Space
		  vDate.value = vDate.value + strSeperator;   
		else
		  vDate.value = vDate.value.substr(0,vDate.value.length-1);   
  }
  else 
	if (vDate.value.length == 8) 
	  vDate.value = vDate.value.substr(0,2) + strSeperator + 
					vDate.value.substr(2,2) + strSeperator + 
					vDate.value.substr(4,4);

}


function fncValidar(pTipo,pValor){
	//relaciona a solicitação de validação com uma função (tem q estar neste documento JS !!!!!!!!! Declara mano!)
	if (pValor == "" && pTipo==""){return true}
	else if (pTipo == "*"){return fncValidaPreenchimento(pValor);}
	else if (pTipo == "data"){return fncValidaData(pValor);}
	else if (pTipo == "data*"){
		if(pValor == ''){return true};
		return fncValidaData(pValor);
	}else if (pTipo == "email*"){return fncValidaEmail(pValor);}
	else if (pTipo == "email"){return fncValidaEmailOpcional(pValor);}
	else if (pTipo == "select"){return fncValidaSelectBox(pValor);}
	else{return false;}
}//function


function fncValidaPreenchimento(pValor){
	if (pValor == ''){
		return true
	}else{
		return false
	}
}//function 

function fncValidaSelectBox(pValor){
	window.status = pValor 
	if (pValor == ''){
		return true
	}else{
		return false
	}
}//function 

function fncValidaEmail(pValor) {
	var array_arroba;
	var array_ponto;
	//alert(pValor)
	if (pValor.indexOf(" ") > 1 ) {return true;}
	if (pValor.indexOf("@") == -1 ) {
		return true;
	}else {
		array_arroba = pValor.split("@");
		if (array_arroba.length != 2) {	return true;}
		if (array_arroba[0] == "" || array_arroba[1] == "")	{	return true;}
			if ( array_arroba[1].indexOf(".") == -1 ) {	
				return true;
			}else {
				array_ponto = array_arroba[1].split(".");
				for (i = 0 ; i < array_ponto.length ; i++) {
					if (array_ponto[i] == "") {	return true;}
				}//for
			}//if ( array_arroba[1].indexOf(".") == -1 )	
	}//if
	
}//function

function fncValidaEmailOpcional(pValor) {
	if (pValor == ""){
		return false
	}else{
		return fncValidaEmail(pValor)
	}
}//function













///////////////////////////////////////Bloco necessário para objetos SWF
//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-19603340-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

