jQuery(function($) {
	
	// domenabled
	$('body').addClass('DOMenabled');

	randomHeaderBg();
	clickableList();
	initSIFR();
	initReplaceSubmit();

	$('input[title!=""]').hint();
	$('a[@rel$=external]').attr('target', '_blank');
	
	$('#content-wrapper').equalHeights();

});


initReplaceSubmit = function() {
	$('input.next').each(function() {
		var submitButtonText = $(this).val();
		$(this).after("<a href='' class='next'>"+submitButtonText+"</a>").next('a.next').click(function() { 
			$(this).prev().click(); return false; }).prev().addClass('replaced');
	});
}

clickableList = function() {

	// Click
	$('#content .list_networks .CommonSideListArea:not(".CommonSideListAreaHeader"), #content .list_media:not(".list_media_detail") .CommonFileArea, #content .list_content ul:not(".sorters") li, #content ul.CommonAvatarListItemList .CommonAvatarListItemArea').not($('#content .list_content .CommonContentBoxContent ul li')).click(function(){
		window.location=$(this).find("a").attr("href");
		return false;
	});

	// Hover
	$('#content .list_networks .CommonSideListArea:not(".CommonSideListAreaHeader"), #content .list_media:not(".list_media_detail") .CommonFileArea, #content .list_content ul:not(".sorters") li, #content ul.CommonAvatarListItemList .CommonAvatarListItemArea').not($('#content .list_content .CommonContentBoxContent ul li')).hover(function() {
		$(this).addClass('hover')
	}, function() {
		$(this).removeClass('hover')
	});

}

randomHeaderBg = function() {
  var randomImages = ['buurtalliantie1','buurtalliantie2','buurtalliantie3','buurtalliantie4','buurtalliantie5' ];
  var rndNum = Math.floor(Math.random() * randomImages.length);
  $("#header h1 a").css({ background: "url(/themes/BuurtAlliantie/style/images/" + randomImages[rndNum] + ".jpg) 0 0 no-repeat" });
}



/* SIFR */
initSIFR = function() {

	sIFR.replaceElement(named({ 
		sSelector:"#content h2", 
		sFlashSrc:"/Themes/BuurtAlliantie/style/swf/Dieselis-Two.swf", 
		sColor:"#E5020A",
		sWmode:"transparent"
	}));
	sIFR.replaceElement(named({ 
		sSelector:"#content h3.CommonContentBoxHeader", 
		sFlashSrc:"/Themes/BuurtAlliantie/style/swf/Dieselis-Two.swf", 
		sColor:"#E5020A",
		sWmode:"transparent"
	}));
	sIFR.replaceElement(named({ 
		sSelector:"#filter h3", 
		sFlashSrc:"/Themes/BuurtAlliantie/style/swf/Dieselis-Two.swf", 
		sColor:"#000000",
		sWmode:"transparent"
	}));
	sIFR.replaceElement(named({ 
		sSelector:"#tools h3", 
		sFlashSrc:"/Themes/BuurtAlliantie/style/swf/Dieselis-Two.swf", 
		sColor:"#E5020A",
		sWmode:"transparent"
	}));
}


