function abreFotoComNome(nome, larg, alt)
{
	alt = alt + 20;
	larg = larg + 20;
	window.open(nome, 'PhotoCast', 'height=' + alt + ', width=' + larg);
}

// Função para abrir o Wimpy

function AbreWimpy()
{
	window.open('ouca.php', 'Wimpy', 'width=525, height=430');
}

function abreCursos()
{
	window.open('cursos/index.php', 'Cursos', 'scrollbars=yes,resizable=yes, width=580, height=560');
}

function AbreDownload()
{
	window.open('down.php', 'Download', 'width=575, height=450');
}

function AbreJogo()
{
	window.open('jogo/instrucoes.php', 'Jogo', 'width=510, height=380');
}

function AbreVozes()
{
	window.open('vozes.php', 'Vozes', 'width=580, height=400, scrollbars=yes');
}

// Funções para Cookies dos formulários
 
function setCookie(name, value, expires, path, domain, secure) 
{
	var curCookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

function getCookie(name) 
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
	begin = dc.indexOf(prefix);
	if (begin != 0) return null;
	} else
	begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
	end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain) 
{
	if (getCookie(name)) {
	document.cookie = name + "=" +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	history.go(0);
	}
}

function fixDate(date) 
{
	var base = new Date(0);
	var skew = base.getTime();
	if (skew > 0) date.setTime(date.getTime() - skew);
}

// Fim das funções de Cookie (padronizadas)


// Funcao para validar enquete

function validaEnquete()
{
	d = document.form_enquete;
	var a = 0;
	for (i=0;i<d.radiobutton.length;i++)
	{
		if (d.radiobutton[i].checked==false)
			a = a + 1;
	}
	if (a >= d.radiobutton.length)		
	{
		alert("Você deve escolher uma opção da enquete!");
		return false;
	}
	else
	{
		var now = new Date();
		fixDate(now);
		now.setTime(now.getTime() + 24 * 60 * 60 * 1000);
		var enquete = getCookie("enquete");
		if (!enquete)
		{
			setCookie("enquete", 1 , now);
			return true;
		}
		else
		{
			alert("Você já participou desta enquete!");
			return false;
		}
	}
}


// Funcao para validar Pesquisa de Opinião

function validaPesquisa()
{
	d = document.form_opiniao;
	if (d.tx_nome_opiniao.value == "")
	{
		alert("O campo NOME deve ser preenchido!");
		d.tx_nome_opiniao.focus();
		return false;
	}
	else if (d.tx_email_opiniao.value == "")
	{
		alert("O campo EMAIL deve ser preenchido!");
		d.tx_email_opiniao.focus();
		return false;
	}
	else if (d.tx_cidade_opiniao.value == "")
	{
		alert("O campo CIDADE deve ser preenchido!");
		d.tx_cidade_opiniao.focus();
		return false;
	}
	else if (d.text_opiniao.value == "")
	{
		alert("O campo SUA OPINIÃO deve ser preenchido!");
		d.text_opiniao.focus();
		return false;
	}
	else
	{
		var now = new Date();
		fixDate(now);
		now.setTime(now.getTime() + 24 * 60 * 60 * 1000);
		var opiniao = getCookie("opiniao");
		if (!opiniao)
		{
			setCookie("opiniao", 1 , now);
			return true;
		}
		else
		{
			alert("Você já participou desta pesquisa!");
			return false;
		}
	}
}


// Funcao para validar Feedback

function validaFeedback()
{
	d = document.form_feedback;
	if (d.tx_nome_feedback.value == "")
	{
		alert("O campo NOME deve ser preenchido!");
		d.tx_nome_feedback.focus();
		return false;
	}
	else if (d.tx_cidade_feedback.value == "")
	{
		alert("O campo CIDADE deve ser preenchido!");
		d.tx_cidade_feedback.focus();
		return false;
	}
	else if (d.tx_email_feedback.value == "")
	{
		alert("O campo EMAIL deve ser preenchido!");
		d.tx_email_feedback.focus();
		return false;
	}
	else if (d.tx_feedback.value == "")
	{
		alert("O campo FEEDBACK deve ser preenchido!");
		d.tx_feedback.focus();
		return false;
	}
	return true;
}


// Funcao para validar newsletter

function validaNewsletter()
{
	d = document.form_newsletter;
	if (d.tx_nome_news.value == "")
	{
		alert("O campo NOME deve ser preenchido!");
		d.tx_nome_news.focus();
		return false;
	}
	if (d.tx_email_news.value == "")
	{
		alert("O campo EMAIL deve ser preenchido!");
		d.tx_email_news.focus();
		return false;
	}
	return true;
}

// Funcao para banners rotatorios

// Banners horizontais rotativos ouca.php

function iniciarOuca()
{
	setInterval("BannerHorizontalOuca()", 1000);
}

function MostraBanner() 
{
	var Imagens = new Array();
	Imagens[1] = "im_comuns/banner01.png";
	Imagens[2] = "im_comuns/banner02.png";
	Imagens[3] = "im_comuns/banner03.png";
	Imagens[4] = "im_comuns/banner04.png";
	Imagens[5] = "im_comuns/banner05.png";
	Imagens[6] = "im_comuns/banner06.png";
	Imagens[7] = "im_comuns/banner07.png";
					
	var Qual = Math.floor(Math.random() * Imagens.length);
	
	if (Qual == 0) 
		Qual = 1;

	document.write('<A HREF="index.php"><img src=" '+Imagens[Qual]+' "border=1></a>');
	//document.write('<A HREF='+' " '+Nome[Qual] + ' " ' + ' target =' + ' " ' + '_blank' + ' " ' + '><img src=" '+Imagens[Qual]+' "border=1></a>');
}

// Banners horizontais

function BannerHorizontal() 
{
	var Imagens = new Array();
	Imagens[1] = "publicidade/horizontal470x60/citylab.jpg";
	Imagens[2] = "publicidade/horizontal470x60/escolafocus.jpg";
	Imagens[3] = "publicidade/horizontal470x60/macrofotografia.jpg";
	
	var Nome = new Array();
	Nome[1] = "citylab";
	Nome[2] = "focusfoto";
	Nome[3] = "macrofotografia";

	var Link = new Array();
	Link[1] = "http://www.citylab.com.br";
	Link[2] = "http://www.focusfoto.com.br";
	Link[3] = "http://www.macrofotografia.com.br";
	
	var Qual = Math.floor(Math.random() * Imagens.length);
	
	if (Qual == 0) 
		Qual = 1;

	document.write('<A HREF="publicidade.php?nome=' + Nome[Qual] + '&link=' + Link[Qual] + ' " ' + ' target =' + ' " ' + '_blank' + ' " ' + '><img src=" '+Imagens[Qual]+' "border=1></a>');
	//document.write('<A HREF='+' " '+Nome[Qual] + ' " ' + ' target =' + ' " ' + '_blank' + ' " ' + '><img src=" '+Imagens[Qual]+' "border=1></a>');
}

// Banners horizontais dos diretorios da Edicao

function BannerHorizontalEdicao() 
{
	var Imagens = new Array();
	Imagens[1] = "../../publicidade/horizontal470x60/citylab.jpg";
	Imagens[2] = "../../publicidade/horizontal470x60/escolafocus.jpg";
	Imagens[3] = "../../publicidade/horizontal470x60/macrofotografia.jpg";
	
	var Nome = new Array();
	Nome[1] = "citylab";
	Nome[2] = "focusfoto";
	Nome[3] = "macrofotografia";

	var Link = new Array();
	Link[1] = "http://www.citylab.com.br";
	Link[2] = "http://www.focusfoto.com.br";
	Link[3] = "http://www.macrofotografia.com.br";
	
	var Qual = Math.floor(Math.random() * Imagens.length);
	
	if (Qual == 0) 
		Qual = 1;

	document.write('<A HREF="publicidade.php?nome=' + Nome[Qual] + '&link=' + Link[Qual] + ' " ' + ' target =' + ' " ' + '_blank' + ' " ' + '><img src=" '+Imagens[Qual]+' "border=1></a>');
	//document.write('<A HREF='+' " '+Nome[Qual] + ' " ' + ' target =' + ' " ' + '_blank' + ' " ' + '><img src=" '+Imagens[Qual]+' "border=1></a>');
}

// Banners quadrados

function BannerQuadrados() 
{
	var Imagens = new Array();
	Imagens[1] = "publicidade/quadrado156x120/riguardare.jpg";
	Imagens[2] = "publicidade/quadrado156x120/louco.jpg";
	
	var Nome = new Array();
	Nome[1] = "riguardare";
	Nome[2] = "louco";
	
	var Link = new Array();
	Link[1] = "http://www.riguardare.com.br";
	Link[2] = "http://www.loucoporfotografia.net";
	
	var Qual = Math.floor(Math.random() * Imagens.length);
	
	if (Qual == 0) 
		Qual = 1;
	
	document.write('<A HREF="publicidade.php?nome=' + Nome[Qual] + '&link=' + Link[Qual] + ' " ' + ' target =' + ' " ' + '_blank' + ' " ' + '><img src=" '+Imagens[Qual]+' "border=1></a>');
	//document.write('<A HREF='+' " '+Links[Qual] + ' " ' + ' target =' + ' " ' + '_blank' + ' " ' + '><img src=" '+Imagens[Qual]+' "border=1></a>');
}