function pp(page, title, width, height) 
{
window.open(page,title,"toolbar=yes,personalbar=yes,titlebar=yes,location=yes,directories=yes,width="+width+",height="+height+",scrollbars=yes,resizable=yes");
}

function uploadpp()
{
pp(path+'files/popup.html','Upload de fichiers',450,120);
}
   
function connexion(event)
{
    if ( !event )
    {
        event = window.event;
    }
    var target = event.target ? event.target : event.srcElement;
	el = $(target);
	s = el.serialize();
		$.ajax({ 
			type: el.attr("method"),
			data: s, 
			url: el.attr("action"), 
			success: function(retour){ 
				$("form#connexion").parent().empty().html(retour); 
			} 
		}); 
		return false;
};
	
function deconnexion(e) {
			$.ajax({ 
			type: "GET", 
			url: $("a#deconnexion").attr("href"), 
			success: function(retour){ 
			$("a#deconnexion").parent().empty().html(retour); 
			} 
		}); 
		return false;
	}
	
function switchdisplay(element)
{
$(element).css('display', ($(element).css('display') == 'none' ? 'block' : 'none'));
}	

cat_id=0;
function showmenu2(catid)
{
cat_id=catid;
$("#rubanIn ul").hide('normal',function() { 	
$("#rubanIn li").css('display','none');
$("#rubanIn ul").css('display','none');
$("#rubanIn li[class='item_c"+cat_id+"']").css('display','');
$("#rubanIn ul").show('normal');
});
}
function showmenu(catid) {showmenu2(catid);}


function portail(catid)
{
window.location.href=path+cats[catid]+'-c'+catid+'/';
}

function realwidth(catid,width)
{
$('#menu_c'+catid+' object').width(width);
$('#menu_c'+catid+' embed').width(width);
}

var timeout;

jQuery(function($){
	//$('#menupasflash').append($('#menuflash').children());
	$("#rubanIn ul").hide();
	
	/*$('#menupasflash img').mouseover(function(event)
	{ 
		if (timeout) window.clearTimeout(timeout);
		msg = $(event.target).parent().parent().attr('id').substr(6);
		var delay = function() { showmenu2(msg); };
		timeout = window.setTimeout(delay, 500); 
	});
	
	$('#menupasflash img').mouseout(function(){if (timeout) window.clearTimeout(timeout);});*/
	
	//$('#menupasflash img').click(function(event) { portail($(event.target).parent().attr('id').substr(6)); });
	
	$('.cat_lueur').css('opacity',0);
	$('.cat_simple').css('margin-left',3);
	$('.cat_lueur').hover(function() {
		$(this).stop().animate({opacity:1},"slow",function()
		{
			showmenu2($(this).parent().parent().attr('id').substr(6));
		});
	},function() {
		$(this).stop().animate({opacity:0},"slow");
	});

	
	
	$('*[rel="option"]').css('display', 'none');
	$('*[rel="option"]').css('position', 'absolute');
	$('*[rel="option"]').parent().mouseover(function() {
	$(this).children('*[rel="option"]').css('display', '');
	});
	$('*[rel="option"]').parent().mouseout(function() {
	$(this).children('*[rel="option"]').css('display', 'none');
	});

	$('a[rel="external"]').attr('target', '_NEW');
	$('.date').attr("autocomplete","off");
	
	$('.date').keyup(function()
	{
		$(this).val($(this).val().replace(/[^0-9]/g,""));
		if ($(this).val().length >= $(this).attr("size")) 
		{
			if ($(this).next().hasClass('date')) $(this).next().focus(); 
			else if ($(this).next().next().hasClass('date')) $(this).next().next().focus(); 
			else $(this).blur();
			$(this).val($(this).val().substr(0,$(this).attr("size")));
		}
	});
	$('.date').each(function()
	{
	if ($(this).val() == "") 
	{
		$(this).val(($(this).attr("title").split(' '))[1]);
		$(this).css("font-style","italic");
		$(this).css("color","#808080");
	}	
	});
	
	$('.date').focus(function()
	{
		if ($(this).css("font-style") == "italic")
		{
			$(this).val("");
			$(this).css("font-style","");
			$(this).css("color","");
		}
	});

	$('.date').blur(function()
	{
		if ($(this).val() == "")
		{
			$(this).val(($(this).attr("title").split(' '))[1]);
			$(this).css("font-style","italic");
			$(this).css("color","#808080");
		}
	});

	url = document.location.toString();
	rel = url.split('#');
	
	if (rel[1] != undefined)
	{
	ancre = rel[1];
	if (ancre.length > 0) document.location='#'+ancre;
	}
	if (document.width < 1400) 
	{
	window.scrollTo(((1400-document.width)/2),0);
	}
});	

var towrite='';
function querypage(page,dest,method)
{
if (!method) method='GET';
if ($(dest).css('display') == 'none')
{
towrite = dest;
$.ajax({ 
    type: method, 
    url: page, 
    success: function(retour){ 
		$(towrite).css('display', 'block');
		$(towrite+' .display_com').html(retour);
    } 
});
}
else $(dest).css('display', 'none');
}
