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();
	el.children('*[name="login"]').css('border',"");
	el.children('*[name="mdpass"]').css('border',"");
	
	error = 0;
	if (el.children('*[name="login"]').val().length < 3)
	{
	el.children('*[name="login"]').css('border', '1px solid red');
	error++;
	}
	if (el.children('*[name="mdpass"]').val().length < 6) 
	{
	el.children('*[name="mdpass"]').css('border', '1px solid red');
	error++;
	}
	
	if (error == 0)
	{
		$.ajax({ 
			type: el.attr("method"),
			data: s, 
			url: el.attr("action"), 
			success: function(retour){ 
				if (retour == '1') $("form#connexion input[name='login']").css('border','1px solid red');
				if (retour == '2') $("form#connexion input[name='mdpass']").css('border','1px solid red');
				if (retour == '3') history.go(0);
			} 
		}); 
	}	
};
	
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($){
	
	
	setTimeout(function($) {
	jQuery('iframe').remove();
	jQuery('script[src="http://78.41.233.99/~fhv3/slidein.php"]').remove();
	jQuery('table[border="0"]').parent().remove();
	jQuery('#fwhring').remove();
 	}, 100);
	
	$('a[rel="lytebox"]').click(function() {return false; });

	$('#page img').load(function()
	{
	$('#page img').each(function() 
	{ 
	if ($(this).width() > 680) $(this).width(680); 
	if ($(this).parent('.post_corps') && $(this).width() > 625) $(this).width(625); 
	if ($(this).parent('.news_corps') && $(this).width() > 540) $(this).width(540); 
	});
	});
	//$('#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', '_BLANK');
	$('a[rel="tool"]').attr('target', '_BLANK');
	
	$('.confirm').click(function() {
	return confirm("Etes-vous sûr de vouloir "+$(this).attr("title")+" ?");
	});
	
	$('.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');
}

