/**
 * 
 * @author «Artod» http://artod.ru/ for ООО «Экспресс лаб»
 * 
 * Copyright (c) 2010 ООО «Экспресс лаб» http://expresslab.ru/
 *
 */

$(document).ready(function(){

	$("a.iframe").fancybox(
	{
		"width" : 770,
		"height" : 610,
		"centerOnScroll": true
	});


	$(function(){
		var n = 0;
		$("img.speccheckbox").attr('src', 'images/checkbox_no_select.gif');
		$("img.speccheckbox").prev().css('display', 'none');
		
		//$("img.speccheckbox").toggle
		$("img.speccheckbox").click(function(){
			if ($(this).attr('src') == 'images/checkbox_no_select.gif') {
				on($(this));
			} else {
				off($(this));
			}
		});
		
		function on(obj) {
			if (n == 12) {
				//alert(n);
				if (confirm("Вы уже выбрали 12 впечатлений. Перейти к оформлению заказа?")) {
					$("a.roz").click();
				}
			} else {
				//alert(n);
				n++;
				obj.attr('src', 'images/checkbox_select.gif');
				obj.prev().attr('checked', 'checked');
			}
		}

		function off(obj) {
			n--;
			obj.attr('src', 'images/checkbox_no_select.gif');
			obj.prev().attr('checked', '');
		}
		
	});


	showUnder();
	showUnder2();

	$('#delivery > input').change(function() {
		showUnder();
	});
	
	$('input.extinfo').parent().find('input').change(function() {
		showUnder2();
	});
	
	function showUnder() {
		$('#delivery > div').hide();
		if ($('#delivery > input:checked').val()) {
			var index = $('#delivery > input').index($('#delivery > input:checked'));
			$('#delivery > div').eq(index).fadeIn();
		}
	}

	function showUnder2() {
		$('div.extinfo').hide();
		if ($('input.extinfo:checked').val()) {
			$('div.extinfo').fadeIn();
		}
	}
	
	$('.nomers-small').click(function() {
	
		var src = $(this).find('img').attr('src').replace('&maxWidth=110&maxHeight=', '&maxWidth=500&maxHeight=350');
		//$("<img>").attr("src", src);
		
		$('#nomers-photo img').fadeOut('fast', function(){
			$(this).remove();
			$('#nomers-photo').append('<img src="'+src+'" style="display:none;" alt="" />');
			//$('#nomers-photo img').attr('src', src);
			$('#nomers-photo img').fadeIn('fast');
		});
	});

});
