function ie_fix()
{
	if ($.browser.msie && jQuery.browser.version < 7)
	{
		$("div.rounded_block").css("margin","8px");
		$("div.small_block").css("margin", "8px");
		$("div.large_block").css("margin", "8px");
		$("#template_left").css("padding","10px");
		$("#template_right").css("width", "240px");
		$(document).pngFix();
	}
}

$(document).ready(function ()
{	ie_fix();
	init_menu();
	$('div.bottom_corner').corner("bottom");
	$('.afbeelding_rechts').corner("bl");
	$('.afbeelding_links').corner("br");
	$('.img_left').corner("bl");
	buttons();
	$("a.fancy").fancybox();
	Forms();



	$('div.img_right_overview').corner("br");
});

function init_menu()
{
	$("#menu li a").hover(
		function() {
			if (!$(this).parent().hasClass("active"))
				$(this).parent().addClass("over");
		},
		function() {
			if (!$(this).parent().hasClass("active"))
				$(this).parent().removeClass("over");
		}
	);

	$(".link_new_window").each(
		function(){
			$(this).attr("target", "_blank");
		}
	);
}

function buttons()
{
	$(".more_absolute").hover(
		function() {
			$(this).attr("src", "/images/button_more_over.png");
		},
		function() {
			$(this).attr("src", "/images/button_more.png");
		}
	);

	$(".inp_submit").hover(
		function() {
			$(this).addClass("inp_submit_over");
		},
		function() {
			$(this).removeClass("inp_submit_over");
		}
	);

	$(".button_subscribe,.hoverbuttons,.button_more,.evenement_subscribe").hover(
		function(){
			var src = $(this).attr("src");
			$(this).attr("src", src.replace(/.gif/i, "_over.gif"));
		},
		function(){
			var src = $(this).attr("src");
			$(this).attr("src", src.replace(/_over.gif/i, ".gif"));
		}
	);
}

function Forms()
{
	$("input[type='text'],textarea").focus(
		function(){
			if ($(this).val() == $(this).attr("defaultValue"))
				$(this).val('');
		}
	).blur(
		function(){
			if ($(this).val() == '')
				$(this).val($(this).attr("defaultValue"));
		}
	);
	$("form").each(
		function(){
			$(this).attr("method", "post");
		}
	);
}

// Homepage news
var nws = new Array();
var scroller = null;
function getnws()
{
	$.ajax(
	{
		type: "GET",
		url: "/_ajax.asp",
		data: "action=news",
		processData: true,
		beforeSend: function(){
			$("#scroller").append('<img src="/images/ajax-progress.gif" alt="" class="progress"/>');
		},
		success: function(html){
			$("#scroller").html(html);
			fillnws();
		}
	});
}

function fillnws()
{
	$("#scroller").find("li").each(function(i) {nws.push($(this).html());});
	$('#scroller').jcarousel({
		vertical: true,
		auto: 5,
		scroll: 4,
		buttonNextHTML: null,
		buttonPrevHTML: null,
		animation: "slow",
		wrap: 'circular',
		itemVisibleInCallback: {onBeforeAnimation: car_add},
		itemVisibleOutCallback: {onAfterAnimation: car_remove},
		pauseOnHover: true
	});
}

function car_add(carousel, item, i, state, evt)
{
	var idx = carousel.index(i, nws.length);
	carousel.add(i, nws[idx-1]);
};

function car_remove(carousel, item, i, state, evt)
{
	carousel.remove(i);
};

function other_option()
{
	if (eval("document.training.via"))
	{
		for (var i=0;i<document.training.via.length;i++)
			document.training.via[i].onclick = function(){
				if (this.value == 'anders')
					return $("#form_anders").show();
				else
					return $("#form_anders").hide();
			}
	}
}

var lastcat = null;
function toggle_weblog(id)
{
	$('#weblogcategorie_'+id).addClass("weblogcategorie_open");
	$('#weblogs_'+id).slideDown();

	if (lastcat != null && lastcat != id)
	{
		$('#weblogcategorie_'+lastcat).removeClass("weblogcategorie_open");
		$('#weblogs_'+lastcat).slideUp();
	}
	lastcat = id;
}

function toggle_faq(id)
{
	$('#faq_'+id).css("display") == 'none' ? $('#faq_'+id).slideDown() : $('#faq_'+id).slideUp();
}

function show_auteur(s)
{
	$("#auteur").html(s);
}