var ok = true;
var screenTyp = "main";
// determine if ie-version is lower than 5.5
var agt = navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3 = (is_ie && (is_major < 4));
var is_ie4 = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0") != -1) );
var is_old_ie = (is_ie && (is_ie3 || is_ie4 || is_ie5));
function doSubmit(form, cmd, screenId){
document.forms[form].method = "post";
document.forms[form].action = "/b2b/"+cmd+".do?sp_screenId="+screenId;
document.forms[form].submit();
}
function doSubmit(form, cmd, screenId, doDoi) {
alert('action: '+document.forms[form].action);
if (ok) {
document.forms[form].method = "post";
document.forms[form].action = "/b2b/"+cmd+".do?sp_screenId="+screenId;
document.forms[form].submit();
ok=false;
if (!is_old_ie && doDoi) {
doi();
}
}
}
function DoLinkSubmit(form, uri) {
if (ok) {
document.forms[form].method = "post";
document.forms[form].action = uri;
document.forms[form].submit();
ok=false;
if (!is_old_ie) {
doi();
}
}
}
function DoReset(form) {
document.forms[form].reset();
}
function docheckForm(form, cmd, screenId)
{
var position = 0;
while(document.forms[form].elements[position] != null)
{
if (document.forms[form].elements[position].req == "true")
{
if (document.forms[form].elements[position].value == "")
{
document.forms[form].elements[position].focus();
return;
}
}
position++;
}
doSubmit(form, cmd, screenId)
}
function updateStatusBar(screenId, dispName) {
parent.topFrame.showText("<a href=\"" + screenId + "\" target=\"mainFrame\" class=\"content-link\">&nbsp;&rarr;" + dispName+ "</a>");
}

// javascript methods to show/hide wait dialog for Ajax calls
var waitDialogShown = false;
var useTimerBeforeShowWaitDialog = true;
var waitDialogTimeout = 50;
var waitDialogTimer;
var waitManualControl = false;
 
function showWaitDialog() {
    //avoid attempt to show it if it is already shown
	if (!waitDialogShown) {
		Richfaces.showModalPanel('wait-dialog');
		waitDialogShown = true;
	}
}

function hideWaitDialog() {
	if (waitDialogShown) {
		Richfaces.hideModalPanel('wait-dialog');
		waitDialogShown = false;
	} else if (useTimerBeforeShowWaitDialog && waitDialogTimer) {
		clearTimeout(waitDialogTimer);
	}
}
 
function onRequestStart() {
		if (!waitManualControl) {
	    if (useTimerBeforeShowWaitDialog) {
	        waitDialogTimer = setTimeout("showWaitDialog();", waitDialogTimeout);
	    } else {
	        showWaitDialog();
	    }
	  }
}

function onRequestEnd() {
	if (!waitManualControl) {
		hideWaitDialog();
	}		
}

