
m = document.createElement( 'modernizr' );
m_style = m.style;

function test_props_all( prop, callback ) {
    var uc_prop = prop.charAt(0).toUpperCase() + prop.substr(1),
    props = [
        prop,
        'webkit' + uc_prop,
        'Moz' + uc_prop,
        'moz' + uc_prop,
        'o' + uc_prop,
        'ms' + uc_prop
    ];

	for ( var i in props ) {
        if ( m_style[ props[i] ] !== undefined && ( !callback || callback( props[i] ) ) ) {
            return true;
        }
    }
}

var center = ($(document).width()) / 2;

$(function () {
	$(".images li a").not(".movies").fancybox();
	$(".movies li a").fancybox();			
	$("li a.movies").fancybox();			
	$(".panoramic li a").fancybox({
		autoScale: false,
		type:'ajax',
		width:800,
		height:600,
		onComplete : function() { 
			$("#widePhoto").mousemove( function (e) {
				var img = document.getElementById("panoramic");
				var width = img.width;		
				var coeficient = (width-800)/800;
				var positionAbsoluteScreen = e.pageX;
				var positionAbsoluteWidePhoto = positionAbsoluteScreen-(center-400);
				$("#panoramic").css("left", (positionAbsoluteWidePhoto*coeficient)*(-1));
			});
		}
	});		
	
	if ( !test_props_all('transitionProperty') ) {
		$("#index li img").css( { border: '1px solid #bfbfbf', marginTop : "-2px", marginLeft: "58px", padding: "2px" } );		
		$("#index li").hover(
			function () {					
				$(this).find("img")
					.animate({ marginTop: "-5px", marginLeft: "55px", padding: '5px' }, 100, 'linear', function () {
						$(this).css( { border: '1px solid #c21515' } )
					});
			},
			function () {		
				$(this).find("img")
					.animate({ marginTop: "-2px", marginLeft: "58px", padding: '2px'  }, 100, 'linear', function () {
						$(this).css( { border: '1px solid #bfbfbf' } )
				});
			}
		);	
	}
		
	$("#index li").hover(
		function () {					
			$(this).find("p.title")
				.css({ borderBottom: '1px solid #c21515' })
				.animate({ paddingBottom: '2px' }, 100, 'linear');			
		},
		function () {
			$(this).find("p.title").animate({ paddingBottom: '5px' }, 'fast', 'linear', function () { 
				$(this).css( { borderBottom: '0px solid #c21515' } )
			});			
		}
	);	
	
	$("nav").find("a").not(".selected").hover(
		function () {						
			$(this).css({ borderBottom: '1px solid #c21515' });
			$(this).animate({ paddingBottom: '2px' }, 100, 'linear');
		},
		function () {			
			$(this).animate({ paddingBottom: '10px' }, 'fast', 'linear', function () { $(this).css({ borderBottom: '0px solid #c21515' }) });
		}
	);	
});
