/**********************************************************
 基本脚本库。
 此处定义了脚本全局变量，常用函数方法以及对象等等。
  
***********************************************************/ 

// 控制重复交易提交的全局变量

var submitFlag=false;
var offHeight = window.screen.height;
var offwidth= window.screen.width;
var logLevel = 'debug,info';

// create our pseudo-two-dimensional array
var myarray ;

/*
 * 页面初始化方法，外部不需要调用。
 */
function _initializtionPage(){		
	document.write("<iframe scrolling='no' id='_loadingfrm' src='../help/frame.htm' frameborder='0' style='position:absolute; top:0px;left:0px; display:none'></iframe>");
	document.write("<div id='loading' class='loading' style='position:absolute;LEFT:38%; top:200px; display:none;z-index:1000'></div>");
	createPromptArea("正在加载，请稍等.....");
}

/*
 *	阻止网页上的右键操作
 *
 */
function Click(){
	alert("为了您的网上交易安全，禁止进行该类操作");
	window.event.returnValue=false;
}


/*
 *	控制表格斑马线
 *
 */
function zebarline(){
	var tabs = document.getElementsByTagName("table");
	for (i=0;i<tabs.length;i++){
		if (tabs[i].className == "table_comm" || tabs[i].className == "table_comm_noborder"){
			var otab = tabs[i];
			var otr = otab.getElementsByTagName("tr");
			for (j=0;j<otr.length;j++){
				if (j%2==0){
					otr[j].className = "tr20"
				} else{
					otr[j].className = "tr20c"
				}
				/*
				if(otr[j].className == "tr20"||otr[j].className == "tr20c"){
					otr[j].onmouseover = function(){
						this.className="trsel";
					}	
					if (j%2==0){
						otr[j].onmouseout = function(){
							this.className="tr20";
						}
					}else{
						otr[j].onmouseout = function(){
							this.className="tr20c";
						}					
					}
				}
				*/
			}//end for
		}	
	}
}


/*
 *	创建一个信息等待提示框。
 *
 */
function createPromptArea(infoStr){
	var promptdiv = document.getElementById("loading");
	
	 if(promptdiv){
	 	promptdiv.style.display="block"
		promptdiv.innerHTML=infoStr;
    var iwidth = promptdiv.offsetWidth;  
    var iheight = promptdiv.offsetHeight;

	var shim=document.getElementById("_loadingfrm");
    shim.style.width = iwidth;
    shim.style.height = iheight;
    shim.style.top = promptdiv.style.top;
    shim.style.left = promptdiv.style.left;
    shim.style.zIndex = promptdiv.style.zIndex - 1;
    shim.style.display = "block";

	}else{	
		
	}
}

/*
 *	关闭创建的信息等待提示框。
 *
 */
function closePromptArea(){
	var promptdiv = document.getElementById("loading");
	var shim=document.getElementById("_loadingfrm");
	if(promptdiv){
		promptdiv.style.display="none";
	}
	if(shim){
		shim.style.display="none";
	}	
}

/**	
	重复交易提交控制函数。
	该函数判断一个Form是否已经提交，如果已经提交则提示用户
	该交易重复提交。
	
	@param formObj 当前提交的Form对象，比如 duplicateSubmitCtrl(form1);
	@param delegateSubmit ，是否有该方法自动根据条件提交该form ,
	取值为true或者false。true交由该方法提交该form，反之为false，默认为false。
**/
function duplicateSubmitCtrl(formObj,delegateSubmit){
	delegateSubmit = true;
	if(submitFlag==true){
		alert("该交易已经提交，请不要重复提交!");
		return false;
	}else if(delegateSubmit==true){
		createPromptArea("已经提交，请稍等...");
		submitFlag= true;
		formObj.submit();
		return false;
	}
	submitFlag= true;	
	return true;
}




/**
	交易跳转方法。在当前页面中返回到指定的交易。
	
	@param formObj 当前提交的Form对象，比如 duplicateSubmitCtrl(form1);
	@param transName，交易名称。
**/
function goBack(formObj,transName){
	formObj.transName.value = transName;
	return duplicateSubmitCtrl(formObj,true);
}

/**
	三级菜单交易页面跳转方法。
	
	@param transName，交易名称。
	@param menuid,三级菜单id。
**/
var _pageMenuId = "";

function goPageWithTransName(transName,menuid){
	function _createInputElement(parent,name,value){
		var newElement = document.createElement("INPUT");
	 	newElement.name = name;
	 	newElement.type = "hidden";
	 	newElement.value = value;
		parent.appendChild(newElement);	
	}		
	//window.status = "";
	//alert(_pageMenuId+"="+menuid);
	if(_pageMenuId!=menuid){
		_pageMenuId = menuid;
	}else{
		createPromptArea("正在处理您的请求...");
		return false;
	}

	if(document.form1){
		if(document.form1.transName){
			document.form1.transName.value = transName;
		}else{
			_createInputElement(document.form1,"transName",transName);
		}
		if(document.form1.SelectedMenuId){
			document.form1.SelectedMenuId.value = menuid;
		}else{
			_createInputElement(document.form1,"SelectedMenuId",menuid);
		}	
	}else{
		document.write("<form name='form1' method='post' action='/per/main' >");
		document.write("<input type='text' name='transName' value='"+transName+"'>");
		document.write("<input type='text' name='SelectedMenuId' value='"+menuid+"'>");
		document.write("</form>");
	}	
	closePromptArea();
	//允许重复提交-切换交易页面。
	submitFlag= false;	
	duplicateSubmitCtrl(document.form1,true);
	//允许重复提交-切换交易页面。
	submitFlag= false;
}	

function showmenu(){
	var menu=document.getElementById("helptip")
	menu.style.display="block"
  var width = menu.offsetWidth;  
  var height = menu.offsetHeight;
	var shim=document.getElementById("ifm")
  shim.style.width = width;
  shim.style.height = height-55;
  shim.style.top = menu.offsetTop+45;
  shim.style.left = menu.style.left;
  shim.style.zIndex = menu.style.zIndex - 1;
  shim.style.display = "block";
}


function closetip(){
	var i;
	var obj;
	var objid = "helptip";		
	if(document.getElementById(objid)){
		document.getElementById(objid).style.display="none";
	}else{
		return;	
	}
	var ff=document.getElementById("ifm")
	ff.style.display="none"
}

function hidemenu(){
	var oo=document.getElementById("menu")
	oo.style.display="none"
	var ff=document.getElementById("ifm")
	ff.style.display="none"
} 


/*************************************************************
	页面初始化。
*************************************************************/
_initializtionPage();
document.onclick=closetip;
document.oncontextmenu=Click;//阻止网页右键的脚本
closePromptArea();
/*
window.onload = function(){
	closePromptArea();	
}
*/
window.onunload = function(){
	createPromptArea("正在加载，请稍等...");
}

function tiparrow(){
	document.getElementById("tiparrowleft").style.top=offHeight/2-146+"px";
}
