﻿var FileProcessor={
	content:{path:'http://www.ezcom.cn/meeting/jf2009/ppt/',pass:'20090225',cache:'',file:'',boxid:'messagebox'},
	CenterOffset:function(base){
		var d;if(base==undefined)d=document.documentElement;else d=$(base);
		var dh=d.scrollHeight,dw=d.scrollWidth,dt=d.scrollTop,dl=d.scrollLeft;
		var ot=dt+d.clientHeight/2,ol=dl+d.clientWidth/2;
		return [ol,ot];
	},
	Download:function(file){
		this.content.file=file;
		if(this.content.cache!='')
			this.GetFile(this.content.cache);
		else
			this.GetPass(1);
	},
	GetPass:function(v){
		box=document.createElement('div');
		box.setAttribute("id",this.content.boxid);
		document.body.appendChild(box);
		
		msgbox=$(box.id);    
		msgbox.innerHTML='';
		if(v==1){
			pos=this.CenterOffset(),cw=300,ch=200;pos[0]-=cw/2;pos[1]-=ch/2;
			msgbox.innerHTML='<div id="msg_bg" style="position:absolute;top:0px;left:0px;z-index:50000;width:'+document.documentElement.clientWidth+'px;height:'+document.documentElement.scrollHeight+'px;background:#999;_filter:Alpha(Opacity=80);opacity:0.8;"></div><div id="msg_info" style="position:absolute;z-index:60000;width:'+cw+'px;height:'+ch+'px;left:'+pos[0]+'px;top:'+pos[1]+'px;font:12px;"><div id="msg_center"> <strong>友情提示：</strong> 请输入下载密码<p><input type="password" id="msg_txtPass" value=""/>&nbsp;&nbsp;&nbsp;<a href="javascript:void(0)" onclick="FileProcessor.GetFile($(\'msg_txtPass\').value);">确定</a></p></div></div>';
		}
	},
	GetFile:function(p){
		if(p.length==0){
			alert('密码不能为空，请重试！');return;
		}
		if(p==this.content.pass){
			this.content.cache=this.content.pass;
			try{
			//location.href=this.content.path+this.content.file;
			window.open(this.content.path+this.content.file);
			}catch(e){alert(e.toString());}
		}
		else
			alert('密码错误，重试请重新点击下载');
		$(this.content.boxid).innerHTML='';
	}
}
function $(element) {
  if (arguments.length > 1) {
    for (var i = 0, elements = [], length = arguments.length; i < length; i++)
      elements.push($(arguments[i]));
    return elements;
  }
  if (typeof element == 'string')
    element = document.getElementById(element);
  return element;
}