function intoPdf(url, actor) {
		
	$("#pdf_link_container").removeClass('visible_hide').addClass('visible_show');
	
	$.post(ACTIONROOT+"generate_pdf/url_to_session.php", { 
		url: url, 
		actor: actor },
  	function(data){
   		showMessage(data);	
  });
}


/* pdftool */

function PDFTOOL() {
	
	this.isOpen=false;
	this.ImageInPdftoolbox=ImageInPdftoolbox;
	this.cleanSession=0;
	
	this.init = function(e) {
		
		$('#create_your_own_pdf').click(function(e) {
			pdftool.openPdftoolBox();
			e.preventDefault();
		});
					
		$('#pdftoolbox .inactiveBtn').click(function() {
			pdftool.openPdftoolBox();
			$(this).hide();
			$('#pdftoolbox .activeBtn').show();
		}) 
		
		$('#pdftoolbox #write_your_pdf').click(function() {
			$('#pdftoolbox .inactiveBtn').show();
				//window.open(ACTIONROOT+"generate_pdf/create_session_pdf.php", "generatePdf");
				pdftool.closePdftoolBox();
		});
		
		$(".parent").hover(function () {
			$(this).children(".pdficon").show();
			}, function () {
			$(this).children(".pdficon").hide();
		});
		
		
		$("#pdftoolbox ul").sortable({
			update : function () {	
				pdftool.sendImagesToPdf();
			}
		});
	
		$("#pdftoolbox #inner #images").sortable();
		$("#pdftoolbox #inner #images").disableSelection();
		
				
		$('#closePdftoolbox').click(function() {
			$('#pdftoolbox .activeBtn').hide();
			$('#pdftoolbox .inactiveBtn').show();
			pdftool.closePdftoolBox();
		});
		
		$('#pdftoolbox #deleteAll').click(function() {
			pdftool.cleanSession=1;
			$('#pdftoolbox ul li').remove();
			pdftool.sendImagesToPdf();
		});

	}
	
	this.openPdftoolBox = function() {
		
				
		$('#pdftoolbox').stop().animate({
			'top': 0
		})
				
		
	}
	
	this.closePdftoolBox = function() {
		$('#pdftoolbox').animate({
			'top': -900
		});
	}
	
	this.sendImagesToPdf = function() {
	var query_string="";
	$("#pdftoolbox ul li a.pic").each(
		function()
		{
			query_string += "&url[]=" + this.href +"___"+ this.rel+'___'+$(this).find('img').attr('src');
			
		});

	$.ajax(
		{
			type: "POST",
			url: ACTIONROOT+'generate_pdf/sort.php',
			data: "clean="+pdftool.cleanSession + query_string,
			success: 
				function(data) 
				{
					$("#pdftoolbox ul").html(data);
				},
			error:
				function()
				{
					//console.log("ajax error");
				}
		 });	
	}
	
}	

var pdftool = new PDFTOOL();

$(document).ready(function(e){
	pdftool.init(e);
	
	$('.pdficon').click(function(e) {
		$(this).parent('li.parent').clone().appendTo('#pdftoolbox ul');
		//console.log($(this).next('a').attr('href'));
		pdftool.sendImagesToPdf();
		pdftool.cleanSession=0;
		e.preventDefault();
	});
	
	$('.deleteicon').live('click', function(e) {
		$(this).parent('li.parent').remove();
		pdftool.sendImagesToPdf();
		e.preventDefault();
	});
	
});
