﻿<!--
/*
  是否为双屏！
*/
var WIDTH_DOUBLESCREEN=false;
var HEIGHT_DOUBLESCREEN=false;

/*
*检测是否双屏
*
*/
function CheckDoubleScreen()
{
	if(screen.width>1900)
		WIDTH_DOUBLESCREEN=true;
	if(screen.height>1200)
		HEIGHT_DOUBLESCREEN=true;
}

CheckDoubleScreen();

/*
是否双屏
*/
function IsDoubleScreen()
{
	if(WIDTH_DOUBLESCREEN||HEIGHT_DOUBLESCREEN)
		return true;
	else
		return false;
}

/*
	根据是否双屏得到屏幕值

*/
function GetMaxSingleScreenWidth()
{
	if(WIDTH_DOUBLESCREEN)
		return screen.availWidth/2;
	else
		return screen.availWidth;
}

/*
	根据是否双屏得到屏幕值

*/
function GetMaxSingleScreenHeight()
{
	if(HEIGHT_DOUBLESCREEN)
		return screen.availHeight/2;
	else
		return screen.availHeight;
}

/*
　在Url后面拼接时间参数，以保证不会存储在Cache
*/
function GetTimeUrl(url)
{
	return url;
}

/*
	打开小窗口

*/
function OpenSmallWindow(url,name, isModal, modalAguments)
{
	var handle;
   handle = OpenNewWindow(url,name,500,350, isModal, modalAguments);
   return handle;
}

/*
	打开中窗口

*/
function OpenMediumWindow(url,name, isModal, modalAguments)
{
	var handle;
   handle = OpenNewWindow(url,name,800,650, isModal, modalAguments);
   return handle;
}

/*
	打开大窗口

*/
function OpenLargeWindow(url,name, isModal, modalAguments)
{
	var handle;
   handle = OpenNewWindow(url,name,1000,750, isModal, modalAguments);
   return handle;
}

/*
	全屏
	isDoubleScreen表示是否考虑双屏。true表示当双屏时打开为双屏。false表示当双屏时也打开为半屏

*/
function OpenMaxWindow(url,name,isDoubleScreen, isModal, modalAguments)
{
	var target=url;
	var handle;
	var width, height;
	var isRealModal=false;
	
	if(isDoubleScreen)
	{
		width=screen.availWidth;
		height=screen.availHeight;
	}
	else
	{
		width=GetMaxSingleScreenWidth();
		height=GetMaxSingleScreenHeight();
	}
	
	///	
	if(isModal==null)
		isRealModal=false;
	else
		isRealModal=isModal;
			
	handle=OpenScrollWindow(target, name, width,height, isRealModal, modalAguments);
	if(isRealModal==true)
		return handle;
	else
	{
		if (document.all)
		{
			handle.moveTo(0,0);		
			handle.resizeTo(width, height);
			handle.outerWidth=width;
			handle.outerHeight=height;
		}
		return handle;
	}
	///newwindow.location=target;
}

/*
**打开窗口
* 注：	若不指明Name，缺省为_blank
*		若不指明height,width，缺省为screen.height, screen.width
*		若不指明status, toolbar, scrollbars, menubar, resizable，缺省为false，即不显示

		isDoubleScreen表示是否考虑双屏。true表示当双屏时打开为双屏。false表示当双屏时也打开为半屏

*/
function OpenWindow(url, name,  width, height, status, toolbar, scrollbars, menubar, resizable, isDoubleScreen, isModal, modalAguments)
{      
   var DEFAULT_NAME = "_blank";
   var DEFAULT_BAR = "no";
   var realName,realUrl,realWidth,realHeight, realStatus, realToolbar, realScrollbars;
   var realMenuBar, realResizable;
   var realIsModal, realModalArguments;
   var iTop, iLeft,opts;
   var handle;
   var realIsDoubleScreen;   
   
   if(url==null) 
   { 
      return;  
   } 
   realUrl = url;
   
   ///对参数进行检查
   
   realName = GetParameterValue(name,null, DEFAULT_NAME);
   
   realWidth = GetParameterValue(width,null, screen.width);
   
   realHeight = GetParameterValue(height,null, screen.height);
   
   realStatus = GetParameterValue(status,null, DEFAULT_BAR);
   
   realToolbar = GetParameterValue(toolbar,null, DEFAULT_BAR);
   
   realScrollbars = GetParameterValue(scrollbars,null, DEFAULT_BAR);
   
   realMenuBar = GetParameterValue(menubar,null, DEFAULT_BAR);
   
   realResizable = GetParameterValue(resizable,null, DEFAULT_BAR);
   
   realIsDoubleScreen = GetParameterValue(isDoubleScreen, null, false);
   
   realIsModal = GetParameterValue(isModal, null , false);
   
   realModalArguments = GetParameterValue(modalAguments, null , window);
   
   ///将窗口打开
   if(realIsDoubleScreen==false)
   {
		iTop=(GetMaxSingleScreenHeight()-realHeight)/2;
		iLeft=(GetMaxSingleScreenWidth()-realWidth)/2;
   }
   else
   {
		iTop=(screen.height-realHeight)/2;
		iLeft=(screen.width-realWidth)/2;        
   }
   if(iTop<0) 
   {
		iTop = 1;
   }
   if(iLeft<0)
   {
	  iLeft =1;
   }
   //确定是否模式对话框

   if(realIsModal)
   {
        opts = GetDialogOptions(iLeft, iTop, realHeight, realWidth, realStatus, realToolbar, realScrollbars, realMenuBar, realResizable);		
		handle = window.showModalDialog(realUrl, realModalArguments, opts);		
   }
   else
   {
        opts = GetWindowOptions(iLeft, iTop, realHeight, realWidth, realStatus, realToolbar, realScrollbars, realMenuBar, realResizable);    
		handle = window.open(realUrl, realName, opts);      
   }
   
   return handle;
}

/*
*
*得到窗口Options
*
*/
function GetWindowOptions(left, top, height, width,  status, toolbar, scrollbars, menubar, resizable)
{
   var arg = "";
   arg = arg + "height=" + height +", width=" + width + ", ";
   arg = arg + "status="+status+", toolbar="+toolbar+", ";
   arg = arg + "scrollbars="+scrollbars+", menubar="+menubar+", ";
   arg = arg + "left=" + left +", top=" + top +", ";
   arg = arg + "resizable="+resizable;	
   return arg;
}

/*
*
*得到对话框Options（即模式对话框）
*
*/
function GetDialogOptions(left, top, height, width,  status, toolbar, scrollbars, menubar, resizable)
{
   var arg = "";
   arg = arg + "dialogLeft=" + left +"px; dialogTop=" + top + "px; ";
   arg = arg + "dialogHeight=" + height +"px; dialogWidth=" + width + "px; ";
   arg = arg + "status="+status+"; toolbar="+toolbar+"; ";
   arg = arg + "scrollbars="+scrollbars+"; menubar="+menubar+"; ";
   ///arg = arg + "center=yes; ";
   arg = arg + "resizable="+resizable;	
   return arg;
}

/*
* 在最下角打开窗口！

*
*/
function OpenWindowInCorner(url, name, width, height, isModal)
{
	  var itop=GetMaxSingleScreenHeight()-height-80;
	  var ileft=GetMaxSingleScreenWidth()-width-8;	
	  var arg;
	  var handle;
	   
	  if(itop<0) 
	  {
		itop = 1;
	  }
	  if(ileft<0)
	  {
		ileft =1;
	  }
	  
	  arg="height=" + height +",width=" + width + ", status=no, toolbar=no ,scrollbars=yes, menubar=no, left=" + ileft +",top=" + itop +" , resizable=yes";
	  
	  handle = window.open(url,name,arg);
	  return handle;   
}

/*
* 在最下角的正下面打开窗口！

*
*/
function OpenWindowInCornerButtom(url, name, width, height)
{
	  var itop=GetMaxSingleScreenHeight();
	  var ileft=GetMaxSingleScreenWidth()-width-8;	
	  var arg;
	  var handle;
	   
	  if(itop<0) 
	  {
		itop = 1;
	  }
	  if(ileft<0)
	  {
		ileft =1;
	  }
	  
	  arg="height=" + height +",width=" + width + ", status=no, toolbar=no ,scrollbars=yes, menubar=no, left=" + ileft +",top=" + itop +" , resizable=yes";
	  
	  handle = window.open(url,name,arg);
	  return handle;   
}
/*
 * 得到参数值

 * 当paramValue=compareValue,返回defaultValue
 * 否则返回	paramValue
 */
function GetParameterValue(paramValue, compareValue, defaultValue)
{
	if(paramValue==compareValue) return defaultValue;
	return paramValue;
}

/*
**打开滚动窗口
*/
function OpenScrollWindow(url, name, width, height,isModal,modalArgs)
{
	return OpenWindow(url,name,width, height,"no","no","yes","no","yes",false,isModal,modalArgs); 
}

/*
**打开固定大小的窗口

*/
function OpenFixedWindow(url, name, width, height,isModal,modalArgs)
{
	return OpenNewWindow(url,name,width, height,isModal,modalArgs); 
}

/*
**打开滚动、可调大小的窗口
*/
function OpenScrollResizableWindow(url, name, width, height,isModal,modalArgs)
{
	return OpenWindow(url,name,width, height,"no","no","yes","no","yes",false,isModal,modalArgs); 
}
/*
**打开滚动,不可调大小的窗口
*/
function OpenScrollNoResizableWindow(url, name, width, height,isModal,modalArgs)
{
	return OpenWindow(url,name,width, height,"no","no","yes","no","no",false,isModal,modalArgs); 
	 
}
/*
**打开带有菜单的滚动窗口

*/
function OpenMenuScrollWindow(url, name, width, height,isModal,modalArgs)
{
	return OpenWindow(url,name,width, height,"no","no","yes","yes","yes",false,isModal,modalArgs); 
}

/*
**打开带有菜单的窗口

*/
function OpenNewScrollWindow(url, name, width, height,isModal,modalArgs)
{
	return OpenWindow(url,name,width, height,"yes","yes","yes","yes","yes",false,isModal,modalArgs); 
}

/*
**打开带有菜单的窗口

*/
function OpenMenuWindow(url, name, width, height,isModal,modalArgs)
{
	return OpenWindow(url,name,width, height,"no","no","yes","no","no",false,isModal,modalArgs); 	
}

/*
**打开新窗口，无任何bar
*/
function OpenNewWindow(url, name, width, height,isModal,modalArgs)
{	
	return OpenWindow(url,name,width, height,"no","no","yes","no","yes",false,isModal,modalArgs);
}

/*
*关闭窗口
*/
function CloseWindow()
{
	window.close();
}

/*
* 重新加载父窗口

*/
function ReloadParentWindow()
{
	top.opener.location.href = top.opener.location.href;
}

/*
* 重新加载指定的父窗口中的Frame
*/
function ReloadSpecifiedWindow(framename)
{
	var tempframe = top.opener.parent.frames[framename];
	tempframe.src=tempframe.src;
}

/*
* 重新加载指定的父窗口中的Frame并将自已关闭
*/
function CloseWindowAndReloadSpecifiedWindow(framename)
{
	ReloadSpecifiedWindow(framename);
	CloseWindow();
}

/*
* 重新加载父窗口并将自已关闭

*/
function CloseWindowAndReloadParent()
{
	ReloadParentWindow();
	CloseWindow();
}

/*
* 将指定的控件移动到中央

*/
function MoveToCenter(id, width, height)
{
   var moveElement, iTop, iLeft;
   
   moveElement = document.getElementById(id);
   
   if(moveElement==null)
		return;
       
   iTop=(document.body.clientHeight-height)/2;
   iLeft=(document.body.clientWidth-width)/2;        
   if(iTop<0) 
   {
		iTop = 1;
   }
   if(iLeft<0)
   {
	  iLeft =1;
   }   
   
   moveElement.style.pixelTop = iTop;
   moveElement.style.pixelLeft = iLeft;
   moveElement.style.position = "absolute";     
}

/*
*替换Url中的空格，解析字符！
*/
function ReplaceUrl(url)
{
	return url.replace(" ", "+");
}


/*
*替换Url中的空格，解析字符！
*/
function ShowModal(url, title, size)
{
	var sOpt = new String();
	switch( size )
	{
		case "small" : 
			sOpt = 'status:no;dialogWidth:600px;dialogHeight:235px;resizable:no;center:yes;edge:sunken;unadorned:1;help:no';
			break;
		case "middle" : 
			sOpt = 'status:no;dialogWidth:750px;dialogHeight:635px;resizable:no;center:yes;edge:sunken;unadorned:1;help:no';
			break;
		case "big" : 
			sOpt = 'status:no;dialogWidth:950px;dialogHeight:735px;resizable:no;center:yes;edge:sunken;unadorned:1;help:no';
			break;
	}

	/* var NewUrl = '/PresentationDemo/ModalHost.aspx';
	var RedirectUrl = new String();	
	NewUrl = NewUrl + '?' + title + '|' + url; */
	
	outVal = window.showModalDialog(url, window, sOpt);
	return outVal;
}

/*
* 将当前窗口设置为最大
*/
function MaxCurrentWindow(isDoubleScreen)
{		
	var width, height;
	
	if(isDoubleScreen)
	{
		width=screen.availWidth;
		height=screen.availHeight;
	}
	else
	{
		width=GetMaxSingleScreenWidth();
		height=GetMaxSingleScreenHeight();
	}
	
	window.moveTo(0,0);		
	window.resizeTo(width, height);	
	window.outerWidth=width;
	window.outerHeight=height;
}

-->

