(function ($) {
	$(document).ready(function(){
		var newsButtons = $('a.news-window-trigger');
		var rentButtons = $('a.rent-window-trigger');

	var popWindow = {
		w : $('#pop-window'),
		content : $('#pop-window-content'),
		curtain : $('#curtain'),

		closeButton: $('#pop-window-close a'),
		printButton: $('#pop-window-print a'),	
		mailButton: $('#pop-window-mail a'),

		mailWindow : $('#mail-window'),
		mailClose : $('#mail-window-close a'),

		init : function() {
			var o = this;
			this.closeButton.click(function(){
				o.w.hide();
				o.curtain.hide();
			
				return false;
			});
		
			this.curtain.click(function(){
				o.w.hide();
				$(this).hide();
			});
			
			this.printButton.click(function(){
				printThis(o.content.html());
				return false;
			});

			this.mailButton.click(function(){
				o.mailWindow.open();
				return false;
			});

			this.mailClose.click(function(){
				o.mailWindow.hide();
				return false;
			});			
		}
			

	}

	popWindow.init();

	var aUrl = $('#article-url');

		newsButtons.click(function() {
			popWindow.content.html($(this).parent().parent().next().html());
			popWindow.w.open();
			popWindow.curtain.css('height',$(document).height()+'px');
			popWindow.curtain.show();
			
			aUrl.text($(this).attr('href'));
			$('#Form_MailForm_url').val($(this).attr('href'));
			
			return false;
		});

		rentButtons.click(function() {
			popWindow.content.html($(this).parent().parent().find('td.info li').html());
			popWindow.w.open();
			popWindow.curtain.css('height',$(document).height()+'px');
			popWindow.curtain.show();
			
			aUrl.text($(this).attr('href'));
			$('#Form_MailForm_url').val($(this).attr('href'));
			
			return false;
		});
	});
	
	function printThis(text)
	{
		top.nWindow = window.open('','Print','height=600,width=700');
		top.nWindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'+
						'<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">'+
						'<head>'+
							'<title>Filmpark Studios</title>'+
							'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'+
							'<link href="http://www.filmpark.sk/themes/filmpark/css/filmpark-print-style.css" rel="stylesheet" type="text/css" />'+				
						'</head>'+
						'<body>');
		top.nWindow.document.write('<div id="logo"><img src="http://www.filmpark.sk/themes/filmpark/images/logo2.png" alt="Filmpark" /></div>');
		top.nWindow.document.write(text);
		top.nWindow.document.write('<div id="footer">This article was printed from www.filmpark.sk</div>')
		top.nWindow.document.write('</body></html>');
		top.nWindow.print();
	}
}) (jQuery);

