//==========================================
//系统开发：鼎鑫在线
//技术支持：http://www.fangka.net/
//==========================================
var Un=0;
//==========================================
//函数名：ShowBox
//用途：操作框弹出
//参数：
//==========================================
function ShowBox(DoUrl){
	$("#AlphaBox").height($(document).height());
	document.getElementById('BoxContent').innerHTML="<div id='LoadBox'><a href='javascript:void(0);' title='点此关闭' onclick=$('select').show();$('#Boxs').hide()><img src='Images/Loading2.gif' /></a></div>";
	$("#Boxs").show();
	$.get(DoUrl,
		function(data){
			document.getElementById('BoxContent').innerHTML=data;
			return true;
		}
	);
	$('select').hide();
}

function Type1(){
	$(".Type1").css("display","block");
	$(".Type2").css("display","none");
}

function Type2(){
	$(".Type1").css("display","none");
	$(".Type2").css("display","block");
}

document.onkeydown=function(){ 
	if(window.event.keyCode==27){ 
		$("#Boxs").hide();
		$('select').show();
	} 
} 

function CheckAll(form) {
	for (var i = 0; i < form.elements.length; i++) {
		var e = form.elements[i];
		if (e.name != 'chkall') 
			e.checked = form.chkall.checked;
	}
}

//==========================================
//函数名：PageReSize
//用途：页面初始化
//参数：
//==========================================
function PageReSize(){
	var LeftWidth=189;
	var RightWidth=$("#Bodys").width()-189;
	var WindowsHeight=$(document).height()-90;
	var LeftHeight=$("#MainLeft").height();
	var RightHeight=$("#MainRight").height();
	if(RightWidth>812){
		$("#MainRight").width(RightWidth);
		$("#AllBox").width($("#Bodys").width());
	}else{
		$("#AllBox").width(1001);
	}
	if(LeftHeight<WindowsHeight||LeftHeight<RightHeight){
		if(RightHeight>WindowsHeight){
			$("#MainLeft").height(RightHeight);
		}else{
			$("#MainLeft").height(WindowsHeight);
		}
	}
}

//==========================================
//函数名：SetRContent
//用途：替换DIV内容
//参数：DivId：要替换的DIV
//     Urls：获取内容的链接
//==========================================
function SetRContent(DivId,Urls){
	document.getElementById(DivId).innerHTML="<a href='javascript:void(0);' title='点此关闭' onclick=$('select').show();$('#Boxs').hide()><img src='Images/Loading.gif' /></a>";
	$.get(Urls,
		function(data){
			document.getElementById(DivId).innerHTML=data;
			return true;
		}
	);
}

//==========================================
//函数名：OpenMenu
//用途：菜单开关
//参数：MenuId：菜单ID
//==========================================
function OpenMenu(MenuId){
	if($("#"+MenuId).css("display")=="block"){
		$("#"+MenuId).css("display","none");
	}else{
		$("#"+MenuId).css("display","block");
	}
}

//==========================================
//函数名：DelIt
//用途：通用删除
//参数：Cstr：提示语句
//     Urls：执行URL
//     F5Url：刷新URL
//     F5Div：刷新DIV
//==========================================
function DelIt(Cstr,Urls,F5Div,F5Url){
	if(confirm(Cstr)){
		$.get(Urls,
			function(data){
				alert(data);
				var Arrstr1 = new Array();
				var Arrstr2 = new Array();
				Arrstr1 = F5Div.split("|");
				Arrstr2 = F5Url.split("|");
				for(var i=0;i<Arrstr1.length;i++){
					SetRContent(Arrstr1[i],Arrstr2[i]);
				}
				return true;
			}
		);
	}
	return;
}

//==========================================
//函数名：Sends
//用途：表单提交
//参数：FormName：提交的FORM
//     ToUrl：提交向的链接
//     SuGo：成功后是否转向链接，1转向，0不转向
//     GoUrl：转向链接
//     SuAlert：成功后是否弹出框提示，1弹出，0不弹出
//     SuF5：成功后是否刷新DIV，1刷新，0不刷新
//     F5Url：刷新URL
//     F5Div：刷新DIV
//==========================================
function Sends(FormName,ToUrl,SuGo,GoUrl,SuAlert,SuF5,F5Div,F5Url){
    var options = { 
		url:  ToUrl,
        beforeSubmit:function(formData, jqForm, options){
          return true; 
		},
        success:function(responseText, statusText){
          if(statusText=="success"){
            if(responseText.search("成功")>0){
				if(SuAlert==1){
					alert(responseText);
				}
				else{
					$("#Boxs").hide();
					$('select').show();
					var st=responseText.replace(/\|\|\|\|\|/gi,"\n");
					alert(st);
				}
				if(SuGo==1){
					location.href=GoUrl;
				}
				if(SuF5==1){
					var Arrstr1 = new Array();
					var Arrstr2 = new Array();
					Arrstr1 = F5Div.split("|");
					Arrstr2 = F5Url.split("|");
					for(var i=0;i<Arrstr1.length;i++){
						SetRContent(Arrstr1[i],Arrstr2[i]);
					}
				}
            }
            else{
				var st=responseText.replace(/\|\|\|\|\|/gi,"\n");
				Un=0;
				alert(st);
           }
          }
          else{
            alert(statusText);
          }
		}
    }; 
    $('#'+FormName+'').ajaxForm(options); 
}

//==========================================
//函数名：Sends_Div
//用途：表单提交更新DIV
//参数：FormName：提交的FORM
//     ToUrl：提交向的链接
//     F5Div：刷新DIV
//==========================================
function Sends_Div(FormName,ToUrl,F5Div){
	document.getElementById(F5Div).innerHTML="<a href='javascript:void(0);' title='点此关闭' onclick=$('select').show();$('#Boxs').hide()><img src='Images/Loading.gif' /></a>";
    var options = { 
		url:  ToUrl,
        beforeSubmit:function(formData, jqForm, options){
          return true; 
		},
        success:function(responseText, statusText){
          if(statusText=="success"){
            document.getElementById(F5Div).innerHTML=responseText;
          }
          else{
            alert(statusText);
          }
		}
    }; 
    $('#'+FormName+'').ajaxForm(options); 
}

//==========================================
//函数名：ChangeSelect
//用途：修改Select内容
//参数：Urls：执行URL
//     SId：操作的Select
//==========================================
function ChangeSelect(Urls,SId){
	$.get(Urls,
		function(data){
			if(data!=""){
				BuildSel(data,document.getElementById(SId));
			}
			return true;
		}
	);
}

//==========================================
//函数名：BuildSel
//用途：执行修改Select内容
//参数：Urls：执行URL
//     SId：操作的Select
//==========================================
function BuildSel(Str,Sel){
	//先清空原来的数据.
	var Arrstr = new Array();
	Arrstr = Str.split(",,,,,");
	//开始构建新的Select.
	if(Str!=""){
		Sel.options.length=0;
		var arrst;
		for(var i=0;i<Arrstr.length;i++){
			if(Arrstr[i]!=""){
				Arrst=Arrstr[i].split("|||||");
				Sel.options[Sel.options.length]=new Option(Arrst[1],Arrst[0]);
			}
		}
	}
}

