﻿
$(document).ready(function() {
	//INICIO
	switch(pagina){
		case "home":
			
		break
	}
	
	//ATUALIZA CURSO ANTERIOR
	$("select[name=curso_id]").change(function(){
		window.location.href = $(this).find("option:selected").val();
	});			
	
	///IDIOMAS BANDEIRAS
	$("ul.bandeiras li").mouseenter(function(){
		var image = path+"img/"+$(this).find("a").attr("rel")+"_over.png";
		$(this).find("a img").attr("src",image);
	}).mouseleave(function(){
		var image = path+"img/"+$(this).find("a").attr("rel")+".png"; 
		$(this).find("a img").attr("src",image);
	});
	
	
	///SUBMENU
	$("ul.menu li a.curso").parents("li").mouseenter(function(){						
		$(this).find("ul").stop(true,true);
		$(this).find("ul").slideDown();
	}).mouseleave(function(){
		$(this).find("ul").stop(true,false);
		$(this).find("ul").slideUp(function(){$(this).height("auto").css("padding","10px 18px");});
	});
	
	init_imgToBackground(".apoio .foto");
	init_imgToBackground(".parceiros .foto");
	
	
	//VERIFICA QUAL PÁGINA E O QUE DEVE EXECUTAR		
	switch(pagina){
		case "infraestrutura":
			$("a.expand_button").live("click",expandImoveis);
			
			
			$("a.grouped_elements").fancybox({
				'overlayShow'		: true,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Imagem ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
			
			
			//$("a.grouped_elements").fancybox();
			
			
			
		break
		case "professores":
			$("a.expand_button").live("click",expandImoveis);
		break
		case "perfil":
			$(".perfil_cont").jScrollPane({wheelSpeed:40, scrollbarWidth:17, showArrows:true, dragMaxHeight:70});
		break
	}
	
	if($(".banners").length > 0){
		init_banners();
	}
	
		
	
	// BANNER PUBLICIDADE //
	if(pagina == "home"){
		init_publicidade(path+"publicidade.php", "ul.banner_publicidade");
	}else{
		init_publicidade(path+"publicidade.php", "ul.banner_publicidade");
	}
});



// CONTROLE DO BANNER PUBLICIDADE ---------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------

function init_publicidade(URL,elemento){
	$.getJSON(URL, function(data) {
		if(data.banners.length>0){
			for(i=0;i<data.banners.length;i++){
				$("<li></li>").appendTo(elemento);
				data.banners[i].loaded = false;
			}
			
			var objImage = new Image();
			objImage.src = data.banners[0].img;
			
			var objPublicidade = new Object();
			
			objPublicidade.index = 0;
			objPublicidade.img = objImage;
			objPublicidade.arrBanners = data.banners;
			objPublicidade.elemento = elemento;
			
			load_publicidade(objPublicidade);
		}
	});
}


function load_publicidade(objPublicidade){
	if(objPublicidade.img.complete){
		$(objPublicidade.elemento).find("li:eq("+objPublicidade.index+")").css("background","url("+objPublicidade.img.src+") no-repeat left top");
		$(objPublicidade.elemento).find("li:eq("+objPublicidade.index+")").fadeIn(500);
		objPublicidade.arrBanners[objPublicidade.index].loaded = true;
		control_publicidade(objPublicidade);
	}else{
		setTimeout(function(){load_publicidade(objPublicidade);},500);
	}
}


function control_publicidade(objPublicidade){
	if(objPublicidade.arrBanners.length>1){
		objPublicidade.interval = setInterval(function(){change_publicidade(objPublicidade)}, 10000);
		$(objPublicidade.elemento).click(function(){
			window.open(objPublicidade.arrBanners[objPublicidade.index].url);
			//window.location.href = objPublicidade.arrBanners[objPublicidade.index].url;
		}).css("cursor","pointer");
	}
}


function change_publicidade(objPublicidade){
	clearInterval(objPublicidade.interval);
	$(objPublicidade.elemento).unbind("click").css("cursor","default");
	
	$(objPublicidade.elemento).find("li:eq("+objPublicidade.index+")").fadeOut(500);

	objPublicidade.index = objPublicidade.index+1;
	if(objPublicidade.index>=objPublicidade.arrBanners.length) objPublicidade.index = 0;
	
	if(objPublicidade.arrBanners[objPublicidade.index].loaded){
		$(objPublicidade.elemento).find("li:eq("+objPublicidade.index+")").fadeIn(500);
		control_publicidade(objPublicidade);
	}else{
		objPublicidade.img.src = objPublicidade.arrBanners[objPublicidade.index].img;
		load_publicidade(objPublicidade);
	}
}



// TROCA IMAGENS NO HTML E ACIONA NO BACKGROUND

function init_imgToBackground(element){
	$(element+" img").each(function(i){
		$(this).parent().css("background","url("+$(this).attr("src")+") no-repeat center center");
		$(this).hide();
	})
}

$.easing.easeInOutCubic = function (x, t, b, c, d) {
	if ((t/=d/2) < 1) return c/2*t*t*t + b;
	return c/2*((t-=2)*t*t + 2) + b;
}



// CONTROLE DO BANNER PRINCIPAL ---------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------

function init_banners(){
	$.getJSON(path+"banners.php", function(data) {
		if(data.banners.length>0){
			for(i=0;i<data.banners.length;i++){
				if(data.banners[i].url != "")
					$("<a href='"+data.banners[i].url+"' target='_blank'><li></li></a>").appendTo(".banners ul.ban_image");
				else
					$("<li></li>").appendTo(".banners ul.ban_image");
				$("<li><a href='javascript:;'>"+(i+1)+"</a></li>").appendTo(".banners ul.ban_number");
				data.banners[i].loaded = false;
				
				/*
				if(data.banners[i].url != ""){
					$(".banners ul.ban_image li:eq("+i+")").click(function(){
						window.location.href = data.banners[i].url;
					}).css("cursor","pointer");
				}*/
			}
			
			var objImage = new Image();
			objImage.src = data.banners[0].img;
			
			
			var objBanner = new Object();
			
			objBanner.index = 0;
			objBanner.indexNext = 1;
			objBanner.indexPrev = data.banners.length-1;
			objBanner.img = objImage;
			objBanner.arrBanners = data.banners;
			
			load_background(objBanner);
		}
	});
}


function change_background(objBanner, next){
	clearInterval(objBanner.interval);
	
	$(".banners .ban_image li:visible").fadeOut(500);
	
	if(next){
		objBanner.indexPrev = objBanner.index;
		objBanner.index = objBanner.indexNext;
		objBanner.indexNext = objBanner.indexNext+1;
		if(objBanner.indexNext>=objBanner.arrBanners.length) objBanner.indexNext = 0;
	}else{
		objBanner.indexNext = objBanner.index;
		objBanner.index = objBanner.indexPrev;
		objBanner.indexPrev = objBanner.indexPrev-1;
		if(objBanner.indexPrev<=0) objBanner.indexPrev = objBanner.arrBanners.length-1;
	}
	
	if(objBanner.arrBanners[objBanner.index].loaded){
		$(".banners .ban_image li:eq("+objBanner.index+")").fadeIn(500);
		control_background(objBanner);
	}else{
		objBanner.img.src = objBanner.arrBanners[objBanner.index].img;
		load_background(objBanner);
	}
	
}

// CARREGA E FAZ A TROCA DO BACKGROUND
function load_background(objBanner){
	if(objBanner.img.complete){
		$(".banners .ban_image li:eq("+objBanner.index+")").css("background","url("+objBanner.img.src+") no-repeat center top");
		$(".banners .ban_image li:eq("+objBanner.index+")").hide().fadeIn(500);
		objBanner.arrBanners[objBanner.index].loaded = true;
		control_background(objBanner);

		
	}else{
		setTimeout(function(){load_background(objBanner);},500);
	}
}

function control_background(objBanner){
	if(objBanner.arrBanners.length>1){
		objBanner.interval = setInterval(function(){change_background(objBanner, true)}, 5000);
		
		$(".banners ul.ban_number li").each(function(i){
			$(this).unbind("click");
			$(this).click(function(){
				var j = i-1;
				objBanner.indexPrev = j-1;
				if(objBanner.indexPrev<0) objBanner.indexPrev = objBanner.arrBanners.length -1
				
				objBanner.index = j;
				
				objBanner.indexNext = j+1;
				if(objBanner.indexNext >= objBanner.arrBanners.length) objBanner.indexNext = 0;
				
				change_background(objBanner, true);
				
			});
			
			if(objBanner.index==i){
				$(this).addClass("old");
			}else{
				$(this).removeClass("old");
			}
			
		});
	}
}

//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------


//******************************************************************************/
//CONTROLE DE INFRAESTRUTURA E PROFESSORES
/******************************************************************************/

function expandImoveis(){
	var ref = $(this).parents(".infra");
	var id = $(this).parent().find("a.expand_button").attr("rel");
	var lang = $(this).parent().find("a.expand_button img").attr("lang");
	if($(".infra .txt:visible").length > 0){
		$(this).parent().find("a.expand_button img").attr("src","img/btn_detalhes_"+lang+".png");
		$(".infra .txt:visible").slideUp(function(){
			var id_compara = $(this).parents(".infra").find("a.expand_button").attr("rel");
			$(this).parent().find("a.expand_button img").attr("src","img/btn_detalhes_"+lang+".png");
			if(id_compara != id){
				$(ref).find(".txt").slideDown(function(){
					$(this).parent().find("a.expand_button img").attr("src","img/btn_fechar_"+lang+".png");
					$("body").scrollTo($(this).parents(".infra"), 400,  { easing:'easeInOutCubic'});
				});
			}
		});
	}else{
		$(this).parent().find("a.expand_button img").attr("src","img/btn_fechar_"+lang+".png");
		$(this).parents(".infra").find(".txt").slideDown();
	}
}



//******************************************************************************/
//ABRE POPUP ESQUECI A SENHA
/******************************************************************************/
function openpopup(settings){
	
	config = {
		width:600,
		height:300,
		url:""
	};
	$.extend(config, settings);
	halfWidth = Math.floor(config.width/-2);
	halfHeight = Math.floor(config.height/-2);
	
	$("<div id=\"bg_black\" onClick=\"javascript:fecharpopup1();\" style=\"display:none;\"></div>").appendTo("body");
	
	
	if($.browser.safari){
		scrollPosition = document.body.scrollTop;
	}else{
		scrollPosition = document.documentElement.scrollTop;
	}	
	
	$.browser.msie ? $("body").attr("scroll", "no") : $("body").css("overflow", "hidden");
	
	$("#bg_black").fadeTo(01, 0).css({width:"100%",height:"100%",cursor:"pointer",top:scrollPosition,position:"absolute",background:"#000",zIndex:"999"});
	$("#bg_black").fadeTo("slow", 0.7);	
	
	$("<div class='popupbox' style='width:"+config.width+"px; height:"+config.height+"px; position:absolute; z-index:2000; left:50%; margin-left:"+halfWidth+"px;'></div>").prependTo("body");
	
	$(".popupbox").load(config.url);
	
	if($.browser.safari){
		scrollPosition = document.body.scrollTop;
	}else{
		scrollPosition = document.documentElement.scrollTop;
	}

	$(".popupbox").css({marginTop:(halfHeight+scrollPosition)+"px", top:"50%"});
	

}

function fecharpopup1(){
	
	$(".popupbox").remove();
	$("#bg_black").fadeOut(function(){$(this).remove();});
	$.browser.msie ? $("body").removeAttr("scroll") : $("body").css("overflow", "auto");	
	if($.browser.msie){
		if($.browser.version=="7.0"){
			$("body").removeAttr("scroll");
		}else{
			$("body").css("overflow", "auto");
		}
	}else{
		$("body").css("overflow", "auto");
	}
	
}
//ATUALIZAR PAGINA DE COMPRADORES
function carregaPaginacao(pagina){
	$("#atualiza").load(pagina);
}

//---------------------------SUBIR A PAGINA---------------------------------------------------------
function topAll()
{
	var url = window.parent.location.href;
	if(url.indexOf("#") == -1)window.parent.location.href = url+"#";
	else window.parent.location.href = url
}

//---------------------PRÓXIMO CAMPO---------------------------------------------------------
function jrs_Valida(campo, prox, total)
{
	if(campo.value.length>total-1)document.getElementById(prox).focus();
}

//MÁSCARA DE VALORES
function txtBoxFormat(objeto, sMask, evtKeyPress) {
    var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
	if(document.all) { // Internet Explorer
		nTecla = evtKeyPress.keyCode;
	} else if(document.layers) { // Nestcape
		nTecla = evtKeyPress.which;
	} else {
		nTecla = evtKeyPress.which;
		if (nTecla == 8 || nTecla == 0) {
			return true;
		}
	}
    sValue = objeto.value;
    // Limpa todos os caracteres de formatação que
    // já estiverem no campo.
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( " ", "" );
    sValue = sValue.toString().replace( " ", "" );
    fldLen = sValue.length;
    mskLen = sMask.length;

    i = 0;
    nCount = 0;
    sCod = "";
    mskLen = fldLen;

    while (i <= mskLen) {
      bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))
      bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

      if (bolMask) {
        sCod += sMask.charAt(i);
        mskLen++;
	  }else{
        sCod += sValue.charAt(nCount);
        nCount++;
      }
      i++;
    }
    objeto.value = sCod;

	if (nTecla != 8) { // backspace ou tab
		if(sMask.charAt(i-1) == "9"){ // apenas números...
			return ((nTecla > 47) && (nTecla < 58));
		}else{ // qualquer caracter...
			return true;
		} 
	}else{
		return true;
	}
}

function validaEmail(email){
	ER = new RegExp("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]{2,64}(\.[a-z0-9-]{2,64})*\.[a-z]{2,4}$");
	if (ER.test(email)){
		return true;
	}else{
		return false;
	}
}

/******************************************************************************/
// ENVIA CONTATO
/******************************************************************************/
function Envia_Contato(form){
var nome=form.nome.value;
var ddd_telefone=form.ddd_telefone.value;
var telefone=form.telefone.value;
var ddd_celular=form.ddd_celular.value;
var celular=form.celular.value;
var email=form.email.value;
var pais=form.pais.value;
var cidade=form.cidade.value;
var uf=form.uf.value;
var assunto=form.assunto.value;
var mensagem=form.mensagem.value;
var lingua=form.lingua.value;
	if(lingua == "pt") {
		if (nome==""){
			$(".form_resposta").html("Digite o Nome.");											
			form.nome.focus();
		} else if (ddd_telefone==""){
			$(".form_resposta").html("Digite o Telefone.");													
			form.ddd_telefone.focus();
		} else if (telefone==""){
			$(".form_resposta").html("Digite o Telefone.");													
			form.telefone.focus();
		} else if (ddd_celular==""){
			$(".form_resposta").html("Digite o Celular.");													
			form.ddd_celular.focus();
		} else if (celular==""){
			$(".form_resposta").html("Digite o Celular.");													
			form.celular.focus();
		} else if (email==""){
			$(".form_resposta").html("Digite o Email.");													
			form.email.focus();
		} else if(!validaEmail(email)){
			$(".form_resposta").html("Formato do Email Incorreto.");													
			form.email.focus();
		} else if (pais==""){
			$(".form_resposta").html("Digite o Pa&iacute;s.");											
			form.pais.focus();
		}else if (cidade==""){
			$(".form_resposta").html("Digite a Cidade.");											
			form.cidade.focus();
		}else if (uf==""){
			$(".form_resposta").html("Digite o UF.");											
			form.uf.focus();
		}else if (assunto==""){
			$(".form_resposta").html("Digite o Assunto.");											
			form.assunto.focus();
		}else if (mensagem==""){
			$(".form_resposta").html("Digite a Mensagem.");											
			form.mensagem.focus();
		} else {	
			$.post('scripts/envia_contato.php',$(form).serialize(),function(data){
				$(".form_resposta").html(data);
				form.reset();
			});
		}		
	}else if(lingua == "en") {
		if (nome==""){
			$(".form_resposta").html("Enter Name.");											
			form.nome.focus();
		} else if (ddd_telefone==""){
			$(".form_resposta").html("Enter Phone.");													
			form.ddd_telefone.focus();
		} else if (telefone==""){
			$(".form_resposta").html("Enter Phone.");													
			form.telefone.focus();
		} else if (ddd_celular==""){
			$(".form_resposta").html("Enter Mobile.");													
			form.ddd_celular.focus();
		} else if (celular==""){
			$(".form_resposta").html("Enter Mobile.");													
			form.celular.focus();
		} else if (email==""){
			$(".form_resposta").html("Enter your Email.");													
			form.email.focus();
		} else if(!validaEmail(email)){
			$(".form_resposta").html("Wrong Email Format.");													
			form.email.focus();
		} else if (pais==""){
			$(".form_resposta").html("Enter the Country.");											
			form.pais.focus();
		}else if (cidade==""){
			$(".form_resposta").html("Enter the City.");											
			form.cidade.focus();
		}else if (uf==""){
			$(".form_resposta").html("Enter the State.");											
			form.uf.focus();
		}else if (assunto==""){
			$(".form_resposta").html("Enter the Subject.");											
			form.assunto.focus();
		}else if (mensagem==""){
			$(".form_resposta").html("Enter the Message.");											
			form.mensagem.focus();
		} else {	
			$.post('scripts/envia_contato.php',$(form).serialize(),function(data){
				$(".form_resposta").html(data);
				form.reset();
			});
		}				
	}else if(lingua == "es") {
		if (nome==""){
			$(".form_resposta").html("Ingrese el nombre.");											
			form.nome.focus();
		} else if (ddd_telefone==""){
			$(".form_resposta").html("Introduzca tel&eacute;fono.");													
			form.ddd_telefone.focus();
		} else if (telefone==""){
			$(".form_resposta").html("Introduzca tel&eacute;fono.");													
			form.telefone.focus();
		} else if (ddd_celular==""){
			$(".form_resposta").html("Introduzca M&oacute;vil.");													
			form.ddd_celular.focus();
		} else if (celular==""){
			$(".form_resposta").html("Introduzca M&oacute;vil.");													
			form.celular.focus();
		} else if (email==""){
			$(".form_resposta").html("Ingrese su correo electrónico.");													
			form.email.focus();
		} else if(!validaEmail(email)){
			$(".form_resposta").html("Formato de correo electrónico incorrecta.");													
			form.email.focus();
		} else if (pais==""){
			$(".form_resposta").html("Ingrese el Pa&iacute;s.");											
			form.pais.focus();
		}else if (cidade==""){
			$(".form_resposta").html("Entrar en la ciudad.");											
			form.cidade.focus();
		}else if (uf==""){
			$(".form_resposta").html("Introduzca el Estado.");											
			form.uf.focus();
		}else if (assunto==""){
			$(".form_resposta").html("Introduzca el Asunto.");											
			form.assunto.focus();
		}else if (mensagem==""){
			$(".form_resposta").html("Introduzca el mensaje.");											
			form.mensagem.focus();
		} else {	
			$.post('scripts/envia_contato.php',$(form).serialize(),function(data){
				$(".form_resposta").html(data);
				form.reset();
			});
		}		
	}
}


/******************************************************************************/
// ENVIA INSCRIÇÃO
/******************************************************************************/
function Envia_Inscricao(form){
var nome=form.nome.value;
var sexo=form.sexo.value;
var endereco=form.endereco.value;
var pais=form.pais.value;
var cidade=form.cidade.value;
var uf=form.uf.value;
var cep1=form.cep1.value;
var cep2=form.cep2.value;
var cpf=form.cpf.value;
var crm=form.crm.value;
var especialidade=form.especialidade.value;
var hospital=form.hospital.value;
var ddd_telefone=form.ddd_telefone.value;
var telefone=form.telefone.value;
var ddd_celular=form.ddd_celular.value;
var celular=form.celular.value;
var email=form.email.value;
var acompanhante=form.acompanhante.value;
var modulo=form.modulo.value;
var lingua=form.lingua.value;
	if(lingua == "pt") {
		if (nome==""){
			$(".form_resposta").html("Digite o Nome.");											
			form.nome.focus();
		} else if (sexo==""){
			$(".form_resposta").html("Informe o Sexo.");													
			form.sexo.focus();
		}else if (endereco==""){
			$(".form_resposta").html("Digite o Endere&ccedil;o.");													
			form.endereco.focus();
		}else if (pais==""){
			$(".form_resposta").html("Digite o Pa&iacute;s.");													
			form.pais.focus();
		}else if (cidade==""){
			$(".form_resposta").html("Digite a Cidade.");													
			form.cidade.focus();
		}else if (uf==""){
			$(".form_resposta").html("Digite o UF.");													
			form.uf.focus();
		}else if (cep1==""){
			$(".form_resposta").html("Digite o CEP");													
			form.cep1.focus();
		}else if (cep2==""){
			$(".form_resposta").html("Digite o CEP.");													
			form.cep2.focus();
		}else if (cpf==""){
			$(".form_resposta").html("Digite o CPF.");													
			form.cpf.focus();
		}else if (crm==""){
			$(".form_resposta").html("Digite o Crm.");													
			form.crm.focus();
		}else if (especialidade==""){
			$(".form_resposta").html("Digite a Especialidade.");													
			form.especialidade.focus();
		}else if (hospital==""){
			$(".form_resposta").html("Digite o Hospital Refer&ecirc;ncia.");													
			form.hospital.focus();
		}else if (ddd_telefone==""){
			$(".form_resposta").html("Digite o Telefone.");													
			form.ddd_telefone.focus();
		} else if (telefone==""){
			$(".form_resposta").html("Digite o Telefone.");													
			form.telefone.focus();
		} else if (ddd_celular==""){
			$(".form_resposta").html("Digite o Celular.");													
			form.ddd_celular.focus();
		} else if (celular==""){
			$(".form_resposta").html("Digite o Celular.");													
			form.celular.focus();
		} else if (email==""){
			$(".form_resposta").html("Digite o Email.");													
			form.email.focus();
		} else if(!validaEmail(email)){
			$(".form_resposta").html("Formato do Email Incorreto.");													
			form.email.focus();
		} else if (acompanhante==""){
			$(".form_resposta").html("Digite o Acompanhante.");											
			form.acompanhante.focus();
		}else if (modulo==""){
			$(".form_resposta").html("Informe o M&oacute;dulo.");											
			form.modulo.focus();
		} else {	
			$.post('scripts/envia_inscricao.php',$(form).serialize(),function(data){
				$(".form_resposta").html(data);
				form.reset();
			});
		}		
	}else if(lingua == "en") {
		if (nome==""){
			$(".form_resposta").html("Enter the name.");											
			form.nome.focus();
		} else if (sexo==""){
			$(".form_resposta").html("Tell Sex.");													
			form.sexo.focus();
		}else if (endereco==""){
			$(".form_resposta").html("Enter your address.");													
			form.endereco.focus();
		}else if (pais==""){
			$(".form_resposta").html("Enter the Country.");													
			form.pais.focus();
		}else if (cidade==""){
			$(".form_resposta").html("Enter the City.");													
			form.cidade.focus();
		}else if (uf==""){
			$(".form_resposta").html("Enter the State.");													
			form.uf.focus();
		}else if (cep1==""){
			$(".form_resposta").html("Enter Zip Code");													
			form.cep1.focus();
		}else if (cep2==""){
			$(".form_resposta").html("Enter Zip Code.");													
			form.cep2.focus();
		}else if (cpf==""){
			$(".form_resposta").html("Enter the CPF.");													
			form.cpf.focus();
		}else if (crm==""){
			$(".form_resposta").html("Enter Crm.");													
			form.crm.focus();
		}else if (especialidade==""){
			$(".form_resposta").html("Enter the Specialty.");													
			form.especialidade.focus();
		}else if (hospital==""){
			$(".form_resposta").html("Enter the Reference Hospital.");													
			form.hospital.focus();
		}else if (ddd_telefone==""){
			$(".form_resposta").html("Enter Phone.");													
			form.ddd_telefone.focus();
		} else if (telefone==""){
			$(".form_resposta").html("Enter Phone.");													
			form.telefone.focus();
		} else if (ddd_celular==""){
			$(".form_resposta").html("Enter Mobile.");													
			form.ddd_celular.focus();
		} else if (celular==""){
			$(".form_resposta").html("Enter Mobile.");													
			form.celular.focus();
		} else if (email==""){
			$(".form_resposta").html("Enter your Email.");													
			form.email.focus();
		} else if(!validaEmail(email)){
			$(".form_resposta").html("Wrong Email Format.");													
			form.email.focus();
		} else if (acompanhante==""){
			$(".form_resposta").html("Enter Escort.");											
			form.acompanhante.focus();
		}else if (modulo==""){
			$(".form_resposta").html("Report Module.");											
			form.modulo.focus();
		} else {	
			$.post('scripts/envia_inscricao.php',$(form).serialize(),function(data){
				$(".form_resposta").html(data);
				form.reset();
			});
		}		
	}else if(lingua == "es") {
		if (nome==""){
			$(".form_resposta").html("Ingrese el nombre.");											
			form.nome.focus();
		} else if (sexo==""){
			$(".form_resposta").html("Dile Sexo.");													
			form.sexo.focus();
		}else if (endereco==""){
			$(".form_resposta").html("Ingrese su direcci&oacute;n.");													
			form.endereco.focus();
		}else if (pais==""){
			$(".form_resposta").html("Ingrese el Pa&iacute;s.");													
			form.pais.focus();
		}else if (cidade==""){
			$(".form_resposta").html("Entrar en la ciudad.");													
			form.cidade.focus();
		}else if (uf==""){
			$(".form_resposta").html("Introduzca la UF.");													
			form.uf.focus();
		}else if (cep1==""){
			$(".form_resposta").html("Introduzca el c&oacute;digo postal");													
			form.cep1.focus();
		}else if (cep2==""){
			$(".form_resposta").html("Introduzca el c&oacute;digo postal.");													
			form.cep2.focus();
		}else if (cpf==""){
			$(".form_resposta").html("Introduzca la CPF.");													
			form.cpf.focus();
		}else if (crm==""){
			$(".form_resposta").html("Introduzca Crm.");													
			form.crm.focus();
		}else if (especialidade==""){
			$(".form_resposta").html("Introduzca la Especialidad.");													
			form.especialidade.focus();
		}else if (hospital==""){
			$(".form_resposta").html("Introduzca el Hospital de Referencia.");													
			form.hospital.focus();
		}else if (ddd_telefone==""){
			$(".form_resposta").html("Introduzca teléfono.");													
			form.ddd_telefone.focus();
		} else if (telefone==""){
			$(".form_resposta").html("Introduzca teléfono.");													
			form.telefone.focus();
		} else if (ddd_celular==""){
			$(".form_resposta").html("Introduzca M&oacute;vel.");													
			form.ddd_celular.focus();
		} else if (celular==""){
			$(".form_resposta").html("Introduzca M&oacute;vel.");													
			form.celular.focus();
		} else if (email==""){
			$(".form_resposta").html("Ingrese correo electrónico.");													
			form.email.focus();
		} else if(!validaEmail(email)){
			$(".form_resposta").html("Formato de correo electrónico incorrecta.");													
			form.email.focus();
		} else if (acompanhante==""){
			$(".form_resposta").html("Introduzca Escort.");											
			form.acompanhante.focus();
		}else if (modulo==""){
			$(".form_resposta").html("Informe del módulo.");											
			form.modulo.focus();
		} else {	
			$.post('scripts/envia_inscricao.php',$(form).serialize(),function(data){
				$(".form_resposta").html(data);
				form.reset();
			});
		}		
	}
}

/******************************************************************************/
// ENVIA CADASTRO
/******************************************************************************/
function Envia_Cadastro(form){
var nome=form.nome.value;
var ddd_telefone=form.ddd_telefone.value;
var telefone=form.telefone.value;
var pais=form.pais.value;
var cidade=form.cidade.value;
var uf=form.uf.value;
var email=form.email.value;
var especialidade=form.especialidade.value;
var senha=form.senha.value;
var conf_senha=form.conf_senha.value;
var lingua=form.lingua.value;
	if(lingua == "pt") {
		if (nome==""){
			$(".form_resposta").html("Digite o Nome.");											
			form.nome.focus();
		}else if (ddd_telefone==""){
			$(".form_resposta").html("Digite o Telefone.");													
			form.ddd_telefone.focus();
		} else if (telefone==""){
			$(".form_resposta").html("Digite o Telefone.");													
			form.telefone.focus();
		} else if (pais==""){
			$(".form_resposta").html("Digite o Pa&iacute;s.");													
			form.pais.focus();
		}else if (cidade==""){
			$(".form_resposta").html("Digite a Cidade.");													
			form.cidade.focus();
		}else if (uf==""){
			$(".form_resposta").html("Digite o UF.");													
			form.uf.focus();
		} else if (email==""){
			$(".form_resposta").html("Digite o Email.");													
			form.email.focus();
		} else if(!validaEmail(email)){
			$(".form_resposta").html("Formato do Email Incorreto.");													
			form.email.focus();
		} else if (especialidade==""){
			$(".form_resposta").html("Digite a Especialidade.");													
			form.especialidade.focus();
		} else if (senha==""){
			$(".form_resposta").html("Digite a senha.");											
			form.senha.focus();
		}else if (conf_senha==""){
			$(".form_resposta").html("Confirme a Senha.");											
			form.conf_senha.focus();
		} else if(senha != conf_senha){
			$(".form_resposta").html("As Senhas n&atilde;o est&atilde;o iguais.");											
			form.conf_senha.focus();			
		}else{	
			$.post('scripts/envia_cadastro.php',$(form).serialize(),function(data){
				$(".form_resposta").html(data);
				form.reset();
			});
		}		
	}else if(lingua == "en") {
		if (nome==""){
			$(".form_resposta").html("Enter Name.");											
			form.nome.focus();
		}else if (ddd_telefone==""){
			$(".form_resposta").html("Enter Phone.");													
			form.ddd_telefone.focus();
		} else if (telefone==""){
			$(".form_resposta").html("Enter Phone.");													
			form.telefone.focus();
		} else if (pais==""){
			$(".form_resposta").html("Enter the Country.");													
			form.pais.focus();
		}else if (cidade==""){
			$(".form_resposta").html("Enter the City.");													
			form.cidade.focus();
		}else if (uf==""){
			$(".form_resposta").html("Enter the state.");													
			form.uf.focus();
		} else if (email==""){
			$(".form_resposta").html("Enter your Email.");													
			form.email.focus();
		} else if(!validaEmail(email)){
			$(".form_resposta").html("Wrong Email Format.");													
			form.email.focus();
		} else if (especialidade==""){
			$(".form_resposta").html("Enter the Specialty.");													
			form.especialidade.focus();
		} else if (senha==""){
			$(".form_resposta").html("Enter password.");											
			form.senha.focus();
		}else if (conf_senha==""){
			$(".form_resposta").html("Confirm Password.");											
			form.conf_senha.focus();
		} else if(senha != conf_senha){
			$(".form_resposta").html("Passwords are not equal.");											
			form.conf_senha.focus();			
		}else{	
			$.post('scripts/envia_cadastro.php',$(form).serialize(),function(data){
				$(".form_resposta").html(data);
				form.reset();
			});
		}		
	}else if(lingua == "es") {
		if (nome==""){
			$(".form_resposta").html("Ingrese el nombre.");											
			form.nome.focus();
		}else if (ddd_telefone==""){
			$(".form_resposta").html("Introduzca teléfono.");													
			form.ddd_telefone.focus();
		} else if (telefone==""){
			$(".form_resposta").html("Introduzca teléfono.");													
			form.telefone.focus();
		} else if (pais==""){
			$(".form_resposta").html("Ingrese el País.");													
			form.pais.focus();
		}else if (cidade==""){
			$(".form_resposta").html("Entrar en la ciudad.");													
			form.cidade.focus();
		}else if (uf==""){
			$(".form_resposta").html("Introduzca la UF.");													
			form.uf.focus();
		} else if (email==""){
			$(".form_resposta").html("Ingrese su correo electrónico.");													
			form.email.focus();
		} else if(!validaEmail(email)){
			$(".form_resposta").html("Formato de correo electrónico incorrecta.");													
			form.email.focus();
		} else if (especialidade==""){
			$(".form_resposta").html("Introduzca la Especialidad.");													
			form.especialidade.focus();
		} else if (senha==""){
			$(".form_resposta").html("Introduzca la contraseña.");											
			form.senha.focus();
		}else if (conf_senha==""){
			$(".form_resposta").html("Confirmar contraseña.");											
			form.conf_senha.focus();
		} else if(senha != conf_senha){
			$(".form_resposta").html("Las contraseñas no son iguales.");											
			form.conf_senha.focus();			
		}else{	
			$.post('scripts/envia_cadastro.php',$(form).serialize(),function(data){
				$(".form_resposta").html(data);
				form.reset();
			});
		}		
	}
}

//ATUALIZAR PAGINA DE COMPRADORES
function carregaPaginacao2(pagina){
	$(".atualiza").load(pagina);
}


function carregaPaginacaoGaleria(pagina, galeria){
	$(".atualiza"+galeria).load(pagina);
}


//ATUALIZAR PAGINA DE COMPRADORES
function TrocaFoto(id){
	$(".curso_foto_grande").load(path+'foto_media.php?id='+id);
}

/******************************************************************************/
// ESQUECI SENHA
/******************************************************************************/
function Esqueci_senha(form){
var email=form.email.value;
var lingua=form.lingua.value;
	if(lingua == "pt") {
		if (email==""){
			$(".form_resposta").html("Digite o Email.");													
			form.email.focus();
		} else if(!validaEmail(email)){
			$(".form_resposta").html("Formato do Email Incorreto.");													
			form.email.focus();
		} else {	
			$.post('scripts/esqueci_senha.php',$(form).serialize(),function(data){
				$(".form_resposta").html(data);
				form.reset();
			});
		}		
	}else if(lingua == "en") {
		if (email==""){
			$(".form_resposta").html("Enter your Email.");													
			form.email.focus();
		} else if(!validaEmail(email)){
			$(".form_resposta").html("Wrong Email Format.");													
			form.email.focus();
		} else {	
			$.post('scripts/esqueci_senha.php',$(form).serialize(),function(data){
				$(".form_resposta").html(data);
				form.reset();
			});
		}				
	}else if(lingua == "es") {
		if (email==""){
			$(".form_resposta").html("Ingrese su correo electrónico.");													
			form.email.focus();
		} else if(!validaEmail(email)){
			$(".form_resposta").html("Formato de correo electrónico incorrecta.");													
			form.email.focus();
		} else if (senha==""){
			$(".form_resposta").html("Introduzca la contraseña.");											
			form.senha.focus();
		}else {	
			$.post('scripts/esqueci_senha.php',$(form).serialize(),function(data){
				$(".form_resposta").html(data);
				form.reset();
			});
		}		
	}
}


/******************************************************************************/
// LOGAR
/******************************************************************************/
function Logar(form){
var email=form.email.value;
var senha=form.senha.value;
var lingua=form.lingua.value;
	if(lingua == "pt") {
		if (email==""){
			alert("Digite o Email.");													
			form.email.focus();
		} else if(!validaEmail(email)){
			alert("Formato do Email Incorreto.");													
			form.email.focus();
		} else if (senha==""){
			alert("Digite a senha.");											
			form.senha.focus();
		} else {	
			$.post('scripts/logar.php',$(form).serialize(),function(data){
				if(data != "ok") {
					alert(data);
				} else {
					window.location = path+'home';	
				}
			});
		}		
	}else if(lingua == "en") {
		if (email==""){
			alert("Enter your Email.");													
			form.email.focus();
		} else if(!validaEmail(email)){
			alert("Wrong Email Format.");													
			form.email.focus();
		} else if (senha==""){
			alert("Enter password.");											
			form.senha.focus();
		} else {	
			$.post('scripts/logar.php',$(form).serialize(),function(data){
				if(data != "ok") {
					alert(data);
				} else {
					window.location = path+'home';	
				}
			});
		}				
	}else if(lingua == "es") {
		if (email==""){
			alert("Ingrese su correo electrónico.");													
			form.email.focus();
		} else if(!validaEmail(email)){
			alert("Formato de correo electrónico incorrecta.");													
			form.email.focus();
		} else {	
			$.post('scripts/logar.php',$(form).serialize(),function(data){
				if(data != "ok") {
					alert(data);
				} else {
					window.location = path+'home';	
				}
			});
		}		
	}
}


/******************************************************************************/
// EDITAR CADASTRO
/******************************************************************************/
function Editar_Cadastro(form){
var nome=form.nome.value;
var telefone=form.telefone.value;
var pais=form.pais.value;
var cidade=form.cidade.value;
var uf=form.uf.value;
var email=form.email.value;
var especialidade=form.especialidade.value;
var senha=form.senha.value;
var conf_senha=form.conf_senha.value;
var lingua=form.lingua.value;
	if(lingua == "pt") {
		if (nome==""){
			$(".form_resposta").html("Digite o Nome.");											
			form.nome.focus();
		}else if (telefone==""){
			$(".form_resposta").html("Digite o Telefone.");													
			form.telefone.focus();
		} else if (pais==""){
			$(".form_resposta").html("Digite o Pa&iacute;s.");													
			form.pais.focus();
		}else if (cidade==""){
			$(".form_resposta").html("Digite a Cidade.");													
			form.cidade.focus();
		}else if (uf==""){
			$(".form_resposta").html("Digite o UF.");													
			form.uf.focus();
		} else if (email==""){
			$(".form_resposta").html("Digite o Email.");													
			form.email.focus();
		} else if(!validaEmail(email)){
			$(".form_resposta").html("Formato do Email Incorreto.");													
			form.email.focus();
		} else if (especialidade==""){
			$(".form_resposta").html("Digite a Especialidade.");													
			form.especialidade.focus();
		} else{
			if (senha!=""){
				if (conf_senha==""){
					$(".form_resposta").html("Confirme a Senha.");											
					form.conf_senha.focus();
				} else if(senha != conf_senha){
					$(".form_resposta").html("As Senhas n&atilde;o est&atilde;o iguais.");											
					form.conf_senha.focus();			
				} else {
					$.post('scripts/editar_cadastro.php',$(form).serialize(),function(data){
						$(".form_resposta").html(data);
					});					
				}
			} else {
				$.post('scripts/editar_cadastro.php',$(form).serialize(),function(data){
					$(".form_resposta").html(data);
				});
			}
		}		
	}else if(lingua == "en") {
		if (nome==""){
			$(".form_resposta").html("Enter Name.");											
			form.nome.focus();
		}else if (ddd_telefone==""){
			$(".form_resposta").html("Enter Phone.");													
			form.ddd_telefone.focus();
		} else if (telefone==""){
			$(".form_resposta").html("Enter Phone.");													
			form.telefone.focus();
		} else if (pais==""){
			$(".form_resposta").html("Enter the Country.");													
			form.pais.focus();
		}else if (cidade==""){
			$(".form_resposta").html("Enter the City.");													
			form.cidade.focus();
		}else if (uf==""){
			$(".form_resposta").html("Enter the state.");													
			form.uf.focus();
		} else if (email==""){
			$(".form_resposta").html("Enter your Email.");													
			form.email.focus();
		} else if(!validaEmail(email)){
			$(".form_resposta").html("Wrong Email Format.");													
			form.email.focus();
		} else if (especialidade==""){
			$(".form_resposta").html("Enter the Specialty.");													
			form.especialidade.focus();
		} else{
			if (senha!=""){
				if (conf_senha==""){
					$(".form_resposta").html("Confirm Password.");											
					form.conf_senha.focus();
				} else if(senha != conf_senha){
					$(".form_resposta").html("Passwords are not equal.");											
					form.conf_senha.focus();			
				} else {
					$.post('scripts/editar_cadastro.php',$(form).serialize(),function(data){
						$(".form_resposta").html(data);
					});					
				}
			} else {
				$.post('scripts/editar_cadastro.php',$(form).serialize(),function(data){
					$(".form_resposta").html(data);
				});
			}			
		}		
	}else if(lingua == "es") {
		if (nome==""){
			$(".form_resposta").html("Ingrese el nombre.");											
			form.nome.focus();
		}else if (ddd_telefone==""){
			$(".form_resposta").html("Introduzca teléfono.");													
			form.ddd_telefone.focus();
		} else if (telefone==""){
			$(".form_resposta").html("Introduzca teléfono.");													
			form.telefone.focus();
		} else if (pais==""){
			$(".form_resposta").html("Ingrese el País.");													
			form.pais.focus();
		}else if (cidade==""){
			$(".form_resposta").html("Entrar en la ciudad.");													
			form.cidade.focus();
		}else if (uf==""){
			$(".form_resposta").html("Introduzca la UF.");													
			form.uf.focus();
		} else if (email==""){
			$(".form_resposta").html("Ingrese su correo electrónico.");													
			form.email.focus();
		} else if(!validaEmail(email)){
			$(".form_resposta").html("Formato de correo electrónico incorrecta.");													
			form.email.focus();
		} else if (especialidade==""){
			$(".form_resposta").html("Introduzca la Especialidad.");													
			form.especialidade.focus();
		} else{
			if (senha!=""){
				if (conf_senha==""){
					$(".form_resposta").html("Confirmar contraseña.");											
					form.conf_senha.focus();
				} else if(senha != conf_senha){
					$(".form_resposta").html("Las contraseñas no son iguales.");											
					form.conf_senha.focus();			
				} else {
					$.post('scripts/editar_cadastro.php',$(form).serialize(),function(data){
						$(".form_resposta").html(data);
					});					
				}
			} else {
				$.post('scripts/editar_cadastro.php',$(form).serialize(),function(data){
					$(".form_resposta").html(data);
				});
			}						
		}		
	}
}

//EXCLUIR FAVORITO VIDEO
function Excluir_Video(id, lingua) {
	if(lingua == "en") {
		if(!confirm('Are you sure you want to remove this video from your favorites?')) 
		{
			return false;
		} else {
			$.get('scripts/excluir_video.php?id='+id,function(data){
				alert(data);
				$("#lista_videos").load("lista_videos_favo.php");
			});
		}
	} else if(lingua == "es"){
		if(!confirm('¿Está seguro que desea eliminar este vídeo de tus favoritos?')) 
		{
			return false;
		} else {
			$.get('scripts/excluir_video.php?id='+id,function(data){
				alert(data);
				$("#lista_videos").load("lista_videos_favo.php");
			});
		}		
	} else {
		if(!confirm('Voce tem certeza que deseja remover esse video de seus favoritos?')) 
		{
			return false;
		} else {
			$.get('scripts/excluir_video.php?id='+id,function(data){
				alert(data);
				$("#lista_videos").load("lista_videos_favo.php");
			});
		}		
	}
}

//FAVORITAR VIDEO
function Favoritar_Video(id) {
	$.get(path+'scripts/favoritar_video.php?id='+id,function(data){
		alert(data);
	});
}

//FAVORITAR AULAS
function Favoritar_Aulas(id) {
	$.get(path+'scripts/favoritar_aulas.php?id='+id,function(data){
		alert(data);
	});
}

//EXCLUIR FAVORITO AULAS
function Excluir_Aulas(id, lingua) {
	if(lingua == "en") {
		if(!confirm('Are you sure you want to remove this classe from your favorites?')) 
		{
			return false;
		} else {
			$.get('scripts/excluir_aulas.php?id='+id,function(data){
				alert(data);
				$("#lista_aulas").load("lista_aulas_favo.php");
			});
		}
	} else if(lingua == "es"){
		if(!confirm('¿Está seguro que desea eliminar esta clase de tus favoritos?')) 
		{
			return false;
		} else {
			$.get('scripts/excluir_aulas.php?id='+id,function(data){
				alert(data);
				$("#lista_aulas").load("lista_aulas_favo.php");
			});
		}		
	} else {
		if(!confirm('Voce tem certeza que deseja remover essa aula de seus favoritos?')) 
		{
			return false;
		} else {
			$.get('scripts/excluir_aulas.php?id='+id,function(data){
				alert(data);
				$("#lista_aulas").load("lista_aulas_favo.php");
			});
		}		
	}
}

/******************************************************************************/
//INDIQUE UM AMIGO
/******************************************************************************/
function Indique(form){
var seu_nome		=	form.seu_nome.value;
var seu_email		=	form.seu_email.value;
var nome_amigo		=	form.nome_amigo.value;
var email_amigo		=	form.email_amigo.value;
var lingua			=	form.lingua.value;
	if(lingua == "pt") {
		if (seu_nome==""){
			$("#resposta").html("Digite o seu Nome.");													
			form.seu_nome.focus();
		} else if (seu_email==""){
			$("#resposta").html("Digite o seu Email.");													
			form.seu_email.focus();
		} else if(!validaEmail(seu_email)){
			$("#resposta").html("Formato do seu Email Incorreto.");													
			form.seu_email.focus();
		} else if (nome_amigo==""){
			$("#resposta").html("Digite o Nome do Amigo.");													
			form.nome_amigo.focus();
		} else if (email_amigo==""){
			$("#resposta").html("Digite o Email do Amigo.");													
			form.email_amigo.focus();
		} else if(!validaEmail(email_amigo)){
			$("#resposta").html("Formato do Email do Amigo Incorreto.");													
			form.email_amigo.focus();
		} else {	
			$.post(path+'scripts/indique.php',$(form).serialize(),function(data){
				$("#resposta").html(data);
				form.reset();
			});
		}		
	}else if(lingua == "en") {
		if (seu_nome==""){
			$("#resposta").html("Enter your Name.");													
			form.seu_nome.focus();
		} else if (seu_email==""){
			$("#resposta").html("Enter your Email.");													
			form.seu_email.focus();
		} else if(!validaEmail(seu_email)){
			$("#resposta").html("Incorrect format of your mail.");													
			form.seu_email.focus();
		} else if (nome_amigo==""){
			$("#resposta").html("Enter your friend's name.");													
			form.nome_amigo.focus();
		} else if (email_amigo==""){
			$("#resposta").html("Enter Friend's Email.");													
			form.email_amigo.focus();
		} else if(!validaEmail(email_amigo)){
			$("#resposta").html("Friend's Email Format Incorrect.");													
			form.email_amigo.focus();
		} else {	
			$.post(path+'scripts/indique.php',$(form).serialize(),function(data){
				$(".form_resposta").html(data);
				form.reset();
			});
		}		
	}else if(lingua == "es") {
		if (seu_nome==""){
			$("#resposta").html("Type o seu Nome.");													
			form.seu_nome.focus();
		} else if (seu_email==""){
			$("#resposta").html("Ingrese su correo electrónico.");													
			form.seu_email.focus();
		} else if(!validaEmail(seu_email)){
			$("#resposta").html("Formato incorrecto de su correo.");													
			form.seu_email.focus();
		} else if (nome_amigo==""){
			$("#resposta").html("Escriba el nombre de su amigo.");													
			form.nome_amigo.focus();
		} else if (email_amigo==""){
			$("#resposta").html("Ingrese correo electrónico del amigo.");													
			form.email_amigo.focus();
		} else if(!validaEmail(email_amigo)){
			$("#resposta").html("Formato de correo electrónico del amigo incorrecta.");													
			form.email_amigo.focus();
		} else {	
			$.post(path+'scripts/indique.php',$(form).serialize(),function(data){
				$("#resposta").html(data);
				form.reset();
			});
		}		
	}
}

