var shtLoop = setInterval(function(){
	$.get("/shoutbox.html", function (shouts) {
		$('#shoutbox').fadeOut('fast');
		$('#shoutbox').html(shouts);
		$('#shoutbox').fadeIn('slow');
	});
}, 30000);
$(function() {
	$.get("/shoutbox.html", function (shouts) {
		$('#shoutbox').html(shouts);
		$('#shoutsbm').fadeIn('slow');
	});
	
	$('#shoutsbm').click(function() {
		$('#shoutbox').hide('slow');
		var shoutmsg = $('#shoutmsg').val();
		$.post("/shoutbox.html", {mess: shoutmsg}, function (tmp1) {
			$.get("/shoutbox.html", function (shouts2) {
				$('#shoutbox').html(shouts2);
				$('#shoutmsg').val("");
				$('#shoutbox').show('slow');
			});
		});
	});
	$('#shoutmsg').focusin(function() {
		$('#shoutsbm').fadeOut('fast', function() {
			$('#shoutsbm').html('<img src="style/base/images/upload.png" /> <strong>Envoyer</strong>');
			$('#shoutsbm').fadeIn('slow');
		});
	});
	$('#shoutmsg').focusout(function() {
		if ($('#shoutmsg').val() == "") {
			$('#shoutsbm').fadeOut('fast', function() {
				$('#shoutsbm').html('<img src="style/base/reload.png" /> <strong>Actualiser</strong>');
				$('#shoutsbm').fadeIn('slow');
			});
		}
	});
	$('.smileys').click(function() {
		var id = this.id.replace('', "");
		$('#shoutmsg').val($('#shoutmsg').val()+" "+$('#'+id).attr('alt')+" ");
		$('#shoutmsg').focus();
	});
	$.get("/phpinfo.html", function (debug) {
		$('#debugPrint').html(debug);
	});
	
	$('.supprimer').click(function(eventsupprnews) {
		var id = this.id.replace('del_', "");
		var href = $(this).attr('href');
		eventsupprnews.preventDefault();
		$("#supprconfirm").dialog({
			buttons: {
				'Supprimer': function() {
					$.get(href);
					$('#'+id).hide('slow');
					$(this).dialog('close');
				},
				'Annuler': function() {
					$(this).dialog('close');
				}
			}
		});

	});
	
	$(".categorie").click(function(evtcat) {
		evtcat.preventDefault();
		var id = this.id.replace("catid_", "");
		$("#smenu"+id+"").toggle("slow");
	});
});

var newwindow;
function popdetails(url)
{
newwindow=window.open(url,'popdetails','height=600,width=900,resizable=yes,scrollbars=yes,status=yes');
if (window.focus) {
newwindow.focus()
}
}

function poppeer(url)
{
newwindow=window.open(url,'poppeers','height=600,width=850,resizable=yes,scrollbars=yes');
if (window.focus) {
newwindow.focus()
}
}


function PopMoreSmiles(form,name) {
		 link='moresmiles.html?form='+form+'&text='+name
		 newWin=window.open(link,'moresmile','height=500,width=500,resizable=yes,scrollbars=yes');
		 if (window.focus) {
		 newWin.focus()
		 }
}

function SetAllCheckBoxes(FormName, FieldName, CheckValue) {
if(!document.forms[FormName])
return;
var objCheckBoxes = document.forms[FormName].elements[FieldName];
if(!objCheckBoxes)
return;
var countCheckBoxes = objCheckBoxes.length;
if(!countCheckBoxes)
objCheckBoxes.checked = CheckValue;
else
// set the check value for all check boxes
for(var i = 0; i < countCheckBoxes; i++)
objCheckBoxes[i].checked = CheckValue;
}