function menu_add_button(className,text,size) {
	size=Convert.Int(size);
	var container = document.createElement('div');
	container.className='button enabled';
	container.style.left = menu_x+'px';
	container.onmouseover=function(){ this.className+=' hover'; }
	container.onmouseout=function(){ this.className = this.className.replace(/ hover/,''); }
	container.disable=function() { this.className='button disabled'; }
	container.enable=function() { this.className='button enabled'; }
	menu_container.appendChild(container);
	
	var icon = document.createElement('div');
	icon.className = 'icon '+className;
	container.appendChild(icon);

	if(typeof(text)!="undefined") {
		var texto = document.createElement('div');
		texto.className = 'texto';
		texto.innerHTML = text;
		container.appendChild(texto);
		container.style.width=(22+size)+'px';
		menu_x+=size+6;
	}
	
	menu_x+=26;
	return container;
}
function menu_add_text(text,size) {
	var texto = document.createElement('div');
	texto.className = 'texto';
	texto.style.left = menu_x+'px';
	texto.innerHTML = text;
	menu_container.appendChild(texto);
	menu_x+=Convert.Int(size);
	return texto;
}
function menu_add_section() {
	var section = document.createElement('div');
	section.className = 'section';
	section.style.left=menu_x+'px';
	menu_container.appendChild(section);
	menu_x+=15;
}
function menu_add_split() {
	var split = document.createElement('div');
	split.className = 'split';
	split.style.left=menu_x+'px';
	menu_container.appendChild(split);
	menu_x+=15;
}


var menu_x=0;
var menu_container = document.createElement('div');
menu_container.id="menu";
document.body.appendChild(menu_container);

menu_add_section();
var menu_first=menu_add_button('first');
var menu_previus=menu_add_button('previus');
menu_add_split();
var menu_page_of=menu_add_text('',LngStr('page_of_size'));
menu_add_split();
var menu_next=menu_add_button('next');
var menu_last=menu_add_button('last');
menu_add_section();
var menu_print=menu_add_button('print',LngStr('print'),LngStr('print_size'));
var menu_orientation=menu_add_button('orientation',LngStr('orientation'),LngStr('orientation_size'));
//var menu_columns=menu_add_button('columns',LngStr('columns'),LngStr('columns_size'));
/*
menu_add_section();
menu_add_text(LngStr('export_to'),LngStr('export_to_size'));
var menu_export_text=menu_add_button('export_text');
var menu_export_html=menu_add_button('export_html');
*/
menu_add_section();

var menu = {
	reset: function() {
		menu.currentPage=1;
		menu.maxPage=report.totalPages;
		menu.show();
	},
	text: function() {
		menu_page_of.innerHTML=Convert.Format(LngStr('page_of'),menu.currentPage,menu.maxPage);
	},
	show: function(){
		menu.text();
		menu.refresh_buttons();
		paper.innerHTML = '<div style="display: none;">&nbsp;</div><style>'+report.draw.styles+'</style>';
		if(report.orientation==0) { paper.innerHTML +='<div style="width: 39px; height: 39px">&nbsp;</div>'; }
		else { paper.innerHTML +='<div style="width: 39px; height: 39px">&nbsp;</div>'; }
		
		paper.innerHTML += report.codePages[menu.currentPage-1];
		
		if(report.orientation==0) { paper.innerHTML += '<div style="padding-top: 20px;">'; }
		else { paper.innerHTML += '<div style="padding-top: 20px;">'; }
		paper.innerHTML += '<span style="vertical-align:bottom;float:left;padding:0px  15px">'+Convert.Format(LngStr('page_of'),menu.currentPage,menu.maxPage)+'</span><span style="float:right;padding:0px  15px">'+Convert.DateNow()+' '+Convert.TimeNow()+'</span></div>';
	},
	refresh_buttons:function(){
		if(menu.currentPage==1){
			menu_first.disable();
			menu_previus.disable();
			menu_first.onclick=null;
			menu_previus.onclick=null;
		}
		else{
			menu_first.enable();
			menu_previus.enable();
			menu_first.onclick=menu.first;
			menu_previus.onclick=menu.previus;
		}
		if(menu.currentPage==menu.maxPage) {
			menu_next.disable();
			menu_last.disable();
			menu_next.onclick=null;
			menu_last.onclick=null;
		}
		else{
			menu_next.enable();
			menu_last.enable();
			menu_next.onclick=menu.next;
			menu_last.onclick=menu.last;
		}
	},
	previus:function(){
		menu.currentPage--;
		menu.show();
	},
	next:function(){
		menu.currentPage++;
		menu.show();
	},
	first:function() {
		menu.currentPage=1;
		menu.show();
	},
	last:function() {
		menu.currentPage=menu.maxPage;
		menu.show();
	}
}

menu_orientation.onclick=function() {
	if(report.orientation==0) { report.ChangeOrientation(1); }
	else{ report.ChangeOrientation(0); }
	Report_Load_Draw();
}
menu_print.onclick=function() {
	var corpseFrame=window.frames['corpseFrame'];
	var strWrite="";
	strWrite = '<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>'+options.title+'</title><head>';
	strWrite += '<meta content="text/html; charset=utf-8" http-equiv="Content-Type">';
	strWrite += '<style type="text/css" media="all">';
	strWrite += 'td { font:9pt Arial; text-align:left; vertical-align:middle; line-height:1.15em;}';
	strWrite += report.draw.styles;
	strWrite += '</style>';
	if(browser.isOp){ strWrite += '<script>function printPage(){ focus(); print(); }</script>'; }
	strWrite += '</head>';
	strWrite += '<body>';
	for(var i in report.codePages){
		if(i!=0) { strWrite += '</table><div style="page-break-before: always;"></div>'; }
		strWrite +=report.codePages[i];
	}
	strWrite += '</body>';
	strWrite += '</html>';
	corpseFrame.document.write(strWrite);
	corpseFrame.document.close();
	if(browser.isOp){
		corpseFrame.onload = function () {
				var iframe = document.frames['corpseFrame'];
				var ifwin = iframe.contentWindow || iframe;
				ifwin.printPage();
		}
	}
	else{
		corpseFrame.focus();
		corpseFrame.print();
	}
}
include('control.report.js');