////////////////////////////////////////////////////////////////////////////////////////////
/*Funcao Adiciona a Favoritos*/
function fnAdicionaFavoritos(){
	str_titulo = "Espaco Guanabara";
	str_url = "http://www.espacoguanabara.com.br";
	try{
		if(window.external){window.external.AddFavorite(str_url,str_titulo); }
	}
	catch(e)
	{
		try{
			if(window.sidebar){ window.sidebar.addPanel(str_titulo,str_url,""); }
		}
		catch(ee)
		{
			if(window.opera && window.print){ return true; }
		}
	}	
}
////////////////////////////////////////////////////////////////////////////////////////////
//Validacao da Newsletter
function ValidaNews(form,evento){
	if(form.form_nome.value.length<=1){
		alert("O campo Nome deve estar preenchido corretamente.");
		form.form_nome.focus();
		return false;
	}		
	if (form.form_email.value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1){
		alert("Atenção!\nDigite corretamente o seu e-mail.");
		form.form_email.focus();
		return false;
	}
}
////////////////////////////////////////////////////////////////////////////////////////////
/*Funcao para target*/
function fnTarget(str_target){
	//declaracao de variaveis
	var ch_tag_A, vet_A, int_i;
	var str_titulo;	
	//pega todos os <a> da pagina e percorre um por um para achar o rel="external"
    ch_tag_A = document.getElementsByTagName('a');
    for(int_i=0; int_i<ch_tag_A.length; int_i++){
		vet_A = ch_tag_A[int_i];
		if(vet_A.getAttribute("href") && vet_A.getAttribute('rel') != null){
			if(vet_A.getAttribute('rel').substring(0,8) == 'external'){
				vet_A.target = str_target;
				str_titulo = ch_tag_A.title;
				ch_tag_A.title = str_titulo;
			}
		}
	}
}
//Funcao para localizacao
function fnLocalizacao(){document.writeln('<iframe width="700" height="450" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=pt-BR&amp;geocode=&amp;q=Rua+Oswaldo+Cruz,+n%C2%BA+300+Guanabara+-+Campinas+-+SP&amp;sll=-22.906365,-47.061574&amp;sspn=0.906998,1.186523&amp;ie=UTF8&amp;hq=&amp;hnear=R.+Dr.+Osvaldo+Cruz,+300+-+Taquaral,+Campinas+-+SP,+13076-260,+Brasil&amp;ll=-22.883253,-47.057683&amp;spn=0.006721,0.01502&amp;z=16&amp;iwloc=A&amp;output=embed"></iframe>')}
///////////////////////////////////////////////////////////////////////////////////////////
//Funcao para flash
function fnFlash(str_url, int_largura, int_altura){
	document.writeln('<object type="application/x-shockwave-flash" data="' + str_url + '" width="' + int_largura + '" height="' + int_altura + '">');
	document.writeln('<param name="movie" value="' + str_url + '">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('<param name="wmode" value="transparent">');
	document.writeln('</object>');
}
////////////////////////////////////////////////////////////////////////////////////////////
//Funcao de popup
function MM_openBrWindow(theURL,winName,features) 
{
	var myWin =  window.open(theURL,winName,features);
	myWin.focus();
}
////////////////////////////////////////////////////////////////////////////////////////////
/*FUNCAO ABRE E FECHA*/
function fnAbreTexto(id){
	esconder = (document.getElementById(id).style.display == 'block');
	divs = document.getElementsByTagName('DIV');
	for(d=0; d<divs.length; d++){
		_div = divs[d];
		if (_div.className == 'texto'){
			id_link = 'texto'+(_div.id);
			_link = document.getElementById(id_link);
			if(_div.id != id){ _div.style.display = 'none'; }
			else{ _div.style.display = esconder ? 'none' : 'block'; }
		}
	}
}
//////////////////////////////////////////////////////////////////////////////////////////////
//valida formulario Contato home
function ValidaForm_Contato_Home(form){
	if(form.form_nome.value.length<=1){
		alert("O campo Nome deve estar preenchido corretamente.");
		form.form_nome.focus();
		return false;
	}
	var str_email = form.form_email.value ;
    if (( str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1 ) || ( str_email == 'Email:' )){
    	alert("O campo E-mail deve ser preenchido corretamente");
    	form.form_email.focus();
    	return false;
	}
	if(form.form_telefone.value.length<=1){
		alert("O campo Telefone deve estar preenchido corretamente.");
		form.form_telefone.focus();
		return false;
	}
	if(form.form_mensagem.value.length<=1){
		alert("O campo Mensagem deve estar preenchido corretamente.");
		form.form_mensagem.focus();
		return false;
	}
}
