$(document).ready( function(){
	$( 'p.employee_list' ).hide();
	$( 'h3.employee_list_title' ).click(
		function() {
			var element_id = '#employee_list'+$( this ).attr( 'id' );
			if( $( element_id+':hidden' ).length == 1 ) {
				if( $( 'p.employee_list:visible' ).length != 1) {
					$( element_id ).show();
				} else {
					$( 'p.employee_list:visible' ).hide();
					$( element_id ).show();
				}
			}
		}
	);

	$( 'a.employee' ).click(
		function() {
			$( 'div#contentSmall div' ).hide();
			address = 'http://'+window.location.hostname+$( this ).attr( 'href' );
			$.ajax( { url: address, cache: false, success:
				function( htmlreturn ){
			    	$( 'div#contentSmall div' ).html( htmlreturn );
			    	$( 'div#contentSmall div' ).show();
				}
			});
			return false;
		}
	);

	activeBannerImg = 1;
	$( '.imageChange').click(
		function(){
			id = $( this ).attr( 'id' );
			$( '#bannerMultiple #large_'+activeBannerImg).fadeOut( 'fast',
				function( ){
					if( id == 'small_2' ){
						activeBannerImg = 2;
						$( '#bannerMultiple #large_2').fadeIn('fast');
					}
					if( id == 'small_3' ){
						activeBannerImg = 3;
						$( '#bannerMultiple #large_3').fadeIn('fast');
					}
				}
			);
		}
	);
	$( '.imageChange').mouseout(
		function(){
			if( activeBannerImg != 1) {
				$( '#bannerMultiple #large_' + activeBannerImg ).fadeOut( 'fast',
					function( ){
						$( '#bannerMultiple #large_1').fadeIn('fast');
						activeBannerImg = 1;
					}
				);
			}
		}
	);

	$( '#fastAccess #quickLinks' ).change(
		function() {
			url = $('#quickLinks option:selected').val();
			if( url != '0' && url != '' ){
				if( url == 'http://www.infolite.ch' ){
					window.open( url, '_blank', '' );
				} else {
					window.open( url, '_self', '' );
				}
			}
		}
	);

	$( 'select.categorySelector' ).change(
		function() {
			url = $('select.categorySelector option:selected').val();
			if( url != '0' && url != '' ){
				window.open( url, '_self', '' );
			}
		}
	);
	$( 'select.yearSelector' ).change(
			function() {
				url = $('select.yearSelector option:selected').val();
				if( url != '0' && url != '' ){
					window.open( url, '_self', '' );
				}
			}
	);

	$( 'span.mapName' ).hover(
		function(){
			$( 'img.map' ).hide();
			$( '#map' + $( this ).attr( 'id' ) ).show();
			$( 'span.mapName' ).removeClass("active");
			$( this ).addClass("active");
		}
		,
		function(){}
	);

	if ($.browser.msie && $.browser.version.substr(0,1)<8) {
		$( 'table.fieldOfWork' ).attr( 'cellSpacing', '24' );
	}

	$('#modalTrigger').click(function(e) {
		e.preventDefault();
		var winW = $(window).width();
		var winH = $(window).height();
		$('#modalMask').css({'width':$(document).width(),'height':$(document).height()})
					   .fadeIn(500)
					   .fadeTo('fast',0.8);
		$( "#modalContent" ).html( $( "#modalSource" ).html() )
						    .css('left', winW/2-874/2)
						    .css('top',  winH/2-500/2)
						    .fadeIn(2000);
		VideoJS.setup( $( "#modalContent video" )[0] );
		$( "#modalSource video" ).height( 480 ).width( 854 );
		$('#modalContent .close, #modalMask').click(function (e) {
			e.preventDefault();
			$('#modalMask, #modalContent').hide();
			$('#modalContent').html('');
		});

		$(window).resize(function() {
			$( "#modalContent" ).css('left', $(window).width()/2-874/2)
		   					    .css('top',  $(window).height()/2-500/2);

			$('#modalMask').css({'width':$(window).width(),'height':$(document).height()});
		});
	});
	$('#modalTrigger2').click(function(e) {
		e.preventDefault();
		var winW = $(window).width();
		var winH = $(window).height();
		$('#modalMask2').css({'width':$(document).width(),'height':$(document).height()})
		.fadeIn(500)
		.fadeTo('fast',0.8);
		$( "#modalContent2" ).html( $( "#modalSource2" ).html() )
		.css('left', winW/2-660/2)
		.css('top',  winH/2-380/2)
		.fadeIn(2000);
		VideoJS.setup( $( "#modalContent2 video" )[0] );
		$( "#modalSource2 video" ).height( 360 ).width( 640 );
		$('#modalContent2 .close, #modalMask2').click(function (e) {
			e.preventDefault();
			$('#modalMask2, #modalContent2').hide();
			$('#modalContent2').html('');
		});

		$(window).resize(function() {
			$( "#modalContent2" ).css('left', $(window).width()/2-660/2)
			.css('top',  $(window).height()/2-380/2);

			$('#modalMask2').css({'width':$(window).width(),'height':$(document).height()});
		});
	});

	$( 'a.historyBack' ).click( function(){ history.back(); return false; } );

	$( '.tableDownloads' ).each(
		function()
		{
			var table = $( this );
			if( table.find( 'tr' ).length > 6 ) {
				table.find( 'tr.pager td' ).click(
					function(){
						if( table.find( 'tr:hidden' ).length > 0 ) {
							table.find( 'tr:hidden' ).fadeIn(200);
							table.find( '.pager .more' ).hide();
							table.find( '.pager .less' ).show();
						} else {
							table.find( 'tr[class!=pager]' ).each(
								function( index ){
									if( index > 4 ){
										$( this ).hide();
									}
								}
							);
							table.find( '.pager .more' ).show();
							table.find( '.pager .less' ).hide();
						}
					}
				);
				table.find( 'tr[class!=pager]' ).each(
						function( index ){
							if( index > 4 ){
								$( this ).hide();
							}
						}
					);
				table.find( '.pager div' ).show()
				table.find( '.more' ).show();
			}
		}
	);
});




















