﻿var validate;
function PatentContent(firstLink, patentCount, patentNO, patentName, patentType, newwindowLink, otherLink, isfmzl, isapproved) 
{
	var ConstWidth = 700;
	var ConstRightWidth = 250;
	var ConstHeight = 870;
	var ConstContentHeight = 500;
	
	var _firstLink = firstLink;
	var _baseLink = "";
	var _patentCount = patentCount;
	
	var _patentNO = patentNO;
	var _patentName = patentName;
	var _patentType = patentType;
	var _patentTypeName = "";
	
	var _newwindowLink = newwindowLink;
	var _otherLink = otherLink;
	var _otherLinkName = "";
	var _isFMZL = isfmzl;
	var _isApproved = isapproved;
	
	var _lastRunTime = new  Date(); 
	var _lastPosition = 0;
	
	var _downloadArray = new Array(_patentCount);
	var _viewedArray = new Array(_patentCount);
	
	var _leixing = "";
	
	var _this = this;
	
	//初始化层
	this.Initialize = function() {
        try
        {
	    document.execCommand("BackgroundImageCache", false, true);
	    }catch(e)
	    {
	    }
	    this.CreatePatentView();
	    this.CreateDialogForm();
	    this.CheckControl();

	    _baseLink = _firstLink.replace(/000001.tif/, "");
	    if (_patentType) {
	        _otherLinkName = "";
	        _patentTypeName = "申请文本";
	        if (_isApproved == true) {
	            _otherLinkName = "授权文本";
	        }
	        _leixing = "sqgk";
	    }
	    else {
	        _patentTypeName = "授权文本";
	        _otherLinkName = "申请文本";
	        _leixing = "sdsq";
	    }
	    this.InitializeMenu();
	    this.ChangeHeight();
	    $("#Left").css("width", document.documentElement.clientWidth - ConstRightWidth);
	    this.ChangeWidth(document.documentElement.clientWidth - ConstRightWidth - 60);
	    
	    this.DownloadPatent(1);
	    this.DisplayPatent(1);
	}
	
	//创建层
	this.CreatePatentView = function()
	{
		var ocxcontent = "";
		for( var i=1; i<_patentCount+1;i++)
		{
			ocxcontent = ocxcontent+"<DIV class='PatentView' style='TOP: "+this.ParseHeight(i)+"px'>"+
                                                    "<DIV class='PatentViewShadow'></DIV>"+
                                                    "<DIV class='PatentViewBorder'>"+
                                                        "<DIV class='PatentViewBackground'>"+
                                                            "<DIV class='PatentViewContent'>"+
                                                                "<OBJECT id="+this.ParseControlName(i)+" height=0 width=0 classid=clsid:001290E5-CD10-4957-9D2B-FD2B74990219><PARAM NAME='_Version' VALUE='65536'><PARAM NAME='_ExtentX' VALUE='2646'><PARAM NAME='_ExtentY' VALUE='1323'><PARAM NAME='_StockProps' VALUE='0'><param name='bViewOrDown' value='0'></OBJECT>"+
                                                            "</DIV>"+
                                                        "</DIV>"+
                                                    "</DIV>"+
                                                "</DIV>";
		}
		$(".PatentInnerContentPosition").append(ocxcontent);
	}
	
	//挂菜单
	this.InitializeMenu = function() 
	{
		this.CreateMenu();
		$("#SavePatent").click(function()
		{
			_this.SavePatent();
		});
		
		$("#PrintPatent").click(function()
		{
			_this.Print();
		});
		
		$("#ZoominPatent").click(function()
		{
			_this.Zoomin();
		});
		
		$("#ZoomoutPatent").click(function()
		{
			_this.Zoomout();
		});
		
		$("#FirstPatent").click(function()
		{
			_this.FirstPage();
		});
		
		$("#PrevPatent").click(function()
		{
			_this.PrevPage();
		});
		
		$("#NextPatent").click(function()
		{
			_this.NextPage();
		});
		
		$("#LastPatent").click(function()
		{
			_this.LastPage();
		});
		
		$("#FullScreen").click(function()
		{
			_this.FullScreen();
		});
		
		$("#RegularScreen").click(function()
		{
			_this.RegularScreen();
		});
		
		$('.PatentInnerContent').bind('scroll',function(event)
		{
			_this.ScrollEvent();
		});
		
		$(window).bind('resize',function()
		{
			_this.ChangeHeight();
			if ( $("#Right").css("display") == "none")
			{
				$("#Left").css("width", document.documentElement.clientWidth);
			}
		});
	}
	
	//创建菜单
	this.CreateMenu = function()
	{
	    var menu = "<ul><li><a id='SavePatent' href='#' class='Save' title='保存所有专利'></a><a id='PrintPatent' href='#' hidefocus='true' title='打印所有专利' class='Print'></a><a id='ZoominPatent' href='#' hidefocus='true' title='放大' class='zoomin'/></a><a id='ZoomoutPatent' href='#' hidefocus='true' title='缩小' class='zoomout'/></a><a id='FirstPatent' href='#' hidefocus='true' title='第一页' class='FirstPatent'/></a><a id='PrevPatent' href='#' hidefocus='true' title='上一页' class='PrevPatent'/></a><input id='PatentPage' readonly='true' type=text value='' /><a id='NextPatent' href='#' hidefocus='true' title='下一页' class='NextPatent'/></a><a id='LastPatent' href='#' hidefocus='true' title='最后一页' class='LastPatent'/></a><a id='FullScreen' href='#' hidefocus='true' title='全屏显示所有专利' class='fullscreen'/></a><a id='RegularScreen' href='#' hidefocus='true' title='恢复正常显示所有专利'class='regularscreen'></a>" +
		"<a id='Exit' href='"+_newwindowLink+"' hidefocus='true' title='新建相同窗口' target='_blank' class='NewWindow'/></a>";
		if ( _isFMZL )
		{
			menu += "<a class='PatentMenuLink' href='"+otherLink+"' hidefocus='true' title='"+_otherLinkName+"' target='_blank' >"+_otherLinkName+"</a>";
		}
		menu += " </li></ul>";
		$(".PatentMenu").append(menu);
	}
	
	var CurrentPatentIndex=1;
	//滚动事件
	this.ScrollEvent = function()
	{
		CurrentPatentIndex = this.ParseIndex(PatentInnerContent.scrollTop);
		if ( this.ScrollSpeed() < 1)
		{
			this.DownloadPatent(CurrentPatentIndex);
			this.DisplayPatent(CurrentPatentIndex);
		}
	}
	
	//下载专利
	this.DownloadPatent = function(index)
	{
		if (_downloadArray[index] != 1 && index <= _patentCount) 
		{
			var ocx = document.getElementById(this.ParseControlName(index));
			ocx.bViewOrDown = "0";
			ocx.InitCtrl();
			ocx.SetCheckCode("2111");
	        ocx.SetUserName("test100");
			ocx.SetScreenSize(ConstWidth);
			ocx.SetNetTifPathDemo(this.ParseLink(index));
			_downloadArray[index] = 1;
		}
	}
	
	//显示专利
	this.DisplayPatent = function(index)
	{
		this.SetPageIndex(index);
		if (_viewedArray[index] != 1 )
		{
			this.ChangeOcxRate();
			_viewedArray[index] = 1;
		}
	}
	
	//改变显示宽度并自动改变倍率
	this.ChangeWidth = function(width)
	{
		ConstWidth = width;
		ConstHeight = width*1.45;
		$(".PatentViewShadow").css("width", width+1).css("height", ConstHeight+1);
		$(".PatentViewBorder").css("width", width+2).css("height", ConstHeight+2);
		$(".PatentViewBackground").css("width", width).css("height", ConstHeight);
		$(".PatentViewContent").css("width", width).css("height", ConstHeight);
		var _this = this;
		$(".PatentView").each(function(i)
		{
			this.style.top = _this.ParseHeight(i+1);
		});
		for (var i = 1; i < _patentCount+1; i++) 
		{
			_viewedArray[i] = 0;
		}
		this.ChangeOcxRate();
	}
	
	//根据当前宽度改变倍率
	this.ChangeOcxRate = function()
	{
		var index = this.ParseIndex(PatentInnerContent.scrollTop);
		var ocx = document.getElementById(this.ParseControlName(index));
		var rate = ConstWidth/4600;
		var rate2 = ConstWidth/2464;
		if (index == 1) 
		{
			ocx.SetImageScale(rate);
		}
		else
		{
			ocx.SetImageScale(rate2);
		}
	}
	
	//改变高度
	this.ChangeHeight = function()
	{
		ConstContentHeight = document.documentElement.clientHeight-134;
		if (ConstContentHeight < 0) 
		{
			ConstContentHeight = 0;
		}
		$(".PatentInnerContent").css("height", ConstContentHeight);
		
		var height = document.documentElement.clientHeight-147;
		if (height < 0) 
		{
			height = 0;
		}
		$(".PatentBlock").css("height", height);
	}
	
	//放大
	this.Zoomin = function()
	{
		this.ChangeWidth(ConstWidth*1.1);
	}
	
	//缩小
	this.Zoomout = function()
	{
		this.ChangeWidth(ConstWidth*0.9);
	}
	
	//获取保存路径
	this.GetSaveFolder = function()
	{
		var ocx = document.getElementById(this.ParseControlName(1));
		return ocx.CtrGetPath()+"\\";
	}
	
	this.SavePatent = function()
	{
	    window.open ('/Home/DownloadChoice/'+_patentNO, '', 'height=160, width=420, top=200,left=300, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
	}
	
	var SavePath = "";
	var CurrentDownloadIndex = 1;
	//下载
	this.Download = function()
	{
		SavePath = this.GetSaveFolder();
		if ( SavePath == "\\" )
		{
			return;
		}
		this.ShowProcessBar("下载");
		CurrentDownloadIndex = 1;
		setTimeout("content.DownloadCurrent();",100); 
	}
	
	this.DownloadCurrent = function()
	{
		if (CurrentDownloadIndex < _patentCount + 1) {
			this.DownloadPatent(CurrentDownloadIndex);
			var ocx = document.getElementById(this.ParseControlName(CurrentDownloadIndex));
			ocx.CtrSaveData(SavePath +_patentNO + "-" +_patentName+"-"+_patentTypeName);
			this.UpdateProgress(CurrentDownloadIndex/_patentCount);
			CurrentDownloadIndex++;
			setTimeout("content.DownloadCurrent();",50);
		}
		else 
		{
			alert("下载完毕！");
			this.HiddenProcessBar();
		}
	}
	
	//打印
	this.Print = function()
	{
		$(".PatentView").css("display", "none");
		$(".MaskDiv").css("width", document.documentElement.clientWidth).css("height", document.documentElement.clientHeight);
		$("#PrintDialog").css("display","block").css("left", (document.documentElement.clientWidth-350)/2).css("top", (document.documentElement.clientHeight-150)/2);
	}
	
	//下一页
	this.NextPage = function()
	{
		this.GoTo(this.ParseIndex(PatentInnerContent.scrollTop)+1);
	}
	
	//第一页
	this.FirstPage = function()
	{
		this.GoTo(1);
	}
	
	//上一页
	this.PrevPage = function()
	{
		this.GoTo(this.ParseIndex(PatentInnerContent.scrollTop)-1);
	}
	
	//下一页
	this.LastPage = function()
	{
		this.GoTo(_patentCount);
	}
	
	//第某页
	this.GoTo = function(index)
	{
		PatentInnerContent.scrollTop = this.ParseHeight(index);
	}
	
	//根据鼠标位置换算显示第几页
	this.ParseIndex = function(positionY)
	{
		return Math.floor((positionY+ConstContentHeight-40)/(ConstHeight+25)+1);
	}
	
	//根据第几页换算鼠标位置
	this.ParseHeight = function(index)
	{
		return 20+(index-1)*(ConstHeight+25);
	}
	
	//转换控件名称
	this.ParseControlName = function(index)
	{
		return "Tiff"+index;
	}
	
	this.CheckControl = function()
	{
		var ocx = document.getElementById(this.ParseControlName(1));
		try
		{
			if(ocx.CtrGetIP() != null)
				return true;
		}
		catch (ex)
		{
	 		if(confirm("您没有安装TIF图片浏览器，不安装此图片浏览器将无法正常浏览专利说明书原文！\n请点击确定从专利局网站下载安装文件，点击取消放弃安装。\n安装完成后请重启IE浏览器。"))
			{
				window.location.href = 'http://211.157.104.94/sipo/zljs/govactive/setup.zip';
				return false;
			}
		}
	}

	//解析链接
	this.ParseLink = function(index)
	{
		var fileName; 
		if ( index< 10 )
		{
			fileName = "00000"+index;
		}
		else if ( index< 100 )
		{
			fileName = "0000"+index;
		}
		else if ( index< 1000 )
		{
			fileName = "000"+index;
		}
		else
		{
			fileName = "000001";
		}
		return _baseLink + fileName + ".tif";
	}
	
	//获取鼠标滑动速度
	this.ScrollSpeed = function()
	{
		var currentPostion = PatentInnerContent.scrollTop;
		var now = new Date();
		
		var speed = (currentPostion-_lastPosition)/(now-_lastRunTime);
		
		_lastRunTime = now;
		_lastPosition = currentPostion;
		return Math.abs(speed/20);
	}
	
	//显示现在第几页
	this.SetPageIndex = function( index )
	{
		$("#PatentPage").val("第"+ index+" / "+_patentCount+" 页");
	}
	
	//全屏
	this.FullScreen = function()
	{
		$("#Right").css("display", "none");
		$("#Left").css("width", document.documentElement.clientWidth);
		LastConstWidth = ConstWidth;
		this.ChangeWidth(document.documentElement.clientWidth-60);
	}
	
	//恢复
	this.RegularScreen = function()
	{
		$("#Left").css("width", document.documentElement.clientWidth-ConstRightWidth);
		$("#Right").css("display", "block");
		this.ChangeWidth(document.documentElement.clientWidth-ConstRightWidth-60);
	}
	
	this.CreateDialogForm = function()
	{
		var formcontent = "";
		formcontent = "<DIV id='ProgressDialog' class='DialogForm' onselectstart='window.event.returnValue=false;'>"+
						  "<DIV class='DialogFormTitle'>"+
						    "正在<span id='Action'>1</span>专利文献…"+
						  "</DIV>"+
						  "<DIV class='DialogLable'>"+
						    "这可能需要一到两分钟的时间，请稍等……"+
						  "</DIV>"+
						  "<DIV class='DialogLable'>"+
						    "专利文献总数：<span id='DialogFormPatentCount'>1</span>页"+
						  "</DIV>"+
						  "<DIV class='DialogLable'>"+
						      "<DIV class='DialogFormProgressOuter'>"+
						        "<DIV class='DialogFormProgressInner'>4</DIV>"+
						      "</DIV>"+
						  "</DIV>"+
						  "<DIV class='DialogFormControlBox'>"+
						  "</DIV>"+
						"</DIV>";
		$(document.body).append(formcontent);
		var maskcontent = "<DIV class='MaskDiv' onclick='window.event.cancelBubble=true; window.event.returnValue=false;'></DIV>";
		$(document.body).append(maskcontent);

		var printform = "<DIV id='PrintDialog' class='DialogForm' onselectstart='window.event.returnValue=false;'>"+
						  "<DIV class='DialogFormTitle'>"+
						    "请输入页码或页码范围"+
						  "</DIV>"+
						  "<DIV class='DialogLable'><INPUT TYPE='radio' name='page' id='page1' value='1' checked='true' />全部</DIV>"+
						  "<DIV class='DialogLable'><INPUT TYPE='radio' name='page' id='page2' value='2' />当前所在页码</DIV>"+
						  "<DIV class='DialogLable'><INPUT TYPE='radio' name='page' id='page3' value='3' />页码范围从：<INPUT TYPE='text' disabled='true' id='pagerangefrom' value='1' size='6' maxlength='3' />到<INPUT TYPE='text' disabled='true' id='pagerangeto' value='"+_patentCount+"' size='6' maxlength='3' /></DIV>"+
						  "<DIV class='DialogLable'>"+
						      "<DIV class='DialogFormProgressOuter'>"+
						        "<DIV class='DialogFormProgressInner'>4</DIV>"+
						      "</DIV>"+
						  "</DIV>"+
						  "<DIV class='DialogFormControlBox'><input type='button' id='startprint' value='打印' /><input type='button' id='cancelprint' value='取消' />"+
						  "</DIV>"+
						"</DIV>";
		$(document.body).append(printform);
		$("#page1").click(function()
		{
			_this.ChoicePage();
		});
		$("#page2").click(function()
		{
			_this.ChoicePage();
		});
		$("#page3").click(function()
		{
			_this.ChoicePage();
		});
		$("#startprint").click(function()
		{
			_this.StartPrint();
		});
		$("#cancelprint").click(function()
		{
		    _this.CancelPrint();
		});
	}
	
	this.ChoicePage = function()
	{
		if ($("#page3").attr("checked") == true)
		{
		    $("#pagerangefrom").attr("disabled",false);
		    $("#pagerangeto").attr("disabled",false);
		}
		else
		{
		    $("#pagerangefrom").attr("disabled",true);
		    $("#pagerangeto").attr("disabled",true);
		}
	}
	
	var PrintPageFrom = 1;
	var PrintPageTo = 1;
	var CancelPrintFlag = false;
	//打印
	this.StartPrint = function()
	{
	    CancelPrintFlag = false;
	    if ($("#page1").attr("checked") == true )
	    {
	        PrintPageFrom = 1;
	        PrintPageTo = _patentCount;
	    }
	    if ($("#page2").attr("checked") == true )
	    {
	        PrintPageFrom = CurrentPatentIndex;
	        PrintPageTo = CurrentPatentIndex;
	    }
	    if ($("#page3").attr("checked") == true )
	    {
	        PrintPageFrom = parseInt($("#pagerangefrom").val());
	        PrintPageTo = parseInt($("#pagerangeto").val());
	        if ( PrintPageFrom > PrintPageTo || PrintPageFrom < 1 || PrintPageTo > _patentCount )
	        {
	            alert('输入页码错误，请重新输入！');
	            return;
	        }
	    }
		CurrentDownloadIndex = PrintPageFrom;
		setTimeout("content.PrintCurrent();",100); 
	}
	
	this.CancelPrint = function()
	{
	    CancelPrintFlag = true;
		this.HiddenProcessBar();
		this.GoTo(CurrentPatentIndex);
	}
	
	this.PrintCurrent = function()
	{
	    if ( CancelPrintFlag == false )
	    {
		    if (CurrentDownloadIndex <= PrintPageTo) 
		    {
			    this.DownloadPatent(CurrentDownloadIndex);
			    var ocx = document.getElementById(this.ParseControlName(CurrentDownloadIndex));
			    ocx.CtlPrintPageAndNumSet(this.ParseLink(CurrentDownloadIndex), "1", "CN"+_patentNO);
			    this.UpdateProgress((CurrentDownloadIndex-PrintPageFrom+1)/(PrintPageTo-PrintPageFrom+1));
			    CurrentDownloadIndex++;
			    setTimeout("content.PrintCurrent();",100);
		    }
		    else 
		    {
			    this.HiddenProcessBar();
			    alert('打印完成。');
			    this.GoTo(CurrentPatentIndex);
		    }
		}
	}
	
	this.UpdateProgress = function(nNewPercent)
	{
		$(".DialogFormProgressInner").css("width", (parseInt($(".DialogFormProgressOuter").css("width"))* nNewPercent)+ "px")
	}
	
	this.HiddenProcessBar = function() 
	{
		$(".PatentView").css("display", "block");
		$(".MaskDiv").css("width", 0).css("height", 0);
		$(".DialogForm").css("display","none");
	}
	
	this.ShowProcessBar = function( action ) 
	{
		$("#Action").html(action);
		$("#DialogFormPatentCount").html(_patentCount);
		$(".PatentView").css("display", "none");
		$(".MaskDiv").css("width", document.documentElement.clientWidth).css("height", document.documentElement.clientHeight);
		$("#ProgressDialog").css("display","block").css("left", (document.documentElement.clientWidth-350)/2).css("top", (document.documentElement.clientHeight-150)/2);
	}
}

var content;
//初始化并挂接滚动条事件
$(document).ready(function()
{
	//鼠标点击打开或关闭层
	$(".PatentBlockTitle").click(function()
	{
		$(this).next().toggle("fast");
		if ( $(this).children("div").attr("class") != "plus_sm")
		{
		    $(this).children("div").attr("class", "plus_sm");
		}
		else
		{
		    $(this).children("div").attr("class", "minus_sm");
		}
	});
});

function ValidateImage()
{
	var _this = this;
	var _url = "";
	this.Initialize = function(url)
	{
		_url = url;
		$("<div id='basicModalContent' style='display:none'><table id='ValidateTable'><tr><td colspan='2' id='TableHeader'>请输入验证码</td></tr><tr><td style='height:34px;'><input type='text' value='' id='ValidateCode' class='ValidateInput' maxlength='4' /></td><td><img id='ValidateImage' src=''/></td></tr><tr><td></td><td><input type='submit' value='确定' id='ValidateSubmitButton' class='ValidateButton' /></td></tr></table></div>").appendTo("body");
		this.BindEvent();
	}
	
	//绑定事件
    this.BindEvent = function()
    {
		$('#NeedValidate').click(function (e) 
		{
			e.preventDefault();
			$('#ValidateImage').attr("src", "/system/ValidateImage.rails?id="+Math.random()*220);
			$('#basicModalContent').modal();
		});
		
		$('#ValidateSubmitButton').click(function () 
		{
			_this.ValidateSubmit();
		});
	
    }
    
    this.ValidateSubmit = function()
    {
		$.ajax(
		{
			url: '/System/ValidateSubmitForm.rails?ValidateCode='+$("#ValidateCode").val(),
			type: 'Get',
			dataType: 'string',
			timeout: 10000,
			error: function()
			{
			alert("error");
			},
			success: function(response)
			{
				if ( response == "1" )
				{
					$.modal.close();
					window.location = _url;
				}
				else
				{
					$('#ValidateImage').attr("src", "/system/ValidateImage.rails?id="+Math.random()*220);
				}
			}
		});
    }
}
var sqgk;
var sdsq;
function DownloadTiff(firstLink, patentCount, filename, objname) 
{
	var _firstLink = firstLink;
	var _baselink = "";
	var _patentCount = patentCount;
	var _objname = objname;
	
	var _filename = filename;
	var ocx = document.getElementById("PDOCX");
	
	this.Initialize = function()
	{
	    _baseLink = _firstLink.replace(/000001.tif/,"");
	    this.CheckControl();
	    this.CreateDialogForm();
	}
	
	this.InitializeSDSQ = function()
	{
	    _baseLink = _firstLink.replace(/000001.tif/,"");
	}
	
	//下载专利
	this.DownloadPatent = function(index)
	{
		ocx.bViewOrDown = "0";
		ocx.InitCtrl();
		ocx.SetCheckCode("2111");
        ocx.SetUserName("test100");
		ocx.SetNetTifPathDemo(this.ParseLink(index));
	}
	
	var SavePath = "";
	//获取保存路径
	this.GetSaveFolder = function()
	{
		return ocx.CtrGetPath()+"\\";
	}
	
	var CurrentDownloadIndex = 1;
	//下载
	this.Download = function()
	{
	    _baseLink = _firstLink.replace(/000001.tif/,"");
		SavePath = this.GetSaveFolder();
		if ( SavePath == "\\" )
		{
		    alert("请选择正确的保存路径！");
			return;
		}
		this.ShowProcessBar("下载");
		CurrentDownloadIndex = 1;
		setTimeout(_objname+".DownloadCurrent();",100); 
	}
	
	this.DownloadCurrent = function()
	{
		if (CurrentDownloadIndex < _patentCount + 1) 
		{
			this.DownloadPatent(CurrentDownloadIndex);
			ocx.CtrSaveData(SavePath+_filename);
			this.UpdateProgress(CurrentDownloadIndex/_patentCount);
			CurrentDownloadIndex++;
			setTimeout(_objname+".DownloadCurrent();",50);
		}
		else 
		{
			alert("下载完毕！");
			this.HiddenProcessBar();
		}
	}
	
	this.CheckControl = function()
	{
		try
		{
			if(ocx.CtrGetIP() != null)
				return true;
		}
		catch (ex)
		{
	 		if(confirm("您没有安装TIF图片浏览器，不安装此图片浏览器将无法正常浏览专利说明书原文！\n请点击确定从专利局网站下载安装文件，点击取消放弃安装。\n安装完成后请重启IE浏览器。"))
			{
				window.location.href = 'http://211.157.104.94/sipo/zljs/govactive/setup.zip';
				return false;
			}
		}
	}

	//解析链接
	this.ParseLink = function(index)
	{
		var fileName; 
		if ( index< 10 )
		{
			fileName = "00000"+index;
		}
		else if ( index< 100 )
		{
			fileName = "0000"+index;
		}
		else if ( index< 1000 )
		{
			fileName = "000"+index;
		}
		else
		{
			fileName = "000001";
		}
		return _baseLink + fileName + ".tif";
	}
	
	
	
	this.CreateDialogForm = function()
	{
		var formcontent = "";
		formcontent = "<DIV class='DialogForm' onselectstart='window.event.returnValue=false;'>"+
						  "<DIV class='DialogFormTitle'>"+
						    "正在<span id='Action'>1</span>专利文献…"+
						  "</DIV>"+
						  "<DIV class='DialogLable'>"+
						    "这可能需要一到两分钟的时间，请稍等……"+
						  "</DIV>"+
						  "<DIV class='DialogLable'>"+
						    "专利文献总数：<span id='DialogFormPatentCount'>1</span>页"+
						  "</DIV>"+
						  "<DIV class='DialogLable'>"+
						      "<DIV class='DialogFormProgressOuter'>"+
						        "<DIV class='DialogFormProgressInner'>4</DIV>"+
						      "</DIV>"+
						  "</DIV>"+
						  "<DIV class='DialogFormControlBox'>"+
						  "</DIV>"+
						"</DIV>";
		$(document.body).append(formcontent);
		var maskcontent = "<DIV class='MaskDiv' onclick='window.event.cancelBubble=true; window.event.returnValue=false;'></DIV>";
		$(document.body).append(maskcontent);
	}
	
	this.UpdateProgress = function(nNewPercent)
	{
		$(".DialogFormProgressInner").css("width", (parseInt($(".DialogFormProgressOuter").css("width"))* nNewPercent)+ "px")
	}
	
	this.HiddenProcessBar = function() 
	{
		$(".PatentView").css("display", "block");
		$(".MaskDiv").css("width", 0).css("height", 0);
		$(".DialogForm").css("display","none");
	}
	
	this.ShowProcessBar = function( action ) 
	{
		$("#Action").html(action);
		$("#DialogFormPatentCount").html(_patentCount);
		$(".PatentView").css("display", "none");
		$(".MaskDiv").css("width", document.documentElement.clientWidth).css("height", document.documentElement.clientHeight);
		$(".DialogForm").css("display","block").css("left", (document.documentElement.clientWidth-350)/2).css("top", (document.documentElement.clientHeight-150)/2);
	}
}

