/* **************************************************************
	ONLOAD
- Seta thisPage com propriedades da Pagina atual
- Adiciona Links Externos
- Adiciona Evento Link Hover
- Se browser for IE Anexa Javascripts Auxiliares
************************************************************** */
function executeOnLoad(){
	xjsBool_DOMisLoad = true;
    xjs_thisPage = new objPageInfo(xjsStr_Location);
	setTargetBlank(xjs_thisPage.siteName);
	setLinkHover();

	if(xjs_browser.type == 'IE'&& xjs_browser.version == '6') {
		searchAndInsertIframe('div', 'iFrame'); 
		autoResizeIframes();
	}
	//initiDHTMLSelects(); // <- Para Selects DHTML
	adjustCorpo();
	
	if(onLoadExecuteThis != '') { eval(onLoadExecuteThis); }
}
onload = executeOnLoad;
onLoadExecuteThis = '';




/* **************************************************************
	ONRESIZE
- Atualiza propriedades da Pagina atual
- Se modal estiver aberto, redimensiona a 'sombra' e respectivo
	iframe(IE6)
************************************************************** */
var isResize = null;
var time = null;
var cResize = 0;
function executeOnResize(){ 
	xjs_thisPage = new objPageInfo(xjsStr_Location);
	if(xjsBool_ModalIsOpen == true) { 
		extendToNode('divShadow', 'Screen', 'yes', 'yes'); 
		if(xjs_browser.type == 'IE' && xjs_browser.version == '6') { autoResizeIframes(); }
	}

	if(isResize ==  null) { 
		cResize++;
		time = setTimeout('adjustCorpo();', 250); 
	}
}
onresize = executeOnResize;





/* **************************************************************
	ONKEYDOWN
- Atualiza 'xjsLastKeyDown' ao apertar alguma tecla
- Há uma lista de testes com endereços de telas onde, se a tecla
	pressionada for 'enter', irá disparar a função activeOnEnter()
************************************************************** */
function executeOnKeyDown(e) { 
    xjsInt_LastKeyDown = checkKeycode(e);
  /*  if(xjsLocation.indexOf('exemplos/ModeloContato.htm') != -1){ if(xjsLastKeyDown == 13) { activeOnEnter(); } }*/
}
document.onkeydown = executeOnKeyDown;





/* **************************************************************
	ONKEYPRESS
- Inibe o Som Produzido pelo IE ao Pressionar Enter
************************************************************** */
function executeOnKeyPress() {
	/*if(MonitoreEnter == true){
	    if(browser.type == 'IE' && xjsLastKeyDown == 13) { return false; }
}*/ }
document.onkeypress = executeOnKeyPress;





/* **************************************************************
	ONMOUSEDOWN
- Percebe quando o Mouse for Clicado
************************************************************** */
function executeOnMouseDown() {
	//setTimeout("closeDHTMLSelect()", 100); // <- Para Selects DHTML
}
document.onmousedown = executeOnMouseDown;





/* **************************************************************
	ONMOUSEUP
- Percebe quando o Mouse for Clicado
************************************************************** */
function executeOnMouseUp() {
}
//document.onmouseup = executeOnMouseUp;








/* **************************************************************
Declaração de javascripts especifícos
************************************************************** */
function adjustCorpo() {
	var isHome = false;
	if(xjsStr_Location.indexOf('/content/home/Default.aspx') != -1) { isHome = true; }
	
	if(xjs_browser.type == 'IE') { 
		if(isHome == true && cResize < 3) { extendToNode('boxPrincipal', 'Screen', 'no', 'yes', 'areaConceitual', 'boxRodape'); }
		else if (isHome == true && cResize < 1) { extendToNode('boxPrincipal', 'Screen', 'no', 'yes', 'areaConceitual', 'boxRodape'); }
	}
	else { extendToNode('boxPrincipal', 'Screen', 'no', 'yes', 'areaConceitual', 'menuPrincipal', 'boxRodape', 'boxPath'); }
}



function changeMap(idMap, nSuf)
{
	var oldSrc = id(idMap).src;
	var iniIndex = oldSrc.length - 6;
	var oldSuf = oldSrc.substring(iniIndex, oldSrc.length);
	var newSuf = nSuf + '.gif';
	var newSrc = oldSrc.replace(oldSuf, newSuf);
	id(idMap).src = newSrc;	
}




function SendNewsData(idNome, idMail, idFone, idPais, idUF, nameRadio, idCidade) {
    var formContato = new objFormValidation();
    formContato.setOutPut('alert', '');

    var isSend = 0;
    
    formContato.addField(idNome, 'isEmpty', 'Nome');
    formContato.addField(idMail, 'isEmail', 'Email');

    formContato.addField(idFone, 'isEmpty', 'Fone');
    formContato.addField(idPais, 'isSelected', 'Pais');
    
    if(id(idPais).value == 'Brasil' || id(idPais).value == 'brasil') {
        formContato.addField(idUF, 'isSelected', 'Estado');
    }
    formContato.addField(nameRadio, 'isRadioSelect', 'Gênero');
    formContato.addField(idCidade, 'isEmpty', 'Cidade');
    
    // Estando Tuo OK, envia dados para a própria página que fará o registro
    if(formContato.checkForm()) {
        var param = 'isMPB=true';
        param += '&nome=' + id(idNome).value;
        param += '&email=' + id(idMail).value;
        param += '&fone=' + id(idFone).value;
        param += '&pais=' + id(idPais).value;
        if(id(idPais).value == 'Brasil') { param += '&estado=' + id(idUF).value; }
        else { param += '&estado=none'; }
        
        var getRadio = getTagsChildOfID('divModalGender', 'input');
        var gender = '';
        for(i=0;i<getRadio.length; i++){
            if(getRadio[i].checked == true) { gender = getRadio[i].value; break;}
        }
        param += '&genero=' + gender;
        param += '&cidade=' + id(idCidade).value;
        
        showHideModal('show', 'Newsletter', param);
    }
}