/*
File: main.js
Author: Simon
*/

//Ready function
$(function() {
	var ActiveElement = $('.menu-level-1.active');
	

/*
	$('.menuGradient:not(:first)').each(function(){
		$(this).click(function(){
			$(ActiveElement).removeClass('active');
			$(this).parent().addClass('active');
			ActiveElement = $(this).parent();
		})
	});
*/

	$('.menuGradient.last').click(function(){
		$(ActiveElement).removeClass('active');
		$(this).parent().addClass('active');
		ActiveElement = $(this).parent();
	});
	
	// Klapmenu:
	$("ul.menu-level-2 ul").hide();
    // De functionaliteit:
	$("ul.menu-level-2 li.menu-sub-header").addClass("clickable").css({cursor: "pointer"}).click(function(){
        $("ul.menu-level-2 ul").not($("ul", $(this).next())).slideUp(function(){
            $("li.menu-sub-header", $(this).parent().parent()).addClass("clickable");
        });;
		$("ul", $(this).next()).slideDown(function(data){
			if($(this).css("display")=='none') {
				$("li.menu-sub-header", $(this).parent().parent()).addClass("clickable");
			} else {
				$("li.menu-sub-header", $(this).parent().parent()).removeClass("clickable");
			}
		});
	});
    // Toon het menu dat actief is:
    $("ul.menu-level-2 li.active").parent().show().parent().prev().removeClass("clickable");

	
	$.getJSON("/assets/templates/roijers/yahoo/weatherproxy.php", { w: "734456", u: "c" }, function(data){
		var img= '/assets/templates/roijers/images/weather-conditions/'+data.condition.code+'.png';
		var weather = $(document.createElement("div"));
		$(weather).append('<span class="arial fs10 darkgrey uc" style="text-shadow:black 0em 0em 0.5em">het weer<br />vandaag</span><br /><br /><span class="AuxLight fs50 white">'+data.forecast[0].high_temperature+'°</span>').css({
			'background':'url('+img+')',
			'width':'inherit',
			'height':'inherit',
			'padding':'17px 0 0 17px'
		});

		$("#home-box-banner-weather").append(weather);
		//Cufon.replace('.weathertitle', {fontFamily:'AkzidenzMedium',textShadow: '#282828 -2px -2px, #282828 2px 2px'});
		Cufon.replace('.AuxLight', {fontFamily:'AuxLight'});
		
			
	});
	
	// InfoPopup:
	// $("#black").click(function(){
	$("#popup a.close").click(function(){
		$("#popup, #black").fadeOut();
		return false;
	});
	
	
	// Scale footerBlock:	
	$(window).resize(function(){
		var newWidth = 266 * (Math.floor($("#footer").width() / 266));
		if(newWidth < 266 * 3) { newWidth = 266 * 3; }
		$("#footer .footerBlock").width(newWidth);
		$("#footer ul").width(newWidth + 20);
		$("img.levering").css({left: $("#footer .footerBlock").width()});
	});
	$(window).resize();
	
	// ShowRoom Tab:
	$("#showRoomTab").hover(function(){
		$(this).stop().animate({top: 0}, "fast");
	}, function(){
		$(this).stop().animate({top: -65}, "fast");
	});
});

Cufon.replace('.AkzidenzMedium, .content-box h1', {fontFamily:'AkzidenzMedium'});
Cufon.replace('.AkzidenzLight, .content-box h2, .content-box h3', {fontFamily:'AkzidenzLight'});
Cufon.replace('#menu .cufon',{
	fontFamily:'AkzidenzMedium',
	color:'-linear-gradient(#595959,#070707)'
});
