function getPopPortfolio(cod)
{
	w = screen.width;
	h = screen.height - 50;
	window.open('clientes_lista_eventos_thumb.asp?w=' + screen.width + '&h=' + screen.height + '&galeria=' + cod,'_blank','scrollbars=yes,resizible=no,toolbar=no,location=no,status=no,menubar=no,width=' + w + ',height=' + h + ',top=1,left=1')
}
function setDivPreview(fl_show,divId,rc) {
	for(x=1;x<=rc;x++) {
		document.getElementById('divPreview' + x).style.display='none';
	}
	
	objDiv = document.getElementById('divPreview' + divId);
	if(fl_show==1) {
		objDiv.style.display = '';
		W = parseInt(objDiv.style.width.replace("px",""));
		H = parseInt(objDiv.style.height.replace("px",""));
		objDiv.style.top = Math.round(tempY - (H/2)) + 'px';
		objDiv.style.left = Math.round(tempX - (W/2)) + 'px';
	}
}
function getPopPapelParede(cod,l,a)
{
	window.open(cod,'_blank','scrollbars=yes,resizible=yes,toolbar=no,location=no,status=no,menubar=no,width=' + l + ',height=' + a + ',top=1,left=1');
}
function getContent(scr,nome_div) {
	var ni = document.getElementById('page1');
	var newIframe = document.createElement('iframe');
	newIframe.setAttribute('id','iframe'+scr);
	newIframe.setAttribute('name','iframe'+scr);
	newIframe.setAttribute('src','scripts/get'+scr+'.asp?obj=' + nome_div);
	newIframe.style.display='none';
	ni.appendChild(newIframe);

}
function submitenter(myfield,formid,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if (keycode == 13)
	{
   		document.getElementById(formid).submit();
	   	return false;
   	}
	else
   		return true;
}
function setSubmitBuscaGaleria(myfield,e,rc)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if (keycode == 13)
	{
   		getListaeventos(1,document.formulario.TxBusca.value,document.formulario.InCdCliente.value,rc)
	   	return false;
   	}
	else
   		return true;
}
function getPopPedidoDetalhes(InCdPedido) {
	w = 791;
	h = 590;
	var l = (screen.width - w) / 2;
	var t = (screen.height - h - 60) / 2;
	window.open('clientes_lista_eventos_pedidos_detalhes.asp?InCdpedido=' + InCdPedido,'_blank','scrollbars=yes,resizible=no,toolbar=no,location=no,status=yes,menubar=no,width=' + w + ',height=' + h + ',top=' + t + ',left=' + l);
}
function setPedidoCancelar(InCdPedido) {
	if(confirm('Você tem certeza que deseja cancelar este pedido em aberto?'))
		document.location.href='clientes_lista_eventos_pedidos.asp?acao=Cancelar&InCdPedido=' + InCdPedido
}
function setPedidoContinuar(InCdPedido) {
	w = screen.width;
	h = screen.height - 50;
	window.open('clientes_lista_eventos_pedidos.asp?acao=Continuar&InCdPedido='+ InCdPedido,'_blank','scrollbars=yes,resizible=no,toolbar=no,location=no,status=no,menubar=no,width=' + w + ',height=' + h + ',top=1,left=1')
	window.close();
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
function replaceAll(string, token, newtoken) {
	while (string.indexOf(token) != -1) {
 		string = string.replace(token, newtoken);
	}
	return string;
}
function getListaeventos(pagina,txBusca,inCdCliente,BoMostracliente,BoPrimeiro,InAno) {
	
	if(!InAno) {
		InAno='';
	}
	if(InAno!='') {
		if(document.getElementById('td_grid_eventos' + InAno)) {
			if(document.getElementById('td_grid_eventos' + InAno).style.display == 'none' && document.getElementById('td_grid_eventos' + InAno).innerHTML != '') {
				document.getElementById('td_grid_eventos' + InAno).style.display = '';
				if(InAno!='')
					document.getElementById('lbl'+InAno).style.display='none';
				return false;
			}
			else if(document.getElementById('td_grid_eventos' + InAno).innerHTML != '') {
				document.getElementById('td_grid_eventos' + InAno).style.display = 'none';
				if(InAno!='')
					document.getElementById('lbl'+InAno).style.display='';
				return false;
			}
			else {
				document.getElementById('lbl'+InAno).style.display='none';
			}
		}
	}
		
	if(document.formulario) {
		if(txBusca=='') document.formulario.TxBusca.value='';
		if(inCdCliente=='') document.formulario.InCdCliente.value='';
	}
	var de = document.documentElement;
    var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
    var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight
	document.getElementById('divAguarde').style.display = '';
	document.getElementById('divAguarde').style.top = h/2;
	document.getElementById('divAguarde').style.left = w/2 - 50;
	if(!BoPrimeiro)document.location.href='#topo'+InAno;
	
	var ni = document.getElementById('content');
	var newIframe = document.createElement('iframe');
	newIframe.setAttribute('id','iframe'+InAno);
	newIframe.setAttribute('name','iframe'+InAno);
	newIframe.setAttribute('src','scripts/getListaeventos.asp?InAno=' + InAno + '&id=td_grid_eventos' + InAno + '&BoMostracliente=' + BoMostracliente + '&pagina=' + pagina + '&TxBusca=' + txBusca + '&InCdcliente=' + inCdCliente);
	newIframe.style.display='none';
	ni.appendChild(newIframe);
	
	return false;
	
}
function hideDivAguarde() {
	document.getElementById('divAguarde').style.display = 'none';
}
function getGaleriaCliente(cod,pagina,TxAssunto)
{
	if(pagina=='lista_eventos_thumb' || pagina == 'lista_eventos_carrinho') {
		w = parseInt(screen.availWidth)-15;
		h = parseInt(screen.availHeight)-35;
		l = 1;
		t = 1;
	}
	else {
		w = 780;
		h = 533;
		var l = (screen.width - w) / 2;
		var t = (screen.height - h - 60) / 2;
	}
	if(!TxAssunto)TxAssunto='';

	window.open('clientes_' + pagina + '.asp?w=' + w + '&h=' + h + '&galeria=' + cod + '&TxGaleria=' + TxAssunto,'_blank','scrollbars=yes,resizible=yes,toolbar=no,location=no,status=no,menubar=no,width=' + w + ',height=' + h + ',top='+t+',left='+l)
}
function getPopNegativos(InCdGaleria)
{
	w = 539;
	h = 400;
	var l = (screen.width - w) / 2;
	var t = (screen.height - h - 60) / 2;
	window.open('clientes_negativos.asp?cod=' + InCdGaleria,'_blank','scrollbars=yes,resizible=no,toolbar=no,location=no,status=yes,menubar=no,width=' + w + ',height=' + h + ',top=' + t + ',left=' + l);
}
function getPopCompartilhar(InCdGaleria,TxOrigem)
{
	w = 539;
	h = 550;
	var l = (screen.width - w) / 2;
	var t = (screen.height - h - 60) / 2;
	window.open('compartilhar.asp?InCdGaleria=' + InCdGaleria + '&TxOrigem=' + TxOrigem,'_blank','scrollbars=yes,resizible=no,toolbar=no,location=no,status=yes,menubar=no,width=' + w + ',height=' + h + ',top=' + t + ',left=' + l);
}
function setLogoff(origem) {
	if(!origem)origem='';
	BoPedido = 0;
	if(readCookie('pedido')) {
		arrPedido = readCookie('pedido').split(',');
		for(i=0;i<=arrPedido.length;i++) {
			if(readCookie('pedido'+arrPedido[i]))
				BoPedido = 1;
		}
	}
	if(BoPedido==1) {
		if(confirm('Você possui um pedido pendente que não foi enviado.\nTem certeza que deseja sair?'))
			document.location.href='clientes_logoff.asp?origem='+origem;
			
	}
	else
		document.location.href='clientes_logoff.asp?origem='+origem;
}
function getPopCadastro(BoSomenteCadastro,TxNome,TxEmail)
{
	if(!BoSomenteCadastro) BoSomenteCadastro = 1;
	if(!TxNome) TxNome = '';
	if(!TxEmail) TxEmail = '';
	
	if(TxNome != '' && TxEmail != '') {
		var ni = document.getElementById('content');
		var newIframe = document.createElement('iframe');
		newIframe.setAttribute('id','iframe');
		newIframe.setAttribute('name','iframe');
		newIframe.setAttribute('src','clientes_lista_eventos_ficha.asp?BoSomenteCadastro='+BoSomenteCadastro+'&TxNome='+TxNome+'&TxEmail='+TxEmail);
		newIframe.style.display='none';
		ni.appendChild(newIframe);
	}
	else {
		w = 650;
		h = 650;
		var l = (screen.width - w) / 2;
		var t = (screen.height - h - 60) / 2;
		window.open('clientes_lista_eventos_ficha.asp?BoSomenteCadastro='+BoSomenteCadastro,'_blank','scrollbars=yes,resizible=no,toolbar=no,location=no,status=yes,menubar=no,width=' + w + ',height=' + h + ',top=' + t + ',left=' + l)
	}
}
function getFotoProduto() {
	document.getElementById('lbl_fotoproduto').style.display='none';
	document.getElementById('tab_fotoproduto1').style.display='none';
	document.getElementById('tab_fotoproduto2').style.display='';
}
function getPopEventoInfo()
{
	w = 600;
	h = 500;
	var l = (screen.width - w) / 2;
	var t = (screen.height - h - 60) / 2;
	window.open('eventos_informacoes.asp','_blank','scrollbars=yes,resizible=no,toolbar=no,location=no,status=yes,menubar=no,width=' + w + ',height=' + h + ',top=' + t + ',left=' + l);
}
