function substr (f_string, f_start, f_length) {
    // http://kevin.vanzonneveld.net
    // +     original by: Martijn Wieringa
    // +     bugfixed by: T.Wild
    // +      tweaked by: Onno Marsman
    // *       example 1: substr('abcdef', 0, -1);
    // *       returns 1: 'abcde'
    // *       example 2: substr(2, 0, -6);
    // *       returns 2: ''

    f_string += '';

    if (f_start < 0) {
        f_start += f_string.length;
    }

    if (f_length == undefined) {
        f_length = f_string.length;
    } else if (f_length < 0){
        f_length += f_string.length;
    } else {
        f_length += f_start;
    }

    if (f_length < f_start) {
        f_length = f_start;
    }

    return f_string.substring(f_start, f_length);
}

function montreonglet(id)
{
	$('#tplonglets div').hide();
	$('#tplonglets #to'+id).show();
	$('#tplonglets a').attr('class','');
	$('#tplonglets #o'+id+' a').attr('class','active');
	$('#tplonglets li').attr('class','');
	$('#tplonglets #o'+id).attr('class','active');
	return false;
}


$(document).ready(
	function()
	{
		
		
		/*cache le flash*/
		//$('#mp3').hide();
		/* hover de la homepage generale */
		$('#big-squares li.loire ul').hide();
		$('#big-squares li.rhone ul').hide();
		$('#big-squares li.ain ul').hide();

		$("#big-squares li.loire .zone-hover").bind("mouseenter",
			function(e)
			{
				$('#big-squares li.loire ul').show();
				$('#til-hover').hide();
				return false;
			}
		);

		$("#big-squares li.loire .zone-hover").bind("mouseleave",
			function(e)
			{
				$('#big-squares li.loire ul').hide();
				$('#til-hover').show();
				return false;
			}
		);

		$("#big-squares li.rhone .zone-hover").bind("mouseenter",
			function(e)
			{
				$('#big-squares li.rhone ul').show();
				$('#rhone-hover').hide();
				return false;
			}
		);

		$("#big-squares li.rhone .zone-hover").bind("mouseleave",
			function(e)
			{
				$('#big-squares li.rhone ul').hide();
				$('#rhone-hover').show();
				return false;
			}
		);

		$("#big-squares li.ain .zone-hover").bind("mouseenter",
			function(e)
			{
				$('#big-squares li.ain ul').show();
				$('#ain-hover').hide();
				return false;
			}
		);

		$("#big-squares li.ain .zone-hover").bind("mouseleave",
			function(e)
			{
				$('#big-squares li.ain ul').hide();
				$('#ain-hover').show();
				return false;
			}
		);


		/* hover des li du hover de la homepage */
		$("#big-squares li .zone-hover li img").bind("mouseenter",
			function(e)
			{
				var src=$(this).attr('src');
				src=substr(src,6,-4);
				$(this).attr('src','images/'+src+'_hover.gif');
			}
		);
		$("#big-squares li .zone-hover li img").bind("mouseleave",
			function(e)
			{
				var src=$(this).attr('src');
				src=substr(src,6,-10);
				$(this).attr('src','images/'+src+'.gif');
			}
		);

		/* hover de la homepage loire */
		$(".til #horaires ul, .roanne #horaires ul").hide();
		$(".til #tarifs ul, .roanne #tarifs ul").hide();


		$(".til #horaires, .roanne #horaires").bind("mouseenter",
			function(e)
			{
				$(".til #horaires ul, .roanne #horaires ul").show();
				$(".til #tarifs ul, .roanne #tarifs ul").hide();
				$(".til #horaires img, .roanne #horaires img").attr("src","images/menu_7_hover.gif");
			}
		);

		$(".til #horaires, .roanne #horaires").bind("mouseout",
			function(e)
			{

				$(".til #horaires img, .roanne #horaires img").attr("src","images/menu_7.gif");
			}
		);



		$(".til #tarifs, .roanne #tarifs").bind("mouseenter",
			function(e)
			{
				$(".til #horaires u, .roanne #horaires ul").hide();
				$(".til #tarifs ul, .roanne #tarifs ul").show();
				$(".til #tarifs img, .roanne #tarifs img").attr("src","images/menu_8_hover.gif");
			}
		);

		$(".til #tarifs, .roanne #tarifs").bind("mouseout",
			function(e)
			{

				$(".til #tarifs img, .roanne #tarifs img").attr("src","images/menu_8.gif");
			}
		);


		$(".til #liens, .roanne #liens").bind("mouseenter",
			function(e)
			{
				$(".til #horaires ul, roanne #horaires ul").hide();
				$(".til #tarifs ul, .roanne #tarifs ul").hide();
				$(".til #liens img, .roanne #liens img").attr("src","images/menu_10_hover.gif");
			}
		);

		$(".til #liens, .roanne #liens").bind("mouseout",
			function(e)
			{

				$(".til #liens img, .roanne #liens img").attr("src","images/menu_10.gif");
			}
		);



		$(".til #conseils, .roanne #conseils").bind("mouseenter",
			function(e)
			{
				$(".til #horaires ul, .roanne #horaires ul").hide();
				$(".til #tarifs ul, .roanne #tarifs ul").hide();
				$(".til #conseils img, .roanne #conseils img").attr("src","images/menu_9_hover.gif");
			}
		);

		$(".til #conseils, .roanne #conseils").bind("mouseout",
			function(e)
			{
				$(".til #conseils img, .roanne #conseils img").attr("src","images/menu_9.gif");
			}
		);


		/* onglets de maniere generale */
		$('#tplonglets #to2').hide();
		$('#tplonglets #to3').hide();
		$('#tplonglets #o1 a').attr('class','active');
		$('#tplonglets #o1').attr('class','active');

		$('#tplonglets #o1 a').bind('click',function(){return(montreonglet(1))});
		$('#tplonglets #o2 a').bind('click',function(){return(montreonglet(2))});
		$('#tplonglets #o3 a').bind('click',function(){return(montreonglet(3))});

		}


);




