//Site
var tmpTempo
function selecionaAtendente(atendente, lista, formulario) {
	var campo = document.getElementById(lista)
	campo.options[campo.selectedIndex].value=atendente;
	campo.options[campo.selectedIndex].text=atendente;
	
	document.getElementById(formulario).submit();
}
function selecionasecao(codsec,nomsec,lista,formulario) {
	var campo = document.getElementById(lista)
	campo.options[campo.selectedIndex].value=codsec;
	campo.options[campo.selectedIndex].text=nomsec;
	
	document.getElementById(formulario).submit();
}

imagem_lista = Array('filmes_menu.png', 'banner_titulo.png', 'menu_fundo.jpg');
		imagem_qtd = imagem_lista.length;
		for (i = 0; i <imagem_qtd; i++) {
			var preload = new Image();
			preload.src = imagem_lista[i];
		} 	

		
function addSWF (URL, WIDTH, HEIGHT, TRANSPARENT)
{
document.write (' <object classid="clsid:27CDB6E-AE6D-11cf-96B8-444553540000" ');
document.write (' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"  name="'+URL+'" id="'+URL+'" ');
document.write (' width="'+ WIDTH +'" height="'+ HEIGHT +'">');
document.write (' <param name="movie" value="'+ URL +'" />');
document.write (' <param name="quality" value="high" />');

if ( TRANSPARENT ) {
  document.write (' <param name="Wmode" value="Transparent" />'); 
}

document.write (' <embed src="'+ URL +'" quality="high"  name="'+URL+'" id="'+URL+'" ');

if ( TRANSPARENT ) {
document.write (' Wmode = "transparent" ');
}

document.write (' pluginspage="http://www.macromedia.com/go/getflashplayer" ');
document.write (' type="application/x-shockwave-flash" width="'+ WIDTH +'" height="'+ HEIGHT +'"></embed> ');
document.write (' </object>');

}



function GetXmlHttpObject()	{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest) {
		objXMLHttp=new XMLHttpRequest()	}
	else if (window.ActiveXObject)	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")	}
	return objXMLHttp
} 		

function CriticaEnter(event, valor) { 
	if (event.keyCode==13 || event.which==13) {
		document.getElementById(valor).submit()
	}
	

}
function muda_menu(txt)	{
	
	if (document.getElementById(txt).className=='nivel_inativo') {	
		document.getElementById(txt).className='niveldois_ativo'	
	}
	else {
		document.getElementById(txt).className='nivel_inativo'
	}
}

function mudalink(txt,txt2)	{
	
	if (document.getElementById(txt).className=='link1Ativo') {	
		document.getElementById(txt).className='linkInativo'	
		document.getElementById(txt2).className='link2Ativo'	
	}
	else {
		document.getElementById(txt).className='link1Ativo'
		document.getElementById(txt2).className='linkInativo'

	}
}
function sugestao(x) {
		if (document.getElementById(x).className=='ativo') {
			document.getElementById(x).className='inativo'
		}
		else  {
			document.getElementById(x).className='ativo'
		}
}

function abrir(){
	janela=window.open(url,"","width=400,height=400,left=30,top=350,scrollbar=1,resizable=1,status=0,menubar=0");
	//interceptacao de erro na abertura da janela
	text = "Se a janela nao estava abrindo\ntalvez seja porque você tenha um\nprograma bloqueador de pop-up!\nObservacao » O windows XP service pack 2\nbloqueia pop-ups!";
	if(janela == null) { alert(text); return; }
	//fim
	} 

function abrir2(){
	janela=window.open(url,"","width=600,height=400,left=30,top=350,scrollbar=1,resizable=1,status=0,menubar=0");
	//interceptacao de erro na abertura da janela
	text = "Se a janela nao estava abrindo\ntalvez seja porque você tenha um\nprograma bloqueador de pop-up!\nObservacao » O windows XP service pack 2\nbloqueia pop-ups!";
	if(janela == null) { alert(text); return; }
	//fim
	} 

function abrir3(){
	janela=window.open(url,"","width=500,height=420,left=380,top=280,scrollbar=1,resizable=1,status=0,menubar=0");
	//interceptacao de erro na abertura da janela
	text = "Se a janela nao estava abrindo\ntalvez seja porque você tenha um\nprograma bloqueador de pop-up!\nObservacao » O windows XP service pack 2\nbloqueia pop-ups!";
	if(janela == null) { alert(text); return; }
	//fim
	} 
	
	
function CestadeCompras(CodigoCli, FilPRD, CodigoPrd, Operacao, conf,qtd, datped, seqped) { 
		clearTimeout(tmpTempo)
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
		alert ("Seu navegador não dá suporte a HTTP Request")
		return	} 
		var dt = new Date();
		var url = "adic_pedido.asp?codcliseq="+ CodigoCli+"&filprd="+FilPRD+"&codprd="+CodigoPrd+"&opr="+Operacao+"&conf="+conf+"&Qtde="+qtd+"&w_datped="+datped+"&w_seqped="+seqped+"&Data="+encodeURI("_" + dt.getTime())
		xmlHttp.onreadystatechange=stateChangedCompras 

		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
		tmpTempo = setTimeout("CestadeCompras('"+CodigoCli+"','F','0', 'A','"+conf+"','1')",4000)
}

function stateChangedCompras() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
	document.getElementById("ListFilmeOnline").innerHTML=xmlHttp.responseText
	if (document.getElementById('bx_tempd').value=='n') { 
		document.getElementById('OBS_inputchat').innerHTML=''
		if (document.getElementById('chat_control').className=='exibe'){ 
		window.a.reload()
		}
		document.getElementById('chat_control').className='some'
	} else { 
		if (document.getElementById('bx_temate').value=='s') { 
			document.getElementById('OBS_inputchat').innerHTML='Converse online com o atendente'
			document.getElementById('chat_control').className='exibe'
			document.getElementById('chat_msg').scrollTop = document.getElementById('chat_msg').scrollHeight }
		else { 
			document.getElementById('OBS_inputchat').innerHTML='Aguarde, em breve você será atendido'
			 document.getElementById('chat_control').className='some'
		}
		//document.getElementById('chat_msgcomp').focus()
	}
	//Firefox ->>
	//I.E
	//document.getElementById('chat_msg').scrollTop = 9999999999;
	//Drag.init(document.getElementById("ListFilmeOnline"));
	
	} 
} 	

function GetXmlHttpObject()	{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest) {
		objXMLHttp=new XMLHttpRequest()	}
	else if (window.ActiveXObject)	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")	}
	return objXMLHttp
} 		

function CestadeComprasLST(CodigoCli, FilPRD, CodigoPrd, Operacao, conf, qtd, datped, seqped, dia,hora_ini,hora_fin,taxa) {
		clearTimeout(tmpTempo)
		document.getElementById("ListFilmeOnline").innerHTML=''
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
		alert ("Seu navegador não dá suporte a HTTP Request")
		return	} 
		var dt = new Date();
		var url = "adic_pedido.asp?codcliseq="+ CodigoCli+"&filprd="+FilPRD+"&codprd="+CodigoPrd+"&opr="+Operacao+"&conf="+conf+"&Qtde="+qtd+"&w_datped="+datped+"&w_seqped="+seqped+"&dia="+dia+"&hora_ini="+hora_ini+"&hora_fin="+hora_fin+"&taxa="+taxa+"&Data="+encodeURI("_" + dt.getTime())
		xmlHttp.onreadystatechange=stateChangedComprasLST 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
		if (conf=='' || conf=='ConfUsu' || conf=='alugar' || conf=='sobcompra' || conf=='emlista' || conf=='emlistaloc' || conf=='TelaPedido1' || conf=='EncerrarPedido' || conf=='ReabrirPedido' || conf=='QueroReabrir') { 
			tmpTempo = setTimeout("CestadeCompras('"+CodigoCli+"','F','0','D','','1')",4000)
		}
		if (conf=='EncerrarPedido') {
			document.getElementById('OBS_inputchat').innerHTML=''
			document.getElementById('chat_control').className='some'
			clearTimeout(tmpTempo)
		}
		if (conf=='FechaPedido' || conf=='GravaPedido') { 
			tmpTempo = setTimeout("CestadeCompras('"+CodigoCli+"','F','0','D','FechaPedido','1')",4000)
			if (conf=='GravaPedido') { 
				document.getElementById('menuEsquerdo').className='some'
				document.getElementById('menuEsquerdoBloq').className='exibe'
				document.getElementById('BoxPropE').className='some'
				window.parent.document.getElementById('logotipo').className='some'
				window.parent.document.getElementById('logotipobloq').className='exibe'
				
			}
		}
		if (conf=='sim' && Operacao=='D') { 
			CestadeCompras(CodigoCli,'F','0','D','','1')
		}
}
function DesbloquearMenu() { 
	window.a.document.getElementById('menuEsquerdo').className='exibe'
	window.a.document.getElementById('menuEsquerdoBloq').className='some'
	window.a.document.getElementById('BoxPropE').className='exibe'
	window.parent.document.getElementById('logotipo').className='exibe'
	window.parent.document.getElementById('logotipobloq').className='some'
}
function stateChangedComprasLST() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
	document.getElementById("ListFilmeOnline").innerHTML=xmlHttp.responseText 
	document.getElementById("ListFilmeOnline").className='exibe'
	//Drag.init(document.getElementById("ListFilmeOnline"));
	if (document.getElementById('bx_tempd').value=='n') { 
		document.getElementById('OBS_inputchat').innerHTML=''
		 document.getElementById('chat_control').className='some'
	} else { 
		if (document.getElementById('bx_temate').value=='s') { 
			document.getElementById('OBS_inputchat').innerHTML='Converse online com o atendente'
			document.getElementById('chat_control').className='exibe' }	
		else { 
			document.getElementById('OBS_inputchat').innerHTML='Aguarde, em breve você será atendido'
			 document.getElementById('chat_control').className='some'
		}
		//document.getElementById('chat_msgcomp').focus()		
		}
	} 
} 	

function Incluirnalista(CodigoCli, FilPRD, CodigoPrd, Operacao, conf, qtd) {
		clearTimeout(tmpTempo)
		document.getElementById("ListFilmeOnline").innerHTML=''
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
		alert ("Seu navegador não dá suporte a HTTP Request")
		return	} 
		var dt = new Date();
		var url = "adic_pedido.asp?codcliseq="+ CodigoCli+"&filprd="+FilPRD+"&codprd="+CodigoPrd+"&opr="+Operacao+"&conf="+conf+"&Qtde="+qtd+"&Data="+encodeURI("_" + dt.getTime())
		xmlHttp.onreadystatechange=stateChangedIncluirLista
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
		if (conf=='sim' && Operacao=='D') { 
			CestadeCompras(CodigoCli,'F','0','D','','1')
		}
}
function stateChangedIncluirLista() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
	document.getElementById("ListFilmeOnline").innerHTML=xmlHttp.responseText 
	window.alert(document.getElementById('alert_msginc').value)
	} 
} 	
function selecionaHora(CodigoCli,FilPRD,CodigoPrd,Operacao,conf,qtd,dia,hora_ini,hora_fin,datped,seqped) { 
		document.getElementById("ListFilmeOnline").innerHTML=''
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
		alert ("Seu navegador não dá suporte a HTTP Request")
		return	} 
		var dt = new Date();
		if (dia==''||hora_ini==''||hora_fin=='') {
			
			var url = "selec_hora.asp?codcliseq="+CodigoCli+"&filprd="+FilPRD+"&codprd="+CodigoPrd+"&opr="+Operacao+"&conf="+conf+"&Qtde="+qtd+"&dia="+dia+"&hora_ini="+hora_ini+"&hora_fin="+hora_fin+"&w_datped="+datped+"&w_seqped="+seqped+"&Data="+encodeURI("_" + dt.getTime())
			xmlHttp.onreadystatechange=stateChangedHorasLST 
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)
			
			} else {
				if ((conf=='alugar'  || conf=='sobcompra') || (conf=='sim' && Operacao=='D') || (conf=='altHora' && Operacao=='H')  ) { 
					document.getElementById('ListFilmeOnline').className='some'
					window.a.CestadeComprasLST(CodigoCli, FilPRD, CodigoPrd, Operacao, conf, qtd,datped,seqped,dia,hora_ini,hora_fin)
				} else {
				CestadeComprasLST(CodigoCli, FilPRD, CodigoPrd, Operacao, conf, qtd,datped,seqped,dia,hora_ini,hora_fin) }
				//var pagina_util = window.a.location 
				//window.a.location='pedidos.asp'
				this.className='some'
			}
}
function stateChangedHorasLST() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
	document.getElementById("ListFilmeOnline").innerHTML=xmlHttp.responseText 
	document.getElementById("ListFilmeOnline").className='exibe'
	//Drag.init(document.getElementById("ListFilmeOnline"));
	} 
} 	
function alteraQtde(CodigoCli,FilPRD,CodigoPrd,Operacao,conf,qtd,datped,seqped) { 
		document.getElementById("ListFilmeOnline").innerHTML=''
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
		alert ("Seu navegador não dá suporte a HTTP Request")
		return	} 
		var dt = new Date();
		var url = "altera_quantidade.asp?codcliseq="+CodigoCli+"&filprd="+FilPRD+"&codprd="+CodigoPrd+"&opr="+Operacao+"&conf="+conf+"&Qtde="+qtd+"&w_datped="+datped+"&w_seqped="+seqped+"&Data="+encodeURI("_" + dt.getTime())
		xmlHttp.onreadystatechange=stateChangedAltQtd
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
}
function stateChangedAltQtd() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
	document.getElementById("ListFilmeOnline").innerHTML=xmlHttp.responseText 
	document.getElementById("ListFilmeOnline").className='exibe'
	
	//Drag.init(document.getElementById("ListFilmeOnline"));
	} 
} 	
function FiltrarHoras(lista,horario_ini,horario_fin,data,dia_escolhido,dia_hoje,msg_diaescolhida) { 
	var temp_horario = document.getElementById(lista).options[document.getElementById(lista).selectedIndex].value;
	var posicaoBarra = temp_horario.indexOf("|")
	document.getElementById(horario_ini).value = temp_horario.substring(0,posicaoBarra)
	document.getElementById(horario_fin).value = temp_horario.substring(posicaoBarra+1)
	document.getElementById(data).value		   = dia_escolhido
	var Mensagem = 'Agendado para '+msg_diaescolhida+' das '+temp_horario.substring(0,posicaoBarra-3)+' às '+temp_horario.substring(posicaoBarra+1,posicaoBarra+6)
	document.getElementById('mensagem_data').innerHTML = Mensagem	
}
function CriticaQuantidade(CodigoCli, FilPRD, CodigoPrd, Operacao, conf, qtd, datped, seqped, dia,hora_ini,hora_fin,taxa) { 
		if (qtd==0 || qtd<=0) { 
			alert("Não aceita quantidade Zero")
			return false;
		} else { 
			CestadeComprasLST(CodigoCli, FilPRD, CodigoPrd, Operacao, conf, qtd, datped, seqped, dia,hora_ini,hora_fin,taxa)
			window.parent.document.getElementById('ListFilmeOnline').className="some"
			tmpTempo = setTimeout("CestadeCompras('"+CodigoCli+"','F','0','D','','1')",4000)	

		}

}
/*function MostraValorServ(valor,SomaIni, SomaFin) { 
	if (document.getElementById('tipoServico').value=='s' || document.getElementById('tipoServico').value=='n') { 
		if (document.getElementById('checkServ').checked==true) { 
			document.getElementById('valorServ').value = valor
			document.getElementById('vlrSoma').value=SomaFin
		} else { 
			document.getElementById('valorServ').value='0,00' 
			document.getElementById('vlrSoma').value=SomaIni
		}
	}

}*/
function MostraValorServ(taxserv,somaitens,soma_tot) { 
	if (document.getElementById('pag_tipoServico').value=='s' || document.getElementById('pag_tipoServico').value=='n') { 
		if (document.getElementById('pag_checkServ').checked==true) { 
			document.getElementById('pag_valorServ').value = taxserv
			document.getElementById('totalSoma').value = soma_tot
		} else { 
			document.getElementById('pag_valorServ').value='0,00' 
			document.getElementById('totalSoma').value = somaitens
		}
	}

}
function cadastraKEYCHATMSG(event,mensagem,codcli,datped,seqped,operador) {  
	if (event.keyCode==13 || event.which==13) {
	cadastraCHATMSG(mensagem,codcli,datped,seqped,operador)
	window.a.document.getElementById('chat_msgcomp').value=''
	window.a.document.getElementById('chat_msgcomp').focus()
	}
}
function cadastraCHATMSG(mensagem,codcli,datped,seqped,operador) { 
		document.getElementById("ListFilmeOnline").innerHTML=''
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
		alert ("Seu navegador não dá suporte a HTTP Request")
		return	} 
		mensagem = mensagem.replace(/'/g,"''")
		var dt = new Date();
		var url = "cad_chatmsg.asp?msg="+mensagem+"&codcli="+codcli+"&w_datped="+datped+"&w_seqped="+seqped+"&operador="+operador+"&DataCtr="+encodeURI("_" + dt.getTime())
		xmlHttp.onreadystatechange=stateChangedChat
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
		document.getElementById("ListFilmeOnline").className='some'
}
function stateChangedChat() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
	document.getElementById("ListFilmeOnline").innerHTML=xmlHttp.responseText 
	window.a.document.getElementById("chat_msgcomp").focus()
	//Drag.init(document.getElementById("ListFilmeOnline"));
	
	} 
} 	

function CestadeComprasPag(CodigoCli, SeqPed, DataPed, Secao,VlrPag1, VlrPag2, VlrPag3, VlrPag4, VlrPag5, VlrPag6, VlrPag7, Obs, txServ, somaItens, usaTaxa) { 
		clearTimeout(tmpTempo)
		document.getElementById("PagFilmeOnline").innerHTML=''
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
			alert ("Seu navegador não dá suporte a HTTP Request")
			return	} 
		var dt = new Date();
		var url = "pagamento.asp?seq="+SeqPed+"&codusu="+CodigoCli+"&data="+DataPed+"&Secao="+Secao+"&VlrPag1="+VlrPag1+"&VlrPag2="+VlrPag2+"&VlrPag3="+VlrPag3+"&VlrPag4="+VlrPag4+"&VlrPag5="+VlrPag5+"&VlrPag6="+VlrPag6+"&VlrPag7="+VlrPag7+"&Obs="+Obs+"&txServ="+txServ+"&somaItens="+somaItens+"&usaTaxa="+usaTaxa+"&DataCtr="+encodeURI("_" + dt.getTime())
		xmlHttp.onreadystatechange=stateChangedComprasPag
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
}
function stateChangedComprasPag() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("PagFilmeOnline").innerHTML=xmlHttp.responseText 
		document.getElementById("PagFilmeOnline").className='exibe' 
		if (document.getElementById("secao").value=="alterado") { 
			tmpTempo = setTimeout("window.a.CestadeCompras('"+document.getElementById('pag_codcli').value+"','','','A','','')",3000)
			document.getElementById("PagFilmeOnline").className='some' 
		}
	} 
} 	
function lembrasenha(email) { 
	var cEmail = email
	if (cEmail=='') { 
		alert('Preencha campo Email para visualizar o lembrete')
	}
	if (cEmail!='') { 
		window.location='login_cli.asp?email='+cEmail
	}
}
	
