function doSubmit(){
    var f=document.stdform;
	
	//not allow to do any submit(even change page) if any problem is found
	if(!validateAll()) return false;
	
	var message=document.all.do_submit_msg.style;
	var cover=document.all.do_submit_cover.style;
	//center the message box, hardcode to align the position
	//alert(document.body.scrollTop+"  " +document.body.scrollLeft+" "+document.body.offsetHeight+" "+document.body.offsetWidth);
    
	message.top=(document.body.scrollTop)+(document.body.offsetHeight/2)-65;
	message.left=(document.body.scrollLeft)+(document.body.offsetWidth/2)-115;
	message.visibility='visible';

	//resize the image to cover the whole page
	//(preserve 3px to prevent page overflow)
	cover.height=document.body.scrollHeight-3;
	cover.width=document.body.scrollWidth;
	cover.visibility='visible';

	//override events to prevent further submit
	for(var i=0; i<f.length; i++){
		f.elements[i].onchange=function(){return false;};
		f.elements[i].onclick=function(){return false;};
	}

	//hidden all select menu to prevent overlap with message layer
	for(i=0;i<document.getElementsByTagName('SELECT').length;i++){
		obj=document.getElementsByTagName('SELECT')[i];
		if(!obj){
			continue;
		}	
		obj.style.visibility="hidden";
	}
	//disable all keyboard events(especially the tab key)
	document.body.onkeydown=function(){return false;};
	//show a wait cursor
	document.body.style.cursor ="wait";
	f.submit();
}

function opSubmit(op){
    document.stdform.op.value=op;
    doSubmit();
}

function setValidateRequired(s){
	lvValidateRequired=s;
}

function validateAll(){
	if(!lvValidateRequired){
		return true;
	}
	var lvf=LiveValidationForm.getInstance(document.stdform);
	if(!lvf.validateAll()){
		return false;
	}
	return true;
}

function popup(mylink){
    if (!window.focus)return true;
    var href;
    if (typeof(mylink) == 'string'){
       href=mylink;
    }else{
       href=mylink.href;
    }
    window.open(href,"","width=980,height=600,resizable=yes,scrollbars=yes");
    return false;
}

function getBrowserVersion(){
	var browser;
	var version;
	if(navigator.appName=='Microsoft Internet Explorer'){
		browser="IE";
		var re=new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if(re.exec(navigator.userAgent)!=null){
			version=parseFloat(RegExp.$1);
		}
	}else
	if(navigator.userAgent.indexOf("Firefox")>0){
		browser="FF";
	}
	return browser+version;
}

function closeWindow(){
	var bv=getBrowserVersion();
	if(bv=="IE6" || bv=="IE7" || bv=="IE8" || bv=="IE9"){
		window.opener=null; 
		window.open("","_self"); 
		window.close();
	}else{
		window.open("../common/opened.jsp","_self"); 
	}
}

function getEValue(name){
	var f=document.stdform;
	return f.elements[name].value;
}

function padZero(s){
	return (s<10)?"0"+s:s;
}

function getDateByString(s){
	var d=s.split("/");
	return new Date(d[2],d[1]-1,d[0]);
}