new Event.observe(window, 'load', onBodyLoad, false);

var starempty = 'images/main/star2.jpg';
var starfull = 'images/main/star1.jpg';
var currentstar = 0;

function onBodyLoad()
{
	if($('frmaddfiche') != null)
	{
		Event.observe($('rubrique'), 'change', maj_sousrubrique, false);
		if($F('sousrubrique') == '')
			$('sousrubrique').options.length = 1;
		Event.observe($('sousrubrique'), 'change', maj_form_add_fiche, false);
		maj_sousrubrique($F('sousrubrique'));
		maj_form_add_fiche();
	}
	if($('starcreetic') != null)
	{
		if($F('notecreetic') != '')
			currentstar = $F('notecreetic');

		$$('#starcreetic a').each
		(
			function(link, index)
			{
				link.observe('click', function(event){starclicked(event, link, index + 1);});
				link.observe('mouseover', function(event){changeStar(index + 1);});
				link.observe('mouseout', function(event){changeStar(currentstar);});
			}
		)
	}
	if($$('.deletefriend').length > 0)
	{
		$$('.deletefriend').each
		(
			function(link)
			{
				link.observe('click', function(event){deletefriend(event, link);});
			}
		)
	}
	if($$('.demand').length > 0)
	{
		$$('.demand a').each
		(
			function(link)
			{
				link.observe('click', function(event){execlink(event, link.href, link.up('.demand'));});
			}
		)
	}
	if($$('.message').length > 0 && $('thread') == null)
	{
		$$('a [class^=link_]').each
		(
			function(link)
			{
				link.observe('click', function(event){execlink(event, link.href, link.up('.message'));});
			}
		)
	}
	if($('thread') != null)
	{
		max = $('thread').className.split('to_');
		max = max[1];
		new Effect.ScrollTo($('message_' + max), {duration:1});
	}
	if($('add_friend') != null)
	{
		$('add_friend').observe('click', function(event){add_friend(event);});
	}
	if($('remove_friend') != null)
	{
		$('remove_friend').observe('click', function(event){remove_friend(event);});
	}
	if($('acceptfriend') != null)
	{
		$('acceptfriend').observe('click', function(event){accept_friend(event);});
	}
	if($('refusfriend') != null)
	{
		$('refusfriend').observe('click', function(event){refus_friend(event);});
	}
	if($('blocked') != null)
	{
		$('blocked').observe('click', function(event){block_unblock_friend(event, 'blocked');});
	}
	if($('unblock') != null)
	{
		$('unblock').observe('click', function(event){block_unblock_friend(event, 'unblock');});
	}
}

function block_unblock_friend(event, action)
{
	Event.stop(event);
	if($(action).title != '')
	{
		var answer = confirm($(action).title);
		if(answer)
		{
			new Ajax.Request
			(
				$(action).href,
				{
					onSuccess: function(transport, json)
					{
						window.location.reload();
					}
				}
			);
		}
	}
}

function refus_friend(event)
{
	Event.stop(event);
	if($('refusfriend').title != '')
	{
		var answer = confirm($('refusfriend').title);
		if(answer)
		{
			new Ajax.Request
			(
				$('refusfriend').href,
				{
					onSuccess: function(transport, json)
					{
						$('action_friend').innerHTML = replaceFirstWordToLink(json.text, json.link, json.title, 'add_friend');
						$('add_friend').observe('click', function(event){add_friend(event);});
					}
				}
			);
		}
	}
}

function createlink(text, link, title, id)
{
	text = '<a href="' + link + '" title="' + title + '" id="' + id + '">' + text + '</a>';
	return text;
}

function accept_friend(event)
{
	Event.stop(event);
	if($('acceptfriend').title != '')
	{
		var answer = confirm($('acceptfriend').title);
		if(answer)
		{
			new Ajax.Request
			(
				$('acceptfriend').href,
				{
					onSuccess: function(transport, json)
					{
						$('action_friend').innerHTML = replaceFirstWordToLink(json.text, json.link, json.title, 'remove_friend');
						$('remove_friend').observe('click', function(event){remove_friend(event);});
					}
				}
			);
		}
	}
}

function add_friend(event)
{
    try {
	Event.stop(event);
    }
    catch (ex) {}

	var answer = confirm($('add_friend').title);
	if(answer)
	{
		new Ajax.Request
		(
			$('add_friend').href,
			{
				onSuccess: function(transport, json)
				{
					$('action_friend').innerHTML = '<strong>' + json.text + '</strong>';
					alert(json.message);
				}
			}
		);
	}
}

function add_public_friend(elt)
{
	var answer = confirm(elt.title);
	if(answer)
	{
		new Ajax.Request
		(
			elt.href,
			{
				onSuccess: function(transport, json)
				{
					elt.innerHTML = '<strong>' + json.text + '</strong>';
				}
			}
		);
	}
    return false;
}

function email_public_send(elt)
{
	new Ajax.Request
	(
		'send-message-public.html',
		{
			method: 'post',
			postBody: 'id='+$(elt+'_id').value+'&sub='+$(elt+'_subject').value+'&cnt='+$(elt+'_content').value,
			onComplete: function(transport, json)
			{
              alert( json.message);
              if (json.error == 0)
              {
                $(elt+'_subject').value = $(elt+'_content').value = '';
			    dspclass(elt);
              }
			}
		}
	);

    return false;
}

function remove_friend(event)
{
	Event.stop(event);
	var answer = confirm($('remove_friend').title);
	if(answer)
	{
		new Ajax.Request
		(
			$('remove_friend').href,
			{
				onSuccess: function(transport, json)
				{
					alert(json.link);
					$('action_friend').innerHTML = replaceFirstWordToLink(json.text, json.link, json.title, 'add_friend');
					$('add_friend').observe('click', function(event){add_friend(event);});
					alert(json.message);
				}
			}
		);
	}
}

function replaceFirstWordToLink(text, link, title, id)
{
	space = text.split(' ');
	word = space[0];
	re = new RegExp(word);;
	re.exec(text);
	text = text.replace(re, '<a href="' + link + '" title="' + title + '" id="' + id + '">' + word + '</a>');
	return text;
}

function execlink(event, href, element)
{
	Event.stop(event);
	new Ajax.Request
	(
		href,
		{
			onComplete: function(transport)
			{
				element.hide();
			}
		}
	);
}

function deletefriend(event, friend)
{
	Event.stop(event);
	new Ajax.Request
	(
		'./supprimer-' + friend.identify() + '-de-ma-liste-amis.html',
		{
			onComplete: function(transport)
			{
				$('friend_' + friend.identify()).hide();
				$$('.pagination-digrs p').each
				(
					function(p)
					{
						content = p.innerHTML.split(' ')
						i = parseInt(content[0]);
						if(i > 0)
							i--;
						p.innerHTML = i + ' ' +content[1];
					}
				)
			}
		}
	);
}

function starclicked(event, link, star)
{
	Event.stop(event);
	changeStar(star);
	currentstar = star;
	$('notecreetic').value = star;
	return false;
}

function changeStar(max)
{
	$$('#starcreetic a').each
	(
		function(link, index)
		{
			img = link.childElements();

			if((index + 1) <= max)
				img[0].src = starfull;
			else
				img[0].src = starempty;
		}
	)
}

function maj_sousrubrique(sousrubrique)
{
	new Ajax.Request
	(
		'./display/sous-rubrique',
		{
			method: 'post',
			postBody: 'rubrique='+$F('rubrique'),
			onComplete: function(transport, json)
			{
				$('sousrubrique').options.length = 0;
				json.each
				(
					function(category, index)
					{
						if(sousrubrique == category.id)
							$('sousrubrique')[index] = new Option(category.name, category.id, true, true);
						else
							$('sousrubrique')[index] = new Option(category.name, category.id);
					}
				);
			}
		}
	);
}

function sendusefull(id)
{
    new Ajax.Request(
		'useful-creetic-'+id+'.html',
		{
			method: 'post',
			onSuccess: function( transport)
            {
            re = /(\()([0-9]+)(\))/; str = $('ut_'+id).innerHTML;re.exec(str); nb = parseInt(RegExp.$2); nb++; $('ut_'+id).innerHTML = str.replace(re, '(' + nb + ')');
            }
		}
	);
}

//@207
function sendwellwritten(id)
{
    new Ajax.Request(
		'written-well-creetic-'+id+'.html',
		{
			method: 'post',
			onSuccess: function( transport)
            {
            re = /(\()([0-9]+)(\))/; str = $('be_'+id).innerHTML;re.exec(str); nb = parseInt(RegExp.$2); nb++; $('be_'+id).innerHTML = str.replace(re, '(' + nb + ')');
            }
		}
	);
}


function maj_form_add_fiche()
{
	$$('.temporaire').each
	(
		function(temp)
		{
			if($F('sousrubrique') == 60 || $F('sousrubrique') == 61 || $F('sousrubrique') == 66)
				Element.hide(temp);
			else
				Element.show(temp);
		}
	)
}

function ajaxDecouvrir( item)
{
	new Ajax.Request(
		'./display/decouvrir.html',
		{
			method: 'post',
			postBody: 'item='+item,
			onSuccess: function( transport)
			{
                $('boxAjaxDecouvrir'+item).innerHTML = transport.responseText;
			}
		}
	);
}


function displayCarrousel(menu, it, currentid)
{
	var important = "";
    var current = 'link_menu_carrousel_'+currentid;

	if(navigator.appName != "Microsoft Internet Explorer")
		important = " !important";

	for(var i = 0; i <= it; i++)
	{
		if( $('menu_carrousel_' + i) != null )
		{
			$('menu_carrousel_' + i).style.display = 'none';
		}
	}

	if( $('menu_carrousel_' + menu) != null )
	{
		$('menu_carrousel_' + menu).style.display = 'block';
	}
}

function boxInitCarrousel(idRub, idSousRub,max)
{
	new Ajax.Request(
		   './display/carrousel',
		   {
			   method: 'post',
			   postBody: 'ajax=3&idRub='+idRub+'&idSousRub='+idSousRub+'&max='+max,
			   onSuccess: function( transport)
			   {
				   $('car_but').innerHTML = transport.responseText;
			   }
		   }
   );
}

function boxBookMark()
{
	new Ajax.Request(
			 './display/bookmark',
		   {
			   method: 'post',
			   onSuccess: function( transport)
			   {
				   $('bookmark').innerHTML = transport.responseText;
			   }
		   }
   );
}

function initCarrousel(idRub, idSousRub,max)
{
boxInitCarrousel(idRub, idSousRub,max);

/*
	for( var i = 0; i < 8; i++)
	{
        try {
            dspn('link_menu_carrousel_'+i);
        }
        catch (ex)
        {
        }
	}
*/
displayCarrousel(0, 7, $('link_menu_carrousel_0'));
}

function boxCarrouselSimple(idRub, idSousRub, idCritRub, i, id, table,z)
{
//@205
    new Ajax.Request(
           './display/carrouselsimple',
           {
               method: 'post',
               postBody: 'ajax=2&idRub='+idRub+'&idSousRub='+idSousRub+'&idCritRub='+idCritRub+'&i='+i+'&id='+id+'&table='+table+'&z='+z,
               onSuccess: function( transport)
               {
                   $('boxcar_0').innerHTML = transport.responseText;
               }
           }
   );
   return false;
}

function boxCarrousel(idRub, idSousRub, i, id, table,z)
{
	new Ajax.Request(
		   './display/carrousel',
		   {
			   method: 'post',
			   postBody: 'ajax=2&idRub='+idRub+'&idSousRub='+idSousRub+'&i='+i+'&id='+id+'&table='+table+'&z='+z,
			   onSuccess: function( transport)
			   {
				   $('boxcar_'+i).innerHTML = transport.responseText;
                   closeRedact();
                   setCurrentOngletCarrousel( 'link_menu_carrousel_'+i);
    		   }
           }
   );
   return false;
}

function boxGlobalCarrousel(idRub, idSousRub)
{
	new Ajax.Request(
		   './display/bigcarrousel',
		   {
			   method: 'post',
			   postBody: 'ajax=99&idRub='+idRub+'&idSousRub='+idSousRub,
			   onSuccess: function( transport)
			   {
				   $('bcarrousel').innerHTML = transport.responseText;
                   displayCarrousel(0,20,'link_menu_carrousel_0');
			   }
		   }
   );
   return false;
}

function boxPub(pub, idRub, idSousRub)
{
    new Ajax.Request(
	    './display/publicite',
		{
            method: 'post',
    	    postBody: 'pub='+pub+'&idRub='+idRub+'&idSousRub='+idSousRub,
    	    onSuccess: function( transport)
    	    {
			    if($('boxAjaxPub'+pub) != null)
        	    $('boxAjaxPub'+pub).innerHTML = transport.responseText;
          	}
	   }
   );
}

function boxSearch(idRub, idSousRub)
{
	new Ajax.Request(
			 './display/filters-search',
		   {
			   method: 'post',
			   postBody: 'ajax=1&idRub='+idRub+'&idSousRub='+idSousRub,
			   onSuccess: function( transport)
			   {
				   $('boxAjaxSearch').innerHTML = transport.responseText;
			   }
		   }
   );
}

function boxUsers(idRub)
{
	new Ajax.Request(
		   './display/liste-users',
		   {
			   method: 'post',
			   postBody: 'ajax=1&idRub='+idRub,
			   onSuccess: function( transport)
			   {
				   $('boxAjaxUsers').innerHTML = transport.responseText;
			   }
		   }
   );
}


function newVideo(deb)
{
	new Ajax.Request(
			 './display/video',
		   {
			   method: 'post',
			   postBody: 'deb='+deb,
			   onSuccess: function( transport)
			   {
				   $('boxAjaxVideo').innerHTML = transport.responseText;
				   new Effect.Appear('boxAjaxVideo', {duration:0.3, fps:25, from:0.0, to:1.0});
			   }
		   }
   );
}

function locktheweb()
{
alert('Copyright© 2008 http://www.creetic.com');
return false;
}

function toto()
{
	alert( 'test');
}

function EnterKey(e)
{
	 var key;
	 if(window.event)
		  key = window.event.keyCode;     //IE
	 else
		  key = e.which;     //firefox

	 if(key == 13)
	 {
		var truePass = document.getElementById( 'passwordForHidden').value;
		
		document.getElementById( 'password').value = truePass;
		connexion.submit();
		return false;
	 }
}


function submitformnewletter()
    {
    if  (document.sub_form.email_addr.value=='')
  	    alert("Cette adresse électronique n'est pas valide");
	else {
		if ( ((document.sub_form.email_addr.value.indexOf('@',1))==-1)||(document.sub_form.email_addr.value.indexOf('.',1))==-1 )
			alert("Cette adresse électronique n'est pas valide");
    	else {
          window.open("", "formPopup", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=200,width=500,toolbar=no", true);
          document.sub_form.target='formPopup';
          document.sub_form.submit();
          }
  		}
    }

   function ScaleEffect(element){
   new Effect.Scale(element,
       {duration:2, from:0, to:1.0});
   }

   function ShowEffect(element){
       new Effect.Appear(element,
       {duration:2, from:0, to:1.0});
   }
   function BlindDownEffect(element){
       new Effect.BlindDown(element,
       {duration:2, from:0, to:1.0});
   }
   function HideEffect(element){
       new Effect.Appear(element,
       {duration:2, from:1.0, to:0});
   }

//@1 FUSION
function thematiquechange(idTheme)
{
var xhr_object = getXMLHTTP();
if (xhr_object == null) return;

labelbox = 'themeC2';

xhr_object.open("GET",'./'+'./plugin/inc.details_creasondagesoustheme.php?idTheme='+idTheme+'&rand='+Math.random(), true);
xhr_object.onreadystatechange=function()
    {
    if( xhr_object.readyState == 4)
	    {
        var box = document.getElementById('themeC2');

	    Message = xhr_object.responseText;
	    if( Message != '')
	        {
	        box.innerHTML = Message;
		    }
		}
	}
xhr_object.send(null);
//	location.replace('./'+From);
// on sort avant de passer à ready state
}



function getXMLHTTP()
{
	var xhr=null;
	if(window.XMLHttpRequest) // Firefox et autres
	{
		xhr = new XMLHttpRequest();
	}
	else
		if(window.ActiveXObject)
		{ // Internet Explorer
			try
			{
				xhr = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					xhr = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e1)
				{
					xhr = null;
				}
			}
		}
		else
		{ // XMLHttpRequest non supporté par le navigateur
			alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		}
	if (xhr == null)
			alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
	return xhr;
}

function Show_content6()
{

	document.resrvat.submit();
}
function Show_content5()
{

	document.crervide.submit();
}
function showdetail(x)
{

	document.getElementById('affiche'+x).style.display = "";


}
function afficher(x)
{

	document.getElementById('affiche'+x).style.display = "none";
	document.updatetab.hiden_update.value = x;
	document.getElementById('hiden_id').value = document.getElementById('hidden_id'+x).value;

	document.getElementById('hiden_avis').value = document.getElementById('avis'+x).value;
	document.getElementById('idusers').value = document.getElementById('idusers'+x).value;
	//alert(document.getElementById('idusers').value);
	document.getElementById('updatetab').submit();


}


function showform(x)
{
	switch(x)
	{
		case 1 :
		document.getElementById('etoile').innerHTML='<a onclick="showform(1);"><img src="images/main/star1.png"></a><a  onclick="showform(2);"><img src="images/main/star2.png"></a><a  onclick="showform(3);"><img src="images/main/star2.png"></a><a  onclick="showform(4);"><img src="images/main/star2.png"></a><a  onclick="showform(5);"><img src="images/main/star2.png"></a></b></span>';
	  break;
		case 2 :
		 document.getElementById('etoile').innerHTML='<a  onclick="showform(1);"><img src="images/main/star1.png"></a><a  onclick="showform(2);"><img src="images/main/star1.png"></a><a  onclick="showform(3);"><img src="images/main/star2.png"></a><a  onclick="showform(4);"><img src="images/main/star2.png"></a><a  onclick="showform(5);"><img src="images/main/star2.png"></a>';
	  break;
		case 3 :
		 document.getElementById('etoile').innerHTML='<a  onclick="showform(1);"><img src="images/main/star1.png"></a><a  onclick="showform(2);"><img src="images/main/star1.png"></a><a  onclick="showform(3);"><img src="images/main/star1.png"></a><a  onclick="showform(4);"><img src="images/main/star2.png"></a><a  onclick="showform(5);"><img src="images/main/star2.png"></a>';
	  break;
		case 4 :
		 document.getElementById('etoile').innerHTML='<a  onclick="showform(1);"><img src="images/main/star1.png"></a><a  onclick="showform(2);"><img src="images/main/star1.png"></a><a  onclick="showform(3);"><img src="images/main/star1.png"></a><a  onclick="showform(4);"><img src="images/main/star1.png"></a><a  onclick="showform(5);"><img src="images/main/star2.png"></a>';
	  break;
		 case 5 :
		  document.getElementById('etoile').innerHTML='<a  onclick="showform(1);"><img src="images/main/star1.png"></a><a  onclick="showform(2);"><img src="images/main/star1.png"></a><a  onclick="showform(3);"><img src="images/main/star1.png"></a><a  onclick="showform(4);"><img src="images/main/star1.png"></a><a  onclick="showform(5);"><img src="images/main/star1.png"></a>';
	  break;
	}
	document.getElementById( "note").value = x;
}

function upStar( nbStar)
{
	switch( nbStar)
	{
		case 1:
			document.getElementById( "starId1").src = "css/images/pictos/star.gif";
			document.getElementById( "starId2").src =
			document.getElementById( "starId3").src =
			document.getElementById( "starId4").src =
			document.getElementById( "starId5").src = "css/images/pictos/star_empty.gif";
			document.getElementById( "textRating").innerHTML = "M&eacute;diocre";
			//document.getElementById( "note").value = 1;
			break;
		case 2:
			document.getElementById( "starId1").src =
			document.getElementById( "starId2").src = "css/images/pictos/star.gif";
			document.getElementById( "starId3").src =
			document.getElementById( "starId4").src =
			document.getElementById( "starId5").src = "css/images/pictos/star_empty.gif";
			document.getElementById( "textRating").innerHTML = "Moyen";
			//document.getElementById( "note").value = 2;
			break;
		case 3:
			document.getElementById( "starId1").src =
			document.getElementById( "starId2").src =
			document.getElementById( "starId3").src = "css/images/pictos/star.gif";
			document.getElementById( "starId4").src =
			document.getElementById( "starId5").src = "css/images/pictos/star_empty.gif";
			document.getElementById( "textRating").innerHTML = "Bien";
			//document.getElementById( "note").value = 3;
			break;
		case 4:
			document.getElementById( "starId1").src =
			document.getElementById( "starId2").src =
			document.getElementById( "starId3").src =
			document.getElementById( "starId4").src = "css/images/pictos/star.gif";
			document.getElementById( "starId5").src = "css/images/pictos/star_empty.gif";
			document.getElementById( "textRating").innerHTML = "Tr&egrave;s bien";
			//document.getElementById( "note").value = 4;
			break;
		case 5:
			document.getElementById( "starId1").src =
			document.getElementById( "starId2").src =
			document.getElementById( "starId3").src =
			document.getElementById( "starId4").src =
			document.getElementById( "starId5").src = "css/images/pictos/star.gif";
			document.getElementById( "textRating").innerHTML = "Excellent";
			//document.getElementById( "note").value = 5;
			break;
	}
}

function downStar()
{
	var nbStar = 0;
	nbStar = document.getElementById( "note").value;
	switch( parseInt( nbStar))
	{
		case 0:
			document.getElementById( "starId1").src =
			document.getElementById( "starId2").src =
			document.getElementById( "starId3").src =
			document.getElementById( "starId4").src =
			document.getElementById( "starId5").src = "css/images/pictos/star_empty.gif";
			document.getElementById( "textRating").innerHTML = "&nbsp;";
			break;
		case 1:
			document.getElementById( "starId1").src = "css/images/pictos/star.gif";
			document.getElementById( "starId2").src =
			document.getElementById( "starId3").src =
			document.getElementById( "starId4").src =
			document.getElementById( "starId5").src = "css/images/pictos/star_empty.gif";
			document.getElementById( "textRating").innerHTML = "M&eacute;diocre";
			//document.getElementById( "note").value = 1;
			break;
		case 2:
			document.getElementById( "starId1").src =
			document.getElementById( "starId2").src = "css/images/pictos/star.gif";
			document.getElementById( "starId3").src =
			document.getElementById( "starId4").src =
			document.getElementById( "starId5").src = "css/images/pictos/star_empty.gif";
			document.getElementById( "textRating").innerHTML = "Moyen";
			//document.getElementById( "note").value = 2;
			break;
		case 3:
			document.getElementById( "starId1").src =
			document.getElementById( "starId2").src =
			document.getElementById( "starId3").src = "css/images/pictos/star.gif";
			document.getElementById( "starId4").src =
			document.getElementById( "starId5").src = "css/images/pictos/star_empty.gif";
			document.getElementById( "textRating").innerHTML = "Bien";
			//document.getElementById( "note").value = 3;
			break;
		case 4:
			document.getElementById( "starId1").src =
			document.getElementById( "starId2").src =
			document.getElementById( "starId3").src =
			document.getElementById( "starId4").src = "css/images/pictos/star.gif";
			document.getElementById( "starId5").src = "css/images/pictos/star_empty.gif";
			document.getElementById( "textRating").innerHTML = "Tr&egrave;s bien";
			//document.getElementById( "note").value = 4;
			break;
		case 5:
			document.getElementById( "starId1").src =
			document.getElementById( "starId2").src =
			document.getElementById( "starId3").src =
			document.getElementById( "starId4").src =
			document.getElementById( "starId5").src = "css/images/pictos/star.gif";
			document.getElementById( "textRating").innerHTML = "Excellent";
			//document.getElementById( "note").value = 5;
			break;
		default:
			document.getElementById( "starId1").src =
			document.getElementById( "starId2").src =
			document.getElementById( "starId3").src =
			document.getElementById( "starId4").src =
			document.getElementById( "starId5").src = "css/images/pictos/star_empty.gif"
			document.getElementById( "textRating").innerHTML = "&nbsp;";
			break;
	}
}
function validStar( nbStar)
{
	switch( nbStar)
	{
		case 1:
			document.getElementById( "starId1").src = "css/images/pictos/star.gif";
			document.getElementById( "starId2").src =
			document.getElementById( "starId3").src =
			document.getElementById( "starId4").src =
			document.getElementById( "starId5").src = "css/images/pictos/star_empty.gif";
			document.getElementById( "textRating").innerHTML = "M&eacute;diocre";
			document.getElementById( "note").value = 1;
			break;
		case 2:
			document.getElementById( "starId1").src =
			document.getElementById( "starId2").src = "css/images/pictos/star.gif";
			document.getElementById( "starId3").src =
			document.getElementById( "starId4").src =
			document.getElementById( "starId5").src = "css/images/pictos/star_empty.gif";
			document.getElementById( "textRating").innerHTML = "Moyen";
			document.getElementById( "note").value = 2;
			break;
		case 3:
			document.getElementById( "starId1").src =
			document.getElementById( "starId2").src =
			document.getElementById( "starId3").src = "css/images/pictos/star.gif";
			document.getElementById( "starId4").src =
			document.getElementById( "starId5").src = "css/images/pictos/star_empty.gif";
			document.getElementById( "textRating").innerHTML = "Bien";
			document.getElementById( "note").value = 3;
			break;
		case 4:
			document.getElementById( "starId1").src =
			document.getElementById( "starId2").src =
			document.getElementById( "starId3").src =
			document.getElementById( "starId4").src = "css/images/pictos/star.gif";
			document.getElementById( "starId5").src = "css/images/pictos/star_empty.gif";
			document.getElementById( "textRating").innerHTML = "Tr&egrave;s bien";
			document.getElementById( "note").value = 4;
			break;
		case 5:
			document.getElementById( "starId1").src =
			document.getElementById( "starId2").src =
			document.getElementById( "starId3").src =
			document.getElementById( "starId4").src =
			document.getElementById( "starId5").src = "css/images/pictos/star.gif";
			document.getElementById( "textRating").innerHTML = "Excellent";
			document.getElementById( "note").value = 5;
			break;
	}
	document.getElementById( "but_crit").show();

}

function dspn(iddiv)
{
    try {
	$(iddiv).style.display="none";
    }
    catch (ex)
    {
    }
}


function dspclass(iddiv)
{
    try {
        var tag = $(iddiv).className;
        found = false;
        if (tag)
        {
            var classes = tag.split(" ");
            for (var cn = 0; cn < classes.length; cn++)
            {
                var cName = classes[cn];
                if (cName == 'displayN')
                {
                $(iddiv).removeClassName("displayN")
                found = true;
                break;
                }
            }
        }
        if (!found)
            $(iddiv).addClassName("displayN")
    }
    catch (ex)
    {
    }
    return false;
}

function cdspn(iddiv)
{
    try {
    Effect.Shrink(iddiv);
    }
    catch (ex)
    {
    }
}

function cdspy(iddiv)
{
  /*
  onmouseover="cdspy('ocar{$ecar.item}')" onmouseout="cdspn('ocar{$ecar.item}')"
  */
    try {
//	$(iddiv).style.display="";
//    new Effect.Appear(iddiv, {duration:0.3, fps:25, from:0.0, to:1.0});
    Effect.Grow(iddiv);
    }
    catch (ex)
    {
    }
}

// Ancien plugin
function PlugIn(current)
{
for(i=1; i < 100; i++)
    {
    try {
        $('plug'+i).style.display = 'none';
        }
    catch (ex) {}
    }
if (current != 0)
{
    if (current == 25)
        displayresatickenet()
    else $('plug'+current).style.display = 'block';
}
return false;
}
function initPlugin()
{
var i = location.href.lastIndexOf('#');
num = 1;
if (i > 0)
    {
    num = location.href.substr(i+1,3);
    PlugIn(num);
    }
else PlugIn(num);
return num;
}



hPresent = 0;
function presOffsetInt(labelbut, langue)
{
try {
var h = $('pres').offsetHeight;
if (h > 212 && hPresent == 0)
    {
    $('pres').style.height = '212px';
    hPresent = h;
//    $(labelbut).setAttribute("src", "css/images/bouton/button_pres_down.gif");
//    alert('es');
    $(labelbut).setAttribute("src", "css/images/bouton/suite_pres"+langue+".png");
    }
else if (hPresent != 0)
    {
    $('pres').style.height = hPresent+'px';
    hPresent = 0;
//    $(labelbut).setAttribute("src", "css/images/bouton/button_pres_up.gif");
    $(labelbut).setAttribute("src", "css/images/bouton/fermer_pres"+langue+".png");
    }
    else {
    $(labelbut).hide();
    }
    }
catch (ex)
{}
}

function presOffset(langue)
{
presOffsetInt('presbut', langue)
}
function presOffsetAvis()
{
presOffsetInt('presbutavis', thelangue)
}

function initPlugToogle(incritiq)
{
    // Display none sur certain onglet
for (o=0; o < 100; o++)
{
    try {
        var tag = $('details_'+o).className;
        if (tag)
        {
            var classes = tag.split(" ");
            for (var cn = 0; cn < classes.length; cn++)
            {
            var cName = classes[cn];
            if (cName == 'onglet_none') dspn('details_'+o);
            }
        }
    }
    catch (ex) {}
}

var d = location.href.lastIndexOf('#');

ifirst = ilast = 1;
var allTags = $('onglets').getElementsByTagName('*');
for (var tg = 0; tg< allTags.length; tg++)
{
    var tag = allTags[tg];
    if (tag.className)
    {
        var classes = tag.className.split(" ");
        for (var cn = 0; cn < classes.length; cn++)
        {
        var cName = classes[cn];
        if (cName == 'first_tab') ifirst = tag.id.substring(3);
        if (cName == 'noborder') ilast = tag.id.substring(3);
        }
    }
}

num = (incritiq == 1)? 4:ifirst;
if (d > 0)
    {
    num = location.href.substr(d+2,3);
    if (num == 5 || num == '27b') // depot
        num = 4;
    }
PlugToggle(1, num, (num == ifirst)?1:0, (num == ilast)?1:0);
return num;
}

    // Carte.html
function disable_vins(nb_page, id_enable)
{
    nb_page = Math.ceil( nb_page);
    if(nb_page == 0) return false;
    for(var i = 0; i < nb_page; i++)
    {
    	$('vins_' + i).style.display = 'none';
    }
    if( $('vins_' + id_enable) != null)
    {
    	$('vins_' + id_enable).style.display = 'block';
    }
    var html = '';
    if( id_enable == 0 && nb_page > 0)
    {
                          html = '1 <a onclick="disable_vins(' + nb_page + ', 1)"> &raquo;</a> ';
    }
    else if( id_enable > 0 && ((nb_page - 1) == id_enable))
    {
    	html = '<a onclick="disable_vins(' + nb_page + ', ' + (id_enable - 1) + ')">&laquo; ' + id_enable + '</a> ' + (id_enable + 1) + ' ';
    }
    else if( id_enable > 0 && (id_enable < (nb_page - 1)))
    {
    	html = '<a onclick="disable_vins(' + nb_page + ', ' + (id_enable - 1) + ')">&laquo; ' + id_enable + ' </a> ' + (id_enable + 1) + ' ';
    	html = html + '<a onclick="disable_vins(' + nb_page + ', ' + (id_enable + 1) + ')"> ' + (id_enable + 2) + ' &raquo;</a> ';
    }
    $('pagvins').innerHTML = html;
}

  // Photo video


timerPhoto = null;
iPhoto = 0;
nPhotos = 0;
iCarCur = 0;
nFamille = 0;
iCurFamille = 0;

function ViewImgBig( iCar, urlImg, n)
{
nPhotos = n;
iCarCur = iCar;
for( var i = 0; i < nPhotos; i++)
	{
	if( $( 'img_view_big_' + iCar + '_' + i) != null)
				$(  'img_view_big_' + iCar + '_' + i).style.display = "none";
	}
new Effect.Appear( $(  'img_view_big_' + iCar + '_' + urlImg),{ duration: 1.0 , from: 0, to: 1 });
for(i=0; i < nPhotos; i++)
{
    try {
        $('img_small_' + iCar + '_' +i).removeClassName("current_photo");
        }
    catch (ex) { break; }
}

    try {
       $('img_small_' + iCar + '_' +urlImg).addClassName("current_photo");
        }
    catch (ex) { }
}



function photoStartAuto( urlImg, n, iFamille, nbFamille)
{
nPhotos = n;
iCarCur = iFamille;
iPhoto = n;
nFamille = nbFamille;
iCurFamille = iFamille;
for( var i = 0; i < nbFamille; i++)
{
  $('car_menu_'+i).removeClassName("current");

  if (i != iFamille)
      $('fCarousel_'+i).hide();
  else {
    $('car_menu_'+i).addClassName("current");
    $('fCarousel_'+i).show();
    }
}
if(timerPhoto!=null)
    clearTimeout(timerPhoto);
timerPhoto = null;
if (n > 1)
    timerPhoto=setTimeout("PhotoChange()", 5000)
PhotoChange();
}

function photoStopAuto()
{
if(timerPhoto!=null)
    clearTimeout(timerPhoto);
timerPhoto = null;
iPhoto = 0;
}

function PhotoChange()
{
    if (iPhoto+1 < nPhotos) iPhoto++;
    else iPhoto = 0;
    ViewImgBig( iCarCur, iPhoto, nPhotos);
    switch (iCarCur)
    {
      case 0 :
        hCarousel0.scrollTo(iPhoto);
        break;
      case 1 :
        hCarousel1.scrollTo(iPhoto);
        break;
      case 2 :
        hCarousel2.scrollTo(iPhoto);
        break;
      case 3 :
        hCarousel3.scrollTo(iPhoto);
        break;
      case 4 :
        hCarousel4.scrollTo(iPhoto);
        break;
      case 5 :
        hCarousel5.scrollTo(iPhoto);
        break;
      case 6 :
        hCarousel6.scrollTo(iPhoto);
        break;
      case 7 :
        hCarousel7.scrollTo(iPhoto);
        break;
      case 8 :
        hCarousel8.scrollTo(iPhoto);
        break;
      case 9 :
        hCarousel9.scrollTo(iPhoto);
        break;
    }

if(timerPhoto!=null)
    clearTimeout(timerPhoto);
timerPhoto = null;
if (nPhotos > 1)
    timerPhoto=setTimeout("PhotoChange()", 5000)
}

    // Proximite
function selcatprox(idRub, idSousRub, permalink)
{
  searchProximite(idRub, idSousRub, permalink, $('catselprox').value);
}

function searchProximite(idRub, idSousRub, permalink, idSel)
{
   new Ajax.Request(
	'./display/proximite',
	{
		method: 'post',
        postBody: 'permalink='+permalink+'&idRub='+idRub+'&idSousRub='+idSousRub+'&idSel='+idSel,
		onSuccess: function( transport, json)
		{
    	   $('proximitelink').innerHTML = transport.responseText;
           loadMapProx(json.coordfiche[0],json.coordfiche[1],json.coordfiche[2],json.coordfiche[3],json.coordonnees);
		}
	}
);
}

function createMarker(point, index, adr, kms, picto) {
    var letter = String.fromCharCode("A".charCodeAt(0) + index);
    var letteredIcon = new GIcon(G_DEFAULT_ICON);
//    letteredIcon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
//    letteredIcon.image = "css/images/pictos/resto.png";
    letteredIcon.image = picto;

    markerOptions = { icon:letteredIcon };
    var marker = new GMarker(point, markerOptions);

    GEvent.addListener(marker, "click", function() {
      marker.openInfoWindowHtml('<b>'+kms+'</b> : '+adr);
    });
    return marker;
}

var marker0;
var marker1;
var marker2;
var marker3;
var marker4;
var map;
var coordg;

function loadMapProx(lat,lng,adr,picto, list_adr)
{
 	if(GBrowserIsCompatible())
   	{
    coordg = new GLatLng(lat, lng);
	map = new GMap2(document.getElementById("map"));
	map.setCenter(coordg, 16, G_NORMAL_MAP);
	map.addControl(new GSmallZoomControl());

    var blueIcon = new GIcon(G_DEFAULT_ICON);
//        blueIcon.image = "http://gmaps-samples.googlecode.com/svn/trunk/markers/blue/blank.png";
    blueIcon.image = picto;
//    blueIcon.iconSize.height = 50;
//    blueIcon.iconSize = new GSize(20,40);

    markerOptions = { icon:blueIcon };

    var marker = new GMarker(coordg, markerOptions);
	map.addOverlay(marker);
	GEvent.addListener( marker, "click", function() { marker.openInfoWindowHtml(adr); } );

    for(var i = j = 0; i < list_adr.length; i+=5,j++)
        {
            m = createMarker(new GLatLng(list_adr[i], list_adr[i+1]), j, list_adr[i+3], list_adr[i+2], list_adr[i+4]);
       	    map.addOverlay( m);
            switch (j)
            {
              case 0 :
                marker0 = m;
                break;
              case 1 :
                marker1 = m;
                break;
              case 2 :
                marker2 = m;
                break;
              case 3 :
                marker3 = m;
                break;
              case 4 :
                marker4 = m;
                break;
            }
        }
//	map.addControl(new ResizeControl());
	}
}

function changeMarker(i, fOrange){

    switch (i)
    {
      case 0 :
        picto = marker0.getIcon();
        coord  = marker0.getLatLng();
        break;
      case 1 :
        picto = marker1.getIcon();
        coord  = marker1.getLatLng();
        break;
      case 2 :
        picto = marker2.getIcon();
        coord  = marker2.getLatLng();
        break;
      case 3 :
        picto = marker3.getIcon();
        coord  = marker3.getLatLng();
        break;
      case 4 :
        picto = marker4.getIcon();
        coord  = marker4.getLatLng();
        break;
    }

    if (fOrange == 1)
    {
    var reg= new RegExp("(.png)", "g");
    image = picto.image.replace(reg, "-orange.png");
//   	map.setCenter(coord, 16, G_NORMAL_MAP);
    }
    else {
      image = picto.image;
//      map.setCenter(coordg, 16, G_NORMAL_MAP);
      }

    switch (i)
    {
      case 0 :
        marker0.setImage(image);
        marker0.show();
        break;
      case 1 :
        marker1.setImage(image);
        marker1.show();
        break;
      case 2 :
        marker2.setImage(image);
        marker2.show();
        break;
      case 3 :
        marker3.setImage(image);
        marker3.show();
        break;
      case 4 :
        marker4.setImage(image);
        marker4.show();
        break;
    }
}

    // Plan access
function loadMap(adresse)
{
    document.getElementById('adr').style.visibility="hidden";
    document.getElementById('adr').style.display = "none";
    document.getElementById('adr').style.height=0;

 	if(GBrowserIsCompatible())
   	{
		geocoder.getLatLng(adresse, function (coord) {
				// Et centrage de la map sur les coordonnées renvoyées par Google :
       	if (!coord)
	    	{
           	alert(address + " - can not find");
        	}
		else {
			map = new GMap2(document.getElementById("map"));
			map.setCenter(coord, 16, G_NORMAL_MAP);
			map.addControl(new GSmallZoomControl());
//        			map.addControl(new GMapTypeControl());
			var marker = new GMarker(coord);
			map.addOverlay(marker);
			GEvent.addListener(
					marker, "click",
					function()
					{
					marker.openInfoWindowHtml(adresse);
					}
			  );
										  // Add the self created ResizeControl
//			map.addControl(new ResizeControl());
			}

			});
	}
}
    // Sondage
function sondagereponse(sond_rub,sond_srub,item, col)
{
	new Ajax.Request(
		   './display/sondage',
		   {
			   method: 'post',
			   postBody: 'idRub='+sond_rub+'&idSRub='+sond_srub+'&id='+item+'&iCol='+col,
			   onSuccess: function( transport)
			   {
				$("sondages10").style.display="none";
				$("sondages11").style.display="";
			   }
		   }
   );
}

function supFriend(elt)
{
    if (!confirm(elt.title)) return false;
	new Ajax.Request(
		   elt.href,
		   {
			   method: 'post',
			   postBody: '',
			   onSuccess: function( transport)
			   {
			    window.location.reload();
			   }
		   }
   );
   return false;
}

function supDiscussion(elt)
{
    if (!confirm(elt.title)) return false;
	new Ajax.Request(
		   elt.href,
		   {
			   method: 'post',
			   postBody: '',
			   onSuccess: function( transport)
			   {
			    window.location.reload();
			   }
		   }
   );
   return false;
}

function supDiscussionFromMsg(elt)
{
    if (!confirm(elt.title)) return false;
	new Ajax.Request(
		   elt.href,
		   {
			   method: 'post',
			   postBody: '',
			   onSuccess: function( transport)
			   {
			    window.location = './mes-messages-recus.html';
			   }
		   }
   );
   return false;
}

var curRspMsg = 0;
function rspMessage(id)
{
        if (curRspMsg != 0)
        {
            $('formrsp_'+curRspMsg).hide();
            $('formrsp_'+curRspMsg).innerHTML = '';
        }
        if (curRspMsg != id)
        {
            $('formrsp_'+id).innerHTML = $('formrsp').innerHTML;
            $('formrsp_'+id).show();
            $('text_mail').focus();
            curRspMsg = id;
        }
        else curRspMsg = 0;
}

    // Calendar
function initCalendar()
{
//    $('cont').offsetTop += 100;
    $('cont').toggle();

    var LEFT_CAL = Calendar.setup({
          				cont: "cont",
          				weekNumbers: true,
          				selectionType: Calendar.SEL_MULTIPLE,
                        onSelect   : selDate,
                        onTimeChange : selTime,
          				titleFormat: "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%B %Y",
                        showTime: true
          		})

    LEFT_CAL.setLanguage('fr');

    var links = document.getElementsByTagName("link");
    var skins = {};
    for (var i = 0; i < links.length; i++) {
            if (/^skin-(.*)/.test(links[i].id)) {
                    var id = RegExp.$1;
                    skins[id] = links[i];
            }
    }

   for (var i in skins) {
              if (skins.hasOwnProperty(i))
                      skins[i].disabled = true;
      }

   skins['steel'].disabled = false;

    LEFT_CAL.setHours(20);
    LEFT_CAL.setMinutes(0);
    LEFT_CAL.showAt(0, 155, false);
}

function showCalendar()
{
$('cont').style.display = 'block';
}

function noshowCalendar()
{
$('cont').style.display = 'none';
}

function selDate()
{
    var date = this.selection.get()[0];
    date = Calendar.intToDate(date);
    date = Calendar.printDate(date, "%d/%m/%Y");
    $('date').value = date;
//    $('cont').toggle();
}

function selTime(cal)
{
    var h = cal.getHours(), m = cal.getMinutes();
    if (h < 10) h = "0" + h;
    if (m < 10) m = "0" + m;
    $('heure').value = Calendar.formatString("${hh}:${mm}", { hh: h, mm: m });
}

redact=false;
function showRedact()
{
  redact=!redact;
  if (redact)
  {
      $('idRedac').removeClassName("displayN");
      new Effect.BlindDown('idRedac', {duration:1, from:0, to:1.0});
  }
  else new Effect.BlindUp('idRedac', {duration:1, from:0, to:1.0});
}

function closeRedact()
{
  redact=false;
  try {
      if (redact)
          new Effect.BlindDown('idRedac', {duration:1, from:0, to:1.0});
      else new Effect.BlindUp('idRedac', {duration:1, from:0, to:1.0});
  }
  catch (ex) {}
}

// Petite boite de recherche
	function loadSelectionFiche(text, li)
	{
	if (li.id != 0)
	    {
	      new Ajax.Request(
	      		   './display/search-go-fiche',
	      		   {
	      			   method: 'post',
	      			   postBody: 'idRub='+$('idRub1').value+'&idSRub='+$('idSRub1').value+'&id='+li.id,
	      			   onSuccess: function( transport)
	      			   {
	                     window.location.replace(transport.responseText);
	      			   }
	      		   }
	         );
	    }
	}

	function searchSetRubs(element, entry) {
		return entry+'&rub='+$('idRub1').value+'&theme='+$('idSRub1').value;
	}

	function selectcat() {
	  $('idSRub1').value = $('idSRub2').value = $('catsel').value;
	  boxSearch($('idRub').value, $('idSRub1').value);
	}

// carte
   		function OpenFormules(categorie)
		{
			if( cat_menu != null)
			{
				for(i = 0; i < cat_menu.length; i++)
				{
					if( cat_menu[i] == categorie)
						$('cat_menu_' + cat_menu[i]).style.display = 'block';
					else
						$('cat_menu_' + cat_menu[i]).style.display = 'none';
				}
			}
		}

function go(url)
{
    window.location = url;
}

function ctrlaccess(lang)
{
/*
if (window.showModalDialog)
    {
    ret = window.showModalDialog("./18ans/18ans.php","name", "center:1;dialogWidth:950px;dialogHeight:710px");
    return (ret == 1);
    }
else {
    ret = window.open('./18ans/18ans.php','name', 'height=710,width=950,toolbar=no,directories=no,status=no, continued from previous linemenubar=no,scrollbars=no,resizable=no ,modal=yes');
    return (ret == 1);
}
*/

  Modalbox.show('./18ans/18ans.php?lang='+lang, {title: "Paris Coquin", width: 970, height:710, overlayClose : false, closeValue:''});
//  Modalbox.show('<iframe name="Acces" align="left" marginWidth="0" marginHeight="20" src="./18ans/18ans.php" frameBorder="no" noResize width="950" height="710" style="margin: 0 0 0 10px; border: 0;"></iframe>', {title: "{/literal}Paris Coquin{literal}", width: 970});
  return false;
}

function valide_ctrlaccess()
{
    new Ajax.Request(
		'valid-access-adult.html',
		{
			method: 'post',
			onSuccess: function( transport)
            {
            }
		}
	);
}

function PlugToggle(current, nouveau, first, last) {
if (nouveau == 25) {
  	displayresatickenet();
  	return nouveau;
} else {
  	try {
			$("details_"+current).hide();
			$('ong'+current).removeClassName("current");
			$("details_"+nouveau).show();
			if (nouveau != "28") {
				Move.element($("details_" + nouveau), $('tab_container'), 'move');
			}
            $('ong'+nouveau).addClassName("current");
		}
		catch (ex) {
			$('ong'+nouveau).addClassName("current");
		}

		if (first == 1) {
  		$('onglets').addClassName("menu_onglet_first_tab_current");
          } else {
  		$('onglets').removeClassName("menu_onglet_first_tab_current");
  		if ($("ong"+nouveau) && $("details_"+nouveau)) {
  			var leftPos = $('ong'+nouveau).offsetLeft + 15;
  			$("details_"+nouveau).style.background = "transparent url(/css/images/background/onglet_arrow.gif) no-repeat scroll "+leftPos+"px top";
  		}
      }
  	if (last == 1) {
    		$('onglets').addClassName("menu_onglet_last_tab_current");
    	} else {
    		$('onglets').removeClassName("menu_onglet_last_tab_current");
    	}
  }
  return nouveau;
}

var Move =	{

  copy	:   function(e, target)	{
	    var eId      = $(e);
	    var copyE    = eId.cloneNode(true);
	    var cLength  = copyE.childNodes.length -1;
	    copyE.id     = e+'-copy';

	    for(var i = 0; cLength >= i;  i++)	{
	    if(copyE.childNodes[i].id) {
	    var cNode   = copyE.childNodes[i];
	    var firstId = cNode.id;
	    cNode.id    = firstId+'-copy'; }
	    }
	    $(target).appendChild(copyE);
	    },
  element:  function(e, target, type)	{
	    var eId =  $(e);
	    if(type == 'move') {
	       $(target).appendChild(eId);
	    }

	    else if(type == 'copy')	{
	       this.copy(e, target);
	    }
	    }
}


hPresentAvis = 0;
thelangue = '_FR';
function getfullpresent(id, idrub, idsrub, langue)
{
thelangue = langue;
if (hPresentAvis == 1) return;

    hPresentAvis = 1;
    new Ajax.Request(
		'get-full-present.html',
		{
 			method: 'post',
		    postBody: 'idRub='+idrub+'&idSousRub='+idsrub+'&id='+id,
			onSuccess: function( transport)
			{
                $('pres').innerHTML = transport.responseText;
                $('presbutavis').observe('click', presOffsetAvis);
                hPresent = 0;
                $('presbutavis').setAttribute("src", "css/images/bouton/fermer_pres"+thelangue+".png");
                presOffsetAvis();
      		}
    	}
	);
}

function clickdec(permalink)
{
    new Ajax.Request(
		'set-click-decouvrir.html',
		{
 			method: 'post',
		    postBody: 'permalink='+permalink,
			onSuccess: function( transport)
			{
//			  alert(transport.responseText);
      		}
    	}
	);
    return true;
//    return false;
}

function filtersResSearch(params)
{
    new Ajax.Request(
		'filters-res-search.html',
		{
 			method: 'post',
		    postBody: 'params='+params,
			onSuccess: function( transport)
			{
            $('menudde'+params).innerHTML = transport.responseText;
            displayletterfirst();
			// $('filtersResSearch').innerHTML = transport.responseText;
//            dropdown(1)
//            initEvents()
      		}
    	}
	);
    return true;
}



	function showSubMenu() {
		var pageLeftOffset = $('page').offsetLeft;
		var tmpHeight = $('submenu_more').previous().offsetTop + $('submenu_more').previous().offsetHeight;
		var tmpWidth  = pageLeftOffset + $('submenu_more_link').offsetLeft;
		$('submenu_more').style.top = tmpHeight + 'px';
		$('submenu_more').style.left = tmpWidth +'px';
		$('submenu_more').style.width = $('submenu_more_link').offsetWidth - 8 + 'px';
		$('submenu_more').show();
		posXB = tmpWidth;
		posXE = tmpWidth + $('submenu_more_link').offsetWidth - 8;
		posYB = tmpHeight - $('submenu_more').previous().offsetHeight;
		posYE = tmpHeight + $('submenu_more').offsetHeight;
	}

	function hideSubmenu() {
		if (x >= posXB && x <= posXE) {
			if (y >= posYB  && y <= posYE) return;
		}
		$('submenu_more').hide();
	}

	function position(e) {
		if (!document.all) {
			x = e.pageX;
			y = e.pageY;
		} else {
			x = event.clientX+document.body.scrollLeft;
			y = event.clientY+document.body.scrollTop;
		}
		hideSubmenu();
	}
	var x;
	var y;
	var posXB, postXE, posYB, posYE;
	Event.observe(window, "load", function(event) {
		if ($("submenu_more")) {
			$("submenu_more").hide();
			if(!document.all) document.captureEvents(Event.MOUSEMOVE);
			document.onmousemove = position;
		}
	});


	var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	    if (this.OS == "Mac") {
		    document.write("<link rel='stylesheet' type='text/css' href='css/mac.css' title='mac_stylesheet'>");
    	}
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};

function displaymodal(elt)
{
    Modalbox.show(elt.href, {title: elt.title, width: 733, height:550, overlayClose : false});
    return false;
}

// facebook avis
    function creetic_fb_init()
    {
        if (location.href.search("member.creetic.ie") >= 0)
        {
            FB.init("38ec8fe29d508cec3fb3da822f596e88", "facebook/xd_receiver.htm");
        }
        else {
            // Init de l'interface paris
            FB.init("84bb7313dca29df4c1555c412cffc5d7", "facebook/xd_receiver.htm");
                // Init de l'interface memberdev
            //FB.init("89f4ae4f49dda4ff6da37c9ded667163", "facebook/xd_receiver.htm");
        }

    }

    function write_fb_review(message,note, urlfiche, notefb, fichecat, fichename, img)
    {
          FB_RequireFeatures(["XFBML", "Connect"],
          function()
          {
              var ret = 'M2 not set';

              FB.ensureInit(function () {
              var attachment = {'name' : 'Creetic',
                                'href' : urlfiche,
                                'description' : notefb+note,
                                'caption' : fichecat + ' ' + fichename,
                                'media' : [
                                  {
                                  'type': 'image', 'src': img,
                                  'href': urlfiche
                                  }
                                  ]
                                }
              FB.Facebook.apiClient.users_hasAppPermission("publish_stream",function(has)
              {
                if (has == 0)
                {
                    FB.Connect.showPermissionDialog("publish_stream", function(granted)
                        {
                        var ret = FB.Connect.streamPublish(message,attachment,null,null,fichecat + ' ' + fichename,null,false);
                        });
                }
                else {
                    var ret = FB.Connect.streamPublish(message,attachment,null,null,fichecat + ' ' + fichename,null,false);
                    }

                info('Stream publish returned: ' + ret);
              });
            });
          });
    }

// facebook invit amis
    function checkFacebookConnectedStatus()
    {
    FB.Connect.ifUserConnected(fb_connected, fb_notconnected);
    }

    function fb_connected()
    {
      $('but_link_fb_allfriends').style.display='';
      dspn('but_fb_connect');
      myfb_session = FB.Facebook.apiClient.get_session();
      facebook_displayfriends();
//      my_uid = FB.Connect.get_loggedInUser();
    }

    function fb_notconnected()
    {
    }

    function facebook_onlogin()
    {
        fb_connected();
        write_fb_friends();
    }

    function facebook_displayfriends()
    {
    var widget_div = document.getElementById("profile_pics");

    FB.ensureInit(function () {
      FB.Facebook.apiClient.friends_get(null, function(result) {
        var markup = "";
        var num_friends = result ? Math.min(4, result.length) : 0;
        if (num_friends > 0) {
          for (var i=0; i<num_friends; i++) {
           markup +=
                '<li>' +
                '<fb:profile-pic size="square" uid="'+ result[i] + '" facebook-logo="true" linked="false" width="40">' + ' </fb:profile-pic>' +
                '<p class="text"><a href="#" onclick="return false;"><b><fb:name uid="'+ result[i] + '" linked="false" ></fb:name></b></a></p>' +
                '</li>';
          }
        }
        widget_div.innerHTML = markup;
        FB.XFBML.Host.parseDomElement(widget_div);
      });
    });
    }


    function write_fb_friends( message, basesite_fb, label_invit_fb)
    {
          FB_RequireFeatures(["XFBML", "Connect"],
          function()
          {
              var ret = 'M2 not set';

              FB.ensureInit(function () {
              var attachment = {'name' : 'Creetic',
                                'href' : basesite_fb,
                                'description' : label_invit_fb,
                                'media' : [
                                  {
                                  'type': 'image', 'src': basesite_fb+'css/images/background/logo_FR.gif',
                                  'href': basesite_fb
                                  }
                                  ]
                                }
              FB.Facebook.apiClient.users_hasAppPermission("publish_stream",function(has)
              {
                if (has == 0)
                {
                    FB.Connect.showPermissionDialog("publish_stream", function(granted)
                        {
                        var ret = FB.Connect.streamPublish(message,attachment,null,null,label_invit_fb,null,false);
                        });
                }
                else {
                    var ret = FB.Connect.streamPublish(message,attachment,null,null,label_invit_fb,null,false);
                    }

                info('Stream publish returned: ' + ret);
              });
            });
          });
    }

// billet
function initpubbillet()
{
    $('pubbillet').innerHTML = '<a href="http://www.usinedeco.com/" target="_blank" rel="nofollow">'+$('pubbillet').innerHTML+'</a>';
}
