function gotodate(d,m,y,url)
{
	if(d=="")
	{
	//ajaxrequest('get','','module=files|screen=calendario|divtarget=calendario|imes='+m+'|iano='+y+'','','','');
	getAjax('loader.php?module=files','calendario','&screen=calendario&imes='+m+'&iano='+y+'','',0);
	}
	else
	{
	window.location=''+url+'index.php/pagina/agenda/data/'+d+'-'+m+'-'+y+'';
	}
}


function objeto(nome,largura,altura){

document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'+
' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"'+
' width="'+largura+'" height="'+altura+'" id="'+nome+'" align="middle">');
document.write('<param name="allowScriptAccess" value="always" />');
document.write('<param name="allowFullScreen" value="true" />');
document.write('<param name="movie" value="'+nome+'" />');
document.write('<param name="quality" value="high" />');
document.write('<param name="menu" value="false" />');
document.write('<param name="wmode" value="transparent" />');
document.write('<embed src="'+nome+'" quality="high" menu="false" wmode="transparent" '+
' width="'+largura+'" height="'+altura+'" name="'+nome+'" align="middle"'+
' allowScriptAccess="always" allowfullscreen="true" type="application/x-shockwave-flash"'+
' pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write('</object>');
}

startNws=	'';
manOn		=	1;
MXnews	=	0;
function swManchete(id)
{
  if(manOn!='')
  {
    if(document.getElementById('spmanchete0'+manOn))
    {
      document.getElementById('spmanchete0'+manOn).style.display = 'none';
      document.getElementById('aman0'+manOn).style.backgroundColor = '#fff';
      document.getElementById('aman0'+manOn).style.color = '#000';
    }
  }
  if(id!='p'&&id!='a')
  {
    if(document.getElementById('spmanchete0'+id))
    {
      document.getElementById('spmanchete0'+id).style.display = '';
      document.getElementById('aman0'+id).style.backgroundColor = '#333';
      document.getElementById('aman0'+id).style.color = '#fff';
      manOn = id;
    }
  }
  else
  {
    if(id=='p')
    {
      if(manOn==MXnews)
        {var gto=1;}
      else
        {var gto=manOn+1;}
    }
    if(id=='a')
    {
      if(manOn==1)
        {var gto=MXnews;}
      else
        {var gto=manOn-1;}
    }
    if(document.getElementById('spmanchete0'+manOn))
    {
      document.getElementById('spmanchete0'+manOn).style.display = 'none';
      document.getElementById('aman0'+manOn).style.backgroundColor = '#fff';
      document.getElementById('aman0'+manOn).style.color = '#000';
    }
    if(document.getElementById('spmanchete0'+gto))
    {
      document.getElementById('spmanchete0'+gto).style.display = '';
      document.getElementById('aman0'+gto).style.backgroundColor = '#333';
      document.getElementById('aman0'+gto).style.color = '#fff';
      manOn = gto;
    }
  }
}


function rotateNews(id)
{
	if(document.getElementById('tanews'))
	{
		MXnews	=	document.getElementById('tanews').value;
		if(id==MXnews){id=MXnews;}
		if(id)
		{
			swManchete(id);
		}
			else
		{
			if(manOn==MXnews){id = 1;}else{id = manOn+1;}
		}
		swManchete(id);
		startNws	= setTimeout('rotateNews()',4000);
	}
}

function stopRotateNews(id)
{
	swManchete(id);
	clearTimeout(startNws);
}

function stopRotateNewsNav()
{
  swManchete(manOn);
	clearTimeout(startNws);
}

function restartRotatorNewsNav()
{
  rotateNews(manOn);
}

function restartRotatorNews(id)
{
  rotateNews(id);
}

startNws	= setTimeout('rotateNews(1)',4000);



posm	=	0;
rMenu	=	'';
cMenu	=	'';
function rollDown()
{
	if(posm<90)
	{
		posm=posm+10;
		document.getElementById('fmenu').style.height = posm+'px';
		rMenu	= setTimeout('rollDown()',10);
	}
	else
	{
		clearTimeout(rMenu);
	}
}


function desceMENU()
{
	clearTimeout(cMenu);
	var posa	=	document.getElementById('fmenu').offsetHeight;
	if(posa==0)
	{
		posm	=	0;
		rollDown();
	}
	else
	{
		document.getElementById('fmenu').style.height = '90px';
	}
}

function menuClose()
{
	document.getElementById('fmenu').style.height = '0px';
	clearTimeout(cMenu);
}

function sobeMENU()
{
	cMenu	= setTimeout('menuClose()',800);
}

function vtenq(nr)
{
	var error = 0;
	for(i=1;i<=nr;i++)
	{
		if(document.getElementById('idr'+i).checked==true){error++;}
	}

	if(error==0)
	{
		alert('Você deve selecionar ao menos uma resposta!');
	}
	else
	{
		//alert('Votando...');
		postAjax('frmsys','loader.php?module=blocos','ajenquete','&screen=enquete&votenow=1','');
	}

}

function vtagain()
{
	getAjax('loader.php?module=blocos','ajenquete','&screen=enquete','',0);
}

function respar()
{
	getAjax('loader.php?module=blocos','ajenquete','&screen=enquete&results=par','',0);
}

function validaContato()
{
  var erro = false;
  if(document.getElementById('nome_remetente').value==''){erro = true; alert('Informe seu nome'); return false;}
  if(document.getElementById('assunto').value==''){erro = true; alert('Selecione o assunto'); return false;}
  if(document.getElementById('email_remetente').value==''){erro = true; alert('Informe seu e-mail'); return false;}
  if(document.getElementById('mensagem_remetente').value==''){erro = true; alert('Digite sua mensagem'); return false;}
  if(document.getElementById('vcode').value==''){erro = true; alert('Digite o codigo de verificação'); return false;}
}

function dtkVid(id,opt)
{

  if(opt=='on')
  {
    document.getElementById('vid_'+id).style.borderColor        = '#cccccc';
    document.getElementById('vid_'+id).style.backgroundColor    = '#dadada';
    document.getElementById('tvid_'+id).style.borderColor       = '#cccccc';
    document.getElementById('ovid_'+id).style.backgroundColor   = '#ffffff';
    document.getElementById('spvid_'+id).style.display          = '';
  }

  if(opt=='off')
  {
    document.getElementById('vid_'+id).style.borderColor        = '#ffffff';
    document.getElementById('vid_'+id).style.backgroundColor    = '#ffffff';
    document.getElementById('tvid_'+id).style.borderColor       = '#ffffff';
    document.getElementById('spvid_'+id).style.display          = 'none';
    document.getElementById('ovid_'+id).style.backgroundColor   = '';
  }

}

function gotoMFpage(cod,offset)
{
	getAjax('loader.php?module=blocos','minifotos','&screen=mfotos&cod='+cod+'&offset='+offset+'','Carregando...',0);
}

function opgft(cod,codf)
{
	abreGaleria(700,cod,codf);
}

function showClose()
{
	document.getElementById('btf').style.display				= '';
	document.getElementById('btfd').style.display				= '';
	document.getElementById('cRBgal').style.display			= '';
	document.getElementById('cLBgal').style.display			= '';
	document.getElementById('cBtGal').style.display			= '';
}
function hideClose()
{
	document.getElementById('btf').style.display				= 'none';
	document.getElementById('btfd').style.display				= 'none';
	document.getElementById('cRBgal').style.display			= 'none';
	document.getElementById('cLBgal').style.display			= 'none';
	document.getElementById('cBtGal').style.display			= 'none';

}


/*GALERIA FADE*/


function abreGaleria(larguraConteudo,cod,codfoto,src)
{
	//Aqui pegamos as dimensões da tela USÁVEL do browser
	if(document.body.scrollHeight<document.documentElement.clientHeight)
	{var alturaTela	= document.documentElement.clientHeight;}
	else
	{var alturaTela	= document.body.scrollHeight+12;}
	var larguraTela = document.documentElement.clientWidth;

	//Aqui definimos o tamanho da div com o FADE de acordo com a dimensões obtidas anteriormente
	document.getElementById('efeitoTransp').style.height				  = alturaTela+'px';
	document.getElementById('efeitoTransp').style.width					  = larguraTela+'px';

	//Aqui mostramos a galeria mudando o estado 'none' do style display:none ( ou seja mostramos a dita cuja )
	document.getElementById('efeitoTransp').style.display         = '';
	document.getElementById('conteudoGaleria').style.display		  = '';
	document.getElementById('aGala').style.display		            = '';

	//Aqui centralizamos a DIV com o conteúdo na tela
	var base  = screen.availWidth/2;
	var temp	= base - (larguraConteudo /2);
	//document.getElementById('conteudoGaleria').style.left				= temp+'px';
	document.getElementById('aGala').style.left				          = temp+'px';
  //location.hash = 'topo';
	scroll(0,0);
  //getAjax('ajaxgal','ajgal','&cod='+cod+'&src='+src+'&img=','');
	getAjax('loader.php?module=files','ajgal','&screen=ajaxgal&cod='+cod+'&imgcod='+codfoto+'','Carregando...',0);
	//document.getElementById('se').style.display		= 'none';
}


function fechaGaleria()
{
	//Aqui mostramos a galeria mudando o estado '' do style display: ( ou seja escondemos a dita cuja )
	document.getElementById('efeitoTransp').style.display				= 'none';
	document.getElementById('conteudoGaleria').style.display		= 'none';
	document.getElementById('aGala').style.display		          = 'none';
	document.getElementById('ajgal').innerHTML		              = '';
	//document.getElementById('se').style.display                 = '';
}

function prevPICS()
{
	var OFFSET_ATUAL	= parseInt(document.getElementById('offsetatual').value);
	var OFFSET_MAX		= parseInt(document.getElementById('offsetmax').value);
	var COD_GALERIA		= parseInt(document.getElementById('codigo_galeria').value);
	var COD_IMAGEM		= parseInt(document.getElementById('codigo_imagem_galeria').value);

	if(OFFSET_ATUAL==0)
	{
		alert('Não existem fotos anteriores a estas!');
	}
	else
	{
		if((OFFSET_ATUAL-1)>=0)
		{
			var PREV = OFFSET_ATUAL-1;
		}
		else
		{
			var PREV = 0;
		}
		//alert(PREV);
		getAjax('loader.php?module=files','intSLIDER','&screen=slider_gal&cod='+COD_GALERIA+'&offset='+PREV+'','Carregando...',0);
	}

}
function nextPICS()
{
	var OFFSET_ATUAL	= parseInt(document.getElementById('offsetatual').value);
	var OFFSET_MAX		= parseInt(document.getElementById('offsetmax').value);
	var COD_GALERIA		= parseInt(document.getElementById('codigo_galeria').value);
	var COD_IMAGEM		= parseInt(document.getElementById('codigo_imagem_galeria').value);

	if(OFFSET_ATUAL==OFFSET_MAX)
	{
		alert('Não existem fotos posteriores a estas!');
	}
	else
	{
		if((OFFSET_ATUAL+1)<=OFFSET_MAX)
		{
			var NEXT = OFFSET_ATUAL+1;
		}
		else
		{
			var NEXT = OFFSET_MAX;
		}
		//alert(NEXT);
		getAjax('loader.php?module=files','intSLIDER','&screen=slider_gal&cod='+COD_GALERIA+'&offset='+NEXT+'','Carregando...',0);
	}

}

function navPHOTO(cdf,cg,gto)
{
	var nof='';
	if(gto!='')
	{
		nof = document.getElementById('fotoatual').value;
	}
	getAjax('loader.php?module=files','mainGGALINT','&screen=bigfoto&cdf='+cdf+'&nof='+nof+'&gto='+gto+'&cg='+cg+'','',0);
}

function downloadFoto(path){
  if(document.getElementById('fotoatual'))
  {
   var galeria_cod = document.getElementById('codigo_galeria').value;
   var foto_nome   = document.getElementById('fotoatual').value;
   window.location = path+'downloadpic.php?cdg='+galeria_cod+'&nf='+foto_nome+''
  }
}


function validaPromo()
{
  var erro = false;
  if(document.getElementById('resposta').value=='')			{erro = true; alert('Digite a resposta'); return false;}
  if(document.getElementById('nome').value=='')					{erro = true; alert('Digite o seu nome completo'); return false;}
  if(document.getElementById('email').value=='')				{erro = true; alert('Digite o seu e-mail'); return false;}
  if(document.getElementById('telefone').value=='')			{erro = true; alert('Digite o seu(s) telefone(s)'); return false;}
  if(document.getElementById('dtnascimento').value=='')	{erro = true; alert('Digite sua data de nascimento'); return false;}
  if(document.getElementById('cidade').value=='')				{erro = true; alert('Digite a sua cidade'); return false;}
  if(document.getElementById('identidade').value=='')		{erro = true; alert('Digite seu RG (Identidade)'); return false;}
}

function addcart()
{
	//verifica itens adicionais
	if(document.getElementById('cdopcao'))
	{
		var opcao					= document.getElementById('cdopcao').value;
		if(opcao==''){alert('Selecione uma opção!'); return false;}

	}
		var quantidade		=	document.getElementById('qtdi').value;
		var codigoproduto	=	document.getElementById('coditem').value;
		if(quantidade==''){alert('Informe a quantidade!'); return false;}

		//document.getElementById('cartstore').style.display = '';

		getAjax('loader.php?module=blocos','intcart','&screen=update-cart&coditem='+codigoproduto+'&cdopcao='+opcao+'&qtdi='+quantidade+'','',0);
}

/**
 *
 * @access public
 * @return void
 **/
function cleanCart()
{
  	getAjax('loader.php?module=blocos','intcart','&screen=update-cart&doit=clencart','',0);
}


/**
 *
 * @access public
 * @return void
 **/
function removeItemCart(nitem){
  var confirma = false;
  confirma = confirm('Confirma remoção do item?');
  if(confirma)
  {
  getAjax('loader.php?module=blocos','intcart','&screen=update-cart&doit=remitem&item='+nitem+'','',0);
  }
}

/**
 *
 * @access public
 * @return void
 **/
bigImage = '';
function swImGp(path,img){
  bigImage     = img;
  var theimage = "url("+path+"image.php?fotos/loja/"+img+"-180x220)";
  document.getElementById('ftipromo').style.backgroundImage = theimage
}


/**
 *
 * @access public
 * @return void
 **/
function showBigImage(path,img){
  //pega a imagem corrente

  if(bigImage=='')
  {
   bigImage = img;
  }

  if(bigImage!='')
  {
	var vUrl = path+'lojaimg.php?img='+bigImage+'';
	var vName = "_toview";
	var vPosFimX = 500;
	var vPosFimY = 400;
	var vArgumentos = "scrollbars=no,status=no,resizable=no,scrollbars=no,status=no";
	vPosIniX=((screen.availWidth/2)-(vPosFimX/2));
  	vPosIniY=((screen.availHeight/2)-(vPosFimY/2));
  	window.open(vUrl,vName,''+vArgumentos+',top='+vPosIniY+',left='+vPosIniX+',width='+vPosFimX+',height='+vPosFimY+'');
  }
}

function updateCart(){
  document.getElementById('formcart').submit();
}


function processCart(){
  document.getElementById('fpagseguro').submit();
}
