
function popCartao() {
	window.open('cartao.php','cartao','width=350, height=580,scrollbars=no,status=no');

}
// ------------------------------------------------
function limpaCampos(campo,padrao){

	var obj = document.getElementById(campo);
	obj.select();
	if (obj.value == padrao)
	obj.value = '';

}

// ------------------------------------------------
function restauraCampos(campo,padrao){

	var obj = document.getElementById(campo);
	if (obj.value == '')
	obj.value = padrao;

}

// ------------------------------------------------
function toggleDiv( element ) {
	var e = document.getElementById(element);

	if (e) {
		e.style.display = ((e.style.display != 'none') ? 'none' : 'block');
	}
}

function infoDialog() {
	Dialog.info("<h1>text</h1><a href='#' onclick='Dialog.cancelCallback();'>teste</a>", {width: 170, height: 50});
}

function enviaFoto(file) {
	Dialog.info(
	{ url: file, options: {method: 'post'} },
	{ className: "dialog",
	width: 380,
	height: 270
	}
	);
}


function infoDialog() {
	Dialog.info("<h1>text</h1><a href='#' onclick='Dialog.cancelCallback();'>teste</a>", {width: 170, height: 50});
}

function pegavalores(valor){
	/*	switch (document.getElementById("assunto").options[document.getElementById("assunto").selectedIndex].value){
	case "5" :window.location="http://www.agafarma.com.br/?on=fornecedor";
	break
	default:
	break
	}
	*/
	var php = "ajax/procuraMsgEmailLink.php";
	var parametros = 'assunto_id='+valor;
	var ajaxNews = new Ajax.Request(php,
	{
		method: 'post',
		parameters: parametros,
		onComplete:  function retornoValores(retorno) {
			resposta = retorno.responseText;

			if (resposta.substr( 0,1 ) == 'L') {//L - Link
				resposta = resposta.substr( 1,resposta.length );
				window.location= resposta;
			}//fim if L
			else if (resposta.substr( 0,1 )=='M'){//M - Mensagem
				if (strrpos(resposta,'*')){
					resposta1 = resposta.substr( 1,strrpos(resposta,'*')-1 );
					resposta2 = resposta.substr( strrpos(resposta,'*')+1,resposta.length );
					resposta = resposta1;
					if (confirm(unescape(resposta))) window.location = resposta2;
					else window.location = 'http://www.agafarma.com.br/?on=contato';
				}else{
					resposta = resposta.substr( 1,resposta.length );
					alert(unescape(resposta));
					window.location= 'http://www.agafarma.com.br/?on=contato';
				}
			}//fim if L
			else if (resposta.substr( 0,1 )=='E'){//E - Email
				//resposta = resposta
				resposta = resposta.substr( 1,resposta.length );
			}//fim if L


		}//fim retornoValores

	})/*fim Request*/;

}//fim pegavalores

function strrpos( haystack, needle, offset){
	// http://kevin.vanzonneveld.net
	// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   bugfixed by: Onno Marsman
	// *     example 1: strrpos('Kevin van Zonneveld', 'e');
	// *     returns 1: 16

	var i = (haystack+'').lastIndexOf( needle, offset ); // returns -1
	return i >= 0 ? i : false;
}


function Mascara(o,f){
	v_obj=o
	v_fun=f
	setTimeout("execmascara()",1)
}

/*Função que Executa os objetos*/
function execmascara(){
	v_obj.value=v_fun(v_obj.value)
}
/*Função que permite apenas numeros*/
function Integer(v){
	return v.replace(/\D/g,"")
}


function showFormConsulta(){
	document.getElementById("segunda_via").style.display = 'block';
		//$(id).setStyle({'display':'block'});
}
