// JavaScript Document



var send_mail = function(form,request){
	
	form = typeof(form) != 'undefined' ? form : "";
	request = typeof(request) != 'undefined' ? request : "";
	
	$.post(request,$(form).serialize()+"&form="+form,function(data){
		
		if(data.response=='Message sent' && typeof(data.response)!='undefined'){
			
			$(form+' :input').attr("value","");
			$('#message').text(data.response);
			//window.location.reload(true);
		
		}else if(data.response!='success' && typeof(data.response)!='undefined'){
			$('#message').text(data.response);
			
		}
		
	},'json');
	
	return false;
	
}



//===================================================//
//	start of NEWS TICKER
//==================================================//
var ticker_timer = null;
var ticker_selected = 0;

var show_ticker = function(index){
	clearTimeout(ticker_timer);
	for(i=0; i<3 ; i++){
		if(i!=index){//If it's not the selected one, hide it
			$('#latest_news .ticker:eq('+i+')').hide();
		}
	}
	$('#latest_news .ticker:eq('+index+')').fadeIn('slow');
	ticker_selected = index;
	ticker_timer = setTimeout(next_ticker, 5000);
}
 
var next_ticker = function(){
	var next_index = ticker_selected+1;//The next index
	if(next_index>2){next_index=0;}//If it's bigger, reset
	show_ticker(next_index);//Show the next headline
}

var set_news_ticker = function(){
	ticker_timer = setTimeout(next_ticker, 5000);//Set the timer
	show_ticker(0)//Show the first one
}
//===================================================//
//	end of NEWS TICKER
//==================================================//



$(document).ready(function(){});





