// JavaScript Document

var opencontent = true;

$(document).ready(function(){	
		   		   
			
			$('a.email').nospam({
				replaceText: true,
				filterLevel: 'low'
			});  
			
			$("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 14000, true);

			$("ul.tabs").tabs("div.panes > div");
			
			function init_gallery(){
				$(".cikkek img").each(function(){
					$(".cikkek img").parent().addClass('fancy');							
				});
				
				$(".fancy").fancybox(
					{
						'padding'			: 1,
						'zoomOpacity'			: true,
						'overlayShow'			: false,
						'zoomSpeedIn'			: 500,
						'zoomSpeedOut'			: 500
				}); 
			
			}
			
			init_gallery();
			
			function price(){
				var price = 0;
				var shipment = 0; 
				var quantity = 0;
				$('.quantity').each(function(){
					var obj = $(this);
					if(obj.attr('value') !=''){
						price += parseInt(obj.attr('value')) * parseInt(obj.parent().parent().children('input').attr('value'));
						quantity += parseInt(obj.attr('value'))
					}
				});	
				
				if($('#OrderNextMagazin').attr('value') == '3 lapszámot 2600 Ft-ért'){
					price += 2600;
					shipment += 3*380;
				}
				if($('#OrderNextMagazin').attr('value') == '6 lapszámot 6500 Ft-ért'){
					price += 6500;
					shipment += 6*380;
				}				
				
				if(quantity == 1){ 
					shipment += 380;
				}
				
				if(quantity == 2){ 
					shipment += 640;
				}
				
				if(quantity > 2 && quantity < 6){ 
					shipment += 840;
				}
				
				if(quantity > 5){
					shipment += 1690;
				} 
				
				$('.total').text(price + ' Ft + ('+ shipment +' Ft postaköltség) = '+ (price + shipment) +' Ft' );
			}
			
			
			$('.quantity').each(function(){
				if($(this).attr('value') !=''){
					$(this).parent().parent().show();
				}
				else {
					$(this).parent().parent().parent().children('.order_checkbox').attr('checked', false);
				}
			});
			
			
			$('.order_checkbox').change(function (){
				var obj = $(this);
				
				if(obj.is(':checked') )
				{
					obj.parent().children('.order_item').children('.input').children('.quantity').attr('value', 1);
					obj.parent().children('.order_item').show();
					price();
				}else{
					obj.parent().children('.order_item').children('.input').children('.quantity').attr('value', '');
					obj.parent().children('.order_item').hide();
					price();
				}
			});
			
			
			
			price();
			
			$('.quantity, #OrderNextMagazin').change(function (){
				price();
			});
			
			$(".tabs a").hover(

				function () {
					$(this).stop().animate({ paddingTop: "0px", paddingBottom: "10px" }, 200);
				}, 
	
				function () {
					$(this).stop().animate({ paddingTop: "10px", paddingBottom: "0px" }, 200);
				}
	
			);
			
			$('.send_mail_box .text input, .send_mail_box textarea').click(function(){$(this).attr({value: ''}) }).focus(function(){$(this).attr({value: ''}) });
					
			
			
});
