(function($){ init = function(){			
			
	var w = window,d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0],x=w.innerWidth||e.clientWidth||g.clientWidth,y=w.innerHeight||e.clientHeight||g.clientHeight;	

	var margin_x = 0;
	var margin_y = 0;
	var padding = 20;

	$('#left').css('width',x/2 - margin_x);
	$('#left').css('height',y - margin_y);

	$('#right').css('width',x/2 - margin_x);
	$('#right').css('height',y - margin_y);	
	$('#right').css('left',x/2);

	var w = x/2 - margin_x - padding;

	$('.box').css('width', w);	
	$('.box').css('height',(y-margin_y)/2 - padding);

	$('#year_tags').css('height',(y-margin_y)/2 - padding- 36);	
	$('#year_tags').css('width',w/6);	

	$('#category_tags').css('height',(y-margin_y)/2 - padding- 36);
	$('#category_tags').css('width',w/4);


	$('#content_tags').css('height',(y-margin_y)/2 - padding- 36);
	$('#content_tags').css('padding-left',60);	
	$('#content_tags').css('width',w/3);

	$('.entry').css('width', w - (x/16)-20);
	$('.project_indent').css('margin-left', (x/16));

	$('#headline-visual').text('Projects–visual');
	$('#project_txt').show();
	$('#keywords').show(); 
	$('#intro').show();
				
	// waiting time before scroll action happens				
	
	var counterLimit = 	500;
	var action;	
	// what happens when you hover over the titles?
	$('.entry').hover(function(){
		var elem = $(this);
		$(this).css('cursor','pointer');
		var id = $(this).attr('id');
		$('.' + id).css('border-bottom',$('#color-' + id).css('background-color') +  ' 4px solid');
		$('#single-' + id).css('background-color', $('#color-' + id).css('background-color'));
		$('strong[id$=' + id + ']').css('background-color',$('#color-' + id).css('background-color'));
		$('strong[id$=' + id + ']').css('color','#fff');

		action = setTimeout(function(){
		$('#project_images').stop().animate({scrollTop: $('#single-' + id).offset().top - 44 - $('#project_images').offset().top + $('#project_images').scrollTop()}, 1000);},counterLimit);

		}, function() {
		clearTimeout(action);
		$(this).css('cursor','auto');
		var id = $(this).attr('id');

		$('.' + id).css('border-bottom','white 4px solid');		
		$('#single-' + id).css('background-color','white');
		$('strong[id$=' + id + ']').css('background-color','transparent');
		$('strong[id$=' + id + ']').css('color','black');
		});
				
	// what happens when you click on a title?
	$('.entry').click(function(){
		var id = $(this).attr('id');
		$('#single-' + id).click();
	});
		
	
	// what happens when you hover over the images?
	$('.img').hover(function(){
			$(this).css('cursor','pointer');
			var id = $(this).attr('id');
			id = id.substring(6,id.length);
	
			$('strong[id$=' + id + ']').css('background-color',$('#color-' + id).css('background-color'));
			$('strong[id$=' + id + ']').css('color','#fff');	
			
			$('#single-' + id).css('background-color',$('#color-' + id).css('background-color'));	
			$('.' + id).css('border-bottom',$('#color-' + id).css('background-color') +  ' 4px solid');		
			$(this).css('border-bottom','black 4px solid');
		
			action = setTimeout(function(){$('#project_txt').stop().animate({scrollTop: $('#' + id).offset().top - 40 - $('#project_txt').offset().top + $('#project_txt').scrollTop()}, 1000);},counterLimit);
		}, function() {
			$(this).css('cursor','auto');
			var id = $(this).attr('id');
			id = id.substring(6,id.length);
			clearTimeout(action);
			$('strong[id$=' + id + ']').css('background-color','transparent');
			$('strong[id$=' + id + ']').css('color','black');				
			$('#single-' + id).css('background-color','white');	
			$('.' + id).css('border-bottom','white 4px solid');		

			$(this).css('border-bottom','white 4px solid');
		});		
		
		// what happens when you hover over the little text boxes?
		$('.single-link').hover(function(){
			$(this).css('cursor','pointer');
			var id = $(this).attr('id');
			id = id.substring(7,id.length);
	
			$('strong[id$=' + id + ']').css('background-color',$('#color-' + id).css('background-color'));
			$('strong[id$=' + id + ']').css('color','#fff');
			$('.' + id).css('border-bottom',$('#color-' + id).css('background-color') +  ' 4px solid');		
			$(this).css('background-color','black');
		
			action = setTimeout(function(){$('#project_txt').stop().animate({scrollTop: $('#' + id).offset().top - 40 - $('#project_txt').offset().top + $('#project_txt').scrollTop()}, 500);},counterLimit);

		}, function() {	
			clearTimeout(action);
			$(this).css('cursor','auto');
			var id = $(this).attr('id');
			id = id.substring(7,id.length);
			$('strong[id$=' + id + ']').css('background-color','transparent');
			$('strong[id$=' + id + ']').css('color','black');						
			$('.' + id).css('border-bottom','white 4px solid');		
	
			$(this).css('background-color','white');
		});			
				
		// BEGIN CATEGORY TAGS
		$('.categorytag').click(function(){ 		
			var catname = $(this).attr('category'); 				
			var active = $(this).attr('active');
		
			if(active == 'false'){				
				$('.categorytag').css('background-color','transparent');	
				$('.categorytag').css('color','black');	
				$('.categorytag').attr('active','false'); 			

				$(this).css('background-color','red');	
				$(this).css('color','white');	
				$(this).attr('active','true');
			}else{		
				$(this).css('background-color','transparent');	
				$(this).css('color','black');	
				$(this).attr('active','false'); 	
				catname = "";
			}

			$('.entry').each(function(){		
				var entry_element = $(this);
				var categories = $(entry_element).attr('categories');		
				var visible = false;			
	
				if(catname === ""){			
				visible = true;		
				}else{		
					categories = categories.split(',');		
					for(i = 0; i < categories.length; i++){		
						if(categories[i] === catname){
						visible = true; 		
						break;	
						}
					}			
				}		

				var id = $(entry_element).attr("id");
				if(visible == false){		
					$(entry_element).hide();		
					$('.'+id).hide(); $('#single-'+id).hide();
				}else{ 		
					$(entry_element).show();							
					$('.'+id).show();$('#single-'+id).show();
				}	
			});
		});
		// END CATEGORY TAGS	
		// BEGIN CONTENT TAGS
		$('.tag').click(function(){ 		
			var tagname = $(this).attr('tag'); 			
			var tagtype = $(this).attr('type');			
			var active = $(this).attr('active');
		
			if(active == 'false'){				
				$('.tag').css('background-color','transparent');	
				$('.tag').css('color','black');	
				$('.tag').attr('active','false'); 			

				$(this).css('background-color','red');	
				$(this).css('color','white');	
				$(this).attr('active','true');
			}else{		
				$(this).css('background-color','transparent');	
				$(this).css('color','black');	
				$(this).attr('active','false'); 	
				tagname = "";
			}

			$('.entry').each(function(){		
				var entry_element = $(this);	
				var tags = "";	
				if(tagtype === 'content'){
				 tags = $(entry_element).attr('tags');	
				}else{ 	
					if(tagtype === 'category'){		
				 	tags = $(entry_element).attr('categories');	
					}else{ 	
					if(tagtype === 'year'){		
				 	tags = $(entry_element).attr('year');	
					}	
				}	
				}		

				var visible = false;			
				if(tagname === ""){			
				visible = true;		
				}else{		
					tags = tags.split(',');		
					for(i = 0; i < tags.length; i++){		
						if(tags[i] === tagname){
						visible = true; 		
						break;	
						}
					}			
				}		

				var id = $(entry_element).attr("id");
				if(visible == false){		
					$(entry_element).hide();		
					$('.'+id).hide(); $('#single-'+id).hide();
				}else{ 		
					$(entry_element).show();							
					$('.'+id).show();$('#single-'+id).show();
				}	
			});
		});
		// END CONTENT TAGS		

				
		// get screen resolution,  scale it down to 800px width and save proportion		
		var x_width = x/x;		
		var y_height = y/x;		
		var html_width = x_width * 800;		
		var html_height = y_height * 800;			

		var amountPosts = 30;
		for(i = 0; i < amountPosts; i++){
			$(".photo_group" + i).colorbox({rel:"photo_group" + i, transition:"none",maxWidth:"95%", maxHeight:"100%",
		opacity:"0.7", next:"next", previous:"previous", close:"close",current:"Slide {current} of {total}"});			
			$(".photo_group"+i+".vimeo").colorbox({iframe:true, innerWidth:"70%", innerHeight:"70%"});		
			$(".photo_group"+i+".html").colorbox({innerWidth:html_width + "px", innerHeight:html_height+"px",scrolling:false});		
		}
		
		var block_width = x_width * 20;
		var block_height = y_height * 20;
		$(".single-link").css("width",block_width );
		$(".single-link").css("height",block_height+4);
		$(".color-block").css("width",block_width );
		$(".color-block").css("height",block_height);	
 };})(jQuery);
