var menu_atual;
var sAgent = navigator.userAgent;

function exibeFader(b){	
	objFader = $('Fader');
	if (b == true){objFader.style.display = 'block';}else{objFader.style.display = 'none';}	
}

function getByFrame(frame,id){ return window.frames[frame].document.getElementById(id); }	
function $(id) { return document.getElementById(id); }
function _$(id) { return parent.document.getElementById(id); }

function habilitaComboBox(obj){
	if (obj != null){	
		obj.disabled = false;
	}
}

function desabilitaComboBox(obj){
	if (obj != null){
		obj.disabled = true;		
	}
}

function limpaCampo(txt,obj){
	if (txt == obj.value){
		obj.value= '';
	}
}
function showSubMenu(name,b){
	obj = $(name);
	if (obj != null){
		if (b){ display = 'block';} else{ display = 'none';}
		obj.style.display = display;
	}			
}

function ValidaLogin2(frm,id_obj,id_obj_loader) {
	if (frm.cd_login.value=="" || frm.cd_login.value == "Login") {
		alert("E-mail não foi informado")
		frm.cd_login.focus();
		return false;
	}
	if (frm.cd_senha.value=="" || frm.cd_senha.value == "Senha") {
		alert("Senha não foi informada")
		frm.cd_senha.focus();
		return false;
	}
	if ( ! ValidaEmail(frm.cd_login.value) ){
		alert("E-mail inválido");
		return false;			
	}else{
		exibeLoader(id_obj,id_obj_loader,true);
		return true;
	}	
}

function exibeLoader(id_obj,id_obj_loader,b){
	obj = $(id_obj);
	obj_loader = $(id_obj_loader);	
	if (b == true){
		obj.style.visibility = 'hidden';
		obj_loader.style.visibility = 'visible';	
		/*obj.style.display = 'none';
		obj_loader.style.display = 'block';		*/
	}else{
		obj.style.visibility = 'visible';
		obj_loader.style.visibility = 'hidden';
		/*obj_loader.style.display = 'none';		
		obj.style.display = 'block';		*/
	}	
}

function validaInsertNewsLetter(){
	email = replaceAll($('news_email').value," ","");	
	if (email == "" ){
		alert("E-mail não foi informado");
		$('news_email').value = "";
		$('news_email').focus();
		return false;			
	}else{
		if ( !ValidaEmail(email) ){
			alert("E-mail inválido");
			$('news_email').value = "";
			$('news_email').focus();
			return false;			
		}
		/* 1 - OK
		 2 - JÁ CADASTRADO NA BASE DE USUÁRIOS
		 3 - JÁ CADASTRADO NA BASE DE NEWSLETTER*/	
		result = SendRequestResponse("/custom/actions/insertNewsLetter.asp?email="+email);			
		switch(result)
		{
			case "2":
				$('mgs-generica-newsletter').innerHTML = 'O seu email já está cadastrado na base de usuários.';	
				$('mgs-generica-newsletter').style.display = 'block';	
				$('mgs-sucesso-newsletter').style.display = 'none';	
				break;
			case "3":
				$('mgs-generica-newsletter').innerHTML = 'O seu email já foi incluído na lista de promoções.';	
				$('mgs-generica-newsletter').style.display = 'block';	
				$('mgs-sucesso-newsletter').style.display = 'none';					
				break;
			case "1":
				$('mgs-generica-newsletter').style.display = 'none';	
				$('mgs-sucesso-newsletter').style.display = 'block';	
				break;
			default:
				alert("Erro ao cadastrar e-mail na lista de promoções.");
				return false;
		}		
		jQuery.fancybox.showActivity();		
		jQuery.fancybox.hideActivity();
		$('news_email').value = "";
		$('news_email').focus();
		return true;
	}
}

function ativaAba(obj,div_aba_ativa,cor_inativa,cor_ativa,altura_inativa,altura_ativa,id_obj_desc,div_desc_aba_ativa){			
	//pega o id da aba que está ativa
	id_ativa  =	document.getElementById(div_aba_ativa).innerHTML;	
	
	//pega o objeto
	obj_ativa = document.getElementById(id_ativa);			
	
	//desativa a aba que estava ativa
	obj_ativa.style.backgroundColor = "#"+cor_inativa;			
	obj_ativa.style.height = altura_inativa;
	
	//ativa a aba que foi clicada
	obj.style.backgroundColor = "#"+cor_ativa;			
	obj.style.height = altura_ativa;		
	
	//atualiza o span com a aba que está ativa
	document.getElementById(div_aba_ativa).innerHTML = obj.id;		
	
	//pega o id da aba desc que está ativa		
	id_desc_ativa  = document.getElementById(div_desc_aba_ativa).innerHTML;	
	
	//desativa a aba desc que estava ativa
	document.getElementById(id_desc_ativa).style.display = 'none';		
	
	//pega o objeto da aba desc que foi clicada
	obj_desc = document.getElementById(id_obj_desc);
	
	//ativa a aba desc que foi clicada
	obj_desc.style.display = 'block';
	
	//atualiza o span com a aba desc que está ativa
	document.getElementById(div_desc_aba_ativa).innerHTML = obj_desc.id;		
}


//COMEÇO CADASTRO
function ValidaDataNasc() {
	with(document.frmCadastro) {
		data_nasc.value = dia.value +'/' + mes.value + '/' + ano.value;
	}
}

function ValidaFormLocalPasso1(frm) {
	var erro = "";
	if (!ValidaFormJS(frm)) { return false;}
	
	email = frm.email.value.toLowerCase(); 
	
	if(frm.senha.value=="") {
		alert("Digite uma senha.");
		frm.senha.focus();
		return false;
	} else {	
		pwd_senha = replaceAll(frm.senha.value," ","");
		if (pwd_senha.length < 6) {
			alert("- Use uma senha com pelo menos 6 caracteres.\n");
			return false;
		}
		if (frm.confirma.value == "") 	{
			alert("- Confirme sua senha.\n");
			return false;
		} else if (frm.confirma.value != frm.senha.value) {
			alert("- A senha confirmada é diferente da senha digitada.\n");
			return false;
		}
	}
	
	if (validaCep(frm.cep) == false){		
		return false;
	}
	
	// verificar se o e-mail já existe na base chamar página via ajax /custom/actions/verificaloginexiste.asp?email=email
	var ret = SendRequestResponse("/custom/actions/verificaloginexiste.asp?email="+frm.email.value)	
	if (ret.toUpperCase() == "TRUE" ){
		alert("E-mail já cadastrado no sistema. Por favor, cadastre um novo.");
		frm.email.focus();
		return false;
	}
	
	return true; 	
}

function ValidaFormLocal(frm) {
	var erro = "";
	var b = true;
	if (!ValidaFormJS(frm)) {b = false;}
	
	if (b == true){
		
			//alert( isNaN( frm.CPF.value ) )
			if (frm.CPF.value != ""){
				if (!ValidaCPF(frm.CPF.value)) {
					
					alert(" - " + "CPF inválido!" + "\n");
					b = false;
					
				}else{
					
					// verificar se o CPF já existe
					var ret = SendRequestResponse("/custom/actions/verificacpfexiste.asp?cpf="+frm.CPF.value)	
					if (ret.toUpperCase() == "TRUE" ){
						alert("CPF já cadastrado no sistema.");
						frm.CPF.focus();
						b = false;
					}
					
				}
			}
			
		
	}

	
	// Teste do captcha
	/*try{

		if (frm.CaptchaStr.value==""){
			alert('- Digite o código de verificação.' );
			return false;
		}

		var captcha_ok; // verifico se os destinatarios encontram-se na base
		navegador_usuario = navigator.userAgent.toUpperCase();				
		if (navegador_usuario.indexOf("FIREFOX") == -1){ //BUG FIREFOX
			captcha_ok = getRequestSync("/custom/captcha/valida.asp?valor=" + frm.CaptchaStr.value );
			if (captcha_ok != "1") {
				alert('Código de verificação incorreto. Por favor digite-o novamente.');
				document.getElementById('captchaImg').innerHTML = ""
				document.getElementById('captchaImg').innerHTML = "<img src='/custom/captcha/CAPTCHA.asp?CaptchaType=2' width='200'>"
				return false;
			}
		}
	}catch(e){
		alert('Erro captcha:' + e.description )
	}*/  
	//return true; 	
	if (b == true){
		frm.submit();	
	}	
}

function ValidaFormLocalAtualizar(frm) {
	var erro = "";
	var b = true;
	if (!ValidaFormJS(frm)) {b = false;}
	
	if (b == true){
		
			//alert( isNaN( frm.CPF.value ) )
			if (frm.CPF.value != ""){
				if (!ValidaCPF(frm.CPF.value)) {
					
					alert(" - " + "CPF inválido!" + "\n");
					b = false;
					
				}else{
					
					// verificar se o CPF já existe
					var ret = SendRequestResponse("/custom/actions/verificacpfexistebyuser.asp?cpf="+frm.CPF.value)	
					if (ret.toUpperCase() == "TRUE" ){
						alert("CPF já cadastrado no sistema.");
						frm.CPF.focus();
						b = false;
					}
					
				}
			}
		
	}

	if (b == true){
		_$('form_cadastro_pop_fade').style.display = 'none';
		frm.submit();			
	}	
}

function parte2Cadastro(){		
	var form = document.getElementById('frmCadastro');
	if (ValidaFormLocalPasso1(form)){
		form.submit();
	}
}

function pop_termos_de_uso1(termo){
  var win = window.open(termo,'','width=706,height=500,scrollbars=yes,top=0,left=0,status=no,toolbar=yes,menubar=no,location=no,resizable=no');
}

function validaImport(form){
	if (form.email_imp.value == "" || form.senha_imp.value == ""){
		alert("Por favor verifique o preenchimento dos campos");
	}else{
		form.submit();
	}
}
//FIM CADASTRO

//COMEÇO FALE CONOSCO
function enviarMensagemFaleConosco(frm){
	nome = replaceAll(frm.nome.value," ","");
	email = replaceAll(frm.email.value," ","");
	assunto = replaceAll(frm.assunto.value," ","");
	if (nome == "" || email == "" || assunto == ""){
		alert("Favor preencher os campos!");
	}else{
		frm.submit();		
	}
}
//FIM FALE CONOSCO

function OAS_VARS(OAS_page, OAS_pos) {
OAS_site = 'www.oifotos.com.br';
OAS_sitepage = OAS_site + OAS_page;
OAS_listpos = OAS_pos;}
OAS_url = 'http://adserver.ig.com.br/RealMedia/ads/';
OAS_query = '';
OAS_target = '_blank';
OAS_version = 10;
OAS_rn = '001234567890'; OAS_rns = '1234567890';
OAS_rn = new String(Math.random()); OAS_rns = OAS_rn.substring(2, 11);
function OAS_NORMAL (pos) {
 document.write('<a href="' + OAS_url + 'click_nx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + '?' + OAS_query + '" target="'+ OAS_target + '">');
 document.write('<img src="' + OAS_url + 'adstream_nx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + '?' + OAS_query + '" border="0"></a>');}//-->

function OAS_START() {
OAS_version = 11;
if (navigator.userAgent.indexOf('Mozilla/3') != -1 || navigator.userAgent.indexOf('Mozilla/4.0 WebTV') != -1)
 OAS_version = 10;
if (OAS_version >= 11)
 document.write('<SCRIP' + 'T LANGUAGE=JavaScript1.1 SRC="' + OAS_url + 'adstream_mjx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '?' + OAS_query + '"><\/SCRIP' + 'T>');}//-->

document.write('');
function OAS_AD(pos){
 if (OAS_version >= 11)
  OAS_RICH(pos);
 else
  OAS_NORMAL(pos);}//-->
  
//HEADER LOGADO
function goUrlMenuLogado(url){
	document.location.href = url;			
}
//FIM HEADER LOGADO

//COMEÇO EDITAR E VISUALIZAR
var sServerName = "http://www.oifotos.com";

function Album() {
	var album_id = "";
	if(frmAlbuns.album) {
		if(frmAlbuns.album.length) {
			for(var x=0; x<frmAlbuns.album.length; x++) {
				if (frmAlbuns.album[x].checked) {
					album_id = frmAlbuns.album[x].value;
					break;
				}
			}
		} else if (frmAlbuns.album.checked) {
			album_id = frmAlbuns.album.value;
		}
	}
	if (album_id!="") location.href="/album.asp?a="+album_id;
}
function AtualizaSelecao(ps,pf) {
	/*document.getElementById('revelarFotos').style.display = 'none'; 
	document.getElementById('loading').style.display = 'block';	
	document.getElementById('compartFotos').style.display = 'none'; 
	document.getElementById('loading2').style.display = 'block';	*/
	//alert(document.getElementById('ifroifselec'));
	ifroifselec.location.href="/custom/selection.asp?f="+pf+"&op="+((ps)?"add":"remove");
}

function CheckAllAlbums(bln) {
	var count = 0;
	var frm = document.frmAlbumList;
	if (frm) {
		if (frm.a.length) {
			for (var x=0; x<frm.a.length; x++) {
				frm.a[x].checked = bln;
			}
		} else {
			frm.f.checked = bln;
		}
	}
}

function CheckAllPhotos(bln) {
	var count = 0;
	var frm = document.frmPhotoList;
	if (frm) {
		if (frm.f.length) {
			for (var x=0; x<frm.f.length; x++) {
				frm.f[x].checked = bln;
			}
		} else {
			frm.f.checked = bln;
		}
	}
}
function ClearAllPhotos() {
	var frm = document.frmPhotoList;
	frm.target = "ifroifselec";
	//document.getElementById('Fader').style.display="block";	
	//document.getElementById('aguarde_selecao_fotos').style.display="block";
	SendForm(frm, "/custom/selection.asp?op=remove");
	CheckAllPhotos(false);
}
function SelectAllPhotos() {
	CheckAllPhotos(true);
	var frm = document.frmPhotoList;
	frm.target = "ifroifselec";
	//document.getElementById('Fader').style.display="block";	
	//document.getElementById('aguarde_selecao_fotos').style.display="block";
	SendForm(frm, "/custom/selection.asp?op=add");
}

function SelectAllAlbuns() {
	CheckAllAlbuns(true);
	var frm = document.getElementById('frmAlbumList');
	//frm.target = "ifroifselec";
	//document.getElementById('Fader').style.display="block";	
	//document.getElementById('aguarde_selecao_fotos').style.display="block";
	//SendForm(frm, "/custom/selection.asp?op=addalbum");
	for (var x=0; x<frm.a.length; x++) {
		//ifroifselec.location.href="/custom/albumselect.asp?a="+frm.a[x].value+"&op=add";	
		//SelectAlbum(frm.a[x].value, frm.a[x].checked)
	}
}

function ClearAllAlbuns() {
	CheckAllAlbuns(false);	
	var frm = document.getElementById('frmAlbumList');
	//frm.target = "ifroifselec";	
	//document.getElementById('Fader').style.display="block";	
	//document.getElementById('aguarde_selecao_fotos').style.display="block";
	//SendForm(frm, "/custom/selection.asp?op=removealbum");	
	for (var x=0; x<frm.a.length; x++) {
		//ifroifselec.location.href="/custom/albumselect.asp?a="+frm.a[x].value+"&op=remove";		
		//SelectAlbum(frm.a[x].value, frm.a[x].checked)
	}	
}

function CheckAllAlbuns(bln) {
	var count = 0;
	var frm = document.getElementById('frmAlbumList');
	if (frm) {
		if (frm.a.length) {
			for (var x=0; x<frm.a.length; x++) {
				frm.a[x].checked = bln;
			}
		} else {
			frm.a.checked = bln;
		}
	}
}

function ClearSelection() {
	try { CheckAllPhotos(false); } catch(e) { }
	try { CheckAllAlbums(false); } catch(e) { }
	ifroifselec.location.href="/custom/selection.asp?op=clearall";
}
function Edit()
{
}

function Paginacao(frm,pgcount,pg) {
	for(x=1;x<=pgcount;x++) {
		pos = frm.pg.options.length++;
		frm.pg.options[pos].value = x;
		frm.pg.options[pos].text = x+" de "+pgcount;
		if (x==''+pg) frm.pg.options[pos].selected = true;
	}
}

function ApplyEffects() {
	effects.style.display=(effects.style.display!='inline')?'inline':'none';
}
function SlideShow(a) {
	var w = document.body.offsetWidth;
	var h = window.screen.height;
	w = ((w - 615) / 2);
	h = ((h - 467) / 2)-80;
	if (ifroifselec) {
		if (ifroifselec.selectedphotos<1) {
			if (document.frmPhotoList) {
			if(confirm("Nenhuma foto foi selecionada. Deseja visualizar todas as fotos do álbum?")) {
					document.getElementById("Fader").style.zIndex = 20;	
					document.getElementById("Fader").style.display = "block";						
					document.getElementById("DivSlideshow").style.left = w + "px";
					document.getElementById("DivSlideshow").style.top = h + "px";
					document.getElementById("DivSlideshow").innerHTML = "<iframe width='615' height='467' scrolling='no' frameborder='0' src='' id='FrameSlideshow' name='FrameSlideshow'></iframe>";
					document.getElementById("DivSlideshow").style.display = "block";
					document.getElementById("FrameSlideshow").src = "/slideshow/slideshow.asp?a="+a;
				} else { return; }
			} else if (document.frmAlbumList) {
				alert("Nenhuma foto foi selecionada. Selecione pelo menos um álbum.");
				return;
			}
		}else{
			document.getElementById("Fader").style.zIndex = 20;
			document.getElementById("Fader").style.display = "block";	
			document.getElementById("DivSlideshow").style.left = w + "px";
			document.getElementById("DivSlideshow").style.top = h + "px";
			document.getElementById("DivSlideshow").style.display = "block";
			document.getElementById("DivSlideshow").innerHTML = "<iframe width='615' height='467' scrolling='no' frameborder='0' src='' id='FrameSlideshow' name='FrameSlideshow'></iframe>";
			document.getElementById("FrameSlideshow").src = "/slideshow/slideshow.asp?a="+a;
		}
	} 
}
function closeSlideShow(){
	parent.document.getElementById("DivSlideshow").innerHTML = "";
	parent.document.getElementById("FrameSlideshow").src = ""; 
	parent.document.getElementById("Fader").style.display = "none";
	parent.document.getElementById("DivSlideshow").style.display = "none";
}

function CopyPhotos() {
	if (ValidateSelectGo("Nenhuma foto foi selecionada. Deseja copiar todas as fotos do álbum?", "/custom/albumselect.asp?a="+arguments[0]+"&url_destino=/photocopy.asp", "_self", "")) {
		location.href = "/photocopy.asp";
	}
}
function MovePhotos() {
	if (ValidateSelectGo("Nenhuma foto foi selecionada. Deseja mover todas as fotos do álbum?", "/custom/albumselect.asp?a="+arguments[0]+"&url_destino=/photomove.asp", "_self", "")) {
		location.href = "/photomove.asp";
	}
}
function EditPhotos() {
	if (arguments.length>0) {
		location.href = "/photoedit.asp?f="+arguments[0]+"&url_destino=/photo.asp?f="+arguments[0];
	} else if (ValidateCountGo(document.frmPhotoList.f, "Nenhuma foto foi selecionada", "Selecione apenas uma foto")) {
		SendForm(document.frmPhotoList, "/photoedit.asp?url_destino=/custom/thumbnail.asp?f="+FindAny(document.frmPhotoList.f));
	}
}
function DeletePhotos() {
	if (arguments.length>0) {
		location.href = "/custom/photodelete.asp?f="+arguments[0];
		return;
	}
	
	var count = 0;
	if (ifroifselec) count = ifroifselec.selectedphotos;

	if (count==0) {
		alert("Nenhuma foto foi selecionada");
		return;
	} else if(confirm("Você tem "+count+" foto(s) selecionada(s). Tem certeza que deseja excluí-la(s)?")) {
		//SendForm(document.frmPhotoList, "/custom/photodelete.asp", "_self");
		location.href = "/custom/photodelete.asp";
	}
}
function SharePhotos() {
	if (ValidateSelectGo("Nenhuma foto foi selecionada. Deseja compartilhar todas as fotos do álbum?", "/custom/albumselect.asp?a="+arguments[0]+"&url_destino=/share.asp", "_self", "")) {
		location.href = "/share.asp"
	}
}

function ChangeAlbumCover() {
	if (arguments.length>0) {
		location.href = "/custom/albumcover.asp?f="+arguments[0];
	} else if (ValidateCountGo(document.frmPhotoList.f, "Nenhuma foto foi selecionada", "Selecione apenas uma foto")) {
		location.href = "/custom/albumcover.asp?f="+FindAny(document.frmPhotoList.f);
	}
}
function NewAlbum() {
	location.href = "/albumedit.asp";
}
function CopyAlbums() {
	var frm = document.frmAlbumList;
	var album_count = 0;
	if (frm.a) {
		if (frm.a.length) {
			for(x=0; x<frm.a.length; x++) {
				if (frm.a[x].checked) {
					album_count++;
					if (album_count>1) break;
				}
			}
		} else if (frm.a.checked) album_count = 1;
	}
	if (album_count==0) { alert("Selecione um álbum"); }
	else if (album_count>1) { alert("Selecione apenas um álbum") }
	else {
		SendForm(frm, "/albumcopy.asp");
	}
}

function EditAlbums() {
	if (ValidateCountGo(document.frmAlbumList.a, "Nenhum álbum foi selecionado", "Selecione apenas um álbum")) {
		SendForm(document.frmAlbumList, "/albumedit.asp");
	}
}
function DeleteAlbums() {
	if (!IsChecked(document.frmAlbumList.a)) {
		alert("Nenhum álbum foi selecionado.");
		return;
	}
	if(confirm("Tem certeza que deseja excluir o(s) álbun(s) selecionado(s)?")) {
		url_action = "/custom/albumdelete.asp"
		if (arguments.length>0) if (arguments[0]=="S") url_action += "?url_destino=/sharedalbumlist.asp"
		SendForm(document.frmAlbumList, url_action);
	}
}

function DeleteAlbumsShared() {
	if (!IsChecked(document.frmAlbumList.a)) {
		alert("Nenhum compartilhamento foi selecionado.");
		return;
	}
	if(confirm("Tem certeza que deseja excluir o(s) compartilhamento(s) selecionado(s)?")) {
		url_action = "/custom/albumdelete.asp?url_destino=/sharedalbumlist.asp"
		SendForm(document.frmAlbumList, url_action);
	}
}

function RotateForm(p1,a) {
	//alert("Esta ferramenta está temporariamente fora do ar.\nEm alguns minutos ela será reestabelecida.");
	if (document.frmPhotoList) {
		if (!IsChecked(document.frmPhotoList.f)) {
			alert("Nenhuma foto foi selecionada");
		} else {
			photos = document.getElementsByName("f");			
			if (photos!=null) {
				for (x=0; x<photos.length; x++) {
					if (photos[x].checked) {						
						SendRequestResponse("/custom/actions/validaeffect.asp?f="+photos[x].value);
						//result = SendRequestResponse("/custom/imgtrans2.asp?op=rotate&p1="+p1+"&f="+photos[x].value);							
						//document.getElementById(photos[x].value).src = '';
						//document.getElementById(photos[x].value).src = '/custom/image.asp?hash='+result;
					}
				}
			}
			//location.href = "/album.asp?a="+a;
			SendForm(document.frmPhotoList, "/custom/imgtrans.asp?op=rotate&p1="+p1+"&url_destino=/album.asp?a="+a, "_self");
		}
	}
}
function Rotate90CCWForm(a) { RotateForm(3,a); }
function Rotate180CWForm(a) { RotateForm(2,a); }
function Rotate90CWForm(a) { RotateForm(1,a); }

function Rotate(p1,f) {
	if (f == 'photo') {
		//alert(document.getElementById('photo_cript_value').value);		
		SendRequestResponse("/custom/actions/validaeffect.asp?f="+document.getElementById('photo_cript_value').value);
		location.href = "/custom/imgtrans.asp?op=rotate&p1="+p1+"&f="+document.getElementById('photo_cript_value').value;			
		//location.href = "/custom/imgtrans.asp?op=rotate&p1="+p1+"&f="+document.getElementById('photo_cript_value').value;
	}else{
		SendRequestResponse("/custom/actions/validaeffect.asp?f="+f);
		location.href = "/custom/imgtrans.asp?op=rotate&p1="+p1+"&f="+f;			
		//location.href = "/custom/imgtrans.asp?op=rotate&p1="+p1+"&f="+f;	
	}
	//alert("Esta ferramenta está temporariamente fora do ar.\nEm alguns minutos ela será reestabelecida.");
}
function Rotate90CCW(f) { Rotate(3,f); }
function Rotate180CW(f) { Rotate(2,f); }
function Rotate90CW(f) { Rotate(1,f); }
function Effect(op,f) {
	if (f == 'photo') {
		//alert(document.getElementById('photo_cript_value').value);		
		SendRequestResponse("/custom/actions/validaeffect.asp?f="+document.getElementById('photo_cript_value').value);
		location.href = "/custom/imgtrans.asp?op="+op+"&f="+document.getElementById('photo_cript_value').value;
	}else{
	//alert("Esta ferramenta está temporariamente fora do ar.\nEm alguns minutos ela será reestabelecida.");
		SendRequestResponse("/custom/actions/validaeffect.asp?f="+f);
		location.href = "/custom/imgtrans.asp?op="+op+"&f="+f;
	}
}
function Original(f) {
	if (f == 'photo') {
		location.href = "/custom/original.asp?f="+document.getElementById('photo_cript_value').value;		
	}else{
		location.href = "/custom/original.asp?f="+f;		
	}
	//alert("Esta ferramenta está temporariamente fora do ar.\nEm alguns minutos ela será reestabelecida.");
}

function FindAny(fld) {
	if (fld) {
		if (fld.length) {
			for(x=0;x<fld.length;x++) {
				if (fld[x].checked) return fld[x].value;
			}
			return fld[0].value;
		} else {
			return fld.value;
		} 
	}
}
function Thumbnails() {
	if (document.frmAlbumList) {
		var a = FindAny(document.frmAlbumList.a);
		if (""+a=="undefined") {
			window.open("/send/photo.asp", "_self");
		} else {
			var dir = ""
			if (arguments.length>0) {
				if (arguments[0]!="") dir = "/" + arguments[0];
			}
			window.open(dir+"/album.asp?a=" + a, "_self");
		}
	} else {
		if (arguments.length>1) {
			if (arguments[1]!="") {
				window.open("/custom/thumbnail.asp?f="+arguments[1], "_self");
			}
		}
	}
}
function Details() {
	if (document.frmPhotoList) {
		var f = FindAny(document.frmPhotoList.f)
		var dir = ""
		if (arguments.length>0) {
			if (arguments[0]!="") dir = "/" + arguments[0];
		}
		window.open(dir+"/photo.asp?f=" + f, "_self");
	} else {
		if (document.frmAlbumList) {
			var a = FindAny(document.frmAlbumList.a)
			if (""+a=="undefined") {
				window.open("/send/photo.asp", "_self");
			} else {
				window.open("/custom/details.asp?a=" + a, "_self");
			}
		}
	}
}

function SendForm(frm, url) {
	frm.action = url;
	if (arguments.length>2) frm.target = arguments[2];
	frm.submit();
	frm.action = "";
}
function SelectAlbum(a, bln) {
	/*document.getElementById('revelarFotos').style.display = 'none'; 
	document.getElementById('loading').style.display = 'block';	
	document.getElementById('compartFotos').style.display = 'none'; 
	document.getElementById('loading2').style.display = 'block';	*/
	ifroifselec.location.href="/custom/albumselect.asp?a="+a+"&op="+((bln)?"add":"remove");
}

function IsChecked(c) {
	if (c) {
		if (c.length) {
			for (x=0;x<c.length;x++) {
				if (c[x].checked) return true;
			}
		} else {
			if (c.checked) return true;
		}
	}
	return false;
}
function CountChecked(c) {
	var count=0;
	if (c) {
		if (c.length) {
			for (x=0;x<c.length;x++) {
				if (c[x].checked) count++;
			}
		} else {
			if (c.checked) count++;
		}
	}
	return count;
}

function Previous(frm) {
	if (frm.pg.selectedIndex>0) {
		frm.pg.selectedIndex--;
		frm.submit();
	}
}
function Next(frm) {
	if (frm.pg.selectedIndex<frm.pg.length-1) {
		frm.pg.selectedIndex++;
		frm.submit();
	}
}

function SavePhotos(a) {
	if (ValidateSelectGo("Nenhuma foto foi selecionada. Deseja salvar todas as fotos do álbum?", "/custom/albumselect.asp?a="+arguments[0]+"&url_destino=/photocopy.asp?op=save", "_self", "")) {
		location.href = "/photocopy.asp?op=save"
	}
}
function Order() {
	if (ValidateSelectGo("Nenhuma foto foi selecionada. Deseja revelar todas as fotos do álbum?", "/custom/albumselect.asp?a="+arguments[0]+"&url_destino=/order.asp", "_self", "")) {
		location.href = "/order.asp"
	}
}

function ValidateSelectGo(msg, url, target, params) {
	if (ifroifselec) {
		if (ifroifselec.selectedphotos<1) {
			if (document.frmPhotoList) {
				if(confirm(msg)) {
					j = window.open(url, target, params);
					if (j==null) alert(arguments[4]);
					else j.focus();
					return false;
				} else { return false; }
			} else if (document.frmAlbumList) {
				alert("Nenhuma foto foi selecionada. Selecione pelo menos um álbum.");
				return false;
			}
		}
	} 
	return true;
}

function ValidateCountGo(c, msg1, msg2) {
	var count = CountChecked(c);
	if (count==0) {
		alert(msg1);
		return false;
	} else {
		if (count>1) {
			alert(msg2);
			return false;
		}
	}
	return true;
}

function regulamento(){
  var win = window.open('mms_regulamento.asp','RegulamentoMMS','width=706,height=500,scrollbars=yes,top=0,left=0,status=no,toolbar=yes,menubar=no,location=no,resizable=no');
}

function regulamento_share(){
  var win = window.open('share_regulamento3.asp','RegulamentoShare','width=706,height=500,scrollbars=yes,top=0,left=0,status=no,toolbar=yes,menubar=no,location=no,resizable=no');
}

function Rename() {
	with(frmAlbumList) {
		action="/albumedit.asp";
		submit();
		action="";
	}
}

function Share() {
	SendForm(document.frmAlbum, "/share.asp");
}

function submenuOut(obj){
	obj.style.background = 'url(/images/menu_fotos/bg_submenu_edit.jpg) repeat-x #FFFFFF';
	obj.style.textDecoration = '';
}
function submenuOver(obj){
	obj.style.background = '';
	obj.style.textDecoration = 'underline';
}

function ReValidateCopyFoto(frm) {
	if (ValidateCopyFoto(frm)){
		frm.submit();		
	}
}

function ValidateCopyFoto(frm) {
	if (frm.albumtype[1].checked) {
		if (frm.a.selectedIndex<=0) {
			alert("Selecione o álbum");
			frm.a.focus();
			return false;
		}
	} else {
		title = replaceAll(frm.title.value," ","");
		if (title=="") {
			alert("Informe a descrição do álbum");
			frm.title.focus();
			return false;
		}
	}
	return true;
}

function ReValidateAlbumEdit(frm){
	if (ValidateAlbumEdit(frm)){
		frm.submit();
	}
}

function ValidateAlbumEdit(frm) {
	if (!VerificaObjeto(frm.album_title,true,"","Preencha o nome do álbum", "")) return false;
	title = replaceAll(frm.album_title.value," ","");
	if (title == ""){
		alert("Preencha o nome do álbum"); 
		return false;
	}
	return true;
}

function ReValidatePhotoEdit(frm) {
	if (ValidatePhotoEdit(frm)){
		frm.submit();
	}
}

function ValidatePhotoEdit(frm) {
	if (!VerificaObjeto(frm.photo_desc,true,"","Preencha o nome da foto", "")) return false;
	title = replaceAll(frm.photo_desc.value," ","");
	if (title == ""){
		alert("Preencha o nome da foto"); 
		return false;
	}
	return true;
}

function ReValidateAlbumCopy(frm) {	
	if (ValidateAlbumCopy(frm)){
		frm.submit();
	}
}

function ValidateAlbumCopy(frm) {	
	title = replaceAll(frm.title.value," ","");
	if (title == ""){
		alert("Preencha o nome do álbum"); 
		return false;
	}
	return true;
}

function ReValidatePhotoMove(frm) {	
	if (ValidatePhotoMove(frm)){
		frm.submit();
	}
}

function ValidatePhotoMove(frm) {
	if (frm.albumtype[1].checked) {
		if (frm.a.selectedIndex<=0) {
			alert("Selecione o álbum");
			frm.a.focus();
			return false;
		}
	} else {
		title = replaceAll(frm.title.value," ","");
		if (title=="") {
			alert("Informe a descrição do álbum");
			frm.title.focus();
			return false;
		}
	}
	return true;
}
function viewFotoOri(hash){
	document.getElementById('view_foto_ori').style.display = 'block';
}
function ViewPhoto(path,photo_cript,path_thumb){
	//obj.style.borderColor = '#507fe7';	
	document.getElementById('view_photo').src = "/custom/image.asp?hash="+path;
	document.getElementById('photo_cript_value').value = photo_cript;	
	result = SendRequestResponse("/custom/actions/buscathumb.asp?hash="+path_thumb);		
	preview = document.getElementById('pre_view_thumb');
	if ( preview!= null){
		preview.src = "/custom/image.asp?hash="+result;
	}	
	result = ""
	result = SendRequestResponse("/custom/actions/buscadesc.asp?p="+photo_cript);		
	desc = document.getElementById('descricao_foto');
	if ( desc!= null){
		desc.innerHTML = result;
	}
	//document.getElementById('pre_view_thumb').src = "/custom/image.asp?hash="+path_thumb;
}
//FIM EDITAR E VISUALIZAR

//validação cadastro
function validaCep( obj ){ 
   var cep = obj.value; 

// ## Verifica se possui caracter não-numérico ... 
		if( isNaN( cep ) ){   	
			  alert( "O CEP deve conter apenas números!" );    
			      obj.focus();	
				  return false;
		 }else    // ## ..., então, verifica se o usuário digitou os 9 dígitos
		      if( cep.length != 0 && cep.length < 8  ){
				       alert( "O CEP deve ter 8 dígitos" );
					   obj.focus();	
					   return false;
		      }else
				     if( cep.length == 0 ){
				          return false;
			        }
					else
						result = SendRequestResponse("/custom/actions/validacep.asp?cep="+cep);
						//alert(result);
						if (result == "OK"){
							return true;	
						}else{
							alert( "CEP inválido" );	
							obj.focus();	
							return false;	
						}
}

function validaCampoNumerico( obj , name ){ 
	num = obj.value;
// ## Verifica se possui caracter não-numérico ... 
	if( isNaN( num ) ){   	
		  alert( "o "+name+" deve conter apenas números!" );    
			  obj.focus();	
			  return false;
	 }
}



function validaCaracteresAlbum( obj ){
     var album = obj.value; 			
	 var tamanho = album.split( " " );
	 var albumSemEspacos = "";		

		// ##Remove os espaços em branco
					if( tamanho ==  1 )
							albumSemEspacos = album;
					else
						     for( var count = 0; count < tamanho.length; count++ )
							      albumSemEspacos = albumSemEspacos +  tamanho[ count ]; 


// ## Verifica se possui algum caracter Inválido
	var limiteNumero = new Array( 47, 58);
	var limiteLetraMaiusc = new Array( 64, 91 );
	var limiteLetraMinusc = new Array( 96, 123 );
	var undescore = 95;			
	var caracter;					
	
					    for( var cols = 0; cols < albumSemEspacos.length; cols++ ){		
						     caracter = albumSemEspacos.charCodeAt( cols );								
							
							   if( ( caracter > limiteNumero[ 0 ] && caracter < limiteNumero[ 1 ] ) ||
							       ( caracter > limiteLetraMaiusc[ 0 ] && caracter <  limiteLetraMaiusc[ 1 ] ) ||
								   ( caracter > limiteLetraMinusc[ 0 ] && caracter  < limiteLetraMinusc[ 1 ] ) ||
								   ( caracter == undescore ) ){
									//  sem instruções...
								}else{
								      window.alert(  "O nome do álbum digitado possui o caracter inválido " );
									  obj.focus( );
									  return; 
							    } 
					   }

				// ## Retorna a string sem espaços
				document.frmShare.publicname.value = albumSemEspacos; 
	}


	//Função que cria a Classe! Com suas propriedades.
function Campo(pForm, ctx, req, mask, msgErroRequired, msgErroValidado)
{
	if (pForm == null)
	{
		alert("O Form (" + pform + ") ou o campo (" + ctx + ") não existe(m)! ");
		return;
	}
	this.controle = ctx;
	this.required = req;
	this.mascara = mask;
	this.mensagem_erro = msgErroRequired;
	this.mensagem_invalido = msgErroValidado;
	if (pForm['RequiredFields'] == null) {
		pForm.RequiredFields = new Array();}
	pForm.RequiredFields[pForm.RequiredFields.length] = this;
}

// Função de validação! Pega cada objeto e valida de acordo com suas propriedades.
function ValidaFormJS(pForm)
{
	var alertMsg = "";
	
	if (pForm['RequiredFields'] == null) return;
	for (i = 0; i < pForm.RequiredFields.length; ++i)
	{
		var oCampo = pForm.RequiredFields[i];
		element = pForm.elements[oCampo.controle];
		if (element == null) {
			//alert("Campo nulo: " + i );
			continue;
		}
		// Se o campo for RADIO ou CHECKBOX e required = TRUE, Valida se pelo menos um foi marcado!!!
		if (element.type == null) 
		{
			var checked = false;
			for (j = 0; j < element.length; ++j)
			{
				if (element[j].checked) { checked = true; }
			}
			if (oCampo.required && !checked)
				alertMsg += (" - " + oCampo.mensagem_erro + "\n");
		}
		else
		{
			if (element.value == "") // Se o campo for required = TRUE, Valida se foi preenchido!!!
			{
				if (oCampo.required){
					alertMsg += (" - " + oCampo.mensagem_erro + "\n");}
			}
			else // Verifica a válidade dos dados prenchidos no campo
			{
				if (oCampo.mascara != null)
				{
				 	var erroBoolean = false;
					switch (oCampo.mascara) 
					{
						case "CPF" :
							if (!ValidaCPF(element.value)) {
								alertMsg+=(" - " + oCampo.mensagem_invalido + "\n");
							}
							break;
							
						case "CNPJ" :
							if (!ValidaCNPJ(element.value)) {
								alertMsg+=(" - " + oCampo.mensagem_invalido + "\n");
							}
							break;
							
						default :
							if (element.value.search(oCampo.mascara) == -1)
								alertMsg+=(" - " + oCampo.mensagem_invalido + "\n");
					}//switch
				}//if								
			}//else
		}//else
	}//for
	if (alertMsg.length > 0)
	{
		alert ("Por favor, verifique o preenchimento dos campos abaixo:\n\n" + alertMsg);
		return false;
	}
	else
		return true;
}


/*********************************************************************************************************************/
/************************************** Tipos de validações já definidas na QX3 **************************************/
	
	// Numeros c/ 1dig. ou +
	function ONLYNUMBER() { return /^\d+$/; }
	
	// Letras Maiusculas e Minusculas c/ 1dig. ou +
	function CHARACTER(){ return /^[a-zA-Z]+$/; }
	
	// az09 .+_ az09 @ az09 . az09
	function EMAIL() { 
		return /^([a-zA-Z0-9_\-])+(\.([a-zA-Z0-9_\-])+)*@((\[(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5]))\]))|((([a-zA-Z0-9])+(([\-])+([a-zA-Z0-9])+)*\.)+([a-zA-Z])+(([\-])+([a-zA-Z0-9])+)*))$/;
		//return /^[0-9a-z]+([.+_]{1}[0-9a-z]+)*[@]{1}[0-9a-z]+([.]{1}[a-z0-9]+)+$/; 
	}
	
	// Valor financeiro com 2 casas decimais 'Padrão Brasileiro'
	function VALOR() { return /^\d{1,3}(\.\d{3})*\,\d{2}$/; }
	
	// Numeros c/ mínimo 3 dig. e no máximo 4 dig., -(hifen, sendo opcional), numeros c/ 4 dig.
	function TELEFONE() { return /^\d{3,4}[-]?\d{4}$/; } 
	
	// Herdadas do antigo ValidaModulo.
	function CPF()  { return 'CPF';  } 
	function CNPJ() { return 'CNPJ'; } 
	
	// Valida hora de 00 à 24 e minuto de 00 à 59
	function HORA() { return /^[01][0-9]|2[0-4][:][0-5][0-9]$/; }
	
	// Valida Dias de 01 à 31, sendo nos mêses 1, 3, 5, 7, 8, 10 e 12; de 01 à 30 no resto e mês 2 de 01 à 29. Valida mês e ano conforme abaixo.
	function DIAMES() { return /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))$/; } 
	
	// Valida mes de 01 a 12 e valida ano conforme abaixo.
	function MESANO() { return /^(0[1-9]|1[0-2])\/(19|20)\d{2}$/; }
	
	// Valida numeros de 1900 à 2099.
	function ANO() { return /^(19|20)\d{2}$/; }
	
	// Valida Data completa.
	function DATACOMPLETA() { return /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/(19|20)\d{2}$/; }
	
	/* OBS: Esta validação aceita expressões regulares customizadas que não estejam pré definidas acima. */

function ValidaCPF(strCpf)
{
	if ( isNaN(strCpf) ){		
		return false;		
	}
	strCpf = strCpf.replace(new RegExp("[.-]","g"),"");

	var varFirstChr = strCpf.charAt(0);	
	var vaCharCPF = false;
	for(var i=0;i<=10;i++){
		var c = strCpf.charAt(i);             
		if(!(c>='0')&&(c<='9')){
			return false;
	    }              
	    if(c!=varFirstChr)
			vaCharCPF = true;
	}
	if(!vaCharCPF){
		return false;
	}
	soma=0;	
	for(i=0;i<9; i++){ 
		soma += (10-i) * ( eval(strCpf.charAt(i)) );
	}
	digito_verificador = 11-(soma % 11);
	if((soma % 11) < 2)
		digito_verificador = 0;	
		if (eval(strCpf.charAt(9)) != digito_verificador){
			return false;
		}
		soma=0;	
		for(i=0;i<9; i++){
			soma += (11-i)*(eval(strCpf.charAt(i)));
		}
		soma += 2*(eval(strCpf.charAt(9)));
		digito_verificador = 11-(soma % 11);
		if((soma % 11)<2) 
			digito_verificador = 0;
		if(eval(strCpf.charAt(10)) != digito_verificador){ 
			return false;
		}
	return true;
}

function ValidaCNPJ(campo) {
 with (Math) {
	 w = 0;
	 Resp1 = "";
	 Resp2 = "";
	 
 	 campo = campo.replace('/','');
 	 campo = campo.replace('-','');
 	 campo = campo.replace('.','');
 	 campo = campo.replace('.','');
	 CGC = campo;
 
	 if (CGC.length != 14) {
	 	return false;
	 }
 
	 if (!ValidaNumero(CGC)) { 
	 	return false;
	 }
 
	 VtCGC = new CriaArray(CGC.length);

	 for (var i=0;i < CGC.length;i++) {
 		if ((CGC.charAt(i) == "0") || (CGC.charAt(i) == "1") || (CGC.charAt(i) == "2") || (CGC.charAt(i) == "3") || (CGC.charAt(i) == "4") || (CGC.charAt(i) == "5") || (CGC.charAt(i) == "6") || (CGC.charAt(i) == "7") || (CGC.charAt(i) == "8") || (CGC.charAt(i) == "9")) {
	 		VtCGC[w]=parseFloat(CGC.charAt(i));	
	 		w++;
		}
 	}


 	Soma1 = (VtCGC[0]*5)+(VtCGC[1]*4)+(VtCGC[2]*3)+(VtCGC[3]*2)+(VtCGC[4]*9)+(VtCGC[5]*8)+(VtCGC[6]*7)+(VtCGC[7]*6)+(VtCGC[8]*5)+(VtCGC[9]*4)+(VtCGC[10]*3)+(VtCGC[11]*2)+0.0001;
 	Divisao1 = Soma1 / 11; 
 	RestoParc1 = (Divisao1 - floor(Divisao1))*11;
 	Resto1 = floor(RestoParc1);
 
 	Soma2 = (VtCGC[0]*6)+(VtCGC[1]*5)+(VtCGC[2]*4)+(VtCGC[3]*3)+(VtCGC[4]*2)+(VtCGC[5]*9)+(VtCGC[6]*8)+(VtCGC[7]*7)+(VtCGC[8]*6)+(VtCGC[9]*5)+(VtCGC[10]*4)+(VtCGC[11]*3)+(VtCGC[12]*2)+0.0001;
 	Divisao2 = Soma2 / 11; 
 	RestoParc2 = (Divisao2 - floor(Divisao2))*11;
 	Resto2 = floor(RestoParc2);


 	if (((Resto1 == 0) || (Resto1 == 1)) && (VtCGC[12] == 0)) {
  		Resp1 = "V";
 	} else {
  		Digito1 = 11 - Resto1;
  		if ((Digito1 == VtCGC[12]) && (Resto1 > 1)) {
			Resp1 = "V";
  		}
 	}
 
 	if (((Resto2 == 0) || (Resto2 == 1)) && (VtCGC[13] == 0)) {
  		Resp2 = "V";
 	} else {
  		Digito2 = 11 - Resto2;
  		if ((Digito2 == VtCGC[13]) && (Resto2 > 1)) {
   			Resp2 = "V";
  		}
 	}
 
 	if ((Resp1 == "V") && (Resp2 == "V")) 
 	{
   		return true;
 	} else {
  		return false;   
 	} 
 }
}

/*         F U N Ç Õ E S   D E   F O R M A T A Ç Ã O          */

function formatarData(campo,teclaPres)
{
	var tecla=teclaPres.keyCode;
	vr = "";

	//if (!IsNumber(tecla)){
	//	return false;
	//}

	for(i=0;i<campo.value.length;i++)
		if(campo.value.charAt(i)!="/")
			vr=vr + campo.value.charAt(i);
	tam = vr.length ;
	if (tecla == 8){ tam = tam - 1 ;}
	if (tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
	{
		if (tam < 2) { campo.value = vr ;}
		if ((tam >= 2) && (tam <= 4) ) { 
			campo.value = vr.substr(0,2) + '/' + vr.substr(2,tam-2);
		}
		if ((tam > 4)) { 
			campo.value = vr.substr(0,2) + '/' + vr.substr(2,2) + '/' + vr.substr(4,tam-4);
		}
	}
}

function AutoSkip(obj) {
	with(document.forms[0]) {
		if (obj.value.length == obj.maxLength) 		{
			if (arguments.length>1) {
				arguments[1].focus();
			} else {
				idObjeto = 0;
				for (x=0; x<elements.length; x++) {
					try {
						if (elements[x].type == 'text') {
							if (elements[x].name == obj.name)
								idObjeto = x;
							if (idObjeto > 0 && x != idObjeto) 	{
								elements[x].focus();
								break;				
							}
						}
					}
					catch (e) {}
				}
			}
		}
	}
}
//fim validação cadastro

//mms Oi
function exibePopAssociarOi(b){
	if (b == true){		
		posicionaPopFadeByScroll("box-associar-numero");				
		exibePopMsg('box-associar-numero',true,'Fader',true,'slow');				
	}else{
		exibePopMsg('box-associar-numero',false,'Fader',false,'fast');		
	}	
}

function exibePopDesassociarOi(b){
	if (b == true){		
		posicionaPopFadeByScroll("box-desassociar-numero");				
		exibePopMsg('box-desassociar-numero',true,'Fader',true,'slow');				
	}else{
		exibePopMsg('box-desassociar-numero',false,'Fader',false,'fast');		
	}	
}

function ExcluiOi() {
	//if(confirm("Deseja realmente desassociar o número Oi de sua conta?")) {
		location.href = "/custom/assocoi.asp?op=remove&ispostback=true";
	//}
}

function SendMMS() {
	if (ValidateCountGo(document.frmPhotoList.f, "Nenhuma foto foi selecionada", "Selecione apenas uma foto")) {
		SendForm(document.frmPhotoList, "/sendmms.asp?f="+FindAny(document.frmPhotoList.f));
	}
}

function LoginOi() {
	var url_retorno = (arguments.length>0)?arguments[0]:sServerName+"/custom/loginoi.asp";
		
	//var j = window.open("http://ww2.oiloja.com.br/wb/POi/POi_popup_de_login_para_parceiros?logout=true&urlretorno="+url_retorno, "_blank", "height=250,width=250,top=40,left=50,statusbar=yes,scrollbars=no,resizeble=no,toolbar=no,menubar=no,location=no");
	//var j = window.open("http://www.oiloja.com.br/portal/site/OiLoja/menuitem.b1964e6212cd212c275aa872835d02a0?logout=true&urlretorno="+url_retorno, "_blank", "height=250,width=250,top=40,left=50,statusbar=yes,scrollbars=no,resizeble=no,toolbar=no,menubar=no,location=no");
	var j = window.open("http://oimovel.oi.com.br/portal/site/OiMovel/menuitem.8cdb0333880ae0d0f9df3f7321cc02a0?urlretorno="+url_retorno, "_blank", "height=250,width=250,top=40,left=50,statusbar=yes,scrollbars=no,resizeble=no,toolbar=no,menubar=no,location=no");
	if (j==null) {
		alert("Você possui um bloqueador de pop-ups ativo em seu navegador.\nDesabilite esta opção para abrir a tela de login.");
		return;
	}
	j.focus();
}
//fim mms Oi

//alteração de cadastro
function exibePopAlterarCadastro(b){
	if (b == true){
		$('mensagem-sucesso-atualiza-cadastro').style.display = 'none';	
		$('form_cadastro_pop_fade').style.display = 'block';
		posicionaPopFadeByScroll("box-meucadastro");				
		exibePopMsg('box-meucadastro',true,'Fader',true,'slow');		
		$('form_cadastro_pop_fade').src = "/cadastro/atualiza_cadastro_pop.asp";
	}else{
		exibePopMsg('box-meucadastro',false,'Fader',false,'fast');		
	}	
}

//fim alteração de cadastro

//pop-fade logout parceiros
function exibePopLogoutParceiros(b){
	if (b == true){		
		posicionaPopFadeByScroll("box-logout-parceiros");		
		exibePopMsg('box-logout-parceiros',true,'Fader',true,'slow');		
	}else{
		exibePopMsg('box-logout-parceiros',false,'Fader',false,'fast');		
	}	
}
//fim pop-fade logout parceiros

//alterar senha
function exibePopAlterPassword(b){
	if (b == true){
		$('msg-alterarsenha').style.display = 'none';	
		$('form-alterar-senha').style.display = 'block';
		posicionaPopFadeByScroll("box-alterar-senha");		
		exibePopMsg('box-alterar-senha',true,'Fader',true,'slow');		
	}else{
		exibePopMsg('box-alterar-senha',false,'Fader',false,'fast');		
	}	
}

function ValidaCampo(c,m) {
	if (c.value=="") {
		alert(m);
		c.focus();
		return false;
	}
	return true;
}
function ValidateNewPwd(frm) {
	var b_ok = true;
	if (!ValidaCampo(frm.pwd, "Informe a senha atual")) b_ok = false;
	
	if (b_ok){
		if (!ValidaCampo(frm.newpwd, "Informe a nova senha")) b_ok = false;	
	}
	
	if (b_ok){
		if (!ValidaCampo(frm.confpwd, "Informe a confirmação da senha")) b_ok = false;
	}
	
	if (b_ok){
		if (frm.newpwd.value!=frm.confpwd.value) {
			alert("Nova senha não confere");
			frm.newpwd.value = "";
			frm.confpwd.value = "";
			frm.newpwd.focus();
			b_ok = false;
		}		
	}
	
	new_pwd = replaceAll(frm.newpwd.value," ","");	
	
	if (b_ok){
		if (new_pwd.length < 6){
			alert("Use uma senha com pelo menos 6 caracteres");
			b_ok = false;
		}
	}
	
	if (b_ok){
		var ret = SendRequestResponse("/custom/actions/alter_password.asp?newpwd="+frm.newpwd.value+"&pwd="+frm.pwd.value);
		if (ret == "OK" ){			
			$('form-alterar-senha').style.display = 'none';
			$('msg-alterarsenha').style.display = 'block';			
		}else{		
			alert(ret);
		}			
	}	
}
//fim alterar senha

//esqueci minha senha

function posicionaPopFadeByScroll(id){
	if  (( navigator.userAgent.indexOf("IE 6.0") != -1)) {
		jQuery(window).scrollTop(0);		
	}else{
		jQuery("#"+id).css("position","fixed");	
	}	
}

function exibePopForgot(b){
	if (b == true){
		$('msg-esquecisenha').style.display = 'none';	
		$('form-esquecisenha').style.display = 'block';
		posicionaPopFadeByScroll("box-esquecisenha");		
		exibePopMsg('box-esquecisenha',true,'Fader',true,'slow');		
	}else{
		exibePopMsg('box-esquecisenha',false,'Fader',false,'fast');		
	}	
}

function validaforgot(form){
	email = replaceAll(form.email.value," ","");
	$('email_forgot_span').innerHTML = email;
	if (email == ""){
		alert("Favor preencher o campo e-mail")
	}else{
		exibeLoader('btn_prosseguir_forgot','obj_loader_ajax4',true);	
		var ret = SendRequestResponse("/custom/actions/forgot.asp?email="+email);
		if (ret == "OK" ){
			$('form-esquecisenha').style.display = 'none';
			$('msg-esquecisenha').style.display = 'block';
			exibeLoader('btn_prosseguir_forgot','obj_loader_ajax4',false);	
		}else if (ret == "NO"){
			exibeLoader('btn_prosseguir_forgot','obj_loader_ajax4',false);	
			alert("O e-mail informado não foi encontrado em nossa base de dados.");
		}else if (ret == "IG"){
			document.location.href = "https://central.ig.com.br/igcc/customer/center/PasswordReminder";
		}else{
			exibeLoader('btn_prosseguir_forgot','obj_loader_ajax4',false);	
			alert("Erro ao enviar nova senha");
		}
		//form.submit();
	}
}
//fim esqueci minha senha

function exibePrecosCartao(b){
	if (b == true){
		posicionaPopFadeByScroll("bloco-cartoes");		
		exibePopMsg('bloco-cartoes',true,'Fader',true,'slow');		
	}else{
		exibePopMsg('bloco-cartoes',false,'Fader',false,'fast');		
	}	
}

function replaceAll(str, de, para){
    var pos = str.indexOf(de);
    while (pos > -1){
		str = str.replace(de, para);
		pos = str.indexOf(de);
	}
    return (str);
}

function ValidaEmail(email){
  strMail = email;
  var re = new RegExp;
  re = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  var arr = re.exec(strMail);
  if (arr == null)
    return(false);
  else
    return(true);
}


//começo histórico de compras
function OrderDetails(oid) {
	window.open("/order/details.asp?oid="+oid+"&email=false", "_blank", "width=520,height=460,scrollbars=yes");
}
function carregabrw() {
    window.open( '', 'SHOPLINE', 'toolbar=yes, menubar=yes, resizable=yes, status=no, scrollbars=yes, width=675, height=485' );
}
function ValidaItau(form) {		
	form.submit();
}
//fim histórico de compras

//começo upload
	function mycarouselAddSelect(carousel,i,path,id_carrosel,photo_id,partner_id)
	{		
		html = mycarousel_getItemHTML(path,i,id_carrosel,photo_id,partner_id)
		if (i == 0){
			pos = 'end';
		}else{
			//pos = jQuery('#'+id_carrosel+' li:first');
			pos = '#'+id_carrosel+' li:first';			
		}
		carousel.trigger("insertItem", [ html,pos,null,0 ]);
	}; 
	
	function mycarousel_getItemHTML(path,i,id_carrosel,photo_id,partner_id)
	{	
		return '<li id="i_'+i+'"><a href="javascript:void(0)" class="borda-interna">' + 
		'<img id="'+photo_id+'" src="'+path+'" alt="Foto" class="thumb-foto-selecionada foto" />' + 
		'<img src="/imgs/btn-excluir-foto-lista.jpg" alt="Excluir" width="20" height="19" class="excluir-foto-lista" onclick=javascript:removePhotoSelectCarrossel("'+id_carrosel+'","'+photo_id+'",'+i+','+partner_id+') width="94" height="94" />' + 
		'</a></li>';
	};
	
	function addPhotoSelectCarrossel(tipo,thumb,photo_id,id_carrosel,photo_name,photo_size,photo_date,photo_height,photo_width,photo_large,partner_id){	
		ret = SendRequestResponse("/custom/actions/control_photos.asp?tipo="+tipo+"&action=add&photo_id="+photo_id+"&thumb="+thumb+"&photo_name="+photo_name+"&photo_size="+photo_size+"&photo_date="+photo_date+"&photo_height="+photo_height+"&photo_width="+photo_width+"&photo_large="+photo_large+"&partner_id="+partner_id);//vai adicionar a variável de sessão		
		
		if (ret == "new"){			
			var carousel = getCarrossel(id_carrosel);
			qtd_fotos = parseInt($('qtd_imagens_select').innerHTML)+1;					
			mycarouselAddSelect(carousel,qtd_fotos - 1,thumb,id_carrosel,photo_id,partner_id);				
			$('qtd_imagens_select').innerHTML = qtd_fotos;
			habilitaAcoesCarroselSelectPhotos(qtd_fotos);		
		}
	} 
	
	function removePhotoSelectCarrossel(id_carrosel,photo_id,i,partner_id){					
		
		SendRequestResponse("/custom/actions/control_photos.asp?tipo="+$('tipo').value+"&action=remove&photo_id="+photo_id+"&partner_id="+partner_id);//vai remover da variável de sessão		
		var carousel = getCarrossel(id_carrosel)
		removeCarrosselItem(id_carrosel,i,carousel);
		//reloadCarroselSelectPhotos(id_carrosel);				
	} 
	
	function removeCarrosselItem(id_carrosel,i,carousel){		
		var qtd_fotos;
		var obj_qtd_img_html = getQtdImagensSelect();
		carousel.trigger("removeItem", jQuery('#i_'+i));			
		qtd_fotos = parseInt(obj_qtd_img_html.innerHTML);		
		if (qtd_fotos >0 ){
			qtd_fotos = qtd_fotos - 1
			obj_qtd_img_html.innerHTML = qtd_fotos;	
			habilitaAcoesCarroselSelectPhotos(qtd_fotos);	
		}		
	}
	
	function removeAllPhotoSelectCarrossel(id_carrosel,str){			
		SendRequestResponse("/custom/actions/control_photos.asp?tipo="+$('tipo').value+"&action=removeall");				
		var carousel = getCarrossel(id_carrosel)
		resetCarrossel(id_carrosel,carousel);
		if (str == "close"){
			viewAllPhotoSelectCarrossel(false);
		}
	}
	
	function reloadCarroselSelectPhotos(id_carrosel){		
		var carousel = getCarrossel(id_carrosel)
		var qtd_fotos = 0;
		var book_id_value;
		//chama a página que vai retornar as fotos selecionadas
		if ($('book_id') != null){
			book_id_value = $('book_id').value;
		}
		data = SendRequestResponse("/custom/actions/control_photos.asp?tipo="+$('tipo').value+"&action=listhumb&book_id="+book_id_value);
		resetCarrossel(id_carrosel,carousel);		
		
		if (data != "" ){			
			var items 						= data.split('<:>');			
			qtd_fotos = items.length;			
			for (i = 0; i < qtd_fotos; i++) {
				arr_details_items 			= items[i].split('{:}');
				photo_id					= arr_details_items[0];	
				path 						= arr_details_items[1];
				partner_id					= arr_details_items[2];
				mycarouselAddSelect(carousel,i,path,id_carrosel,photo_id,partner_id);
			}
		}	
		var obj_qtd_img_html = getQtdImagensSelect();	
		obj_qtd_img_html.innerHTML = qtd_fotos;
		habilitaAcoesCarroselSelectPhotos(qtd_fotos);
	}
	
	function reloadCarroselSelectPhotosByAction(id_carrosel,action){		
		var carousel = getCarrossel(id_carrosel)
		var qtd_fotos = 0;
		var book_id_value;
		//chama a página que vai retornar as fotos selecionadas
		if ($('book_id') != null){
			book_id_value = $('book_id').value;
		}
		data = SendRequestResponse("/custom/actions/control_photos.asp?tipo="+$('tipo').value+"&action="+action+"&book_id="+book_id_value);
		resetCarrossel(id_carrosel,carousel);		
		
		if (data != "" ){			
			var items 						= data.split('<:>');			
			qtd_fotos = items.length;			
			for (i = 0; i < qtd_fotos; i++) {
				arr_details_items 			= items[i].split('{:}');
				photo_id					= arr_details_items[0];	
				path 						= arr_details_items[1];
				partner_id					= arr_details_items[2];
				mycarouselAddSelect(carousel,i,path,id_carrosel,photo_id,partner_id);
			}
		}	
		var obj_qtd_img_html = getQtdImagensSelect();	
		obj_qtd_img_html.innerHTML = qtd_fotos;
		habilitaAcoesCarroselSelectPhotos(qtd_fotos);
	}
	
	function reloadCarroselSelectPhotosUploadSimplesFotoalbum(id_carrosel){		
		var carousel = getCarrossel(id_carrosel)
		var qtd_fotos = 0;
		var book_id_value;
		//chama a página que vai retornar as fotos selecionadas
		if ($('book_id') != null){
			book_id_value = $('book_id').value;
		}
		data = SendRequestResponse("/custom/actions/control_photos.asp?tipo="+$('tipo').value+"&action=listhumbuploadsimplesfotoalbum&book_id="+book_id_value);
		resetCarrossel(id_carrosel,carousel);		
		
		if (data != "" ){			
			var items 						= data.split('<:>');			
			qtd_fotos = items.length;			
			for (i = 0; i < qtd_fotos; i++) {
				arr_details_items 			= items[i].split('{:}');
				photo_id					= arr_details_items[0];	
				path 						= arr_details_items[1];
				partner_id					= arr_details_items[2];
				mycarouselAddSelect(carousel,i,path,id_carrosel,photo_id,partner_id);
			}
		}	
		var obj_qtd_img_html = getQtdImagensSelect();	
		obj_qtd_img_html.innerHTML = qtd_fotos;
		habilitaAcoesCarroselSelectPhotos(qtd_fotos);
	}
	
	function resetCarrossel(id_carrosel,carousel){
		var qtd_fotos;	
		var obj_qtd_img_html = getQtdImagensSelect();	
		qtd_fotos = parseInt(obj_qtd_img_html.innerHTML);
		for (i = 0; i < qtd_fotos; i++) {						
			removeCarrosselItem(id_carrosel,i,carousel);			
		}
	}	
	
	function getCarrossel(id_carrosel){
		var carousel = jQuery('#'+id_carrosel);	
		return carousel;
	}
	
	function getQtdImagensSelect(){
		return $('qtd_imagens_select');
	}
	
	function viewAllPhotoSelectCarrossel(b){
		if ($('frame_view_fotos') != null){
			obj = $('frame_view_fotos');
		}else if (_$('frame_view_fotos') != null){
			obj = _$('frame_view_fotos');
		}else{						
			return;
		}

		if (b == true){						
			obj.src = "/selecaoFotos/view_fotos.asp";
			//window.frames['frame_view_fotos'].document.location.reload();
			obj.style.display = 'block';				
		}else{
			obj.src = "";	
			obj.style.display = 'none';	
		}		
	}
	
	function habilitaAcoesCarroselSelectPhotos(qtd_fotos){
		if (qtd_fotos == 0){
			$('remove_all_action').style.display = 'none';
			$('view_all_action').style.display = 'none';	
		}else{
			$('remove_all_action').style.display = 'block';
			$('view_all_action').style.display = 'block';	
		}		
	}
	
	function addPhotoSelect(){
		alert("Incluir as fotos no projeto ou para revelação.");
		//SendRequestResponse("/custom");
	}

	//upload simples
	function TrataEnvio(frm) {		
		arq = false;
		var bnew = false;
	
		if (frm.SourceFile_1.value == "" && frm.SourceFile_2.value == "" && frm.SourceFile_3.value == "" && frm.SourceFile_4.value == "" && frm.SourceFile_5.value == ""){
		
			alert("Favor adicionar a(s) foto")
			arq = false;
	
		}else{
			title = $('title').value;
			album_id_cript = $('album_id').value;
		
			if ($('new_album').value == "1"){ // novo album		
				bnew = true
				url = "/custom/actions/control_album.asp?action=create&title="+title;			
			}else{// album existente			
				url = "/custom/actions/control_album.asp?action=exist&album_id="+album_id_cript;
			}				
			
			result = SendRequestResponse(url);		
			if (result != ""){
				arr_result 						= result.split('<:>');
				if (arr_result[0] == "OK"){
					dados = arr_result[1].split("{:}");							
					album_id_cript = dados[0];			
					
					if (bnew){//vou exibir o select com o album que acabou de ser criado selecionado						
						url = "/custom/actions/control_album.asp?action=listrecentalbum&album_id="+album_id_cript;
						ret = SendRequestResponse(url);																							
						str = "<select name='select_album' id='select_album' onchange=javascript:controlAlbumUpload('alter',this.value)>" + ret + "</select>";
				
						$('cont_select_album').innerHTML = str;	
						
						$('create_album').style.display = 'none';
						$('exist_album').style.display = 'block';
						$('new_album').value = "0";	
						$('album_id').value = album_id_cript;	
					}		
					arq = true
					$('msg_upload').style.display = 'block';
					$('btn_upload_disable').style.block = 'block';
					$('msg_upload').innerHTML = 'Aguarde enquanto suas fotos são transferidas...';				
					//alert("album_id = "+$('album_id').value+"\n MultiPowUpload.getParameter(redirectUploadUrl) = "+MultiPowUpload.getParameter("redirectUploadUrl")+"\n MultiPowUpload.getParameter(uploadUrl) = "+MultiPowUpload.getParameter("uploadUrl") );										
				}
			}
		}		
		return arq;
		//document.getElementById('Fader').style.display="block";	
		//document.getElementById('aguarde_upload_simples').style.display="block";
	}	
	//fim upload
	
	function controlAlbumUpload(act,album_id){
		if (act == "exist"){
			$('btn_upload_disable').style.display = 'block';	
			$('create_album').style.display = 'none';
			$('exist_album').style.display = 'block';
			$('new_album').value = "0";
			$('setVars').value = "0";
		}else if (act == "new"){
			$('btn_upload_disable').style.display = 'none';
			$('create_album').style.display = 'block';
			$('exist_album').style.display = 'none';
			$('new_album').value = "1";
			$('setVars').value = "0";
		}else if(act == "alter"){
			if (album_id == "-99"){
				$('btn_upload_disable').style.display = 'block';	
			}else{
				$('btn_upload_disable').style.display = 'none';	
				$('album_id').value = album_id;	
				$('setVars').value = "0";
			}			
		}else if(act == "disable"){
			$('select_album').disabled = 'disabled';
			$('title').disabled = 'disabled';
			if ($('link_exist_album')!= null){
				$('link_exist_album').style.display = 'none';		
			}			
			$('link_new_album').style.display = 'none';		
		}else if(act == "enable"){
			$('select_album').disabled = '';
			$('title').disabled = '';
			if ($('link_exist_album')!= null){
				$('link_exist_album').style.display = 'block';
			}
			$('link_new_album').style.display = 'block';
		}						
	}
	
	function exibeMsg(msg){
		alert(msg);	
	}
	
	function uploadSimples(){
		var url = document.location.href;
		var param = "type=simples";
		if (url.indexOf("?") != -1){
			document.location.href = url + "&"+param;	
		}else{
			document.location.href = url + "?"+param;	
		}
		
	}
	
function ReValidate(frm){
	if (Validate(frm)){
		frm.submit();
	}
}
	
function Validate(frm) {
	if (frm.albumtype[1].checked) {
		if (frm.a.selectedIndex<=0) {
			alert("Selecione o álbum");
			frm.a.focus();
			return false;
		}
	} else {
		title = replaceAll(frm.title.value," ","");
		if (title=="") {
			alert("Informe a descrição do álbum");
			frm.title.focus();
			return false;
		}
	}
	return true;
}
function updateTypeUpload(type_upload,album_id){
	var result;
	result = SendRequestResponse("/send4/update_type_upload.asp?type_upload="+type_upload);
	if (result == "OK"){
		if (type_upload == "fls"){
			document.location.href = '/send4/send_flash.asp?a=<%=album_id_crypt%>';
		}else{
			document.location.href = '/send3/quick.asp?a=<%=album_id_crypt%>';
		}
	}
}

//valida.js
var isNav4, isNav, isIE;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
  isNav = (navigator.appName=="Netscape") ? true : false;
  isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
}

if (navigator.appName=="Netscape") {
	isNav4 = (parseInt(navigator.appVersion.charAt(0))==4);
}

function ValidaTextArea(campo, max) {
	if (campo.value.length >= max) {
		alert("Digite no máximo " + max + " caracteres.");
		campo.focus();
		campo.value = campo.value.substring(0, campo.value.length-1);
	}
	return campo.value;
}

function DateToString (data_param) {
	ano = data_param.getYear();
	mes = data_param.getMonth();
	dia = data_param.getDate();
	
	mes = mes + 1;
	
	dia = '00' + String(dia)
	dia = dia.substring(dia.length-2,dia.length)
	mes = '00' + String(mes)
	mes = mes.substring(mes.length-2,mes.length)
	ret = dia + "/" + mes + "/" + ano;	
	
	if (arguments.length>1) {
		if (arguments[1] == "YYYYMMDD") {
			ret = '' + ano + mes + dia;
		}
	} 
	return ret;
}

function VerificaObjeto(obj,obrigatorio,tipo,msg1,msg2) {
	valor = obj.value;
	if (obrigatorio == true && valor.length == 0) {
		alert(msg1);
		obj.focus();
		return false;
	}
	if (valor.length > 0) {
		switch (tipo) {
			case "PER" :
				ret = ValidaPeriodo(valor);
				break;
			case "NUM" : 
				ret = ValidaNumero(valor);
				break;
			case "EMAIL" : 
				ret = ValidaEmail(valor);
				break;
			case "CPF" :
				ret = ValidaCPF(valor);
				break;
			case "DATA" :
				ret = ValidaData(valor);
				break;
			case "LOGIN" :
				ret = ValidaLogin(valor);
				break;
			case "CNPJ"  :
				ret = ValidaCNPJ(valor);
				break;
			case "HORA"  :
				ret = ValidaHora(valor);
				break;
			case "VALOR"  :
				ret = ValidaValor(valor);
				break;
			case "TEL"  :
				ret = ValidaTel(valor);
				break;
			case "CEP"  :
				ret = ValidaCEP(valor);
				break;
			case "DDD"	:
				ret = ValidaDDD(valor)
				break;
			case "FAX"	:
				ret = ValidaFAX(valor)
				break;
				
			default :
				ret = true;
		}
		if (ret == false) {
			alert(msg2);
			obj.focus();
			return false;
		}
	}
	return true;
}

function ValidaValor(num)
{
	for (var i=0;i<num.length;i++) {
		if ((num.charAt(i) < "0") || (num.charAt(i) > "9")) {
			if (num.charAt(i) != ",") {
				return false;
			}
		}
	}
	return true;
}

function ValidaTel(num) {
	if (ValidaNumero(num)) {
		if (num.length < 7 || num.length > 8 || num.charAt(0) == "0") {
			return false
		}
		else {
			return true ;
		}
	}
	else {
		return false;
	}
}

function ValidaFAX(num) {
	if (ValidaNumero(num)) {
		if (num.length < 7 || num.length > 8 || num.charAt(0) == "0" || num.charAt(0) == "9") {
			return false
		}
		else {
			return true ;
		}
	}
	else {
		return false;
	}
}

function ValidaDDD(num) {
	if (ValidaNumero(num)) {
		if (num.charAt(0) == "9" || num.charAt(0) == "0") {
			return false
		}
		else {
			return true ;
		}
	}
	else {
		return false;
	}
}


function ValidaCEP(num) {
	if (ValidaNumero(num)) {
		if (num.length != 8) {
			return false
		}
		else {
			return true ;
		}
	}
	else {
		return false;
	}
}

function ValidaNumero(num)
{
	for (var i=0;i<num.length;i++) {
		if ((num.charAt(i) < "0") || (num.charAt(i) > "9")) {
			return false;
		}
	}
	return true;
}

function ValidaEmail(email) {
        var achou_ponto=false;
        var achou_arroba=false;
        var achou_caracter=false;
        for (var i=0; i<email.length; i++) {
                if (email.charAt(i)=="@") achou_arroba=true;
                else if (email.charAt(i)==".") achou_ponto=true;
                else if (email.charAt(i)!=" ") achou_caracter=true;
        }
        return (achou_ponto & achou_arroba & achou_caracter);
}

function ValidaData (data) {
	separador = '/';
	aux = data;
	barras = 0;
	erro = 0;
	dia = 0;
	mes = 0;
	ano = 0;
	eh_barra = 1;

	meses = new Array(12);
	meses = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	
	for (var i=0; (i<aux.length) && (erro==0); i++) {
		if (aux.charAt(i)==separador) {
			if (eh_barra==0) {
				barras++;
				eh_barra = 1;
			}
			else erro = 1;
		}
		else {
			a = parseInt(aux.charAt(i), 10);
			if (isNaN(a)) erro = 1;
			eh_barra = 0;
		}
	}
	if (barras != 2) erro = 1;

	if (erro==0) {
		pos = aux.indexOf(separador);
		pos2 = aux.indexOf(separador, pos+1);
		dia = parseInt(aux.substring(0, pos), 10);
		mes = parseInt(aux.substring(pos+1, pos2), 10);
		ano = parseInt(aux.substring(pos2+1, aux.length), 10);
		if (ano<1900 || ano>2050) erro = 1;
		else {
			if (eh_bissexto(ano)) meses[1] = 29;
			else meses[1] = 28;
			if (mes<1 || mes>12) erro = 1;
			else if (dia<1 || dia>meses[mes-1]) erro = 1;
		}
	}
	if (erro==1) return false;
	return true;
}

function ValidaLogin(campo)
{
	letras="false";
	var vetor=new Array("ç", "Ç", "á", "Á", "à", "À", "ã", "Ã", "â", "Â", "é", "É", "è", "È", "ê", "Ê", "ë", "Ë", "í", "Í", "ì", "Ì", "î", "Î", "ï", "Ï", "ó", "Ó", "ò", "Ò", "ô", "Ô", "ö", "Ö", "õ", "Õ", "ú", "Ú", "ù", "Ù", "ü", "Ü", "û", "Û", "^", "`", "'", "~");
	var temp;
	for(i=0;i<campo.length;i++)
	{
		temp=campo.substring(i,i+1);
		for (x=0;x<100;x++)
		{
			if (vetor[x]==temp)
			{
				letras="true";
			}
		}
	}
	if (letras=="true") 
	{
		return false;
	}
	return true;
}

function eh_bissexto(ano)
{
	if ( ((ano - 1996) % 4) == 0) return true;
	return false;
}

function CriaArray(n) {
	this.length=n
	for (var i=1;i<=n;i++)
		{this[i]=""}
}

function ValidaCNPJ(campo) {
 with (Math) {
	 w = 0;
	 Resp1 = "";
	 Resp2 = "";
	 CGC = campo;
 
	 if (CGC.length != 14) {
	 	return false;
	 }
 
	 if (!ValidaNumero(CGC)) { 
	 	return false;
	 }
 
	 VtCGC = new CriaArray(CGC.length);

	 for (var i=0;i < CGC.length;i++) {
 		if ((CGC.charAt(i) == "0") || (CGC.charAt(i) == "1") || (CGC.charAt(i) == "2") || (CGC.charAt(i) == "3") || (CGC.charAt(i) == "4") || (CGC.charAt(i) == "5") || (CGC.charAt(i) == "6") || (CGC.charAt(i) == "7") || (CGC.charAt(i) == "8") || (CGC.charAt(i) == "9")) {
	 		VtCGC[w]=parseFloat(CGC.charAt(i));	
	 		w++;
		}
 	}


 	Soma1 = (VtCGC[0]*5)+(VtCGC[1]*4)+(VtCGC[2]*3)+(VtCGC[3]*2)+(VtCGC[4]*9)+(VtCGC[5]*8)+(VtCGC[6]*7)+(VtCGC[7]*6)+(VtCGC[8]*5)+(VtCGC[9]*4)+(VtCGC[10]*3)+(VtCGC[11]*2)+0.0001;
 	Divisao1 = Soma1 / 11; 
 	RestoParc1 = (Divisao1 - floor(Divisao1))*11;
 	Resto1 = floor(RestoParc1);
 
 	Soma2 = (VtCGC[0]*6)+(VtCGC[1]*5)+(VtCGC[2]*4)+(VtCGC[3]*3)+(VtCGC[4]*2)+(VtCGC[5]*9)+(VtCGC[6]*8)+(VtCGC[7]*7)+(VtCGC[8]*6)+(VtCGC[9]*5)+(VtCGC[10]*4)+(VtCGC[11]*3)+(VtCGC[12]*2)+0.0001;
 	Divisao2 = Soma2 / 11; 
 	RestoParc2 = (Divisao2 - floor(Divisao2))*11;
 	Resto2 = floor(RestoParc2);


 	if (((Resto1 == 0) || (Resto1 == 1)) && (VtCGC[12] == 0)) {
  		Resp1 = "V";
 	} else {
  		Digito1 = 11 - Resto1;
  		if ((Digito1 == VtCGC[12]) && (Resto1 > 1)) {
			Resp1 = "V";
  		}
 	}
 
 	if (((Resto2 == 0) || (Resto2 == 1)) && (VtCGC[13] == 0)) {
  		Resp2 = "V";
 	} else {
  		Digito2 = 11 - Resto2;
  		if ((Digito2 == VtCGC[13]) && (Resto2 > 1)) {
   			Resp2 = "V";
  		}
 	}
 
 	if ((Resp1 == "V") && (Resp2 == "V")) 
 	{
   		return true;
 	} else {
  		return false;   
 	} 
 }
}

function ValidaHora(campo) {
	tam = campo.length;
	
	if (tam != 5 && tam != 8)
		return false;
	
	if (campo.charAt(2) != ":") 
		return false;

	if (tam == 8) 
		if (campo.charAt(5) != ":") 
			return false;

	hora = campo.substring(0, 2);
	minuto = campo.substring(3, 5);

	segundo = "00"
	if (tam == 8) 
		segundo = campo.substring(6, 8);

	if (!ValidaNumero(hora)) return false;
	if (!ValidaNumero(minuto)) return false;
	if (!ValidaNumero(segundo)) return false;

	if (hora > 23) return false;
	if (minuto > 59) return false;
	if (segundo > 59) return false;
}

function StringToDate(dateParam) {
	var arr = dateParam.split('/');
	var myDate = new Date(parseFloat(arr[2]), parseFloat(arr[1])-1, parseFloat(arr[0]));
	return myDate;
}

function ValidaCheckBox (obj, msg) {
	achou = false;
	if (obj) {
		if (obj.length) {
			for (i=0;i<obj.length;i++) {
				if (obj[i].checked) {
					achou = true;
					return true;
					break;								
				}
			}				
			if (!achou) {
				alert(msg);
				return false;
			}
		}
		else
		{
			if (!obj.checked) {
				alert(msg);
				return false;
			}
		}
	}	
}

function ValidaPeriodo (data) {
	separador = '/';
	aux = data;
	barras = 0;
	erro = 0;
	mes = 0;
	ano = 0;
	eh_barra = 1;
	
	for (var i=0; (i<aux.length) && (erro==0); i++) {
		if (aux.charAt(i)==separador) {
			if (eh_barra==0) {
				barras++;
				eh_barra = 1;
			}
			else erro = 1;
		}
		else {
			a = parseInt(aux.charAt(i), 10);
			if (isNaN(a)) erro = 1;
			eh_barra = 0;
		}
	}
	if (barras != 1) erro = 1;

	if (erro==0) {
		pos = aux.indexOf(separador);
		mes = parseInt(aux.substring(0, pos), 10);
		if (mes <1 || mes >12) erro = 1;
		ano = parseInt(aux.substring(pos+1, aux.length), 10);
		if (ano<1900 || ano>2050) erro = 1;
	}
	if (erro==1) return false;
	return true;
}

function capturaCodTecla(e) {
	codTeclaKeyDown = (isNav) ? e.which : event.keyCode;
	if (isIE) {
		switch (codTeclaKeyDown) {
			case 8:
				event.srcElement.value = formatarValor(event.srcElement.value.substring(0,event.srcElement.value.length-1));
				return false;
			break;
			case 46:
				event.srcElement.value = formatarValor(event.srcElement.value.substring(0,event.srcElement.value.length-1));
				return false;
			break;
		}
	}
}

function formatarValor(str){
  var decimal,inteiro;
  var i,count;
  STR = new String(str);
  STR = tirarZerosEsquerda(STR);
  inteiro='';
		if (STR.length == 1){
			  inteiro  = '0';
			  decimal = '0' + STR;
			}
			else { 
			  if (STR.length == 2){
				  inteiro  = '0';
				  decimal = STR;
				}
				else{
				  decimal = STR.substring(STR.length-2,STR.length);
				  i=3;
				  count=0;
				  while (i<=STR.length){
			 		if (count==3) {
					  inteiro = '.' + inteiro;
					  count = 0;
					}
				    inteiro = STR.charAt(STR.length-i) + inteiro;
					count++;
					i++;
				  }
				}
			}
		if (inteiro == '') {
		  inteiro = '0';
		}
		if (decimal == '') {
		  decimal = '00';
		}
		return inteiro+','+decimal;
}

function tirarZerosEsquerda(STR){
	var sAux = '';
	STR = new String(STR);  
	var i = 0;
	while (i < STR.length ){
		if ((STR.charAt(i)!='.') && (STR.charAt(i)!=',')){
			sAux += STR.charAt(i);
		}
		i++
	}
  STR = new String(sAux);
  sAux = '';
  i = 0;
  while (i < STR.length ){
    if (STR.charAt(i) != '0'){
      sAux = STR.substring(i,STR.length)
	  i = STR.length;
	}
    i++;
  }
  return  sAux;
}

function soNumero(e) {
	var keyNumber = (isIE) ? event.keyCode : e.which;
	if (((keyNumber<48)||(keyNumber>57)) && (keyNumber!=13) && (keyNumber!="0") && (keyNumber!=8)) {
		if (isIE) {
			event.keyCode=0
		}
		return false;
	}
	return true;
}

function exibirValorFormatado(e) {
		var obj,tecla;
		//verificando se o que foi digitado é um número
		if (!soNumero(e)){
			return false;
		}
		obj   = (isNav) ? e.target : event.srcElement;
		codTecla = (isNav) ? e.which : event.keyCode;

		if (obj.value.length + 1 > 13) {
			return false;
		}
		
		switch (codTeclaKeyDown) {
			case 8:
				obj.value = formatarValor(obj.value.substring(0,obj.value.length-1));
				break;
			case 9:
				return true;
				break;
			case 46:
				obj.value = formatarValor(obj.value.substring(0,obj.value.length-1));	
				break;
			default :
					if ((codTecla>47)&&(codTecla<58)) {
						obj.value = formatarValor(obj.value + String.fromCharCode(codTecla));
					}
		}
		return false;
}

function SetaValidacaoCampo(obj) {
	obj.onkeypress	= exibirValorFormatado;
	obj.onkeydown	= capturaCodTecla;
	if (navigator.appName != "Netscape") {
		obj.style.textAlign	= "right";
	}
}



function ValidaDataAtual(obj,a,m,d,msg) {
//Verifica se a data de entrada é maior que a data de hoje. Se for, alerta
    dia = obj.value.substr(0,2);
    mes = parseInt(obj.value.substr(3,2)-1);                    
    ano = obj.value.substr(6,4);                    
    data_de_entrada = new Date();
    data_de_entrada.setFullYear(ano,mes,dia);
    hoje = new Date();                    
    hoje.setFullYear(a,m,d);
    if (hoje.getTime() > data_de_entrada.getTime()){       
        if((dia==d)&&(mes==m)&(ano==a)){
            return true
        }
        else{
            alert(msg);
            obj.focus();                    	 
            return false;
        }
    }
    else{
        return true;
    }
}

function DateDiff(strFim, strInicio) {
	var	Inicio, Fim
	var	tmpInicio, tmpFim
	var	Days
	
	if(strInicio.toUpperCase() != "NOW") {
		tmpDate =	strInicio.substring(6, 10) + "/" + strInicio.substring(3, 5) + "/" + strInicio.substring(0, 2);
		Inicio = new Date(tmpDate);
	} else {
		Inicio = new Date();
	}

	if(strFim.toUpperCase() != "NOW") {
		tmpDate =	strFim.substring(6, 10) + "/" + strFim.substring(3, 5) + "/" + strFim.substring(0, 2);
		Fim = new Date(tmpDate);
	} else {
		Fim = new Date();
	}
	//alert("<<<-->>>" + Inicio.getTime())
	//alert("<<<-->>>" + Fim.getTime())
	msecondsPerMinute = 1000 * 60;
	msecondsPerHour = msecondsPerMinute * 60;
	msecondsPerDay = msecondsPerHour * 24;

	interval = Fim.getTime() - Inicio.getTime(); // Difference in ms.
	Days = Math.ceil(interval / msecondsPerDay);
	delete Inicio;
	delete Fim;
	
	return Days;
}

// Calcula a soma entre uma data e um número de dias
function DateAdd(strInicio, Days) {
	var	Inicio, Fim
	var	tmpInicio, tmpFim
	var	strFim
	
	Inicio = new Date()
	if(strInicio.toUpperCase() != "NOW") {
		Inicio.setDate(parseInt(strInicio.substring(0, 2)));
		Inicio.setMonth(parseInt(strInicio.substring(3, 5) - 1));
		Inicio.setYear(parseInt(strInicio.substring(6, 10)));
	}
//	alert(Inicio.getDate());
//	alert(Inicio.getMonth());
//	alert(Inicio.getYear());
	
	Fim = new Date();
	Fim.setDate(Inicio.getDate() + Days);
	
	Day = parseInt(Fim.getDate());
	if(Day <= 9) Day = '0' + Day;
//	alert('day='+Day);
	
//	alert('fimgetmonth='+parseInt(Fim.getMonth()));
//	alert('fimgetmonth+1='+parseInt(Fim.getMonth()+1));
	Month = parseInt(Fim.getMonth())+1;
	if(Month <= 9) Month = '0' + Month;
//	alert('month='+Month);
	
	Year = parseInt(Fim.getYear());
//	alert('ano='+Year);

	strFim = Day + '/' + Month + '/' + Year;
	
	delete Inicio;
	delete Fim;
//	alert(strFim);
	return strFim;
}
//fim valida.js

//popup ajuda
function PopupAjuda(c) {
	window.open("/popupajuda.asp?conteudo="+c, "_blank", "width=385,height=500");
}
//fim popup ajuda

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
function ValidaExtensao(file,span){
	if(Right(file.value.toLowerCase(),4)!='.jpg' && Right(file.value.toLowerCase(),4)!='jpeg'){
		//alert('Extensão de arquivo não suportada!');
		alert('O tipo de arquivo não é valido. Selecione um arquivo com a extensão .JPG');
		document.getElementById(span).innerHTML = document.getElementById(span).innerHTML;
	}
}
function ValidaExtensao2(file,span,ext){
	if(Right(file.value.toUpperCase(),4)!=ext && Right(file.value.toUpperCase(),4)!=ext){
		alert('O tipo de arquivo não é valido. Selecione um arquivo com a extensão '+ext.toUpperCase());
		file.value = '';
	}
}

function removeEspacos(valor){
	return replaceAll(valor," ","");
}	

//COMEÇO COMPARTILHAMENTO
function AddContact() {
	var frm = $("frmShare");
	contact = removeEspacos(frm.contact.value); 
	if (contact=="") {
		alert("Informe o nome do destinatário");
		frm.contact.focus();
		return;
	}
	email = removeEspacos(frm.email.value); 
	if (email=="") {
		alert("Informe o email do destinatário");
		frm.email.focus();
		return;
	}
	
	if (!ValidaEmail(email)) {
		alert("Formato de e-mail inválido");
		frm.email.focus();
		return;
	}
	SendRequestResponse("/custom/actions/setContact.asp?nome="+frm.contact.value+"&email="+frm.email.value);
	SetContact(frm.contact.value, frm.email.value);
	
	frm.exibiu_msg.value = "0";

	frm.email.value = "";
	frm.contact.value = "";
}
var isShareWindow = true;
var listMail = new Array();

function SetContact(n,e) {
	var frm = document.frmShare;
	var pos = frm.contacts.options.length++;
	frm.contacts[pos].value = n + "|" + e;
	frm.contacts[pos].text = n + " (" + e + ")";
	listMail[pos] = e ;
}
function RemoveContact() {
	var frm = document.frmShare;
	var arr = new Array();
	for (x=0;x<frm.contacts.length;x++) {
		if (!frm.contacts[x].selected) {
			arr[arr.length++] = new MyContact(frm.contacts[x].value, frm.contacts[x].text);
		}else{
			SendRequestResponse("/custom/actions/setContact.asp?nome="+frm.contacts[x].value+"&email="+frm.contacts[x].text+"&action=remove");
		}
	}
	if (arr.length==frm.contacts.length) {
		alert("Nenhum contato foi selecionado");
	} else {
		frm.contacts.length=0;
		for (x=0;x<arr.length;x++) {
			pos = frm.contacts.length++;
			frm.contacts[pos].value = arr[x].value;
			frm.contacts[pos].text = arr[x].text;
		}	
	}
}
function AddressBook() {
	j = window.open("/popaddressbook.asp?return=share", "addressbook", "width=600,height=600,scrollbars=yes,resizable=1");
	if (j==null) alert("Você possui um bloqueador de pop-ups ativo em seu navegador.\nDesabilite esta opção para abrir o Catálogo de Endereços.");
	else j.focus();
}

function getContactList() {
	var frm = document.frmShare;
	var sRet  ;
	var virgula;

	virgula = "" ;
	sRet    = "" ;
				
	for (x=0;x<listMail.length;x++) {
		sRet = "" + sRet + "" + virgula + "" + listMail[x]; 
		virgula = "," ;
	}
	frm.tot_emails.value = listMail.length;
	return sRet;		
}


function MyContact(v,t) {
	this.value = v;
	this.text = t;
}

//alt fernando
function dialog2(p_text) {
	var ponto
	ponto = ""
	try{
		ponto = "2";
		$('msg2').innerHTML                 = "<BR>" + p_text
		ponto = "3";
		$('Fader').style.display = "block";
		ponto = "4";
		$('LayerDialogBox2').style.display  = "block"
		ponto = "5";
		$("contacts").style.visibility='hidden'
		$('frmShare').exibiu_msg.value = "0";
		parent.scroll(1,1);
	}catch(e){
		alert(  ponto + ' : ' + e.description );
	}
}

function dialog(p_text) {
	var ponto
	ponto = ""
	try{
		ponto = "2";
		$('msg').innerHTML  = "<BR>" + p_text
		ponto = "3";
		$('Fader').style.display = "block";
		ponto = "4";
		$('LayerDialogBox').style.display  = "block"
		ponto = "5";
		$("contacts").style.visibility='hidden'
		$('frmShare').exibiu_msg.value = "0";
		parent.scroll(1,1);
	}catch(e){
		alert(  ponto + ' : ' + e.description );
	}
}

function ok(nome) {
	$('Fader').style.display = "none";
	//LayerScreenAlfa.style.display = 'none'
	$(nome).style.display  = 'none'
	$("contacts").style.visibility='visible'
}

function compartilhar(obj) {
	$(obj).style.display  = 'none';
	$('AguardeBoxShare').style.display      = 'block';
	$('frmShare').submit();
}

function SharedPhotoCount() {
	var count = 0;
	var frm = document.frmShare;
	if (frm.f) {
		if (frm.f.length) {
			for (x=0;x<frm.f.length;x++) {
				if (frm.f[x].checked) count++;
			}
		} else {
			if (frm.f.checked) count++;
		}
	}
	var pc = $("photocount");
	pc.innerHTML = count;
	frm.count.value = count;
}

//FIM COMPARTILHAMENTO

//COMEÇO CONTACTS

function VerifyChecked() {
	var frm = $('frmAddressList');
	bOk = false;
	if (frm.c) {
		if (frm.c.length) {
			for(x=0;x<frm.c.length;x++) {
				if (frm.c[x].checked) {
					bOk = true;
					break;
				}
			}
		} else bOk = frm.c.checked 
	}
	return bOk;
}
function EditContact() {
	if (VerifyChecked()) $('frmAddressList').submit();
	else alert("Selecione pelo menos um contato");
}
function DeleteContact() {
	if (VerifyChecked()) {
		if(confirm("Confirma a exclusão dos contatos?")) {			
			with($('frmAddressList')) {
				action = "/custom/contactdelete.asp";
				submit();
				action = "";
			}
		}
	} else 
		alert("Selecione pelo menos um contato");
}

function CopyContacts() {
	if (!opener) return; if (!opener.isShareWindow) return;
	var frm = $('frmAddressList');
	if (frm.c) {
		if (frm.c.length) {
			for(x=0;x<frm.c.length;x++) {
				if (frm.c[x].checked) {
					arr = document.getElementById("c_"+frm.c[x].value).value.split("|");
					opener.SetContact(arr[0],arr[1]);
					SendRequestResponse("/custom/actions/setContact.asp?nome="+arr[0]+"&email="+arr[1]);
				}
			}
		} else {
			if (frm.c.checked) {
				arr = document.getElementById("c_"+frm.c.value).value.split("|");
				opener.SetContact(arr[0],arr[1]);
				SendRequestResponse("/custom/actions/setContact.asp?nome="+arr[0]+"&email="+arr[1]);
			}
		}
	}
	opener.focus();
	window.close();
}

function ValidateSubmitContactEdit(frm){
	if (ValidateContactEdit(frm)){
		frm.submit();
	}
}

function ValidateContactEdit(frm) {

	if (!VerificaObjeto(frm.contact_name,true,null,"Informe o nome", "")) return false;
	if (!VerificaObjeto(frm.contact_email,true,"EMAIL","Informe o email", "Email inválido")) return false;
	if (!VerificaObjeto(frm.zip_code,false,"NUM","", "CEP inválido")) return false;
	if (frm.phone_number.value!="") {
		if (!VerificaObjeto(frm.phone_area_code,true,"DDD","Informe o DDD do telefone", "DDD do telefone inválido")) 
			return false;
	}
	if (!VerificaObjeto(frm.phone_number,false,"TEL","", "Telefone inválido")) return false;
	if (frm.mobile_number.value!="") {
		if (!VerificaObjeto(frm.mobile_area_code,false,"Informe o DDD do telefone móvel","", "DDD do telefone móvel inválido"))
			return false;
	}
	if (!VerificaObjeto(frm.mobile_number,false,"TEL","", "Telefone móvel inválido")) return false;
	name = removeEspacos(frm.contact_name.value);
	if (name == ""){
		alert("Informe o nome");
		return false;
	}else{
		return true;
	}
}

//FIM CONTACTS

//COMEÇO CART

//PASSO 1

	function RemoveBookFromCart(b) {
		if(confirm("Tem certeza que deseja remover o fotolivro do carrinho?")) {
			document.location.href = "/books/actions/cartitemremovebook.asp?remove=" + b;
		}			
	}

	function RemoveConviteFromCart(b) {
		if(confirm("Tem certeza que deseja remover o cartão do carrinho?")) {
			document.location.href = "/produtos/system/actions/cartitemremoveconvite.asp?remove=" + b;
		}			
	}
	
	function RemoveCadernoFromCart(b) {
		if(confirm("Tem certeza que deseja remover o cartão do carrinho?")) {
			document.location.href = "/produtos/system/actions/cartitemremovecaderno.asp?remove=" + b;
		}			
	}

	function RemovePostCardFromCart(b) {
		if(confirm("Tem certeza que deseja remover o Cartão Postal do carrinho?")) {
			document.location.href = "/produtos/system/actions/cartitemremovepostcard.asp?remove=" + b;
		}			
	}
	
	function RemoveAgendaFromCart(b) {
		if(confirm("Tem certeza que deseja remover a Agenda do carrinho?")) {
			document.location.href = "/produtos/system/actions/cartitemremoveagenda.asp?remove=" + b;
		}			
	}
	
	function RemoveImaFromCart(b) {
		if(confirm("Tem certeza que deseja remover o Imã do carrinho?")) {
			document.location.href = "/produtos/system/actions/cartitemremoveima.asp?remove=" + b;
		}			
	}
	
	function RemoveCalendarioFromCart(b) {
		if(confirm("Tem certeza que deseja remover o Calendário do carrinho?")) {
			document.location.href = "/produtos/system/actions/cartitemremovecalendario.asp?remove=" + b;
		}			
	}
	
	function RemoveCanecaFromCart(b) {
		if(confirm("Tem certeza que deseja remover a caneca do carrinho?")) {
			document.location.href = "/produtos/system/actions/cartitemremovecaneca.asp?remove=" + b;
		}			
	}
	
	function validaQtd(obj){
		qtd = obj.value
		if (qtd == "0"){
			alert("A quantidade deve ser maior que 0!")
			obj.value = "1";
			obj.focus();
			return false;	
		}else{
			if (obj.id.indexOf("a_") != -1){
				SendRequestResponse("/custom/actions/savebooks.asp?item="+replaceAll(obj.id,"a_","")+"&qtd="+obj.value);
			}
			return true;
		}
	}
	
	function validaQtdProducts(obj){
		qtd = obj.value
		if (qtd == "0"){
			alert("A quantidade deve ser maior que 0!")
			obj.value = "1";
			obj.focus();
			return false;	
		}else{
			if (obj.id.indexOf("pc_") != -1){
				//alert("item="+replaceAll(obj.id,"pc_","")+"&qtd="+obj.value);
				SendRequestResponse("/custom/actions/saveproducts.asp?item="+replaceAll(obj.id,"pc_","")+"&qtd="+obj.value+"&type=postcard");
			}else if (obj.id.indexOf("cad_") != -1){
				//alert("/custom/actions/saveproducts.asp?item="+replaceAll(obj.id,"c_","")+"&qtd="+obj.value+"&type=convite")
				SendRequestResponse("/custom/actions/saveproducts.asp?item="+replaceAll(obj.id,"cad_","")+"&qtd="+obj.value+"&type=caderno");
			}else if (obj.id.indexOf("ag_") != -1){
				//alert("/custom/actions/saveproducts.asp?item="+replaceAll(obj.id,"c_","")+"&qtd="+obj.value+"&type=convite")
				SendRequestResponse("/custom/actions/saveproducts.asp?item="+replaceAll(obj.id,"ag_","")+"&qtd="+obj.value+"&type=agenda");
			}else if (obj.id.indexOf("c_") != -1){
				//alert("/custom/actions/saveproducts.asp?item="+replaceAll(obj.id,"c_","")+"&qtd="+obj.value+"&type=convite")
				SendRequestResponse("/custom/actions/saveproducts.asp?item="+replaceAll(obj.id,"c_","")+"&qtd="+obj.value+"&type=convite");
			}else if (obj.id.indexOf("cal_") != -1){
				//alert("/custom/actions/saveproducts.asp?item="+replaceAll(obj.id,"c_","")+"&qtd="+obj.value+"&type=convite")
				SendRequestResponse("/custom/actions/saveproducts.asp?item="+replaceAll(obj.id,"cal_","")+"&qtd="+obj.value+"&type=calendario");
			}else if (obj.id.indexOf("cn_") != -1){
				//alert("/custom/actions/saveproducts.asp?item="+replaceAll(obj.id,"cn_","")+"&qtd="+obj.value+"&type=caneca");
				SendRequestResponse("/custom/actions/saveproducts.asp?item="+replaceAll(obj.id,"cn_","")+"&qtd="+obj.value+"&type=caneca");
			}
			return true;
		}		
	}
	
	function validaQtdMin(obj,qtd_min){
		qtd = obj.value				
		if (parseInt(qtd) < qtd_min){
			alert("A quantidade deve ser maior ou igual a "+qtd_min+"!")
			obj.value = qtd_min;
			obj.focus();
			return false;	
		}else{
			//verificar se a qtd é par
			//alert((parseInt(qtd) % 2));
			if ((parseInt(qtd) % 2) != 0){
				alert("A quantidade de imãs deve ser múltipla de 2!")
				obj.value = parseInt(qtd) + 1;
				SendRequestResponse("/custom/actions/saveproducts.asp?item="+replaceAll(obj.id,"ima_","")+"&qtd="+(parseInt(qtd) + 1)+"&type=ima");
				obj.focus();
				return false;	
			}else{
				SendRequestResponse("/custom/actions/saveproducts.asp?item="+replaceAll(obj.id,"ima_","")+"&qtd="+obj.value+"&type=ima");
				return true;	
			}
		}
	}
	
	function SaveCart(num_pagina) {		
		with($('frmPhotoList')) {
			pagina.value = num_pagina;				
			action = "/custom/savecart.asp";				
			submit();				
		}
		//target = "_self";
		//action = "cart.asp";
	}
	
	function RemoveFromCart(p,num_pagina) {
		if(confirm("Tem certeza que deseja remover a foto do carrinho?")) {
			with($('frmPhotoList')) {
				action = "/custom/cartitemremove.asp?remove="+p;
				pagina.value = num_pagina;	
				submit();
			}
		}			
	}
	
	function RemovesFromCarts(num_pagina) {
		with($('frmPhotoList')) {
			//verificar todos os fotos que estão selecionadas					
			var photos = document.getElementsByName("f");
			//var res = frmRes.resolution[frmRes.resolution.selectedIndex].value;
			var str_photos = "";
			if (photos!=null) {
				for (x=0; x<photos.length; x++) {
					if (photos[x].checked) {
						str_photos = str_photos + photos[x].value + ",";
					}
				}
			}
			if (str_photos == ""){
				alert("Nenhuma foto foi selecionada!");
			}else if(confirm("Tem certeza que deseja remover a(s) foto(s) do carrinho?")) {
				action = "/custom/cartitemremove.asp?remove="+str_photos+"&action=fotos";
				submit();	
			}
			
		}
	}
	
	function ValidaAjuste(fid,obj) {			
		valor = replaceAll(obj.value," ","");
		if( isNaN( valor ) || valor == "" ){   	
			  alert( "Quantidade inválida!" );    
			  obj.focus();	
			  obj.value = "0";
		}else{
			obj.value = valor;
		}
		if (obj.value == "" || obj.value == "0"){				
			SendRequestResponse("/custom/savephotos.asp?item="+obj.id+"&qtd="+obj.value+"&action=remove");//exclui a variável de sessão
		}else{				
			SendRequestResponse("/custom/savephotos.asp?item="+obj.id+"&qtd="+obj.value);//inclui na variável de sessão a qtd da foto				
		}
	
		VerificaErros(fid);
	}
	
	function listaFotosBR(){
		SaveCart(-1);//pg = -1 FOTOS EM BR
		//document.location.href = '/cart.asp?pg=-1';			
	}
//FIM PASSO1

//COMEÇO PASSO2
	function adicionarAlbinho(num) { 
		with($('frmStep2')) {
			step.value = "2";
			submit();
		}
	}

	function Recalcular(num) { 
		with($('frmStep2')) {
			step.value = "2";
			num_pack.value = "-1";
			action = $('frmStep2').action + '#d'
			submit();
		}
	}

	function Pack(num) { 
		with($('frmStep2')) {
			step.value = "2";
			num_pack.value = num;
			action = $('frmStep2').action + '#d'
			cupom.value = "";
			submit();
		}
	}

	function atualizaFrete(valor) { 
		with($('frmStep2')) {
			step.value = "2";
			$('frmStep2').tipo_frete.value = valor
			action = $('frmStep2').action + '#d'
			submit();
		}
	}

	function RecalcularMMS(num) { 
		with($('frmStep2')) {
			promotion.value = "-1";//alteração 20080613
			action = $('frmStep2').action + '#d'//alteração 20080613
			step.value = "2";
			submit();
		}
	}

	function RecalcularShare(num) { 
		with($('frmStep2')) {
			promotion.value = "-2";//alteração 20080613
			action = $('frmStep2').action + '#d'//alteração 20080613
			step.value = "2";
			submit();
		}
	}

	function TotalizaDebito() {
		var frm = $('frmStep2');
		var total = ((frm.debito_conta.value=="") ? 0 : parseFloat(frm.debito_conta.value.replace("/,/gi", "."))) + ((frm.debito_cartao.value=="") ? 0 : parseFloat(frm.debito_cartao.value.replace("/,/gi", ".")));
		divTotalDebito.innerHTML = total.replace("/./gi", ",");
	}
	

// ## Verifica se o usuário teclou "Enter" na caixa de Texto do Cupom...
var flag = false;

	function mudaFlag( ){
	       if( event.keyCode == 13 )
		          flag = true;
	}

	function ValidateStep2() {
	// ## ... caso afirmativo, invoco o método "Recalcular" e submeto os dados para o Servidor
			if( flag ) {
				Recalcular( );
				flag = false;
				return true;
			}
		
		for (var i = 0; i<$('frmStep2').elements.length; i++) {
			if (($('frmStep2').elements[i].name.indexOf('p_') > -1)) {
				if ($('frmStep2').elements[i].value == "-99") {
					alert('Favor selecionar o tipo de papel.');
					$('frmStep2').elements[i].focus;
					return(false);
				}
			}
		 }


		for (var i = 0; i<$('frmStep2').elements.length; i++) {
			if (($('frmStep2').elements[i].name.indexOf('b_') > -1)) {
				if ($('frmStep2').elements[i].value == "-99") {
					alert('Favor selecionar o tipo de borda.');
					$('frmStep2').elements[i].focus;
					return(false);
				}
			}
		}

		
		var frm = $('frmStep2');

		var p_total = parseFloat(frm.total.value);		
		var p_debito_conta = parseFloat(frm.debito_conta.value);
		var p_debito_cartao = parseFloat(frm.debito_cartao.value);
		var id_div_aguarde = 'aguarde_proc_pgto';
		
		//alert(p_debito_conta);
		//alert(p_debito_cartao);
		//alert(p_total);
		
			if (p_debito_conta+p_debito_cartao!=p_total) {		
					var somaDebitos = "" + (p_debito_conta + p_debito_cartao);
					var index =somaDebitos.indexOf(".");					
					var doisDigitos = somaDebitos.slice(index+1, index+3);	
					var formatedNumber = somaDebitos.slice(0, index).concat(".").concat(doisDigitos);
					var floatNumber = parseFloat(formatedNumber);

							if( floatNumber != p_total ){
									alert("Valores de pagamento incorretos");
									return false;
							}
			}
		

		
		if ( p_debito_cartao > 0 ) {
			var blnPaymentType = false;

			for ( x = 0; x < frm.payment_type.length; x++ ) {

				if ( frm.payment_type[x].checked ) {
						blnPaymentType = true;
						break;
				}
			}

			if ( ! blnPaymentType ) {
					alert( "Informe a forma de pagamento" );
					return false;
			}

			if ( frm.forma_pgto.value == "cartao" ) {
				if ( ! VerificaObjeto( frm.card_number, true, "NUM","Informe o número do cartão", "Número de cartão inválido" ) ) return false;
				if ( ! VerificaObjeto( frm.security_code, true, "NUM","Informe o código de segurança", "Código de segurança inválido" ) ) return false;
				if ( ! VerificaObjeto( frm.card_name, true, "", "Informe o nome impresso no cartão", "" ) ) return false;
				if ( ! VerificaObjeto( frm.card_expiration_month, true, "", "Informe a data de expiração", "" ) ) return false;
				if ( ! VerificaObjeto( frm.card_expiration_year, true, "", "Informe a data de expiração", "" ) ) return false;
			  }
			  
			  if ( frm.forma_pgto.value == "oi_paggo" ) {
				//validar o número do celular e a qtd de dígitos
				if (frm.oi_number.value == "" ) {
					alert("Favor preencher o número do celular!");
					return false;
				}else if (frm.oi_number.value.length < 10){
					alert("O número do celular deve possuir 10 números (ddd + número)!");
					return false;
				}else{
					id_div_aguarde = 'aguarde_oi_paggo';
				}								
			  }
		}

//		if (p_debito_conta+p_debito_cartao!=p_total) {
//			alert("Valor informado diferente do total");
//			return false;
//		}
		$("Fader").style.display = "block";
		$(id_div_aguarde).style.display = "block";
		parent.scroll(1,1);			
		//return false;
		return true;
	}
	
	function CalculaDiferecaCartao() {
		var frm = $('frmStep2');

		p_utilizado = 0.0;
		if (frm.debito_conta.value!="") {
			p_utilizado = parseFloat(frm.debito_conta.value);
			if (p_utilizado<0) {
				alert("Valor não pode ser negativo");
				frm.debito_conta.value = "";
				frm.debito_conta.focus();
				return;
			}
		}

		p_total = parseFloat(frm.total.value);
		p_saldo = parseFloat(frm.saldo_conta.value);

		if (p_utilizado>p_saldo) {
			alert("Valor superior ao saldo disponível");
			p_utilizado = p_saldo;
		} 
		if (p_utilizado>p_total) {
			alert("Valor informado diferente do total da compra");
			p_utilizado = p_total;
		}
		p_saldo -= p_utilizado;
		

		$('divSaldoConta').innerHTML = p_saldo;
//		frm.saldo_conta.value = p_saldo;
		frm.debito_conta.value = p_utilizado;
		frm.debito_cartao.value = p_total-p_utilizado;

	}
	
	function UsarSaldoConta(bln) {
		var frm = $('frmStep2');

		p_total = parseFloat(frm.total.value);
		p_saldo = parseFloat(frm.saldo_conta.value);
		p_utilizado = 0;

		if (bln) {
			if (p_saldo>p_total) {
				p_utilizado = p_total;
				p_saldo -= p_utilizado;
			} else {
				p_utilizado = p_saldo;
				p_saldo = 0;
			}
		}		
		
		
		$('divSaldoConta').innerHTML = FormataDecimal(p_saldo);
//		frm.saldo_conta.value = p_saldo;
		frm.debito_conta.value = FormataDecimal(p_utilizado);
		frm.debito_cartao.value = FormataDecimal(p_total-p_utilizado);
	}
	
	function FormataDecimal(vl)  {
		vl += 0.00001;
		vl2 = ''+vl;
		pos = vl2.indexOf('.');
		return vl2.substr(0,pos+3);
	}
	
	 // AlteraFormaPgto:
	 // Função que exibe o formulário referente à forma de pgto escolhida e esconde o(s) outro(s)
	 function alteraFormaPgto( obj ) {
			var formaPgto;
			var divCartao;
			var divItau;

			formaPgto = obj.value;

			if ( formaPgto == "visa" || formaPgto == "master" || formaPgto == "diners") {
				$( "forma_pgto" ).value = "cartao";
			} else if ( formaPgto == "itau" ) {
				$( "forma_pgto" ).value = "itau";
			} else if (formaPgto == "oi_paggo") {
				$( "forma_pgto" ).value = "oi_paggo";
			} 
			//alert(document.getElementById( "forma_pgto" ).value);
	 }
	 
	 function calcula_promocao(id_promocao) { 
	 //alert("calcula_promocao = "+id_promocao);
		with($('frmStep2')) {		
			step.value = "2";
			action = $('frmStep2').action + '#d'
			promotion.value = id_promocao;
			cupom.value = "";			
			submit();
		
		}
	}

	 function calcula_promocao_default(id_promocao) { 
	 //alert("calcula_promocao_default = "+id_promocao);
		with($('frmStep2')) {
			calculou_promocao_default.value = "1";
			step.value = "2";
			action = $('frmStep2').action + '#d'
			promotion.value = id_promocao;
			cupom.value = "";			
			submit();		
		}
	}    

//FIM PASSO2

//FIM CART

//BARRA IG
	function $$(o){return document.getElementById(o)}; function buscaiG(frm1){ if(frm1.q.value == "Fa&ccedil;a sua busca" || frm1.q.value == "Faça sua busca" ){ alert("Digite uma consulta antes de acionar a busca") }else{ window.open("http://busca.igbusca.com.br/app/search?q="+escape(frm1.q.value)+"&o=BARRAIG") }return false} function autoComplete(){ if($$('buscaig').q.value == "Fa&ccedil;a sua busca" || $$('buscaig').q.value == "Faça sua busca" ){ $$('buscaig').q.value = "" }return false }
//FIM BARRA IG

function validaLimiteTextArea( obj,evt ) {
	if ( obj.value.length < obj.getAttribute('maxLenght') ) {
		return true;
	} else {
		if ( evt.keyCode == 8 || evt.keyCode == 9 || evt.keyCode == 46 || ((evt.keyCode >= 33) && (evt.keyCode <= 40)) ){
			return true;
		}else{
			return false;
		}
	}
}

//books getstarted
function carregarGaleriaFotos() {
	if (document.images) {
	
		preload_image_object = new Image();
		
		image_url = new Array('/books/fotoalbumtutor/images/imgs/img1_m.jpg','/books/fotoalbumtutor/images/imgs/img2_m.jpg','/books/fotoalbumtutor/images/imgs/img3_m.jpg','/books/fotoalbumtutor/images/imgs/img4_m.jpg','/books/fotoalbumtutor/images/imgs/img5_m.jpg','/books/fotoalbumtutor/images/imgs/img6_m.jpg','books/fotoalbumtutor/images/imgs/img7_m.jpg','/books/fotoalbumtutor/images/imgs/img8_m.jpg','/books/fotoalbumtutor/images/imgs/img9_m.jpg','/books/fotoalbumtutor/images/imgs/img10_m.jpg');
		for (var i=0; i<=image_url.length-1; i++) {
			preload_image_object.src = image_url[i];
		}
	}
}
function showPic(imageURL){
	var err = "#0";
	try{
	err = "#1";
	document.getElementById('zoomImagem').innerHTML = "<img src='/books/selecaoFotos/loader_fotos.gif' style='padding-top:120px;'/><BR>Aguarde...";	
	document.getElementById('zoomImagem').innerHTML = "<img src='" + imageURL + "'/>";
	err = "#2";
	document.getElementById('light').style.display='block';
	err = "#3";
	document.getElementById('Fader').zIndex = 1000;
	document.getElementById('Fader').style.display='block';
	}catch(e){
	alert('erro [' + err + ']:' + e.description);
	}
}

function closezoom(){
	document.getElementById('light').style.display='none';
	document.getElementById('Fader').style.display='none';
	document.getElementById('zoomImagem').innerHTML = "<img src='/books/selecaoFotos/loader_fotos.gif' style='padding-top:120px;'/><BR>Aguarde...";	
}
//fim books getstarted

//começo xmlHttpRequest.js
/*

Apenas chame a funcao SendRequest(url) e pronto


*/
var agt = navigator.userAgent.toLowerCase();
var is_ie = (agt.indexOf('msie') != -1);
var is_ie5 = (agt.indexOf('msie 5') != -1);

function CreateXmlHttpReq(handler) {
	var xmlhttp = null;
	if (is_ie) {
		var control = (is_ie5) ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP";

		try {
			xmlhttp = new ActiveXObject(control);
			xmlhttp.onreadystatechange = handler;
		} catch(e) {
			alert("Active Scripting e controles Activex devem estar habilitados");
		}

	} else {
		xmlhttp = new XMLHttpRequest();
		xmlhttp.onload = handler;
		xmlhttp.onerror = handler;
	}
	return xmlhttp;
}

function DummyHandler() { }

function XmlHttpGET(xmlhttp, url) {
	xmlhttp.open('GET', url, true);
	xmlhttp.send(null);
}

function SendRequest(url) {
	var xmlhttp = CreateXmlHttpReq(DummyHandler);
	XmlHttpGET(xmlhttp, url);
}

function XmlHttpResponse(xmlhttp, url) {
	xmlhttp.open('GET', url, false);
	xmlhttp.send(null);
	return xmlhttp.responseText;
}

function SendRequestResponse(url) {
	var xmlhttp = CreateXmlHttpReq(DummyHandler);
	return XmlHttpResponse(xmlhttp, url);
}
//fim xmlHttpRequest.js

//começo /includes/ajax.js
//----------------------------------------------------
//-- Método sincrono para a chamada do Ajax
//-- ( o browser fica aguardando a resposta )
//----------------------------------------------------

var http_request_sync = false;
function getRequestSync(url) {

	http_request_sync = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request_sync = new XMLHttpRequest();

		if (http_request_sync.overrideMimeType) {
			http_request_sync.overrideMimeType('text/xml');
			// See note below about this line
		}

	} else if (window.ActiveXObject) { // IE
		try {
			http_request_sync = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request_sync = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request_sync) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}

	http_request_sync.onreadystatechange = dummyFunction;
	http_request_sync.open('GET', url, false);
	http_request_sync.send(null);
	return (http_request_sync.responseText);

}

function dummyFunction() {

}
//fim /includes/ajax.js	

//começo /cadastro/ajax/ajax.js

var http;

function validaFaixaCep( ) {     		
	var cep =  document.getElementById( 'cep' ).value.slice( 0, 5 );
	var estado = document.getElementById( 'estado' ).value;
	var tipoRetorno = true;
   

	http = createHttpRequest( );
	http.open('GET',  'buscaFaixaCep.asp?estado=' + estado, false);
	http.send(null);		
	
	var resposta = http.responseText;						 
	 var faixas = resposta.split( " ");								   

							if( cep < faixas[ 0 ]  ||  cep > faixas[ 1 ] )	{										
								tipoRetorno = false;
							}

	if( tipoRetorno == false )
				return false;
			else
				return true; 
}



function createHttpRequest( ){
	 
	if (window.XMLHttpRequest) 
		return new XMLHttpRequest();           
	else 
		if (window.ActiveXObject) 
			 try {
				 return  new ActiveXObject("Msxml2.XMLHTTP");
			 } catch (e) {                 
				 return new ActiveXObject("Microsoft.XMLHTTP");
			}              
}
//fim /cadastro/ajax/ajax.js

function goPrintPartners(){
	document.location.href = '/selecaoFotos/selectFotos.asp'
}

function exibeFader(nomeFader,b,tipo){	
	if (b == true){
		if  (( navigator.userAgent.indexOf("IE") != -1)) {
	
			$(nomeFader).style.display = 'block';
		}else{
			//$(nomeFader).style.display = 'block';
			jQuery("#"+nomeFader).fadeIn( tipo );	
		}			
	}else{					
		//$(nomeFader).style.display = 'none';
		
		if  (( navigator.userAgent.indexOf("IE") != -1)) {					
			$(nomeFader).style.display = 'none';
		}else{
			jQuery("#"+nomeFader).fadeOut( tipo );	
		}
	}		
}	

function exibePopMsg(nomeBox,b,nomeFader,bfader,tipo){	
	if (nomeFader != ""){
		exibeFader(nomeFader,bfader,tipo);
	}					
	
	if (b == true){		
		//$(nomeBox).style.display = 'block';
		jQuery("#"+nomeBox).fadeIn( tipo );	
	}else{
		//$(nomeBox).style.display = 'none';
		jQuery("#"+nomeBox).fadeOut( tipo );	
	}						
}

//*promoção indique um amigo*/
function showPopPromoIndique(b){
	//alert($('Layer_indique'));
	//alert("entrou aki1");	
	if (b == true){		
		posicionaPopFadeByScroll("layer_indique");
		//$('Layer_indique').style.display = 'block';		
		exibePopMsg('layer_indique',true,'Fader',true,'slow');				
	}else{
		exibePopMsg('layer_indique',false,'Fader',false,'fast');		
	}	
	//alert("entrou aki2");
	//alert($('Layer_indique').style.display);
	//$('layer_indique').style.display = 'block';			
}

function showPopPrePago(b, box_id){
	//alert($('Layer_indique'));
	//alert("entrou aki1");	
	if (b == true){		
		posicionaPopFadeByScroll('layer_pre_pago'+box_id);
		//$('Layer_indique').style.display = 'block';		
		exibePopMsg('layer_pre_pago'+box_id,true,'Fader',true,'slow');				
	}else{
		exibePopMsg('layer_pre_pago'+box_id,false,'Fader',false,'fast');		
	}	
	//alert("entrou aki2");
	//alert($('Layer_indique').style.display);
	//$('layer_indique').style.display = 'block';			
}

function regulamento_convide(){
  var win = window.open('convide_regulamento.asp','RegulamentoConvide','width=816,height=500,scrollbars=yes,top=0,left=0,status=no,toolbar=yes,menubar=no,location=no,resizable=no');
}
//*fim promoção indique um amigo*/

//pop-fade erro upload
function exibePopFormErroUpload(b){	
	parent.viewFormErroUpload(false);	
	if (b == true){		
		$('msg_sucesso_erro_upload').style.display = 'none';
		//insere na tabela "erro_upload"
		registerErroUpload();
		posicionaPopFadeByScroll("box-form-erro-upload");				
		exibePopMsg('box-form-erro-upload',true,'Fader',true,'slow');				
	}else{
		exibePopMsg('box-form-erro-upload',false,'Fader',false,'fast');		
	}	
}

function registerErroUpload(){
	//table: erro_upload
	//id,user_id,data,remote_addr,tipo_upload,ip_origem,navegador,SO,http_user_agent,erro_interno,info_id,album_id,tp_entrada
	frm = _$('erro_form_upload');
	var tipo_upload_erro_upload 	= frm.tipo_upload_erro_upload.value;
	var erro_interno_erro_upload 	= frm.erro_interno_erro_upload.value;
	var album_id_cript_erro_upload 	= frm.album_id_cript_erro_upload.value;	
	var album_id_erro_erro_upload 	= frm.album_id_erro_erro_upload.value; 
	var tp_entrada					= frm.clicou_no_link_erro_upload.value;
	var email_erro_upload			= frm.email_erro_upload.value;
	//alert(tp_entrada);
	var id = SendRequestResponse("/custom/actions/inclui_erro_upload.asp?action=addErroUpload&tipo_upload_erro_upload="+tipo_upload_erro_upload+"&erro_interno_erro_upload="+erro_interno_erro_upload+"&album_id_cript_erro_upload="+album_id_cript_erro_upload+"&album_id_erro_erro_upload="+album_id_erro_erro_upload+"&tp_entrada="+tp_entrada+"&email_erro_upload="+email_erro_upload);
	
	if (id != ""){
		frm.id_erro_upload.value = id;
	}	
	//alert(tipo_upload_erro_upload + ' ' + erro_interno_erro_upload + ' '+ album_id_cript_erro_upload + ' '+album_id_cript_erro_upload+' '+tp_entrada+ ' '+album_id_cript_erro_upload+ ' '+album_id_cript_erro_upload);
}
	
function enviarFormErro(frm){
	var tipo_conexao		= frm.tipo_conexao_erro_upload.value;
	var local_acesso		= frm.local_acesso_erro_upload.value;
	var cidade_acesso		= frm.cidade_acesso_erro_upload.value;
	var bairro_acesso		= frm.bairro_acesso_erro_upload.value;
	var tipo_problema_desc	= frm.tipo_problema_desc_erro_upload.value;
	var descricao			= frm.descricao_erro_upload.value;
	var provedor			= frm.tipo_provedor_erro_upload.value;	
	
	if (!validaCampo(local_acesso,"-99","Local de acesso","2")){ return; }  
	if (local_acesso != "Trabalho"){
		if (!validaCampo(provedor,"-99","Provedor","2")){ return; }        
		if (!validaCampo(tipo_conexao,"-99","Velocidade da conexão","2")){ return; }  	
	}	
	if (!validaCampo(cidade_acesso,"","Cidade de acesso","1")){ return; }        
	if (!validaCampo(bairro_acesso,"","Bairro de acesso","1")){ return; }        
	if (!validaCampo(tipo_problema_desc,"-99","Tipo problema","1")){ return; }        
	if (!validaCampo(descricao,"","Descricao do erro","1")){ return; }        
	
	frm.submit();
	//url = "?user_id="+user_id+"&remote_addr="+remote_addr+"&tipo_upload="+tipo_upload+"&ip_origem="+ip_origem+"&navegador="+navegador+"&so="+so+"&album_id="+album_id+"&tipo_conexao="+tipo_conexao+"&local_acesso="+local_acesso+"&cidade_acesso="+cidade_acesso+"&bairro_acesso="+bairro_acesso+"&tipo_problema_desc="+tipo_problema_desc+"&descricao="+descricao;
}

function validaCampo(valor,val2,nome_campo,msg){
	val = replaceAll(valor," ","");
	var b = false;
	
	if ((val != val2) && val != "" ){ b = true;	}			

	if (b){ 			
		return true; 
	}else{ 
		if (msg == "1"){
			alert("Favor preencher o campo: "+nome_campo); 				
		}else if (msg == "2"){
			alert("Favor selecionar o: "+nome_campo); 				
		}		
		return false; 
	}
}

function validaLocalAcesso(obj){	
	if (obj.value == "Trabalho"){
		$('tipo_provedor_erro_upload').disabled = 'disabled';
		$('tipo_conexao_erro_upload').disabled = 'disabled';
	}else{
		$('tipo_provedor_erro_upload').disabled = '';
		$('tipo_conexao_erro_upload').disabled = '';
	}
}

function exibePopErroUpload(erro){	
	_$('album_id_erro_erro_upload').value = $('album_id').value;
	_$('erro_interno_erro_upload').value = erro;
	_$('album_id_cript_erro_upload').value = "true";
	_$('msg_erro_upload').style.display = "block";	
	_$('clicou_no_link_erro_upload').value = '2';
	parent.viewFormErroUpload(false);
	parent.exibePopFormErroUpload(true);
}

function viewFormErroUpload(b){
	if (b==true){
		_$('erro_form_upload').style.display = 'block';
		_$('msg_erro_upload').style.display = 'none';
	}else{
		_$('erro_form_upload').style.display = 'none';
		_$('msg_erro_upload').style.display = 'block';
	}					
}
//fim pop-fade erro upload
