
$(document).ready(function() {
	$(".gallery a").fancybox();
	$('a[target="_fancybox"]').fancybox();

	if($('.mainMedia .slider img').length>1) {
	    $('.mainMedia .slider').cycle({
			  fx: 'fade',
			  //pager:  '.mainMedia-pager'
			  speed : 2000
			 });
	}
	if($('.list-slider img').length>1) {
	    $('.list-slider').cycle({
			  fx: 'fade'
			 });
	}
	//$('a.media').media();
	// ie7-hack
/*
	if ($.browser.msie && $.browser.version.substr(0,1)==7) {
		$('.nav ul').each(function() {
			$(this).css({
				'margin-left' : '-'+$(this).parent().width()
			})
		});
	}
*/
	var calcShip = function() {
			$(this).parents('form').append('<input type="hidden" name="justReload" value="1"/>');
			//$(this).parents('form')[0].submit();
			var url = $('.mailform form').attr('action')+'?'+$('.mailform form').serialize();
			url+=' .mailform';
			$.fancybox(
					'.. loading ..',
					{
			        		'autoDimensions'	: false,
						'width'         		: 350,
						'height'        		: 'auto',
						'transitionIn'		: 'none',
						'transitionOut'		: 'none'
					}
					);	
			$('.mailform').load(url,function() {
				$('.recalcShip').unbind('change').change(calcShip);
				$.fancybox.close();
			});
	};
	$('.recalcShip').unbind('change').change(calcShip);
	
	
	
	if($('.Ierror')[0]) {
		$('html, body').animate({scrollTop:$('.Ierror:eq(0)').offset().top}, 'fast',
			function() {
					$.fancybox(
					'<h2>'+$('h1').text()+'</h2><p style="color:red">'+$('legend').text()+'</p>',
					{
			        		'autoDimensions'	: false,
						'width'         		: 350,
						'height'        		: 'auto',
						'transitionIn'		: 'none',
						'transitionOut'		: 'none'
					}
					);	
			}
		
		);
			
	}
	
});
