﻿function confirmDelete() {
	return confirm("Tem a certeza que deseja apagar este item?");
}

function selectPage(page) {
	$('#page').attr('value', page);
	var itemsPerPage = $('#itemsPerPageMain').val();
	$('[name=itemsPerPage]').val(itemsPerPage);
	$('#resultsButton').click();
}

function deleteParent(element) {
	$(element).parent().remove();
}

function previewDialog(dialogId) {
    var dialogWidth = window.screen.availWidth * 0.75;
    var dialogHeight = window.screen.availHeight * 0.75;
    $("#" + dialogId).dialog({
        autoOpen: false,
        bgiframe: true,
        modal: false,
        draggable: true,
        width: dialogWidth,
        height: dialogHeight,
        buttons: { "Fechar": function() { $(this).dialog('close'); } },
        close: function(event, ui) {
            $(this).dialog('option', 'width', window.screen.availWidth * 0.75);
            $(this).dialog('option', 'height', window.screen.availHeight * 0.75);
        }
    });
}

function printPage(baseLocation) {
    //var url = window.location.host;
    var content = $('#printable-area').html();
    var printPageContent =
        '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' +
        '<html xmlns="http://www.w3.org/1999/xhtml">' +
        '<head>' +
	    '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />' +
	    '<title>Página de Impressão</title>' +
    	'<link rel="stylesheet" type="text/css" href="' +
    	baseLocation + '/Content/Css/Site-print.css" />' +
	    '<link rel="stylesheet" type="text/css" href="' +
	    baseLocation + '/Content/Css/smoothness/jquery-ui-1.7.1.custom.css" />' +
	    '<!--[if lt IE 7]>' +
	    '<script src="' +
	    baseLocation + '/Content/Scripts/IE7.js" type="text/javascript"></script>' +
	    '<![endif]-->' +
        '</head>' +
        '<body onload="window.print()">' +
	    '<div id="printable-area">' +
	    content +
	    '</div>' +
        '</body>' +
        '</html>';
    var printWindow = window.open();
    printWindow.document.write(printPageContent);
    printWindow.document.close();
    //alert('oi3');
    //$.get('/PrintPage', function(data) {
    //    data = data.replace('CONTEUDO', content);
    //    printWindow.document.write(data);
    //    printWindow.document.close();
    //});
   return false;
}