/* TRACER */
traceEnabled = false;
trace = function(a) {
	if (traceEnabled) {
		$('tracer').style.display = 'block';
		$('tracer').innerHTML += a.toString()+'<br />';
		$('tracer').scrollTop = 100000;
	}
};
clearTrace = function () {
	if (traceEnabled) {
		$('tracer').innerHTML = '';
		$('tracer').scrollTop = 100000;
		$('tracer').style.display = 'none';
	}
};
/* Funções diversas */
var isIE =(/\bmsie\b/i.test(navigator.userAgent)&& document.all&&!(/\bopera\b/i.test(navigator.userAgent)));
$ = function (a) {
	return document.getElementById(a);
};
var lastError = null;
onerror = function(e,f,l) {
	xml = new xmlConnection();
	var FV = deconcept.SWFObjectUtil.getPlayerVersion();
	var strFV = FV.major+'.'+FV.minor+'.'+FV.rev;
	if (xml.create()) {
		xml.setMethod('POST');
		xml.setURL('errorReportingXML.php');
		xml.add('erro',e);
		xml.add('arquivo',f);
		xml.add('linha',l);
		xml.add('XML',XMLVersion);
		xml.add('flash',strFV);
		xml.add('time',new Date());
		xml.onComplete = function() {
			trace('Erro reportado');
		};
		xml.execute();
	}
	//return true;
	trace('ERRO:');
	trace('Descri&ccedil;&atilde;o: '+e);
	trace('Arquivo: '+f);
	trace('Linha: '+l);
	return true;
};
error = function(e) {
	lastError = e;
	trace('ERRO:');
	if (e.description) trace('Descri&ccedil;&atilde;o: '+e.description);
	if (e.message) trace('Mensagem: '+e.message);
	if (e.name) trace('Tipo: '+e.name);
	if (e.fileName) trace('Arquivo: '+e.fileName);
	if (e.lineNumber) trace('Linha: '+e.lineNumber);
	if (e.number) trace('N&uacute;mero: '+e.number);
	if (e.stack) {
		var err = '<table cellspacing="1" cellpadding="1" border="1" align="center"><tr><th>Arquivo:</th><th>Linha:</th><th>Par&acirc;metro:</th></tr>';
		var arr = e.stack.split('\n');
		for (var i = 0; i < arr.length-2; i++) {
			var arquivo = arr[i].split('@')[1].replace('http://','@#$').split(':')[0].replace('@#$','http://');
			var linha = arr[i].split('@')[1].replace('http://','@#$').split(':')[1];
			var parametros = arr[i].split('@')[0];
			err += '<tr><td>'+arquivo+'</td><td>'+linha+'</td><td>'+parametros+'</td></tr>';
		}
		err += '</table>';
		trace('Caminho: '+err);
	}
};
radio = function(object) {
	if(typeof object == 'object'){
		strChek = object.name;
	}else{
		strChek = object;
	}
	obj = document.getElementsByTagName('input');
	for (var i = 0; i< obj.length; i++){
	    if (obj[i].type == 'radio' && obj[i].name == strChek  && obj[i].checked){
			return obj[i].value;
		}
	}
	return null
}
/* Máscara */
filter2 = function(txtEntrada, strValidos) {
	var txtSaida = '';
	for (var a = 0; a<txtEntrada.length; a++) {
		if (strValidos.indexOf(txtEntrada.substr(a, 1)) != -1) {
			txtSaida = txtSaida+txtEntrada.substr(a, 1);
		}
	}
	return txtSaida;
};
mask = function(strMask, ev, objData) {
	ev = ev || event;
	var key = getKey(ev);
	if (isNum(key, '%\'#$.') == true) return true;
	if (!(key>=37 && key<=40)) {
		var valor = filter2(objData.value, '0123456789');
		var tam = valor.length;
		var tamMask = strMask.length;
		var strOut = '';
		var intCont = 0;
		for (var a = 0; a<tamMask && intCont<=tam; a++) if (strMask.substr(a, 1) == '#') strOut += valor.substr(intCont++, 1); else strOut += strMask.substr(a, 1);
		objData.value = strOut;
		return true;
	}
};
isNum = function(code, strValidos) {
	var strCode = String.fromCharCode(code);
	strValidos = strValidos || '%\'#$.0123456789`abcdefghi	';
	return (strValidos.indexOf(strCode)>=0);
};

/* Prorotypes */
String.prototype.format = function(casas) {
	var ret = new String('');
	while (ret.length < (casas-this.toString().length)) ret += '0';
	return ret+this;
};
Date.prototype.getString = function() {
	return this.getDate().toString().format(2)+'/'+(this.getMonth()+1).toString().format(2)+'/'+this.getFullYear();
};
String.prototype.isDate = function() {
	try {
		var arrData = new Array();
		arrData = this.split('/');
		var dia = arrData[0];
		var mes = arrData[1]-1;
		var ano = arrData[2];
		var dataEntrada = (arrData[0]*1)+'/'+(arrData[1]*1)+'/'+arrData[2];
		var minhaData = new Date(ano, mes, dia);
		var dataRetorno = minhaData.getDate()+'/'+(minhaData.getMonth()+1)+'/'+minhaData.getFullYear();
		return (dataEntrada == dataRetorno);
	} catch (e) {
		return false;
	}
};
String.prototype.isMail = function() {
	var ER = new RegExp(/^[A-Za-z0-9]+(([\.\_\-]{1}[A-Za-z0-9]+)+)?@[A-Za-z0-9]+(([\.\_\-]{1}[A-Za-z0-9]+)+)?\.[A-Za-z]{2,4}$/);
	return (ER.test(this));
};
String.prototype.isCPF = function() {
	var cpf = filter2(this,'0123456789');
	var rrValida = new Array(00000000000,11111111111,2222222222,3333333333,44444444444,5555555555,6666666666,7777777777,8888888888,9999999999);
	for (i=0;i<11;i++) if (cpf == rrValida[i]) return null;
	var i;
	var c = cpf.substr(0,9);
	var dv = cpf.substr(9,2);
	var d1 = 0;   
	for (i = 0; i < 9; i++) d1 += c.charAt(i)*(10-i);
	if (d1 == 0) return null;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1) return null;
	d1 *= 2;
	for (i = 0; i < 9; i++) d1 += c.charAt(i)*(11-i);
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1) return null;
	return true;
};
if (traceEnabled) document.write('<div ondblclick="clearTrace();" style="position:absolute;top:50px;left:50px;width:900px;height:150px;border:solid 1px black;background-color:white;overflow:auto;padding:3px;display:none;z-index:1000;font:normal 14px Courier;" id="tracer"></div>');

// Marca um campo
mark = function(e) {
	if (typeof e == 'string') e = $(e);
	e.checked = true;
};
// Retorna um Ponto
_point = function (_x, _y) {
	_x = _x || 0;
	_y = _y || 0;
	return {x:_x, y:_y};
};
// Aplica um valor alpha de 0 a 100
setAlpha = function (e, a) {
	a = Math.round(a);
	if (typeof e == 'string') e = $(e);
	with (e.style) {
		if (isIE) {
			filter = 'alpha(opacity='+a+')';
		} else {
			opacity = a/100;
		}
	}
};
// Aplica a posição x e y a um objeto
setPosition = function (obj, x, y) {
	with (obj.style) {
		top = x+'px';
		left = y+'px';
	}
};
// Retorna a posição de um objeto
getPos = function (e) {
	if (typeof e == 'string') e = $(e);
	var left = 0;
	var top = 0;
	while (e.offsetParent) {
		left += e.offsetLeft;
		top += e.offsetTop;
		e = e.offsetParent;
	}
	left += e.offsetLeft;
	top += e.offsetTop;
	return {x:left, y:top};
};
// Retorna o tamanho de um objeto
getSize = function (e) {
	if (typeof e == 'string') e = $(e);
	return {x:e.offsetWidth, y:e.offsetHeight};
};
// Retorna o tamanho total do documento
getDocSize = function () {
	return {x:document.body.offsetWidth, y:document.body.offsetHeight};
};
// Retorna o tamanho da área visivel
getDocVisibleSize = function () {
	var _x, _y;
	if (window.innerWidth) {
		_x = window.innerWidth;
	} else if (document.documentElement && document.documentElement.clientWidth) {
		_x = document.documentElement.clientWidth;
	} else if (document.body) {
		_x = document.body.clientWidth;
	}
	if (window.innerHeight) {
		_y = window.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		_y = document.documentElement.clientHeight;
	} else if (document.body) {
		_y = document.body.clientHeight;
	}
	return {x:_x, y:_y};
};
// Retorna caracter pressionado em um evento do teclado
getKey = function (e) {
	try {
		return event ? (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode)) : null;
	} catch (f) {
		return e.keyCode;
	}
};
// Retorna o scroll da página
getScroll = function () {
	if (self.pageXOffset) {
		sX = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollLeft) {
		sX = document.documentElement.scrollLeft;
	} else if (document.body) {
		sX = document.body.scrollLeft;
	}
	if (self.pageYOffset) {
		sY = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {
		sY = document.documentElement.scrollTop;
	} else if (document.body) {
		sY = document.body.scrollTop;
	}
	return {x:sX, y:sY};
};
// Retorna a posição do mouse no documento
getMousePos = function (ev) {
	if (ev.pageX || ev.pageY) return {x:ev.pageX, y:ev.pageY};
	var SC = getScroll();
	return {x:ev.clientX+SC.x-document.body.clientLeft, y:ev.clientY+SC.y-document.body.clientTop};
};
// Retorna um SWF como objeto
$_ = getFlashObject = getFlash = function(n) {
	if (navigator.appName.indexOf("Microsoft")!=-1) return window[n]; else return document[n];
};
// Mostra um div na tela
mostraDIV = function (e) {
	if (typeof e == 'string') e = $(e);
	e.style.display = 'block';
};
// Oculta um div da tela
ocultaDIV = function (e) {
	if (typeof e == 'string') e = $(e);
	e.style.display = 'none';
};
// Faz um preloader de imagem
imgPreLoad = function (img, fn, a) {
	fn = fn || function () {};
	a = a || null;
	var i = new Image();
	i.onload = function() {
		fn(true, this.src, a);
	};
	i.onerror = function() {
		fn(null);
	};
	i.src = img;
};
// Faz preloader de várias imagens recursivamente
var LI = {
	'arr': [],
	'pos': 0,
	'_load': function(i) {
		var thisObj = this;
		this.pos = i;
		if (i<this.arr.length) {
			abc = i;
			if (typeof this.arr[i] == 'function') {
				this.arr[i]();
				setTimeout('LI._load(LI.pos+1);',50);
			} else {
				var img = new Image();
				img.onload = img.onerror = function() {
					setTimeout('LI._load(LI.pos+1);',50);
				};
				img.src = this.arr[i];
			}
		}
	},
	
	'load': function() {
		this.arr = arguments;
		this._load(0);
	}
};
/* Array de HTML's */
arrHTML = [];
arrHTML[0] = 'Digite o nome ou especialidade';
arrHTML[1] = '<table border="0" cellpadding="0" cellspacing="0"><tr><td style="height:240px;vertical-align:middle;text-align:center;width:170px;"><img alt="" src="imagens/loading.gif" /><br />Carregando...</td></tr></table>';
arrHTML[2] = arrHTML[1];
arrHTML[3] = '<img alt="" src="imagens/loading.gif" /><br />Carregando...';
arrHTML[4] = '<img alt="" src="imagens/loading.gif" />';
/* Funções da página */
// Sistema de busca
var arrBusca = ['buscaProfdeSaude', 'buscaClinicas', 'buscaPacientes'];
var btBuscaAtivo = 0;
var topSetaBusca = 138;
var tipoBusca = 1;
var btBuscaAtual = 'buscaProfdeSaude';
loadSiteImages = function (fn) {
	fn = fn || function () {};
	LI.load('imagens/buscaProfdeSaudeAtivo.gif', 'imagens/buscaClinicasAtivo.gif', 'imagens/buscaPacientesAtivo.gif', 'imagens/buscaProfdeSaudeInativo.gif', 'imagens/buscaClinicasInativo.gif', 'imagens/buscaPacientesInativo.gif', 'imagens/alertaTopo.png', 'imagens/alertaMeioEsquerda.png', 'imagens/alertaMeioDireita.png', 'imagens/alertaRodape.png', 'imagens/abaDentistaMedico.gif', fn);
};
trocaBotao = function (bt) {
	btBuscaAtual = bt;
	
	if(bt == "buscaProfdeSaude"){
		arrHTML[0] = 'Digite o nome ou especialidade';
	}else{
		arrHTML[0] = 'Digite o nome';
	}
	$('campoBusca').value = "";
	
	for (var i = 0; i<arrBusca.length; i++) {
		if (arrBusca[i] == bt) {
			$(arrBusca[i]).src = 'imagens/'+arrBusca[i]+'Ativo.gif';
			btBuscaAtivo = i;
		} else {
			$(arrBusca[i]).src = 'imagens/'+arrBusca[i]+'Inativo.gif';
		}
	}
	var newLeft = getPos(bt).x+((getSize(bt).x-13)/2);
	$('setaBusca').stopTween();
	$('setaBusca').tweenTo(topSetaBusca, newLeft, 'easeoutelastic', 0.6);
	focusTo('campoBusca');
};
validaBusca = function () {
	if ($('campoBusca').value.length<3 || $('campoBusca').value == arrHTML[0]) {
		SA.onClose = function(e) {
			$('campoBusca').select();
		};
		SA.open('Digite 3 ou mais caracteres para buscar!');
		return;
	}
	if (btBuscaAtual == 'buscaProfdeSaude') location = 'busca.php?t='+btBuscaAtivo+'&q='+$('campoBusca').value;
	else if (btBuscaAtual == 'buscaPacientes') location = 'buscapaciente.php?t='+btBuscaAtivo+'&q='+$('campoBusca').value;
	else location = 'buscaclinica.php?t='+btBuscaAtivo+'&q='+$('campoBusca').value;
};
posicionaFundoBranco = function () {
	
};
// Patrocinadores
inicializarPatrocinadores = function () {
	return;
	try {
		$('patrocionadoresTD').innerHTML = '';
		var xml = new xmlConnection();
		with (xml) {
			if (create()) {
				setURL('patrocinadoresXML.php');
				add('nocache', nocache(4));
				onComplete = function () {
					setChildName('p');
					numVideoAtual = 0;
					var html = '';
					for (var i = 0; i<getCountItens(); i++) {
						if (i != 0) html += '<br />';
						html += '<a href="'+getAttByName('link', i)+'"><img alt="'+getAttByName('tit', i)+'" src="'+getAttByName('img', i)+'" style="margin:10px;" /></a>';
					}
					$('patrocionadoresTD').innerHTML = html;
				};
				execute();
			}
		}
	} catch (e) {
		alert((isIE) ? e.description : e);
	}
};
// Publicidade
page = 'index';
inicializarPublicidade = function () {
	return;
	try {
		var xml = new xmlConnection();
		with (xml) {
			if (create()) {
				setURL('bannersXML.php');
				add('nocache', nocache(4));
				add('page', page);
				onComplete = function () {
					setChildName('b');
					numVideoAtual = 0;
					for (var i = 0; i<getCountItens(); i++) {
						var img = getAttByName('img', i);
						var local = getAttByName('local', i);
						if (!$(local)) continue;
						new imgPreLoad(img, function (e, _img, a) {
							if (e) {
								$(a).innerHTML = '<img onmouseover="playMoldura(this);" alt="" src="'+_img+'" />';
							} else {
								$(a).innerHTML = 'Imagem n&atilde;o disponível!';
							}
						}, local);
					}
				};
				execute();
			}
		}
	} catch (e) {
		alert((isIE) ? e.description : e);
	}
};

// Outros
setAllEvents = function () {
	// Eventos do campo busca
	$('campoBusca').onfocus = function() {
		if (this.value == arrHTML[0]) {
			this.value = '';
		}
	};
	$('campoBusca').onblur = function() {
		if (this.value == '') {
			this.value = arrHTML[0];
		}
	};
	$('campoBusca').onkeydown = function(e) {
		e = e || event;
		var key = getKey(e);
		if (key == 13) validaBusca();
	};
	$('campoBusca').value = arrHTML[0];
	new tween('verImagemTb');
	// Seta os eventos privados da página
	setPageEvents();
	try{
		if(jsBtComunidade != ""){
			trocaBotao(jsBtComunidade);
		}
	}catch(e){}
	if(abreContato == 1){
		enviarContato.show();	
	}
};

// Ver imagem
var imagemAberta = false;
var imagemSizeX, imagemSizeY;
verImagem = function(file) {
	bgSite.show();
	var maxX = 640;
	var maxY = 480;
	var imgLoader = new Image();
	imgLoader.onload = function() {
		var newX = imgLoader.width;
		var newY = imgLoader.height;
		if (newX > maxX) {
			newY = newY*maxX/newX;
			newX = maxX;
		}
		if (newY > maxY) {
			newX = newX*maxY/newY;
			newY = maxY;
		}
		$('verImagemTb').style.display = 'block';
		imagemSizeX = newX+40;
		imagemSizeY = newY+60;
		$('verImagemTb').style.width = imagemSizeX+'px';
		$('verImagemTb').style.height = imagemSizeY+'px';
		$('verImagemImg').width = newX;
		$('verImagemImg').height = newY;
		$('verImagemImg').src = imgLoader.src;
		imagemAberta = true;
		refreshImagem();
	};
	imgLoader.onerror = function() {
		bgSite.hide();
		imagemAberta = false;
		SA.show('Imagem n&atilde;o encontrada!');
	};
	imgLoader.src = file;
};

fecharImagem = function() {
	$('verImagemTb').style.display = 'none';
	bgSite.hide();
};

refreshImagem = function(tween) {
	tween = tween || false;
	if (imagemAberta) {
		var SC = getScroll();
		var VS = getDocVisibleSize();
		var SZ = new _point(imagemSizeX, imagemSizeY);
		newX = (VS.x-SZ.x)/2;
		newY = (VS.y-SZ.y)/2;
		if (tween) {
			$('verImagemTb').tweenTo((newY+SC.y), (newX+SC.x), 'easeoutexpo', 0.3);
		} else {
			$('verImagemTb').style.left = newX+SC.x+'px';
			$('verImagemTb').style.top = newY+SC.y+'px';
		}
	}
};

/* Moldura da imagem */
var imgAtual = null;
var ptInicio = new _point();
var ptFinal = new _point();
var molduraAtiva = null;
playMoldura = function (o) {
	if (imgAtual != o && molduraAtiva) {
		imgAtual = o;
		var p = getPos(o);
		var s = getSize(o);
		setAlpha('molduraImagem', 10);
		s.x++;
		ptInicio = p;
		ptFinal.x = p.x+s.x;
		ptFinal.y = p.y+s.y;
		with ($('molduraImagem').style) {
			top = p.y+'px';
			left = p.x+'px';
			height = s.y+'px';
			width = s.x+'px';
			display = 'block';
		}
		$('molduraImagem').alphaTo(10, 30, 'linear', 0.2);
	}
};
stopMoldura = function (e) {
	var m = getMousePos(e);
	if (m.x<ptInicio.x || m.y<ptInicio.y || m.x>ptFinal.x || m.y>ptFinal.y) {
		$('molduraImagem').stopAlpha();
		setAlpha('molduraImagem', 0);
		with ($('molduraImagem').style) {
			top = '0px';
			left = '0px';
			display = 'none';
		}
		imgAtual = null;
		ptInicio = new _point();
		ptFinal = new _point();
	}
};
clickMoldura = function () {
	if (imgAtual) if (imgAtual.onclick) imgAtual.onclick();
};
/* Preloader das imagens */
functionLoader = function() {};
var posImgPL = -1;
loadNextImage = function () {
	if (++posImgPL<arrImgPL.length) {
		var arrSplit = arrImgPL[posImgPL].split('|');
		new imgPreLoad(arrSplit[1], function (e, _img, a) {
			if (e) {
				new alpha(a);
				setAlpha(a, 0);
				$(a).src = _img;
				$(a).alphaTo(0, 100, 'linear', 0.15, function () {
					loadNextImage();
				});
			} else {
				loadNextImage();
			}
		}, arrSplit[0]);
	} else {
		functionLoader();
	}
};
/* Evento window.onstopscroll */
window.intervalstopscroll = null;
window.onscroll = function() {
	clearTimeout(window.intervalstopscroll);
	window.intervalstopscroll = setTimeout('window.onstopscroll();window.onstopscroll2();', 50);
};
window.onstopscroll2 = function() {
	Indiq.alinha();
	browserEm.alinha();
	SOC.alinha();
	enviarOpiniao.alinha();
};
/* Fundo azul do site */
var bgSite = {
	'show': function() {
		setAlpha('bgSite', 60);
		$('bgSite').style.height = getDocSize().y+13+'px';
		$('bgSite').style.display = 'block';
		var obj = document.getElementsByTagName('SELECT');
		for (var i = 0; i < obj.length; i++) {
			if (obj[i].className != 'campoEditor') obj[i].style.display = "none";
		}
	},
	'hide': function() {
		$('bgSite').style.display = 'none';
		var obj = document.getElementsByTagName('SELECT');
		for (var i = 0; i < obj.length; i++) obj[i].style.display = "block";
	},
	'alinha': function(){
		$('bgSite').style.width = getDocSize().x+'px';
		$('bgSite').style.height = getDocSize().y+13+'px';
	}
};
/* Flash Sound Player */
var FS = {
	'active': true,
	'created': false,
	'enable': false,
	'enabled': function() {
		this.enable = true;
	},
	'create': function(){
		if (this.created == false) {
			$('SWFLoader').innerHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http:/'+'/download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,22,0" id="flahSound" width="0" height="0"><param name="movie" value="som.swf" /><param name="wmode" value="transparent" /><param name="allowscriptaccess" value="always" /><embed type="application/x-shockwave-flash" pluginspage="http:/'+'/www.macromedia.com/go/getflashplayer" name="flahSound" width="0" height="0" src="som.swf" bgcolor="#FFFFFF" swliveconnect="true" allowscriptaccess="always"></embed></object>';
			this.created = true;
		}
	},
	'play': function(som) {
		if (this.enable == true && this.active == true) getFlashObject('flahSound')._play(som);
	}
};
/* Simple Alert */
var SA = {
	'created': 0,
	'opened': 0,
	'size': null,
	'docSize': null,
	'scroll': null,
	'shakeEnabled': false,
	'open': function(txt, tipo) {
		this.create();
		tipo = tipo || 1;
		if (tipo == 1) {
			$('SAButtons').innerHTML = '<img src="imagens/alertaOK.gif" alt="" onclick="SA.click(\'OK\');" style="cursor:pointer;" />';
		} else {
			$('SAButtons').innerHTML = '<img src="imagens/alertaSim.gif" alt="" onclick="SA.click(\'YES\');" style="cursor:pointer;" /><img src="imagens/alertaNao.gif" alt="" onclick="SA.click(\'NO\');" style="cursor:pointer;" />';
		}
		$('SAText').innerHTML = txt;
		if (this.opened == 0) {
			FS.play('alert');
			shakeEnabled=false;
			this.reset();
			$('SA').style.top = (this.scroll.y-this.size.y)+'px';
			$('block').style.height = getDocSize().y+13+'px';
			$('block').style.display = 'block';
			var x = (this.docSize.x-this.size.x)/2+this.scroll.x;
			var y = (this.docSize.y-this.size.y)/2+this.scroll.y;
			$('SA').tweenTo(y,x,'easeoutexpo',0.35,function(){shakeEnabled=true;});
			this.opened = 1;
		} else {
			this.refresh(true);
			this.shake();
		}
	},
	'close': function() {
		if (this.opened == 1) {
			this.opened = 0;
			shakeEnabled=false;
			var x = (this.docSize.x-this.size.x)/2;
			//var y = this.docSize.y+this.size.y+this.scroll.y;
			var y = this.docSize.y+this.scroll.y;
			$('SA').tweenTo(y,x,'easeinexpo',0.35,function(){SA.reset();SA.onClose();});
			$('block').style.display = 'none';
		}
	},
	'reset': function() {
		this.size = getSize('SA');
		this.docSize = getDocVisibleSize();
		this.scroll = getScroll();
		var x = (this.docSize.x-this.size.x)/2;
		var y = (this.size.y)*(-1);
		if (this.opened == 0) {
			$('SA').style.top = y+'px';
			$('SA').style.left = x+'px';
		}
	},
	'refresh': function(type) {
		type = type || false;
		if (this.opened == 1) {
			shakeEnabled=false;
			this.size = getSize('SA');
			this.docSize = getDocVisibleSize();
			this.scroll = getScroll();
			var x = (this.docSize.x-this.size.x)/2+this.scroll.x;
			var y = (this.docSize.y-this.size.y)/2+this.scroll.y;
			if (type == false) {
				$('SA').tweenTo(y,x,'easeoutexpo',0.25,function(){shakeEnabled=true;});
			} else {
				setPosition($('SA'),y,x);
			}
		}
	},
	'create': function() {
		if (this.created == 0) {
			new tween('SA');
			new shake('SA');
			$('SA').className = 'SA';
			this.created = 1;
		}
	},
	'shake': function() {
		if (this.opened == 1 && shakeEnabled == true) {
			FS.play('nudge');
			shakeEnabled = false;
			$('SA').shakeNow(0.5,function(){shakeEnabled=true;});
		}
	},
	'click': function(a) {
		this.close();
		this.onClick(a);
	},
	'onClose': function(){},
	'onClick': function(){}
};
/* AJAX */
var requisicoes = new Number(0);
var XMLVersion = '';
xmlConnection = function () {
	var strNav = new String('');
	var objAjax = null;
	var strMethod = new String('');
	strMethod = 'POST';
	var strParams = new String('');
	var strURL = new String('');
	var strChildName = new String('');
	var arrParamName = new Array();
	var arrParamValue = new Array();
	var numTotalParams = new Number(0);
	var xmlReturn = null;
	var textReturn = new String('');
	var thisObj = this;
	this.onComplete = function() {
	};
	this.onLoad = function() {
	};
	this.onStateChange = function() {
	};
	this.onError = function() {
		trace('Erro ao ler o xml!');
	};
	this.add = function() {
		arrParamName[numTotalParams] = arguments[0];
		arrParamValue[numTotalParams] = arguments[1];
		numTotalParams++;
	};
	this.emptyParameters = function() {
		numTotalParams = new Number(0);
		arrParamName = new Array();
		arrParamValue = new Array();
	};
	this.setURL = function() {
		strURL = arguments[0];
	};
	this.setMethod = function() {
		if ((arguments[0].toUpperCase() == 'POST') || (arguments[0].toUpperCase() == 'GET')) {
			strMethod = arguments[0].toUpperCase();
		}
	};
	this.setChildName = function() {
		strChildName = arguments[0];
	};
	this.getStatus = function() {
		return objAjax.statusText;
	};
	this.getXML = function() {
		return xmlReturn;
	};
	this.getText = function() {
		return textReturn;
	};
	this.getCountItens = function() {
		return xmlReturn.getElementsByTagName(strChildName).length;
	};
	this.getAttByName = function() {
		try {
			return xmlReturn.getElementsByTagName(strChildName)[arguments[1]].getAttribute(arguments[0]);
		} catch (e) {
			return null;
		}
	};
	this.getDataByName = function() {
		try {
			return xmlReturn.getElementsByTagName(strChildName)[arguments[0]].firstChild.data;
		} catch (e) {
			return null;
		}
	};
	this.execute = function() {
		if (requisicoes++ == 0) {
			//
		}
		strParams = '';
		for (var i = 0; i<arrParamName.length; i++) {
			if (i>0) {
				strParams += '&';
			}
			strParams += arrParamName[i]+'='+encodeURIComponent(arrParamValue[i]);
		}
		if (strMethod == 'GET') {
			objAjax.open(strMethod, strURL+'?'+strParams, true);
		} else {
			objAjax.open(strMethod, strURL, true);
		}
		with (objAjax) {
			setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			setRequestHeader("CharSet", "UTF-8");
			setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
			setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
			setRequestHeader("Pragma", "no-cache");
			onreadystatechange = function () {
				thisObj.onStateChange(objAjax.readyState);
				if (objAjax.readyState == 4) {
					thisObj.onLoad(objAjax.status);
					if (objAjax.status == 200) {
						xmlReturn = objAjax.responseXML;
						textReturn = objAjax.responseText;
						thisObj.onComplete();
					} else {
						thisObj.onError(objAjax.status, objAjax.statusText);
					}
					if (--requisicoes == 0) {
						//
					}
				}
			};
			if (strMethod == 'GET') {
				send(null);
			} else {
				send(strParams);
			}
		}
	};
	this.create = function() {
		if (window.ActiveXObject) {
			strNav = 'ie';
			if (XMLVersion == '') {
				var AXO = ['Msxml2.XMLHTTP.8.0','Msxml2.XMLHTTP.7.0','Msxml2.XMLHTTP.6.0','Msxml2.XMLHTTP.5.0','Msxml2.XMLHTTP.4.0','Msxml2.XMLHTTP.3.0','Msxml2.XMLHTTP.2.0','Msxml2.XMLHTTP','Microsoft.XMLHTTP'];
				for (var i = 0; i < AXO.length; i++) {
					try {
						objAjax = new ActiveXObject(AXO[i]);
						XMLVersion = AXO[i];
						break;
					} catch (e) {
						continue;
					}
					if (i >= (AXO.length-1)) {
						objAjax = null;
						return;
					}
				};
			} else {
				try {
					objAjax = new ActiveXObject(XMLVersion);
				} catch (e) {
					objAjax = null;
					return;
				}
			}
		} else if (window.XMLHttpRequest) {
			XMLVersion = 'XMLHttpRequest';
			objAjax = new XMLHttpRequest();
			strNav = 'ff';
		} else {
			objAjax = null;
			return;
		}
		return true;
	};
};
/* Função para carregar itens em objetos do tipo select */
selectLoader = function () {
	var xml = new xmlConnection();
	var thisObj = this;
	this.onLoad = function() {
	};
	this.firstItem = true;
	this.load = function(strObj, strList, strValue, cache) {
		cache = cache || false;
		if (xml.create()) {
			xml.setURL(strList);
			xml.setMethod('GET');
			if (cache != false) {
				xml.add('nocache', nocache());
			}
			xml.onComplete = function() {
				this.setChildName('item');
				$(strObj).innerHTML = '';
				if (this.getCountItens()>1) {
					var linha;
					if (this.firstItem == true) {
						linha = document.createElement("OPTION");
						$(strObj).appendChild(linha);
						linha.value = '';
						linha.text = 'Selecione...';
						linha.style.color = '#999999';
					}
					var index = 0;
					for (var j = 0; j<this.getCountItens(); j++) {
						linha = document.createElement("OPTION");
						$(strObj).appendChild(linha);
						linha.value = this.getAttByName('id', j);
						linha.text = this.getAttByName('nome', j);
						if (strValue) {
							if (linha.value == strValue) {
								linha.selected = true;
								if (this.firstItem == true) {
									index = (j+1);
								} else {
									index = j;
								}
							}
						}
					}
					$(strObj).selectedIndex = index;
					$(strObj).disabled = false;
				} else if (this.getCountItens() == 1) {
					linha = document.createElement("OPTION");
					$(strObj).appendChild(linha);
					linha.value = this.getAttByName('id', 0);
					linha.text = this.getAttByName('nome', 0);
					linha.selected = true;
					$(strObj).disabled = true;
				} else {
					linha = document.createElement("OPTION");
					$(strObj).appendChild(linha);
					linha.value = '';
					linha.text = 'Sem dados';
					linha.selected = true;
					$(strObj).disabled = true;
				}
				thisObj.onLoad(($(strObj).disabled) ? false : true);
			};
			xml.execute();
		}
	};
};
/* Tween */
tween = function () {
	var obj = $(arguments[0]);
	obj.numStepTween = (isIE) ? 10 : 10;
	obj.thisIntervalTween = null;
	obj.posXTween = 100;
	obj.posYTween = 100;
	obj.onEnterFrameTween = function() {
		obj.numTimeTween += obj.numStepTween;
		var posX = findTweenValue(obj.numInicioXTween, obj.numFinalXTween, 0, obj.numTimeTween, obj.numDurationTween, obj.strEasingTween);
		var posY = findTweenValue(obj.numInicioYTween, obj.numFinalYTween, 0, obj.numTimeTween, obj.numDurationTween, obj.strEasingTween);
		setPosition(obj, posX, posY);
		if (obj.numTimeTween>=obj.numDurationTween) {
			setPosition(obj, obj.numFinalXTween, obj.numFinalYTween);
			clearInterval(obj.thisIntervalTween);
			obj.callbackTween();
		}
	};
	obj.tweenTo = function() {
		var pos = getPos(obj);
		this.numTimeTween = 0;
		this.numInicioXTween = pos.y;
		this.numInicioYTween = pos.x;
		this.numFinalXTween = arguments[0];
		this.numFinalYTween = arguments[1];
		this.strEasingTween = (arguments[2]) ? arguments[2] : 'linear';
		this.numDurationTween = (arguments[3]) ? arguments[3]*1000 : 1000;
		this.callbackTween = arguments[4] || function () {
		};
		clearInterval(obj.thisIntervalTween);
		obj.thisIntervalTween = setInterval(obj.onEnterFrameTween, obj.numStepTween);
	};
	obj.stopTween = function() {
		clearInterval(obj.thisIntervalTween);
	};
};
/* Shake */
shake = function () {
	var obj = $(arguments[0]);
	var dist = 4;
	var moving = false;
	obj.numStepShake = 25;
	obj.thisIntervalShake = null;
	obj.onEnterFrameShake = function() {
		obj.numTimeShake += obj.numStepShake;
		var posX = Math.round((Math.random()*dist*2-dist)+obj.numInicioXShake);
		var posY = Math.round((Math.random()*dist*2-dist)+obj.numInicioYShake);
		setPosition(obj, posX, posY);
		if (obj.numTimeShake>=obj.numDurationShake) {
			setPosition(obj, obj.numInicioXShake, obj.numInicioYShake);
			clearInterval(obj.thisIntervalShake);
			obj.callbackShake();
			moving = false;
		}
	};
	obj.shakeNow = function() {
		if (moving == true) {
			obj.stopShake();
		}
		var pos = getPos(obj);
		this.numTimeShake = 0;
		this.numInicioXShake = pos.y;
		this.numInicioYShake = pos.x;
		this.numDurationShake = (arguments[0]) ? arguments[0]*1000 : 1000;
		this.callbackShake = arguments[1] || function () {
		};
		obj.thisIntervalShake = setInterval(obj.onEnterFrameShake, obj.numStepShake);
		moving = true;
	};
	obj.stopShake = function() {
		clearInterval(obj.thisIntervalShake);
		setPosition(obj, obj.numInicioXShake, obj.numInicioYShake);
	};
};
/* Alpha */
alpha = function () {
	var obj = $(arguments[0]);
	obj.numStepAlpha = (isIE) ? 45 : 40;
	obj.thisIntervalAlpha = null;
	obj.onEnterFrameAlpha = function() {
		obj.numTimeAlpha += obj.numStepAlpha;
		var newAlpha = findTweenValue(obj.numInicioAlpha, obj.numFinalAlpha, 0, obj.numTimeAlpha, obj.numDurationAlpha, obj.strEasingAlpha);
		setAlpha(obj, newAlpha);
		if (obj.numTimeAlpha>=obj.numDurationAlpha) {
			setAlpha(obj, obj.numFinalAlpha);
			clearInterval(obj.thisIntervalAlpha);
			obj.callbackAlpha();
		}
	};
	obj.alphaTo = function() {
		this.numTimeAlpha = 0;
		this.numInicioAlpha = arguments[0];
		this.numFinalAlpha = arguments[1];
		this.strEasingAlpha = (arguments[2]) ? arguments[2] : 'linear';
		this.numDurationAlpha = (arguments[3]) ? arguments[3]*1000 : 1000;
		this.callbackAlpha = arguments[4] || function () {
		};
		clearInterval(obj.thisIntervalAlpha);
		obj.thisIntervalAlpha = setInterval(obj.onEnterFrameAlpha, obj.numStepAlpha);
	};
	obj.stopAlpha = function() {
		clearInterval(obj.thisIntervalAlpha);
	};
};
// Controla a posição do scroll
var SC = {
	'interval': null,
	'initPos': 0,
	'finalPos': 0,
	'timeNow': 0,
	'timeTotal': 0,
	'effect': '',
	'step': 20,
	'fn': 20,
	'scroll': function(pos,effect,time,fn) {
		var sc = getScroll();
		SC.fn = fn || function(){};
		SC.timeTotal = (time)?time*1000:1000;
		SC.timeNow = 0;
		SC.initPos = sc.y;
		SC.finalPos = pos;
		SC.effect = effect;
		clearInterval(SC.interval);
		SC.interval = setInterval(SC.enterFrame,SC.step);
	},
	'enterFrame': function() {
		var sc = findTweenValue(SC.initPos, SC.finalPos, 0, SC.timeNow, SC.timeTotal, SC.effect);
		window.scrollTo(0,sc);
		SC.timeNow += SC.step;
		if (SC.timeNow >= SC.timeTotal) {
			clearInterval(SC.interval);
			SC.fn();
		}
	}
};
/* Função de easing */
findTweenValue = function (PS, PD, TS, TN, TD, AT, E1, E2) {
	var t = TN-TS, b = PS, c = PD-PS, d = TD-TS, a = E1, p = E2, s = E1;
	switch (AT.toLowerCase()) {
	case "linear" :
		return c*t/d+b;
	case "easeinexpo" :
		return (t == 0) ? b : c*Math.pow(2, 10*(t/d-1))+b;
	case "easeoutexpo" :
		return (t == d) ? b+c : c*(-Math.pow(2, -10*t/d)+1)+b;
	case "easeoutelastic" :
		if (t == 0) {
			return b;
		}
		if ((t /= d) == 1) {
			return b+c;
		}
		if (!p) {
			p = d*.3;
		}
		if (!a || a<Math.abs(c)) {
			a = c;
			var s = p/4;
		} else {
			var s = p/(2*Math.PI)*Math.asin(c/a);
		}
		return (a*Math.pow(2, -10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b);
	}
};
/* Cookies */
var CK = {
	'data': new Date(),
	'w': function(c,v,t) {
		try {
			var expires = "";
			var d = this.data;
			if (arguments.length>2) {
				d.setTime(d.getTime()+(t*86400000));
				expires = "expires="+d.toGMTString()+";";
			}
			document.cookie = c+"="+v+";"+expires+"path=/";
			//var dasdasd = dsadasddsd;
			return true;
		} catch (e) {error(e)}
	},
	'r': function(c) {
		try {
			var nameE = c+"=";
			var cookies = document.cookie.split(";");
			for (var i = 0, Cookie; Cookie=cookies[i]; i++) {
				while (Cookie.charAt(0) == " ") {
					Cookie = Cookie.substring(1, Cookie.length);
				}
				if (Cookie.indexOf(nameE) == 0) {
					return Cookie.substring(nameE.length, Cookie.length);
				}
			}
			return null;
		} catch (e) {error(e)}
	},
	'e': function(c) {
		try {
			this.write(c, "", -1);
			return true;
		} catch (e) {error(e)}
	}
};
/* Função para gerar um valor unico */
nocache = function (nivel) {
	nivel = nivel || 6;
	var data = new Date();
	var s = data.getFullYear();
	if (nivel>0) {
		s += '.'+(data.getMonth()+1);
	}
	if (nivel>1) {
		s += '.'+data.getDate();
	}
	if (nivel>2) {
		s += '.'+data.getHours();
	}
	if (nivel>3) {
		s += '.'+data.getMinutes();
	}
	if (nivel>4) {
		s += '.'+data.getSeconds();
	}
	if (nivel>5) {
		s += '.'+data.getMilliseconds();
	}
	return s;
};
/* Formulários */
campoAtual = '';
formError = function(campo, mensagem) {
	campoAtual = campo;
	SA.onClose = function() {
		if (!stageTest(campoAtual)) {
			SC.scroll(getPos(campoAtual).y-20,'easeoutexpo',0.5,function(){focusTo(campoAtual);});
		} else {
			focusTo(campoAtual);
		}
	};
	SA.open(mensagem);
};

stageTest = function(o) {
	var DSC = getScroll().y;
	var DVS = getDocVisibleSize().y;
	var OP = getPos(o).y;
	var OS = getSize(o).y;
	return (DSC < OP && OP+OS < DVS+DSC);
};

focusTo = function(o) {
	try {
		$(o).focus();
		$(o).select();
	} catch(e) {}
};

function radio(object) {
	if(typeof object == 'object'){
		strChek = object.name;
	}else{
		strChek = object;
	}
	obj = document.getElementsByTagName('input');
	for (var i = 0; i< obj.length; i++){
	    if (obj[i].type == 'radio' && obj[i].name == strChek  && obj[i].checked){
			return obj[i].value;
		}
	}
	return null
}

var SOC = {
	'tweencreate': 0,
	'aberto':0,
	'show': function(id) {
		$('selecionarCidade').style.display = "block";	
		if(this.tweencreate == 0){
			new tween('selecionarCidade');
			this.tweencreate = 1;
		}
		this.aberto = 1;
		this.alinha();
		bgSite.show();	
		document.getElementById('Cidades.cidade').style.display = "block";		
	},
	'alinha': function(){
		if(this.aberto == 0)return;
		
		var SC = getScroll();
		var VS = getDocVisibleSize();
		var SZ = getSize('selecionarCidade');
		newX = (VS.x-SZ.x)-68;
		newY = (41);		

		$('selecionarCidade').tweenTo((newY+SC.y), (newX+SC.x), 'easeoutexpo', 0.3,function(){
			var sl = new selectLoader();
			sl.load("Cidades.cidade","cidadesXML.php");
		});		
	},
	'hide': function(){
		this.aberto = 0;
		var SC = getScroll();
		var VS = getDocVisibleSize();
		var SZ = getSize('selecionarCidade');	
		
		newX = (VS.x-SZ.x)/2;
		newY = (VS.y-SZ.y)/2;
		$('selecionarCidade').tweenTo(-((newY+SC.y)+50), -((newX+SC.x)+50), 'easeoutexpo', 1,function(){	
			$('selecionarCidade').style.display = "none";	
		});	
		bgSite.hide();	
	},
	'onSelect':function(){
		if($("Cidades.cidade").value == ""){
			SA.open("Selecione uma cidade!");
			return false;
		}
		location = "index.php?cidade="+$("Cidades.cidade").value;
	}
};

var Indiq = {
	'tweencreate': 0,
	'aberto':0,
	'btOK': '',
	'show': function(id) {
		$('indicarSite').style.display = "block";	
		if(this.tweencreate == 0){
			new tween('indicarSite');
			this.tweencreate = 1;
		}
		this.aberto = 1;
		this.alinha();
		bgSite.show();	
	},
	'alinha': function(){
		if(this.aberto == 0)return;
		var SC = getScroll();
		var VS = getDocVisibleSize();
		var SZ = getSize('indicarSite');
		newX = (VS.x-SZ.x)/2;
		newY = (VS.y-SZ.y)/2;	
		$('indicarSite').tweenTo((newY+SC.y), (newX+SC.x), 'easeoutexpo', 0.3);		
	},
	'hide': function(){
		var SC = getScroll();
		var VS = getDocVisibleSize();
		var SZ = getSize('indicarSite');	
		
		newX = (VS.x-SZ.x)/2;
		newY = (VS.y-SZ.y)/2;
		this.aberto = 0;			
		$('indicarSite').tweenTo(-((newY+SC.y)+50), -((newX+SC.x)+50), 'easeoutexpo', 1,function(){
			$('indicarSite').style.top = "-1000px";
			$('indicarSite').style.lef = "-1000px";		
			$('indicarSite').style.display = "none";
			Indiq.btOK = ''
		});	
		bgSite.hide();	
	},
	'onClick':function(){
		if($('Indiq.nome').value.length == 0){
			SA.onClick = function(){
				$('Indiq.nome').focus();
			}
			SA.open('Digite um nome!');
			return false;
		}
		if($('Indiq.email').value.length == 0){
			SA.onClick = function(){
				$('Indiq.email').focus();
			}
			SA.open('Digite um e-mail!');
			return false;
		}
		if(!$('Indiq.email').value.isMail()){
			SA.onClick = function(){
				$('Indiq.email').select();
				$('Indiq.email').focus();
			}
			SA.open('Digite um e-mail v&aacute;lido!');
			return false;			
		}
		if($('Indiq.nomeamigo').value.length == 0){
			SA.onClick = function(){
				$('Indiq.nomeamigo').focus();
			}
			SA.open('Digite o nome do seu amigo!');
			return false;
		}	
		if($('Indiq.emailamigo').value.length == 0){
			SA.onClick = function(){
				$('Indiq.emailamigo').focus();
			}
			SA.open('Digite o e-mail do seu amigo!');
			return false;
		}
		if(!$('Indiq.emailamigo').value.isMail()){
			SA.onClick = function(){
				$('Indiq.emailamigo').select();
				$('Indiq.emailamigo').focus();
			}
			SA.open('Digite um e-mail v&aacute;lido!');
			return false;			
		}
		
		if(this.btOK == ''){
			this.btOK = $('Indiq.bts').innerHTML;
		}
		var xml = new xmlConnection();
		if (xml.create()) {
			xml.setMethod('POST');
			xml.setURL('indicaXML.php');
			xml.add('acao','lista');
			xml.add('nome',$('Indiq.nome').value);
			xml.add('email',$('Indiq.email').value);			
			xml.add('nomeamigo',$('Indiq.nomeamigo').value);
			xml.add('emailamigo',$('Indiq.emailamigo').value);						
			xml.onComplete = function() {
				SA.onClick = function(){
					$('Indiq.nome').value = "";
					$('Indiq.email').value = "";			
					$('Indiq.nomeamigo').value = "";			
					$('Indiq.emailamigo').value = "";								
					$('Indiq.bts').innerHTML = Indiq.btOK;
					Indiq.hide();				
				}				
				SA.open('Indica&ccedil;&atilde;o feita com sucesso! para o e-mail: <b>'+$('Indiq.emailamigo').value+'</b>');
			};
			$('Indiq.bts').innerHTML = '<div style="font:bold 14px Arial;color:#8d8c87;text-align:left;"><img alt="" style="vertical-align:middle;" src="imagens/loading.gif" /> Carregando...</div>';
			xml.execute();
		}		
	}
};
var arrPaineis = ['painelclinica.php','painelmedico.php?s=http://201.6.144.110:8082/usuarios','painelpaciente.php'];
login = function(){
	if($('Login.login').value.length == 0){
		SA.onClick = function(){
			$('Login.login').focus();
		}
		SA.open('Digite seu login!');
		return false;
	}
	if($('Login.senha').value.length == 0){
		SA.onClick = function(){
			$('Login.senha').focus();
		}
		SA.open('Digite sua senha!');
		return false;
	}	
	if($('Login.senha').value.length < 6){
		SA.onClick = function(){
			$('Login.senha').focus();
		}
		SA.open('Sua senha cont&eacute;m menos que 6 caracteres!');
		return false;
	}		
	var xml = new xmlConnection();
	if (xml.create()) {
		xml.setMethod('POST');
		xml.setURL('loginXML.php');
		xml.add('login',$('Login.login').value);
		xml.add('senha',$('Login.senha').value);
		xml.setChildName('l');
		xml.onComplete = function() {	
			if(this.getAttByName('status',0) == 0){
				SA.open("Usu&aacute;rio ou senha incorreto!");
			}else if(this.getAttByName('status',0) == 2){
				SA.open("Voc&ecirc; n&atilde;o ativou sua conta por e-mail!");
			}else if(this.getAttByName('status',0) == 1){
				location = arrPaineis[this.getAttByName('redir',0)];
			}
			$("Login.bt").src = "imagens/loginOk.gif";
		};
		$("Login.bt").src = "imagens/botaoOKcarregando.gif";
		xml.execute();
	}
};
logout = function(){		
	var xml = new xmlConnection();
	if (xml.create()) {
		xml.setMethod('POST');
		xml.setURL('logoutXML.php');
		xml.setChildName('l');
		xml.onComplete = function() {	
			if (this.getAttByName('status',0) == 1) {
				location = 'index.php';
			}
		};
		xml.execute();
	}		
};
loginEnter = function(e){
	if (window.event) {
		keycode = window.event.keyCode;          
	} else if (e) {              
		keycode = e.which;          
	} else {
		keycode = e.keyCode;
	}
	if (keycode == 13) {
		login();
	}
}
painel = function() {
	location = arrPaineis[autComunidade];
};

conteudoBloqueado = function() {
	SA.onClick = function(e) {
		if (e == 'YES') SA.onClose = function() {
			enviarContato.show(33);
			//for (var k = 0; k < $('enviarContato.Setor').options.length; k++) if ($('enviarContato.Setor').options[k].value = 33) $('enviarContato.Setor').selectedIndex = k;
		}; else SA.onClose = function(){};
	};
	SA.open('Conte&uacute;do exclusivo para assinantes!<br />Deseja assinar agora?',2);
};
var buscaAvancada = {
	'tweencreate': 0,
	'aberto':0,
	'btOK': '',
	'show': function() {
		$('buscaAvancada').style.display = "block";	
		if(this.tweencreate == 0){
			new tween('buscaAvancada');
			var sl = new selectLoader();
			sl.load("buscaAvancada.especialidade","especialidades3XML.php");
			this.tweencreate = 1;
		}
		this.aberto = 1;
		this.alinha();
		bgSite.show();	
		document.getElementById('buscaAvancada.especialidade').style.display = "block";
	},
	'alinha': function() {
		if(this.aberto == 0)return;
		var SC = getScroll();
		var VS = getDocVisibleSize();
		var SZ = getSize('buscaAvancada');
		newX = (VS.x-SZ.x)/2;
		newY = (VS.y-SZ.y)/2;	
		$('buscaAvancada').tweenTo((newY+SC.y), (newX+SC.x), 'easeoutexpo', 0.3);		
	},
	'hide': function() {
		var SC = getScroll();
		var VS = getDocVisibleSize();
		var SZ = getSize('buscaAvancada');
		newX = (VS.x-SZ.x)/2;
		newY = (VS.y-SZ.y)/2;
		this.aberto = 0;			
		$('buscaAvancada').tweenTo(-SZ.y+SC.y, -SZ.x+SC.x, 'easeinexpo', 0.3, function(){
			$('buscaAvancada').style.top = "-1000px";
			$('buscaAvancada').style.lef = "-1000px";		
			$('buscaAvancada').style.display = "none";
		});	
		bgSite.hide();	
	},
	'onClick':function(id){
		if (id == 1) {
			$('buscaAvancada.form').submit();
		} else {
			
		}
	}
};

var buscaAvancada2 = {
	'tweencreate': 0,
	'aberto':0,
	'btOK': '',
	'show': function() {
		$('buscaAvancada2').style.display = "block";	
		if(this.tweencreate == 0){
			new tween('buscaAvancada2');
			this.tweencreate = 1;
		}
		this.aberto = 1;
		this.alinha();
		bgSite.show();	
	},
	'alinha': function() {
		if(this.aberto == 0)return;
		var SC = getScroll();
		var VS = getDocVisibleSize();
		var SZ = getSize('buscaAvancada2');
		newX = (VS.x-SZ.x)/2;
		newY = (VS.y-SZ.y)/2;	
		$('buscaAvancada2').tweenTo((newY+SC.y), (newX+SC.x), 'easeoutexpo', 0.3);		
	},
	'hide': function() {
		var SC = getScroll();
		var VS = getDocVisibleSize();
		var SZ = getSize('buscaAvancada2');
		newX = (VS.x-SZ.x)/2;
		newY = (VS.y-SZ.y)/2;
		this.aberto = 0;			
		$('buscaAvancada2').tweenTo(-SZ.y+SC.y, -SZ.x+SC.x, 'easeinexpo', 0.3, function(){
			$('buscaAvancada2').style.top = "-1000px";
			$('buscaAvancada2').style.lef = "-1000px";		
			$('buscaAvancada2').style.display = "none";
		});	
		bgSite.hide();	
	},
	'onClick':function(id){
		if (id == 1) {
			$('buscaAvancada2.form').submit();
		} else {
			
		}
	}
};

var buscaAvancada3 = {
	'tweencreate': 0,
	'aberto':0,
	'btOK': '',
	'show': function() {
		$('buscaAvancada3').style.display = "block";	
		if(this.tweencreate == 0){
			new tween('buscaAvancada3');
			this.tweencreate = 1;
		}
		this.aberto = 1;
		this.alinha();
		bgSite.show();	
	},
	'alinha': function() {
		if(this.aberto == 0)return;
		var SC = getScroll();
		var VS = getDocVisibleSize();
		var SZ = getSize('buscaAvancada3');
		newX = (VS.x-SZ.x)/2;
		newY = (VS.y-SZ.y)/2;	
		$('buscaAvancada3').tweenTo((newY+SC.y), (newX+SC.x), 'easeoutexpo', 0.3);		
	},
	'hide': function() {
		var SC = getScroll();
		var VS = getDocVisibleSize();
		var SZ = getSize('buscaAvancada3');
		newX = (VS.x-SZ.x)/2;
		newY = (VS.y-SZ.y)/2;
		this.aberto = 0;			
		$('buscaAvancada3').tweenTo(-SZ.y+SC.y, -SZ.x+SC.x, 'easeinexpo', 0.3, function(){
			$('buscaAvancada3').style.top = "-1000px";
			$('buscaAvancada3').style.lef = "-1000px";		
			$('buscaAvancada3').style.display = "none";
		});	
		bgSite.hide();	
	},
	'onClick':function(id){
		if (id == 1) {
			$('buscaAvancada3.form').submit();
		} else {
			
		}
	}
};

abreBuscaAvancada = function () {
	if(btBuscaAtual == 'buscaProfdeSaude'){
		buscaAvancada.show();
	}else if(btBuscaAtual == 'buscaPacientes'){
		buscaAvancada2.show();
	}else{
		buscaAvancada3.show();
	}
};

/*var alterarSenha = {
	'tweencreate': 0,
	'aberto':0,
	'btOK': '',
	'show': function() {
		$('alterarSenha').style.display = "block";	
		if(this.tweencreate == 0){
			new tween('alterarSenha');
			this.tweencreate = 1;
		}
		this.aberto = 1;
		this.alinha();
		bgSite.show();	
	},
	'alinha': function() {
		if(this.aberto == 0)return;
		var SC = getScroll();
		var VS = getDocVisibleSize();
		var SZ = getSize('alterarSenha');
		newX = (VS.x-SZ.x)/2;
		newY = (VS.y-SZ.y)/2;	
		$('alterarSenha').tweenTo((newY+SC.y), (newX+SC.x), 'easeoutexpo', 0.3);		
	},
	'hide': function() {
		var SC = getScroll();
		var VS = getDocVisibleSize();
		var SZ = getSize('alterarSenha');
		newX = (VS.x-SZ.x)/2;
		newY = (VS.y-SZ.y)/2;
		this.aberto = 0;			
		$('alterarSenha').tweenTo(-SZ.y+SC.y, -SZ.x+SC.x, 'easeinexpo', 0.3, function(){
			$('alterarSenha').style.top = "-1000px";
			$('alterarSenha').style.lef = "-1000px";		
			$('alterarSenha').style.display = "none";
		});	
		bgSite.hide();	
	},
	'onClick':function(id){
		SA.open("Alterar senha");
	}
};
alterarSenha.show();*/
var browserEm = {
	'aberto':0,
	'btOK': '',
	'show': function(url) {
		$('browserEm').style.display = "block";
		this.aberto = 1;
		this.alinha();
		bgSite.show();
		$('browserEm_iframe').src = url;
	},
	'alinha': function() {
		if(this.aberto == 0)return;
		var SC = getScroll();
		var VS = getDocVisibleSize();
		var SZ = getSize('browserEm');
		newX = (VS.x-SZ.x)/2;
		newY = (VS.y-SZ.y)/2;
		$('browserEm').style.top = (newY+SC.y)+'px';
		$('browserEm').style.left = (newX+SC.x)+'px';		
	},
	'hide': function() {
		var SC = getScroll();
		var VS = getDocVisibleSize();
		var SZ = getSize('browserEm');
		newX = (VS.x-SZ.x)/2;
		newY = (VS.y-SZ.y)/2;
		this.aberto = 0;	
		$('browserEm').style.display = "none";
		bgSite.hide();	
	}
};

var hintTimeout, hintTxt, hintObj;
hint = function(txt, obj) {
	txt = txt || hintTxt; hintTxt = txt;
	obj = obj || hintObj; hintObj = obj;
	clearTimeout(hintTimeout);
	var MP = getPos(obj);
	$('hintText').innerHTML = txt;
	$('hintTb').style.display = 'block';
	var SZ = getSize('hintTb');
	$('hintTb').style.top = (MP.y-SZ.y)+'px';
	$('hintTb').style.left = (MP.x-SZ.x)+'px';
	obj.onmouseout = function() {
		hintTimeout = setTimeout(hideHint, 300);
	};
};

hideHint = function() {
	$('hintTb').style.display = 'none';
};

function upCase(string) {
	var texto = string.toUpperCase();
	return texto;
};