function get_flash(arquivo, largura, altura, bgcolor, id, qualidade, alinhamento,transparente,pgphp) {
	obj = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+largura+'" height="'+altura+'" id="'+id+'" align="'+alinhamento+'">';
	obj+= '<param name="allowScriptAccess" value="sameDomain" />';
	obj+= '<param name="movie" value="'+arquivo+'" />';
	obj+= '<param name="quality" value="'+qualidade+'" />';
	if(transparente == true) {
		obj+= '<param name="wmode" value="transparent" />';
	}
	obj+= '<param name="bgcolor" value="'+bgcolor+'" />';
	obj+= '<param name="FlashVars" value="pg='+pgphp+'" />';
	obj+= '<embed src="'+arquivo+'" '+((transparente==true)?'wmode="transparent"':'')+'" quality="'+qualidade+'" bgcolor="'+bgcolor+'" FlashVars="pg='+pgphp+'" width="'+largura+'" height="'+altura+'" name="'+id+'" align="'+alinhamento+'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	obj+= '</object>';
	document.write(obj);
}


var Forms = function(){
	this.msg = undefined;
	this.form = undefined;
	this.target = undefined;
};
Forms.prototype.email = function(mail){
	var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
	if(typeof(mail) == "string"){
		if(er.test(mail)){ return true; }
	}else if(typeof(mail) == "object"){
		if(er.test(mail.value)){
			return true;
		}
	}else{
		return false;
	}
};
/*Forms.prototype.cpf = function(cpf){
	var c = cpf;
	if((c = c.replace(/[^\d]/g,"").split("")).length != 11) return false;
	if(new RegExp("^" + c[0] + "{11}$").test(c.join(""))) return false;
	for(var s = 10, n = 0, i = 0; s >= 2; n += c[i++] * s--);
	if(c[9] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
	for(var s = 11, n = 0, i = 0; s >= 2; n += c[i++] * s--);
	if(c[10] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
	return true;
};*/
Forms.prototype.cnpj = function(cnpj){
	var b = [6,5,4,3,2,9,8,7,6,5,4,3,2], c = cnpj;
	if((c = c.replace(/[^\d]/g,"").split("")).length != 14) return false;
	for(var i = 0, n = 0; i < 12; n += c[i] * b[++i]);
	if(c[12] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
	for(var i = 0, n = 0; i <= 12; n += c[i] * b[i++]);
	if(c[13] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
	return true;
};
Forms.prototype.inputs = function(){
	var inputs = this.form.getElementsByTagName('input');
	var j = inputs.length;
	var i = 0;
	var erMail = new RegExp(/email+|e-mail+/);
	var erCnpj = new RegExp(/cnpj+|CNPJ+/);
	//var erCpf = new RegExp(/cpf+|CPF+/);
	for (i; i < j; i++) {
		if ((inputs[i].type == 'text')||(inputs[i].type == 'password')) {
			if(inputs[i].title != ''){
				if(inputs[i].value == ''){
					this.msg.push(inputs[i].title);
				}
				else{
					// verifica se é um campo email, para fazer a validação
					if (erMail.test(inputs[i].name)) {
						// email valido, title != null, value != null
						if (!this.email(inputs[i].value)) {
							this.msg.push(inputs[i].title);
						}
					}
					else{
						// Verifica se é um cnpj
						if (erCnpj.test(inputs[i].name)) {
							if (!this.cnpj(inputs[i].value)) {
								this.msg.push(inputs[i].title);
							}
						}
						else{
							/* Verifica se é um cpf
							if (erCpf.test(inputs[i].name)) {
								if (!this.cpf(inputs[i].value)) {
									this.msg.push(inputs[i].title);
								}
							}*/
						}
					}
				}
			}
			// Verifica se é pra fazer a comparação com outro elemento
			if($("[name='"+inputs[i].name+"2"+"']").size() > 0){
				// Compara os valores
				if(inputs[i].value != $("[name='"+inputs[i].name+"2"+"']").attr("value")){
					this.msg.push("Os elementos '"+inputs[i].title+"' não são iguais");
				}
			}
		}
	}
};
Forms.prototype.textareas = function(){
	var textareas = this.form.getElementsByTagName('textarea');
	var j = textareas.length;
	var i = 0;
	for(i; i < j; i++){
		if(textareas[i].title != '' && textareas[i].value == ''){
			this.msg.push(textareas[i].title);
		}
	}
};
Forms.prototype.selects = function(){
	var selects = this.form.getElementsByTagName('select');
	var j = selects.length;
	var i = 0;
	for(i; i < j; i++){
		if(selects[i].title != '' && selects[i].value == ''){
			this.msg.push(selects[i].title);
		}
	}
};
Forms.prototype.submit = function(form_name, response){
	this._form = document.getElementById(form_name);
	this._msg = new Array();
	this._response = document.getElementById(response);
	this.inputs(this._form);
	this.textareas(this._form);
	this.selects(this._form);
	if(this._msg.length == 0){
		this._msg = null;
		$("#"+form_name+" .submit").fadeOut(500);
		this._response.innerHTML = "Enviando...";
		$(this._response).fadeIn(500);
		var dados = $(this._form).serialize();
		var resposta = eval($.ajax({
			url:'?id=/forms.php',
			cache:false,
			async:false,
			data:dados
		}).responseText);
		if(resposta.retorno == true){
			$(this._response).animate({
				backgroundColor:"#DAFEDB"
			},500);
			this._response.innerHTML = resposta.msg.join("<br />");
		}else{
			$(this._response).animate({
				backgroundColor:"#FFD9D9"
			},500);
			this._response.innerHTML = resposta.msg.join("<br />");
		}
	}else{
		this._response.innerHTML = unescape(this._msg.join("<br />"));
		$(this._response).fadeIn(500);
		this._msg = null;
	}
};
Forms.prototype.compara = function(){
	if($("[name='ob_senha']").attr("value") != $("[name='ob_senha2']").attr("value")){
		this.msg.push("As senhas não são iguais");
	}
};
Forms.prototype.submitNormal = function(formId, target){
	this.form = document.getElementById(formId);
	this.target = document.getElementById(target);
	this.msg = new Array();
	this.inputs();
	this.textareas();
	this.selects();
	//this.compara();
	if(this.msg.length == 0){
		this.msg = null;
		this.form.submit();
	}else{
		this.target.innerHTML = unescape("<b>Os campos abaixo são obrigatórios e/ou inválidos:</b><br />"+this.msg.join("<br />"));
		$(this.target).fadeIn(1000);
		this.msg = null;
		return false;
	}
};
Forms.prototype.excluirCadastro = function(){
	return window.confirm("Deseja deletar seu cadastro?");
}
//Objeto forms
var objForms = new Forms;

// Inicia os elementos
$(document).ready(function(){
	// Fixa o PNG para o IE6
	$(document).pngFix();
	
	// Máscaras do formulário.
	$("[name='ob_cnpj']").mask("99.999.999/9999-99");
	$("[name='ob_cpf']").mask("999.999.999-99");
	$("[name='ob_data_nascimento']").mask("99/99/9999");
	$("[name='telefone']").mask("(99) 9999-9999");
	$("[name='ob_cep']").mask("99999-999");
	$("[name='entrega_cep']").mask("99999-999");
	
});

function buscarCepCorreios(cep, endereco, bairro, cidade, estado, id_resposta){

		if(cep.length == 9){
				
			$('#'+id_resposta).show();
			
			$.post('?go=includes/buscar_cep_correios.php', 
				{ cep : cep }, 
				function(resposta){
					
					<!-- Pegando o endereco -->
					$.post('?go=includes/buscar_cep_correios.php', { pegaEndereco : 'true' }, 
						   function(resposta){ 
								if(resposta == "")
									alert('CEP inexistente!');
								else
									window.document.getElementById(endereco).value = resposta; 
								
						   } 
					);
					<!-- Fim do endereco -->
					
					<!-- Pegando o bairro -->
					$.post('?go=includes/buscar_cep_correios.php', { pegaBairro : 'true' }, function(resposta){ window.document.getElementById(bairro).value = resposta; } );
					<!-- Fim do bairro -->
					
					<!-- Pegando a cidade -->
					$.post('?go=includes/buscar_cep_correios.php', { pegaCidade : 'true' }, function(resposta){ window.document.getElementById(cidade).value = resposta; } );
					<!-- Fim da cidade -->
					
					<!-- Pegando o estado -->
					$.post('?go=includes/buscar_cep_correios.php', { pegaUf : 'true' }, function(resposta){ window.document.getElementById(estado).value = resposta; } );
					<!-- Fim do estado -->
					
					$('#'+id_resposta).hide();
	
				}
			);
		}
}

function alertaListaDePresentes(cod){
	alert('Atenção! Para adicionar o produto a sua lista de presentes, você deverá fazer o login. Você será redirecionado!');
	window.document.location.href = '?go=listadepresentes/login.php&id_produto='+cod;
}