﻿$(document).ready(function(){


	/* Псевдо-ссылки */
	$( '.Link' ).makeHover();


	var iMinWidth = 1170;


	$( window ).resize( setPosition );
	setPosition();


	function setPosition(){
		var iOffset = ( $( '#Portfolio' ).width() - iMinWidth ) / 2;
		if( iOffset < 0 ){
			iOffset = 0;
		}
//		$( '#Header' ).css( 'margin-left', iOffset );
//		$( '#Portfolio .Item' ).css( 'padding-left', iOffset );
		$( '#Header' ).stop().animate({
			'marginLeft': iOffset
		}, 100, 'easeInOutQuad' );

		$( '#Contact .Canvas' ).stop().animate({
			'marginLeft': iOffset
		}, 100, 'easeInOutQuad' );

		$( '#Portfolio .Item' ).stop().animate({
			'paddingLeft': iOffset
		}, 100, 'easeInOutQuad' );

	}


	$( '.Preview' ).hover(function(){
		if( $( '#Portfolio' ).width() < iMinWidth ){
			$( this ).data( 'bIsShift', true )
			$( this ).parent().stop().animate({
				marginLeft: -( iMinWidth - $( '#Portfolio' ).width() )
			}, 500, 'easeInOutQuad' )
		}
	}, function(){
		if( $( this ).data( 'bIsShift' ) ){
			$( this ).parent().stop().animate({
				marginLeft: 0
			}, 500, 'easeInOutQuad' )
		}
	});


	$( '#Contact div.Item' ).mouseover(function(){
//		$( this ).children().show().select().focus();
		$( this ).children().show();
	});
	$( '#Contact div.Item' ).mouseout(function(){
		$( this ).children().hide();
	});
	$( '#Contact div.Item input' ).bind('blur, mouseout', function(){
		$( this ).hide();
	})


});


function scrollToPortfolio(){
	$( 'html, body' ).animate({
		scrollTop: $( '#Portfolio' ).offset().top
	}, 500, 'easeInOutCubic');
}

