function popupURL(url)
{w = open(url,"winLov","Scrollbars=1,resizable=1,width=800,height=600");
if (w.opener == null)
w.opener = self;
w.focus();}


// similar to lpad (str, 2, '0')
function LZ(x) {
    return(x<0||x>9?x:"0"+x);
 }

// this function will return the name of an element
//  given a starting element and an offset
function whichElement ( pForm, pElement, pOffset )

{
  n = parseInt(pElement.substring(3,pElement.length),10);
  m = n + parseInt(pOffset,10);  
  return  eval("document." + pForm + ".p_t" + LZ(m));
}

function nullFields(event, pField1, pField2, pField3) {
    var code = 0;
    code = event.keyCode;
    if (code > 45 && code < 106 || code == 8) {
      if (pField1) {
         pField1.value = "";
      }
      if (pField1) {
          pField2.value = "";
      }
      if (pField3) {
          pField3.value = "";
      }

    }
}

//
// generic URL popup
//
function popUp(URL) {
 day = new Date();
 id = day.getTime();
 eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=600');");
 }

function popUp2(URL,width,height) {
 day = new Date();
 id = day.getTime();
 eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='+width+',height='+height);");
 }




//
// used for custom popup of condition types
//
function callConditionsPopup(s1, sessionId) {
     var url =
 'f?p=4000:271:' + sessionId + ':::271:PASSBACK:' + s1.name;
     popUp (url);
 }

//
// used for custom popup of page template preview
//
function callPageTemplatePopup(s1, sessionId, flowId, pageId) {
     var url =
 'f?p=4000:74:' + sessionId + ':::74:F4000_P74_PASSBACK,F4000_P74_FLOW_ID,F4000_P74_PAGE_ID:'
 + s1.name + ',' + flowId + ',' + pageId;
     popUp (url);
 } 

function redirect( where )
{
  location.href=where;
}

function selectAll(fromList)
{
 for ( i = 0; i <= fromList.length-1; i++ )
  fromList.options[i].selected = false;
 for ( i = 0; i <= fromList.length-1; i++ )
  fromList.options[i].selected = true;
 return true;
}

function upperMe(obj){
   obj.value = obj.toUpperCase();
}


function disableItems(testString,item1,item2,item3,item4,item5,item6,item7,item8,item9,item10){
    theTest = eval(testString);
    
    if(theTest){
        for(var i=1;i<12;i++){
            if (arguments[i]){
                disItem = document.getElementById(arguments[i]);
                disItem.style.background = '#cccccc';
                disItem.disabled = true;
                }
            }
        }
    else{
        for(var i=1;i<12;i++){
            if (arguments[i]){
                disItem = document.getElementById(arguments[i]);
                disItem.disabled = false;
                disItem.style.background = '';
                }
            }
    }
}     

function setValue(id,val){
    obj = document.getElementById(id);
    obj.value = val;
}

//  errorMsg = the message returned if the value is not avilible.
function setValue2(id,val,errorMsg){
        obj = document.getElementById(id);     
        obj.value = val;
        if (obj.value != val)
            alert(errorMsg);
}
 
/* sfHover = function() {
 var sfEls = document.getElementById("nav").getElementsByTagName("LI");
 for (var i=0; i<sfEls.length; i++) {
  sfEls[i].onmouseover=function() {
   this.className+=" sfhover";
  }
  sfEls[i].onmouseout=function() {
   this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
  }
 }
}
if (window.attachEvent) window.attachEvent("onload", sfHover); */

