/**//**//**//**
* 数剧处理类
2010-06-09 
by:海鸥
**//**//**//**-----------------------------------------------------------------
/**//**//**//**
UI类
**//**//**//*-------------------------------------------------------------*/
//初始CLASS
var Class = {
	create: function() {
		return function(){}
	}
};

var UI=Class.create();
UI.prototype = {
	NewLayer:function() {
		var newsID='';var formWidth=380;var AlphaNum=80;
		if(arguments[0]!=undefined)	newsID		= arguments[0];
		if(arguments[1]!=undefined)	formWidth	= arguments[1];
		if(arguments[2]!=undefined)	varAlphaNum	= arguments[2];
		createlayer(newsID,formWidth,AlphaNum);
	},
	UserLink:"/user",
	HistoryLink:document.location.href,
	MsgLayer:function(txt,closeType,imgType) {//普通信息提示
		var goLink="";var loadimgurl='';
		switch(closeType){
			case 0:
				goLink=" closeActMsg()";break;
			case 1:
				goLink=" history.back()";break;
			case 2:
				goLink="location.reload()";break;
			default:
				goLink=" closeActMsg()";break;
		}
		switch(imgType){
			case 0:
				loadimgurl="/Images/Titpic/success.gif";break;
			case 1:
				loadimgurl="/Images/Titpic/fail.gif";break;
			case 2:
				loadimgurl="/Images/Titpic/tip.gif";break;
			default:
				loadimgurl="/Images/Titpic/tip.gif";break;
			}
		this.NewLayer('',380,80);
		$('#out_Main').html('<img src="'+loadimgurl+'"/>&nbsp;&nbsp;&nbsp;'+txt);
		$('#out_Foot').html('<input name="bntok" type="button" id="bntok" value="返 回" class="btn69" onclick="javascript: '+goLink+';"/>');
	},
	ErrMsg:function() {
		var txt="";var closeType=0;imgType=1;
		if(arguments[0]!=undefined)	txt			= arguments[0];
		if(arguments[1]!=undefined)	closeType	= arguments[1];
		if(arguments[2]!=undefined)	imgType		= arguments[2];
		this.MsgLayer(txt,closeType,imgType);
	},
	AlertMsg:function(cont){
		this.NewLayer('',380,80);
		$('#out_Main').html('<img src="/Images/Titpic/alert.gif"/>&nbsp;&nbsp;&nbsp;<span class="focusBold">'+cont+'</span>');
		$('#out_Foot').html('<input name="bntok" type="button" id="bntok" value="关 闭" class="btn69" onclick="javascript: closeActMsg();"/>');
		},
	//LOADING条
	LoadMsg:function (statePic,txtcont){
		this.NewLayer('Msg_Info',250,80);
		$('#Msg_Info').html('<div class="loadDiv" ><div class="load_Main"><span class="load_Img">'+statePic+'</span><span class="load_Text"> '+txtcont+'...</span></div></div>');
	}
}
//---------------------------------------------------------------------------------------
/**//**//**//**
Model类
**//**//**//**/
function Model(){
	this.UserLink='/user';
	this.HistoryLink='document.location.href';
	this.Task='';
	this.Task1='';
	this.Task2='';
	this.Task3='';
	this.Task4='';
	this.TaskOutTime=30;//毫秒
}
//var Model=Class.create();
var SysUI= new UI();
/**//**//**//**
读取。。可用于任何请求处理（推荐用于读取）
@param:actionType,postUrl,dataStr,showTag,statePic,postType,asyncTF
**//**//**//**/
Model.prototype.Execute=function(){
	var actionType='';var showTag='';var postUrl='';var dataStr='';var statePic=Loadimg3;var postType='POST';var asyncTF=true;
	if(arguments[0]!=undefined)	actionType		= arguments[0];
	if(arguments[1]!=undefined)	postUrl			= arguments[1];
	if(arguments[2]!=undefined)	dataStr			= arguments[2];
	if(arguments[3]!=undefined)	showTag			= arguments[3];

	if(arguments[4]!=undefined)	statePic		= arguments[4];
	if(arguments[5]!=undefined)	postType		= arguments[5];
	if(arguments[6]!=undefined)	asyncTF			= arguments[6];
	if(arguments[2]==undefined){return false;}
	clearTimeout(this.Task);
	this.Task=setTimeout(function(){
		$.ajax({
		type: postType,url: postUrl+"&r="+Math.random(),data: dataStr,cache:false,async:asyncTF,success: function(msg){
			if(unescape(msg)=='False'){location.href='/login.shtml?url='+this.HistoryLink;	return false;}
			viewData(actionType,msg,showTag);
		},
		error:function(msg){SysUI.ErrMsg("操作失败");return false;},
		timeout:function(msg){SysUI.ErrMsg("网络超时");	}
		})
	},this.TaskOutTime);
};

/**//**//**//**
添加数剧
@param:actionType,postUrl,dataStr,pageName,pageTitle,actionTitle,backType,showTag,statePic,postType,asyncTF
**//**//**//**/

Model.prototype.Insert=function(){
	var actionType='';var dataStr='';var postUrl='';var pageName='';var pageTitle='';var backType='0';var showTag='';var statePic=Loadimg3;var postType='POST';var asyncTF=true;
	var M=this;
	if(arguments[0]!=undefined)		actionType		= arguments[0];
	if(arguments[1]!=undefined)		postUrl			= arguments[1];
	if(arguments[2]!=undefined)		dataStr			= arguments[2];
	
	if(arguments[3]!=undefined)		pageName		= arguments[3];
	if(arguments[4]!=undefined)		pageTitle		= arguments[4];
	if(arguments[5]!=undefined)		actionTitle		= arguments[5];
	if(arguments[6]!=undefined)		backType		= arguments[6];
	if(arguments[7]!=undefined)		showTag			= arguments[7];
	
	if(arguments[8]!=undefined)		statePic		= arguments[8];
	if(arguments[9]!=undefined)		postType		= arguments[9];
	if(arguments[10]!=undefined)	asyncTF			= arguments[10];
	if(arguments[2]==undefined){return false;}
	clearTimeout(this.Task1);
	this.Task1=setTimeout(function(){
		$.ajax({
		type: postType,url: postUrl+"&r="+Math.random(),data: dataStr,cache:false,async:asyncTF,success: function(msg){
			if(unescape(msg)=='False'){location.href='/login.shtml?url='+this.HistoryLink;	return false;}
			
			M.InsertSysMsg(actionType,msg,backType,pageName,pageTitle,actionTitle,showTag);
		},
		error:function(msg){SysUI.ErrMsg("操作失败");return false;},
		timeout:function(msg){SysUI.ErrMsg("网络超时");	}
		})
	},this.TaskOutTime);
};

/**//**//**//**
回调处理
@param:actionType,msg,backType,pageName,pageTitle,actionTitle,showTag
**//**//**//**/
Model.prototype.InsertSysMsg=function(){
	var actionType;var backType=0;var msg;var pageName='';var pageTitle;var actionTitle='';var showTag;
	if(arguments[0]!=undefined)		actionType		= arguments[0];
	if(arguments[1]!=undefined)		msg				= arguments[1];
	if(arguments[2]!=undefined)		backType		= arguments[2];
	
	if(arguments[3]!=undefined)		pageName		= arguments[3];
	if(arguments[4]!=undefined)		pageTitle		= arguments[4];
	if(arguments[5]!=undefined)		actionTitle		= arguments[5];
	if(arguments[6]!=undefined)		showTag			= arguments[6];
	switch(backType){
		case 0:
			if(msg=="1"){
				SysUI.NewLayer('',350,10);
				$('#out_Main').html('<img src="/Images/Titpic/success.gif"/>&nbsp;&nbsp;&nbsp; '+pageTitle+actionTitle+'成功!');
				$('#out_Foot').html('<input name="bntok" type="button" id="bntok" value="继续'+actionTitle+'" class="btn69" onclick="javascript: closeActMsg();"/><input name="bntok" type="button" id="bntok" value="返回列表" class="btn69" onclick="javascript: location.href=\''+pageName+'\';"/>');
			}else{SysUI.ErrMsg("提交失败");}
			return true;break;
		case 1:
			if(msg=="1"){
				SysUI.NewLayer('',350,10);
				$('#out_Main').html('<div align=center>数据提交成功&nbsp;&nbsp;'+truepic+'<br>');
				$('#out_Foot').html('手动<a href="javascript:location.href=\''+pageName+'\';">点击返回列表</a>');
				}else{SysUI.ErrMsg("提交失败");}
			return true;break;
		case 3:
			if(msg=="1"){
				SysUI.NewLayer('',350,10);
				$('#out_Main').html('<img src="/Images/Titpic/success.gif"/>&nbsp;&nbsp;&nbsp; '+pageTitle+actionTitle+'成功!');
				$('#out_Foot').html('<input name="bntok" type="button" id="bntok" value="返回列表" class="btn69" onclick="javascript: location.href=\''+pageName+'\';"/>');
				}else{SysUI.ErrMsg("提交失败");}
			return true;break;
		case 2:
			if(msg=="1"){
				SysUI.NewLayer('',350,10);
				$('#out_Main').html('<p><img src="/Images/Titpic/success.gif"/>&nbsp;&nbsp;&nbsp; '+pageTitle+actionTitle+'成功!</p>');
				$('#out_Foot').html('<input name="bntok" type="button" id="bntok" value="继续'+actionTitle+'" class="btn69" onclick="javascript: closeActMsg();"/>');
			}else{SysUI.ErrMsg("提交失败");}
			return true;break;
		case 4:
			outMsgInfo(actionType,msg,pageName,pageTitle,actionTitle,showTag);
			return true;break;
		default:
			closeActMsg();break;
	}
};


/**//**//**//**
删除数剧
@param:actionType,postUrl,dataStr,pageName,backType,showTag,statePic,postType,asyncTF
**//**//**//**/
Model.prototype.Delete=function(){
	var M=this;
	var actionType='';var showTag='';var postUrl='';var dataStr='';var backType=0;var pageName='index.shtml';var statePic=Loadimg3;var postType='POST';var asyncTF=true;
	if(arguments[0]!=undefined)	actionType		= arguments[0];
	if(arguments[1]!=undefined)	postUrl			= arguments[1];
	if(arguments[2]!=undefined)	dataStr			= arguments[2];
	if(arguments[3]!=undefined)	pageName		= arguments[3];
	if(arguments[4]!=undefined)	backType		= arguments[4];
	if(arguments[5]!=undefined)	showTag			= arguments[5];

	if(arguments[6]!=undefined)	statePic		= arguments[6];
	if(arguments[7]!=undefined)	postType		= arguments[7];
	if(arguments[8]!=undefined)	asyncTF			= arguments[8];
	if(arguments[2]==undefined){return false;}
	if (confirm('您是否确定要删除？')==false){return false;}
	clearTimeout(this.Task2);
	this.Task2=setTimeout(function(){
		$.ajax({
		type: postType,url: postUrl+"&r="+Math.random(),data: dataStr,cache:false,async:asyncTF,success: function(msg){
			if(unescape(msg)=='False'){location.href='/login.shtml?url='+this.HistoryLink;	return false;}
			M.DeleteSysMsg(actionType,msg,backType,pageName,showTag);
		},
		error:function(msg){SysUI.ErrMsg("操作失败");return false;},
		timeout:function(msg){SysUI.ErrMsg("网络超时");	}
		})
	},this.TaskOutTime);
};
	
/**//**//**//**
删除回调处理
@param:actionType,msg,backType,pageName,showTag
**//**//**//**/
Model.prototype.DeleteSysMsg=function(){
	var actionType;var backType=0;var msg;var pageName='';
	if(arguments[0]!=undefined)		actionType		= arguments[0];
	if(arguments[1]!=undefined)		msg				= arguments[1];
	if(arguments[2]!=undefined)		backType		= arguments[2];
	if(arguments[3]!=undefined)		pageName		= arguments[3];
	if(arguments[4]!=undefined)		showTag			= arguments[4];
	switch(backType){
		case 0:
			if(msg=="1"){
				SysUI.NewLayer('',350,10);
				$('#out_Main').html('<img src="/Images/Titpic/success.gif"/>&nbsp;&nbsp;&nbsp; 删除成功!');
				$('#out_Foot').html('<input name="bntok" type="button" id="bntok" value="关 闭" class="btn69" onclick="javascript: closeActMsg();location.reload();"/><input name="bntok" type="button" id="bntok" value="返回列表" class="btn69" onclick="javascript: location.href=\''+pageName+'\';"/>');
			}else{SysUI.ErrMsg("提交失败");}
			return true;break;
		case 1:
			if(msg=="1"){location.reload();}else{SysUI.ErrMsg("提交失败");}
			return true;break;
		case 4:
			DelOutMsg(actionType,msg,showTag);
			return true;break;
		default:
			closeActMsg();break;
	}
};	

/**//**//**//**
min类删除数剧
@param:actionType,postUrl,NewsID,pageName,backType,showTag
**//**//**//**/
Model.prototype.Del=function(){
	var actionType='';var showTag='';var postUrl='';var NewsID='';var pageName='index.shtml';var backType=0;
	if(arguments[0]!=undefined)	actionType		= arguments[0];
	if(arguments[1]!=undefined)	postUrl			= arguments[1];
	if(arguments[2]!=undefined)	NewsID			= arguments[2];
	if(arguments[3]!=undefined)	pageName		= pageName[3];
	if(arguments[4]!=undefined)	backType		= arguments[4];
	if(arguments[5]!=undefined)	showTag			= arguments[5];
	var dataStr='';var statePic=Loadimg3;var postType='POST';var asyncTF=true;
	if ($.trim(NewsID)=='' ){alert("请您先选择要删除的项!");return false;}
		dataStr="NewsID="+ escape(NewsID);
		this.Delete(actionType,postUrl,dataStr,pageName,backType,showTag);
};

/**//**//**//**
常用AJAX 封装类
@param:actionTitle,postUrl,dataStr,showTag,tagType,statePic,postType,asyncTF
**//**//**//**/
Model.prototype.AjaxComon=function(){
	var actionTitle='';var showTag='';var postUrl='';var dataStr='';var statePic=Loadimg2;var postType='POST';var asyncTF=true;
	var tagType=1;
	if(arguments[0]!=undefined)	actionTitle		= arguments[0];
	if(arguments[1]!=undefined)	postUrl			= arguments[1];
	if(arguments[2]!=undefined)	dataStr			= arguments[2];
	if(arguments[3]!=undefined)	showTag			= arguments[3];
	if(arguments[4]!=undefined)	tagType			= arguments[4];
	if(arguments[5]!=undefined)	postType		= arguments[5];
	if(arguments[6]!=undefined)	asyncTF			= arguments[6];
	if(arguments[2]==undefined){return false;}
	if(!asyncTF&&tagType==7){this.Task3=0;}
	clearTimeout(this.Task3);
	this.Task3=setTimeout(function(){
		$.ajax({
		type: postType,
		url: postUrl+"&r="+Math.random(),
		data: dataStr,
		cache:false,
		async:asyncTF,
		beforeSend: function(XMLHttpRequest){
			if(asyncTF){
				if (tagType==1&&$(showTag).length>0&&statePic!=''){$(showTag).html(statePic+actionTitle+"&nbsp;&nbsp;请稍后");}	
				else if(tagType==3){SysUI.LoadMsg(statePic,actionTitle+"请稍后");}
			}
			},
		success: function(msg){
				
				if(unescape(msg)=='False'){location.href='/login.shtml?url='+this.HistoryLink;	return false;}
				switch(tagType){
					case 1:
						if(showTag!='undefinded'&&showTag!=''){$(showTag).html(unescape(msg));return true;}
						break;
					case 2:
						if(showTag!='undefinded'&&showTag!=''){$(showTag).attr('value',unescape(msg));return true;}
						break;
					case 3:
						SysUI.NewLayer('',200,10);
						$('#out_Main').html(unescape(msg));
						$('#out_Foot').html('<input name="bntok" type="button" id="bntok" value="确 定" class="btn45" onclick="javascript: closeActMsg();"/>');
						break;
					case 4 :
						document.body.innerHTML = unescape(msg);
						break;
					case 5 :
						document.write(unescape(msg));
					case 6 :
						location.href = unescape(msg);
						break;
					case 7 :
						return unescape(msg);
						break;	
					default:
						if(showTag!='undefinded'&&showTag!=''){$(showTag).html(unescape(msg));return true;}
						break;
					}
		},
		error:function(msg){SysUI.ErrMsg("操作失败");alert(unescape(msg));return false;},
		timeout:function(msg){SysUI.ErrMsg("网络超时");	}
		})
	},this.TaskOutTime);
};

//下拉框单项数据
Model.prototype.Select=function(){
	var showTag='';var postUrl='';var dataStr='';var postType='POST';var asyncTF=true;var actionTitle='';
	if(arguments[0]!=undefined)	showTag			= arguments[0];
	if(arguments[1]!=undefined)	postUrl			= arguments[1];
	if(arguments[2]!=undefined)	dataStr			= arguments[2];
	if(arguments[3]!=undefined)	postType		= arguments[3];
	if(arguments[4]!=undefined)	asyncTF			= arguments[4];
	if(arguments[5]!=undefined)	actionTitle		= arguments[5];
	if(arguments[0]==undefined){return false;}
	clearTimeout(this.Task4);
	this.Task4=setTimeout(function(){
		$.ajax({
		type: postType,
		url: postUrl+"&r="+Math.random(),
		data: dataStr,
		cache:false,
		async:asyncTF,
		success: function(msg){
			if(unescape(msg)=='False'){location.href='/login.shtml?url='+this.HistoryLink;	return false;}
			$(showTag).empty();
			if(msg !='0'){
				var arrMajor=unescape(msg);
				var arrMa=arrMajor.split(",");
				for(var i = 0; i < arrMa.length; i++){
					var arrMavt = arrMa[i ].split("&");
					$("<option value=\""+arrMavt[0]+"\">"+arrMavt[1]+"</option>").appendTo(showTag)
				}
			}
			return true;
		},
		error:function(msg){return false;},
		timeout:function(msg){SysUI.ErrMsg(actionTitle+"加载超时，请重刷");	}
		})
	},this.TaskOutTime);
};

///批量获取表单中带ID非单选多选项值
Model.prototype.GetTagVal=function(){
	var aIdArray=new Array("flag="+Math.random());	var argLen=arguments.length;
	for(i=0;i<argLen;i++){aIdArray[i+1]="&"+arguments[i]+"="+escape(getObjValue("#"+arguments[i]));}
	return aIdArray.join('');
};
//批量获取动态表单值
Model.prototype.GetMovieTagVal=function(){
	var aIdArray=new Array("flag="+Math.random());	var argLen=arguments.length;
	for(i=1;i<argLen;i++){aIdArray[i+1]="&"+arguments[i]+"="+escape(getObjValue("#"+arguments[i]+"_"+arguments[0]));}
	return aIdArray.join('');
};

/**//**//**//**
批量获取表单中多选项值
@param:objTag:多选框name
**//**//**//**/
Model.prototype.CheckBoxVal=function(){
	var str='';
	if(arguments[0]==undefined){return '';}else{
		$("input:checkbox[name='"+arguments[0]+"'][checked]").each(function(){str+=$(this).val()+",";});
	}
	if (str!=""&&str!=undefined){return str.substr(0,str.length-1);}else{return ""}
};
//调用函数
function closeActMsg(){
	if($('#FullScreenDiv').length>0&&$('#Msg_Info').length>0){
			hiddenSelect('show');$('#FullScreenDiv').hide();$('#Msg_Info').hide();}
	}
	
function createLockDiv(id){
	hiddenSelect('hidden');
	if (!document.getElementById(id)) {
	var cDiv = document.createElement("div");
	cDiv.id = 'FullScreenDiv';
	cDiv.style.position = 'absolute';
	cDiv.style.zIndex = 8888;
	cDiv.style.left = '0px';
	cDiv.style.top = '0px';
	cDiv.style.width = '100%';
	cDiv.style.height = document.documentElement.scrollHeight + 50 +'px';
	cDiv.style.backgroundColor = '#000000';
	document.body.appendChild(cDiv);
	}else {$('#FullScreenDiv').show();	document.getElementById('FullScreenDiv').style.height = document.documentElement.scrollHeight + 50 +'px';	}
}

function createlayer(newsID,formWidth,AlphaNum){
	createLockDiv('FullScreenDiv');
	if(newsID==''||newsID==undefined)newsID="Msg_Info";
	if (AlphaNum==""){AlphaNum=80;}
	if (formWidth==""){formWidth=452;}
	if (!document.getElementById(newsID)){
		var cDiv = document.createElement("div");
		document.body.appendChild(cDiv);
		cDiv.id = newsID;
		cDiv.className = newsID;
		cDiv.style.position = 'absolute';
		cDiv.style.zIndex = 88888;
		cDiv.style.left = (document.documentElement.scrollWidth / 2 - 190) +'px';
		cDiv.style.backgroundColor = '#000000';
	}else{$('#FullScreenDiv').show();document.getElementById(newsID).style.display = '';	}
	var tempTop='<div class="out_Top" id="out_Top">\
				<div class="out_Title" id="out_Title">信息提示</div>\
				<div class="out_Close" id="out_Close"><a href="javascript:void(0);" onClick="closeActMsg();" class="closebtn" title="关闭"><span>关闭</span></a></div>\
			  </div>';
	var tempMain=' <div class="out_Main" id="out_Main"></div>';
	var tempFoot='<div class="out_Foot" id="out_Foot">\
					<input name="bntok" type="button" id="bntok" value="确定" class="btn45"/>\
				  </div>';
	var tempAll='<div class="out_Div" id="out_Div">\
				<div class="out_Box">\
				'+tempTop+'\
				'+tempMain+'\
				'+tempFoot+'\
				 </div>\
			  </div>';
	document.getElementById(newsID).innerHTML = tempAll;
	document.getElementById('FullScreenDiv').style.opacity = AlphaNum/100;
	document.getElementById('FullScreenDiv').style.filter = 'Alpha(opacity='+AlphaNum+')';
	document.getElementById(newsID).style.position = 'absolute';
	document.getElementById(newsID).style.width=formWidth+'px';
	var floatdiv=document.getElementById(newsID);
	var range=getRange();
	floatdiv.ox=(range.width-formWidth)/2;
	floatdiv.oy=(range.height-200)/2;
	floatdiv.style.top=(range.top+floatdiv.oy) +"px";
	floatdiv.style.left=(range.left+floatdiv.ox) +"px";
	moveactive(newsID,formWidth,'out_Top','out_Foot');
	}
/*-------------------------鼠标拖动---------------------*/
function moveactive(boxobj,formWidth,moveobj1,moveobj2){
	if($('#'+moveobj1).length>0)$('#'+moveobj1).css({"cursor":"move"});
	var od = document.getElementById(boxobj);
	var tod = document.getElementById(moveobj1);
	var bod = document.getElementById(moveobj2);
	var dx,dy,mx,my,mouseD;
	var odrag;
	var marclientW;
	var marclientH;
	var isIE = document.all ? true : false;
	document.onmousedown = function(e){
		var e = e ? e : event;
		if(e.button == (document.all ? 1 : 0)){mouseD = true; }
	}
	document.onmouseup = function(){
		mouseD = false;
		odrag = "";
		if(isIE){
			od.releaseCapture();
			od.style.filter = 'Alpha(opacity=100)';
			//od.filters.alpha.opacity = 100;
		}else{
		window.releaseEvents(od.MOUSEMOVE);
		od.style.opacity = 1;
		}
	}
	//function readyMove(e){
	// 顶层托
	tod.onmousedown = function(e){
	//	tod.style.cursor='move';
		odrag = this;
		var e = e ? e : event;
		if(e.button == (document.all ? 1 : 0)){
			mx = e.clientX;
			my = e.clientY;
			od.style.left = od.offsetLeft + "px";
			od.style.top = od.offsetTop + "px";
			if(isIE){
				od.setCapture();
				//od.filters.alpha.opacity = 50;
				od.style.filter = 'Alpha(opacity=50)';
			}else{
				window.captureEvents(Event.MOUSEMOVE);
				od.style.opacity = 0.5;
			}
		}
	}
	//底层托
	bod.onmousedown = function(e){

		odrag = this;
		var e = e ? e : event;
		if(e.button == (document.all ? 1 : 0)){
			mx = e.clientX;
			my = e.clientY;
			od.style.left = od.offsetLeft + "px";
			od.style.top = od.offsetTop + "px";
			if(isIE){
				od.setCapture();
				//od.filters.alpha.opacity = 80;
				od.style.filter = 'Alpha(opacity=80)';
			}else{
				window.captureEvents(Event.MOUSEMOVE);
				od.style.opacity = 0.8;
			}
		}
	}
	document.onmousemove = function(e){
		var marclientW= parseInt(document.documentElement.clientWidth-formWidth-20);
		var sh=document.documentElement.scrollHeight;
		var ch=document.documentElement.clientHeight
		var pageHeight=(sh-ch)>0?sh:ch;
		var marclientH=pageHeight-200;
		var e = e ? e : event;
		if(mouseD==true && odrag){
		var mrx = e.clientX - mx;
		var mry = e.clientY - my;
		var odw= parseInt(od.style.left) +mrx;
		var odh= parseInt(od.style.top) + mry
		odw=odw>marclientW?marclientW:odw;
		odw=odw<0?0:odw;
		odh=odh>marclientH?marclientH:odh;
		odh=odh<0?0:odh;
		od.style.left = odw + "px";
		od.style.top = odh + "px";
		mx = e.clientX;
		my = e.clientY;
		}
	}
}
	
function getRange() {
		var top     = document.documentElement.scrollTop;
		var left    = document.documentElement.scrollLeft;
		var height  = document.documentElement.clientHeight;
		var width   = document.documentElement.clientWidth;
      	if (top==0 && left==0 && height==0 && width==0) {
			top     = document.body.scrollTop;
			left    = document.body.scrollLeft;
			height  = document.body.clientHeight;
			width   = document.body.clientWidth;
     	 }
      return  {top:top  ,left:left ,height:height ,width:width };
}

var model	= new Model();
var ui		= new UI();
function logout() {
	var d = document.domain;
	var returnurl='0';
	if(arguments[0]!=undefined)	returnurl		= arguments[0];
	ui.LoadMsg(Loadimg3,"正在退出");
	//var cElement = document.createElement("iframe");
//	document.body.appendChild(cElement);
//	cElement.id = 'passportLogoutFrame';
//	cElement.style.display = 'none';
//	if (d.indexOf('zyho.net') >= 0) {
//		cElement.src = 'http://www.balew.com/Lib/Xml/Param/?action=logout';
//	}
//	else if (d.indexOf('balew.com') >= 0) {
//		cElement.src = 'http://www.zyho.net/Lib/Xml/Param/?action=logout';
//	}
	var c = function(){
			$.ajax({
			type: "POST",url: "/Lib/Xml/Param/"+defaultPage+"?subaction=logout&r="+Math.random(),data: "go=ok",cache:false,async:false,timeout: 5000,	error: function(msg){ui.ErrMsg("操作失败22！");return false;},timeout: function(msg){ui.ErrMsg("服务器超时！");return false;},   
			success: function(msg){
				if(unescape(msg) == '1'){
					if(returnurl!='0'){
						var url = location.href.toLowerCase().split('&url=');
						var refererUrl = '';
						for (var i = 1;i < url.length ;i ++ ){
							refererUrl += url[i];
						}
						if(refererUrl.indexOf("/login.shtml")!=-1){location.href='/login.shtml';}else{location.href = refererUrl;}
						
						return true;
					}else{
						location.reload();return true;
					}
				}
				else{ ui.ErrMsg("操作失败33！");return false;}
				}
			});
		}
	setTimeout(c,1000);
}

function checkLogin() {
	var Lmodel	= new Model();
	$(document).ready(function(){
	if($('#loginstate').length>0){
		Lmodel.AjaxComon('..','/Lib/Xml/Param/'+defaultPage+'?subaction=checkMemberLogin','','#loginstate');
		}
	 });
}

function GetSearchResult(e,val,id,type) {
	var Smodel	= new Model();
	var tag = document.getElementById(id);
	var jtag='#'+id;
	var c;
	val = val.replace(/ /g,'');
	var k = e.keyCode;
	if (k != 13 && k != 16 && k != 17 && k != 27 && k != 37 && k != 38 && k != 39 && k != 40 && k != 144){
		c = function() {
			if (val != '' && val.length > 1){
				Smodel.AjaxComon('..','/Lib/Xml/Param/'+defaultPage+'?subaction=GetSearchResult','val='+ escape(val) +'&id='+ id+'&type='+unescape(type),jtag);
				if (tag.innerHTML != '') {
					if (tag.style.display == 'none' && val.replace(/ /g,'') != '') {
						showTr(id);
						tag.style.opacity = 0.85;
						tag.style.filter = 'Alpha(opacity=85)';
						tag.style.zIndex = 7777;
					}
					hiddenSelect('hidden');
				}
			}
			else {tag.style.display = 'none';}
			clearTimeout(c);
		}
		setTimeout(c,500);
	}
	else if (k == 27|| k == 32){tag.style.display = 'none';}
	else if (k == 13){tag.style.display = 'none';searchsubmit();}
	else if (k == 38 || k == 40) {
		if (tag.style.display != 'none' && document.getElementById('searchResultDiv')){
			var t = -1;
			var j = document.getElementById('searchResultCount').value - 1;
			for (var i=0; i <= j; i++) {
				if (document.getElementById('r_'+ i) && document.getElementById('r_'+ i).className == 'resultFocusLi') {
					document.getElementById('r_'+ i).className = 'searchResultli';
					t = i;
				}
			}
			if (k == 40) t = t + 1;
			if (k == 38) t = t - 1;
			if (t > j) t = 0;
			if (t < 0) t = j;
			if (document.getElementById('r_'+ t)) {
				document.getElementById('r_'+ t).className = 'resultFocusLi';
				document.getElementById('k').value = document.getElementById('text_'+ t).innerHTML;
			}
		}
	}
}
