window.onload = Init;

function Init () {
	var vPrint = document.getElementById ('print');
	if (vPrint) vPrint.onclick = PrintPage;
}

function PrintPage () {

	var vPreview = open ('', 'PrintPreview', 'width=' + screen.width + ',height=' + screen.height + ',status=no,toolbar=no,menubar=yes,resizable=yes,scrollbars=yes');
	vPreview.focus ();

	headerSource = parent.frames['head'].document.body.innerHTML;
	contentSource = parent.frames['content'].document.body.innerHTML;

	headerPath = parent.frames['head'].location.href;
	headerPath = headerPath.replace (/(.*)\/.*/ig, '$1/');

	contentPath = parent.frames['content'].location.href;
	contentPath = contentPath.replace (/(.*)\/.*/ig, '$1/');

	headerSource = headerSource.replace (/href="/ig, 'href="' + headerPath);
	contentSource = contentSource.replace (/href="/ig, 'href="' + contentPath);
	headerSource = headerSource.replace (/src="/ig, 'src="' + headerPath);
	contentSource = contentSource.replace (/src="/ig, 'src="' + contentPath);

//	vHtml = vHtml.replace (/href="/ig, 'href="' + vPath);
//	vHtml = vHtml.replace (/src="../ig, 'src="' + vPath);

	var vHtml ='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
				+ '<html xmlns="http://www.w3.org/1999/xhtml">'
				+ '<head><title>Header</title><base target="content" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link type="text/css" rel="stylesheet" href="css/common.css" /><link type="text/css" rel="stylesheet" href="css/ifrs.css" /><link type="text/css" rel="stylesheet" href="css/print.css" media="print" /></head>'
				+ '<body>'
				+ headerSource
				+ contentSource
				+ '</body></html>';

//	var vPath = location.href;
//	vPath = vPath.replace (/(.*)\/.*/ig, '$1/');
//	vHtml = vHtml.replace (/href="/ig, 'href="' + vPath);
//	vHtml = vHtml.replace (/src="../ig, 'src="' + vPath);

	vPreview.document.open ();
	vPreview.document.write (vHtml);
	vPreview.document.close ();

//	window.print ();
	return false;
}

function SetMenu () {
	if (this.name == 'content') {
		var vPage = this.location.href;
		var vHead = parent.frames['head'].document.getElementById ('topmenu');
		if (vHead) {
			var vMenu = vHead.getElementsByTagName ('a');
			for (var Index = 0; Index < vMenu.length; Index++)	if (vMenu[Index] == vPage) var vCheck = true;
			if (vCheck == true)
				for (var Index = 0; Index < vMenu.length; Index++) {
					vMenu[Index].className = '';
					if (vMenu[Index] == vPage) vMenu[Index].className = 'active';
				}
		}
	}
}