//取父页面 parent.document.getElementById("")
//打开模态窗口使用的
var arguemnts = new Object();
arguemnts.window = window;
//关闭当前页面刷新父页面
function closeCurrentPage(){
	if(window.dialogArguments!=undefined){
		var u=window.dialogArguments.window.location;
		var u2=u.href;
		u2=u2.replace("method=delete","method=findAll");
		u2=u2.replace("method=deleteAll","method=findAll");
		u2=u2.replace("method=findAllAll","method=findAll");
		u.href = u2; 
		self.close();
	} 
}
//多选框全选
function CheckAll(elementsA,elementsB){
	var len = elementsA;
	if(len.length > 0){
		for(i=0;i<len.length;i++){
			elementsA[i].checked = true;
		}
		if(elementsB.checked ==false){
			for(j=0;j<len.length;j++){
				elementsA[j].checked = false;
			}
		}
	}else{
		len.checked = true;
		if(elementsB.checked == false){
			len.checked = false;
		}
	}
}
//判断删除前是否有选中
function CheckSelected(){
	var o=document.getElementsByName('chk_id');
	for(var i=0;i<o.length;i++){
		if(o[i].checked){
			return true;
		}
	}
	return false;
}
//可以为空，不为空时，填数字
function checkNumber(name,message){
	if (name.value.search(/^[0-9]+$/)==-1 && name.value!=""){
		alert(message+"!\n"); // 判断不能为空
		name.focus();
		name.select();
		return false;
	}else{
		return true;
	}
	
}

function gotoPage(go){
	if('' == go.value){
		alert('请输入页码');
		go.focus();
		return ;
	}
	if(go.value.search(/^[0-9]+$/)==-1){
		alert('页码必须为数字');
		go.focus();
		go.select();
		return ;
	}
	document.location.href=('<%=url %>?method=showRecordByTag&goto='+document.all.goto.value);
}
//不能为空,必须是数字判断
function checkNumberNull(name,value,message){
	if (value==""){
		alert(message+"!\n");
		name.focus();
		name.select();
		return false;
	}else{
		return true;
	}
	if (value.search(/^[0-9]+$/)==-1) {
		alert(message+"!\n"); // 判断不能为空
		name.focus();
		name.select();
		return false;
	}else{
		return true;
	}
	
}
function check_float(obj) {    
	if(obj.value == "")
		return true;      
    if (/^(\+|-)?\d+($|\.\d+$)/.test(obj.value )) {   
       return true;   
    } else {   
       alert("您输入非法数字！");
       obj.value = "";
	   obj.focus();
       return false;   
    }   
}  
//判断email,不一定输入
function checkEmail(name,value,message){
	if(name.value!=""){
		if (value.search(/^[_\.a-z0-9]+@[a-z0-9]+[\.][a-z0-9]{2,}$/i)==-1){
			alert(message+"!\n");
			name.focus();
			name.select();
			return false;
		}else{
			return true;
		}
	}else{
		return true;
	}
}
//判断选择框是否选中
function checkSelect(name,value,message){
	if (name.selected==false){
		alert(message+"!\n"); //为空时出现的提示
		return false;
	}else{
		return true;
	}
}
//判断日期,比如2000-12-20
function checkDate(name,value,message){
	flag=true; //为true说明可以为空
	getdate=value; 
	if (getdate.search(/^[0-9]{4}-(0[1-9]|[1-9]|1[0-2])-((0[1-9]|[1-9])|1[0-9]|2[0-9]|3[0-1])$/)==-1) {// 判断输入格式时候正确
		flag=false;
	}else{
		var year=getdate.substr(0,getdate.indexOf('-')) // 获得年
		// 下面操作获得月份
		var transition_month=getdate.substr(0,getdate.lastIndexOf('-')); 
		var month=transition_month.substr(transition_month.lastIndexOf('-')+1,transition_month.length);
		if (month.indexOf('0')==0){
			month=month.substr(1,month.length);
		}
		// 下面操作获得日期
		var day=getdate.substr(getdate.lastIndexOf('-')+1,getdate.length);
		if (day.indexOf('0')==0){
			day=day.substr(1,day.length);
		}
		//alert(month);
		//alert(day)
		//return false;
		if ((month==4 || month==6 || month==9 || month==11) && (day>30)){ // 4,6,9,11月份日期不能超过30
			flag=false; 
		}
		if (month==2){ // 判断2月份
			if (LeapYear(year))	{
				if (day>29 || day<1){ flag=false; }
			}else{
				if (day>28 || day<1){flag=false; }
			}
		}else{
			flag=true;
		}
	}
	if (flag==false){
		alert(message+"!\n"); //为空时出现的提示
		name.focus();
		name.select();
		return false;
	}
}

//以下两个方法Ajax使用
var XMLHttpReq = false;
	//创建XMLHttpRequest对象       
function createXMLHttpRequest() {
	if(window.XMLHttpRequest) { //Mozilla 浏览器
		XMLHttpReq = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) { // IE浏览器
		try {
			XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
}
//发送请求函数
function sendRequest(url) {
	createXMLHttpRequest();
	XMLHttpReq.open("GET", url, true);
	XMLHttpReq.onreadystatechange = processResponse;//指定响应函数
	XMLHttpReq.send(null);  // 发送请求
}

//以下用于显示和隐藏框架的功能
function shtop(){
 if (parent.full.rows.indexOf("0,*,")!=-1){
  parent.full.rows="64,*,"+parent.full.rows.split(",")[2]
  //document.getElementById("shtop").value="隐藏上部";
 }
 else{
  parent.full.rows="0,*,"+parent.full.rows.split(",")[2]
  //document.getElementById("shtop").value="显示上部";
 }
}
function shleft(){
 if (parent.cen.cols=="8,*"){
  parent.cen.cols="171,*,"
  //document.getElementById("shleft").value="隐藏左部";
 }
 else{
  parent.cen.cols="8,*"
  //document.getElementById("shleft").value="显示左部";
 }
}
function shbottom(){
var obj=parent.full;
if(obj==undefined){obj=parent.parent.full}
if(obj!=undefined){
 if (obj.rows.indexOf("*,0")!=-1){
  obj.rows=obj.rows.split(",")[0]+"*,550"
//  document.getElementById("shbottom").value="隐藏下部";
 }
 else{
  obj.rows=obj.rows.split(",")[0]+"*,0"
//  document.getElementById("shbottom").value="显示下部";
 }
}
}
function sbottom(){
	var obj=parent.full;
	if(obj==undefined){obj=parent.parent.full}
	if(obj!=undefined){
	  obj.rows=obj.rows.split(",")[0]+"*,550"
	
	}
}
function maxmain(){
 if (parent.full.rows=="0,*,0"){
  parent.full.rows="64,*,64"
  parent.cen.cols="25%,*"
  document.getElementById("maxmain").value="隐藏左上下";
  document.getElementById("shtop").value="隐藏上部";
  document.getElementById("shleft").value="隐藏左部";
  document.getElementById("shbottom").value="隐藏下部";
 }
 else{
  parent.full.rows="0,*,0";
  parent.cen.cols="0,*";
  document.getElementById("maxmain").value="显示左上下";
  document.getElementById("shtop").value="显示上部";
  document.getElementById("shleft").value="显示左部";
  document.getElementById("shbottom").value="显示下部";
 }
}

//打开下面的编辑框架
function openBottomPage(url){
	if(parent.bottomFrame!=undefined){
		parent.bottomFrame.location.href=url;
		shbottom();
	}else{
		window.showModalDialog(url,arguemnts, 'dialogWidth =1000px;dialogHeight = 500px;help=0');
	}
}
function openBottomPage2(url){//总是打开
	if(parent.bottomFrame!=undefined){
		parent.bottomFrame.location.href=url;
		sbottom();
	}
}
//新增或修改后刷新上面的列表页面
function refreshTopPage(){
	var obj=parent.listFrame;
	if(obj==undefined){
		obj=parent.parent.listFrame;
	}
	if(obj!=undefined){
		var u=obj.location;
		var u2=u.href;
		u2=u2.replace("method=delete","method=findAll");
		u2=u2.replace("method=deleteAll","method=findAll");
		u2=u2.replace("method=findAllAll","method=findAll");
		u2=u2.replace("#","");
		u.href = u2; 
	}
}
//打印预览的时候使用
function doPrintPreview(){ 
	PageSetup_Null();
	//WB.ExecWB(7,1);
	document.execCommand('print');
}
/*
function onload(){
	   WB.printing.SetMarginMeasure(2); // measure margins in inches
	   WB.printing.SetPageRange(false, 1, 3); // need pages from 1 to 3
	   WB.printing.printer = "HP DeskJet 870C";
	   WB.printing.copies = 2;
	   WB.printing.collate = true;
	   WB.printing.paperSize = "A4";
	   WB.printing.paperSource = "Manual feed";
	   // -- basic features
	   WB.printing.header = "居左显示&b居中显示&b居右显示页码，第&p页/共&P页";
	   WB.printing.footer = "（自定义页脚）";
	   WB.printing.portrait = false;
	   WB.printing.leftMargin = 0.75;
	   WB.printing.topMargin = 1.5;
	   WB.printing.rightMargin = 0.75;
	   WB.printing.bottomMargin = 1.5;
}*/
var HKEY_Root,HKEY_Path,HKEY_Key;
HKEY_Root="HKEY_CURRENT_USER";
HKEY_Path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
//设置网页打印的页眉页脚为空
function PageSetup_Null(){
	try{
		var Wsh=new ActiveXObject("WScript.Shell");
		HKEY_Key="header";
		Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
		HKEY_Key="footer";
		Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
	}catch(e){}
}
//设置网页打印的页眉页脚为默认值
function PageSetup_Default(){ 
	try{
		var Wsh=new ActiveXObject("WScript.Shell");
		HKEY_Key="header";
		Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&w&b页码,&p/&P");
		HKEY_Key="footer";
		Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&u&b&d");
	}catch(e){}
}

//tab标签使用
function secBoard(n)  {
	for(i=0; i<secTable.cells.length; i++){
		if(i==0){
			secTable.cells[i].className="sec1";
		}else{
			secTable.cells[i].className="sec3";
		}
	}
	if(n==0){
		secTable.cells[n].className="sec2";
	}else{
		secTable.cells[n].className="sec4";
	}
}
//下拉框跳转
//function MM_jumpMenu(targ,selObj,restore){ //v3.0
 // eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
 // if (restore) selObj.selectedIndex=0;
//}

	//下拉框跳转
function MM_jumpMenu(selObj,restore){ //v3.0
  window.open(selObj.options[selObj.selectedIndex].value);
  if (restore) selObj.selectedIndex=0;
}

