<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $_REQUEST['titel'];?></title>
 


<script type="text/javascript" language="javascript"> 

function print_page()
{
	var i = 0;
	var id = "";
	var data = "";
	var counter = document.getElementById('page_counter').value;
	var mywindow = window.open ('', '', 'height=50,width=50');
	mywindow.document.write('<html><head><title></title>');
	mywindow.document.write('<style>.show{width: 8.5in; height: 11.69in; background:#FFF;} .page_bariar{page-break-after:always;} .page_body{width: 8.5in; height: 10in; font-family: Calibri; font-size:12px;}.page_footer{width: 8.5in; height: 1in;font-family: Verdana; font-size:12px;}.footer_contant{width: 6.5in; height: 1in; }</style>');
	mywindow.document.write("</head><body style='width:8.5in;height:auto;'><div style='height:auto;'>");
 
	
	var dat = '';
 
	for(i = 0; i < counter; i++)
	{
		id = 'page' + i;
		data = document.getElementById(id).innerHTML;
		mywindow.document.write("\n<div align='center' >");
		mywindow.document.write(data);
		mywindow.document.write("</div>");
		mywindow.document.write("<div class='page_bariar'></div>");	
		
	//	dat += "\n<div align='center'  >";
	//	dat += data + "</div>";
	//	dat += "\n<div class='page_bariar'></div>";
		  		
	
	}
	
 
	
	
	mywindow.document.write('</div></body></html>');
	mywindow.document.close();
	mywindow.print(); 
//	alert(dat);
	mywindow.close();
 
}
 


 
 
 
 
function getXmlhttp()
{
	var xmlhttp;
	
 	try
	{
		xmlhttp = new XMLHttpRequest();
	} 
	catch(e)
	{
		// Internet Explorer Browsers
		try
		{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch(e) 
		{
			try
			{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e)
			{
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	return xmlhttp;
}

function load_report_page(page_id, element_id, sub_element_id, query, count)
{
 
 	var pageAddress = "";
	
	var xmlhttp = getXmlhttp();
 	 
	xmlhttp.onreadystatechange=function()
	{	  
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{ 
			if( xmlhttp.responseText != -1 )
			{
				document.getElementById("reportAjax").innerHTML = xmlhttp.responseText;
			} 
		}
	}
 
 	var address = page_id + "?element_id=" + element_id + "&sub_element_id=" + sub_element_id + "&query=" + query + "&count=" + count;
 	xmlhttp.open("GET",address ,true);
 	xmlhttp.send();
	
}
 
 

function change_page(flag)
{
 
	var count_page = document.getElementById("page_counter").value ;
	var cur_page = document.getElementById("current_page").value;
	var cur_id = cur_page;
	cur_id = cur_id.substring(4, cur_id.length);
	
	if(flag == 0)
	{
		if(cur_id != 0)
		{
		
			cur_id = (parseInt(cur_id) - 1);
			for(var i = 0; i < count_page; i++)
			{
				document.getElementById(("page" + i)).className = "hide";
			}
 
			document.getElementById(("page" + cur_id)).className = "show";
		}
		else
			return;
	}
	else
	{
	
		if(cur_id != (count_page - 1))
		{
			cur_id = (parseInt(cur_id) + 1);
			for(var i = 0; i < count_page; i++)
			{
				document.getElementById(("page" + i)).className = "hide";
			}

			document.getElementById(("page" + cur_id)).className = "show";
		}
		else
			return;
	}
	
	document.getElementById("prev").disabled = false;
	document.getElementById("next").disabled = false;

	if(cur_id == 0)
		document.getElementById("prev").disabled = true;
	if(cur_id == (count_page - 1))
		document.getElementById("next").disabled = true;
 
 	document.getElementById("current_page").value = ("page" + cur_id);
}

function change_view(value)
{
 
	var count_page = document.getElementById("page_counter").value;
	
	if(document.getElementById("page0")!= null )
	{
		if(value == '0')
		{
			for(var i = 0; i < count_page; i++)
			{
				document.getElementById(("page" + i)).className = "hide";
				document.getElementById(("pageBreakTag" + i)).className = "pageBreakHide";
			}
			document.getElementById(("page" + 0)).className = "show";
		}
		else
		{

			for(var i = 0; i < count_page; i++)
			{
				document.getElementById(("page" + i)).className = "show";
				document.getElementById(("pageBreakTag" + i)).className = "pageBreakShow";
			}	
 
		}
	}
 
}

</script>

<style>

.show
{
	width: 8.5in; 
	height: 11in; 
	background:#FFF;
}
.hide
{
	width: 8.5in; 
	height: 11in; 
	background:#FFF;
	display:none;
}
 
#reportAjax
{
	width: 8.5in; 
	height: auto; 
}

.pageBreakShow
{
	height:20px;
}

.pageBreakHide
{
	height:20px;
	display:none;
}


#loder
{
	height:70px;
}

.page_body
{
	width: 8.5in; 
	height: 10in; 
	font-family: Verdana; 
	font-size:12px;

 
}
.page_footer
{
	width: 8.5in; 
	height: 1.50in; 
	font-family: Verdana; 
	font-size:12px;
}

.footer_contant
{
	width: 6.5in; 
	height: 1in; 
 
}

</style>

</head>

<body style="border:0px; padding:opx; margin:0px" bgcolor="#999999" onload="load_report_page('<?php echo $_REQUEST['page_id']; ?>','<?php echo $_REQUEST['element_id']; ?>', '<?php echo $_REQUEST['sub_element_id']; ?>','<?php echo $_REQUEST['query']; ?>', '<?php echo $_REQUEST['count']; ?>')">


	<table style="width:100%; height:auto;" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td  style="width:10%; height:60px; background:#CCC;">
 
            </td>
               <td style="width:90%; height:60px; background:#CCC;" >
                 <input type="button" onclick="print_page()"  value="Print" />
                 <input type="button" onclick="change_page(0)" disabled="disabled"  id="prev"  value="prev" />
                 <input type="button" onclick="change_page(1)"  value="next" id="next" />
                 <select onchange="change_view(this.value)" id="cmb_view_index">
                 	<option  selected="selected" value="0">None</option>
                    <option value="1">All</option>
                 </select>
                 <script type="text/javascript" language="javascript"> 
				 	document.getElementById('cmb_view_index').value = 0;
					document.getElementById('prev').disabled = true;
					document.getElementById('next').disabled = false;
				 
				 </script>
            </td>
        </tr>

  		<tr>
            <td style="width:10%; height:13in; background:#CCC;" >
            </td>
               <td style="width:90%; height:12in; background:#999;">
                   	<center >

						<div id="reportAjax" >
 	        			<img id="loder" align="baseline"   src="../images/ajax_loader_big.gif" alt="Loder" />
             			</div>
				</center>
 
            </td>

        </tr>
          <tr>
            <td style="width:10%; height:20px; background:#CCC; ">
            </td>
               <td style="width:90%; height:20px; background:#CCC;">
            </td>

        </tr>
	</table>
 
</body>
</html>