
$(document).ready(function(){
			
			// init blocker for preloading
			$('div#wraper.post').block({ css: { backgroundColor: 'transparent', color: '#000', border: 'none', width: 'auto', left: '50%', top: '150px'}, overlayCSS: { backgroundColor: '#fff', opacity: '1', border: '1px solid #e4e4e4', width: '858px', height: '643px' }, message: '<p><img src="/_lib/images/waitanimation.gif" /></p>', centerY: false });
			
			// hide project images
			$("#wraper2.post img").hide();
			
			// teaser image preloader
			if ($('#teaser-img').length >= 1 )	{
				var teaserImg = $('#teaser-img').attr("src");
				$('#teaser-img').attr("src","");
				var urls = [teaserImg];

				//$('#wraper').css("border","1px solid #e4e4e4");
		
				$.preload( urls, {
						onComplete:function( data ){
							var img = new Image();
							img.src = data.image;
							
							$('#teaser-img').attr({ src: img.src});
						},
						onFinish:function(){

      				// resize preloader area
      				//if ($.browser.msie) { $('#wraper').css({'border':'none','padding-left':'1px','padding-top':'1px'}); };
      				$('#wraper').animate({'height':$('#teaser-img').height()},500, function() { $("#teaser-img").css({'visibility': 'visible'}); $('#content-teaser, #content-special, .sIFR-flash').css('visibility','visible'); $('#wraper.post').unblock({onUnblock: function(){ $("#wraper2.post img").fadeIn("slow"); $('#pager-bottom').fadeIn('slow'); } }); });
      				//$('#wraper.post').animate({'height':'645px'},500, function() { $("#teaser-img").css({'visibility': 'visible'}); $('#content-teaser, #content-special, .sIFR-flash').css('visibility','visible'); $('#wraper.post').unblock({onUnblock: function(){ $("#wraper2.post img").fadeIn("slow"); $('#pager-bottom').fadeIn('slow'); } }); });
      				$("#teaser-img").animate({'opacity': '1.0'}, 1000);
      				//$('#wraper').animate({'borderTopColor': 'white','borderBottomColor': 'white','borderLeftColor': 'white','borderRightColor': 'white'}, 500, function() {
      					//$('#wraper').css({'border':'none','padding-left':'1px','padding-top':'1px','margin-bottom':'1px'});
						
						// init sub images loader
						//$("#wraper2 img").fadeIn("slow");
						//$('#pager-bottom').fadeIn('slow');
      					
      				//});
					}
				});
			}
			
			// end - preload

	// load tooltip
	$('#pager a, #pager-bottom a').tooltip({
		showURL: false,
    	extraClass: "pager", 
    	fixPNG: true,
    	top: -20,
    	track: false
	});
	
	//fancybox
	
	$("a.iframe").fancybox({ 'width': 880, 'height': 600, 'padding':0, 'titleShow': false, 'overlayShow': false });
	
	jQuery.fn.getTitle = function() {
			var arr = jQuery("a.fancybox");
			jQuery.each(arr, function() {
				var title = jQuery(this).children("img").attr("title");
				jQuery(this).attr('title',title);
			})
		}

		// Supported file extensions
		var thumbnails = 'a:has(img)[class$="fancybox"],a:has(img)[href$=".gif"],a:has(img)[href$=".jpg"],a:has(img)[href$=".jpeg"],a:has(img)[href$=".png"],a:has(img)[href$=".GIF"],a:has(img)[href$=".JPG"],a:has(img)[href$=".JPEG"],a:has(img)[href$=".PNG"]';
	
		jQuery(thumbnails).addClass("fancybox").attr("rel","fancybox").getTitle();

			jQuery("a.fancybox").fancybox({
			'imageScale': true,
			'padding': 0,
			'zoomOpacity': true,
			'zoomSpeedIn': 300,
			'zoomSpeedOut': 300,
			'zoomSpeedChange': 300,
			'overlayShow': false,
			'overlayColor': "#666666",
			'overlayOpacity': 0.3,
			'enableEscapeButton': true,
			'showCloseButton': true,
			'hideOnOverlayClick': true,
			'hideOnContentClick': false,
			'frameWidth':  560,
			'frameHeight':  340,
			'callbackOnStart': null,
			'callbackOnShow': null,
			'callbackOnClose': null,
			'centerOnScroll': false,
			'titleShow': false
		});
	
	
		});
		
$(window).load(function()
		{
			if($("#home_slideshow").length) {
				setTimeout('init_first()',5000)
			}
		})
	
		init_first = function() {
			teaser_height = $("#content-teaser").height()+'px';
			teaser_width = $("#content-teaser").width()+'px';
			// set dimensions teaser container
			$('#content-teaser, #home_slideshow_violator').css({'width' : teaser_width, 'height' : teaser_height})
			
			$('#content-teaser h1').fadeOut('fast', function () { 
	      		
				$('#content-teaser').remove()
				$("#home_slideshow_violator").animate({ 
       				width: "34.625em",
       				height: "1.938em"
      			}, 500, 'linear', function () { $('#init_slide').remove(); init_slideshow() } );
      		
			})
		}
		
		init_slideshow = function()
		{
			$('#home_slides').fadeIn('slow')
			$('#home_slides').cycle({
				fx:'fade',
				timeout:8000,
				//pager:'#slide_navigation',
				after:update_slide_caption,
				before:fade_slide_caption
			})
		}
		
		fade_slide_caption = function(next, previous, opts)
		{
			caption_container = $('#project_caption')
			caption_container.fadeOut('fast')
			
		}
		
		update_slide_caption = function(next, previous, opts)
		{
			caption_container = $('#project_caption')
			
			caption = $('span.slide_caption', previous)
			caption_container.fadeIn('fast')
			caption_container.html(caption.html())
			
		}