﻿// JScript File
/*----------------------------------------------+
| Projeto:   SiteBasico (Beez)                  |
| Autor:     Edvin Markstein Zimmermann         |
| Criado em: Junho/2009                         |
| Versao:    1.20090629                         |
| Descricao: Funcoes projeto SiteBasico         |
| Linguagem: JavaScript                         |
+-----------------------------------------------+
+---------------------------------------------------------------------------------------------------------------+
+---------------------------------------------------------------------------------------------------------------+
|          I N D I C E      D E      F U N C O E S      -     O R D E M       A L F A B E T  I C A              |
+---------------------------------------------------------------------------------------------------------------+
+---------------------------------------------------------------------------------------------------------------+
|	jAlbum( sImg )
|		- abre layer e mostra imagem (grande)
+---------------------------------------------------------------------------------------------------------------+
|	jBusca( oTxt, sFrm )
|		- efetua busca de uma notícia
+---------------------------------------------------------------------------------------------------------------+
|	jCadastreSe()
|		- cadastra uma pessoa na base
+---------------------------------------------------------------------------------------------------------------+
|	jContatoEnviar()
|		- envia o formulário de contato
+---------------------------------------------------------------------------------------------------------------+
*/
function jAlbum( sImg ){
    var sLayer = "layerAlbum";
    if(document.getElementById(sLayer) == null)
    {
        oDiv = document.createElement("DIV");
        oDiv.id = sLayer;
        oDiv.style.position = "absolute";
        oDiv.style.left = "0px";
        oDiv.style.top = "0px";
        oDiv.style.width = "100%";
        oDiv.style.height = "100%";
        oDiv.style.zIndex = 1;
        oDiv.style.visibility = "hidden";
        document.body.appendChild(oDiv);
    }
    sHtml = '<table class="transparente" width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">';
    sHtml += '<tr>';
    sHtml += '<td align="center" valign="middle">';
    sHtml += '<table width="100" height="100" class="EMZAguarde" style="border: 1px solid #000000;">';
    sHtml += '<tr>';
    sHtml += '<td>';
    sHtml += '<a href="#" onclick="jHiddenLayer(\'' + sLayer + '\')">';
    sHtml += '<img class="EMZImgAlbum" src="img/album/' + sImg + '">';
    sHtml += '</a></td>';
    sHtml += '</tr>';
    sHtml += '<tr>';
    sHtml += '<td>';
    sHtml += '<div align="center">';
    sHtml += '<input type="button" value="fechar"';
    sHtml += ' onclick="jHiddenLayer(\'' + sLayer + '\')"';
    sHtml += ' style="';
    sHtml += 'border-width: 1px;';
    sHtml += 'border-style: solid;';
    sHtml += 'border-color: #999999;';
    sHtml += 'color: #576C73;';
    sHtml += 'display: inline;';
    sHtml += 'float: none;';
    sHtml += 'font-size: 12px;';
    sHtml += 'height: 20px;';
    sHtml += 'padding-right: 1px;';
    sHtml += '">';
    sHtml += '</div>';
    sHtml += '</td>';
    sHtml += '</tr>';
    sHtml += '</table>';
    sHtml += '</td>';
    sHtml += '</tr>';
    sHtml += '</table>';
    oDiv.innerHTML = sHtml;

    oLayer = document.getElementById(sLayer);	
    oLayer.style.visibility = "visible";
    return;

}

function jImagem( sImg ){
    var sLayer = "layerAlbum";
    sHtml = "";
    if(document.getElementById(sLayer) == null)
    {
        oDiv = document.createElement("DIV");
        oDiv.id = sLayer;
        oDiv.style.position = "absolute";
        oDiv.style.left = "0px";
        oDiv.style.top = "0px";
        oDiv.style.width = "100%";
        oDiv.style.height = "100%";
        oDiv.style.zIndex = 1;
        oDiv.style.visibility = "hidden";
        document.body.appendChild(oDiv);
    }
    sHtml += '<table class="transparente" width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">';
    sHtml += '<tr>';
    sHtml += '<td align="center" valign="middle">';
    sHtml += '<table width="100" height="100" class="EMZAguarde" style="border: 1px solid #000000;">';
    sHtml += '<tr>';
    sHtml += '<td>';
    sHtml += '<a href="#" onclick="jHiddenLayer(\'' + sLayer + '\')">';
    sHtml += '<img class="EMZImgAlbum" src="' + sImg + '">';
    sHtml += '</a></td>';
    sHtml += '</tr>';
    sHtml += '<tr>';
    sHtml += '<td>';
    sHtml += '<div align="center">';
    sHtml += '<input type="button" class="botaoFechar" value="fechar"';
    sHtml += ' onclick="jHiddenLayer(\'' + sLayer + '\')"';
    sHtml += ' style="';
    sHtml += 'border-width: 1px;';
    sHtml += 'border-style: solid;';
    sHtml += 'border-color: #999999;';
    sHtml += 'color: #576C73;';
    sHtml += 'display: inline;';
    sHtml += 'float: none;';
    sHtml += 'font-size: 12px;';
    sHtml += 'height: 20px;';
    sHtml += 'padding-right: 1px;';
    sHtml += '">';
    sHtml += '</div>';
    sHtml += '</td>';
    sHtml += '</tr>';
    sHtml += '</table>';
    sHtml += '</td>';
    sHtml += '</tr>';
    sHtml += '</table>';
    oDiv.innerHTML = sHtml;
    oLayer = document.getElementById(sLayer);	
    oLayer.style.visibility = "visible";
    return;

}

function jBusca( sTxt , sFrm ){
    oTxt = jGebi(sTxt);
    if(oTxt.value == ""){
        alert("Preencha o campo Busca para efetuar uma pesquisa.");
        oTxt.focus();
        return false;
    }
    jAguarde( false, "Buscando..." );
    oFrm = jGebi(sFrm);
    oFrm.method = "post";
    oFrm.action = "Busca.aspx";
    oFrm.submit();
    return true;
}

function jCadastreSe(){
    oNome = jGebi("txtCadastroNome");
    oEmail = jGebi("txtCadastroEmail");
    if(oNome.value == ""){
        alert("Preencha o campo nome.");
        oNome.focus();
        return false;
    }
    if(oEmail.value == ""){
        alert("Preencha o campo email.");
        oEmail.focus();
        return false;
    }
    if(!jIsEmail(oEmail)){
        return false;
    }
    oFrm = jGebi("frmCadastro");
    oFrm.method = "post";
    oFrm.action = "Cadastrese.aspx";
    jAguarde( false, "Cadastrando..." );
    oFrm.submit();
    return true;
}

function jHiddenLayer( sLayer ){
    oLayer = jGebi( sLayer );
    oLayer.style.visibility = "hidden";
    return;
}

function jContatoEnviar(){
    var aField = "Nome,Telefone,Assunto".split(",");
    var oMail = jGebi("txtContatoEmail");
    if(jGebi("txtContatoNome").value == ""){
            alert("Preencha o campo Nome.");
            jGebi("txtContatoNome").focus();
            return;
    }
    if(jGebi("txtContatoTelefone").value == "" && oMail.value == ""){
            alert("Preencha o campo Telefone ou o campo Email.");
            jGebi("txtContatoTelefone").focus();
            return;
    }
    if(oMail.value != ""){
        if(!jIsEmail(oMail)){
            return;
        }
    }
    if(jGebi("txtContatoAssunto").value == ""){
            alert("Preencha o campo Assunto.");
            jGebi("txtContatoAssunto").focus();
            return;
    }
    oFrm = jGebi("frmContato");
    oFrm.method = "post";
    jAguarde( false, "Enviando" );
    oFrm.submit();
    return;    
}

function jIndique(){
	jGebi("divEnvie").style.visibility = "visible";
	window.scrollTo(0,0);
	return;
}

function jIndiqueEnvie(){
	var oFrm = jGebi("frmIndique");
	var oSeuNome = jGebi("txtSeuNome");
	var oSeuEmail = jGebi("txtSeuEmail");
	var oEmailAmigo = jGebi("txtEmailAmigo");
	if( oSeuNome.value == "" && oSeuEmail.value == ""){
		alert('Preencha o campo "Seu nome" ou "Seu Email".');
		oSeuNome.focus();
		return;
	}else{
		if( oSeuEmail.value != "" && !jIsEmail(oSeuEmail)){
			oSeuEmail.focus();
			return;
		}
	}
	if(oEmailAmigo.value == ""){
		alert('Preencha o campo "Email do amigo".');
		oEmailAmigo.focus();
		return;
	}
	if( !jIsEmail(oEmailAmigo)){
		oEmailAmigo.focus();
		return;
	}
	jAguarde( false, "Enviando" );
	oFrm.submit();	
	return;
}
