function afterload(){
	_uacct = "UA-1063175-1";
	//urchinTracker();
}

//ADICIONAR FONTE NO FLASH//
var hasFlash=function(){var a=6;if(navigator.appVersion.indexOf("MSIE")!=-1&&navigator.appVersion.indexOf("Windows")>-1){document.write('<script language="VBScript"\> \non error resume next \nhasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & '+a+'))) \n</script\> \n');if(window.hasFlash!=null)return window.hasFlash}if(navigator.mimeTypes&&navigator.mimeTypes["application/x-shockwave-flash"]&&navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){var b=(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description;return parseInt(b.charAt(b.indexOf(".")-1))>=a}return false}();String.prototype.normalize=function(){return this.replace(/\s+/g," ")};if(Array.prototype.push==null){Array.prototype.push=function(){var i=0,a=this.length,b=arguments.length;while(i<b){this[a++]=arguments[i++]}return this.length}}if(!Function.prototype.apply){Function.prototype.apply=function(a,b){var c=[];var d,e;if(!a)a=window;if(!b)b=[];for(var i=0;i<b.length;i++){c[i]="b["+i+"]"}e="a.__applyTemp__("+c.join(",")+");";a.__applyTemp__=this;d=eval(e);a.__applyTemp__=null;return d}}function named(a){return new named.Arguments(a)}named.Arguments=function(a){this.oArgs=a};named.Arguments.prototype.constructor=named.Arguments;named.extract=function(a,b){var c,d;var i=a.length;while(i--){d=a[i];if(d!=null&&d.constructor!=null&&d.constructor==named.Arguments){c=a[i].oArgs;break}}if(c==null)return;for(e in c)if(b[e]!=null)b[e](c[e]);return};var parseSelector=function(){var a=/^([^#.>`]*)(#|\.|\>|\`)(.+)$/;function r(s,t){var u=s.split(/\s*\,\s*/);var v=[];for(var i=0;i<u.length;i++)v=v.concat(b(u[i],t));return v}function b(c,d,e){c=c.normalize().replace(" ","`");var f=c.match(a);var g,h,i,j,k,n;var l=[];if(f==null)f=[c,c];if(f[1]=="")f[1]="*";if(e==null)e="`";if(d==null)d=document;switch(f[2]){case "#":k=f[3].match(a);if(k==null)k=[null,f[3]];g=document.getElementById(k[1]);if(g==null||(f[1]!="*"&&!o(g,f[1])))return l;if(k.length==2){l.push(g);return l}return b(k[3],g,k[2]);case ".":if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;k=f[3].match(a);if(k!=null){if(g.className==null||g.className.match("(\\s|^)"+k[1]+"(\\s|$)")==null)continue;j=b(k[3],g,k[2]);l=l.concat(j)}else if(g.className!=null&&g.className.match("(\\s|^)"+f[3]+"(\\s|$)")!=null)l.push(g)}return l;case ">":if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;if(!o(g,f[1]))continue;j=b(f[3],g,">");l=l.concat(j)}return l;case "`":h=m(d,f[1]);for(i=0,n=h.length;i<n;i++){g=h[i];j=b(f[3],g,"`");l=l.concat(j)}return l;default:if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;if(!o(g,f[1]))continue;l.push(g)}return l}}function m(d,o){if(o=="*"&&d.all!=null)return d.all;return d.getElementsByTagName(o)}function o(p,q){return q=="*"?true:p.nodeName.toLowerCase().replace("html:", "")==q.toLowerCase()}return r}();var sIFR=function(){var a="http://www.w3.org/1999/xhtml";var b=false;var c=false;var d;var ah=[];var al=document;var ak=al.documentElement;var am=window;var au=al.addEventListener;var av=am.addEventListener;var f=function(){var g=navigator.userAgent.toLowerCase();var f={a:g.indexOf("applewebkit")>-1,b:g.indexOf("safari")>-1,c:navigator.product!=null&&navigator.product.toLowerCase().indexOf("konqueror")>-1,d:g.indexOf("opera")>-1,e:al.contentType!=null&&al.contentType.indexOf("xml")>-1,f:true,g:true,h:null,i:null,j:null,k:null};f.l=f.a||f.c;f.m=!f.a&&navigator.product!=null&&navigator.product.toLowerCase()=="gecko";if(f.m&&g.match(/.*gecko\/(\d{8}).*/))f.j=new Number(g.match(/.*gecko\/(\d{8}).*/)[1]);f.n=g.indexOf("msie")>-1&&!f.d&&!f.l&&!f.m;f.o=f.n&&g.match(/.*mac.*/)!=null;if(f.d&&g.match(/.*opera(\s|\/)(\d+\.\d+)/))f.i=new Number(g.match(/.*opera(\s|\/)(\d+\.\d+)/)[2]);if(f.n||(f.d&&f.i<7.6))f.g=false;if(f.a&&g.match(/.*applewebkit\/(\d+).*/))f.k=new Number(g.match(/.*applewebkit\/(\d+).*/)[1]);if(am.hasFlash&&(!f.n||f.o)){var aj=(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description;f.h=parseInt(aj.charAt(aj.indexOf(".")-1))}if(g.match(/.*(windows|mac).*/)==null||f.o||f.c||(f.d&&(g.match(/.*mac.*/)!=null||f.i<7.6))||(f.b&&f.h<7)||(!f.b&&f.a&&f.k<312)||(f.m&&f.j<20020523))f.f=false;if(!f.o&&!f.m&&al.createElementNS)try{al.createElementNS(a,"i").innerHTML=""}catch(e){f.e=true}f.p=f.c||(f.a&&f.k<312);return f}();function at(){return{bIsWebKit:f.a,bIsSafari:f.b,bIsKonq:f.c,bIsOpera:f.d,bIsXML:f.e,bHasTransparencySupport:f.f,bUseDOM:f.g,nFlashVersion:f.h,nOperaVersion:f.i,nGeckoBuildDate:f.j,nWebKitVersion:f.k,bIsKHTML:f.l,bIsGecko:f.m,bIsIE:f.n,bIsIEMac:f.o,bUseInnerHTMLHack:f.p}}if(am.hasFlash==false||!al.getElementsByTagName||!al.getElementById||(f.e&&(f.p||f.n)))return{UA:at()};function af(e){if((!k.bAutoInit&&(am.event||e)!=null)||!l(e))return;b=true;for(var i=0,h=ah.length;i<h;i++)j.apply(null,ah[i]);ah=[]}var k=af;function l(e){if(c==false||k.bIsDisabled==true||((f.e&&f.m||f.l)&&e==null&&b==false)||(al.body==null||al.getElementsByTagName("body").length==0))return false;return true}function m(n){if(f.n)return n.replace(new RegExp("%\d{0}","g"),"%25");return n.replace(new RegExp("%(?!\d)","g"),"%25")}function as(p,q){return q=="*"?true:p.nodeName.toLowerCase().replace("html:", "")==q.toLowerCase()}function o(p,q,r,s,t){var u="";var v=p.firstChild;var w,x,y,z;if(s==null)s=0;if(t==null)t="";while(v){if(v.nodeType==3){z=v.nodeValue.replace("<","&lt;");switch(r){case "lower":u+=z.toLowerCase();break;case "upper":u+=z.toUpperCase();break;default:u+=z}}else if(v.nodeType==1){if(as(v,"a")&&!v.getAttribute("href")==false){if(v.getAttribute("target"))t+="&sifr_url_"+s+"_target="+v.getAttribute("target");t+="&sifr_url_"+s+"="+m(v.getAttribute("href")).replace(/&/g,"%26");u+='<a href="asfunction:_root.launchURL,'+s+'">';s++}else if(as(v,"br"))u+="<br/>";if(v.hasChildNodes()){y=o(v,null,r,s,t);u+=y.u;s=y.s;t=y.t}if(as(v,"a"))u+="</a>"}w=v;v=v.nextSibling;if(q!=null){x=w.parentNode.removeChild(w);q.appendChild(x)}}return{"u":u,"s":s,"t":t}}function A(B){if(al.createElementNS&&f.g)return al.createElementNS(a,B);return al.createElement(B)}function C(D,E,z){var p=A("param");p.setAttribute("name",E);p.setAttribute("value",z);D.appendChild(p)}function F(p,G){var H=p.className;if(H==null)H=G;else H=H.normalize()+(H==""?"":" ")+G;p.className=H}function aq(ar){var a=ak;if(k.bHideBrowserText==false)a=al.getElementsByTagName("body")[0];if((k.bHideBrowserText==false||ar)&&a)if(a.className==null||a.className.match(/\bsIFR\-hasFlash\b/)==null)F(a, "sIFR-hasFlash")}function j(I,J,K,L,M,N,O,P,Q,R,S,r,T){if(!l())return ah.push(arguments);aq();named.extract(arguments,{sSelector:function(ap){I=ap},sFlashSrc:function(ap){J=ap},sColor:function(ap){K=ap},sLinkColor:function(ap){L=ap},sHoverColor:function(ap){M=ap},sBgColor:function(ap){N=ap},nPaddingTop:function(ap){O=ap},nPaddingRight:function(ap){P=ap},nPaddingBottom:function(ap){Q=ap},nPaddingLeft:function(ap){R=ap},sFlashVars:function(ap){S=ap},sCase:function(ap){r=ap},sWmode:function(ap){T=ap}});var U=parseSelector(I);if(U.length==0)return false;if(S!=null)S="&"+S.normalize();else S="";if(K!=null)S+="&textcolor="+K;if(M!=null)S+="&hovercolor="+M;if(M!=null||L!=null)S+="&linkcolor="+(L||K);if(O==null)O=0;if(P==null)P=0;if(Q==null)Q=0;if(R==null)R=0;if(N==null)N="#FFFFFF";if(T=="transparent")if(!f.f)T="opaque";else N="transparent";if(T==null)T="";var p,V,W,X,Y,Z,aa,ab,ac;var ad=null;for(var i=0,h=U.length;i<h;i++){p=U[i];if(p.className!=null&&p.className.match(/\bsIFR\-replaced\b/)!=null)continue;V=p.offsetWidth-R-P;W=p.offsetHeight-O-Q;aa=A("span");aa.className="sIFR-alternate";ac=o(p,aa,r);Z="txt="+m(ac.u).replace(/\+/g,"%2B").replace(/&/g,"%26").replace(/\"/g, "%22").normalize() + S + "&w=" + V + "&h=" + W + ac.t;F(p,"sIFR-replaced");if(ad==null||!f.g){if(!f.g){if(!f.n)p.innerHTML=['<embed class="sIFR-flash" type="application/x-shockwave-flash" src="',J,'" quality="best" wmode="',T,'" bgcolor="',N,'" flashvars="',Z,'" width="',V,'" height="',W,'" sifr="true"></embed>'].join("");else p.innerHTML=['<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" sifr="true" width="',V,'" height="',W,'" class="sIFR-flash"><param name="movie" value="',J,"?",Z,'"></param><param name="quality" value="best"></param><param name="wmode" value="',T,'"></param><param name="bgcolor" value="',N,'"></param> </object>'].join('')}else{if(f.d){ab=A("object");ab.setAttribute("data",J);C(ab,"quality","best");C(ab,"wmode",T);C(ab,"bgcolor",N)}else{ab=A("embed");ab.setAttribute("src",J);ab.setAttribute("quality","best");ab.setAttribute("flashvars",Z);ab.setAttribute("wmode",T);ab.setAttribute("bgcolor",N)}ab.setAttribute("sifr","true");ab.setAttribute("type","application/x-shockwave-flash");ab.className="sIFR-flash";if(!f.l||!f.e)ad=ab.cloneNode(true)}}else ab=ad.cloneNode(true);if(f.g){if(f.d)C(ab,"flashvars",Z);else ab.setAttribute("flashvars",Z);ab.setAttribute("width",V);ab.setAttribute("height",W);ab.style.width=V+"px";ab.style.height=W+"px";p.appendChild(ab)}p.appendChild(aa);if(f.p)p.innerHTML+=""}if(f.n&&k.bFixFragIdBug)setTimeout(function(){al.title=d},0)}function ai(){d=al.title}function ae(){if(k.bIsDisabled==true)return;c=true;if(k.bHideBrowserText)aq(true);if(am.attachEvent)am.attachEvent("onload",af);else if(!f.c&&(al.addEventListener||am.addEventListener)){if(f.a&&f.k>=132&&am.addEventListener)am.addEventListener("load",function(){setTimeout("sIFR({})",1)},false);else{if(al.addEventListener)al.addEventListener("load",af,false);if(am.addEventListener)am.addEventListener("load",af,false)}}else if(typeof am.onload=="function"){var ag=am.onload;am.onload=function(){ag();af()}}else am.onload=af;if(!f.n||am.location.hash=="")k.bFixFragIdBug=false;else ai()}k.UA=at();k.bAutoInit=true;k.bFixFragIdBug=true;k.replaceElement=j;k.updateDocumentTitle=ai;k.appendToClassName=F;k.setup=ae;k.debug=function(){aq(true)};k.debug.replaceNow=function(){ae();k()};k.bIsDisabled=false;k.bHideBrowserText=true;return k}();
if(typeof sIFR == "function" && !sIFR.UA.bIsIEMac){
	sIFR.setup();
	sIFR.replaceElement("h1 .exibir", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#11367d", sWmode: "transparent", sFlashVars:"textalign=center"}));
	sIFR.replaceElement("h1 .titulo", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#11367d", sWmode: "transparent"}));
	sIFR.replaceElement("h1 .form", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#ffffff", sWmode: "transparent"}));
	sIFR.replaceElement("h1 .tituloPaginaExibida", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#ccdfed", sWmode: "transparent", sFlashVars:"textalign=center"}));
	sIFR.replaceElement("h1 .tituloPaginaExibida2", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#ccdfed", sWmode: "transparent"}));
	sIFR.replaceElement("h2 .tituloPaginaExibida", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#254064", sWmode: "transparent"}));
	sIFR.replaceElement("h2 .home1", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#835c07", sWmode: "transparent", sFlashVars:"textalign=center"}));
	sIFR.replaceElement("h3 .home1", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#835c07", sWmode: "transparent", sFlashVars:"textalign=center"}));
	sIFR.replaceElement("h2 .home2", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#446a14", sWmode: "transparent", sFlashVars:"textalign=center"}));
	sIFR.replaceElement("h3 .home2", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#446a14", sWmode: "transparent", sFlashVars:"textalign=center"}));
	
	sIFR.replaceElement("h1 .formaturas", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#7482ad", sWmode: "transparent"}));
	sIFR.replaceElement("h1 .servicos", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#a99530", sWmode: "transparent"}));
	sIFR.replaceElement("h1 .festas-infantis", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#7faa18", sWmode: "transparent"}));
	sIFR.replaceElement("h1 .festas-diversas", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#7faa18", sWmode: "transparent"}));
	sIFR.replaceElement("h1 .eventos-corporativos", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#a99530", sWmode: "transparent"}));
	sIFR.replaceElement("h1 .casamentos", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#a99530", sWmode: "transparent"}));		
	
	sIFR.replaceElement("h1 .servicos1", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#8a6510", sWmode: "transparent"}));
	sIFR.replaceElement("h1 .menu_servicos", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#835c07", sWmode: "transparent"}));
	sIFR.replaceElement("h1 .eventos1", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#446a14", sWmode: "transparent"}));
	sIFR.replaceElement("h1 .eventos2", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#447238", sWmode: "transparent"}));
	sIFR.replaceElement("h1 .artigos1", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#835c07", sWmode: "transparent"}));
	sIFR.replaceElement("h2 .artigos2", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#835c07", sWmode: "transparent"}));
	sIFR.replaceElement("h2 .tituloServicos", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#fffae5", sWmode: "transparent"}));
	sIFR.replaceElement("h2 .procurados1", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#254064", sWmode: "transparent"}));
	sIFR.replaceElement("h1 .imprimir", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#000000", sWmode: "transparent"}));
	sIFR.replaceElement("h2 .login", named({sFlashSrc: root_dir+"imagens/pakenham.swf", sColor: "#ffffff", sWmode: "transparent", sFlashVars:"textalign=center"}));

};

function hideSelect() {
	if (!document.getElementsByTagName){ return; }
	var allfields = document.getElementsByTagName("select");
	var allvalues = new Array();
	for (var i=0; i<allfields.length; i++){
		var field = allfields[i];
		field.style.display = 'none';
	}
}

function showSelect() {
	if (!document.getElementsByTagName){ return; }
	var allfields = document.getElementsByTagName("select");
	var allvalues = new Array();
	for (var i=0; i<allfields.length; i++){
		var field = allfields[i];
		field.style.display = '';
	}
}

function ShowHide(id){
	var obj = document.getElementById('details_'+id);
	var btn = document.getElementById('button_'+id);

	disp = (obj.style.display!='block')?'block':'none';
	dispBtn = (btn.className!='detalhesExibe')?'detalhesExibe':'detalhesEsconde';

	obj.style.display = disp;
	btn.className = dispBtn;
}

function ShowHideServicos(id){
	var obj = document.getElementById('details_'+id);
	disp = (obj.style.display!='block')?'block':'none';
	obj.style.display = disp;

	var button_abre = document.getElementById('button_abre_'+id);
	var button_fecha = document.getElementById('button_fecha_'+id);

	if (disp == 'block') {
		button_abre.style.display = 'none';
		button_fecha.style.display = 'block';
	} else {
		button_abre.style.display = 'block';
		button_fecha.style.display = 'none';
	}

	return false;
}

function EW_ElementHide(id){
	var obj = document.getElementById(id);
	obj.style.display = "none";
	showSelect();
}

function EW_ElementShow(id){
	var obj = document.getElementById(id);
	obj.style.display = "block";
	hideSelect();
}

function MM_findObj(n, d){
	var p, i, x;
	if (!d) {
		d = document;
	}
	if ((p=n.indexOf("?"))>0 && parent.frames.length){
		d = parent.frames[n.substring(p+1)].document;
		n = n.substring(0, p);
	}
	if (!(x=d[n]) && d.all) {
		x = d.all[n];
	}
	for (i=0; !x && i<d.forms.length; i++) {
		x = d.forms[i][n];
	}
	for (i=0; !x && d.layers && i<d.layers.length; i++) {
		x = MM_findObj(n, d.layers[i].document);
	}
	if (!x && document.getElementById) {
		x = document.getElementById(n);
	}
	return x;
}

function tmt_findObj(n) {
	var x, t;
	if ((n.indexOf("?"))>0 && parent.frames.length) {
		t = n.split("?");
		x = eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
	} else {
		x = document.getElementById(n);
	}
	return x;
}

function MM_showHideLayers(){
	var i, p, v, obj, args = MM_showHideLayers.arguments;
	if (navigator.userAgent.indexOf("Opera") == -1) {
		if (document.getElementById) {
			for (i=0; i<(args.length-2); i += 3) {
				obj = tmt_findObj(args[i]);
				v = args[i+2];
				v = (v == 'show') ? 'visible' : (v='hide') ? 'hidden' : v;
				if (obj) {
					obj.style.visibility = v;
				}
			}
		} else {
			for (i=0; i<(args.length-2); i += 3) {
				if ((obj=MM_findObj(args[i])) != null) {
					v = args[i+2];
					if (obj.style) {
						obj = obj.style;
						v = (v == 'show') ? 'visible' : (v='hide') ? 'hidden' : v;
					}
					obj.visibility = v;
				}
			}
		}
	}
}

function jump(id){
	document.location.href = "servicos_detalhes?id="+id;
}

function pagina(pag){
	document.getElementById('pag').value=pag;
	document.getElementById('frm_filtro').submit();
}

function seleciona(master){
    if (document.getElementById('frmLista').itemLista.length == undefined) {
            document.getElementById('frmLista').itemLista.checked=master.checked;
    }
    else {
        for (cont=0; cont<document.getElementById('frmLista').itemLista.length;cont++){
            document.getElementById('frmLista').itemLista[cont].checked=master.checked;
        }
    }
}

function getLista(){
	arr = document.getElementById('frmLista').itemLista
	var lista="(";
	if (arr.length == 0){
        lista = "()";
	} else {
        if (arr.length == undefined) {
            if (arr.checked)
                if (lista=="(")lista=lista+arr.value;
                else lista=lista+','+arr.value;
        }
        else {
            for (cont=0; cont<arr.length;cont++){
                if (arr[cont].checked)
                    if (lista=="(")lista=lista+arr[cont].value;
                    else lista=lista+','+arr[cont].value;
            }
        }
		lista=lista+")";
	}
	return lista;
}

function imprimir(esse,categoria){
	var lista=getLista()
	if (lista == "()"){
		alert("Você deve selecionar os resultados que deseja imprimir!");
		return false;
	}else{
		link=root_dir+"imprimir.php?categoriaID=" + categoria + "&tipodadoID=" + esse + "&ids=" + lista;
		window.open(link,"Imprimir","scrollbars=yes,width=797,height=600,resizable=yes,top=0,left=0");
	}
}
function addFavoritos(tipo){
	var lista = getLista();
	if (lista == "()"){
		alert("Você deve selecionar os resultados que deseja imprimir!");
		return false;
	}else{
		$.get(root_dir+"adiciona_favorito.php?tipo="+tipo+"&ids="+lista,function(data){
			alert(data);
		});
	}

}
function delFavorito(tipo,id){
	var form = document.getElementById("formDel");
	//form.setAttribute("action", "favoritos.php?hId="+id+"&tipo="+tipo);
	$.get('favoritos.php?hId='+id+"&tipo="+tipo, function(data){
		alert(data);
		form.submit();
	});

}
function verFavoritos(tipo){
	document.location.href = "favoritos.php?fTipo="+tipo;
}
function imprimirArtigo(id){
	link=root_dir+"imprimir_artigo.php?artigoID=" + id;
	window.open(link,"Imprimir","width=800,height=600,toolbar=no,scrollbars=yes");

}

function verListaEmail(tipo){
	var lista = getLista();

	if (lista =="()"){
		switch (tipo) {
			case "servico":
				tipo = "serviços";
				break;

			case "evento":
				tipo = "eventos";
				break;
		}

		alert("Você deve selecionar os " + tipo + " que deseja enviar por e-mail!");
		fechaLightBox();

		return false;
	}else{
		return true;
	}
}

function addFavorite(){
	var title = 'Tudos Sobre Eventos';
	var url = 'http://www.tudosobreeventos.com.br';

	/* Mozilla Firefox */
	if(window.sidebar){window.sidebar.addPanel(title, url,"");}

	/* Internet Explorer */
	if(window.external){external.AddFavorite(url,title);}
}

function checkAll(cmp){
	nm = tiraComplemento(cmp.name);
	if ((cmp.checked)&&(cmp.value==0)){rollAll(nm,true);}
	if ((!cmp.checked)&&(cmp.value==0)){rollAll(nm,false);}
	if (cmp.value!=0){
		i=1;j=0;
		while (document.getElementById(nm+'['+i+']')){
			if(document.getElementById(nm+'['+i+']').checked==true){j++;}
			i++;
		}
		document.getElementById(nm+'[0]').checked = false;
		if(j>0){
			document.getElementById('horarioEventoaPartir[0]').disabled = false;
			document.getElementById('horarioEventoAte[0]').disabled = false;
			if(j==7)document.getElementById(nm+'[0]').checked = true;
		}else{
			document.getElementById('horarioEventoaPartir[0]').disabled = true;
			document.getElementById('horarioEventoAte[0]').disabled = true;
		}
		document.getElementById('horarioEventoaPartir['+cmp.value+']').disabled = (cmp.checked)?false:true;
		document.getElementById('horarioEventoAte['+cmp.value+']').disabled = (cmp.checked)?false:true;
	}
}

function rollAll(nm,tp){
	i=0;
	while (document.getElementById(nm+'['+i+']')){
		document.getElementById(nm+'['+i+']').checked = tp;
		document.getElementById('horarioEventoaPartir['+i+']').disabled = (tp)?false:true;
		document.getElementById('horarioEventoAte['+i+']').disabled = (tp)?false:true;
		i++;
	}
}

function reproduzValor(cmp){
	nm = tiraComplemento(cmp.name);
	i=1;
	while (document.getElementById(nm+'['+i+']')){
		document.getElementById(nm+'['+i+']').value = cmp.value;
		i++;
	}
}

function tiraComplemento(str){
	arr = ["[","]",0,1,2,3,4,5,6,7];
	for (i=0;i<arr.length;i++){
		str = str.replace(arr[i],"");
	}
	return str;
}

function envia_email(tipo){
	var lista = getLista();

	if(lista == "()"){
		alert("Você deve selecionar os serviços que deseja enviar por e-mail!");
	}else{
        if (tipo == 1) {
    		document.getElementById('idServicos').value = lista;
        }
        else {
    		document.getElementById('idEventos').value = lista;
        }
		EW_ElementShow('formIndiqueP2');
	}
}

function envia_email_artigo(){
	EW_ElementShow('formIndiqueP2');
	sobeTopo();
}

function ENumero(campo, nome) {
	if (campo && campo.value == "") return(true);
	expr = /[^\d]/;
	if (campo && campo.value.match(expr)) {
		alert("Por favor preencha somente com numeros o campo " + nome + "!");
		return(false);
	}
	return(true);
}

// Verifica campo vazio
function vazio(campo, nome) {
	if (campo && campo.value == "") {
		alert("Por favor preencha o campo " + nome + "!");
		return(false);
	}
	return(true);
}

// Verifica campo igual
function igual(campo, campo2) {
	if (campo.value != campo2.value) {
		alert("Por favor a senha e confirmacao devem ser iguais!");
		return(false);
	}
	return(true);
}

// Verifica select parado
function parado(campo, nome) {
	if (campo && campo.selectedIndex == 0) {
		alert("Por favor selecione o campo " + nome + "!");
		return(false);
	}
	return(true);
}

// valida campo de email
function validaEmail(email, nome) {
	valido = /^.*\@.*\..*$/i;
	if (email && email.value.search(valido) == -1) {
		alert("Prencha corretamente o campo " + nome + "!");
		return(false);
	}
	return(true);
}

// valida data
function validaData(campo, nome) {
   var err = 0
   string = campo.value;
   var valid = "0123456789/"
   var temp;
   for (var i=0; i< string.length; i++) {
     temp = "" + string.substring(i, i+1);
     if (valid.indexOf(temp) == "-1") err = 1;
   }
   if (string.length != 10) err=1
   b = string.substring(3, 5)		// month
   c = string.substring(2, 3)		// '/'
   d = string.substring(0, 2)		// day 
   e = string.substring(5, 6)		// '/'
   f = string.substring(6, 10)	// year
   if (b<1 || b>12) err = 1
   if (c != '/') err = 1
   if (d<1 || d>31) err = 1
   if (e != '/') err = 1
   if (f<1850 || f>2050) err = 1
   if (b==4 || b==6 || b==9 || b==11){
     if (d==31) err=1
   }
   if (b==2){
     var g=parseInt(f/4)
     if (isNaN(g)) {
         err=1 
     }
     if (d>29) err=1
     if (d==29 && ((f/4)!=parseInt(f/4))) err=1
   }
   if (err==1) {
   	alert("Insira uma data correta no campo "+nome);
    return false;
   }
   else {
	return true;
   }
}

//Verifica quantos caracters minimos e maximo o campo pode ter
function validaMaxMinCaracteres(campo, min, max, nome){
	var blnRetorno = true;
	var string = campo.value;
	if( string.length < min ){
		alert("O campo "+nome+" tem que ter no minimo "+min+" caracteres");
		blnRetorno = false;
	} else if( string.length > max ) {
		alert("O campo "+nome+" tem que ter no maximo "+max+" caracteres");
		blnRetorno = false;
	}
	
	return blnRetorno;
}

function verificaFale() {
	if (vazio(document.contato.nome, "Nome"))
	if (vazio(document.contato.email, "E-mail"))
	if (validaEmail(document.contato.email, "E-mail"))
	//if (vazio(document.contato.ddd, "DDD"))
	//if (ENumero(document.contato.ddd, "DDD"))
	//if (vazio(document.contato.telefone, "Telefone"))
	//if (ENumero(document.contato.telefone, "Telefone"))
	//if (vazio(document.contato.cidade, "Cidade"))
	//if (vazio(document.contato.estado, "Estado"))
	if (vazio(document.contato.assunto, "Assunto"))
	if (vazio(document.contato.mensagem, "Mensagem"))
	return true;
	return false;
}

function verificaRecomenda() {
	if (vazio(document.formIndique.nome, "Seu nome"))
	if (vazio(document.formIndique.email, "Seu e-mail"))
	if (validaEmail(document.formIndique.email, "Seu e-mail"))
	if (vazio(document.formIndique.nomeamigo, "Nome do destinatario"))
	if (vazio(document.formIndique.emailamigo, "E-mail do destinatario"))
	if (validaEmail(document.formIndique.emailamigo, "E-mail do destinatario"))
	return true;
	return false;
}

function verificaRecomenda2() {
	if (vazio(document.formIndique2.nome, "Seu nome"))
	if (vazio(document.formIndique2.email, "Seu e-mail"))
	if (validaEmail(document.formIndique2.email, "Seu e-mail"))
	if (vazio(document.formIndique2.nomeamigo, "Nome do destinatario"))
	if (vazio(document.formIndique2.emailamigo, "E-mail do destinatario"))
	if (validaEmail(document.formIndique2.emailamigo, "E-mail do destinatario"))
	return true;
	return false;
}

function verificaLogin() {
	if (vazio(document.frmLogin.login, "Seu E-mail"))
	if (validaEmail(document.frmLogin.login, "Seu E-mail"))
	if (vazio(document.frmLogin.senha, "Sua Senha"))
	return true;
	return false;
}

function verificaCadastro() {
	if (vazio(document.frmCadastro.email, "Seu E-mail"))
	if (validaEmail(document.frmCadastro.email, "Seu E-mail"))
	if (vazio(document.frmCadastro.empresa, "Razao Social"))
	if (vazio(document.frmCadastro.nome, "Nome"))
	if (vazio(document.frmCadastro.telefone, "Telefone"))
	if (ENumero(document.frmCadastro.telefone, "Telefone"))
	if (vazio(document.frmCadastro.ncontribuinte, "CNPJ da Empresa ou seu CPF"))
	if (vazio(document.frmCadastro.morada, "Endereco"))
	return true;
	return false;
}

function verificaSenha() {
	if (vazio(document.frmSenha.senha, "Senha"))
	if (vazio(document.frmSenha.conf, "Confirmacao"))
	if (igual(document.frmSenha.conf, document.frmSenha.senha))
	return true;
	return false;
}

// exclui item e retorna a pagina
function excluir(id, pagina, query) {
	if (confirm("Tem certeza que deseja excluir esse item?")) {
		location.href=pagina + '?' + query + '&excluirID=' + id;
	}
}

function verificaEvento() {
	if (vazio(document.forms[1].nome, "Nome"))
    if (parado(document.forms[1].subfamiliaID, "Categoria"))
	if (vazio(document.forms[1].morada, "Endereco"))
	if (vazio(document.forms[1].descricaoCurta, "Descricao"))
    if (parado(document.forms[1].estadoID, "Estado"))
    if (parado(document.forms[1].cidadeID, "Cidade"))
    if (parado(document.forms[1].zonaID, "Regiao"))
    if (parado(document.forms[1].bairroID, "Bairro"))
	//if (parado(document.forms[1].diaDe, "Dia Inicio"))
	//if (parado(document.forms[1].mesDe, "Mes Inicio"))
	//if (parado(document.forms[1].anoDe, "Ano Inicio"))
	//if (parado(document.forms[1].diaAte, "Dia Fim"))
	//if (parado(document.forms[1].mesAte, "Mes Fim"))
	//if (parado(document.forms[1].anoAte, "Ano Fim"))
    //if (parado(document.forms[1].clienteID, "Cliente"))
	//if (vazio(document.forms[1].local, "Local"))
	//if (vazio(document.forms[1].email, "Email"))
	//if (validaEmail(document.forms[1].email.value, "Email"))
	//if (vazio(document.forms[1].telefone, "Telefone"))
	//if (vazio(document.forms[1].site, "Site"))
	return true;
	return false;
}

function verificaartigo() {
	if (vazio(document.formulario.nome, "Nome"))
    if (parado(document.formulario.subfamiliaID, "Família/Subfamília"))
	return true;
	return false;
}

function verificaServico() {
	if (vazio(document.forms[1].nomeEmpresa, "Nome da Empresa"))
    //if (parado(document.forms[1].subfamiliaID, "Categoria"))
	//if (vazio(document.forms[1].morada, "Endereco"))
	//if (vazio(document.forms[1].descricaoCurta, "Descricao"))
    if (parado(document.forms[1].estadoID, "Estado"))
    if (parado(document.forms[1].cidadeID, "Cidade"))
    //if (parado(document.forms[1].zonaID, "Regiao"))
    //if (parado(document.forms[1].bairroID, "Bairro"))
	//if (parado(document.forms[1].diaDe, "Dia Inicio"))
	//if (parado(document.forms[1].mesDe, "Mes Inicio"))
	//if (parado(document.forms[1].anoDe, "Ano Inicio"))
	//if (parado(document.forms[1].diaAte, "Dia Fim"))
	//if (parado(document.forms[1].mesAte, "Mes Fim"))
	//if (parado(document.forms[1].anoAte, "Ano Fim"))
    //if (parado(document.forms[1].clienteID, "Cliente"))
	//if (vazio(document.forms[1].local, "Local"))
	//if (vazio(document.forms[1].email, "Email"))
	//if (validaEmail(document.forms[1].email.value, "Email"))
	if (vazio(document.forms[1].telefone, "Telefone"))
	//if (vazio(document.forms[1].site, "Site"))
	return true;
	return false;
}

// ir para o TOPO
function sobeTopo(){
	// pega a posicao da barra de rolagem
	var scroll = 0;
	if (window.scrollY)
		scroll = window.scrollY;
	else if (document.documentElement.scrollTop)
		scroll = document.documentElement.scrollTop;
	else
		scroll = document.body.scrollTop;

	if (scroll != 0)
	{
		window.scrollTo(0, scroll - 50);

		setTimeout('sobeTopo()', 4);
	}
}

function verificaCategoria() {
    if (parado(document.forms[1].categoriaID, "Categoria"))
    if (parado(document.forms[1].subfamiliaID, "Subfamilia"))
	return true;
	return false;
}

function adiciona_hit(pagina, tipo, paginaID) {
    imagemNova = new Image();
    imagemNova.src = root_dir+'pixel.php?pagina=' + pagina + '&tipo='+ tipo + '&paginaID=' + paginaID;
    document['pixel_adiciona_hit'].src = imagemNova.src;
}

function verificaBusca() {
	if (vazio(document.formBusca.busca, "Palavra da busca"))
	return true;
	return false;
}
function forgotpass(email) {
    var emailpedido = prompt('Tem certeza que esqueceu sua senha, digite seu email: ', email);
    if (emailpedido) {
    	location.href= 'nova_senha.php?loginPedido=' + emailpedido;
    }
}

function trataAction(){
	action = root_dir + parceiro + 'eventos/' + document.getElementById('categoria').value;
	return action;
}

function busca_cep(tipo){
	var cep = $('input#' + tipo + 'Cep').val();
	$.get('form_cadastro.php?buscarCep=buscarCep&cep=' + cep, function(data){
		eval(data);

		if (resultadoCEP != false)
		{
			$('input#' + tipo + 'Endereco').val( resultadoCEP.tipo_logradouro + ' ' + resultadoCEP.logradouro );
			$('input#' + tipo + 'Bairro').val( resultadoCEP.bairro );
			$('input#' + tipo + 'Cidade').val( resultadoCEP.cidade );
			$('input#' + tipo + 'Estado').val( resultadoCEP.uf );

		}
	});
	return false;
}
// menu SUB-MENU
$(document).ready(function() {
	$('.menu_topo ul li').hover(function(){
		$('ul', this).show();
	}, function(){
		$('ul', this).hide();
	});

	$('#lateral1 ul li').hover(function(e){
		var div = $('div', this);
		e = e.originalEvent;

		if (typeof e.layerY == 'undefined') {
			var layerY = e.y;
		} else {
			var layerY = e.layerY;
		}
		var clientY = e.clientY - layerY;
		var height = $(window).height();
		var tamanho = div.height();

		if (clientY + (tamanho / 2) > height) {
			div.css('top', height - (clientY + tamanho));
		} else if ((tamanho / 2) > clientY) {
			div.css('top', 0 - clientY);
		} else {
			div.css('top', 0 - (tamanho / 2));
		}

		div.show();
		$(this).addClass('selecionado');
	}, function(){
		$('div', this).hide();
		$(this).removeClass('selecionado');
	});
	
	// Arruma altura se for parceiro
	if (eh_parceiro) {
		window.parent.redimensiona_iframe($('#conteudo').outerHeight({ margin: true }));
	}

	$('form#form').jForm({
		txtNome:	$('#txtNome').jField({ name: 'Nome', empty: 'no', minLength: 6 }),
		txtEmail:   $('#txtEmail').jField({ name: 'Email', type:'email',empty: 'no', minLength: 10 }),
		txtSenha:   $('#txtSenha').jField({ name: 'Senha', type: 'password', empty: 'no', minLength: 6 }),
		txtSenhaConfirma:   $('#txtSenhaConfirma').jField({ name: 'Senha', type: 'password_confirmation', empty: 'no', minLength: 6 }),
		txtCep:     $('#txtCep').jField({ name: 'Cep', empty: 'no', minLength: 6 }),
		categoria:  $('select#categoria').jField({ name: 'Tipo de evento', empty: 'no', type: 'select' })
	});

	if ($('form#addPromocao').is('form')) {
		$('form#addPromocao').jForm({
			servicoID:		$('#servicoID').jField({ name: 'Servi&ccedil;o', empty: 'no', type: 'select' }),
			nome:			$('#nome').jField({ name: 'T&iacute;tulo', empty: 'no' }),
			texto_maior:	$('#texto_maior').jField({ name: 'Texto Maior', empty: 'no' }),
			texto_menor:	$('#texto_menor').jField({ name: 'Texto Menor', empty: 'no' }),
			descricao:		$('#descricao').jField({ name: 'Descri&ccedil;&atilde;o / Regulamento', empty: 'no' }),
			dataInicio:		$('#dataInicio').jField({ name: 'In&iacute;cio', empty: 'no', type: 'date' }),
			dataFim:		$('#dataFim').jField({ name: 'Fim', empty: 'no', type: 'date-biggest', condition: '!$("#expira").attr("checked")' })
		});

		function contaCaracteres(objeto, maxLength) {
			objeto.val(objeto.val().substr(0, maxLength));
			objeto.parent().children('em').html('Restam ' + (maxLength - objeto.val().length) + ' caracteres');
		}

		var texto_maior = $('#texto_maior');
		texto_maior.keypress(function() { contaCaracteres(texto_maior, 100); });
		contaCaracteres(texto_maior, 100);

		var texto_menor = $('#texto_menor');
		texto_menor.keypress(function() { contaCaracteres(texto_menor, 150); });
		contaCaracteres(texto_menor, 150);

		var descricao = $('#descricao');
		descricao.keypress(function() { contaCaracteres(descricao, 300); });
		contaCaracteres(descricao, 300);
	}

	$('#txtCep').maskedinput("99999-999");
	$('#txtDataNas').maskedinput("99/99/9999");
	$('#txtTelefone').maskedinput("(99)9999-9999");
	$('#txtDataEvento').maskedinput("99/99/9999");

	//add no bt cep
	$('#buscarCep').click(function(){
		return busca_cep('txt');
	});

	$('#aLogin').click(function() {
		$("#fieldForm").toggle();
		mudaClassLogin();
	});
	$('#aFecha2').click(function(){
		$("#fieldForm").hide();
		$("#esqueciSenha").hide();
		$("#loginUsuario").show();
		mudaClassLogin();
	});
	$('#aEsqueci').click(function(){
		$("#esqueciSenha").show();
		$("#loginUsuario").hide();

	});
	$('#aFecha').click(function() {
		$("#fieldForm").toggle();
		mudaClassLogin();
	});
});

function mudaClassLogin() {
	if ($('#aLogin').attr("class") == "login") {
		$('#aLogin').addClass("login_aberto");
	} else {
		$('#aLogin').removeClass("login_aberto");
		$('#aLogin').removeClass("login");
		$('#aLogin').addClass("login");
	}
}
// preview promocao
function previewPromocao() {
	tb_show('Visualizar Promoção', root_dir + 'adminClienteVisPromocao.php/ajax:true?width=450&height=450', false, function() {
		var html = '<h1>' + $('#texto_maior').val() + '</h1>';
		html += '<h2>' + $('#texto_menor').val() + '</h2>';
		html += '<div class="separador"></div>';
		html += '<p>' + $('#descricao').val() + '</p>';

		if ($("#expira").attr("checked")) {
			html += '<p>Validade: ' + $('#dataInicio').val() + '</p>';
		} else {
			html += '<p>Validade: ' + $('#dataInicio').val() + ' &agrave; ' + $('#dataFim').val() + '</p>';
		}

		$('#interno').prepend(html);
	});
	this.blur();
}
// preview promocao front
function previewPromocaoFront(promocaoID) {
	tb_show('Visualizar Promoção', root_dir + 'popPromocao.php?promocaoID=' + promocaoID + '&/ajax:true?width=500&height=500');
}

// preview promocao front
function previewOrcamentoFront(orcamentoID) {
	tb_show('Visualizar Orçamento', root_dir + 'popOrcamento.php?orcamentoID=' + orcamentoID + '&/ajax:true?width=450&height=600');
}

//Mascara no Orçamento
function mascaraOrcamento() {
	$('#txtDataEvento').maskedinput("99/99/9999");
	$('#txtTelefone').maskedinput("(99) 9999-9999");
}

//Valida o orçamento
function verificaOrcamento(){
	if (vazio(document.orcamento.txtNome, "Nome"))
	if (validaEmail(document.orcamento.txtEmail, "E-mail"))
	if (parado(document.orcamento.slEvento, "Tipo de Evento"))
	if (validaData(document.orcamento.txtDataEvento, "Data do Evento"))
	if (validaMaxMinCaracteres(document.orcamento.txtDetalhe, 10, 3000, "Detalhes do Orçamento"))
	return true;
	return false;
}

//Mensagem para logar
function AvisoLogar(local){
	var msg = 'Para solicitar um orçamento e ter acesso a promoções exclusivas é necessário cadastrar-se em nosso site.';
	msg += ' Cadastre-se agora mesmo <a href="' + root_dir + 'form_cadastro.php" title="Clique aqui para se cadastrar">clicando aqui</a>. Se já for cadastrado, por favor, <a href="javascript:;IndicaLogin();" title="Faça o login">faça o login</a>.';
	
	jFormError($('#'+local), msg);
}

//Indica a usuario onde deve ser o login
function IndicaLogin(){
	sobeTopo();
	if ($('#aLogin').attr("class") == "login") {
		$('#aLogin').click();
	}
}

/* nao deixa os fundos piscarem no IE */
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}