// CEFOLGEST FUNCTIONS

	function headlines_rotator(){
		change_headline('next',0);
	}
	
	//CHANGE HEADLINES WITH FADE
	current_headline = 0;
	function change_headline(action,order){
		
		if(order == 1){ clearInterval(rotator);}
		
		if(action == 'prev'){
			if(current_headline != 0){
				current_headline--;
				$('#headline_img').fadeOut('fast', function() { 
					load_picture();
					document.getElementById('headline_link').href = headlines_links[current_headline];
				});
			}else{
				current_headline = headlines_count - 1;
				$('#headline_img').fadeOut('fast', function() { 
					load_picture();
					document.getElementById('headline_link').href = headlines_links[current_headline];
				});
			}	
		}else if(action == 'next'){
			if(current_headline < headlines_count - 1 ){
				current_headline++;
				$('#headline_img').fadeOut('fast', function() { 
					load_picture();
					document.getElementById('headline_link').href = headlines_links[current_headline];
				});
			}else{
				current_headline = 0;
				$('#headline_img').fadeOut('fast', function() { 
					load_picture();
					document.getElementById('headline_link').href = headlines_links[current_headline];
				});
			}	
		}
	}
	
	//TRY TO LOAD PICTURE
	function load_picture(){
		tempimage = new Image ;
		tempimage.src = "images/user/" + headlines_pics[current_headline] ;
		timer = setTimeout( 'loading()', 100 ) ;
	}
	
	//CHANGE HEADLINE WHEN PICTURE IS LOADED
	function loading(){
		if(tempimage.complete ){ 
			document.getElementById('headline_img').src = "images/user/" + headlines_pics[current_headline];	
			$('#headline_img').fadeIn('fast', function() { });
			clearTimeout(timer);
		}else{
			timer = setTimeout( 'loading()', 100 ) ;	
		}
	}

	
	//SHOW DIV
	function show(div){
		if(document.getElementById(div).style.display == 'none'){
			document.getElementById(div).style.display = 'block';
		}else{
			document.getElementById(div).style.display = 'none';
		}
	}
	
	
	//SUBMIT NEWSLETTER
	function submit_newsletter(){
		if( document.getElementById("newsletter_name").value != '' && document.getElementById("newsletter_email").value != ''){
			if( document.getElementById("newsletter_email").value.indexOf("@") != -1 && document.getElementById("newsletter_email").value.indexOf(".") != -1){
				document.newsletter_form.submit();
			}else{
				alert("E-mail inválido.");
			}
		}else{
			alert("Por favor preencha todos os campos.");
		}		
	}
	
	//Submit FORM
	missing = 0;
	function submit_form(){
		for(i=1;i<8;i++){
			if(document.getElementById("input"+i).value == ''){
				missing = 1;	
			}
		}	
		if(missing == 1){
			alert("Por favor preencha todos os campos assinalados com *");
			missing = 0;
		}else{
			document.class_form_data.submit();	
		}
	}
	
	function close_home_box(){
		$('#box_content').fadeOut('fast', function() {});		
		$('#box_background').fadeOut('fast', function() {});
	}
	
