var AJAX_OBJ;

$(document).ready(function() {
	
    
    $('#dialog').jqm();
    $('#mapa').jqm();
    
    /*
    $("#linkMapa").click(function() {
        $('#mapa').jqmShow(); 
    }); 
	*/
	
	/** ************************************************************* */
	//Estilos/Links
	$(".linkDS").click(function() {
	    window.location = "desenvolvimento_de_software.asp";
	});
	
	$(".linkAP").click(function() {
	    window.location = "alocacao_profissional.asp";
	});
	
	$(".linkMI").click(function() {
	    window.location = "midia_impressa_e_digital.asp";
	});
	
	
	/** ************************************************************* */
	//Formulario de Contato
	$(".submit").click(function() {
	    var frm = $(".checkedFormItens");
	    var checkStatusForm = true;
	    $("#linkCloseSendMail").hide();
	    
	    $(".reqField").each(function() {
	        var field = jQuery.trim($(this).val());
	        var itemType = $(this).attr("itemType");
	        var itemNotify = $(this).attr("itemNotify");
	        
	        if (field.length == 0)
	        {
	            $("#" + itemNotify).removeClass("fGreen");
	            $("#" + itemNotify).addClass("fRed");
	            $("#" + itemNotify).html(" * Campo obrigatório");
	            checkStatusForm = false;
	            return;
	        }
	        else
	        {
	            $("#" + itemNotify).removeClass("fRed");
	            $("#" + itemNotify).addClass("fGreen");
	            $("#" + itemNotify).html(" *");
	        }
	        
	        if (itemType == "email")
	        {
	            if (field.indexOf("@") == -1 ||
	                field.indexOf(".") == -1)
	            {
	                $("#" + itemNotify).removeClass("fGreen");
	                $("#" + itemNotify).addClass("fRed");
	                $("#" + itemNotify).html(" * Campo com valor inválido");
	                checkStatusForm = false;
	                return;
	            }
	            else
	            {
	                $("#" + itemNotify).removeClass("fRed");
	                $("#" + itemNotify).addClass("fGreen");
	                $("#" + itemNotify).html(" *");
	            }
	        }
	    });
	    
	    if (checkStatusForm)
        {
            var txtNome = document.frmFormMail.txtNome.value;
            var txtEmail = document.frmFormMail.txtEmail.value;
            var txtEmpresa = document.frmFormMail.txtEmpresa.value;
            var txtDDD = document.frmFormMail.txtDDD.value;
            var txtTelefone = document.frmFormMail.txtTelefone.value;
            var tipoConhec = "";
            var txtMensagem = document.frmFormMail.txtMensagem.value;
        
            for (i = 0; i < document.frmFormMail.tipoConhec.length; i++) {
	            if (document.frmFormMail.tipoConhec[i].checked) {
		            tipoConhec += document.frmFormMail.tipoConhec[i].value;
	            }
            }
        
            var sendDataForm = "txtNome=" + txtNome;
                sendDataForm += "&txtEmail=" + txtEmail;
                sendDataForm += "&txtEmpresa=" + txtEmpresa;
                sendDataForm += "&txtDDD=" + txtDDD;
                sendDataForm += "&txtTelefone=" + txtTelefone;
                sendDataForm += "&tipoConhec=" + tipoConhec;
                sendDataForm += "&txtMensagem=" + txtMensagem;
            
            AJAX_OBJ = $.ajax({ type        : "POST"
                                , url       : "sendMailHandler.asp"
                                , data      : sendDataForm
                                , success   : function(msg){
                                
                                                $("#imgLoad").hide();
                                                $("#linkCloseSendMail").show();
                                                
                                                $("#labelNome").removeClass("fRed");
	                                            $("#labelNome").addClass("fGreen");
	                                            $("#labelNome").html(" *");
	                                            
	                                            $("#labelEmail").removeClass("fRed");
	                                            $("#labelEmail").addClass("fGreen");
	                                            $("#labelEmail").html(" *");
	                                            
	                                            $("#labelMensagem").removeClass("fRed");
	                                            $("#labelMensagem").addClass("fGreen");
	                                            $("#labelMensagem").html(" *");
                                                
                                                if (msg == "00")
                                                {
                                                    $("#h1MsgMail").html("E-mail enviado com sucesso");
                                                    $("#h2MsgMail").html("Obrigado por sua mensagem. Em breve entraremos em contato");
                                                    
                                                    document.frmFormMail.txtNome.value = "";
                                                    document.frmFormMail.txtEmail.value = "";
                                                    document.frmFormMail.txtEmpresa.value = "";
                                                    document.frmFormMail.txtDDD.value = "";
                                                    document.frmFormMail.txtTelefone.value = "";
                                                    document.frmFormMail.txtMensagem.value = "";
                                                }
                                                
                                                if (msg == "01")
                                                {
                                                    $("#h1MsgMail").html("Ocorreu um erro no processo de envio");
                                                    $("#h2MsgMail").html("Por favor, entre em contato através do canal de atendimento Setia");
                                                }
                                                
                                                if (msg == "02")
                                                {
                                                    $("#h1MsgMail").html("Existem informações com valor incorreto");
                                                    $("#h2MsgMail").html("Por favor, verifique os dados do formulário e envie novamente");
                                                }
                                            }
                              });
            
            $('#dialog').jqmShow();
        }
         
	});
	/** ************************************************************* */
	
	
	
	
});




function addFav(){
    var url = "http://www.setia.com.br";
    var title = "Setia Tecnologia - 10 Anos de História, Produzindo Valores, Gerando Satisfação";
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(url, title);}
}

function callFlashMain() {
	AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',
			'width', '933',
			'height', '293',
			'src', 'flash/banner',
			'quality', 'high',
			'pluginspage', 'http://www.adobe.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', 'banner',
			'bgcolor', '#ffffff',
			'name', 'banner',
			'menu', 'true',
			'allowFullScreen', 'false',
			'allowScriptAccess','sameDomain',
			'movie', 'flash/banner',
			'salign', ''
			); 
}

function callFlashMenu() {
	AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',
			'width', '306',
			'height', '295',
			'src', 'flash/menu',
			'quality', 'high',
			'pluginspage', 'http://www.adobe.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', 'menu',
			'bgcolor', '#ffffff',
			'name', 'banner',
			'menu', 'true',
			'allowFullScreen', 'false',
			'allowScriptAccess','sameDomain',
			'movie', 'flash/menu',
			'salign', ''
			); 
}

