
/*
	Opens popup window, whitch is centered in screen
	Param:
		id string (element id to get content)
		width int (window width)
		height int (window height)
*/
function openPrintPopup(id,width,height) {
	var rnd = (Math.round((Math.random()*999)+1));
    var html = $('#'+id).html();
    
	scrollbars = 'yes';
	
	var top = (screen.height) ? (screen.height-height)/2 : 0;
	var left = (screen.width) ? (screen.width-width)/2 : 0;
    
	my_window = window.open("", "w"+rnd, "top="+top+",left="+left+",width="+width+",height="+height+",buttons=no,scrollbars="+scrollbars+",location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no");
	my_window.document.writeln("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
    my_window.document.writeln("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
	my_window.document.writeln("<head>");
	my_window.document.writeln("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />");
	my_window.document.writeln("<meta http-equiv=\"Content-Script-Type\" ","content=\"text/javascript\">");
    my_window.document.writeln("<title>Print document</title>");
    my_window.document.writeln("<link rel=\"stylesheet\" rev=\"stylesheet\" href=\"/css/print.css\" type=\"text/css\" media=\"all\" charset=\"utf-8\" />");
    my_window.document.writeln("<\/head>");
	my_window.document.writeln("<body onload=\"window.print()\" style='margin:15px;padding:0px;'>");
	my_window.document.writeln(html);
	my_window.document.writeln("<\/body><\/html>");
	my_window.document.close();
	
	return false;
}
//---------------------------------------------------------------

function trimString(str)
{
	while (str.charAt(0) == ' ')
		str = str.substring(1);
	while (str.charAt(str.length - 1) == ' ')
		str = str.substring(0, str.length - 1);

	return str;
}
//---------------------------------------------------------------

