function getForm(fieldName)
{
	var forms = document["forms"]

    if (forms.length == 1)
        return forms[0]

    for (var i=0; i<forms.length; i++)
    {
        var form = forms[i]

        if (typeof(form[fieldName]) != "undefined")
			return form
    }

    return forms[0]
}

// Popup a help window
function help(helpFile, lang)
{

    if (helpFile.indexOf('html') > 0)
        url = aux+lang+'/help/'+helpFile
    else
        url = helpFile

    hw = window.open(url ,'help', 'toolbar=yes,scrollbars=yes,width=500,height=600,resizable=yes,status=no,menubar=no')
    hw.focus()
    return false;
}
var isClickedOnSearchWidget = false;
function startWaitScreen()
{
	set_display("mainScreen", false)
    set_display("waitScreen", true)
    if(document.getElementById("waitFullMessage")!= null)
    {
    	if(!isClickedOnSearchWidget)
		{
			document.getElementById("searchWidgetWaitFullMessage").innerHTML ="";
			set_display("searchWidgetWaitFullMessage", false);
			set_display("waitFullMessage", true);
			
		}	
		else
		{
			document.getElementById("waitFullMessage").innerHTML ="";
			set_display("searchWidgetWaitFullMessage", true);
			set_display("waitFullMessage", false);
		}
	}
	eval(onwait)
	window.scrollTo(0, 0)
    setTimeout("waitAnimate()", 1)
}

function popupServlet(servlet, width, height)
{
	var pos = servlet.indexOf("?")
	var wnd = (pos > 0) ? wnd=servlet.substring(0, pos) : wnd = servlet

    pos = wnd.indexOf("/consumer")
    if (pos > 0)
        wnd = wnd.substring(0, pos)

    alert(servlet)
    alert(wnd)


	if (!width)
		width = "510"

	if (!height)
		height = "310"

	wnd = open(servlet,wnd)
	wnd = open(servlet,wnd,"toolbar=no,scrollbars=yes,resizable=yes,status=no,menubar=no,width=" +
                width + ",height=" + height)
	wnd.focus()
}

function redirectTo(newPage)
{
	var form = getForm("redirect")
	form.redirect.value=newPage;
	form.submit();
}

function onContinue(isNS4, waitPage, formName)
{
	if (isNS4 == true)
	{
		document.forms[formName].action=waitPage;
		document.forms[formName].submit();
	}
	else
	{
		startWaitScreen();
	}

    return true
}

function setURL(loc, isSecured)
{
  if (loc.indexOf("http:") == 0)
    url = loc
  else
  {
    if (isSecured)
      url = base_sec + loc
     else
      url = base_nosec + loc
    if (loc.indexOf('?') >= 0)
      url += '&'
     else
      url += '?'
     url += "DD="+dd
  }
  document.location=url;
}

function enterTipField(fld, tipText, normalColor)
{
  if (fld.value == tipText)
  {
    fld.value = ''
    if (fld.style)
	    fld.style.color = normalColor
  }
}

function exitTipField(fld, tipText, ignoreColor)
{
  if (fld.value == "")
  {
    fld.value = tipText
    if (fld.style)
	    fld.style.color = ignoreColor
  }
}

function setTipField(fld, tipText, normalColor, ignoreColor)
{
  if (fld.value == tipText || fld.value == "")
  {
    fld.value = tipText
    if (fld.style)
    	fld.style.color = ignoreColor
  }
  else
    if (fld.style)
	    fld.style.color = normalColor
}
