// JavaScript Document
$(window).load(function(){
	onrsz();

	if(swfobject.hasFlashPlayerVersion('8')){
		swfobject.embedSWF(ROOT + "images/loganim.swf", "logo_flash_block", "109", "107", "8.0.0", ROOT + "images/expressInstall.swf", {}, {menu:false, wmode:'transparent'});
		$('#logo').css({marginLeft:'-8px', marginTop:'-1px'});
		swfobject.embedSWF(ROOT + "images/top_banner.swf", "top_banner_flash_block", "522", "270", "8.0.0", ROOT + "images/expressInstall.swf", {}, {menu:false, wmode:'transparent'});
	}
	
	if($('div.gallery_item').length){
		$('div.gallery_item a[class!="title"]').prettyPhoto({theme:'facebook'});
		$('div.gallery_item a[class="title"]').click(function(){
			$(this).parent('div').children('a[class!="title"]').click();
			return false;
		});
	}


	$('#feedback_form').submit(function(){
		$('#feedback_form').children('input,textarea').attr('disabled', 'disabled');
		$('#feedback_form input#feedback_submit').hide();
		$('#feedback_form .loader').show();
		var dataToSend = {};
		$('#feedback_form').children('input[type="text"],input[type="hidden"],textarea').each(function(){
			dataToSend[$(this).attr('name')] = $(this).val();
		});
		$.post(
			$('#feedback_form').attr('action'),
			dataToSend,
			function(data){
				alert(data);
				if(data == '1'){
					alert('Письмо успешно отправленно!');
				}else{
					alert('Письмо не было отправленно!');
				}
				$('#feedback_form').children('input,textarea').removeAttr('disabled');
				$('#feedback_form input#feedback_submit').show();
				$('#feedback_form .loader').hide();
			}
		);
		return false;
	});
});

function onrsz(){
	if($('.center_block_content').html()){
		var hh;
		if($('td.c1').height())
			hh = Math.max($('.center_block_content').outerHeight(), $('td.c1').height());
		else
			hh = $('.center_block_content').outerHeight()
		$('.center_block_bg img').height(hh);
		$('.center_block_content').css({marginTop:-hh});
		$('.center_block_bg').mousedown(function(){return false;});
	}
}
