// Copyright 2007 JP7
function refreshDateStyle(f,event){
	if(event=='blur'){
		if(parseInt(f.value)>0||f.value=='00'){
			f.style.color='#000'
			f.style.fontStyle='normal'
		}else{
			f.style.color='#ccc'
			f.style.fontStyle='italic'
			f.value = f.getAttribute('helpvalue');
		}
	}else{
		f.style.color='#000'
		f.style.fontStyle='normal'
		if(parseInt(f.value)>0||f.value=='00'){
	
		}else{
			f.value=''
		}
	}
}

function playPatrocinadores(){
	/* Slide Down #right */
	$(".slider").easySlider({
		vertical: true,
		auto: true,
		continuous: true,
		speed: 2000,
		pause: 4000
	});
}

function validateNewsletterForm (messageNome, messageSobrenome, messageEmail) {
	/* jValidate */
	$('#form_newsletter').validate({	        
        rules: {
            nome: {
                required:  true,
                minlength: 2
            },
			sobrenome: {
                required:  true,
                minlength: 2
            },
			email: {
                required: true,
             	email:    true
            }								
        },	        
        messages: {
            nome:      messageNome,
			sobrenome: messageSobrenome,
			email:     messageEmail	            
        }
    });		
}

function init_login(ola) {
	$.ajax({
		url: '../_ajax/login.php',
		type: 'GET',
		dataType: 'xml',
		timeout: 2000,
		error: function(){
			//alert('Error loading XML document');
			$('#box-naologado').show();
			$('#box-logado').hide();
		},
		success: function(xml) {
			var xml = $(xml);
			if (xml.find('email').text()) {
				$('#box-naologado').hide();
				$('#box-logado').show();
				$('#box-logado #nome-associado').text(ola + xml.find('nome').text());
			} else {
				$('#box-naologado').show();
				$('#box-logado').hide();
			}
		}
	});
}

function init_header_time(text) {
	$.ajax({
		url: '../_ajax/header_time.php',
		type: 'GET',
		dataType: 'html',
		error: function(){
			$('#top-date').hide();
		},
		success: function(text) {
			$('#top-date').html(text);
		}
	});
}

function init_patrocinadores(lang, tipoObjIdTipo) {
	$.ajax({
		url: '../_ajax/patrocinadores.php',
		type: 'GET',
		data: 'lang=' + lang + '&tipoObjIdTipo=' + tipoObjIdTipo,
		success: function(text) {
			$('#right #publicidade-conteudo').html(text);
			$('#right #publicidade-conteudo img').css('border', '1px solid #3896D9');
		},
		error: function(e) {
			$('#right #publicidade').hide();
		}
	});
}

function patrocinadores_click(id, lang) {
	$.ajax({
		url: '../../' + lang + '/_ajax/patrocinadores_click.php',
		type: 'GET',
		data: 'clicked=1&id='+id
	});
}