﻿function PrintPreview(zoom_size, footerWidth)
    {

		if (!!!zoom_size)
			zoom_size = 0.73;
		
		if (!!!footerWidth)
			footerWidth = '880px';

	var prntxt = "Print This Page";
	if (window.location.href.indexOf('/china/') >= 0)
		prntxt = "列印此页";
	else if (window.location.href.indexOf('/zh/') >= 0)
		prntxt = "列印此頁";
        var l = (screen.width - 640) / 2;
        var t = (screen.height - 480) / 2;
        var openwindow=window.open('','','height=600, width=800, top=0, left=0, toolbar=no, menubar=no,scrollbars=yes, resizable=yes,location=n o, status=no');
        var str=document.documentElement.innerHTML;
        var sp,ep;
        
        var starstr="<!--Print"+"DocStart-->";
        sp=str.indexOf("<!--Print"+"DocStart-->");
        ep=str.indexOf("<!--Print"+"DocEnd-->");
        var fstr = "";
        var fsp,fep;
        var fstarstr="<!--Print"+"FlashStart-->";
        fsp=str.indexOf("<!--Print"+"FlashStart-->");
        fep=str.indexOf("<!--Print"+"FlashEnd-->");
        if (fsp>=0 && fep>fsp)
        {
            fstr=str.substring(fsp+fstarstr.length,fep);  
            fstr="<table width='741' border='0' cellspacing='0' cellpadding='0'>" + fstr + "</table>";
        }
        var dstr = "";
        var dsp,dep;
        var dstarstr="<!--Print"+"DStart-->";
        dsp=str.indexOf("<!--Print"+"DStart-->");
        dep=str.indexOf("<!--Print"+"DEnd-->");
        if (dsp>=0 && dep>dsp)
        {
            dstr=str.substring(dsp+dstarstr.length,dep);  
        }
        var hstr = "";
        var hsp,hep; 
        var hstarstr="<!--Print"+"HeaderStart-->";
        hsp=str.indexOf("<!--Print"+"HeaderStart-->");
        hep=str.indexOf("<!--Print"+"HeaderEnd-->");
        if (hsp>=0 && hep>hsp)
        {
        hstr=str.substring(hsp+hstarstr.length,hep);  
        hstr=hstr + "<br><br>";
        }
        var frstr = "";
        var frsp,frep; 
        var frstarstr="<!--Print"+"FooterStart-->";
        frsp=str.indexOf("<!--Print"+"FooterStart-->");
        frep=str.indexOf("<!--Print"+"FooterEnd-->");
        if (frsp>=0 && frep>frsp)
        {
        frstr=str.substring(frsp+frstarstr.length,frep);  
        frstr= frstr + "<br>";
        }
        if (sp>=0 && ep>sp)
        {
        //debugger;
            str=str.substring(sp+starstr.length,ep);
            var titlestr=document.getElementsByTagName('title').item(0);
	var stylestr=document.getElementsByTagName('style').item(0);

		var cssitems=document.getElementsByTagName('link');
		var cssstr="";
		for (var i=0;i<cssitems.length;i++)
		{
			//if (cssitems.item(i).getAttribute('media') != 'print')
			cssstr=cssstr+cssitems.item(i).outerHTML.replace(/media=screen/g, '').replace(/media="screen"/g, '');
		}

openwindow.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");

openwindow.document.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
            openwindow.document.write("<html>");
            openwindow.document.write("<head>");
            openwindow.document.write(titlestr.outerHTML);
		if( stylestr != null)
	{
            openwindow.document.write(stylestr.outerHTML);
		}
			openwindow.document.write(cssstr);
            openwindow.document.write("<script language='javascript' type='text/javascript'>");
/*            openwindow.document.write("function PrintWindow(){");
            openwindow.document.write("var d=document.getElementById('PrintButton');");
            openwindow.document.write("var p=d.parentNode;");
            openwindow.document.write("d.parentNode.removeChild(d);");
            openwindow.document.write("p.appendChild(d);");
            openwindow.document.write("} ");
            openwindow.document.write("function flash(src,width,height,tr){}");
*/
            openwindow.document.write("function playflash(){ if (document.getElementById('param') != null) {document.getElementById('param').Play();} }");
            openwindow.document.write("function getScrollHeight(){");
            openwindow.document.write("var scoheight = window.document.body.scrollHeight;");
            openwindow.document.write("document.getElementById('layer').style.height = (scoheight*1)+50");
            openwindow.document.write("}</script>");
            openwindow.document.write("<style>@media Screen {body {margin:5px;} .printbtn{height:30px;}} @media Print {body {zoom: " + zoom_size + "} .layer, .printbtn{display:none;} .schFooter{width:" + footerWidth  + ";}} .second_print_friendly, .funds_tab_date, .back_to_top, .second_view_more_fund, .export_column, #rRestart {display:none;}</style>");
            openwindow.document.write("</head>");
            
            openwindow.document.write("<body onLoad='setTimeout(\"getScrollHeight()\", 300)'>");
            openwindow.document.write("<div class='printbtn'><input type='button' value='" + prntxt + "' onclick='javascript:self.print()'/></div>");
            openwindow.document.write("<div class='wrapperGlobal'>");	
            openwindow.document.write(hstr);
            openwindow.document.write(fstr);
            openwindow.document.write(str);
            openwindow.document.write(dstr);
            openwindow.document.write(frstr);
            openwindow.document.write("</div>");
            openwindow.document.write("<script> if(document.getElementById('drag') !=null){drag.style.display = \'none\'};playflash();<\/script>");
            openwindow.document.write("<div id='layer' class='layer' style='boarder:0px; position: absolute;top:42px;left:0px; z-index:5000;'>");
            openwindow.document.write("<table border='0' width='100%' height='100%' border='0' cellspacing='0' cellpadding='0'>");
            openwindow.document.write("<tr>");
            openwindow.document.write("<td width='100%' valign='bottom'> <td>");
            openwindow.document.write("</tr>");
            openwindow.document.write("</table>");
            openwindow.document.write("</div>");
            openwindow.document.write('</body></html>');
            openwindow.document.close();
        }
    }

//Print friendly
