/*----------------------------------------------------------------
// Copyright (C) 2004 PHOOK
// 版权所有。 
//
// 文件名：			print.js
// 文件功能描述：	打印控制
//
// 创建标识：		张吉锋20071030
//----------------------------------------------------------------
// 功能说明：
//----------------------------------------------------------------
// 在使用此弹出层之前引用print.js
// 在网页中添加 <object style="display:none;" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" id="webPrintObject"></object>
//----------------------------------------------------------------*/
var hkey_path="HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup";
var hkey_key="";
var RegWsh=null;
try
{
	RegWsh =new ActiveXObject("WScript.Shell");
}
catch(e)
{
	alert('创建"WScript.Shell"错误！');
	window.location.href = '/print/help.htm';
}
//设置网页打印的页眉页脚为空 
function pagesetup_null()
{
	RegWsh.RegWrite(hkey_path+"\\header","");
	RegWsh.RegWrite(hkey_path+"\\footer","");
	//RegWsh.RegWrite(hkey_path+"\\footer","收货单:54564654 &b页码:&p/&P");
	RegWsh.RegWrite(hkey_path+"\\margin_bottom","0");
	RegWsh.RegWrite(hkey_path+"\\margin_left","0");
	RegWsh.RegWrite(hkey_path+"\\margin_right","0");
	RegWsh.RegWrite(hkey_path+"\\margin_top","0");
}
//设置网页打印的页眉页脚为默认值 
function pagesetup_default() 
{
	RegWsh.RegWrite(hkey_path+"\\header","&w&b页码，&p/&P");
	RegWsh.RegWrite(hkey_path+"\\footer","&u&b&d");
}

// 直接打印 
function printPage()
{ 
	webPrint.ExecWB(6,6); 
} 

// 打印设置 
function printSetup()
{ 
	webPrint.ExecWB(8,1); 
} 

// 打印预览 
function printPreview()
{ 
	webPrint.ExecWB(7,1); 
} 

if(window.attachEvent){
	window.attachEvent('onload',printInit); 
}
else{
	window.addEventListener('load',printInit,false);
}

var webPrint = null;
function printInit()
{
	webPrint = document.getElementById('webPrintObject');
	if(webPrint != 'Microsoft Web 浏览器控件')
	{
		alert('创建"WebBrowser"错误！');
		window.location.href = '/print/help.htm';
	}
}