function update_photo_count()
{
	$.post("ajax/ajaxAddPhotoPrint.php", 
			{ o: "update_photo_count"			
			}, function(data){
				$('span#print_photo_count').html(data);
		});
	
}

function add_photo(photo_id)
{
	$('div#print_photo_ref').html('Добавление...');
	$.post("ajax/ajaxAddPhotoPrint.php", 
			{ 
		       o: "add_photo",
		       photo_id: photo_id			
			}, function(data){
			var bin_link="Фото добавлено в <a href='index.php?o=order' onclick='window.open("+'"'+"index.php?o=order"+'"'+","+'""'+","+'"'+"menubar=yes, toolbar=yes, location=yes, scrollbars=yes,status=yes,resizable=yes,fullscreen=yes"+'"'+");return false;'>корзину</a>";
			//alert(bin_link);
			$('div#print_photo_ref').html(bin_link);
			update_photo_count();
		});
	
}

function load_order_page()
{
	$.post("ajax/ajaxAddPhotoPrint.php", 
			{ 
		       o: "load_order_page"		
			}, function(data){
			$('div#img_block').html(data);
		});
	
}

function delete_photo(photo_id)
{
	$.post("ajax/ajaxAddPhotoPrint.php", 
			{ 
		       o: "delete_photo",
		       photo_id: photo_id	
			}, function(data){
			load_order_page();
		});
//	alert(photo_id);
	
}

function photo_size_shange(photo_id,selected_index)
{
	  // alert(selected_index);
	   $.post("ajax/ajaxAddPhotoPrint.php", 
			{ 
		       o: "photo_size_shange",
		       photo_id: photo_id,
		       selected_index : selected_index
			}, function(data){
			load_order_page();
		});
}

function paper_shange(photo_id,selected_index)
{
	   $.post("ajax/ajaxAddPhotoPrint.php", 
				{ 
			       o: "paper_shange",
			       photo_id: photo_id,
			       selected_index : selected_index
				}, function(data){
				load_order_page();
			});
}

function order()
{
	 if(($('textarea#adressTextarea').attr('value'))&&($('textarea#contactTextarea').attr('value')))
	 {
		 $.post("ajax/ajaxAddPhotoPrint.php", 
					{ 
				       o: "order",
				       adress: $('textarea#adressTextarea').attr('value'),
				       contact: $('textarea#contactTextarea').attr('value'),
				       comment: $('textarea#commentTextarea').attr('value') 
					}, function(data){
					$('div#orderComplete').css('display','block');
					$('div#orderError').css('display','none');
					$('input#orderButton').attr('disabled','disabled'); 
				});
	 }
	 else
	 {
		 $('div#orderError').css('display','block');	 
	 }
		 
}

function photo_count_change(photo_id,new_count)
{
	//alert(new_count);
	if(!isNaN(new_count))
	{
		 $.post("ajax/ajaxAddPhotoPrint.php", 
					{ 
				       o: "count_change",  
				       photo_id: photo_id,
				       new_count : new_count
					}, function(data){
					load_order_page();
				});
	}
	else
	{
		
	}
}

function keyDownNumber(e)
{
 var key = (typeof e.charCode == 'undefined' ? e.keyCode : e.charCode);
  if (e.ctrlKey || e.altKey || key < 58)    return true;
  else    return false;
}



