/**
 *	Made by Maarten van Spil
 *	Insyde 2009
 */
// include jquery cookie plugin for saving fontsize state clientside
document.write('<scr'+'ipt type="text/javascript" src="script/jquery.cookie.js"><\/scr'+'ipt>');
document.write('<scr'+'ipt type="text/javascript" src="script/jquery.filestyle.js"><\/scr'+'ipt>');

$(document).ready(function(){
	// set vars
	var cookieName = 'vanruysdael_fontsize';
	var fontsizeLinkColor = '#999999';
	var activeFontsizeIndicatorColor = '#404040';
	var smallFontsize = '1em';
	var biggerFontsize = '1.1em';
	var BiggestFontsize = '1.2em';
	
	if($.cookie(cookieName) != 0)
	{
		$('html').css('font-size', $.cookie(cookieName));
		if($.cookie(cookieName) == smallFontsize)
		{
			$('#fontsizepicker a').css('color', fontsizeLinkColor);
			$('#fontsize_small').css('color', activeFontsizeIndicatorColor);
		}
		if($.cookie(cookieName) == biggerFontsize)
		{
			$('#fontsizepicker a').css('color', fontsizeLinkColor);
			$('#fontsize_bigger').css('color', activeFontsizeIndicatorColor);
		}
		if($.cookie(cookieName) == BiggestFontsize)
		{
			$('#fontsizepicker a').css('color', fontsizeLinkColor);
			$('#fontsize_biggest').css('color', activeFontsizeIndicatorColor);
		}
 	}
	
	// small font size
  	$("#fontsize_small").click(function(){
	  	$('#fontsizepicker a').css('color', fontsizeLinkColor);
		$(this).css('color', activeFontsizeIndicatorColor);
	    $('html').css('font-size', smallFontsize);
		$.cookie(cookieName, smallFontsize, { path: '/' });
	    return false;
  	});
  	// bigger font size
	$("#fontsize_bigger").click(function(){
		$('#fontsizepicker a').css('color', fontsizeLinkColor);
		$(this).css('color', activeFontsizeIndicatorColor);
		$('html').css('font-size', biggerFontsize);
		$.cookie(cookieName, biggerFontsize, { path: '/' });
		return false;
	});
  	// biggest font size
  	$("#fontsize_biggest").click(function(){
	    $('#fontsizepicker a').css('color', fontsizeLinkColor);
		$(this).css('color', activeFontsizeIndicatorColor);
		$('html').css('font-size', BiggestFontsize);
		$.cookie(cookieName, BiggestFontsize, { path: '/' });
	    return false;
  	});
  
 	 // form button hover
  	$(".button").hover(
	  	function(){
	  		$(this).css('background-color', '#404040');
	  	},
	  	function(){
	  		$(this).css('background-color', '#999999');
	  	}
	);
	
	//file inputs stylen
	$("input[type=file]").filestyle({ 
		image: "img/file_input_button.gif",
		imageheight : 21,
		imagewidth : 60,
		width : 298
	});
	
	//calculator weergeven
	$("a.aantalmaatvorm").click(function(){
		$("div#glasscalculator").css('visibility', 'visible');
	});
	
	//opslaan en sluiten
	$('a#saveandexit').click(function(){
		$("div#glasscalculator").css('visibility', 'hidden');
	});
	
	//projectafbeelding wijzigen
	$('ul.projectfotos li a').each(function(){
		//for each thumb link do the following
		var fotoSRC = $(this).attr("href");
		$(this).click(function(){
			$('#projectafbeelding_groot').attr('src',fotoSRC);
			$('ul.projectfotos li').removeClass('hier');
			$(this).parent().addClass('hier');
			return false;
		});
	});
});
