// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
var page_nb = 1
var slideshow


var max_pages_slideshow = 0

var slide_time = 5000

var menu_timer = null


function open_close_option_block(obj_link, model, block_id)
{
	block = $(block_id);
	
	if(block.visible())
	{
		block.hide();
		obj_link.style.background = "url('images/option_block_btn_open_"+model+".gif') center right no-repeat"
	}
	else
	{
		block.show();
		obj_link.style.background = "url('images/option_block_btn_close_"+model+".gif') center right no-repeat"
	}
	
}

function change_page(max_pages, direction)
{
	if($("picture_"+page_nb+"_content"))
		$("picture_"+page_nb+"_content").hide();
	
	page_nb = page_nb + direction ;
	
	if(page_nb < 1)
	{
		page_nb = max_pages
	}
	
	if(page_nb > max_pages)
	{
		page_nb = 1
	}
	
	if($("picture_"+page_nb+"_content"))
		$("picture_"+page_nb+"_content").show();
	
	margin_left = (page_nb-1) * 453
	
	$('page_nb').innerHTML = page_nb
	
	new Effect.Morph('project_slideshow_image', {style:'margin-left:-'+margin_left+'px'})

}

function start_slideshow()
{
	slideshow = setInterval("change_page(max_pages_slideshow, 1)", slide_time)
}

function stop_slideshow()
{
	clearInterval(slideshow)
}



function hover_menu(section_id)
{
	clearInterval(menu_timer)
	show_menu(section_id)
}

function out_menu()
{
	menu_timer = setTimeout("hide_menu()", 500)
}

function show_menu(section_id)
{
	$('menu_top_secondary').show();
	$('menu_top_'+section_id).show();
}

function hide_menu()
{
	$('menu_top_secondary').hide();
	$$('.menu_top_child').each(function(menu_block){menu_block.hide();})
}

function display_client_login()
{
	$('home_coor').toggle();
	$('client_login').toggle();
}

function observe_menu()
{	
	$('menu_top_secondary').observe('mouseover', function(event){
		clearInterval(menu_timer)
	 });
	$('menu_top_secondary').observe('mouseout', function(event){
		out_menu()
	 });
}