var userLink="/user";
var historyLink=document.location.href;
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 = '#eeeeee';
	cDiv.style.opacity = 0.90;
	cDiv.style.filter = 'Alpha(opacity=90)';
	document.body.appendChild(cDiv);
	}else {$('#FullScreenDiv').show();	document.getElementById('FullScreenDiv').style.height = document.documentElement.scrollHeight + 50 +'px';	}
}
function ActMsg(AlphaNum,htmlcont){
	createLockDiv('FullScreenDiv');
	var newsID="Msg_Info";
	if (AlphaNum==""){AlphaNum=80;}
	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 = '#eeeeee';
	}else{$('#FullScreenDiv').show();document.getElementById(newsID).style.display = '';	}
	document.getElementById(newsID).innerHTML = htmlcont;
	document.getElementById('FullScreenDiv').style.backgroundColor ='#eee';
	document.getElementById('FullScreenDiv').style.opacity = AlphaNum/100;
	document.getElementById('FullScreenDiv').style.filter = 'Alpha(opacity='+AlphaNum+')';
	document.getElementById(newsID).style.position = 'absolute';
	var floatdiv=document.getElementById(newsID);
	var range=getRange();
	floatdiv.ox=(range.width-400)/2;
	floatdiv.oy=(range.height-300)/2;
	floatdiv.style.top=(range.top+floatdiv.oy) +"px";
	floatdiv.style.left=(range.left+floatdiv.ox) +"px";
	}
function FloatForm(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 = '#eeeeee';
	}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" onclick="javascript: closeActMsg();"></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.backgroundColor ='#eee';
	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";
	}
function closeFloatForm(newsID) {
	hiddenSelect('show');
	if($('#FullScreenDiv').length>0)$('#FullScreenDiv').hide();
	if($(newsID).length>0)$(newsID).hide();
}
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 };
}
function closeActMsg() {
	if($('#FullScreenDiv').length>0&&$('#Msg_Info').length>0){hiddenSelect('show');$('#FullScreenDiv').hide();$('#Msg_Info').hide();}	
}
function LoadMsg(statePic,txtcont){
	ActMsg(80,"<div class=\"msg_Div\" ><div id=\"msg_text\"><div class=\"msg_text_top\"> <div align=center>"+statePic+"&nbsp;&nbsp;&nbsp;"+txtcont+"...</div> </div></div></div>");
}
function ErrMsg(txtcont){
	FloatForm('',380,10);
	$('#out_Main').html('<img src="/Images/Titpic/fail.gif"/>&nbsp;&nbsp;&nbsp;'+txtcont);
	$('#out_Foot').html('<a href="javascript: closeActMsg();">返回</a><a href="javascript:location.reload();" >刷新重试</a>');
}
function ErrMsg(txtcont,getType){
var goLink="";
	switch(getType){
	case 0:
	goLink=" closeActMsg()";break;
	case 1:
	goLink=" history.back()";break;
	case 2:
	goLink="location.reload()";	break;
	default:
	goLink=" closeActMsg()";break;
	}
	FloatForm('',380,10);
	$('#out_Main').html('<img src="/Images/Titpic/fail.gif"/>&nbsp;&nbsp;&nbsp;'+txtcont);
	$('#out_Foot').html('<a href="javascript:'+goLink+';">返回</a>');
}
function ShowMsg(txtcont,getType,loadimgtype){
	var goLink="";
	switch(getType){
		case 0:
			goLink=" closeActMsg()";break;
		case 1:
			goLink=" history.back()";break;
		case 2:
			goLink="location.reload()";break;
		default:
			goLink=" closeActMsg()";break;
	}
	switch(loadimgtype){
		case 0:
			loadimgurl="http://file.zgz93.com/Images/Titpic/success.gif";break;
		case 1:
			loadimgurl="http://file.zgz93.com/Images/Titpic/fail.gif";break;
		case 2:
			loadimgurl="http://file.zgz93.com/Images/Titpic/tip.gif";break;
		default:
			loadimgurl="http://file.zgz93.com/Images/Titpic/tip.gif";break;
		}
	
	FloatForm('',380,10);
	$('#out_Main').html('<img src="'+loadimgurl+'"/>&nbsp;&nbsp;&nbsp;'+txtcont);
	$('#out_Foot').html('<a href="javascript:'+goLink+';">返回</a>');
}
function SumbitForm1(postUrl,dataStr,successType,pageTitle,actionType){
	var showType="0";var insertTag="#formMain";	var buttonTag="#Update";
	sendUserDataToService("",showType,insertTag,buttonTag,"#msg_text","",successType,pageTitle,Loadimg3,postUrl,dataStr,"POST",false,false,actionType);
	return true;
}
function SumbitForm2(showType,pageName,postUrl,dataStr,pageTitle,actionType){
	sendUserDataToService("",showType,"#formMain","#Update","#msg_text",pageName,"2",pageTitle,Loadimg1,postUrl,dataStr,"POST",false,false,actionType);
	return true;
}
function SumbitForm3(showType,insertTag,buttonTag,msgObj,pageName,successType,pageTitle,statePic,postUrl,dataStr,actionType){
	sendUserDataToService("",showType,insertTag,buttonTag,"#msg_text",pageName,successType,pageTitle,Loadimg3,postUrl,dataStr,"POST",false,false,actionType);
	return true;
}
function SumbitForm4(subAction,statePic,postUrl,dataStr){
	sendUserDataToService(subAction,"2","#formMain","#Update","#msg_text","","4","",statePic,postUrl,dataStr,"POST",false,false,"");
	return true;
}
function getFormData(){
	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('');
}
function getRequestData(){
	var aIdArray=new Array("flag="+Math.random());	var argLen=arguments.length;
	for(i=0;i<argLen;i++){aIdArray[i+1]="&"+arguments[i]+"="+escape(Request(arguments[i]));}
	return aIdArray.join('');
}
function getFormData2(){
	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('');
}
function sendUserDataToService(subAction,showType,insertTag,buttonTag,msgObj,pageName,successType,pageTitle,statePic,postUrl,dataStr,postType,cacheTF,asyncTF,actionType) {
	$.ajax({
	   type: postType,
	   url: postUrl+"&r="+Math.random(),
	   data: dataStr,
	   cache:cacheTF,
	   async:asyncTF,
	   success: function(msg){
		   if(unescape(msg)=='False'){location.href='/login.shtml?url='+historyLink;
			return false;
			}
		getInsertSuccessCont(subAction,successType,unescape(msg),insertTag,buttonTag,msgObj,pageName,pageTitle,actionType);
		},
		error:function(msg){
			ErrMsg("提交失败");return false;},
		timeout:function(msg){ErrMsg("网络超时");return false;}
		});
}
function getInsertSuccessCont(subAction,getType,msgCont,insertTag,buttonTag,msgObj,pageName,pageTitle,actionType){
	var msgTxt=msgObj;
	if (msgObj=="" || msgObj=="#sendmsg"||msgObj=="#msg_text"){msgTxt="#msg_text";msgObj="#sendmsg";}
switch(getType){
	case "0":
		if(msgCont=="1"){
		FloatForm('',380,10);
		$('#out_Main').html('<img src="/Images/Titpic/success.gif"/>&nbsp;&nbsp;&nbsp; '+pageTitle+actionType+'成功!');
		$('#out_Foot').html('<a href="javascript:closeActMsg();"  >返回'+pageTitle+'页面</a><a href="'+userLink+'">返回会员中心</a>');
		}else{ErrMsg("提交失败");}
		return true;break;
	case "1":
	if(msgCont=="1"){
		FloatForm('',380,10);
		$('#out_Main').html('<div align=center>数据提交成功&nbsp;&nbsp;'+truepic+'<br><br>'+numTime3+'秒钟自动返回列表页</div>');
		$('#out_Foot').html('手动<a href="javascript:location.reload();">点击返回列表</a>');
		
		}else{ErrMsg("提交失败");}
	return true;break;
	case "2":
	if(msgCont=="1"){
		FloatForm('',380,10);
		$('#out_Main').html('<img src="/Images/Titpic/success.gif"/>&nbsp;&nbsp;&nbsp; '+pageTitle+actionType+'成功!');
		$('#out_Foot').html('<a href="javascript:location.href=\''+pageName+'\'">返回'+pageTitle+'</a><a href="javascript:location.reload();">继续'+actionType+'</a>');
		return true;}else{ErrMsg("提交失败");return false;	}
		break;
	case "4":
		outMsgInfo(subAction,getType,msgCont,insertTag,buttonTag,msgObj,pageTitle,actionType);
		return true;break;
	case "5":
		outMsgInfo(subAction,getType,msgCont,insertTag,buttonTag,msgObj,pageTitle,actionType);
	return true;break;
	case "test":
	$(msgObj).show();$(msgTxt).html(msgCont);return false;break;
	default:
	return "";break;
	}
}
function showDataComm(subAction,postUrl,dataStr){
	setTimeout(function(){	showData(subAction,"#formMain","#msg_text",Loadimg3,postUrl,dataStr,"POST",false,false);},10);
   }
function showData(subAction,showTag,msgObj,statePic,postUrl,dataStr,postType,cacheTF,asyncTF){
	$.ajax({
	   type: postType,
	   url: postUrl+"&r="+Math.random(),
	   data: dataStr,
	   cache:cacheTF,
	   async:asyncTF,
	   success: function(msg){
		   if(unescape(msg)=='False'){location.href='/login.shtml?url='+historyLink;return false;}
			viewData(msg,subAction,showTag,msgObj);
		},
		error:function(msg){
			
			ErrMsg("读取失败");return false;
		},
		timeout:function(msg){
			ErrMsg("网络超时");}
		});
}
function DelDataCom(getType,obj,postUrl){
	var ListTag="#cont_main";var msgObj="#msg_text";var statePic=Loadimg3;	var postType="POST";cacheTF=false;	asyncTF=false;
	DelSelect(getType,obj,ListTag,msgObj,statePic,postUrl,postType,cacheTF,asyncTF);
}
function DelDataCom2(getType,newsID,postUrl){
	var ListTag="#cont_main";var msgObj="#msg_text";var statePic=Loadimg3;	var postType="POST";cacheTF=false;asyncTF=false;
	var dataStr="NewsID="+ escape(newsID);
	DelNews(getType,ListTag,msgObj,statePic,postUrl,dataStr,postType,cacheTF,asyncTF);
}
function DelSelect(getType,obj,ListTag,msgObj,statePic,postUrl,postType,cacheTF,asyncTF){
	var NewsID="";
	NewsID=getallboxval(obj);
	if (jQuery.trim(NewsID)=="" ){alert("请您先选择要删除的项!");return false;	}
	var dataStr="NewsID="+ escape(NewsID);
	DelNews(getType,ListTag,msgObj,statePic,postUrl,dataStr,postType,cacheTF,asyncTF);
}

function DelNews(getType,ListTag,msgObj,statePic,postUrl,dataStr,postType,cacheTF,asyncTF){
	if (confirm('您是否确定要删除？')==false){return false;}
	if(jQuery.trim(dataStr)!="" || jQuery.trim(dataStr)!="undefined" ){
	LoadMsg(Loadimg3,"正在删除信息");
	$.ajax({
	   type: postType,
	   url: postUrl+"&r="+Math.random(),
	   data: dataStr+"&go=1",cache:cacheTF,async:asyncTF,
	   success: function(msg){
		   if(unescape(msg)=='False'){location.href='/login.shtml?url='+historyLink;return false;	}
			DelOutMsg(getType,unescape(msg));
		},
		error:function(msg){
			ErrMsg("操作失败");	return false;}	,
		timeout:function(msg){
			ErrMsg("操作失败");return false;}
	});
	}else{ErrMsg("操作失败");}
}

