function loader_start( )
{
	var loader = new Image( );
	loader.src = assets_url + 'images/loader.gif';
	loader.id = 'loader';
	$("#projects").prepend( loader );
}

$(window).load( function(){
	$("#loader").remove( );
});

$(document).ready( function( ){

	loader_start( );
	
	$(".projects dd").each( function( ){
		$(this).toggle( );
	});
	
	$(".projects dt").click( function( ){
		$(this).next("dd").slideToggle( );
		$(this).toggleClass( "active" );
	});

	$(".img img").click( function( ){
//		var imgZoomedSrc = replace( 'thumb_', '', $(this).attr( "src" ) );
//		new Image( );
//		imgZoomedSrc
	});

	$('input[@name=year]').click( function(){
		filterByYear( this );
		filterProjects( );
	});

	
	$('input[@name=technology]').change( function(){
			var techs = [];
			$('input[@name=technology]:checked').each(function(){
				techs.push( this.value );
			});

			$('.technologies').each(function(){
				temp = [];
				$( "img", this ).each(function(){
					for( i in techs )
					{
						if( techs[i] == $(this).attr( "alt" ) )
						{
							temp.push( 1 );
							return;
						}
					}
				});
				fVisible = ( ( temp.length == techs.length && techs.length > 0 ) ? 1 : 0 );
				
				$(this).parents(".projects").attr( "showT", fVisible );
			});
			filterProjects( );
	} );
	
	//startup
//	$(".projects").attr( "showY", 0 ).attr( "showT", 0 );
	
	$('input[@name=year]').each(function(){
//		filterByYear( this );
	});
	$('input[@name=technology]:first').change( );
});


	function filterByYear( obj )
	{
		var year = obj.getAttribute( "value" );
		var fVisible = ( obj.checked ? 1 : 0 );
		$('[@id*=year-'+ year +']').attr( "showY", fVisible );
	}
	
	function filterProjects( )
	{
	//	alert( "filterProjects" );
		$(".projects").each(function( ) {
	//		alert( $(this).html( ) );
	//		alert( $(this).attr( "showY" ) +"\n\n"+ $(this).attr( "showT" ) );
	//			+"\n\n\n\n"+ ( $(this).attr( "showY" ) && $(this).attr( "showT" ) ) );
	
	//		alert( typeof( $(this).attr( "showY" ) && $(this).attr( "showT" ) ) );
			if( $(this).attr( "showY" ) == 1 )//&& $(this).attr( "showT" ) == 1 )
			{
	//			alert( "show me" );
				$(this).show( "slow" );
			}
			else //if(  $(this).css( "display" ) != "none" )
			{
	//			alert( "hide me" );
				$(this).hide( "slow" );
			}
		});
	}
	
	function selectAll( objName )
	{
		$('input[@name='+ objName +']').click( );
	}