/*htmld_elements will contain the lower level html access js*/

var gDebug = true;
var gkeyPressTime;
var gLastTab=false;
var gRegex=false;
if(document.all){document.expando = true;}
// Elements //

function cDebug(pThis,pThat){null;}


function $x(pNd){
  try{
    var node;
    switch(typeof (pNd)){
      case 'string':node = document.getElementById(pNd); break;
      case 'object':node = pNd; break;
      default:node = false; break;
    }
    return node;
  }catch(e){return false;}
}
/*dep*/function html_GetElement(pNd){return $x(pNd);}

function $x_Hide(pNd){

	if(pNd.constructor == Array){
		for(var i=0;i<pNd.length;i++){

			if (node && node.nodeType == 1) {node.style.display = "none"};
		}
		return pNd;
	}else{
		var node = $x(pNd);
			if (node && node.nodeType == 1) {node.style.display = "none"};
		return node;
	}
}
/*dep*/function html_HideElement(pNd){return $x_Hide(pNd)}



function $x_Show(pNd){
	if(pNd.constructor == Array){
		for(var i=0;i<pNd.length;i++){
			var node = $x(pNd[i]);
			if (node && node.nodeType == 1) {node.style.display = ""};
		}
		return pNd;
	}else{
		var node = $x(pNd);
			if (node && node.nodeType == 1) {node.style.display = ""};
		return node;
	}
}
/*dep*/function html_ShowElement(pNd){return $x_Show(pNd)}

function html_VisibleElement(pNd){
  var l_Node = $x(pNd);
  if(l_Node){l_Node.style.visibility = "visible";}
  return l_Node;
}

function html_HiddenElement(pNd){
  var l_Node = $x(pNd);
  if(l_Node){l_Node.style.visibility = "hidden";}
  return l_Node;
}

function $x_Toggle(pNd){
	if(pNd.constructor == Array){
		for(var i=0;i<pNd.length;i++){
			var node = $x(pNd[i]);
			if (node && node.nodeType == 1) {
				if(node.style.display == "none"){$x_Show(node)}
				else{$x_Hide(node)}
			}
		}
		return pNd;
	}else{
		var node = $x(pNd);
			if (node && node.nodeType == 1) {
			if(node.style.display == "none"){$x_Show(node)}
			else{$x_Hide(node)}
		}
		return node;
	}
}
/*dep*/function html_ToggleElement(pNd){return $x_Toggle(pNd);}


//$v functions work with form values
// moving / checking / returning

function $v_PopupReturn(pThis,pThat){
 opener.$x(pThat).value = $x(pThis).value;
 window.close();
}


function html_HideItemRow(pNd){
	if(pNd.constructor == Array){
		for(var i=0;i<pNd.length;i++){
			var node = $x(pNd[i]);
			var lTr = $x_UpTill(node,'TR');
			$x_Hide(lTr);
		}
		return;
	}else{
		var node = $x(pNd);
		var lTr = $x_UpTill(node,'TR');
		$x_Hide(lTr);
		return;
	}
}

function html_ShowItemRow(pNd){
	if(pNd.constructor == Array){
		for(var i=0;i<pNd.length;i++){
			var node = $x(pNd[i]);
			var lTr = $x_UpTill(node,'TR');
			$x_Show(lTr);
		}
		return;
	}else{
		var node = $x(pNd);
		var lTr = $x_UpTill(pNd,'TR');
		$x_Show(lTr);
		return;
	}
}

function html_ToggleItemRow(pNd){
	if(pNd.constructor == Array){
		for(var i=0;i<pNd.length;i++){
			var node = $x(pNd[i]);
			var lTr = $x_UpTill(node,'TR');
			$x_Toggle(lTr);
		}
		return;
	}else{
		var node = $x(pNd);
		var lTr = $x_UpTill(pNd,'TR');
		$x_Toggle(lTr);
		return;
	}
}

 function html_GetTarget(e){
 	var targ;
  var lEvt;
	if (!e) {e = window.event;}
	  if (e.target){targ = e.target;}
    else if(e.srcElement){targ = e.srcElement;
  }
	if (targ.nodeType == 3){targ = targ.parentNode;}// defeat Safari bug
  return targ;  
 }

function html_HideSiblings(pNd){
  var l_Node = $x(pNd);
   if(l_Node){
   var l_NodeSibs = l_Node.parentNode.childNodes;
   
   for(var i=0,l=l_NodeSibs.length;i<l;i++){
    if(l_NodeSibs[i] && l_NodeSibs[i].nodeType == 1){$x_Hide(l_NodeSibs[i]);}}}
    $x_Toggle(l_Node)
  return l_Node;
}

function html_ShowSiblings(pNd){
   var node = $x(pNd);
   if(node){
    var l_NodeSibs = node.parentNode.childNodes;
    for(var i=0,l=l_NodeSibs.length;i<l;i++){if(l_NodeSibs[i] && l_NodeSibs[i].nodeType == 1){
      $x_Show(l_NodeSibs[i]);}}
    }
  return node;
}

function $x_UpTill(pThis,pToTag,pToClass,pCount){
	var node = $x(pThis);
 if ( node) {
	var tPar = node.parentNode;
  if(pToClass){
    while(tPar.nodeName != pToTag && tPar.className != pToClass){
  	  tPar = tPar.parentNode;
    }
  }else{
    while(tPar.nodeName != pToTag){
  	  tPar = tPar.parentNode;
    }
  }
 return tPar;
 } else {
  return null;
 }
 }
function html_CascadeUpTill(pThis,pToTag,pToClass,pCount){return $x_UpTill(pThis,pToTag,pToClass,pCount);}



var gToggleWithImageA = 'pseudoButtonActive';
var gToggleWithImageI = 'pseudoButtonInactive';

function htmldb_ToggleWithImage(pThis,pNd){htmldb_ToggleTableBody(pThis,pNd)}
function htmldb_ToggleTableBody(pThis,pNd){
    pThis = $x(pThis);
    if(html_CheckImageSrc(pThis,'plus')){
     pThis.className = gToggleWithImageI;
     pThis.src = html_replace(pThis.src,'plus','minus');
    }else{
     pThis.className = gToggleWithImageA;
     pThis.src = html_replace(pThis.src,'minus','plus');
    }
    var node = $x_Toggle(pNd);
    return;
}

function findPosX(obj){
 obj = $x(obj);
   var leftOff = 0;
   var curleft = 0;
   if (obj.x) {
     return obj.x;
   } else if (obj.offsetParent) {
     while (obj.offsetParent){
       if ( obj.style.left )  {
          curleft += parseInt(obj.style.left.substring(0,obj.style.left.length-2));
          return curleft;
       }else {
          curleft += obj.offsetLeft
       }
       obj = obj.offsetParent;
     }
   } 
   return curleft;
}

function findPosY(obj){
   obj = $x(obj);
   var curtop = 0;
   if (obj.y){
     return obj.y;
   } else if (obj.offsetParent) {
     while (obj.offsetParent){
       if ( obj.style.top )  {
          curtop += parseInt(obj.style.top.substring(0,obj.style.top.length-2));
          return curtop;
       }else {
          curtop += obj.offsetTop
       }
       obj = obj.offsetParent;
     }
   }
   return curtop;
}

function html_SwitchImageSrc(pId,pSearch,pReplace){
  var htmlEl = $x(pId);
  if(htmlEl && htmlEl.nodeName == "IMG"){
    if(htmlEl.src.indexOf(pSearch) != -1){htmlEl.src = pReplace;}
  }
 return htmlEl;
}

function html_CheckImageSrc(pId,pSearch){
  var htmlEl = $x(pId);
  var lReturn = false;
  if(htmlEl && htmlEl.nodeName == "IMG"){
    if(htmlEl.src.indexOf(pSearch) != -1){lReturn = true;}
  }
 return lReturn;
}

function html_RemoveAllChildren(pThis) {
	var node = $x(pThis);
	if (node && node.hasChildNodes && node.removeChild) {
		while (node.hasChildNodes()){
			node.removeChild(node.firstChild);
		}
	}
} 

function html_SubString(pText,pMatch){
  var lReturn = false;
  if(pText && pMatch){if(pText.toString().indexOf(pMatch.toString()) != -1){lReturn = true;}}
 return lReturn;
}

function html_replace(string,text,by) {
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;
    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;
    var newstr = string.substring(0,i) + by;
    if (i+txtLength < strLength)newstr += html_replace(string.substring(i+txtLength,strLength),text,by);
    return newstr;

}

function html_GetPageScroll(){
  pageScroll = document.body.scrollTop;
  return pageScroll;
}

function html_Find(pThis,pString,pTags,pClass){
    if (!pTags){pTags = 'DIV'}
    pThis = $x(pThis);
    if(pThis){
    var d=pThis.getElementsByTagName(pTags);
    pThis.style.display="none";
    if ( ! gRegex  ) 
         gRegex =new RegExp("test");
    gRegex.compile(pString,"i");
    var start = new Date();
    for(var i=0,len=d.length ;i<len;i++){
          if (gRegex.test(d[i].innerHTML)){
            d[i].style.display="block";
          }else{
            d[i].style.display="none";}
     }
    pThis.style.display="block";
    }
  return;
}

function html_disableItems(a,nd){
  if(nd){
    for (var i=1;i <= arguments.length; i++){html_disableItem(arguments[i],a)}
  }
  return;
}

function html_disableItem(nd,a){
    var lEl = $x(nd);
    if (lEl && lEl != false){
	  if(a){
      lEl.disabled = true;
      lEl.style.background = '#cccccc';
    }else{
      lEl.disabled = false;
      lEl.style.background = '#ffffff';
     }
	}
	return true;
} 

function html_InitTextFieldSubmits(){
 var docI = document.getElementsByTagName('INPUT');
 for(var i=0;i<docI.length;i++){
 if(docI[i].type == "text"){docI[i].onkeypress = html_submitFormFromKeyPress;}
 }
}

function html_submitFormFromKeyPress(key) {
   if ( event.keyCode == "13" )  {
       var form =  html_cascadeUpTillTag("FORM");
         if(form){form.submit()}
     }
}

function html_TabClick(pThis , pId){
    var lTab = $x(pId);
    var lParent = lTab.parentNode;
    html_HideSiblings(lTab);
    html_TabMakeCurrent(pThis);
    return;
}


function html_TabMakeCurrent(pThis){
   var node = $x(pThis);
   if(node){
    var nodeSibs = node.parentNode.parentNode.childNodes;
    for(var i=0;i < nodeSibs.length;i++){
      if(nodeSibs[i] && nodeSibs[i].nodeType == 1 && nodeSibs[i].getElementsByTagName('A')[0]){
        nodeSibs[i].getElementsByTagName('A')[0].className = "";}
      }
    pThis.className = "tabcurrent";
    }
  return node;
}

function html_ShowLov(s){
    if(lovUI){
        lovUI.innerHTML = s;
        $x_Show(lovUI);
        lovUI.scrollIntoView(false);
    }
    return;
}


var returnInput = null;
var returnDisplay = null;

function setReturn(return_id,display_id){
    if(return_id){returnInput = $x(return_id);}
    if(display_id){returnDisplay = $x(display_id);}
    return;
}

function html_Return_Form_Items(pThis,pType){
 var l_This = $x(pThis);
 var l_Inputs = new Array();
 var l_Array = new Array();
 l_Selects = l_This.getElementsByTagName('SELECT');
 l_Textarea = l_This.getElementsByTagName('TEXTAREA');
 l_Inputs = l_This.getElementsByTagName('INPUT');
 
 if(pType && pType.toUpperCase() == 'SELECT'){
  l_Inputs = l_Selects;
  pType = false;
 }
 else if(pType && pType.toUpperCase() == 'TEXTAREA'){
  l_Inputs = l_Textarea;
  pType = false;
 }
 else if (pType && pType.toUpperCase() == 'ALL'){
 l_Inputs = l_Inputs.concat(l_Textarea);
 l_Inputs = l_Inputs.concat(l_Selects);
 }
 else {
  l_Inputs = l_This.getElementsByTagName('INPUT');
 }
 for (var i=0;i<l_Inputs.length;i++){
  if(pType && (pType.toUpperCase() == 'ALL')){
    l_Array[l_Array.length] = l_Inputs[i];
  }
  else if(pType && (l_Inputs[i].type.toUpperCase()==pType.toUpperCase())){
    l_Array[l_Array.length] = l_Inputs[i];
  }else{
    l_Array[l_Array.length] = l_Inputs[i];
  }
 }
return l_Array;
}

function html_CheckAll(pThis,pCheck,pArray){
  if(pArray){l_Inputs = pArray;}
  else{var l_Inputs = html_Return_Form_Items(pThis,'checkbox');}
  for (var i=0,l=l_Inputs.length;i<l;i++){
    l_Inputs[i].checked = pCheck;
  }
  return;
}

function detailTab(id){
 html_TabClick(id)
 return;
}


function html_CreateFormElement(pType,pName,pValue){
 var lEl =   document.createElement('<input type="'+pType+'" name="'+ pName +'" value="'+ pValue +'" />');
 return lEl;
}

function html_StringReplace(string,text,by) {
      if(!by){by = ''}
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) {return string;}
    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) {return string;}
    if (i == -1) {return string;}
    var newstr = string.substring(0,i) + by;
    if (i+txtLength < strLength){
        newstr += html_StringReplace(string.substring(i+txtLength,strLength),text,by);
                }
    return newstr;
}

function html_HideHolderDiv(){
    var tRow = html_cascadeUpTillTag("DIV");
    html_ToggleVis(tRow);
    if(tId){tId = null;}
  return;
}

function formHasValue(what) {
    var result = false;
    var output = '';
    for (var i=0, j=what.elements.length; i<j; i++) {
        myType = what.elements[i].type;
        /*if (myType == 'checkbox' || myType == 'radio') {
            if (what.elements[i].checked && what.elements[i].defaultChecked) {
                output += what.elements[i].name + ' is still checked' + '\n';
                result = false
            }
        }*/
        //if (myType == 'hidden' || myType == 'password' || myType == 'text' || myType == 'textarea') {
                if (myType == 'text' || myType == 'textarea') {
            if (what.elements[i].value != '') 
                        {result = true;
                        }
                        
        }
        if (myType == 'select-one' || myType == 'select-multiple') {
                        if(what.elements[i].selectedIndex != 0 && what.elements[i].options[what.elements[i].selectedIndex].value!=''){
                                result = true;
                            }
        }
    }
    return result;
}

function html_GoToRelative(nURL){
 var urlP = location.pathname.substring(0,location.pathname.lastIndexOf('/')); 
 document.location = urlP+"/"+nURL;
 return;
}

function html_toggleNextCell(){
 var tCell = html_cascadeUpTillTag('TD');
 tCell = tCell.nextSibling
 html_ToggleVis(tCell);
 return tCell;
}

function html_ResetSelect(tCell){
 var l_Node = $x(tCell);
 if(l_Node.nodeName == 'SELECT'){
 var tSelects = l_Node;
 }else{
 var tSelects = tCell.getElementsByTagName('select')[0];
 }
 tSelects.selectedIndex = 0;
 return;
}

function html_PageTable(table,start,end){
        var tTable = $x(table);
        if(!start){start = 1}
        if(!end){end=25}
        for(var i=0;i<tTable.rows.length;i++){
         if(i>=!start && i<=end){
                $x_Show(tTable.rows[i])
         }else{
           $x_Hide(tTable.rows[i])
         }
        }
}

var gDebugWindow = false;


function timestamp(){
   var d, s = "T:";
   var c = ":";
   d = new Date();
   s += d.getHours() + c;
   s += d.getMinutes() + c;
   s += d.getSeconds() + c;
   s += d.getMilliseconds();
   return(s);
}

var dbaseTime1 = null;
var dbaseTime2 = null;

function timeC(t){
if(dbaseTime1){
  dbaseTime2 = new Date();
  dbaseTime1 = null;
  dbaseTime2 = null;
}else{
  dbaseTime1 = new Date();
}
}

function html_MakeParent(p_Node,p_Parent){
  var l_Node = $x(p_Node);
  var l_Parent = $x(p_Parent);
  if(l_Node.parentNode != l_Parent){l_Parent.appendChild(l_Node)}
  return l_Node;
}

var gCurrentRow = false;
function html_RowHighlight(pThis,pColor){
  var l_Cells = pThis.getElementsByTagName('TD');
  for (var i=0,l=l_Cells.length;i<l;i++){
    l_Cells[i].style.backgroundColor = pColor;
  }
  gCurrentCells = pThis;
  return;
}

function html_RowHighlightOff(pThis,pColor){
  var l_Cells = pThis.getElementsByTagName('TD');
  for (var i=0,l=l_Cells.length;i<l;i++){
    l_Cells[i].style.backgroundColor = '';
  }
}

function html_Allow_Copy(e){
  l_return = false;
  var keyCode = document.layers ? evt.which :document.all ? event.keyCode :document.getElementById ? e.keyCode : 0; 
  if (e.ctrlKey && keyCode == "c"){l_return = true}
  return l_return
}

function html_SelectValue(pId){
 var lSelect = $x(pId);
 if(lSelect.nodeName == 'SELECT'){
  return lSelect.options[lSelect.selectedIndex].value;
 }
}

function html_SetSelectValue(pId,pValue){
 var lSelect = $x(pId);
 if(lSelect.nodeName == 'SELECT'){
  lSelect.selectedIndex = 0;
  
  for(var i=0,l=lSelect.options.length;i<l;i++){
    if(lSelect.options[i].value == pValue){lSelect.options[i].selected=true;};
  }
 }
}

function html_RadioValue(pId){
 var lReturn = false;
 var lSelect = html_Return_Form_Items(pId,'RADIO');
 var l=lSelect.length
   for(var i=0;i<l;i++){
   if(lSelect[i].checked){
    lReturn=lSelect[i].value;
   }
 }
 return lReturn;
}

function html_ReturnToTextSelection(pText,pThis){ 
 if (document.selection){//IE support for inserting HTML into textarea
   var cmd = $x(pThis);
   cmd.focus();
   var sel = document.selection;
   var rng = sel.createRange();
   rng.text = rng.text + ' ' + pText;
 }else{ // Mozilla/Netscape support for selecting textarea
  cmd = $x(pThis);
  start = cmd.selectionStart;
  end = cmd.selectionEnd;
  cmd.value = cmd.value.slice(0,start) +' ' + pText + cmd.value.slice(end,cmd.value.length);  
  cmd.focus();
  setCaretToPos (cmd, end +(pText.length + 2));
 }
}

function setSelectionRange(input, selectionStart, selectionEnd) {
  if (input.setSelectionRange) {
    input.focus();
    input.setSelectionRange(selectionStart, selectionEnd);
  }
  else if (input.createTextRange) {
    var range = input.createTextRange();
    range.collapse(true);
    range.moveEnd('character', selectionEnd);
    range.moveStart('character', selectionStart);
    range.select();
  }
}

function setCaretToEnd (input) {
  setSelectionRange(input, input.value.length, input.value.length);
}

function setCaretToBegin (input) {
  setSelectionRange(input, 0, 0);
}

function setCaretToPos (input, pos) {
  setSelectionRange(input, pos, pos);
}

function selectString (input, string) {
  var match = new RegExp(string, "i").exec(input.value);
  if (match) {
    setSelectionRange (input, match.index, match.index + match
[0].length);
  }
}

 function ob_PPR_TAB(l_URL){
  top.gLastTab = l_URL;
  var lBody = document.body;
  var http = new htmldb_Get(lBody,null,null,null,null,'f',l_URL.substring(2));
  var temp = http.get(null,'<body  style="padding:10px;">','</body>');
  get = null;
  if(document.all){
    var ie_HACK = 'window.parent.obFrameSize()';
	setTimeout(ie_HACK,100);}
    else{window.parent.obFrameSize();}
 } 

/* FROM core.js*/
function flowSelectAll(){
	var theList;
	var lListLength;
	if (typeof(flowSelectArray)=="undefined"){return true;}
	else{
		for (a=0;a<flowSelectArray.length;a++){						
			 theList = $x(flowSelectArray[a]);
			 lListLength = theList.length;
			 for (var i = 0; i <= lListLength-1; i++ ){theList.options[i].selected = false;}
			 for (var i = 0; i <= lListLength-1; i++ ){theList.options[i].selected = true;}
		}
	}
 return true;
}

function redirect(where){
  location.href=where;
  return;
} // End redirect

function doSubmit(r){
	flowSelectAll();
	document.wwv_flow.p_request.value = r;
	document.wwv_flow.submit();
} // End doSubmit()

function first_field(field1){
try{
    	if($x(field1)){
    		var theField = $x(field1);
    		if((theField.type!="hidden")&&(!theField.disabled)){theField.focus();}
      }
	return true;
}catch(e){}
}

function charCount(tArea,maxNo,ctrField,maxField,ctrBlock,allowExtra){
	var textArea = $x(tArea);
	var ctrF	 = $x(ctrField);
	var maxF	 = $x(maxField);
	var ctrBlk   = $x(ctrBlock);
	var pctFull  = textArea.value.length / maxNo * 100;
	if (allowExtra != 'Y')
		{if (textArea.value.length >= maxNo)
			{textArea.value = textArea.value.substring(0, maxNo);
			 textArea.style.color = 'red';
			}
		 else
			{msg = null;
			 textArea.style.color = 'black';}
		}
	ctrF.innerHTML = textArea.value.length;
	maxF.innerHTML = maxNo;
	if (textArea.value.length > 0){
    ctrBlk.style.visibility = 'visible';
  }else{
    ctrBlk.style.visibility = 'hidden';
  }

	if (pctFull >= 90){
    ctrBlk.style.color='red';
  }else if (pctFull >= "80"){
    ctrBlk.style.color='#EAA914';
  }else{
    ctrBlk.style.color='black';
  }

} // End charCount()

function shuttleItem(theSource, theDest, moveAll) {
    srcList  = $x(theSource);
    destList = $x(theDest);
    var arrsrcList = new Array();
    var arrdestList = new Array();
    var arrLookup = new Array();
    var i;
    if (moveAll){
        for ( i = 0; i <= srcList.length-1; i++ )
			  srcList.options[i].selected = true;
    }
    for (i = 0; i < destList.options.length; i++) {
        arrLookup[destList.options[i].text] = destList.options[i].value;
        arrdestList[i] = destList.options[i].text;}
    var fLength = 0;
    var tLength = arrdestList.length;
    for(i = 0; i < srcList.options.length; i++) {
        arrLookup[srcList.options[i].text] = srcList.options[i].value;
        if (srcList.options[i].selected && srcList.options[i].value != "") {
            arrdestList[tLength] = srcList.options[i].text;
            tLength++;}
        else {
            arrsrcList[fLength] = srcList.options[i].text;
            fLength++;}
    }
    arrsrcList.sort();
    arrdestList.sort();
    srcList.length = 0;
    destList.length = 0;
    var c;
    for(c = 0; c < arrsrcList.length; c++) {
        var no = new Option();
        no.value = arrLookup[arrsrcList[c]];
        no.text = arrsrcList[c];
        srcList[c] = no;
    }
    for(c = 0; c < arrdestList.length; c++) {
        var no = new Option();
        no.value = arrLookup[arrdestList[c]];
        no.text = arrdestList[c];
        destList[c] = no;
       }
} // End shuttleItem()

var ie = (document.all) ? true : false;

function setStyleByClass(t,c,p,v){
	var elements;
	if(t == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (ie) ? document.all : document.getElementsByTagName('*');
	} else {
		elements = document.getElementsByTagName(t);
	}
	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == c) {
					eval('node.style.' + p + " = '" +v + "'");
				}
			}
		}
	}
}

function setClassByClass(t,c,p){
	var elements;
	if(t == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (ie) ? document.all : document.getElementsByTagName('*');
	} else {
		elements = document.getElementsByTagName(t);
	}
	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == c) {
					node.className = p ;
				}
			}
		}
	}
}

function setStyle(e,s,v){
    theItem = $x(e);
    eval('theItem.style.'+ s + " = '" + v + "'");
}

function confirmDelete(msg,req){
    if(req==null){req='Delete'}
    var confDel = msg;
    if(confDel ==null){
        confDel= confirm("Would you like to perform this delete action?");
    }else{
        confDel= confirm(msg);}
    
    if (confDel== true){
      doSubmit(req);}
}

function submitEnter(itemObj,e){
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (keycode == 13){
       doSubmit(itemObj.id);
      return false;
    }else{
       return true;
    }

}

function hideShow(objectID,imgID,showImg,hideImg){
    var theImg = $x(imgID);
    var theDiv = $x(objectID);
    if(theDiv.style.display == 'none' || theDiv.style.display == '' || theDiv.style == null){
        theImg.src = hideImg;
        $x(objectID).style.display = 'block';}
    else{
        theImg.src = showImg;
        $x(objectID).style.display = 'none';}
    return;
}

//Get a value from a cookie
function htmldbCheckCookie(pThis){
  SetCookie ('ISCOOKIE','true');
  flow = GetCookie ('ISCOOKIE');
  if(flow){}else{
   //doSubmit()
  }
  return
}

function getCookieVal (offset){
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));

   }
//Get a cookie and it's value
function GetCookie (name) 
   {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) 
      {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
         return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break; 
      }
   return null;
   }

//Set a cookie and it's value
function SetCookie (name, value) {
   var argv = SetCookie.arguments;
   var argc = SetCookie.arguments.length;
   var expires = (argc > 2) ? argv[2] : null;
   var path = (argc > 3) ? argv[3] : null;
   var domain = (argc > 4) ? argv[4] : null;
   var secure = (argc > 5) ? argv[5] : false;
   document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
   }

// Used for quick edit links
function quickLinks(what){
    if (what == 'HIDE'){  
        setClassByClass('a','eLinkOn','eLink');
        setClassByClass('img','eLinkOn','eLink');
				$x_Toggle('hideEdit');
				$x_Toggle('showEdit');
        SetCookie('MarvelQuickEdit',what);}
    else{
        setClassByClass('a','eLink','eLinkOn');
        setClassByClass('img','eLink','eLinkOn'); 
				$x_Toggle('hideEdit');
				$x_Toggle('showEdit');
        SetCookie('MarvelQuickEdit',what);}            
}

/* */
var htmldb_ch=false;  
function htmldb_item_change(e){htmldb_ch=true;}

function htmldb_doUpdate(r){
     if(htmldb_ch){
         lc_SetChange()
         doSubmit(r);
     }else{
         doSubmit(r);
     }  
     return;
 }

function htmldb_goSubmit(r){
  if(htmldb_ch){
		if (!htmldb_ch_message || htmldb_ch_message == null){htmldb_ch_message='Are you sure you want to leave this page without saving? /n Please use translatable string.';}
    if (window.confirm(htmldb_ch_message)){doSubmit(r);}
  }else{
    doSubmit(r);
  }
  return;      
} 

function html_PopUp(pURL,pName,pWidth,pHeight){
  if(!pURL){pURL = 'about:blank'}
  if(!pName){pName = 'Popup'}
  if(!pWidth){pWidth = 600}
  if(!pHeight){pHeight = 600}
  l_Window = window.open(pURL,pName, 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='+pWidth+',height='+pHeight);
  if (l_Window.opener == null){l_Window.opener = self;}
  l_Window.focus();
  return l_Window;
}

// used for custom popup of condition types
function callConditionsPopup(s1, sessionId) {
     var pURL = 'f?p=4000:271:' + sessionId + ':::271:PASSBACK:' + s1.name;
     html_PopUp(pURL,null,null,null);
 }

// used for custom popup of page template preview
function callPageTemplatePopup(s1, sessionId, flowId, pageId) {
     var pURL = 'f?p=4000:74:' + sessionId + ':::74:F4000_P74_PASSBACK,F4000_P74_FLOW_ID,F4000_P74_PAGE_ID:' + s1.name + ',' + flowId + ',' + pageId;
     html_PopUp(pURL,null,null,null);
 } 
 
function popupFieldHelp(curentItemId, sessionId, closeButtonName){
    var closeButton;
    if (closeButtonName){closeButton = '&p_close_button_name='+closeButtonName;}
    else{closeButton = '';}
    html_PopUp("wwv_flow_item_help.show_help?p_item_id=" + curentItemId + "&p_session=" + sessionId+closeButton,'Help',500,350);
    return;
}

// use for popups in which you want the page to close after delete
function confirmDelete2(msg,req){
    if(req==null){req='Delete'}
    var confDel = msg;
    if(confDel ==null){
        confDel= confirm("Would you like to perform this delete action?");}
    else{
        confDel= confirm(msg);}
    if (confDel== true){
        doSubmit(req);
        window.close();
     }
}

function popUpNamed(pURL,pName) {html_PopUp(pURL,pName,null,null)}
function popUp2(pURL,pWidth,pHeight) {day = new Date();pName = day.getTime();html_PopUp(pURL,pName,pWidth,pHeight);}
function popUp(pURL) {day = new Date();pName = day.getTime();html_PopUp(pURL,pName,null,null);}
function popupURL(pURL){html_PopUp(pURL,"winLov",800,600);}

/* End Popup Functionality */



// similar to lpad (str, 2, '0')
function LZ(x) {
    return(x<0||x>9?x:"0"+x);
 }

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 = "";}
    }
}


function selectAll(fromList){
     for(var i=0; i<=fromList.length-1;i++){
 		      fromList.options[i].selected = false;
		 }
 		 for(var i=0; i <= fromList.length-1; i++ ){
  	 		  fromList.options[i].selected = true;
		 }
 return true;
}

function upperMe(pId){
   var obj = $x(pId);
   if(obj){obj.value = obj.toUpperCase()}
}

function disableItems(testString,item1,item2,item3,item4,item5,item6,item7,item8,item9,item10){
    var theTest = eval(testString);
    var i = 1;
    if(theTest){
        for(i;i<12;i++){
            if (arguments[i]){
                disItem = $x(arguments[i]);
                disItem.style.background = '#cccccc';
                disItem.disabled = true;
                }
            }
        }
    else{
        for(i;i<12;i++){
            if (arguments[i]){
                disItem = $x(arguments[i]);
                disItem.disabled = false;
                disItem.style.background = '#ffffff';
                }
            }
    }
}     

function $f_SetValue(id,val){
    var obj = $x(id);
    if(obj){
      obj.value = val;
    }
}

function setValue(id,val){$f_SetValue(id,val)}
function lc_SetChange(){
   if (gChangeCheck){
   gChangeCheck.value = 1;
   gChangeCheck.type = 'text';
   }
}

//  errorMsg = the message returned if the value is not avilible.
function setValue2(id,val,errorMsg){
        obj = $x(id);
        if(obj){
          obj.value = val;
          if (obj.value != val){alert(errorMsg)}
        }
}
 
 
 /*Notes: complex elements dhtml library*/
/*Begin DHTML Menus*/
var gCurrentAppMenu = false;
var gCurrentAppMenuImage = false;
var gSubMenuArray = new Array();

/* close all submenus */
function dhtml_CloseAllSubMenus(pStart){
  var l_Start = null;
  if(!pStart){l_Start = 0}
  else{l_Start = pStart;}
  
  for (var i=l_Start;i<=gSubMenuArray.length;i++){
    if(gSubMenuArray[i]){
      var l_Sm = $x_Hide(gSubMenuArray[i]);
      if(l_Sm){$x_Hide(l_Sm)};
    }
  }
  /*if you deleted starting from level do not null out array*/
  if(!pStart){gSubMenuArray.length = 0}
  htmldb_IE_Select_Item_Fix(false)
  return;
}

/* close all submenus starting from level */
function dhtml_CloseAllSubMenusL(pThis){
  var l_Start = parseInt($x_UpTill(pThis,'UL').getAttribute("htmldb:listlevel"))+1;
  dhtml_CloseAllSubMenus(l_Start);
  return;
}

function dhtml_DocMenuCheck(e){
  var tPar = html_GetTarget(e);
  var l_Test = true;
    while(tPar.nodeName != 'BODY'){
  	  tPar = tPar.parentNode;
      if(html_SubString(tPar.className,'dhtmlMenuLG')){l_Test = !l_Test;}
    }
  if(l_Test){
    app_AppMenuMultiClose();
    dhtml_CloseAllSubMenus();
    document.onclick = null;
  }
  else{
  }
  return;
}

function dhtml_ButtonDropDown(pThis,pThat,pDir,pX,pY){
  //var lThis = $x_UpTill(pThis,'TABLE')//.cells[1];
  dhtml_SingeMenuOpen(pThis,pThat,'Bottom',pX,pY);
  return
}

function dhtml_MenuOpen(pThis,pThat,pSub,pDir){
    if($x(pThat)){
      document.onclick = dhtml_DocMenuCheck;
      if(!pSub){
        dhtml_CloseAllSubMenus();
        gCurrentAppMenu = pThat;
      }else{
        var l_Level = parseInt($x(pThat).getAttribute("htmldb:listlevel"));
        var l_Temp = gSubMenuArray[l_Level];
        if(l_Temp){$x_Hide(l_Temp);}
        gSubMenuArray[l_Level] = $x(pThat);
       }
        var lMenu = $x(pThat);
        document.body.appendChild(lMenu);
        if(!pDir || pDir == 'Right'){
          lMenu.style.position = "absolute"
          lMenu.style.top = parseInt(findPosY(pThis));
          lMenu.style.left = parseInt(findPosX(pThis));
        }else if(pDir == 'Bottom'){
          lMenu.style.position = "absolute"
          lMenu.style.top = parseInt(findPosY(pThis)) + parseInt(pThis.offsetHeight);
          lMenu.style.left = parseInt(findPosX(pThis));
        }else if(pDir == 'BottomRight'){
          lMenu.style.position = "absolute"
          lMenu.style.top = parseInt(findPosY(pThis)) + parseInt(pThis.offsetHeight);
          lMenu.style.left = parseInt(findPosX(pThis)) - parseInt(pThis.offsetWidth);
        }else{
          lMenu.style.position = "absolute"
          lMenu.style.top = parseInt(findPosY(pThis));
          lMenu.style.left = parseInt(findPosX(pThis)) + parseInt(pThis.offsetWidth);
        }
        $x_Show(lMenu);
        dhtml_FixLeft(pThis,lMenu)
        htmldb_IE_Select_Item_Fix(lMenu);
        }
      return
}

function dhtml_DocMenuSingleCheck(e,force){
  if(g_Single_Menu_Count > 0){
  if(e){
	var tPar = html_GetTarget(e)
	var l_Test = true;
    while(tPar.nodeName != 'BODY' && !force){
  	  tPar = tPar.parentNode;
      if(tPar == g_Single_Menu){
        l_Test = !l_Test;
      }
    }
	}
    if(l_Test || force){
      $x_Hide(g_Single_Menu);
      document.onclick = null;
    }else{}
  }else{
    g_Single_Menu_Count = 1
  }
  return;
}

var g_Single_Menu = false;
var g_Single_Menu_Count = 0;
function dhtml_SingeMenuOpen(pThis,pThat,pDir,pX,pY){
        var lMenu = $x(pThat);
        var lThis = $x(pThis);
        lMenu.style.zIndex = 2001;
        document.body.appendChild(lMenu);
        if(!pDir || pDir == 'Right'){
          lMenu.style.position = "absolute"
          lMenu.style.top = parseInt(findPosY(lThis));
          lMenu.style.left = parseInt(findPosX(lThis));
        }else if(pDir == 'Bottom'){
          lMenu.style.position = "absolute"
          lMenu.style.top = parseInt(findPosY(lThis)) + parseInt(lThis.offsetHeight);
          lMenu.style.left = parseInt(findPosX(lThis));
        }else if(pDir == 'BottomRight'){
          lMenu.style.position = "absolute"
          lMenu.style.top = parseInt(findPosY(lThis)) + parseInt(lThis.offsetHeight);
          lMenu.style.left = parseInt(findPosX(lThis)) - parseInt(lThis.offsetWidth);
        }else if(pDir == 'Set'){
          lMenu.style.position = "absolute"
          lMenu.style.top = parseInt(pY);
          lMenu.style.left = parseInt(pX);
        }else {
          lMenu.style.position = "absolute"
          lMenu.style.top = parseInt(findPosY(lThis));
          lMenu.style.left = parseInt(findPosX(lThis)) + parseInt(lThis.offsetWidth);
        }
        
      $x_Show(lMenu);
      dhtml_FixLeft(lThis,lMenu);
      htmldb_IE_Select_Item_Fix(true);
      g_Single_Menu_Count = 0;
      g_Single_Menu = lMenu;
      document.onclick = dhtml_DocMenuSingleCheck;
      return
}

function dhtml_FixLeft(pThis,pMenu){
     var l_Width;
     if(document.all){l_Width = document.body.clientWidth}
     else{l_Width = window.innerWidth}
        if(parseInt(l_Width) < parseInt(findPosX(pThis)) + parseInt(pThis.offsetWidth) + parseInt(pMenu.offsetWidth)){
          pMenu.style.position = "absolute"
          pMenu.style.left = (parseInt(findPosX(pThis)) - parseInt(pMenu.offsetWidth));
        }
    return
}

function htmldb_IE_Select_Item_Fix(pTest){
  /* only run in IE and only if there is a select in the page*/
  var lSel = document.getElementsByTagName('SELECT').length >= 1;
  if(document.all && pTest && lSel){
        if(pTest.firstChild && pTest.firstChild.nodeName != 'IFRAME'){
          pTest.innerHTML = '<iframe  src="'+htmldb_Img_Dir+'blank.html" width="'+pTest.offsetWidth+'" height="'+pTest.offsetHeight+'" style="z-index:-10;position: absolute;left: 0;top: 0;filter: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0);" scrolling="no" frameborder="0"></iframe>' + pTest.innerHTML;
        }
  } 
  return
}

/* this runs the the show hide with sideimages template*/
var g_dhtmlMenuOn = "dhtmlMenuOn";
function app_AppMenuMultiOpenBottom(pThis,pThat,pSub){
      var lMenu = $x(pThat);
      if(pThis != gCurrentAppMenuImage){
        app_AppMenuMultiClose();
        var l_That = pThis.previousSibling.firstChild ; 
        pThis.className = g_dhtmlMenuOn;
        dhtml_MenuOpen(l_That,pThat,false,'Bottom');
        gCurrentAppMenuImage = pThis;
      }else{
        dhtml_CloseAllSubMenus();
        app_AppMenuMultiClose();
      }
  return;
}


function app_AppMenuMultiOpenBottom2(pThis,pThat,pSub){
      var lMenu = $x(pThat);
      if(pThis != gCurrentAppMenuImage){
        app_AppMenuMultiClose();
        var l_That = pThis.parentNode; 
        pThis.className = g_dhtmlMenuOn;
        dhtml_MenuOpen(l_That,pThat,false,'Bottom');
        gCurrentAppMenuImage = pThis;
      }else{
        dhtml_CloseAllSubMenus();
        app_AppMenuMultiClose();
      }
  return;
}

/* this runs the the show hide with sideimages template*/
var g_dhtmlMenu = "dhtmlMenu";
function app_AppMenuMultiClose(){
  if(gCurrentAppMenu){
    var lMenu = $x(gCurrentAppMenu);
    gCurrentAppMenuImage.className = g_dhtmlMenu;
    $x_Hide(lMenu);
    gCurrentAppMenu = false;
    gCurrentAppMenuImage = false;
  }
  return;
}
/*End DHTML Menus*/

function html_CleanRegionId(pRid){
	var l_PTest = pRid.indexOf('.');
	var l_CTest = pRid.indexOf(',');
	var l_Rid = pRid;
	if(l_PTest >= 0){
		l_Rid = l_Rid.substring(0,l_PTest)
	}else if (l_CTest >= 0){
		l_Rid = l_Rid.substring(0,l_CTest)}
	return l_Rid;
}




/* Begin PPR Reports */
function html_PPR_Report_Page (pThis,pRid,pURL,pHeader,pFooter){
	var l_pRid = html_CleanRegionId(pRid);
	document.body.style.cursor = 'wait';
    var l_URL = pURL;
    var start = l_URL.indexOf('?');
    l_URL = l_URL.substring(start + 1);
    l_URL = html_replace(l_URL,'pg_R_','FLOW_PPR_OUTPUT_'+l_pRid+'_pg_R_');
    l_URL = html_replace(l_URL,'fsp_sort_','FLOW_PPR_OUTPUT_'+l_pRid+'_fsp_sort_');
    var http = new htmldb_Get('report'+ l_pRid,null,null,null,null,'f',l_URL);
    http.get(null,'<htmldb:'+l_pRid+'>','</htmldb:'+l_pRid+'>');
    if(pHeader){$x('report'+ l_pRid).innerHTML =  pHeader + $x('report'+ l_pRid).innerHTML}
    if(pFooter){$x('report'+ l_pRid).innerHTML += pFooter;}
    document.body.style.cursor = '';
    init_htmlPPRReport(l_pRid);
    http = null;
    return;
}

/* inits ppr report by replacing href's with javascript call*/
function init_htmlPPRReport2(pId){
  var l_Table = $x('report'+pId);
  if(l_Table){
    var l_THS = l_Table.getElementsByTagName('TH');
    for(var i = 0;i<l_THS.length;i++){
    if(l_THS[i].getElementsByTagName('A')[0]){
      var oldHREF = l_THS[i].getElementsByTagName('A')[0].href;
      l_THS[i].getElementsByTagName('A')[0].href = 'javascript:html_PPR_Report_Page(this,\''+pId+'\',\''+oldHREF+'\');'
      }
    }
  }
  return;
}

/*this function needs to be called for a bug in ie*/
function init_htmlPPRReport(pId){
  if(document.all){
    var ie_HACK = 'init_htmlPPRReport2(\''+pId+'\')';setTimeout(ie_HACK,100);}
    else{init_htmlPPRReport2(pId);}
  return;
}


/*Given a region id*/
function PPR_Tabluar_Submit(pId,pFlowID,pPageId,pRequest,pInsertReturn,pReportId,pReplacementOveride){
 pThis = $x(pId);
 if(pInsertReturn){var get = new htmldb_Get(pId,pFlowID,pRequest,pPageId,null,'wwv_flow.accept');}
 else{var get = new htmldb_Get(null,pFlowID,pRequest,pPageId,null,'wwv_flow.accept');}
 var lItems = html_Return_Form_Items(pThis);
 for(var i=0;i<lItems.length;i++){
  if(lItems[i].type == 'checkbox'){
    if(lItems[i].checked == true){
      get.addParam(lItems[i].name,lItems[i].value);
     }
    }else{
      if(lItems[i].name && lItems[i].name != 'fcs'){
        get.addParam(lItems[i].name,lItems[i].value);
      }

    }  
 }
 var lSelects = html_Return_Form_Items(pThis,'SELECT');
 for(var i=0;i<lSelects.length;i++){
 get.addParam(lSelects[i].name,html_SelectValue(lSelects[i]))
 
 }
 var lTextarea= html_Return_Form_Items(pThis,'TEXTAREA');
 for(var i=0;i<lTextarea.length;i++){
         get.addParam(lTextarea[i].name,lTextarea[i].value);
 }

 if(pReplacementOveride){
  var q = get.get(null,'<htmldb:'+pReplacementOveride+'>','</htmldb:'+pReplacementOveride+'>');
 }else{
  var q = get.get(null,'<htmldb:PPR_'+pId+'>','</htmldb:PPR_'+pId+'>');
 }
 if(pReportId){init_htmlPPRReport(pReportId);}
 get = null;
 return q;
}

/* End PPR Reports */

/* Begin Smart Table Code */
  /* delete table row based off off element*/
function html_RemoveRow(pId){
 var l_Table = $x('htmldbAddRowTable');
 var l_Row = $x_UpTill(pId,'TR');
 if(l_Table.childNodes.length >= 2 && l_Row){
  l_Table.removeChild(l_Row)
  l_Table.normalize();
 }
 return;
}

/* inits the Add Row Table */
/*begin fix for ie unchecking checkbox on row move*/
var g_CheckedArray_IE;
function ie_RowFixStart(pThis){
  if(document.all){
		var l_Items = html_Return_Form_Items(pThis,'checkbox');
		g_CheckedArray_IE = new Array();
		for (var i=0;i<l_Items.length;i++){if(l_Items[i].type == 'checkbox'){g_CheckedArray_IE[i] = l_Items[i].checked}}
	}
}

function ie_RowFixFinish(pThis){
  if(document.all){
		var l_Items = html_Return_Form_Items(pThis,'checkbox');
		for (var i=0;i<l_Items.length;i++){
				if(l_Items[i].type == 'checkbox'){l_Items[i].checked = g_CheckedArray_IE[i]}
		}
 }
}
/*begin fix for ie unchecking checkbox on row move*/

function html_InitAddRowTable(){
  var l_Table = $x('htmldbAddRowTable');
  var l_Cell = l_Table.rows[0].cells[l_Table.rows[0].cells.length-1];
  l_Cell.innerHTML ="<br />"
  l_Cell.className = l_Table.rows[0].cells[l_Table.rows[0].cells.length-2].className;
  return;
}

var gLastRowMoved = null;
var gLastRowMovedColor = '#CCCCCC';
var gLastRowHighlight = true;
function $tr_RowMoveFollow(pThis,pColorLastRow){
	if(gLastRowHighlight){
	if(pColorLastRow && gLastRowMoved){
		html_RowHighlightOff(gLastRowMoved);
	}
	html_RowHighlight(pThis,gLastRowMovedColor);
	}
	gLastRowMoved = pThis
}


function html_RowUp(pThis,pColorLastRow){
  var l_Row = $x_UpTill(pThis,'TR');
	ie_RowFixStart(l_Row);
  $tr_RowMoveFollow(l_Row,pColorLastRow);
  var l_Table = l_Row.parentNode;
  var l_RowPrev = l_Row.previousSibling;
	while(l_RowPrev != null){
	 if(l_RowPrev.nodeType == 1){break}
	 l_RowPrev = l_RowPrev.previousSibling;
	}
	if(l_RowPrev != null && l_RowPrev.firstChild != null && l_RowPrev.firstChild.nodeName != 'TH' && l_RowPrev.nodeName == 'TR'){
	  oElement = l_Table.insertBefore(l_Row ,l_RowPrev);
  }else{
    oElement = l_Table.appendChild(l_Row);
  }
	ie_RowFixFinish(oElement);
  return oElement;
 }

function html_RowDown(pThis,pColorLastRow){
  var l_Row = $x_UpTill(pThis,'TR');
	ie_RowFixStart(l_Row);
  $tr_RowMoveFollow(l_Row,pColorLastRow);
  var l_Table = l_Row.parentNode;
  var l_RowNext = l_Row.nextSibling;
  while(l_RowNext != null){
	 if(l_RowNext.nodeType == 1){break}
	 l_RowNext = l_RowNext.nextSibling;
  }
	if(l_RowNext != null && l_RowNext.nodeName == 'TR'){
    oElement = l_Table.insertBefore(l_Row ,l_RowNext.nextSibling);
  }else{
    oElement = l_Table.insertBefore(l_Row ,l_Table.getElementsByTagName('TR')[1]);
  }
	ie_RowFixFinish(oElement);
  return oElement;
}

/* End Smart Table Code */
function dhtml_CloseDialog(pThis){
  html_enableBase();
  $x_Hide($x_UpTill(pThis,'TABLE'));
  toolTip_disable();
}

function html_processing(){
  var t = $x("htmldbWait");
   if (!t) {
    var l_newDiv = document.createElement('DIV');
    l_newDiv.className="htmldbProcessing";
    l_newDiv.style.zIndex=20000;
    l_newDiv.id = "htmldbDisablePage";
    l_newDiv.style.width = "100%";
    l_newDiv.style.height = "100%";
    l_newDiv.onclick = "return false;";
    l_newDiv.style.position="absolute";
    l_newDiv.style.top="0";
    l_newDiv.style.left="0";
    document.body.insertBefore(l_newDiv,document.body.firstChild);
  }
}
function html_enableBase(){
  var t = $x("htmldbDisablePage");
   if (t){t.parentNode.removeChild(t)}
}

function html_disableBase(z,c){
  var t = $x("htmldbDisablePage");
   if (!t) {
    var l_newDiv = document.createElement('DIV');
    l_newDiv.className= c!= null ? c : "htmldbDisablePage";
    l_newDiv.style.zIndex=z;
    l_newDiv.id = "htmldbDisablePage";
    l_newDiv.style.width = "100%";
    l_newDiv.style.height = "100%";
    l_newDiv.onclick = "return false;";
    l_newDiv.style.position="absolute";
    l_newDiv.style.top="0";
    l_newDiv.style.left="0";
    document.body.insertBefore(l_newDiv,document.body.firstChild);
  }
}

function html_Centerme(id){
      var t = $x(id);
     if(document.all){
      l_Width = document.body.clientWidth;
      l_Height = document.body.clientHeigth;
     }
     else{
      l_Width = window.innerWidth;
      l_Height = window.innerHeight;
     }

      var tW=t.offsetWidth;
      var tH=t.offsetHeight;  
      t.style.top = '40%';
      t.style.left = '40%';
}

var gChangeCheck = null;
function htmldb_InitPrevNextChange(pThis){}
function htmldb_SetOC(pThis){}

/* tool tip section */
var tt_target;
var gToolTipGraphic = "arrow2.gif"
function toolTip_init(){
  if ( document && document.body) {
        var tt_tipobj=$x("dhtmltooltip");
        if (tt_tipobj == null || typeof(tt_tipobj) != 'object' ){
              tt_tipobj = document.createElement('DIV');
              tt_tipobj.id="dhtmltooltip";
              tt_tipobj.className="htmldbToolTip";
              tt_tipobj.style.position = "absolute";
              tt_tipobj.style.border="1px solid black"; 
              tt_tipobj.style.padding="2px"; 
              tt_tipobj.style.backgroundColor=""; 
              tt_tipobj.style.visibility="hidden"; 
              tt_tipobj.style.zIndex=10000;
              document.body.appendChild(tt_tipobj);
        }
        var tt_pointerobj=$x("dhtmlpointer");
        if (tt_pointerobj == null ||  typeof(tt_pointerobj) != 'object' ) {
               tt_pointerobj = document.createElement('IMG');
               tt_pointerobj.id="dhtmlpointer";
               tt_pointerobj.src= htmldb_Img_Dir + gToolTipGraphic;
               tt_pointerobj.style.position = "absolute";
               tt_pointerobj.style.zIndex=10001;
              document.body.appendChild(tt_pointerobj );   
        }
     return true;
    } else {
     return false;
    }
}

function toolTip_disable(){
    if ( toolTip_init() ) {
    var tt_tipobj=$x("dhtmltooltip");
    var tt_pointerobj=$x("dhtmlpointer");

    tt_target = null;
    tt_tipobj.style.visibility="hidden"
    tt_pointerobj.style.visibility="hidden"
    tt_tipobj.style.backgroundColor=''
    tt_tipobj.style.width=''
    tt_tipobj.innerHTML='';   
  }
}

function toolTip_enable(evt,obj,tip, width, color){
    var evt = (evt) ? evt : ((window.event) ? event : null);
    var target_x = evt.pageX ? evt.pageX : evt.clientX ;
    var target_y = evt.pageY ? evt.pageY : evt.clientY ;
    
    if ( toolTip_init() ) {
    var tt_tipobj=$x("dhtmltooltip");
    var tt_pointerobj=$x("dhtmlpointer");

    tt_target = obj;
    if (!tip) 
      tip = obj.getAttribute("htmldb:tip");      
    tt_tipobj.innerHTML=tip;
    if (typeof width!="undefined") 
         tt_tipobj.style.width=width+"px"      
    if (typeof color!="undefined" && color!="")  {
         tt_tipobj.style.backgroundColor=color
    } else {
        tt_tipobj.style.backgroundColor="lightyellow";
    }

    tt_pointerobj.style.left = ( 10 + target_x ) +"px";
    tt_pointerobj.style.top  = (15 + target_y ) +"px";   

    tt_tipobj.style.left = ( 7 + target_x ) +"px";
    tt_tipobj.style.top  = ( 28 + target_y ) +"px";   
     
    tt_tipobj.style.visibility="visible"
    tt_tipobj.style.zIndex=10000;
    tt_pointerobj.style.zIndex=10001;
    tt_pointerobj.style.visibility="visible";
    
    try {
        obj.addEventListener("mouseout", toolTip_disable, false);
     } catch(E) {
      obj.attachEvent('onmouseout', toolTip_disable);
     }
   }
    return false;
}

function dhtml_ShuttleValue(pThis,pThat){
 var l_SelectArray = new Array();
 var l_From = $x(pThis);
 var l_To = $x(pThat); 
 l_SelectArray = getSelected(l_From.options);
 for (var i=0;i<l_SelectArray.length;i++){
  l_To.appendChild(l_SelectArray[i])
 }
}

   function getSelected(opt) {
      var selected = new Array();
      var index = 0;
      for (var intLoop=0; intLoop < opt.length; intLoop++) {
         if (opt[intLoop].selected) {
            index = selected.length;
            selected[index] = opt[intLoop];
         }
      }
      return selected;
   }
   
function retFalse() {
  return false;
}


function dhtml_ShuttleObject(pThis,pThat){
 this.Select1 = $x(pThis);
 this.Select2 = $x(pThat);
 this.Select1ArrayInit = this.Select1.cloneNode(true);
 this.Select2ArrayInit = this.Select2.cloneNode(true);
 this.Op1Init = new Array();
 this.Op2Init = new Array(); 
 this.Op1Init = this.Select1ArrayInit.options;
 this.Op2Init = this.Select2ArrayInit.options;
 this.move = move;
 this.moveall = moveall;
 this.remove = remove;
 this.removeall = removeall;
 this.reset = reset;
 return;

 function move(){
 var l_SelectArray = getSelected(this.Select1.options);
 var Array_Length = l_SelectArray.length;
 for (var i=0;i<Array_Length;i++){
	 this.Select2.appendChild(l_SelectArray[i]);
 }
 }
 
 function remove(){
 var l_SelectArray = getSelected(this.Select2.options);
 var Array_Length = l_SelectArray.length;
 for (var i=0;i<Array_Length;i++){
  this.Select1.appendChild(l_SelectArray[i])
 }
 }
 
 function reset(){
  this.Select1.options.length = 0;
  this.Select2.options.length = 0;
  var L_Count1 = this.Op1Init.length;
  for(var i=0;i<L_Count1;i++){
	  this.Select1.options[i]= new Option(this.Op1Init[i].text,this.Op1Init[i].value)	  
  }
  var L_Count2 = this.Op2Init.length;
  for(var i=0;i<L_Count2;i++){
	  this.Select2.options[i]= new Option(this.Op2Init[i].text,this.Op2Init[i].value)	  
  }
  
 }

 function moveall(){}
 function removeall(){}
 
 
}


gReturn = 'F4000_P4017_SOURCE_CHART'

function ChartSqlReturn(pThis){
$v_PopupReturn('P4000_CHART_SQL',gReturn)
window.close();
}


function plsql_in_string(pThis,pArray){
 var l_Return = false;
 var l = pArray.length;
 for(var i=0;i<l;i++){
  if(pThis == pArray[i]){l_Return = true}
 }
 return l_Return;
}

function plsql_in(pThis,pArray){
 var l_Return = false;
 var l = pArray.length;
 for(var i=0;i<l;i++){
  if($x(pThis) == $x(pArray[i])){l_Return = true}
 }
 return l_Return;
}

function isEmpty(pThis) {
	var re = /^\s{1,}$/g; //match any white space including space, tab, form-feed, etc.
	if (($x(pThis).value.length==0) || ($x(pThis).value==null) || (($x(pThis).value.search(re)) > -1)) {
		return true;
	}else{
		return false;
	}
}







function html_SetSelectValue(pId,pValue){
 var lSelect = $x(pId);
 if(lSelect.nodeName == 'SELECT'){  
  for(var i=0,l=lSelect.options.length;i<l;i++){
    if(lSelect.options[i].value == pValue){lSelect.options[i].selected=true;}
		else{lSelect.options[i].selected=false;}
  }
 }
}


/* New Javscript Functions */

function f_Hide_On_Value_Item(pThis,pThat,pValue){
    var lTest = html_CheckValueAgainst(pThis,pValue);
	if($x(pThat)){
		if(lTest){$x_Hide(pThat);}
		else{$x_Show(pThat);}
	}
}

function f_Hide_On_Value_Item_Row(pThis,pThat,pValue){
    var lTest = html_CheckValueAgainst(pThis,pValue);
	if($x(pThat)){
		if(lTest){html_HideItemRow(pThat);}
		else{html_ShowItemRow(pThat);}
	}
	return lTest;
}

function html_DisableOnValue(pThis,pValue,pThat){
    var lTest = html_CheckValueAgainst(pThis,pValue);
	if(pThat){
		 for (var i=2;i <= arguments.length; i++){html_disableItem(arguments[i],lTest);}
	}
	return lTest;
}

/*
This function checks an items value agianst 
a set of values and returns true if any one matchs
*/
function html_CheckValueAgainst(pThis,pValue){
    var lTest = false;
	var lArray = new Array();
	var lValue = false;
	var lLength = false;
	
	if(pValue.constructor == Array){lArray = pValue}
	else{lArray[0] = pValue;}
	lLength = lArray.length;

	if(pThis.nodeName == 'SELECT'){lValue = html_SelectValue(pThis);
	}else{lValue = $x(pThis).value;}

	for(var i=0;i<lLength;i++){
		lTest = lValue == lArray[i];
		if(lTest){break;}
	}
	return lTest;
}




/* 
these two functions extend the 
dhtml_ShuttleObject to add move_all 
and remove_all methods
*/
dhtml_ShuttleObject.prototype.move_all = function(){
	for (var i=0;i<this.Select1.options.length;i++){
			this.Select1.options[i].selected=true;
	}
	this.move()
}
dhtml_ShuttleObject.prototype.remove_all = function(){
	for (var i=0;i<this.Select2.options.length;i++){
			this.Select2.options[i].selected=true;
	}
	this.remove();
}

dhtml_ShuttleObject.prototype.sort1 = function(pDir){
	this.sort(this.Select1,pDir);
}

dhtml_ShuttleObject.prototype.sort2 = function(pDir){
	this.sort(this.Select2,pDir);
}

dhtml_ShuttleObject.prototype.sort = function(pShuttle,pDir){
	var nextOption;
	var lLength = pShuttle.options.length;
	if(pDir == 'U'){
		for (var i=0;i<pShuttle.options.length;i++){
			if(pShuttle.options[i].selected==true){
				if(pDir == 'U'){
					if(i!=0){pShuttle.insertBefore(pShuttle.options[i], pShuttle.options[i-1]);}
				}
			}
		}
	}else if(pDir == 'D'){
		for (var i=pShuttle.options.length-1;i>=0;i--){
			if(pShuttle.options[i].selected==true){
				if(pDir == 'D'){
					if(i!=pShuttle.options.length-1){pShuttle.insertBefore(pShuttle.options[i], pShuttle.options[i+2]);}
				}
			}
		}
	}else{
		var l_Opt = new Array();
			for (var i=0;i<pShuttle.options.length;i++){
				if(pShuttle.options[i].selected==true){
					l_Opt[l_Opt.length] = pShuttle.options[i];
				}
			}
		if(pDir == 'B'){
			for (var i=0;i<l_Opt.length;i++){
				pShuttle.appendChild(l_Opt[i]);
			}
		}else if(pDir == 'T'){
			for (var i=l_Opt.length-1;i>=0;i--){
				pShuttle.insertBefore(l_Opt[i],pShuttle.firstChild);
			}
		}
	}
}

/* New Javscript Objects */




function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}


/*swaps two form values*/
function $f_Swap(pThis,pThat){
	if(pThis && pThat){
		var lThis = $x(pThis).value;
		var lThat = $x(pThat).value;
		$x(pThis).value = lThat;
		$x(pThat).value = lThis;
	}
}


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}


function html_ShowAllByClass(pThis,pClass,pTag) {
		var node = $x(pThis);
		var lH = getElementsByClass(pClass,node,pTag);
		if (lH) {
			$x_Show(lH);
		}
} 


function $ShowChildren(pThis){html_ShowAllChildren(pThis);}
function html_ShowAllChildren(pThis) {
	var node = $x(pThis);
	if (node && node.hasChildNodes) {
	  var lH = node.childNodes;
	  var lH_length = lH.length; 
	  for (var i=0;i<lH_length;i++){
		$x_Show(lH[i]);
	  }
	}
} 


/*quick functions for html building using dom*/
function $tr_AddTD(pThis,pText){
  var td1 = document.createElement("TD")
  pThis.appendChild(td1);
	if(pText){td1.innerHTML = pText;}
	return td1
}

function $tr_AddTH(pThis,pText){
    var td1 = document.createElement("TH")
    pThis.appendChild(td1);
	  if(pText){td1.innerHTML = pText;}
	return td1
}

function $x_AddTag(pThis,pTag,pText){
    var td1 = document.createElement(pTag)
    pThis.appendChild(td1);
		if(pText){td1.innerHTML = pText;}
	return td1
}

/* sets array of form values to sequntial number*/
function $f_SetValueSequence(pArray,pMultiple){
			 var lLength = pArray.length;
			 for (var i=0;i<lLength;i++){
			 		 var pNode = $x(pArray[i]);
		  		 if(pNode){pNode.value = (i+1)*pMultiple;}
			  }		
}


function $f_ValuesToArray(pThis,pClass,pTag){
	var lTemp = getElementsByClass(pClass,$x(pThis),pTag);
	var lTempLength = lTemp.length;
	var lArray = new Array();
	for(var i=0;i<lTempLength;i++){
	    lArray[i] = lTemp[i].value;
	}
	return lArray;
}


/* the following runs the dhtml ordering tables */
var gTestArray;
var gTestId;
var gReSequence = false;
var gReSequenceBy = 10;
function reorder_init(pThis){
	var node = $x(pThis);
	var lH = getElementsByClass('orderby',node,'INPUT');
	for (var i=0;i<node.rows.length;i++){
		if(i==0){$tr_AddTH(node.rows[i],'<br />')}
		else{$tr_AddTD(node.rows[i],'<img src="'+htmldb_Img_Dir+'htmldb/icons/up_arrow.gif" onclick="html_RowUp(this,true);reorder_set();" class="pb" alt="" /><img src="'+htmldb_Img_Dir+'htmldb/icons/down_arrow.gif" onclick="html_RowDown(this,true);reorder_set();" class="pb" alt="" />')}
	}
	if(gReSequence){$f_SetValueSequence(lH,gReSequenceBy);}
	gTestArray = $f_ValuesToArray(node,'orderby','INPUT');
	gTestId = pThis;
    if($x('pview')){rpreview()}
}

function reorder_set(){
	var node = $x(gTestId);
	var lH = getElementsByClass('orderby',node,'INPUT');
	for (var i=0;i<lH.length;i++){
		lH[i].value = gTestArray[i];
	}
   if($x('pview')){rpreview()}
}

/*the following runs item layout preview */
function rpreview(){
	var node = $x(gTestId);
	var lnode = $x('pview');
	var lH = getElementsByClass('orderby',node,'INPUT');
	lnode.innerHTML = '';
	var lTable = $x_AddTag(lnode,'TABLE');
	lTable.className='itemlayout';
	lLastRow = false;
	lLastCell = false;
	for (var i=1;i<node.rows.length;i++){
		var lSelect = html_Return_Form_Items(node.rows[i],'SELECT');
		var lText = html_Return_Form_Items(node.rows[i],'TEXT');
		var lValue = node.rows[i].cells[0].innerHTML;
		var lLabel = lText[0].value;
		var lType = lText[2].value;
		if(lType){}
		var lNewLine = lSelect[0].value;
		var lNewField = lSelect[1].value;
		var lAlign = lSelect[2].value;
	if(lType == 'STOP_AND_START_HTML_TABLE'){
			$x_AddTag(lnode,'BR');
			var lTable = $x_AddTag(lnode,'TABLE');
			lTable.className='itemlayout';
	}else{
		if(lNewLine == 'YES' || i==1){lLastRow = $x_AddTag(lTable,'TR');}
		if(lType == 'BUTTON'){lLabel = '<br />';}
		lLastCell = $tr_AddTD(lLastRow,lLabel);
		lLastCell.setAttribute('style',rAlign(lAlign));
		if(lType == 'HIDDEN'){lLastCell.setAttribute('style','font-weight:normal;background-color:#FFF;')}
		if(lNewField == 'YES' && lAlign != 'ABOVE' && lAlign != 'BELOW'){
			lLastCell = $tr_AddTD(lLastRow,lValue);
			lLastCell.className='itemlayout';
		  if(lType == 'TEXTAREA'){lLastCell.setAttribute('style','height:75px;')}
			if(lType == 'HIDDEN'){lLastCell.setAttribute('style','font-weight:normal;background-color:#FFF;')}
			  lLastCell.colSpan = lText[1].value
			}else{
		      if(lAlign == 'ABOVE'){lLastCell.innerHTML += '<br />'+ lValue;}
			  else if(lAlign == 'BELOW'){lLastCell.innerHTML = lValue + '<br />' + lLastCell.innerHTML;}
			  else{lLastCell.innerHTML += lValue;}
			  if(lType == 'TEXTAREA'){lLastCell.setAttribute('style','height:75px;')}
			  lLastCell.colSpan = lText[1].value
		}
	}
	}
	if(document.all){lnode.innerHTML = lnode.innerHTML;}
}

function rAlign(pThis){
		var lText;
		var lThis = pThis.split("-");
		switch(lThis[0]){
			case 'CENTER' : lText='text-align:center;'; break;
			case 'RIGHT' : lText='text-align:right;'; break;
			case 'LEFT' : lText='text-align:left;'; break;
			default : lText = ' '; break;
		}
		if(lThis[1]){
		switch(lThis[1]){
			case 'BOTTOM' : lText+='vertical-align:bottom;'; break;
			case 'CENTER' : lText+='vertical-align:middle;'; break;
			case 'TOP' : lText+='vertical-align:top;'; break;
			default : lText += ' '; break;
		}
		}
	  return lText
}



/*the following runs the attribute page filter*/
var gThis = false;
var lEl = false;
var lH = false;
function qF(pThis,pThat){filterAttributeRegions(pThis,pThat);}
var gFARButtonListCurrent = 'htmldbButtonListCurrent';
var gFARButtonList = 'htmldbButtonList2';
var gFARCookieName = 'propHide';
function filterAttributeRegions(pThis,pThat){
	try{
		var lThis = pThat.substr(1);
		if(lThis == 'ALL' || lThis == 'DEFAULTALL'){
			  pThis.className = gFARButtonListCurrent;;
			  if(lThis != 'DEFAULTALL'){SetCookie (gFARCookieName, $x('pFlowStepId').value+','+pThat);}
			  uF();
			  if($x('ContentArea')){$x_Show('ContentArea');}
		}else{
			 if($x('ALL')){$x('ALL').className = gFARButtonList;}
			 uR();
 			 pThis.className = gFARButtonListCurrent;
			 gThis = pThis;
			 if($x('ContentArea')){
				lH = getElementsByClass('T',$x('ContentArea'),'TH');
			 }else{
				lH = getElementsByClass('T',$x('ContentBody'),'TH');
			 }
			 for (var i=0;i<lH.length;i++){
	     		 $x_Hide($x_UpTill(lH[i],'TABLE'));
		  		 if(lH[i].getElementsByTagName('A')){
					 		var lTr = lH[i].getElementsByTagName('A')[0];
							if(lTr && lTr.name && lTr.name == lThis){lEl = lTr;}
						}
				}		
				if(lEl){$x_Show($x_UpTill(lEl,'TABLE'))}
				SetCookie (gFARCookieName, $x('pFlowStepId').value+','+pThat);
				if($x('ContentArea')){$x_Show('ContentArea');}
		}
	}catch(e){
		uF();
		if($x('ContentArea')){$x_Show('ContentArea');}
	}
}


function propTest(){
	var currentURL = document.URL;
	var lInd = currentURL.lastIndexOf('#');
	if(lInd != -1){var lId = currentURL.substring(lInd);}
	else if(GetCookie ('propHide')){
		var lPage = GetCookie ('propHide').split(',')[0];
		if ($x('pFlowStepId').value == lPage && lInd == -1){var lId = GetCookie ('propHide').split(',')[1];}
	}else{lId = false;}
	if(lId){
		var lLinks = $x('ql').getElementsByTagName('A');
		for (var i=0;i<lLinks.length;i++){
			if(lLinks[i].getAttribute('href').lastIndexOf(lId) != -1){qF(lLinks[i],lId);}
		}
	}else{qF($x('ALL'),'#DEFAULTALL');}
	
}

function uF(){unfilterAttributeRegions()}
function unfilterAttributeRegions(){
	try{
		lH = getElementsByClass('T',$x('ContentBody'),'TH');
		for (var i=0;i<lH.length;i++){$x_Show($x_UpTill(lH[i],'TABLE'));}
		uR();
		scroll(0,0);
	}catch(e){
		scroll(0,0);
	}
	return;
}


function uR(){
	if(gThis){
		gThis.className = 'htmldbButtonList';
		if(gThis == $x('ALL')){gThis = $x('ALL');}
	}
}

/* sets an array of nodes to a single class name*/
function $x_SetClassArray(pArray,pClass){
   if(pArray){
	for(var i=0,l=pArray.length;i<l;i++){if(pArray[i] && pArray[i].nodeType == 1){$x(pArray[i]).className=pClass;}}
   }
  return pArray;
}


function $x_SetSiblingsClass(pThis,pClass,pThisClass){
   var l_Node = $x(pThis);
   if(l_Node){
		var l_NodeSibs = l_Node.parentNode.childNodes;
		$x_SetClassArray(l_NodeSibs,pClass);
		if(pThisClass){l_Node.className=pThisClass;}
  }
  return l_Node;
}




