/* Print-PopUp */

/* Attributes for PopUp */
var attribPopUpPrint="location=no,menubar=no,toolbar=no,status=yes";
attribPopUpPrint+=",resizable=yes,scrollbars=yes,width=600,height=768";

var attribPopUpRemark="location=no,menubar=no,toolbar=no,status=yes";
attribPopUpRemark+=",resizable=yes,scrollbars=yes,width=690,height=768";


/* init variables, which later point to the window object */
var subwindow=0;

/* This function closes  (if open) the popup window */
function ClosePopUp()
{
	if (!subwindow)          /* if not jet opened */
		return;                /* cancel */
	if (subwindow.closed)    /* if already closed */
		return;                /* cancel */
	subwindow.close();       /* close */
}

function PopUpPrint()
{
	ClosePopUp()             /* close, if already opened */

	/* CE_print.html open with name "popup" and remenber window object */
	subwindow=window.open("/utils/printview.php?id="+window.parent.document.location.pathname.substr(1),"popup",attribPopUpPrint);

	/* move window to left top */
	subwindow.moveTo(10,50);
}

function PopUpPrintGerling()
{
	ClosePopUp()             /* close, if already opened */

	/* CE_print.html open with name "popup" and remenber window object */
	subwindow=window.open("/utils/printview_gerling.php?id="+window.parent.document.location.pathname.substr(1),"popup",attribPopUpPrint);

	/* move window to left top */
	subwindow.moveTo(10,50);
}

function PopUpRemark()
{
	ClosePopUp()             /* close, if already opened */

	/* CE_print.html open with name "popup" and remenber window object */
	var openUrl = "/zglos_uwage/"+encodeURIComponent(window.parent.$('.footer p').attr('title'));
	subwindow=window.open(openUrl,"popup",attribPopUpRemark);

	/* move window to left top */
	subwindow.moveTo(10,50);
}

/* Rozciąganie wysokości div'a z treścią */
function calculateContentMiddle() {
	/*
	var centerdivheight = $("#content #middle").height();
	var rightdivheight 	= $("#content #right").height();

	if ((rightdivheight-80) > centerdivheight)
		$("#middle").css('height',(rightdivheight-80)+'px');
	*/
		
}

/**
 * wysylanie uwagi do dokumentu
 */ 
function sendRemark(){
  if($('#sremark').val().length > 0){
    $.post('/ajax.php', {scontroller: 'remark', 
                        saction: 'send', 
                        iddocumentremark: $('#iddocumentremark').val(), 
                        sremark: $('#sremark').val(), 
                        semail: $('#semail').val()
                        }, 
                        function(sdata){
                          $('#middle').html(sdata); 
                        });
  }else{
    alert('Proszę wypełnić formularz');
  }
}

$(document).ready(function() {
	//calculateContentMiddle();
	
	if($('#send_remark').length > 0){
	   $('#send_remark').click(function(){
        sendRemark();
        return false;
     });
  }
});