function msn(id){
	width = 410;
	height = 350;
	var left = ((screen.width/2) - width/2);
	var top  = ((screen.height/2) - height/2);
	janela=window.open('http://settings.messenger.live.com/Conversation/IMMe.aspx?invitee='+id+'@apps.messenger.live.com&mkt=pt-br','Msn_'+id, 'top='+top+',left='+left+',width='+width+',height='+height+',toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=no');
}

function desabilitar(){ 
    return false;
} 
document.oncontextmenu=desabilitar;

function catalogo(id, foto, ref, valor, idioma){
	var b = document.getElementById('fundo2').style.display;
	var linhas = document.getElementById('table').rows;   
    var i = 0;   
    for (i= linhas.length-1; i>=0; i--){
		document.getElementById('table').deleteRow(i);   
	}
	if(idioma==1){
		Referencia.innerHTML = "Referência";
		cor_da_pedra.innerHTML = "Pedra Natural";
		cor_zirconia.innerHTML = "Zirc&ocirc;nia";
		quantidade.innerHTML = "Quantidade";
		t_valor.innerHTML = "Valor";
		observacao.innerHTML = "Observação";
		adicionar.innerHTML = "Adicionar";
		fechar.innerHTML = "Fechar";
		tamanho.innerHTML = "Tamanho";
		perola.innerHTML = "Pérola";
		aproveite = "Aproveite!!";
		ver = "Ver";
		document.form.compra_ok.value = "Produto Incluso com Sucesso!";
	}else if(idioma==2){
		Referencia.innerHTML = "Reference";
		cor_da_pedra.innerHTML = "Natural Stone";
		cor_zirconia.innerHTML = "Zirconia";
		quantidade.innerHTML = "Qty";
		t_valor.innerHTML = "Amount";
		observacao.innerHTML = "Observations";
		adicionar.innerHTML = "Add";
		fechar.innerHTML = "Close";
		tamanho.innerHTML = "Size";
		perola.innerHTML = "Pearl";
		aproveite = "Enjoy!!";
		ver = "See";
		document.form.compra_ok.value = "Product Added Successfully!";
	}else if(idioma==3){
		Referencia.innerHTML = "Referencia";
		cor_da_pedra.innerHTML = "Piedra Natural";
		cor_zirconia.innerHTML = "Zirconia";
		quantidade.innerHTML = "Cantidad";
		t_valor.innerHTML = "Valor";
		observacao.innerHTML = "Observaciones";
		adicionar.innerHTML = "Agregar";
		fechar.innerHTML = "Fechar";
		tamanho.innerHTML = "Tamaño";
		perola.innerHTML = "Pearl";
		aproveite = "Disfrute!!";
		ver = "Ver";
		document.form.compra_ok.value = "Producto Incluido con éxito!";
	}
	
	
	if(id!=undefined){
		document.getElementById('catalogo').style.display='block';	
		document.getElementById('fundo2').style.display='block';	
		document.foto_catalogo.src = "imagens/catalogo/"+foto+".jpg";
		document.form.id.value = id;
		document.form.obs.value = "";
		reff.innerHTML = ref;
		valorr.innerHTML = "R$ "+valor;
		$.ajax({
		   type: "POST",
		   url: "response.php?acao=detalhes&id="+id+"&idioma="+idioma,
		   data: "",
		   success: function(msg){
				a = msg.split("&");
				id_cor = a[1].split(",");
				nome_cor = a[2].split(",");
				id_tamanho = a[3].split(",");
				nome_tamanho = a[4].split(",");	
				id_perola = a[9].split(",");
				nome_perola = a[10].split(",");
				id_zirconia = a[11].split(",");
				nome_zirconia = a[12].split(",");
				
				id_ass = a[5].split("@");
				referencia = a[6].split("@");
				foto_ass = a[7].split("@");
				valor_ass = a[8].split("@");
				
				document.form.qtd.value = 1;
				document.form.tamanh.options.length = 0;
				for(i=1;i<id_tamanho.length;i++){
					var novo = document.createElement("option");
					novo.setAttribute("id", "opcoes");
					novo.value = id_tamanho[i];
					novo.text  = nome_tamanho[i];
					document.form.tamanh.options.add(novo);
				}
				
				document.form.cor.options.length = 0;				
				for(i=1;i<id_cor.length;i++){
					var novo = document.createElement("option");
					novo.setAttribute("id", "opcoes");
					novo.value = id_cor[i];
					novo.text  = nome_cor[i];
					document.form.cor.options.add(novo);
				}
				
				document.form.zirconia.options.length = 0;				
				for(i=1;i<id_zirconia.length;i++){
					var novo = document.createElement("option");
					novo.setAttribute("id", "opcoes");
					novo.value = id_zirconia[i];
					novo.text  = nome_zirconia[i];
					document.form.zirconia.options.add(novo);
				}
				
				document.form.perol.options.length = 0;				
				for(i=1;i<id_perola.length;i++){
					var novo = document.createElement("option");
					novo.setAttribute("id", "opcoes");
					novo.value = id_perola[i];
					novo.text  = nome_perola[i];
					document.form.perol.options.add(novo);
				}
				
				if(id_ass.length>1){
					var row = table.insertRow(0);
					var c1 = row.insertCell(0);	
					c1.colSpan = "3";
					c1.setAttribute('height', '10');
					c1.setAttribute('align', 'center');
					var hr = document.createElement("hr"); 
					hr.setAttribute('width', '285');
					hr.setAttribute('size', '2');
					hr.setAttribute('color', '#FFFFFF');
					c1.setAttribute('align', 'left');
					c1.appendChild(hr);
					
					var row = table.insertRow(1);
					var c1 = row.insertCell(0);	
					c1.setAttribute('height', '20');
					c1.setAttribute('className', 'texto_destaque_g');
					c1.setAttribute('vAlign', 'top');
					var texto1 = document.createTextNode(aproveite);
					c1.colSpan = "3";
					c1.appendChild(texto1);
				}
								u = 2;
				for(i=1;i<id_ass.length;i++){
					
					var row = table.insertRow(u);
					u++;
					
					///////////////
					var c1 = row.insertCell(0);					
					c1.setAttribute('width', '42');
					c1.setAttribute('height', '47');
					var link1 = document.createElement("a");
					var img = document.createElement("img"); 
					img.setAttribute("src","thumb.php?foto="+foto_ass[i]);
					img.setAttribute("border",0);
					link1.setAttribute("href","javascript:catalogo('"+id_ass[i]+"','"+foto_ass[i]+"','"+referencia[i]+"','"+valor_ass[i]+"','"+idioma+"')");
					link1.appendChild(img); 					
					c1.appendChild(link1);
					
					//				
					var c2 = row.insertCell(1);
					c2.setAttribute('width', '165');
					c2.setAttribute('height', '10');
					c2.setAttribute('align', 'left');
					c2.setAttribute('vAlign', 'top');
					
					refer = referencia[i];
					valor = "R$ "+valor_ass[i];
					
					var texto2 = document.createTextNode(refer);
					c2.appendChild(texto2);	
					
					
					var c3 = row.insertCell(2);					
					c3.setAttribute('width', '70');	
					c3.setAttribute('align', 'center');	
					var link1 = document.createElement("a");					
					var texto1 = document.createTextNode(ver);					
					link1.setAttribute("href","javascript:catalogo('"+id_ass[i]+"','"+foto_ass[i]+"','"+referencia[i]+"','"+valor_ass[i]+"','"+idioma+"')");
					link1.appendChild(texto1); 	
					link1.setAttribute('className', 'botao_ver');
					c3.appendChild(link1);
					
					
					var row = table.insertRow(u);
					u++;				
					var c22 = row.insertCell(0);		
					c22.setAttribute('height', '31');
					c22.setAttribute('vAlign', 'top');
					c22.setAttribute('className', 'apartir_de');
					var texto3 = document.createTextNode(valor);					
					c22.appendChild(texto3);

					
					c1.rowSpan = "2";
					c3.rowSpan = "2";
					//	
				}

		   }
		 });
		
	}else{
		document.getElementById('catalogo').style.display='none';
		document.getElementById('fundo2').style.display='none';
	}	
}
function comprar(){
		if(document.form.situacao.value == 0){
			document.form.situacao.value = 1;
			id = document.form.id.value;
			cor = document.form.cor.value;
			tamanh = document.form.tamanh.value;
			perol = document.form.perol.value;
			qtd = document.form.qtd.value;
			obs = document.form.obs.value;
			zirc = document.form.zirconia.value;
			
			if(qtd==0){
				qtd = 1;
			}else if(qtd==""){
				qtd = 1;
			}
			
			$.ajax({
			   type: "POST",
			   url: "incluir.php",
			   data: "id="+id+"&cor="+cor+"&tamanho="+tamanh+"&qtd="+qtd+"&obs="+obs+"&perola="+perol+"&zirc="+zirc,
			   success: function(msg){
				   certo(document.form.compra_ok.value);
				   catalogo();
				   document.form.situacao.value = 0;
			   }
			 });
		
		}
}

function somente_numero(campo){   
	var digits="0123456789"; 
	var campo_temp;
    for (var i=0;i<campo.value.length;i++){   
        campo_temp=campo.value.substring(i,i+1)   
        if (digits.indexOf(campo_temp)==-1){   
            campo.value = campo.value.substring(0,i);   
        }   
    }   
}  
