
 var AppPicker = new PickerControl();
 document.write("<script src='_common/Func.js'></script>");
 document.write("<script src='_common/Sys.js'></script>");	
 function PickerControl(){
  		this.name = "WS";//一个页面只需要创建一个窗口，所以无需通用
		this.left = 0;
		this.top = 0;
		this.width = 184;
		this.height = 180;
		this.title = "";
		this.action = null;
		this.timer = null;
		this.position_x = null;
		this.position_y = null;
		this.leftMargin = null;
		this.topMargin = null;
		this.originalLeft = null;
		this.originalTop = null;
		this.originalWidth = null;
		this.originalHeight = null;
		this.pickerPad = null;//最外面的图层
		this.pickerFrm = null;
		this.calendarPane = null;
		this.targetObj = null;
		this.triggerObj= null;
  /************** 加入底板及阴影 *********************/

  this.showSimple = function(oTarget, sUrl, oTrigger, iWidth, iHeight){
  	
	if(!window.picker) {
		this.ini();
		this.setupPanel();
		window.picker = this.pickerPad;
		window.calendar = this.calendarPane;
		window.pickerF = this.pickerFrm;
	}
	//window.pickerF.src = "";
	window.calendar.style.height = "0px";
	window.calendar.style.width = "0px";
	$("WS_title_content").innerHTML = "";
	$("WS_div_status").style.display = "";
	$("WS_resize_td").style.display = "";
//	if($("WS_div_content").style.display == "none") {
//		$("WS_min_operator").click();
//	}
	$("WS_div_content").style.height = iHeight;
	$("WS_max_undo_operator").style.display = "";
	if(window.calendar.firstChild) {
		window.calendar.removeChild(window.calendar.firstChild);
	}
	
	if (sUrl) {
		window.pickerF.style.display = "none";
		//window.pickerF.src = "";
	}
	this.executeShow(oTarget, oTrigger, iWidth, iHeight);
	if (sUrl) {
		window.pickerF.style.display = "";
		window.pickerF.src = sUrl;
		window.pickerF.style.width = parseInt(window.picker.style.width) - 3;
		window.pickerF.style.height =window.picker.style.height;
		$("WS_div_status").style.top = parseInt($("WS_div_content").style.height) - 17;
	}
  }
  
  this.showCalendar = function(oTarget, oCalendar, oTrigger, iWidth, iHeight){
	if(!window.picker) {
		this.ini();
		this.setupPanel();
		window.picker = this.pickerPad;
		window.calendar = this.calendarPane;
		window.pickerF = this.pickerFrm;
	}
	$("WS_title_content").innerHTML = "";
//	if($("WS_div_content").style.display == "none") {
//		$("WS_min_operator").click();
//	}
	$("WS_div_content").style.height = "180px";
	window.picker.style.display = "";
	window.pickerF.src = "";
	$("WS_div_status").style.display = "none";
	$("WS_resize_td").style.display = "none";
	$("WS_max_undo_operator").style.display = "none";
	window.pickerF.style.width = "181px";
	window.picker.style.width = "185px";
	window.picker.style.height = window.pickerF.style.height = "180px";
	var ocal = oCalendar;
	if(ocal == null){
		ocal = new Calendar(new PopCalendarAction(oTarget));
		ocal.registerLodging(this, oTarget);
	}
	this.executeShow(oTarget, oTrigger, iWidth, iHeight);
	if(window.calendar.hasChildNodes())
		window.calendar.removeChild(window.calendar.firstChild);
	window.calendar.appendChild(ocal.asHTMLNode());
  }

  this.executeShow = function(oTarget, oTrigger, iWidth, iHeight){
	if(oTarget == null){
		alert("Didn't set target object!");
		return;
	}
	if(oTrigger == null)
		oTrigger = oTarget;
	this.targetObj = oTarget;
	this.triggerObj = oTrigger;
	if(iWidth != null){
		window.picker.style.width = iWidth;
		window.pickerF.style.width = iWidth;
	}
	if(iHeight != null){
		window.picker.style.height = iHeight;
		window.pickerF.style.height = iHeight;
	}
    var restOn  = this.restOnPos();
    window.picker.style.pixelLeft = restOn.left;
	var ptop = restOn.top - ($("areaForm") ? $("areaForm").scrollTop : 0);
	ptop = (ptop < 0) ? 0 : ptop;
    window.picker.style.pixelTop = ptop;
	window.picker.style.display="block";
  }

  this.restOnPos = function(){
	  var offsetPos = this.getAbsolutePos(this.triggerObj);//计算对象的绝对位置;
	  var calTop = offsetPos.y + (this.triggerObj.offsetHeight == 0 ? 20 : this.triggerObj.offsetHeight);
	  var winHeight = window.innerHeight ? window.innerHeight : document.body.clientHeight;
	  var padHeight = window.picker.style.height;
	  if(padHeight.indexOf("px") > -1)
		padHeight = 1*padHeight.substring(0, padHeight.indexOf("px"));
	  if(calTop + padHeight > winHeight){
		calTop = winHeight - padHeight;
		calTop = calTop > 0 ? calTop : 0;
	  }
	  if((document.body.offsetWidth-(offsetPos.x+this.triggerObj.offsetWidth-document.body.scrollLeft)) > window.picker.style.pixelWidth){
		var calLeft=offsetPos.x ;
	  }else{
		var calLeft=document.body.offsetWidth-window.picker.style.pixelWidth;
	  }
	  return { top  : calTop, left : calLeft };
  }
  
  this.getAbsolutePos = function(el) {
   var r = { x: el.offsetLeft, y: el.offsetTop };
   if (el.offsetParent) {
    var tmp = this.getAbsolutePos(el.offsetParent);
    r.x += tmp.x;
    r.y += tmp.y;
   }
   return r;
  };

  this.hide = function(){
  	try{
		window.picker.style.display = "none";
		var operator = $("WS_max_undo_operator");
		if(operator.innerText == 2) {
			operator.click();
		}
  	}catch(e) {
  		//do nothing
  	}
  }

  this.afterPicked = function(){
	this.hide();
  }
  
 }
 
 function $() {
	var elements = new Array();

	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if ((typeof element == 'string') && (element != ''))
			element = document.getElementById(element);
		if (arguments.length == 1) 
			return element;
		elements.push(element);
	}
	
	return elements;
}

//用以初始化图层的基本架构
PickerControl.prototype.ini = function() {
	this.iniDiv_whole();
	var table_whole = this.iniTable_whole();
	this.pickerPad.appendChild(table_whole);
}

PickerControl.prototype.setupPanel = function() {
	window.document.body.appendChild(this.pickerPad);
	if(!window.maxZIndex){
		window.maxZIndex = this.pickerPad.style.zIndex + 1;
	}	
	var me = this;
	var change = function() {me.change();};
	var stop = function() {me.stop();};
	window.document.body.attachEvent("onmousemove",change);
	window.document.body.attachEvent("onmouseup",stop);
	window.document.body.attachEvent("onmouseleave",stop);
	window.document.body.attachEvent("ondrag",change);
	window.document.body.attachEvent("ondragend",stop);
	var assist_div = document.createElement("div");
	assist_div.id = me.name + "_assist_div";
	assist_div.style.left = "0";
	assist_div.style.top = "0";
	assist_div.style.width = window.document.body.clientWidth;
	assist_div.style.height = window.document.body.clientHeight;
	assist_div.style.position = "absolute";
	assist_div.style.zIndex = 999;
	assist_div.style.display = "none";
	assist_div.attachEvent("onmouseup",stop);
	document.body.appendChild(assist_div);
}

PickerControl.prototype.iniDiv_whole = function() {
	this.pickerPad = document.createElement("div");
	this.pickerPad.id = "divPickerpad";
	this.pickerPad.style.left = this.left;
	this.pickerPad.style.top = this.top;
	this.pickerPad.style.width = this.width;
	this.pickerPad.style.height = this.height;
	this.pickerPad.style.position = "absolute";
	this.pickerPad.style.display = "none";
	this.pickerPad.style.zIndex = 1000;
	var me = this;
	this.pickerPad.onmousedown = function() {
		if(me.pickerPad.style.zIndex < window.maxZIndex){
				me.pickerPad.style.zIndex = window.maxZIndex + 1;
				window.maxZIndex = me.pickerPad.style.zIndex;
		}
	}
};

PickerControl.prototype.iniTable_whole = function() {
	var table_whole = document.createElement("table");
	table_whole.id = this.name + "_table_whole";
	table_whole.style.width = "100%";
	table_whole.style.height = "100%";
	table_whole.cellPadding = "0";
	table_whole.cellSpacing = "0";
	var tbody_whole = document.createElement("tbody");
	var me = this;
	
	function iniContent_Panel() {
		var tr_content_panel = document.createElement("tr");
		tr_content_panel.id = me.name + "_tr_content";
		tr_content_panel.extend = "true";
		tr_content_panel.style.width = "100%";
		tr_content_panel.style.height = "100%";
		var td_content = document.createElement("td");
		var div_content = document.createElement("div");
		div_content.id = me.name + "_div_content";
		div_content.unselectable = "on";
		div_content.style.width = "100%";
		div_content.style.height = "100%";
		div_content.style.borderBottom = "2px #336699 solid";
		div_content.style.borderLeft = "2px #336699 solid";
		div_content.style.borderRight = "2px #336699 solid";
		div_content.style.backgroundColor = "#EBEAF3";
		div_content.style.left = "0";
		div_content.style.top = "0";
		div_content.style.position = "absolute";
		var label_div = document.createElement("div");
		label_div.id = me.name + "_label_div";
		label_div.style.left = 0;
		label_div.style.top = "50%";
		label_div.style.width = "100%";
		label_div.style.height = "40%";
		label_div.style.position = "absolute";
		label_div.style.display = "none";
		label_div.style.zIndex = 1000;
		label_div.innerHTML = "<center>"+Sys.getString("Operating")+"...</center>";
		div_content.appendChild(label_div);
		
		me.pickerFrm = document.createElement("iframe");
		me.pickerFrm.id = "pickerFrame";
		me.pickerFrm.scrolling = "no";
		me.pickerFrm.src = ""; // !NOTE: 1
		me.pickerFrm.unselectable = "on";
		me.pickerFrm.frameborder = "0";
		me.pickerFrm.style.width = "100%";
		me.pickerFrm.style.height = "80%";
		div_content.appendChild(me.pickerFrm);
		
		me.calendarPane = document.createElement("div");
		me.calendarPane.id = "calendarLocal";
		me.calendarPane.style.position = "absolute";
		me.calendarPane.style.left = "-1px";
		me.calendarPane.style.top = "20px";
		me.calendarPane.style.width = "100%";
		me.calendarPane.style.height = "100%";
		me.calendarPane.style.zIndex = 1001;
		div_content.appendChild(me.calendarPane);
		
		td_content.appendChild(div_content);
		
		var div_title = document.createElement("div");
		div_title.id = me.name + "_div_title";
		div_title.style.cursor = "move";
		div_title.style.border = "2px #336699 solid";
		div_title.style.backgroundColor = "#336699";
		div_title.style.width = "100%";
		div_title.style.height = "21px";
		div_title.style.left = "0";
		div_title.style.top = "0";
		div_title.style.position = "absolute";
		div_title.onmousedown = function() {
			if((event.srcElement.tagName=="TD" && (event.srcElement.id != me.name + "_resize_td")) || event.srcElement.tagName=="SPAN" || event.srcElement.tagName=="STRONG"){
				me.action = "move";
			}
		};
		div_title.ondblclick = function() {
			me.maximize(document.getElementById(me.name + "_max_undo_operator"));
		}
		var table_title = document.createElement("table");
		table_title.id = "table_title";
		table_title.cellPadding = "0";
		table_title.cellSpacing = "0";
		table_title.style.width = "100%";
		table_title.style.height = "19px";
		var tbody_table_title = document.createElement("tbody");
		var tr_table_title = document.createElement("tr");
		tr_table_title.title = Sys.getString("CanDrag");
		var resize_td = document.createElement("td");
		resize_td.id = me.name + "_resize_td";
		resize_td.align = "left";
		resize_td.width = "1";
		resize_td.noWrap = "true";
		resize_td.innerText = " ";
		resize_td.unselectable = "on";
		resize_td.style.cursor = "nw-resize";
		resize_td.onmousedown = function() {
			me.action = "nw-resize";
		}
		var title_content = document.createElement("td");
		title_content.id = me.name + "_title_content";
		title_content.unselectable = "on";
		title_content.style.color = "white";
		title_content.noWrap = "true";
		title_content.innerText = me.title;
		var td_operator = document.createElement("td");
		td_operator.id = me.name + "_td_operator";
		td_operator.align = "right";
		td_operator.style.verticalAlign = "top";
		td_operator.unselectable = "on";
		td_operator.noWrap = "true";
		var operator_ele = null;
		
		
//		operator_ele = document.createElement("font");
//		operator_ele.unselectable = "on";
//		operator_ele.face = "webdings";
//		operator_ele.title = "存储大小";
//		operator_ele.id = me.name + "_setSize_operator";
//		operator_ele.color = "white";
//		operator_ele.style.verticalAlign = "top";
//		operator_ele.style.cursor = "hand";
//		operator_ele.onclick = function() {
//			me.writeSizeToCookie();
//		}
//		operator_ele.ondblclick = function() {event.cancelBubble = true;};
//		operator_ele.innerText = "@";
//		td_operator.appendChild(operator_ele);
		
//		
//		var spacer = document.createTextNode("  ");
//		td_operator.appendChild(spacer);
//		
		
//		operator_ele = document.createElement("font");
//		operator_ele.unselectable = "on";
//		operator_ele.face = "webdings";
//		operator_ele.title = "最小化";
//		operator_ele.id = me.name + "_min_operator";
//		operator_ele.color = "white";
//		operator_ele.style.verticalAlign = "top";
//		operator_ele.style.cursor = "hand";
//		operator_ele.onclick = function() {
//			me.minimize(this);
//		}
//		operator_ele.ondblclick = function() {event.cancelBubble = true;};
//		operator_ele.innerText = "0";
//		td_operator.appendChild(operator_ele);
//		
//		
//		var spacer = document.createTextNode("  ");
//		td_operator.appendChild(spacer);
		
		operator_ele = document.createElement("font");
		operator_ele.unselectable = "on";
		operator_ele.face = "webdings";
		operator_ele.title = Sys.getString("Maximize");
		operator_ele.id = me.name + "_max_undo_operator";
		operator_ele.color = "white";
		operator_ele.style.verticalAlign = "top";
		operator_ele.style.cursor = "hand";
		operator_ele.onclick = function() {
			me.maximize(this);
		}
		operator_ele.ondblclick = function() {event.cancelBubble = true;};
		operator_ele.innerText = "1";
		td_operator.appendChild(operator_ele);
		spacer = document.createTextNode("  ");
		td_operator.appendChild(spacer);
		operator_ele = document.createElement("img");
		operator_ele.unselectable = "on";
		operator_ele.title = Sys.getString("Close");
		operator_ele.style.verticalAlign = "bottom";
		operator_ele.style.cursor = "hand";
		operator_ele.src = "_imgs/ico/x_close.gif";
		operator_ele.onclick = function() {
			me.hide();
		};
		operator_ele.ondblclick = function() {event.cancelBubble = true;};
		td_operator.appendChild(operator_ele);
		tr_table_title.appendChild(resize_td);
		tr_table_title.appendChild(title_content);
		tr_table_title.appendChild(td_operator);
		tbody_table_title.appendChild(tr_table_title);
		table_title.appendChild(tbody_table_title);
		div_title.appendChild(table_title);
		td_content.appendChild(div_title);
		
		
		var div_status = document.createElement("div");
		div_status.id = me.name + "_div_status";
		div_status.unselectable = "on";
		div_status.style.borderLeft = "2px #336699 solid";
		div_status.style.borderRight = "1px #336699 solid";
		div_status.style.borderBottom = "2px #336699 solid";
		div_status.style.left = "0";
		div_status.style.top = "90%";
		div_status.style.position = "absolute";
		div_status.style.width = "100%";
		div_status.style.height = "15px";
		div_status.style.backgroundColor = "#ECE9D8";
		var table_status = document.createElement("table");
		table_status.style.width = "100%";
		table_status.border = "1";
		table_status.cellPadding = "0";
		table_status.cellSpacing = "0";
		var tbody_table_status = document.createElement("tbody");
		var tr_table_status = document.createElement("tr");
		
		var td_table_status = document.createElement("td");
		td_table_status.align = "left";
		td_table_status.width = "20";
		td_table_status.innerText = " ";
		td_table_status.unselectable = "on";
		td_table_status.style.cursor = "sw-resize";
		td_table_status.onmousedown = function() {
			me.action = "sw-resize";
		}
		tr_table_status.appendChild(td_table_status);
		
		
		td_table_status = document.createElement("td");
		td_table_status.unselectable = "on";
		td_table_status.innerText = Sys.getString("StatusBar");
		tr_table_status.appendChild(td_table_status);
		
		
		td_table_status = document.createElement("td");
		td_table_status.align = "right";
		td_table_status.width = "20";
		td_table_status.innerText = " ";
		td_table_status.unselectable = "on";
		td_table_status.style.cursor = "se-resize";
		td_table_status.onmousedown = function() {
			me.action = "se-resize";
		}
		tr_table_status.appendChild(td_table_status);
		
		tbody_table_status.appendChild(tr_table_status);
		table_status.appendChild(tbody_table_status);
		div_status.appendChild(table_status);
		td_content.appendChild(div_status);
		
		tr_content_panel.appendChild(td_content);
		return tr_content_panel;
	}
	tbody_whole.appendChild(iniContent_Panel());
	table_whole.appendChild(tbody_whole);
	return table_whole;
}


PickerControl.prototype.maximize = function(ele) {
	var tr_content = $(this.name + "_tr_content");
	var div_status = $(this.name + "_div_status");
	var div_content = $(this.name + "_div_content");
	if(ele.innerText=="1") {
		this.originalLeft = this.pickerPad.style.left;
		this.originalTop = this.pickerPad.style.top;
		this.originalWidth = this.pickerPad.style.width;
		this.originalHeight = this.pickerPad.style.height;
		this.pickerPad.style.left = "0px";
		this.pickerPad.style.top = "0px";
		this.pickerPad.style.width = document.body.clientWidth;
		this.pickerFrm.style.width = document.body.clientWidth;
		if(tr_content.extend=="true"){
			this.pickerPad.firstChild.style.height = document.body.clientHeight;
			this.pickerPad.style.height = document.body.clientHeight;
			this.pickerFrm.style.height = document.body.clientHeight;
			div_content.style.height = document.body.clientHeight;
			div_status.style.top = parseInt(div_content.style.height) - 17;
		}
		ele.innerText = "2";
		ele.title = Sys.getString("DownRestore");
	} else if(ele.innerText=="2") {
		this.pickerPad.style.left = this.originalLeft;
		this.pickerPad.style.top = this.originalTop;
		this.pickerPad.style.width = this.originalWidth;
		this.pickerFrm.style.width = parseInt(this.originalWidth) - 3;
		this.pickerPad.firstChild.style.height = this.originalHeight;
		this.pickerPad.style.height = this.originalHeight;
		this.pickerFrm.style.height = this.originalHeight;
		div_content.style.height = this.originalHeight;
		div_status.style.top = parseInt(div_content.style.height) - 17;
		ele.innerText = "1";
		ele.title = Sys.getString("Maximize");
	}
}

PickerControl.prototype.minimize = function(ele) {
	var tr_content = $(this.name + "_tr_content");
	var div_content = $(this.name + "_div_content");
	var table_whole = $(this.name + "_table_whole");
	var pickerFrame = $("pickerFrame");
	pickerFrame.origiHeight = pickerFrame.style.height;
//	var tr_status = $(this.name + "_tr_status");
	var div_status = $(this.name + "_div_status");
	if(tr_content.extend=="true"){
		table_whole.style.height = "20px";
		pickerFrame.style.height = "20px";
		div_content.style.display = "none";
		tr_content.style.height = "0px";
//		tr_status.style.height = "0px";
		div_status.style.display = "none";
		tr_content.extend = "false";
		ele.title = Sys.getString("Restore");
	} else {
		table_whole.style.height = pickerFrame.origiHeight;
		pickerFrame.style.height = pickerFrame.origiHeight;
		div_content.style.display = "";
		tr_content.style.height = "";
//		tr_status.style.height = "15px";
		div_status.style.display = "";
		tr_content.extend = "true";
		ele.title = Sys.getString("Minimize");
	}
}


PickerControl.prototype.stop = function() {
		if(this.action != null) {
			if(this.action == "move"){
			    this.leftMargin = null;
				this.topMargin = null;
				
			} else if(this.action == "se-resize" || this.action == "sw-resize" || this.action == "nw-resize") {
				this.writeSizeToCookie();
			}
			$("WS_label_div").style.display = "none";
			$("WS_assist_div").style.display = "none";
			this.pickerFrm.style.display = "";
			this.pickerFrm.style.height = this.pickerPad.style.height;
			this.action = null;
			this.position_x = null;
			this.position_y = null;
		}
}

PickerControl.prototype.change = function() {
	if(this.action == "move") {
		try{
			$("WS_assist_div").style.display = "";
			if(this.leftMargin==null){
				this.leftMargin = event.clientX - parseInt(this.pickerPad.style.left);
				this.topMargin = event.clientY - parseInt(this.pickerPad.style.top);
				this.pickerFrm.style.height = 15;
				$("WS_label_div").style.display = "";
			}
			this.position_x = event.clientX - this.leftMargin;
			this.position_y = event.clientY - this.topMargin;
			var maxWidth = document.body.clientWidth - parseInt(this.pickerPad.style.width);
			var maxHeight = document.body.clientHeight - parseInt(this.pickerPad.style.height);
			if((this.position_x>=0)&&(this.position_x<=maxWidth)){
				this.pickerPad.style.left = this.position_x + "px";
			} else if(this.position_x < 0) {
				this.pickerPad.style.left = 0 + "px";
			} else {
				this.pickerPad.style.left = maxWidth + "px";
			}
				
			if((this.position_y>=0)&&(this.position_y<=maxHeight)){
				this.pickerPad.style.top = this.position_y + "px";
			} else if(this.position_y<0) {
				this.pickerPad.style.top = 0 + "px";
			} else {
				this.pickerPad.style.top = maxHeight + "px";
			}
		}catch(e) {
			this.stop();
		}
	} else if(this.action == "se-resize") {
		try{
			$("WS_assist_div").style.display = "";
			if(this.position_x == null || this.position_y == null) {
				this.position_x = parseInt(this.pickerPad.style.left) + parseInt(this.pickerPad.style.width);
				this.position_y = parseInt(this.pickerPad.style.top) + parseInt(this.pickerPad.style.height);
//				this.pickerFrm.style.height = 15;
				this.pickerFrm.style.display = "none";
				$("WS_label_div").style.display = "";
			} else {
				this.position_x = event.clientX;
				this.position_y = event.clientY;
			}
			var width_changed = this.position_x - parseInt(this.pickerPad.style.left) + 15;
			if(width_changed >= 205 && (width_changed + parseInt(this.pickerPad.style.left)) <= document.body.clientWidth) {
				this.pickerPad.style.width = width_changed;
				this.pickerFrm.style.width = parseInt(this.pickerPad.style.width) - 3;
			}
			var height_changed = this.position_y - parseInt(this.pickerPad.style.top) - 5;
			if(height_changed >= 35 && (height_changed + parseInt(this.pickerPad.style.top)) <= document.body.clientHeight) {
				this.pickerPad.style.height = height_changed;
				$("WS_div_content").style.height = parseInt(this.pickerPad.style.height);
				$("WS_div_status").style.top = parseInt($("WS_div_content").style.height) - 17;
			}
		} catch(e) {
			this.stop();
		}
	} else if(this.action == "sw-resize") {
		try{
			$("WS_assist_div").style.display = "";
			if(this.position_x == null || this.position_y == null) {
				this.position_x = parseInt(this.pickerPad.style.left);
				this.position_y = parseInt(this.pickerPad.style.top) + parseInt(this.pickerPad.style.height);
//				this.pickerFrm.style.height = 15;
				this.pickerFrm.style.display = "none";
				$("WS_label_div").style.display = "";
			} else {
				this.position_x = event.clientX;
				this.position_y = event.clientY;
			}
			var pickerPad_right = parseInt(this.pickerPad.style.left) + parseInt(this.pickerPad.style.width);
			var width_changed = pickerPad_right - this.position_x;
			
			if(width_changed >= 205 && this.position_x >= 0) {
				this.pickerPad.style.width = width_changed;
				this.pickerPad.style.left = this.position_x;
				this.pickerFrm.style.width = parseInt(this.pickerPad.style.width) - 3;
			}
			var height_changed = this.position_y - parseInt(this.pickerPad.style.top) - 5;
			if(height_changed >= 35 && (height_changed + parseInt(this.pickerPad.style.top)) <= document.body.clientHeight) {
				this.pickerPad.style.height = height_changed;
				$("WS_div_content").style.height = parseInt(this.pickerPad.style.height);
				$("WS_div_status").style.top = parseInt($("WS_div_content").style.height) - 17;
			}
		}catch(e) {
			this.stop();
		}
	} else if(this.action == "nw-resize") {
		try{
			$("WS_assist_div").style.display = "";
			if(this.position_x == null || this.position_y == null) {
				this.position_x = parseInt(this.pickerPad.style.left);
				this.position_y = parseInt(this.pickerPad.style.top);
//				this.pickerFrm.style.height = 15;
				this.pickerFrm.style.display = "none";
				$("WS_label_div").style.display = "";
			} else {
				this.position_x = event.clientX;
				this.position_y = event.clientY;
			}
			var pickerPad_right = parseInt(this.pickerPad.style.left) + parseInt(this.pickerPad.style.width);
			var width_changed = pickerPad_right - this.position_x;
			if(width_changed >= 205 && this.position_x >= 0) {
				this.pickerPad.style.width = width_changed;
				this.pickerPad.style.left = this.position_x;
				this.pickerFrm.style.width = parseInt(this.pickerPad.style.width) - 3;
			}
			
			var pickerPad_bottom = parseInt(this.pickerPad.style.top) + parseInt(this.pickerPad.style.height);
			var height_changed = pickerPad_bottom - this.position_y;
			if(height_changed >= 35 && this.position_y >= 0) {
				this.pickerPad.style.height = height_changed;
				this.pickerPad.style.top = this.position_y;
				$("WS_div_content").style.height = parseInt(this.pickerPad.style.height);
				$("WS_div_status").style.top = parseInt($("WS_div_content").style.height) - 17;
			}
			
		}catch(e) {
			this.stop();
		}
	}
}

PickerControl.prototype.writeSizeToCookie = function() {
	try{
		var expiration = new Date();
		expiration.setYear(expiration.getYear() + 1);
		var frm_src = this.pickerFrm.src;
		var key_page = frm_src.substring(frm_src.indexOf("page/")+5,(frm_src.indexOf("&")!=-1)?frm_src.indexOf("&"):frm_src.length);
		var key = key_page;
		if(frm_src.indexOf("lookupclass=")!=-1)	{
			var key_lookupClass = frm_src.substring(frm_src.indexOf("lookupclass=")+12,frm_src.indexOf("&page"));
			key = key_page + "." + key_lookupClass;
		}
		var pad_width = parseInt(this.pickerPad.style.width);
		var pad_height = parseInt(this.pickerPad.style.height);
		var size = pad_width + ":" + pad_height;
		var value = escape(size);
		document.cookie = key + "=" + value + ";expires=" + expiration.toGMTString() + ";path=/";
	}catch(e) {
		//do nothing
	}
}


 function PopCalendarAction(oTarget){
	this.adjustDate = function(){};
	this.pickDate = function(sDate){
		oTarget.value = sDate;
		var needReturnTime = false;
		var otargetId = oTarget.id;
  	    var otimeTarget = $("tm_" + otargetId);
  	    
		if (otimeTarget) {
			needReturnTime = true;
			if (needReturnTime) {
				var hour = $("Calendar.hour").value;
				var minute = $("Calendar.minute").value;
				var time = hour + ":" + minute;
				otimeTarget.value = time;
			}
		}
		try{////在活动/历史编辑页面进行时间差计算
			 	fillDateEnd(oTarget, needReturnTime);	
		}catch(e){
		}
	}
 }
 
 /*
 var AppDownComer = new DownComer();
 
 function DownComer() {
 	this.name = "WSDownComer";
 	this.width = 150;
 	this.height = 150;
 	this.div_whole = null;
 	this.iframeEle = null;
 }
 
 DownComer.prototype.showDownComer = function(lookupId) {
 	if(!window.downComer) {
 		this.ini();
 		window.downComer = this.div_whole;
 		DownComerTableControl.constructTable();
 		window.downComer.insertBefore(DownComerTableControl.downComerTable,this.iframeEle);		
 	}
	this.restPos(window.downComer,lookupId);
 	//更新table
 	//更新iframe及div大小
 	window.downComer.style.display = "";
 	this.iframeEle.style.width = DownComerTableControl.downComerTable.offsetWidth + 1;
 	this.iframeEle.style.height = DownComerTableControl.downComerTable.offsetHeight + 1;
 	window.downComer.style.width = this.iframeEle.style.width;
 	window.downComer.style.height = this.iframeEle.style.height;
// 	alert(window.downComer.style.height);
 	//显示图层
 }
 
 DownComer.prototype.restPos = function(ele,lookupId) {
 	var lookupFieldEle = document.getElementById("lookup_textfield_"+lookupId);
 	var lookupFieldPos = this.getAbsolutePos(lookupFieldEle);
 	ele.style.left = lookupFieldPos.x + 1;
 	ele.style.top = lookupFieldPos.y + 19;
// 	ele.style.display = "";
 }
 
 DownComer.prototype.getAbsolutePos = function(el) {
   var r = { x: el.offsetLeft, y: el.offsetTop };
   if (el.offsetParent) {
    var tmp = this.getAbsolutePos(el.offsetParent);
    r.x += tmp.x;
    r.y += tmp.y;
   }
   return r;
  };
 
 DownComer.prototype.ini = function() {
 	var me = this;
 	function iniDivWhole() {
 		me.div_whole = document.createElement("div");
 		me.div_whole.id = me.name + "_div_whole";
 		me.div_whole.style.left = 0;
 		me.div_whole.style.top = 0;
 		me.div_whole.style.width = me.width;
 		me.div_whole.style.height = me.height;
 		me.div_whole.style.position = "absolute";
 		me.div_whole.style.display = "none";
 		var iframeEle = document.createElement("iframe");
 		iframeEle.src = "";
 		iframeEle.id = me.name + "_iframe";
 		iframeEle.style.left = 0;
 		iframeEle.style.top = 0;
 		iframeEle.style.width = me.width;
 		iframeEle.style.height = me.height;
 		iframeEle.scrolling = "no";
 		me.div_whole.appendChild(iframeEle);
 		me.iframeEle = iframeEle;
 	};
 	iniDivWhole();
 	window.document.body.appendChild(this.div_whole);
 }
 
 var DownComerTableControl = new DownComerTable();
 
 function DownComerTable() {
 	this.name = "DownComerTable";
 	this.downComerTable = null;
 }
 
 DownComerTable.prototype.constructTable = function() {
 	this.downComerTable = this.ini();
 }
 
 DownComerTable.prototype.ini = function() {
 	var downComerTable = document.createElement("table");
 	downComerTable.id = this.name + "_table";
 	downComerTable.style.border = "1px solid #7B9EBD";
 	downComerTable.cellPadding = 0;
 	downComerTable.cellSpacing = 0;
 	downComerTable.style.position = "absolute";
 	downComerTable.style.backgroundColor = "white";
 	var downComerTBody = document.createElement("tbody");
 	var downComerTr = document.createElement("tr");
 	var downComerTd = document.createElement("td");
 	downComerTd.innerHTML = "<font color='red' style='font-size:14;'>&nbsp;No  Match&nbsp;</font>";
 	downComerTr.appendChild(downComerTd);
 	downComerTBody.appendChild(downComerTr);
 	downComerTable.appendChild(downComerTBody);
 	return downComerTable;
 }
 */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 