﻿// JScript 文件

String.prototype.format=function(){   //格式化字符串 e.g. "a={0}&b={1}".format('A','B');
		var str=this;
		var matchs=str.match(/\{\d\}/ig);
		for(var i=0;i<arguments.length;i++){
			str=str.replace(eval('/\\{'+i+'\\}/ig'),arguments[i]); 
		}
		return str;
}
function exist(s){return $(s)!=null;}
 /*
 设置加载信息
 */
function addschedule(int1){
 	 if(int1==0){
	 	var m=document.createElement('div');
	 	m.id='schedule';
	 	m['style']['position'] = "absolute";
	 	m['style']['z-index']='999';	 	
	 	m['style']['border']='1px solid #6298CD';
	 	m['style']['width']='200px';
	 	m['style']['padding']='15 15 15 15';
	 	m['style']['backgroundColor']='#EFF3FB';
	 	m.innerHTML='正在加载……,请稍后';
	 	document.body.appendChild(m);
	 	divInit('schedule',0,0);
 	 }else{
 	 	 if(exist('schedule')){
 	 	 	document.body.removeChild($('schedule'));
 	 	 }
 	 }
 }
  function GetXY(){
		var theX,theY; 
		if(window.innerWidth){ 
		theX=window.innerWidth; 
		}
		else if(document.documentElement && document.documentElement.clientWidth){ 
		theX=document.documentElement.clientWidth; 
		}else if(document.body){ 
		theX=document.body.clientWidth; 
		} 
		if(window.innerHeight){ 
		theY=window.innerHeight; 
		}else if(document.documentElement && document.documentElement.clientHeight){ 
		theY=document.documentElement.clientHeight; 
		}else if(document.body){ 
		theY=document.body.clientHeight; 
		}
		return[theX,theY];
}
    	 /*获取页面滚动条top值*/  
function GetscrollTop(){
        var scrollPos; 
        if (typeof window.pageYOffset != 'undefined') { 
           scrollPos = window.pageYOffset; 
        } 
        else if (typeof document.compatMode != 'undefined' && 
             document.compatMode != 'BackCompat') { 
           scrollPos = document.documentElement.scrollTop; 
        } 
        else if (typeof document.body != 'undefined') { 
           scrollPos = document.body.scrollTop; 
        } 
        return scrollPos;
    }
  /*设置层的位置:居中，居右，居左*/  
  function divInit(_sId,int1,int2){ 
    if(typeof(_sId)=='string')_sId=$(_sId);
 	_sId['style']['display'] = '';
	_sId['style']['position'] = "absolute";
	var xy=GetXY();
 	 switch(int1){
 	 	 case 1://left
 	 	 	 _sId['style']['left'] = '5px';
 	 	 	 break;
 	 	 case 2://right
 	 	 	 _sId['style']['left'] = xy[0]-_sId.offsetWidth -5+"px";
 	 	 	 break;
 	 	 default:
 	 	 	 _sId['style']['left'] = (xy[0] / 2) - (_sId.offsetWidth / 2)+"px";
 	 	 	 break;
	 }
	 switch(int2){
	 	case 1://top
	 		_sId['style']['top'] ='5px';
	 		break;
	 	default://mid
	 		_sId['style']['top'] = (xy[1] / 2 + GetscrollTop()) - (_sId.offsetHeight / 2)+"px";
	 		break;
	 }
 }