$(document).ready(function(){
	
			$("div.product").fadeTo("fast", 1);
			
			$("div.product").hover(function(){
					$(this).fadeTo("normal", 0.7); 
				},function(){
					$(this).fadeTo("normal", 1.0);
			});
			
			$("a.big-img").hover(function(){
					$(this).fadeTo("normal", 0.7); 
				},function(){
					$(this).fadeTo("normal", 1.0);
			});	
		
			$("a.img-thumb").hover(function(){
					$(this).fadeTo("normal", 0.7); 
				},function(){
					$(this).fadeTo("normal", 1.0);
			});	

			$("a.fancy").fancybox({
				'autoScale' : false,
				'titleShow'		: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});			
			
			$(".fancyframe").fancybox({
				'width'				: '65%',
				'height'			: '80%',
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
			});
			
			$("#size-chart").fancybox();					

			$("a[rel=gallery]").fancybox({
				'autoScale' : false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
				'titleShow'		: false,
				'titlePosition' 	: 'outside',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-outside">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
      
      
      $('#product_order').submit(function(e) {
        
        var errors = false;
        $('#product_order select.required_option').each(function(){
          if($(this).val()==0){
            alert('Моля, изберете "'+$(this).attr('title')+'" за да продължите.');
            errors = true;
          }
        });
        
        if(errors) return false;
          else return true;
        
      });
      
			$('#product_order_old').submit(function() {
			  
			  var poption = $('#product_options').val();
				if(poption != 'null') return true;
			  	else alert($('#product_options option:first').text());
			  return false;
			});
	
			$('#newsletter_form').live('submit',function(){
				
				$.fancybox.showActivity();

				$.ajax({
					type		: "POST",
					cache	: false,
					url		: "/subscription.php",
					data		: $(this).serializeArray(),
					success: function(data) {
						$.fancybox(data);
					}
				});
				
				return false;

			});
			
		 	$("#newsletterdlg").fancybox({

				'titlePosition'		: 'inside',
				'transitionIn'		: 'fade',
				'transitionOut'		: 'none',
				
				'scrolling'		: 'no',
				'titleShow'		: false,
				
				
			}); 
		
});
