/******************************************/
/** DIT AANPASSEN VOOR MAANDELIJKE REMIX **/
/******************************************/
var BackgroundColor = "#ffffff";
var MonthYear = "september2010";
var NumDate = "09/10";
var ArtistName = "Thierry Mortier";
var Website = "http://www.semiotic.tv";
/********************************************/
/************** TOT HIER ********************/
/********************************************/


$(document).ready(function(){

if (!$.cookie("cookieRemixMonthYear") || $.cookie("cookieRemixAuto") == "true") {
	$.cookie("cookieRemixBgColor", BackgroundColor, { path: '/', expires: 9999});
	$.cookie("cookieRemixMonthYear", MonthYear, { path: '/', expires: 9999});
	$.cookie("cookieRemixDate", NumDate, {path:'/', expires: 9999});
	$.cookie("cookieRemixName", ArtistName, {path:'/', expires: 9999});
	$.cookie("cookieRemixWebsite", Website, {path:'/', expires: 9999});
	$.cookie("cookieRemixAuto", "true", {path:'/', expires: 9999});
	RemixToepassen();
}


/** REMIX SWITCHER **/
RemixToepassen();

$("#" + $.cookie("cookieRemixMonthYear")).addClass("remix_selected");

if ($.cookie("cookieRemixAuto") == "true") {
	$("#remix_auto").addClass("remix_auto_on");
}

$(".remix_switcher").click(function(){
	$(".remix_switcher").removeClass("remix_selected");
	$("#remix_auto").removeClass("remix_auto_on");	
	$(this).addClass("remix_selected");
	$.cookie("cookieRemixBgColor", $(".remix_switcher_props .remix_bgcolor", this).text(), { path: '/', expires: 9999});
	$.cookie("cookieRemixMonthYear", $(".remix_switcher_props .remix_monthyear", this).text(), { path: '/', expires: 9999});
	$.cookie("cookieRemixDate", $(".remix_switcher_props .remix_date", this).text(), {path:'/', expires: 9999});
	$.cookie("cookieRemixName", $(".remix_switcher_props .remix_name", this).text(), {path:'/', expires: 9999});
	$.cookie("cookieRemixWebsite", $(".remix_switcher_props .remix_website", this).text(), {path:'/', expires: 9999});
	$.cookie("cookieRemixAuto", "false", {path:'/', expires: 9999});
	RemixToepassen();
});

$("#remix_auto").click(function(){
	$(".remix_switcher").removeClass("remix_selected");
	$(".remix_switcher:first").addClass("remix_selected");
	$(".remix_switcher:first").click();
	$(this).addClass("remix_auto_on");	
	$.cookie("cookieRemixAuto", "true", { path: '/'});
	RemixToepassen();
});
				
// Laatste Item Geen Border-Bottom						   
$(".cr_item div:last-child").css("border-bottom", "0");
$("#drawer div:last-child").css("border-bottom", "0");
$(".bdb_item li:last-child").css("border-bottom", "0");
$(".projects_list li:last-child").css("border-bottom", "0");
$(".projects_list li:last-child").css("padding-bottom", "0");

// Afwisselen Achtergrond
$(".comments_item:odd").addClass("comments_item_odd");

// Comments Link Uitklappen Juiste Comments
$("span.reacties_link").click(function(){
	$(this).parent().next().toggle("fast");
});

// Invoerveld om reactie toe te voegen, tonen.
$(".btn_voeg_reactie_toe").toggle(function(){
	$(this).next().show("fast");
	$(this).css("background-image", "url(/gfx/icon_voeg_reactie_toe_close.gif)");
},
	function() {
	$(this).next().hide("fast");
	$(this).css("background-image", "url(/gfx/icon_voeg_reactie_toe.gif)");
	}
);

// Afbeeldingen in .blog_item die te groot zijn, verkleinen.
$(".blog_item img").each(function(){
	var imgWidth = this.width;
	var bodyWidth = $(".blog_item_body").width();
	if (imgWidth > bodyWidth) {
		$(this).css({width: bodyWidth});
	}
});

// Afbeeldingen in Single Page die te groot zijn, verkleinen.
$("#single img").each(function(){
	var imgWidth = this.width;
	var bodyWidth = 510;
	if (imgWidth > bodyWidth) {
		$(this).css({width: bodyWidth});
	}
});

// Search Options Tonen

$("#show_so").toggle(function(){
	$("#so").show();
	$(this).html("Verberg Opties");
},
function() {
	$("#so").hide();
	$(this).html("Toon Opties");
});


// Tooltips
$('.usercard').tooltip({
	track: true,
	delay: 200,
	fade: 200,
	showURL: false,
	top: -20,
	left: 20,
	bodyHandler: function() {
		return $(".tt_content", this).html();
	}
});

// Max-Breedte Tooltips
$(".usercard").hover(function(){
	$("#tooltip").each(function(){
			var divWidth = $(this).width();
			var maxWidth = 250;
			if (divWidth > maxWidth) {
				$(this).css({width: maxWidth});
		}
	});
	return false;
});

}); /* einde document.ready */


/** remix toepassen **/
function RemixToepassen() {
	var trimmedMonthYear = $.trim($.cookie("cookieRemixMonthYear")); // IE7 Bug: Spatie wordt toegevoegd achter MonthYear
	var backgroundProperties = 	$.cookie("cookieRemixBgColor") + " url(/art/remixes/" + trimmedMonthYear + ".png) no-repeat center 0";
	$("body").css("background", backgroundProperties);
	$("#themeswitcher .remix_date").text($.cookie("cookieRemixDate") + " ");
	$("#themeswitcher .remix_link").text($.cookie("cookieRemixName"));
	$("#themeswitcher .remix_link").attr({href : $.cookie("cookieRemixWebsite")});
}