function ROF(p1,p2)  //引用法律文库中的资料
{
    window.open("/flwk/show.php?file_id="+(p1+1)+"#"+p2,"_blank");
}

function setFontSize(class_name,size)
{
    document.getElementById(class_name).style.fontSize=size+'px';
    return false;
}

function formatTime(sTime)
{
	sTime = ("0"+sTime);
	return sTime.substr(sTime.length-2);
}

function doPrint(mod)
{
   if (window.print)
   {
        var currentTime = new Date();
        var sTime = currentTime.getFullYear() + '年' + (currentTime.getMonth() + 1) + '月' + currentTime.getDate() + '日 '+
					formatTime(currentTime.getHours())+':'+formatTime(currentTime.getMinutes())+':'+formatTime(currentTime.getSeconds());

        var URL = "" + window.location;
        if (URL.substr(URL.length-1)=='#') URL = "" + URL.substr(0,URL.length-1);

        var new_window = window.open('',"newsssWin2","toolbar=no,location=no,directories=no,status=yes,menubar=yes,resizable=yes,align=left,top=0,left=0,width="+(screen.availWidth-10)+",height="+(screen.availHeight-30));
        var ad_in_page = document.getElementById('ad_in_page').innerHTML;
        document.getElementById('ad_in_page').innerHTML='';
        var content = document.getElementById('news').innerHTML;
        document.getElementById('ad_in_page').innerHTML=ad_in_page;

		var head ='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' +
                  '<HTML>' +
                  '<HEAD>' +
                  '<TITLE>打印预览</TITLE>' +
                  '<META http-equiv=Content-Type content="text/html; charset=gb2312">' +
                  '<LINK href="/images/detail.css" type=text/css rel=STYLESHEET>' +
		          '<style type="text/css">' +
				  '' +
				  '</style>'+
                  '</HEAD>' +
                  '<BODY leftMargin=4 topMargin=2 marginheight="4" marginwidth="4" bgcolor="#FFFFFF">' +
				  '<table width="600" border="0" align="center">' +
				  ' <tr> ' +
				  '    <td align="left"><img src="/images/logo.gif" width="173" height="60"> </td>' +
				  '  </tr>' +
				  '</table>';
		var nav  ='' ;

		var body ='<table width="600" border="0" cellpadding="10" align="center">' +
				  '  <tr> ' +
				  '    <td align="center">' + content +
				  '  </tr>' +
				  '</table>';

		var tail ='<br/><br/><br/><table width="600" border="0" cellpadding="10" align="center">' +
				  '  <tr> ' +
				  '    <td align="center">中国法院网版权所有 ，未经书面授权禁止使用<br>' + sTime + '<br\>'+ URL + '</td>' +
				  '  </tr>' +
				  '</table>'+
				  '</body>'+
				  '</html>';


        new_window.document.clear();
        if (navigator.appName == 'Microsoft Internet Explorer')
        {
            new_window.document.body.innerHTML = head + nav + body + tail;
         }else{
            new_window.document.write(head + nav + body + tail);
        }

    	new_window.window.document.title='打印预览';
    	if (mod==2)
    	{
    	    new_window.window.print();
    	    new_window.close();
        }
    }

}

function debug(id,URL,title)
{
    var str = '';
    /*
    form='<form id="form1" name="form1" method="post" action="/public/debug.php">' +
        title+'<br/><br/>'+
        '    姓名<input type="text" name="user_name" size="15" maxlength="20" />' +
        '    联系方式<input type="text" name="connect_with" size="28" maxlength="60"/>' +
        '    <textarea name="debug_content" id="textarea" cols="56" rows="8"></textarea>' +
        '    <br /><br />' +
        '    <input type="hidden" name="article_id" value="' + id + '" />' +
        '    <input type="hidden" name="article_url" value="' + URL + '" />' +
        '    <input type="hidden" name="article_title" value="' + title + '" />' +
        '    <input type="submit" name="button" id="button" value="提交" />' +
        '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' +
        '    <input type="button" name="button2" id="button2" value="关闭" onclick="close_dialog()" />' +
        '</form>';
     */
    URL=escape(URL);
    //title=escape(title);
    form = '<iframe src="/public/debug.php?id='+id+'&url='+URL+'&title='+title+'" width="100%" height="260" scrolling="no" frameborder="0"></iframe>';
    form += '<br><br><input type="button" name="button2" id="button2" value="关闭返回" onclick="close_dialog()" />';
    dialog('纠错',form,400,340);
}

var dialogs = new Array(2);
function dialog(title, msg, w, h)
{
	var titleheight = "22px"; // 提示窗口标题高度
	var bordercolor = "#666699"; // 提示窗口的边框颜色
	var titlecolor = "#FFFFFF"; // 提示窗口的标题颜色
	var titlebgcolor = "#3A76B1"; // 提示窗口的标题背景色
	var bgcolor = "#FFFFFF"; // 提示内容的背景色

	var iWidth = document.documentElement.clientWidth;
	var iHeight = document.documentElement.clientHeight;
	var bgObj = document.createElement("div");
	bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000;z-index:101;";
	document.body.appendChild(bgObj);
	dialogs[0] = bgObj;

	var msgObj=document.createElement("div");
	msgObj.style.cssText = "position:absolute;font:11px '宋体';top:"+(iHeight-h)/2+"px;left:"+(iWidth-w)/2+"px;width:"+w+"px;height:"+h+"px;text-align:center;border:1px solid "+bordercolor+";background-color:"+bgcolor+";padding:1px;line-height:22px;z-index:102;";
	document.body.appendChild(msgObj);
	dialogs[1] = msgObj;

	var table = document.createElement("table");
	msgObj.appendChild(table);
	table.style.cssText = "margin:0px;border:0px;padding:0px;";
	table.cellSpacing = 0;
	var tr = table.insertRow(-1);
	var titleBar = tr.insertCell(-1);
	titleBar.style.cssText = "width:100%;height:"+titleheight+"px;text-align:left;padding:3px;margin:0px;font:bold 13px '宋体';color:"+titlecolor+";border:1px solid " + bordercolor + ";cursor:move;background-color:" + titlebgcolor;
	titleBar.style.paddingLeft = "10px";
	titleBar.innerHTML = title;
	var moveX = 0;
	var moveY = 0;
	var moveTop = 0;
	var moveLeft = 0;
	var moveable = false;
	var docMouseMoveEvent = document.onmousemove;
	var docMouseUpEvent = document.onmouseup;
	titleBar.onmousedown = function() {
		var evt = getEvent();
		moveable = true;
		moveX = evt.clientX;
		moveY = evt.clientY;
		moveTop = parseInt(msgObj.style.top);
		moveLeft = parseInt(msgObj.style.left);

		document.onmousemove = function() {
			if (moveable) {
				var evt = getEvent();
				var x = moveLeft + evt.clientX - moveX;
				var y = moveTop + evt.clientY - moveY;
				if ( x > 0 &&( x + w < iWidth) && y > 0 && (y + h < iHeight) ) {
					msgObj.style.left = x + "px";
					msgObj.style.top = y + "px";
				}
			}
		};
		document.onmouseup = function () {
			if (moveable) {
				document.onmousemove = docMouseMoveEvent;
				document.onmouseup = docMouseUpEvent;
				moveable = false;
				moveX = 0;
				moveY = 0;
				moveTop = 0;
				moveLeft = 0;
			}
		};
	}

	var closeBtn = tr.insertCell(-1);
	closeBtn.style.cssText = "cursor:pointer; padding:2px;background-color:" + titlebgcolor;
	closeBtn.innerHTML = "<span style='font-size:15pt; color:"+titlecolor+";'>×</span>";
	closeBtn.onclick = function(){
		document.body.removeChild(bgObj);
		document.body.removeChild(msgObj);
	}
	var msgBox = table.insertRow(-1).insertCell(-1);
	msgBox.style.cssText = "font:10pt '宋体';";
	msgBox.colSpan  = 2;
	msgBox.innerHTML = msg;

    // 获得事件Event对象，用于兼容IE和FireFox
    function getEvent() {
	    return window.event || arguments.callee.caller.arguments[0];
    }
}

function close_dialog()
{
	document.body.removeChild(dialogs[0]);
	document.body.removeChild(dialogs[1]);
}

function UrlEncode(s)
{
    var hex=''
    var i,j,t
    j=0
    for (i=0; i<s.length; i++)
    {
        t = hexfromdec( s.charCodeAt(i) );
        if (t=='25')
        {
            t='';
        }
        hex += '%' + t;
    }
    return hex;
}

function hexfromdec(num) {
    if (num > 65535) { return ("err!") }
    first = Math.round(num/4096 - .5);
    temp1 = num - first * 4096;
    second = Math.round(temp1/256 -.5);
    temp2 = temp1 - second * 256;
    third = Math.round(temp2/16 - .5);
    fourth = temp2 - third * 16;
    return (""+getletter(third)+getletter(fourth));
}

function getletter(num)
{
    if (num < 10) {
    return num;
    }
    else {
        if (num == 10) { return "A" }
        if (num == 11) { return "B" }
        if (num == 12) { return "C" }
        if (num == 13) { return "D" }
        if (num == 14) { return "E" }
        if (num == 15) { return "F" }
    }
}

