﻿// JavaScript Document
var Class = {
	create: function() {
		return function() { this.initialize.apply(this, arguments); }
	}
}

var Extend = function(destination, source) {
	for (var property in source) {
		destination[property] = source[property];
	}
}

var Bind = function(object, fun) {
	return function() {
		return fun.apply(object, arguments);
	}
}

var BindAsEventListener = function(object, fun) {
	var args = Array.prototype.slice.call(arguments).slice(2);
	return function(event) {
		return fun.apply(object, [event || window.event].concat(args));
	}
}

var CurrentStyle = function(element){
	return element.currentStyle || document.defaultView.getComputedStyle(element, null);
}

function addEventHandler(oTarget, sEventType, fnHandler) {
	if (oTarget.addEventListener) {
		oTarget.addEventListener(sEventType, fnHandler, false);
	} else if (oTarget.attachEvent) {
		oTarget.attachEvent("on" + sEventType, fnHandler);
	} else {
		oTarget["on" + sEventType] = fnHandler;
	}
};

function removeEventHandler(oTarget, sEventType, fnHandler) {
    if (oTarget.removeEventListener) {
        oTarget.removeEventListener(sEventType, fnHandler, false);
    } else if (oTarget.detachEvent) {
        oTarget.detachEvent("on" + sEventType, fnHandler);
    } else { 
        oTarget["on" + sEventType] = null;
    }
};

//生成div
var alertDiv = Class.create();
alertDiv.prototype = {
	initialize: function(obj, options) {
		this.obj=obj;
		this.SetOptions(options);
		//范围限制
		this.Shadow = !!this.options.Shadow;
		this.Resizable = !!this.options.Resizable;
		//this.MaxSize = !!this.options.MaxSize;		
		this.Dragable = !!this.options.Dragable;
		this.Closable = !!this.options.Closable;
		
		this.PReLoad = !!this.options.PReLoad;
		
		this.minWidth = Math.round(this.options.minWidth);
		this.minHeight = Math.round(this.options.minHeight);		
		this.contentType = Math.round(this.options.contentType);
		
		this.alertDivTitleStr=this.options.alertDivTitleStr;
		this.srcUrl=this.options.srcUrl;
		this.srcHTML=this.options.srcHTML;
		this.createDiv();
	},
	//设置默认属性
	SetOptions: function(options) {
		this.options = {//默认值
			Shadow:		false,//是否有阴影
			Resizable: 	false,//是否允许缩放
		//	MaxSize:	false,//允许最大化窗口
		    PReLoad:    false,
			Closable:	true,//关闭按钮
			Dragable:	true,//允许拖拽
			minWidth:	550,//最小宽度
			minHeight:	350,//最小高度
			contentType:1,//内容形式1为iframe 0为div
			alertDivTitleStr:"loadding...",
			srcUrl:		"about:blank",
			srcHTML:	"HTML CODE"
		};
		Extend(this.options, options || {});
	 },
	 //生成HTML
	 createDiv:function(){
		if(is_ie)this.forbiSelect();
		if($("alertDivMark")){     
	        $("alertDivMark").style.display="";
	    }
		else
		{
			var  alertDivMark=document.createElement("div");
				  alertDivMark.setAttribute("id","alertDivMark");
	    		  document.body.appendChild(alertDivMark);
		}

	    if($("alertDiv")==null)
	    {
	    	var  alertDivcontainer=document.createElement("div");
				  alertDivcontainer.setAttribute("id","alertDiv"); 
				  document.body.appendChild(alertDivcontainer);
        	$("alertDiv").className="alertDiv";
		}
		else
		{
			$("alertDiv").style.display="";
		}
		var tableDragHTML="";
		if (this.Dragable)
			tableDragHTML='class="alertDivTitle alertDivHander"';
		else
			tableDragHTML='class="alertDivTitle"';
		
		var  PReLoadHTML="";
		if(this.PReLoad)
		    PReLoadHTML="true";
		else
		    PReLoadHTML="false";
		
		var alarmHTML="";
		if(!this.Closable)
			alarmHTML='<td width="25" align="center" valign="middle"><a href="#" class="alertDivAlarm" id="alertDivAlarm"></a></td>';
		var headTableHTML='<table cellspacing="0" border="0" style="width:100%;border-collapse:collapse;">'+alarmHTML+'<td '+tableDragHTML+' id="alertDivTitle">'+this.alertDivTitleStr+'</td>';
		if(this.Closable)
			//headTableHTML+='<td width="25" align="center" valign="middle"><a href="#" class="alertDivMaxSize" id="alertDivMaxSize">M</a></td>';
		headTableHTML+='<td width="25" align="center" valign="middle"><a href="javascript:void(0);" class="alertDivCloseDiv" reload="'+PReLoadHTML+'" id="alertDivCloseDiv"></a></td>';
		headTableHTML+='</tr></table>';
		var contentHTML="";
		if(this.contentType==1)
			contentHTML='<iframe src="about:blank" frameborder="0" width="100%" id="dragIframe" scrolling="auto" name="dragIframe"></iframe>';
		else
			contentHTML='<div id="alertDivHtmlBox">'+this.srcHTML+'</div>';
	
		var resizeHTML='';
		if(this.Resizable)
			resizeHTML='<div id="rRightDown"> <\/div>';
		
	    var optHTML='<div class="alertDivHeader" id="alertDivHeader">'+headTableHTML+'<\/div><div id="alertDivContentBox">'+contentHTML+'<\/div><div class="alertDivBottom" id="alertDivBottom"><\/div>'+resizeHTML;
								
			// optHTML+='<div id="alertDivContentBox">'+contentHTML+'<\/div>';
//			 optHTML+='<div class="alertDivBottom"><\/div>'+resizeHTML;
		
		$("alertDiv").innerHTML=optHTML;
	
		if(this.Dragable)
			addEventHandler($("alertDivTitle"), "mouseover", this.abDrag);
		
	//	if(this.MaxSize)
			//addEventHandler($("alertDivMaxSize"), "click", "function(){abSize("+this.minWidth+","+this.minHeight+");}");
			//{
			//	$("alertDivMaxSize").attachEvent("onclick",function(){abSize(""+this.minWidth+"",""+this.minHeight+"");});
			//}
		if(this.Closable)
		{	
		   
		    addEventHandler($("alertDivCloseDiv"), "click", alertCloseDiv);
		}
		//removeEventHandler($("alertDivCloseDiv"), "click", this.closeDiv);
		$("alertDiv").style.width=this.minWidth+"px";
		
		

		$("alertDiv").style.height=($("alertDivHeader").clientHeight+this.minHeight+$("alertDivBottom").clientHeight)+"px";
		if(this.Resizable){
		//	addEventHandler($("rRightDown"), "mouseout", this.doResize);	
			var rs = new Resize("alertDiv", {  Max: true, mxContainer: "",onResize:doResize });
			rs.Set("rRightDown", "right-down");
			rs.minWidth=this.minWidth;
			rs.minHeight=($("alertDivHeader").clientHeight+this.minHeight+$("alertDivBottom").clientHeight);
			//alert($("alertDiv").style.height);
			rs.Min = true;
		}
		//addEventHandler(window, "scroll", this.setsize);
		//addEventHandler(window, "resize", this.setsize);
		//window.onscroll=alertDivSetsize;
		//window.onresize=alertDivSetsize;
		if(this.contentType==1){
			addEventHandler($("dragIframe"), "load", this.dragDivLoadOk);
			$("dragIframe").style.height=this.minHeight+"px";
			}
		else
			$("alertDivHtmlBox").style.height=this.minHeight+"px";
		this.setsize();
		if(this.contentType==1)
		$("dragIframe").src=this.srcUrl;
		//alert($("alertDiv").clientHeight+"---"+$("alertDivBottom").clientHeight+"--"+$("dragIframe").clientHeight+"--"+this.minHeight)
	 },
	 doResize:function(){
	 		var totalH=$("alertDiv").clientHeight;
			var hH=$("alertDivHeader").clientHeight;
			var bH=$("alertDivBottom").clientHeight;
			
			
			if($("dragIframe"))
				$("dragIframe").style.height=(totalH-hH-bH)+"px";
			else
				$("alertDivHtmlBox").style.height=(totalH-hH-bH)+"px";
	 },
	// abSize:function(w,h){
//	 	if($("alertDivMaxSize").className=="alertDivMaxSize")
//		{
//			$("alertDiv").style.border="0px";
//			$("alertDiv").style.width=client._W();
//			$("alertDiv").style.height=client._H();
//			$("alertDiv").style.top="0px";
//			$("alertDiv").style.left="0px";
//			
//			$("alertDivMaxSize").className="alertDivMinSize";
//
//		}
//		else
//		{
//			$("alertDiv").style.width=w+"px";
//			$("alertDiv").style.height=h+"px";
//			$("alertDiv").style.top=(document.documentElement.scrollTop+(document.documentElement.clientHeight-$("alertDiv").offsetHeight)/2)+"px";
//		    $("alertDiv").style.left=(document.documentElement.scrollLeft+(document.documentElement.clientWidth-$("alertDiv").offsetWidth)/2)+"px";
//			$("alertDivMaxSize").className="alertDivMaxSize";
//		}
//	 },
	 abDrag:function(){
		 ilsrDrag.Drag('alertDiv');
	 },
	 setsize:function(){
        if($("alertDiv")!=null&&$("alertDiv").clientHeight<client._H())
        {
		    $("alertDiv").style.top=(document.documentElement.scrollTop+(document.documentElement.clientHeight-$("alertDiv").offsetHeight)/2)+"px";
		    $("alertDiv").style.left=(document.documentElement.scrollLeft+(document.documentElement.clientWidth-$("alertDiv").offsetWidth)/2)+"px";
		}
		if($("alertDivMark")!=null)
		{

		    $("alertDivMark").style.width=client._W()+"px";
		    $("alertDivMark").style.height=client._H()+"px";
		}
		
	 },
	 closeDiv:function(){
		if($('dragIframe')!=null)
	   		$('dragIframe').src="about:blank";
		$("alertDiv").style.display="none";
		$("alertDivMark").style.display="none";
		//var aD=$("alertDiv");
//		aD.parentNode.removeChild(aD);
		var selectElement=document.getElementsByTagName("select");
			for(i=0;i<selectElement.length;i++)
			{
				selectElement[i].style.visibility="visible";
			}
		
	 },
	 forbiSelect:function(){
		var selectElement=document.getElementsByTagName("select");
			for(i=0;i<selectElement.length;i++)
			{
				selectElement[i].style.visibility="hidden";
			}
	 },
	ableSelect:function(){
		var selectElement=document.getElementsByTagName("select");
			for(i=0;i<selectElement.length;i++)
			{
				selectElement[i].style.visibility="visible";
			}
	 },
	 dragDivLoadOk:function(){
	 		try{
				var f=window.frames["dragIframe"];
				if(f.document.title!="")
				$("alertDivTitle").innerHTML=f.document.title;
				
			}
			catch(e)
			{
				
			}

	 }
	
};
function alertCloseDiv()
{
    
	if($('dragIframe')!=null)
	{
	   		$('dragIframe').src="about:blank";
	}
	var r=0;
    try{
	if($("alertDivCloseDiv").getAttribute("reload").toString()=="true")
	    var r=1;
	    }
	    catch(e){}

	$("alertDiv").style.display="none";
	$("alertDivMark").style.display="none";
	//var aD=$("alertDiv");
//		aD.parentNode.removeChild(aD);
	var selectElement=document.getElementsByTagName("select");
		for(i=0;i<selectElement.length;i++)
		{
			selectElement[i].style.visibility="visible";
		}
    
	if(r==1)
	    location.reload();
}
function doResize(){
	 		var totalH=$("alertDiv").clientHeight;
			var hH=$("alertDivHeader").clientHeight;
			var bH=$("alertDivBottom").clientHeight;
			//var iH=$("dragIframe").clientHeight;
			//alert(totalH+"--"+hH+"--"+bH+"--"+iH);
			if($("dragIframe"))
				$("dragIframe").style.height=(totalH-hH-bH)+"px";
			else
				$("alertDivHtmlBox").style.height=(totalH-hH-bH)+"px";
}
function alertDivSetsize(){
        if($("alertDiv")!=null&&$("alertDiv").clientHeight<client._H())
        {
			//alert($("alertDiv").clientHeight+"-----"+(document.documentElement.scrollTop+(document.documentElement.clientHeight-$("alertDiv").offsetHeight)/2));
		    $("alertDiv").style.top=parseInt(document.documentElement.scrollTop+(document.documentElement.clientHeight-$("alertDiv").offsetHeight)/2)+"px";
		    $("alertDiv").style.left=parseInt(document.documentElement.scrollLeft+(document.documentElement.clientWidth-$("alertDiv").offsetWidth)/2)+"px";
		}
		if($("alertDivMark")!=null)
		{

		    $("alertDivMark").style.width=client._W()+"px";
		    $("alertDivMark").style.height=client._H()+"px";
		}
		
}
//缩放程序
var Resize = Class.create();
Resize.prototype = {
  //缩放对象
  initialize: function(obj, options) {
	this._obj = $(obj);//缩放对象
	
	this._styleWidth = this._styleHeight = this._styleLeft = this._styleTop = 0;//样式参数
	this._sideRight = this._sideDown = this._sideLeft = this._sideUp = 0;//坐标参数
	this._fixLeft = this._fixTop = 0;//定位参数
	this._scaleLeft = this._scaleTop = 0;//定位坐标
	
	this._mxSet = function(){};//范围设置程序
	this._mxRightWidth = this._mxDownHeight = this._mxUpHeight = this._mxLeftWidth = 0;//范围参数
	this._mxScaleWidth = this._mxScaleHeight = 0;//比例范围参数
	
	this._fun = function(){};//缩放执行程序
	
	//获取边框宽度
	var _style = CurrentStyle(this._obj);
	this._borderX = (parseInt(_style.borderLeftWidth) || 0) + (parseInt(_style.borderRightWidth) || 0);
	this._borderY = (parseInt(_style.borderTopWidth) || 0) + (parseInt(_style.borderBottomWidth) || 0);
	//事件对象(用于绑定移除事件)
	this._fR = BindAsEventListener(this, this.Resize);
	this._fS = Bind(this, this.Stop);
	
	this.SetOptions(options);
	//范围限制
	this.Max = !!this.options.Max;
	this._mxContainer = $(this.options.mxContainer) || null;
	this.mxLeft = Math.round(this.options.mxLeft);
	this.mxRight = Math.round(this.options.mxRight);
	this.mxTop = Math.round(this.options.mxTop);
	this.mxBottom = Math.round(this.options.mxBottom);
	//宽高限制
	this.Min = !!this.options.Min;
	this.minWidth = Math.round(this.options.minWidth);
	this.minHeight = Math.round(this.options.minHeight);
	//按比例缩放
	this.Scale = !!this.options.Scale;
	this.Ratio = Math.max(this.options.Ratio, 0);
	
	this.onResize = this.options.onResize;
	
	this._obj.style.position = "absolute";
	!this._mxContainer || CurrentStyle(this._mxContainer).position == "relative" || (this._mxContainer.style.position = "relative");
  },
  //设置默认属性
  SetOptions: function(options) {
    this.options = {//默认值
		Max:		false,//是否设置范围限制(为true时下面mx参数有用)
		mxContainer:"",//指定限制在容器内
		mxLeft:		0,//左边限制
		mxRight:	9999,//右边限制
		mxTop:		0,//上边限制
		mxBottom:	9999,//下边限制

		Min:		false,//是否最小宽高限制(为true时下面min参数有用)
		minWidth:	50,//最小宽度
		minHeight:	50,//最小高度
		Scale:		false,//是否按比例缩放
		Ratio:		0,//缩放比例(宽/高)
		onResize:	function(){}//缩放时执行
    };
    Extend(this.options, options || {});
  },
  //设置触发对象
  Set: function(resize, side) {
	var resize = $(resize), fun;
	if(!resize) return;
	//根据方向设置
	switch (side.toLowerCase()) {
	case "up" :
		fun = this.Up;
		break;
	case "down" :
		fun = this.Down;
		break;
	case "left" :
		fun = this.Left;
		break;
	case "right" :
		fun = this.Right;
		break;
	case "left-up" :
		fun = this.LeftUp;
		break;
	case "right-up" :
		fun = this.RightUp;
		break;
	case "left-down" :
		fun = this.LeftDown;
		break;
	case "right-down" :
	default :
		fun = this.RightDown;
	};
	//设置触发对象
	addEventHandler(resize, "mousedown", BindAsEventListener(this, this.Start, fun));
  },
  //准备缩放
  Start: function(e, fun, touch) {	
	//防止冒泡(跟拖放配合时设置)
	e.stopPropagation ? e.stopPropagation() : (e.cancelBubble = true);
	//设置执行程序
	this._fun = fun;
	//样式参数值
	this._styleWidth = this._obj.clientWidth;
	this._styleHeight = this._obj.clientHeight;
	this._styleLeft = this._obj.offsetLeft;
	this._styleTop = this._obj.offsetTop;
	//四条边定位坐标
	this._sideLeft = e.clientX - this._styleWidth;
	this._sideRight = e.clientX + this._styleWidth;
	this._sideUp = e.clientY - this._styleHeight;
	this._sideDown = e.clientY + this._styleHeight;
	//top和left定位参数
	this._fixLeft = this._styleLeft + this._styleWidth;
	this._fixTop = this._styleTop + this._styleHeight;
	//缩放比例
	if(this.Scale){
		//设置比例
		this.Ratio = Math.max(this.Ratio, 0) || this._styleWidth / this._styleHeight;
		//left和top的定位坐标
		this._scaleLeft = this._styleLeft + this._styleWidth / 2;
		this._scaleTop = this._styleTop + this._styleHeight / 2;
	};
	//范围限制
	if(this.Max){
		//设置范围参数
		var mxLeft = this.mxLeft, mxRight = this.mxRight, mxTop = this.mxTop, mxBottom = this.mxBottom;
		//如果设置了容器，再修正范围参数
		if(!!this._mxContainer){
			mxLeft = Math.max(mxLeft, 0);
			mxTop = Math.max(mxTop, 0);
			mxRight = Math.min(mxRight, this._mxContainer.clientWidth);
			mxBottom = Math.min(mxBottom, this._mxContainer.clientHeight);
		};
		//根据最小值再修正
		mxRight = Math.max(mxRight, mxLeft + (this.Min ? this.minWidth : 0) + this._borderX);
		mxBottom = Math.max(mxBottom, mxTop + (this.Min ? this.minHeight : 0) + this._borderY);
		//由于转向时要重新设置所以写成function形式
		this._mxSet = function(){
			this._mxRightWidth = mxRight - this._styleLeft - this._borderX;
			this._mxDownHeight = mxBottom - this._styleTop - this._borderY;
			this._mxUpHeight = Math.max(this._fixTop - mxTop, this.Min ? this.minHeight : 0);
			this._mxLeftWidth = Math.max(this._fixLeft - mxLeft, this.Min ? this.minWidth : 0);
		};
		this._mxSet();
		//有缩放比例下的范围限制
		if(this.Scale){
			this._mxScaleWidth = Math.min(this._scaleLeft - mxLeft, mxRight - this._scaleLeft - this._borderX) * 2;
			this._mxScaleHeight = Math.min(this._scaleTop - mxTop, mxBottom - this._scaleTop - this._borderY) * 2;
		};
	};
	//mousemove时缩放 mouseup时停止
	addEventHandler(document, "mousemove", this._fR);
	addEventHandler(document, "mouseup", this._fS);
	if(is_ie){
		addEventHandler(this._obj, "losecapture", this._fS);
		this._obj.setCapture();
	}else{
		addEventHandler(window, "blur", this._fS);
		e.preventDefault();
	};
  },
  //缩放
  Resize: function(e) {
	//清除选择
	if($("dragIframe"))
		$("dragIframe").style.display="none";
	else
		$("alertDivHtmlBox").style.display="none";
	
	window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
	//执行缩放程序
	this._fun(e);
	//设置样式，变量必须大于等于0否则ie出错
	with(this._obj.style){
		width = this._styleWidth + "px"; height = this._styleHeight + "px";
		top = this._styleTop + "px"; left = this._styleLeft + "px";
	}
	//附加程序
	
  },
  //缩放程序
  //上
  Up: function(e) {
	this.RepairY(this._sideDown - e.clientY, this._mxUpHeight);
	this.RepairTop();
	this.TurnDown(this.Down);
  },
  //下
  Down: function(e) {
	this.RepairY(e.clientY - this._sideUp, this._mxDownHeight);
	this.TurnUp(this.Up);
  },
  //右
  Right: function(e) {
	this.RepairX(e.clientX - this._sideLeft, this._mxRightWidth);
	this.TurnLeft(this.Left);
  },
  //左
  Left: function(e) {
	this.RepairX(this._sideRight - e.clientX, this._mxLeftWidth);
	this.RepairLeft();
	this.TurnRight(this.Right);
  },
  //右下
  RightDown: function(e) {
	this.RepairAngle(
		e.clientX - this._sideLeft, this._mxRightWidth,
		e.clientY - this._sideUp, this._mxDownHeight
	);
	this.TurnLeft(this.LeftDown) || this.Scale || this.TurnUp(this.RightUp);
  },
  //右上
  RightUp: function(e) {
	this.RepairAngle(
		e.clientX - this._sideLeft, this._mxRightWidth,
		this._sideDown - e.clientY, this._mxUpHeight
	);
	this.RepairTop();
	this.TurnLeft(this.LeftUp) || this.Scale || this.TurnDown(this.RightDown);
  },
  //左下
  LeftDown: function(e) {
	this.RepairAngle(
		this._sideRight - e.clientX, this._mxLeftWidth,
		e.clientY - this._sideUp, this._mxDownHeight
	);
	this.RepairLeft();
	this.TurnRight(this.RightDown) || this.Scale || this.TurnUp(this.LeftUp);
  },
  //左上
  LeftUp: function(e) {
	this.RepairAngle(
		this._sideRight - e.clientX, this._mxLeftWidth,
		this._sideDown - e.clientY, this._mxUpHeight
	);
	this.RepairTop(); this.RepairLeft();
	this.TurnRight(this.RightUp) || this.Scale || this.TurnDown(this.LeftDown);
  },
  //修正程序
  //水平方向
  RepairX: function(iWidth, mxWidth) {
	iWidth = this.RepairWidth(iWidth, mxWidth);
	if(this.Scale){
		var iHeight = this.RepairScaleHeight(iWidth);
		if(this.Max && iHeight > this._mxScaleHeight){
			iHeight = this._mxScaleHeight;
			iWidth = this.RepairScaleWidth(iHeight);
		}else if(this.Min && iHeight < this.minHeight){
			var tWidth = this.RepairScaleWidth(this.minHeight);
			if(tWidth < mxWidth){ iHeight = this.minHeight; iWidth = tWidth; }
		}
		this._styleHeight = iHeight;
		this._styleTop = this._scaleTop - iHeight / 2;
	}
	this._styleWidth = iWidth;
  },
  //垂直方向
  RepairY: function(iHeight, mxHeight) {
	iHeight = this.RepairHeight(iHeight, mxHeight);
	if(this.Scale){
		var iWidth = this.RepairScaleWidth(iHeight);
		if(this.Max && iWidth > this._mxScaleWidth){
			iWidth = this._mxScaleWidth;
			iHeight = this.RepairScaleHeight(iWidth);
		}else if(this.Min && iWidth < this.minWidth){
			var tHeight = this.RepairScaleHeight(this.minWidth);
			if(tHeight < mxHeight){ iWidth = this.minWidth; iHeight = tHeight; }
		}
		this._styleWidth = iWidth;
		this._styleLeft = this._scaleLeft - iWidth / 2;
	}
	this._styleHeight = iHeight;
  },
  //对角方向
  RepairAngle: function(iWidth, mxWidth, iHeight, mxHeight) {
	iWidth = this.RepairWidth(iWidth, mxWidth);	
	if(this.Scale){
		iHeight = this.RepairScaleHeight(iWidth);
		if(this.Max && iHeight > mxHeight){
			iHeight = mxHeight;
			iWidth = this.RepairScaleWidth(iHeight);
		}else if(this.Min && iHeight < this.minHeight){
			var tWidth = this.RepairScaleWidth(this.minHeight);
			if(tWidth < mxWidth){ iHeight = this.minHeight; iWidth = tWidth; }
		}
	}else{
		iHeight = this.RepairHeight(iHeight, mxHeight);
	}
	this._styleWidth = iWidth;
	this._styleHeight = iHeight;
  },
  //top
  RepairTop: function() {
	this._styleTop = this._fixTop - this._styleHeight;
  },
  //left
  RepairLeft: function() {
	this._styleLeft = this._fixLeft - this._styleWidth;
  },
  //height
  RepairHeight: function(iHeight, mxHeight) {
	iHeight = Math.min(this.Max ? mxHeight : iHeight, iHeight);
	iHeight = Math.max(this.Min ? this.minHeight : iHeight, iHeight, 0);
	return iHeight;
  },
  //width
  RepairWidth: function(iWidth, mxWidth) {
	iWidth = Math.min(this.Max ? mxWidth : iWidth, iWidth);
	iWidth = Math.max(this.Min ? this.minWidth : iWidth, iWidth, 0);
	return iWidth;
  },
  //比例高度
  RepairScaleHeight: function(iWidth) {
	return Math.max(Math.round((iWidth + this._borderX) / this.Ratio - this._borderY), 0);
  },
  //比例宽度
  RepairScaleWidth: function(iHeight) {
	return Math.max(Math.round((iHeight + this._borderY) * this.Ratio - this._borderX), 0);
  },
  //转向程序
  //转右
  TurnRight: function(fun) {
	if(!(this.Min || this._styleWidth)){
		this._fun = fun;
		this._sideLeft = this._sideRight;
		this.Max && this._mxSet();
		return true;
	}
  },
  //转左
  TurnLeft: function(fun) {
	if(!(this.Min || this._styleWidth)){
		this._fun = fun;
		this._sideRight = this._sideLeft;
		this._fixLeft = this._styleLeft;
		this.Max && this._mxSet();
		return true;
	}
  },
  //转上
  TurnUp: function(fun) {
	if(!(this.Min || this._styleHeight)){
		this._fun = fun;
		this._sideDown = this._sideUp;
		this._fixTop = this._styleTop;
		this.Max && this._mxSet();
		return true;
	}
  },
  //转下
  TurnDown: function(fun) {
	if(!(this.Min || this._styleHeight)){
		this._fun = fun;
		this._sideUp = this._sideDown;
		this.Max && this._mxSet();
		return true;
	}
  },
  //停止缩放
  Stop: function() {

	removeEventHandler(document, "mousemove", this._fR);
	removeEventHandler(document, "mouseup", this._fS);
	if(is_ie){
		removeEventHandler(this._obj, "losecapture", this._fS);
		this._obj.releaseCapture();
	}else{
		removeEventHandler(window, "blur", this._fS);
	}
	
	this.onResize();
	if($("dragIframe"))
		$("dragIframe").style.display="";
	else
		$("alertDivHtmlBox").style.display="";
  }
};

var ilsrDrag={
drag_:false,
$ : function (id) {
	return document.getElementById(id);
},
oevent:function(e)
{
	if (!e) e = window.event;return e;
},
Drag:function(obj)
{
	var x,y;
	ilsrDrag.$(obj).onmousedown=function(e){
		if(document.all) 
			var el = event.srcElement;
		else
			var el = e.target;
		 	
		 if(el.id.toLowerCase()!=(obj+"title").toLowerCase()) return;
		 ilsrDrag.$(obj).onselectstart=function(){return false;}
		  ilsrDrag.drag_=true;
		  with(this){
			   style.position="absolute";var temp1=offsetLeft;var temp2=offsetTop;
			   x=ilsrDrag.oevent(e).clientX;y=ilsrDrag.oevent(e).clientY;
			   document.onmousemove=function(e){
					if(!ilsrDrag.drag_)
					{ 
					try
					{
					    if($("dragIframe"))
                            $("dragIframe").style.display="";
                        else
                            $("alertDivHtmlBox").style.display="";
                     }
                     catch(e)
                     {
                     }
					    return false;
					}
					with(this){
					    try
					    {
					                if($("dragIframe"))
		                                $("dragIframe").style.display="none";
	                                else
		                                $("alertDivHtmlBox").style.display="none";
					    }
					        catch(e)
                         {
                         }
						style.left=temp1+ilsrDrag.oevent(e).clientX-x+"px";
						style.top=temp2+ilsrDrag.oevent(e).clientY-y+"px";
					}
			   }
		  }
		  document.onmouseup=function(){
		  	 ilsrDrag.drag_=false;
		  };
	 }
}
};
function openNoReturn(url,w,h,preload,title,closeable)
{

    if(url.lastIndexOf("?")==-1)
        {
        	url=url+"?"+Math.random();
        }
        else
        {
        	url=url+"&"+Math.random();
        }
    var args=arguments.length;
    if(args==1)
        var newAlert=new alertDiv("alertDiv", {Resizable:true,MaxSize:true,srcUrl:url,contentType:1,Closable:true});
    else if(args==2)
    {
//        var evalStr="";
//        var Str=opStr.trim();
//        var Strs=Str.split(',');
//        for (var i=0;i<Strs.length;i++)
//        {
//            var iStr=Strs[i].trim();
//            var iStrs=iStr.split['='];
//            evalStr+=iStrs[0]+":"+iStrs[1]+",";
//        }
//        if(evalStr.length>0)
//        {
//            evalStr=evalStr.substr(0,evalStr.length-1);
//           
//         }   
        w=w<1?550:w;
      
         var newAlert=new alertDiv("alertDiv", {Resizable:true,minWidth:w,MaxSize:true,srcUrl:url,contentType:1,Closable:true});
    }
        
    else if(args==3)
        {
            w=w<1?550:w;
            h=h<1?300:h;
          
            var newAlert=new alertDiv("alertDiv", {Resizable:true,minWidth:w,minHeight:h,MaxSize:true,srcUrl:url,contentType:1,Closable:true});
            
        }
    else if(args==4)
        {
             w=w<1?550:w;
            h=h<1?300:h;
        
            var newAlert=new alertDiv("alertDiv", {Resizable:true,minWidth:w,minHeight:h,MaxSize:true,srcUrl:url,contentType:1,Closable:true,PReLoad:preload});
            
        }
    else  if(args==5)
        {
            w=w<1?550:w;
            h=h<1?300:h;
        
            var newAlert=new alertDiv("alertDiv", {Resizable:true,minWidth:w,minHeight:h,MaxSize:true,srcUrl:url,contentType:1,Closable:true,PReLoad:preload,alertDivTitleStr:title});
        }
    else
    {

            w=w<1?550:w;
            h=h<1?300:h;
        
            var newAlert=new alertDiv("alertDiv", {Resizable:true,minWidth:w,minHeight:h,MaxSize:true,srcUrl:url,contentType:1,Closable:true,PReLoad:preload,alertDivTitleStr:title,Closable:closeable});
    
    }
}


function deleteRangClass(url)
{
    var  w=300;
    var h=100;
        
            var newAlert=new alertDiv("alertDiv", {Resizable:true,minWidth:w,minHeight:h,MaxSize:false,srcUrl:url,contentType:1,Closable:false,PReLoad:false,alertDivTitleStr:"确认对话框",Resizable:false});
}
function JTKQ(url)
{
    var  w=550;
    var h=130;
        
            var newAlert=new alertDiv("alertDiv", {Resizable:true,minWidth:w,minHeight:h,MaxSize:false,srcUrl:url,contentType:1,Closable:false,PReLoad:false,alertDivTitleStr:"确认对话框",Resizable:false});
}