ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
ns6 = (navigator.vendor == ("Netscape6") || navigator.product == ("Gecko"))? true:false;
ns61=(ns6 && parseInt(navigator.productSub)>=20010710)? 1:0;
ns60=(ns6 && parseInt(navigator.productSub) < 20010710)?1:0;
var defaultText = "Click here to type your interest, question or error message";
var cflag = 0;

function answerLinksQuestion(theLinksForm, theCaptureStateElement, questionId, answerValue)
{
    //fillInDialogState(theLinksForm);
    if(ie4){
        CaptureState(theCaptureStateElement);
    }
    theLinksForm.id.value= questionId;
    theLinksForm.answerValue.value=answerValue;
    return true;
    //return theLinksForm.submit();
}

function isblank(s) {
    for(var i=0; i<s.length; i++) {
        var c = s.charAt(i);
        if((c != ' ') && (c != '\n') && (c != '\t')) return false;
    }
    return true;
}

function verifySearchWithin(f) {
        searchString = f.text.value;
        if (searchString == null || searchString == "" || isblank(searchString) || searchString == 'Type your keywords here') {
        alert("Please enter your search within query in the text box")
        f.text.value = 'Type your keywords here';
        return false;
        }
        return true;
        //return fillInDialogState(f);
        if(ie4)CaptureState(document.all.invisibleDIV);
    }

function CaptureState(gHTMLElementStateInfo)
{
  var i,collDIV,strVisibleDIV="";
  collDIV=document.getElementsByTagName("DIV")

  for (i=0;i<collDIV.length;i++)
  {
      if (collDIV(i).style.display=="none")
      {
          if (strVisibleDIV.length!=0)
              strVisibleDIV=strVisibleDIV + "|";
          strVisibleDIV=strVisibleDIV + collDIV(i).id
      }
  }
  gHTMLElementStateInfo.value=strVisibleDIV;

  if(document.all.invisiblespans)
  {
    document.all.invisiblespans.value = currentVisible;
  }
}

function open_console(ref_url, name) {
    h=window.open(ref_url, name, 'toolbar=no,height=480,width=800,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no');
    h.focus();
}

function popup(ref_url, name, height, width) {
    h=window.open(ref_url, name, "toolbar=no,height=" + height + ",width=" + width + ",directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no");
    h.focus();
    return h;
}

function popupWToolbar(ref_url, name, height, width) {
    h=window.open(ref_url, name, "toolbar=yes,height=" + height + ",width=" + width + ",directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no");
    h.focus();
    return h;
}

function openwindow(ref_url, name, height, width) {
    h=window.open(ref_url, name, "toolbar=no,height=" + height + ",width=" + width + ",directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no");
    h.focus();
}

function verifyDelete(workflowID)
{
    if(window.confirm('Are you sure you want to delete this document?'))
    {
      return true;
    }
    return false;
}

<!--
    function showArea(id)
    {
      document.all[id + "_hidden"].style.display = "none";
      document.all[id + "_shown"].style.display = "block";
    }

    function hideArea(id)
    {
      document.all[id + "_shown"].style.display = "none";
      document.all[id + "_hidden"].style.display = "block";
    }

    function popupSmall(page, name)
    {
      window.open(page, name, 'toolbar=no,height=400,width=300,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no');
    }

    function popupTemplates(page, name)
    {
      window.open(page, name, 'toolbar=no,height=460,width=325,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no');
    }

    function popupLarge(page, name)
    {
      window.open(page, name, 'toolbar=no,height=800,width=800,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no');
    }
//-->

var selectedRange;
var selectedInputArea;

function storeCaret (textEl)
{
	if (textEl.createTextRange) {
    	     selectedRange = document.selection.createRange().duplicate();
	     selectedInputArea = textEl;
	}	
}
function insertAtCaret (textEl, text) {
	  if (selectedInputArea != textEl){
	  	textEl.value = text;
	  	return;
	  }
	  
      if (textEl.createTextRange && selectedRange) {
         var caretPos = selectedRange;
         caretPos.text =
           caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
             text + ' ' : text;
      }
      else
      	textEl.value  = text;
}

function viewAttachment(id, contentType)
{
    openwindow('viewattachment.do?id=' + id + '&contentType=' + contentType, '', 480, 640);
}



       function OpenModal (theURL, theName, pWidth, pHeight, pOther){ //theName is used for Netscape
        var theParam;
           if (window.showModalDialog) {
               // IE
            theParam = 'dialogHeight:'+pHeight+'px; dialogWidth:'+pWidth+'px; status:no; center:yes; resizable:yes; scroll:yes; help:no;';
    	    // the window object of the caller is passed as the second argument of the showModalDialog() method, so the dialogArguments property in the new window (the dialog box) reflects the caller's window object.
    		win = window.showModalDialog(theURL, window, theParam); //theName is replaced with the window object window
            return win;
        } else {
               // Firefox
            // this is mainly for Nescape (opens a window in the middle of the screen)
    		// add the following to the body tag of the pop-up window: onload="focus();"
        }
    }
       function showQuestion3Actions(text,btn1,btn2,btn3,action1,action2,action3,def,cx,cy, path)
       {
		text = encodeURIComponent( text );	       
        var url=(path ? path : "") + "question3b.jsp?text=" + text +
      		"&action1=" + action1 + "&action2=" + action2 + "&action3=" + action3 +
      		"&name1=" + btn1 + "&name2=" + btn2 + "&name3=" + btn3 +
      		"&default=" + def;
        if( !cx ) cx = 360;
        if( !cy ) cy = 180;
        return OpenModal(url,"", cx,cy, "");
      }

function showQuestion2Actions(text,btn1,btn2,action1,action2,def,cx,cy, path){
  text = encodeURIComponent( text );	
  var url=(path ? path : "") + "question2b.jsp?text=" + text +
		"&action1=" + action1 + "&action2=" + action2 +
		"&name1=" + btn1 + "&name2=" + btn2 +
		"&default=" + def;
  if( !cx ) cx = 360;
  if( !cy ) cy = 180;
  return OpenModal(url,"", cx,cy);
}


var startChar = "[:A-Z_a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|" +
"[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]";
var nameChar = startChar + "|" + "[\\-.0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040]";
// this is not supported by java script:[\u10000-\uEFFFF]";
function isValidXmlName(str) {
	var re = new RegExp("^((" + startChar + ")(" + nameChar + ")*)$");
	return re.test(str);
}

