﻿/*<![CDATA[*/
if(typeof(HTMLElement)!="undefined" && !window.opera)
{
  HTMLElement.prototype.__defineGetter__("outerHTML",function()
  {
	var a=this.attributes, str="<"+this.tagName, i=0;for(;i<a.length;i++)
	if(a[i].specified) str+=" "+a[i].name+'="'+a[i].value+'"';
	if(!this.canHaveChildren) return str+" />";
	return str+">"+this.innerHTML+"</"+this.tagName+">";
  });
  HTMLElement.prototype.__defineSetter__("outerHTML",function(s)
  {
	var r = this.ownerDocument.createRange();
	r.setStartBefore(this);
	var df = r.createContextualFragment(s);
	this.parentNode.replaceChild(df, this);
	return s;
  });
  HTMLElement.prototype.__defineGetter__("canHaveChildren",function()
  {
	return !/^(area|base|basefont|col|frame|hr|img|br|input|isindex|link|meta|param)$/.test(this.tagName.toLowerCase());
  });
}

function clearFrame()
{
    if(window.opener==null)
    { 
        window.opener=null; 
        window.close(); 
        window.open('#','','toolbar=no,menubar=no,location=no,status=no,width=' + screen.width + ',height=' + screen.height + ',left=0,top=0'); 
    } 
}

function Navigation(url)
{
	window.location.href=url;
}

function $() {
  var elements = new Array();
  
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1) 
      return element;
      
    elements.push(element);
  }
  
  return elements;
}

function openNoFrameWindow(url,left,top,width,height)
{
    var w = screen.width-10;
    var h = screen.height-65;
    if(width!=null) w=width;
    if(height!=null) h=height;
    var l=eval((window.screen.availWidth-w)/2);
    var t=eval((window.screen.availHeight-h)/2);    
    if(left!=null) l=left;
    if(top!=null) t=top;
    window.open(url,"","width="+w+",height="+h+",top="+t+",left="+l+",toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes");
}

function openWindow(openUrl,width,heith,isModal,max,args)
{
	var wid=800;
	var heit=600;
	if (openUrl ==null || openUrl == ''){
		alert('请指定要弹出窗口的URL！');
		return false;
	}
	//默认一个宽度与高度(800*600)
	if(width == 0 || heith==0){
		if(width==0){
			wid=800;
		}else{
			heit=600
		}
	}else{
		wid=width;
		heit=heith;
	}
	var top = eval(window.screen.availHeight/4+(window.screen.availHeight/2-heit)/2);
	var left = eval(window.screen.availWidth/4+(window.screen.availWidth/2-wid)/2);
	//去掉状态栏的高度
	heit=heit-28;
	var sFeatures="dialogWidth:"+wid+"px;dialogHeight:"+heit+"px;help:no"+";resizable:yes"+";status:yes";
	var sArguments="";
	if(args != null || args != ""){
		sArguments = args;
	}
	//便于调试，把状态栏加上，程序发布后把它去除
	var popParameters
	if(max==true)
	{
	    popParameters = 'toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no,fullscreen=no,top='+top+',left='+left+',width='+wid+',height='+heit;
	}else{
	    popParameters = 'resizable=yes,status=no,menubar=no,scrollbars=yes,top='+top+',left='+left+',width='+wid+',height='+heit;
	}
	if(isModal == true){
		//弹出模式窗口。
		openWin = window.showModalDialog(openUrl,sArguments,sFeatures);
	}else{
		openWin = window.open(openUrl,'_blank',popParameters,true);
	}
}

/*]]>*/