/*  Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
    ToolsRel: 8.51.10 */
// JScript File PT common functions
var browserInfoObj;
var ptCommonObj; //Object of PT common
var ptConsole;
var ptRC;

function PT_createStandardObjects()
{
    browserInfoObj = new PT_browserInfo();  // Create browser info object
    browserInfoObj.init();
    ptCommonObj = new PT_common();  // Create common object for utility functions.
    ptConsole = new PT_console();   // debugger console
    ptRC = new PT_RC();     // related content object
}

function PT_console()
{
this.el = null;
this.enabled = false;
}

PT_console.prototype = {
isEnabled:function(){
if (this.el && this.enabled) return true;
return false;
},
enable:function(){
this.enabled = true;
},
active:function(){
if (!this.enabled) return false;
if (!this.el)
{
this.el = document.getElementById("pt_console");
if (!this.el) return null;
this.el.innerHTML="<input type=button id='COPYCONSOLE' value='Copy' onclick='ptConsole.copy();' alt='copy to clipboard' title='copy to clipboard'><input type=button id='CLEARCONSOLE' onclick='ptConsole.clear();' value='Clear' alt='clear console' title='clear console'><input type=button id='HIDECONSOLE' onclick='ptConsole.hide();' value='Hide' alt='hide console' title='hide console'><input type=button id='CLOSECONSOLE' onclick='ptConsole.deactive();' value='Close' alt='close console' title='close console'>";
this.el.consoleModal=this;
}
this.show();
},
deactive:function(){
if (!this.enabled) return false;
this.hide();
if (this.el)
    this.el.innerHtml = "";
this.el = null;
},
show:function(){
if (!this.el) return false;
this.el.style.display = "block";
},
hide:function(){
if (!this.el) return false;
this.el.style.display = "none";
},
copy:function(){
if (!this.el) return false;
var txt='';
for (var i=0; i<this.el.childNodes.length; i++) {
    var node=this.el.childNodes[i];
    if (node.nodeName.toLowerCase() == 'div')
    {
    if (node.lastChild.nodeName.toLowerCase() == 'textarea')
        txt=txt+node.lastChild.value+'\n\n';
    }
 }
CopyUrlToClipboard(txt);
},
clear:function(){
if (!this.el) return false;
while(this.el.lastChild && this.el.lastChild.type!='button') {
this.el.removeChild(this.el.lastChild);
}
},
append:function(msg){
if (!this.el) return false;
var txtNode=document.createElement('textarea');//document.createTextNode(msg);
txtNode.className='debugtext';
txtNode.readOnly = 'true';
txtNode.value=msg;
var domEl=document.createElement('div');
domEl.appendChild(txtNode);
domEl.className='debugtext';
this.el.appendChild(domEl);
}
}

function PT_browserInfo()
{
    this.browser=''; // Complete user agent information
    this.isOpera=false; // Is the browser "Opera"
    this.isIE=false; // Is the browser "Internet Explorer"
    this.isFF=false; // Is the browser "Firefox"
    this.isNetscape; // Is the browser "Netscape"
    this.isMozilla = false;
    this.isSafari = false;
    this.version=''; // Browser version
    this.isMacOS=false;
    this.isSafari2x = false;
}

PT_browserInfo.prototype = {
init:function(){
this.browser = navigator.userAgent.toLowerCase();
//this.isMacOS = (this.browser.toLowerCase().indexOf('macintosh')!= -1)?true:false;
this.isOpera = (this.browser.toLowerCase().indexOf('opera')>=0)?true:false;
this.isFF = (this.browser.toLowerCase().indexOf('firefox')>=0)?true:false;
this.isNetscape = (this.browser.toLowerCase().indexOf('netscape')>=0)?true:false;
this.isIE = (this.browser.toLowerCase().indexOf('msie')>=0)?true:false;
this.version = navigator.appVersion.replace(/.*?MSIE (\d\.\d).*/g,'$1')/1;
this.isSafari = /webkit/.test(this.browser);
this.isMozilla = /mozilla/.test(this.browser) && !/(compatible|webkit)/.test(this.browser);
//this.isSafari2x = browserInfoObj.Safari2x(this.browser);
this.isSafari2x = this.Safari2x(this.browser);
},

// Check for Safari 2.x.
// Note that Safari 2.x does not have the version info in the user agent. We will need to use the WebKit build information
// to determine the actual version. For details, see http://developer.apple.com/internet/safari/uamatrix.html
Safari2x : function (userAgent) {
    if (userAgent == null)
        return false;
    var bSafari2x = false;
    var WEBKITBUILD412 = 412.0;      // Safari 2.0
    var WEBKITBUILD419DOT3 = 419.3;  // Safari 2.0.4
    var WEBKITSTR = "applewebkit/";  // webkit build string
    var HTMLSTR = " (khtml";         // the actual webkitbuild is before
    var webKitBuild = 0;             // default value of webkit build

    var i = userAgent.toLowerCase().indexOf(WEBKITSTR);
    var j = userAgent.toLowerCase().indexOf(HTMLSTR);
    if (i >= 0 && j >= 0) {
        var b = i + WEBKITSTR.length; // beginning of webkit build
        var webKitBuildLen = j - b;   // length of webKit build
        webKitBuild = userAgent.substring(b, b + webKitBuildLen);
        //alert("i,j,b,webKitBuildLen,webKitBuild = " + i +","+ j+","+ b+","+webKitBuildLen+","+ webKitBuild);
        if (webKitBuild >= WEBKITBUILD412 && webKitBuild <= WEBKITBUILD419DOT3)
            bSafari2x = true;
    }
    return bSafari2x;
}
}

/* Constructor */
function PT_common()
{}

PT_common.prototype = {

isHTMLTemplate : typeof(bPSHTMLtemplate) !== "undefined" && bPSHTMLtemplate,

 //  cancelEvent() function only returns false. It is used to cancel selections and drag
cancelEvent : function()
    {
        return false;
    },
//used by popup getclient height
getViewportHeight:function()
{
    if (window.innerHeight!=window.undefined)
        return window.innerHeight;
    if (document.compatMode=='CSS1Compat')
        return document.documentElement.clientHeight;
    if (document.body)
        return document.body.clientHeight;
    return window.undefined;
},
// get client width. used in popup for prompt and message dialog
getViewportWidth:function()
{
    if (window.innerWidth!=window.undefined)
        return window.innerWidth;
    if (document.compatMode=='CSS1Compat')
        return document.documentElement.clientWidth;
    if (document.body)
        return document.body.clientWidth;
    return window.undefined;
},

getMouseCoords : function(ev)
{
   
   
   if('ltr'=='rtl' && browserInfoObj.isIE)
      {
      var scLeft= parseInt((document.body.scrollWidth - document.body.clientWidth- document.body.scrollLeft),10);
      var newX=ev.clientX;
      if (scLeft > 0 && ev.clientX>=scLeft)
          newX = ev.clientX - scLeft; 
      if(ev.pageX || ev.pageY)
         return {x:newX, y:ev.pageY};
      else
         return {x:newX, y:ev.clientY + document.body.scrollTop  - document.body.clientTop};
      }

   if(ev.pageX || ev.pageY)
      return {x:ev.pageX, y:ev.pageY};

   return { x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,  y:ev.clientY + document.body.scrollTop  - document.body.clientTop };
},

getMouseOffset : function(target, ev)
{
    ev = ev || window.event;
	
    var docPos    = this.getPosition(target);
    var mousePos  = this.getMouseCoords(ev);
    return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
},

getPosition : function(e)
{
    var left = 0;
    var top  = 0;
    var oParent=null;
    while (e.offsetParent)
    {
        if (e.tagName!='HTML')
           {
           if ('ltr' =='rtl')
              {
              if (!(e.offsetLeft<0 && e.scrollLeft ==0)) 
                 left += e.offsetLeft;
              }
           else 
              left += e.offsetLeft;
           top  += e.offsetTop;
           }
        else
           oParent=e.offsetParent;
        e  = e.offsetParent;
    }
	
    if ('ltr' =='rtl')
       {
       if (!(e.offsetLeft<0 && e.scrollLeft ==0)) 
           left += e.offsetLeft;
       }
    else
       left += e.offsetLeft;
    top  += e.offsetTop;

    return {x:left, y:top};
},

//method will return the top coordinate(pixel) of an object. used in drag & drop
getTopPos : function(inputObj)
{
  if (inputObj == null)
      return 0;
  var returnValue = inputObj.offsetTop;
  while((inputObj = inputObj.offsetParent) != null){
    if(inputObj.tagName!='HTML'){
        returnValue -=inputObj.scrollTop;
        returnValue += inputObj.offsetTop;
        if(document.all)returnValue+=inputObj.clientTop;
    }
  }

  return returnValue;
},
// getLeftPos() method will return the left coordinate(pixel) of an object. Used in drag & drop
getLeftPos:function(inputObj)
{
  if (inputObj == null)
      return 0;
  var returnValue = inputObj.offsetLeft;
  if (inputObj.offsetParent)
  {
  while((inputObj = inputObj.offsetParent) != null){
    if(inputObj.tagName!='HTML'){
        returnValue -=inputObj.scrollLeft;
        returnValue += inputObj.offsetLeft;
        if(document.all)returnValue+=inputObj.clientLeft;
    }
  }
  }

  return returnValue;
},

//get name and value pair for an element
getNV:function(el)
{
 var nv="";
 if (el == null || el.disabled)
    return nv;
 switch(el.type)
 {
    case "button":
      if (el.checked)
        nv = el.name + "=" + encodeURIComponent(el.value)+"&";
      break;
   case "radio":
     if (el.checked)
        nv = el.name + "=" + encodeURIComponent(el.value)+"&";
      break;
   case "select-one":
        if (el.selectedIndex>-1)
        nv = el.name + "=" + encodeURIComponent(el.options[el.selectedIndex].value)+"&";
        break;
   case "select-multiple":
        var i=0;
        for (i=0;i<el.options.length;i++)
           {
           if (el.options[i].selected)
               nv += (el.name + "=" + encodeURIComponent(el.options[i].value)+"&");
           }
        break;
    default:
       nv = el.name + "=" +encodeURIComponent(el.value)+"&";
  }
  return nv;
},
// available on IE only. Find the current active element and set focus.
setActiveFocus:function()
{
  var b = navigator.userAgent.toLowerCase();
  if (b.indexOf("msie")!=-1)
  {
  var cObj = document.activeElement;
  if (cObj)
  {
  //alert(cObj.type);
  cObj.setActive();
  cObj.focus();
  }
  }
},

tryFocus:function(obj)
{
if (!this.tryFocus0(obj))
    gFocusObj = obj;
return;
},

tryFocus0:function(obj)
{
if (obj && typeof obj.focus != "undefined" && !obj.disabled && obj.style.visibility!="hidden")
{
    var b = navigator.userAgent.toLowerCase();
    obj.focus();
    if (b.indexOf("msie")!=-1)
        obj.setActive();
    if (window.focusHook)
        focusHook(obj);
    return false;
}
return true;
},

//get width of ob
getWidth:function(o)
{
if (!o || typeof o == 'undefined') return 0;
return o.clientWidth;
/*var w=o.style.width;
if (w && (w.indexOf('px')!=-1 || w.indexOf('em')!=-1 ))
    return new Number(w.substring(0,w.length-2).valueOf());
else
    return new Number(w.valueOf());*/
},
//set resize cursor
setResizeCursor:function(evt){var o=getEO(evt);if (o && o != "undefined")    o.style.cursor='E-resize';},

//get event obj
getEO:function(evt)
{
if (!evt)
	evt = event;
if (!evt)
	evt = window.event;
if (!evt)
	return null;
if (browserInfoObj.isIE)
	return evt.srcElement;
else
	return evt.target;
},

//is PIA ajax req
isAJAXReq:function(name)
{
if((name.indexOf('$spellcheck') != -1) || document.getElementById("SPELLCHECKSTRING") != null )
 	return false;
if (!(typeof bPSHTMLtemplate == "undefined" || !bPSHTMLtemplate))
	return false;

if (name.indexOf('#ICOKZG') != -1) {// close grid zoom request
    popupModalObj_win0.hideModalElement();
    return true;
}

if (typeof(bPromptPage_win0) != "undefined" &&
    bPromptPage_win0 && name && (name == "#ICAdvSearch" || name == "#ICSearch"))
    return true;

if (typeof(bModalPage_win0) != "undefined" && bModalPage_win0)
    {
       if(name.indexOf('$spellcheck')!=-1)
           return false;
       else
           return true;
    }


var bSearch=false;
if (typeof(bSearchDialog_win0)!="undefined" && bSearchDialog_win0)
{
    bSearch=true;
    if (typeof(bSearchAddDialog_win0)!="undefined" && bSearchAddDialog_win0 && name.indexOf('#ICSearch') != -1)
        return false;

    
    if (name.indexOf("#ICRow") != -1 && ((typeof(bModalPage_win0) != "undefined" && !bModalPage_win0) || typeof(bModalPage_win0) == "undefined"))  
        return false;

    
    if (name.indexOf("#ICSwitchMode") != -1 && ((typeof(bModalPage_win0) != "undefined" && !bModalPage_win0) || typeof(bModalPage_win0) == "undefined"))  
        return false;

    if (name.indexOf('#ICSaveSearch') ==-1 &&
    name.indexOf('#ICDeleteSearch') ==-1 &&
    name.indexOf('#ICCancel') ==-1 &&
    name.indexOf('#ICSave')==-1 &&
    name.indexOf('#KEY') == -1)
    return true;
}
if (!name)
    return false;
if (!bSearch && name.length==7 && name.indexOf('#ICSave')!=-1)
    return true;
if (name.length>11 && name.indexOf('#ICSetField')!=-1)  // enable AJAX for HTML area
    return true;

if (name.indexOf('#ICRow')==0 && typeof(bPopUpMenuPage_win0)!="undefined" && bPopUpMenuPage_win0)
	return false;			//796933-disable AJAX for PopUpMenu
else if (name.indexOf('#ICRow')==0)
    return true;

//treat switching grid tabs as ajax request when modal grid
if (typeof popupModalObj_win0 != 'undefined' &&
    popupModalObj_win0.isModalElement &&
    (name.indexOf('$tab')!=-1 || name.indexOf('$htab')!=-1))
    return true;
var BrType = new PT_browserInfo();
BrType.init();
var bSfr=BrType.isSafari;
if(bSfr)
  {
//disable ajax support for chart for now(7lines) for SAFARI
    /// ImageMap!!
   if( name.indexOf('$alic')!=-1
	|| name.indexOf('$agdn')!=-1
    || name.indexOf('$mvsk')!=-1
    || name.indexOf('$area')!=-1
    || name.indexOf('$right_arrow')!=-1
    || name.indexOf('$left_arrow')!=-1
    || name.indexOf('$expand')!=-1
    )
    {
     return false;
     }

   }

if (name && (name.indexOf('#IC')!=-1
	|| (name.indexOf('#KEY')!=-1 && name != '#KEYA5' && name.charCodeAt(4) != 13)  
	|| name.indexOf('$hpers')!=-1
	|| name.indexOf('$popup')!=-1
	|| name.indexOf('$excel')!=-1
	|| name.indexOf('$spellcheck')!=-1
	))
    {
    return false;
    }
else
    {
    return true;
    }
},

//is PIA search page, not add, but search
isSearchSearchPage:function(form)
{
    if (form)
        {
        var searchMsg = "Search";
        var oElement = form.elements["#ICSearch"];
        var cElement = form.elements["#ICCancel"];
        if (cElement != null)       
            return false;
        if (oElement != null && oElement.value.indexOf(searchMsg)==0 && searchMsg.length==oElement.value.length)
            return true;
        }
},


//is PIA search page
isSearchPage:function(form)
{
    if (form)
        {
        var oElement = form.elements["#ICSearch"];
        if (oElement != null)
            return true;
        }
},

generateABNSearchResults:function()
{

  try {
    var abnSearchResults = document.getElementById('win0divabnsearchresults');
    if (abnSearchResults) {
      if (abnSearchResults.parentNode.id != 'ptabn') {				

        var abntbl = document.getElementById("ptabndt");
        if (abntbl) {	
          
          abnSearchResults = abnSearchResults.parentNode.removeChild(abnSearchResults);
          abnSearchResults.style.display = "block";

          if (!isCrossDomain(top) && typeof(top.ptIframe) != "undefined") {
            
            if (typeof(top.pthNav) != "undefined") {
              
              var doclocation = document.location.href;
              var index = doclocation.indexOf('?');
              var actionurl = '';
              if (index > 0) {
                actionurl = doclocation.substr(0,index);
              }
              else {
                actionurl = doclocation;
              }
              
              
              if (this.isClass(abnSearchResults,"ptabncustom")) {
                
                top.pthNav.abn.search.add(actionurl,abnSearchResults,this.setABNCustomSearchFormParams());
              } else {
                top.pthNav.abn.search.add(actionurl,abnSearchResults);
              }
            }
          }
        }
      }
    }
  } catch (e) {}
},

// set the NV params for custom search
setABNCustomSearchFormParams:function()
{
	var customSearchParams = "{\"ptCustomSearch\":[";
	var bFirstParam = true;
	for (var i = 0; i < document.win0.elements.length; i++) {	
		var tempId = document.win0.elements[i].id;
		if ((tempId == "#ICIncludeHistory" || tempId == "#ICCorrectHistory" ||
			 tempId == "#ICMatchCase") && !document.win0.elements[i].checked) {
	 		continue;
	  	} else {    // exclude unchecked checkbox and radio button
			if (document.win0.elements[i].tagName == "INPUT" &&
		         (document.win0.elements[i].type == "checkbox" || document.win0.elements[i].type == "radio") ) {
		    	if (!document.win0.elements[i].checked) {
			    	continue;
				}
			}
			if (tempId == "ICRefresh" || tempId == "okbuttonModal" || document.win0.elements[i].type == "button") {
				continue;
			}	
	 	}
        
        // e.g. var customSearch = "{\"ptCustomSearch\":[{\"name\":\"snap\",\"value\":\"myvalue1\"},{\"name\":\"crackle\",\"value\":\"myvalue2\"},{\"name\":\"pop\",\"value\":\"myvalue3\"}]}";
		if (!bFirstParam) { customSearchParams += ","; }
		bFirstParam = false;
		
		// res # 842245
		var paramValue = document.win0.elements[i].value;
		if (tempId == "ICAction")
			paramValue = "";			

        customSearchParams += this.getCustomSearchNV(document.win0.elements[i].name, paramValue);
	} // for
		
	if (!bFirstParam) { customSearchParams += ","; }

	customSearchParams += this.getCustomSearchNV('ICABNSEARCHRESULT', '1');
	customSearchParams += ']}';
	return customSearchParams;
},

// get NV for custom search param
getCustomSearchNV:function(paramName, paramValue)
{
    return "{\"name\":\"" + paramName + "\",\"value\":\"" + paramValue + "\"}";
},

// submitAction from dropdown menu search results
submitABNAction:function(form,name)
{
	if (!/\/h\/\?tab=/.test(location)) { 
		parent.pthNav.abn.search.doSubmitABN(name);
	} else {
		pthNav.abn.search.doSubmitABN(name);
	}
},

isClass:function(el,cName) {
  if (!el) { return false; }

  
  var classes = el.className;
  if (!classes) { return false; }
		
  
  if (classes === cName) { return true; }

  
  var whiteSpace = /\s+/;
  if (!whiteSpace.test(classes)) { return false; }

  
  
  var c = classes.split(whiteSpace);
  for (var i = 0; i < c.length; i++) {
    if (c[i] === cName) { return true; }
  }
  return false;
},

clearABNSearchResults:function() {
	try { 
		var dn = top.document.domain;
		try { 
			if (typeof(top.pthNav) !== "undefined" && 
				typeof(top.pthNav.abn) !== "undefined" && 
				typeof(top.pthNav.abn.search) !== "undefined") { 
				top.pthNav.abn.search.clearData(true);
			}	 
		} catch (ex2) {} 
	} catch (ex1) {}
},
//is PIA prompt req
isPromptReq:function(name)
{
if  ((name && (name.indexOf("$prompt")!=-1 || name == '#KEYA5')) && !this.isHTMLTemplate)
    return true;
else
    return false;
},
//for PIA collasible group box
expcolGrp:function(id,colurl,colalt,expurl,expalt)
{
var objGrp = document.getElementById("divgrp"+id);
var objimg = document.getElementById(id+"$img");
if (objGrp.style.display=="none")
{
    objGrp.style.display="block";
    objimg.src = colurl;
    objimg.title = colalt;
    objimg.alt = colalt;
}
else
{
    objGrp.style.display="none";
    objimg.src = expurl;
    objimg.title = expalt;
    objimg.alt = expalt;
}
},

// update multiple select values for prompt modal window
updateMultiSelectValues:function(form,fieldValue)
{
window.parent.popupObj_win0.updateMultiSelectValues(fieldValue);
},

// update prompt edit field
updatePrompt:function(form,fieldValue)
{
if (this.isHTMLTemplate &&
    window.parent.popupObj_win0 != "undefined" &&
    !window.parent.popupObj_win0.isShown)
    
    
    submitAction_win0(form,fieldValue);
else if (typeof form == 'undefined' && typeof fieldValue == 'undefined') {
    
    
    theForm = document.getElementById("popupFrame").contentWindow.document.win0;
    popupObj_win0.updatePrompt(theForm, "#ICCancel");
    }
else if (typeof fieldValue != 'undefined' &&  popupObj_win0.bPromptMessageOpen == true){
    popupObj_win0.updatePrompt(form, fieldValue);
    }
else
    window.parent.popupObj_win0.updatePrompt(form, fieldValue);
},

moveWindow:function(obj)
{
	obj.onmousemove = null;
	if ((typeof ptEvent != "undefined") && (typeof(window.parent.popupObj_win0) != "undefined")) {
		if (window.parent.popupObj_win0.isModalWidget)
			window.parent.popupObj_win0.setResizeEvent_win0(obj);
	}
	else if ((typeof ptEvent != "undefined") && (typeof(popupObj_win0) != "undefined")) {
		if (popupObj_win0.isModalWidget)
			popupObj_win0.setResizeEvent_win0(obj);
	}
},

// close a non-prompt modal window
endModalCntrl:function(form,fieldValue,bModalElement)
{
if (typeof CKEDITOR != 'undefined') UpdateEditorLinkedField();
if (typeof bModalElement == 'undefined') {
    if (typeof form != "undefined") { //Not the close button
        if (typeof form.ICModalOrgContent != "undefined" && typeof form.ICModalNewContent != "undefined" && typeof form.ICModalWidget != "undefined" && form.ICModalOrgContent.value == form.ICModalNewContent.value)
            form.ICModalWidget.value = "0";
        
        if (window.name=='popupFrameWidget' &&  typeof form.ICZoomGrid != 'undefined' && form.ICZoomGrid.value)
           {
           if (typeof window.parent.popupObj_win0 != 'undefined' && typeof window.popupObj_win0 != 'undefined' && typeof window.popupModalObj_win0 != 'undefined')
               {
               if (!window.popupObj_win0.isShown && !window.popupModalObj_win0.isShown && !window.popupObj_win0.bPromptPageOpen && !window.popupObj_win0.bPromptMessageOpen && window.parent.popupObj_win0.isShown && window.parent.popupObj_win0.launchedFromModal)
                   {
                   if (typeof form.ICModalWidget != 'undefined')
                        form.ICModalWidget.value=0;
                   form.ICZoomGrid.value=0;
                   }
               }
           }
        
        else if (window.name ==	'TargetContent' &&  typeof form.ICZoomGrid != 'undefined' && form.ICZoomGrid.value)
           {
           if (typeof window.popupObj_win0 != 'undefined' && typeof window.popupModalObj_win0 != 'undefined')
               {
               if (!window.popupObj_win0.isShown && !window.popupModalObj_win0.isShown && !window.popupObj_win0.bPromptPageOpen && !window.popupObj_win0.bPromptMessageOpen)
                   {
                   if (typeof form.ICModalWidget != 'undefined')
                        form.ICModalWidget.value=0;
                   form.ICZoomGrid.value=0;
                   }
               }
           }

        if (window.parent.popupObj_win0 != undefined) {
            window.parent.popupObj_win0.endModalCntrl(form, fieldValue);
            }
        else
            popupObj_win0.endModalCntrl(form, fieldValue);
        }
     else {  //Close button clicked
          
          
          
          var theiFrame = document.getElementById("popupFrameWidget");
          if (typeof theiFrame == "undefined" || theiFrame != null) {
            var n_iFrames = document.getElementById("popupFrameWidget").contentWindow.length;
            if (n_iFrames > 0)
                var theForm = document.getElementById("popupFrameWidget").contentWindow.document.win0;
            }

          if (typeof theForm != "undefined") {
            
            
            
            
            if (theForm.ICModalOrgContent.value == theForm.ICModalNewContent.value)
                theForm.ICModalWidget.value = "0";

           if (window.parent.popupObj_win0 != undefined)
                window.parent.popupObj_win0.endModalCntrl(theForm, '#ICCancel');
           else
                popupObj_win0.endModalCntrl(theForm, '#ICCancel');
          }
          else {
            
            
            
            
            
            
            
            
            
            
            if (typeof popupObj_empty != "undefined")
                popupObj_empty.endModalCntrl();
            else
                popupObj_win0.endModalCntrl();
          }
        }
    }
else {
    form.ICModalWidget.value = "0";
    form.ICZoomGrid.value = "0";
    popupModalObj_win0.endModalCntrl(form, fieldValue, bModalElement);
    popupModalObj_win0.isModalWidget = false;
    popupModalObj_win0.isModalElement = false;
    }

},

//get name and  value pair from the url
getParam:function(url,name)
{
    var queryString = null;
    if (url.indexOf("?")!=-1)
       queryString = new String(url.substring(url.indexOf("?")+1,url.length));
    var paramList = null;
    if (queryString)
        paramList = queryString.split("&");
    if (paramList)
    {
        for (var j = 0; j < paramList.length; j++)
        {
            var tmp = new String(paramList[j]);
            if (tmp.indexOf(name+"=")!=-1)
            {
               return tmp.substring(tmp.indexOf(name+"=")+name.length+1,tmp.length);
            }
        }
    }
    return null;
},
canFocus:function(obj)
{
if (!obj) return false;
if (!obj.type && !obj.href) return false;
if (obj && typeof obj.focus != "undefined" && !obj.disabled && obj.style.visibility!="hidden")
    return true;
else
    return false;
},
getPixValue:function(v)
{
if (v && (v.indexOf('px')!=-1 || v.indexOf('em')!=-1 ))
    return new Number(v.substring(0,v.length-2).valueOf());
else
    return new Number(v.valueOf());
},
getHeight:function(o)
{
if (!o || typeof o == 'undefined') return 0;
var h=o.style.height;
return this.getPixValue(h);
},
terminateEvent:function(e)
{
e = e || window.event;
if (e.stopPropagation != undefined) e.stopPropagation();
else if (e.cancelBubble != undefined) e.cancelBubble = true;
if (e.preventDefault != undefined) e.preventDefault();
else e.returnValue = false;
},
isGridEl:function(evt,objid)
{
if (typeof ptGridObj_win0 == "undefined" || !ptGridObj_win0)
	return null;

if (typeof gridList_win0 == "undefined" || typeof gridFieldList_win0 == "undefined")
	return null;

var obj = null;
var id = '';
var nRowCnt = 0;
var idarr = '';

if (!objid || typeof objid == "undefined") {
    obj = getEventTarget(evt);
    if (!obj || !obj.id) return null;
    id = obj.id;
    nRowCnt = 0;
    idarr = id.split("$");
    if (idarr.length<2) return null;
    if (isNaN(idarr[1]))
        nRowCnt = idarr[2];
    else
        nRowCnt = idarr[1];
}
else {
    id = objid;
    idarr = id.split("$");
    if (idarr.length<2) return null;
    nRowCnt = idarr[1];
}

for (var i = 0; i < gridList_win0.length; i++)
{
var gn = gridList_win0[i][0];
var gc = document.getElementById('divgc'+gn);
if (!gc || typeof gc == "undefined") continue;

var gfields = gridFieldList_win0[i];
for (var j = 0; j < gfields.length; j++)
{
    var gfield = gfields[j].replace(/%c/,nRowCnt);
    if (id==gfield)
        return gn;
}
}
return null;
},

getGridRowID:function(oContrl)
{
   var obj = oContrl;
   if (!obj)
       return null;
   if (!obj.id)
       return null;
   if (typeof ptGridObj_win0 == "undefined" || !ptGridObj_win0)
   	   return null;

   if (typeof gridList_win0 == "undefined" || typeof gridFieldList_win0 == "undefined")
	   return null;

   var id = obj.id;
   var nRowCnt = 0;
   var idarr = id.split("$");

   if (idarr.length<2) return null;
   if (idarr.length == 2)
       nRowCnt = idarr[1];
   else if (idarr.length == 5)
       nRowCnt = idarr[2];
   else if (idarr.length == 4)
       nRowCnt = idarr[3];
   else
       nRowCnt = idarr[1];

   for (var i = 0; i < gridList_win0.length; i++)
      {
      var gn = gridList_win0[i][0];
      var gfields = gridFieldList_win0[i];
      for (var j = 0; j < gfields.length; j++)
         {
         var gfield = gfields[j].replace(/%c/,nRowCnt);
         if (id==gfield)     // control belongs to the grid
              {
              
              while (obj != null && gridList_win0[i][2] >1)      // get row id
                     {
                     if ( (obj.nodeName).indexOf("TR")==0 )
                          return obj.id;
                     else
                          obj = obj.parentNode;
                     } // end of while loop
              return null;
              }  // end of if (id==gfield)
         }  // end of for (var j = 0; j < gfields.length; j++)
      }  // end of for (var i = 0; i < gridList_win0.length; i++)

   return null;
},

isGridNav:function(evt)
{
var gn = this.isGridEl(evt);
if (typeof ptGridObj_win0 != "undefined" && ptGridObj_win0 && gn != null)
{
    evt= (evt)? evt: ((event)? event:null);
    var key = getKeyCode(evt);
    if (isShiftKey(evt) && key<=40 && key>=37)
        return true;
}
return false;
},
fadeElement:function(elID, fade, min_opacity, max_opacity, speed, istep){
  var step;
  var t = 0;
  if ((typeof(istep) == "undefined") || (istep == null))
    istep=1;
  if (fade) {
    // fade out
    for (step = max_opacity; step >= min_opacity; step=step-istep) {
      setTimeout("ptCommonObj.setOpaq('" + elID + "', " + step + ")", (t*speed));  //translucent
      t++;
    }
  }else {
    // fade in
    for (step = min_opacity; step <= max_opacity; step=step+istep) {
      setTimeout("ptCommonObj.setOpaq('" + elID + "', " + step + ")", (t*speed));  //display
      t++;
    }
  }
  return t;
},
setOpaq:function(elID, opacity) {
  var el = document.getElementById(elID);
  el.style.opacity = (opacity / 100);
  el.style.filter="alpha(opacity=" + opacity + ")";
},
initTypeAhead:function(oWin,form)
{
    if (!form) return;
    if (!form.ICTypeAheadID) return;

    
    if (typeof PFieldList_win0!='undefined' && PFieldList_win0) {
        for (var i = 0; i < PFieldList_win0.length; i++) {
            var fname = PFieldList_win0[i][0];
            var nStop = PFieldList_win0[i][1];
                for (var j=0; j<nStop; j++) {
                    var name = fname;
                    var nsuffix = "";
                    if (nStop>1) {
                        nsuffix = '$'+j;
                        name = fname+nsuffix;
                    } else if (oWin.document.getElementById(fname+'$'+j)) {
                        nsuffix = '$'+j;
                        name = fname+nsuffix;
                    }
                    var el = oWin.document.getElementById(name);
                    if (!el) break;
					if (el.type!='text') continue; 
					if (el.obj) continue;
                    var icAction = fname+"$prompt"+nsuffix;
                    var serverScript = "ptTAObj_win0.oWin.pAction_win0(ptTAObj_win0.oDoc.win0,'"+icAction+"');";
                    if (el)
                        el.obj=oWin.ptTAObj_win0.SetProperties(el,0,form.ICTypeAheadID,serverScript,true,false,false,true,true,500);   //default search 'Begin with'

            }
        }
        if (oWin.document.win0.ICActionPrompt.value=='true')
            oWin.ptTAObj_win0.OnPromptLaunch(oWin.document);
    }

    
    if (this.isSearchSearchPage(form)) {
        
        if (typeof EFieldList_win0!='undefined' && EFieldList_win0) {
            for (var i = 0; i < EFieldList_win0.length; i++) {
                var fname = EFieldList_win0[i][0];
                var nStop = EFieldList_win0[i][1];
                    for (var j=0; j<nStop; j++) {
                        var name = fname;
                        var nsuffix = "";
                        if (nStop>1) {
                            nsuffix = '$'+j;
                            name = fname+nsuffix;
                        } else if (oWin.document.getElementById(fname+'$'+j)) {
                            nsuffix = '$'+j;
                            name = fname+nsuffix;
                        }
                        var el = oWin.document.getElementById(name);
                        if (!el || el.type!='text' || el.obj) continue;
                        var icAction = '#ICSrchTypAhd';
                        var serverScript = "ptTAObj_win0.oWin.aAction_win0(ptTAObj_win0.oDoc.win0,'#ICSrchTypAhd');";
                        el.obj=oWin.ptTAObj_win0.SetProperties(el,0,form.ICTypeAheadID,serverScript,true,false,false,true,true,500);   //default search 'Begin with'
                }
            }
        }
    }
},
initTypeAheadEl: function(el) {
        var oWin = window;
        var oDoc = document;
        var form = document.win0;
        var pId = el.name + "$prompt";
        if (document.getElementById(pId))
            icAction = pId;
        else if (ptCommonObj.isSearchSearchPage(form)) 
            icAction = '#ICSrchTypAhd';
        else 
            {
            var nsuffixIndex = el.name.lastIndexOf('$');
            if (nsuffixIndex > -1)
                {
                var fname = el.name.slice(0, nsuffixIndex);
                var nsuffix = el.name.slice(nsuffixIndex + 1, el.name.length);
                }
            else
                var fname = el.name;
            icAction = fname + "$prompt";
            if (nsuffixIndex > -1)
                icAction += "$" + nsuffix;
            }
        var serverScript = "ptTAObj_win0.oWin.pAction_win0(ptTAObj_win0.oDoc.win0,'" + icAction + "');";
        el.obj = oWin.ptTAObj_win0.SetProperties(el, 0, form.ICTypeAheadID, serverScript, true, false, false, true, true, 500); //default search 'Begin with'
 },

 isTypeAheadEvtTgt: function(el) {
        if (el && el.form && !el.form.ICTypeAheadID) return false;
        if (!el || el.type != 'text') return false;
        if (typeof el.obj != 'undefined')
            return true;
        else if (typeof PFieldList_win0 != 'undefined' && PFieldList_win0) {
            var fname = el.name.split('$')[0];
            for (var i = 0; i < PFieldList_win0.length; i++) {
                if (fname == PFieldList_win0[i][0] || el.name == PFieldList_win0[i][0]) {
                    ptCommonObj.initTypeAheadEl(el);
                    return true;
                }
            }
		}
        if (this.isSearchSearchPage(el.form)) {
            if (typeof EFieldList_win0 != 'undefined' && EFieldList_win0) {
                for (var i = 0; i < EFieldList_win0.length; i++) {
                    if (fname == EFieldList_win0[i][0] || el.name == EFieldList_win0[i][0]) {
                        ptCommonObj.initTypeAheadEl(el);
                        return true;
                    }
                }
            }
        }
        return false;
 },

/*isTypeAheadEvtTgt:function(el)
{
    if (el && el.form && !el.form.ICTypeAheadID) return false;
    if (!el || el.type!='text')  return false;
    if (el.obj) return true;
    return false;
},*/
isTypeAheadEl:function(evt)
{
    var el = getEventTarget(evt);
	return this.isTypeAheadEvtTgt(el);
},
isTypeAheadField:function(id)
{
 	var el = document.getElementById(id);
  	return this.isTypeAheadEvtTgt(el);
},
cleanUpModalElement:function(name)
{
    
    
    
    
    if (popupModalObj_win0 &&
        popupModalObj_win0 != 'undefined' &&
        popupModalObj_win0.isModalElement &&
        name.indexOf('$hexcel')!=-1)
            {
            popupModalObj_win0.form.ICModalWidget.value = "0";
            popupModalObj_win0.isModalWidget = false;
            popupModalObj_win0.isModalElement = false;
            }
    },
getFormName:function() {
	return "win0";
}
}

function PT_RC()
{}

PT_RC.prototype = {
    
    isEnabled:function() {

        var bIsEnabled = false;

        
        if ( (window.top.document.getElementById('ptifrmtarget') == null) &&
             (window.top.document.getElementById('TargetContentFrame') == null) ) {
            return bIsEnabled;
        }

        
        if (typeof window.top.ptrc.onAddChangeEvent != 'function') {
            return bIsEnabled;
        }

        bIsEnabled = true;

        return bIsEnabled;
    },

    
    isFrame:function() {
        return (window.top.document.getElementById('TargetContentFrame') != null) ? true : false;
    },

    
    isIFrame:function() {
        return  ((window.top.document.getElementById('ptifrmtarget') != null) ? true:false);
    }
}

function ptLoadingStatus_win0(display)
{
clearupTimeout(); // clear timers for session timeout when request is submitted.
var objFrame =  top.frames['TargetContent'];
var waitobj = null;
if ((typeof(window.parent.popupObj_win0) != "undefined") &&
    window.parent.popupObj_win0.isShown) {
   
   waitobj = document.getElementById("WAIT_win0");
}
else if (objFrame) {
   waitobj = objFrame.document.getElementById("WAIT_win0");
}
else {
   waitobj = document.getElementById("WAIT_win0");
}

if (waitobj) {
  if ((typeof display == "undefined") || (display != 0)) {
    waitobj.style.top = getYScroll();
    var x = getXScroll();
    waitobj.style.right = (x > 0) ? (0 - x) : x;
    waitobj.style.display="block";
    waitobj.style.visibility="visible";
  }
  else {
    waitobj.style.display="none";
    waitobj.style.visibility="hidden";
  }
}
}

function getYScroll(){
return window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop || 0;
}

function getXScroll(){
return window.pageXOffset || document.body.scrollLeft || document.documentElement.scrollLeft || 0;
}

function positionWAIT_win0(){
var waitobj = null;
var savedobj = null;
var objFrame =  top.frames['TargetContent'];
if (objFrame) {
  waitobj = objFrame.document.getElementById("WAIT_win0");
  savedobj = objFrame.document.getElementById("SAVED_win0");
}
else {
  waitobj = document.getElementById("WAIT_win0");
  savedobj = document.getElementById("SAVED_win0");
}

if (waitobj && waitobj.style.display != "none" && waitobj.style.visibility != "hidden")
  keepObjTopRight(waitobj);
if (savedobj && savedobj.style.display != "none" && savedobj.style.visibility != "hidden")
  keepObjTopRight(savedobj);

}


function keepObjTopRight(waitobj) {
   waitobj.style.position = "absolute";
   if (window.frames.length)
       waitobj.style.top = document.body.scrollTop + "px";
   else {
       if (document.body.scrollTop >= 50)
           waitobj.style.top = document.body.scrollTop + "px";
       else
           waitobj.style.top = 50 + "px";
   }
   waitobj.style.right = (document.body.scrollLeft > 0) ? ((0-document.body.scrollLeft) + "px") : (document.body.scrollLeft + "px");
}


PT_createStandardObjects();     


if (typeof(ptEvent) === "undefined") {
var ptEvent = {
	fnList : [],
	huid: 100,
	hList: {},
	done: false,
	init : function () {

		if (!ptEvent.done) {
			ptEvent.done = true;

			if (ptEvent.fnList) {
				for ( var i = 0, fl = ptEvent.fnList.length; i < fl; i++ ) {
					ptEvent.fnList[i].apply(document);
				}
				ptEvent.fnList = null;
			}

			
			ptEvent.add(window, "unload", ptEvent.remove);

			
			if (browserInfoObj.isMozilla) {
				document.removeEventListener( "DOMContentLoaded", ptEvent.init, false );
			}
		}
	},

	load : function (f) {

		if (ptEvent.done) {
			f.apply(document);
		} else {
		   ptEvent.fnList.push(f);
		}
	},

    onDOMLoad : function (f) {
	  if ((browserInfoObj.isSafari) && (document.readyState == "complete")){
		
		ptEvent.safariTimer = setInterval(function () {
	        
			ptEvent.load(f);
		    
			clearInterval(ptEvent.safariTimer);
			ptEvent.safariTimer = null;			
		}, 10); 
      }
	  else
	    ptEvent.load(f);
	},

	
	add : function (element, type, data) {

		
		
		if (browserInfoObj.isIE && element.setInterval != undefined)
			element = window;

		if (data) {
			handler = data;
			handler.data = data;
		}

		
		if ( !handler.huid )
			handler.huid = this.huid++;

		
		if (!element.events) {
			element.events = {};
		}

		if (!element.handle) {
			element.handle = function() { 

				
				var retVal;
	
				
				if (typeof ptEvent == "undefined") {
					return retVal;
				}
	               
				retVal = ptEvent.handle.apply(element,arguments);
				return retVal;
			 };
		}

		
		var handlers = element.events[type];

		
        if (!handlers) {
	        handlers = element.events[type] = {}; 
	           
	        
			if (element.attachEvent) {
				element.attachEvent("on" + type, element.handle);
			} else if (element.addEventListener) {
				element.addEventListener(type, element.handle, false);
			}
        }

		
		handlers[handler.huid] = handler;
	},

	
	remove : function (element, type, handler) {

		var elEvents = element.events, ret;
		if (elEvents) {

			
			if (type && type.type) {
				handler = type.handler;
				type = type.type;
			}
	           
			if (!type) {
				for (type in elEvents) {
					this.remove( element, type );
				}
			} else if (elEvents[type]) {

				
				if (handler) {
					delete elEvents[type][handler.huid];
				} else {
	               
					
					for (handler in element.events[type]) {
						delete elEvents[type][handler];
					}
				}
	
				
				for (ret in elEvents[type]) { 
					break;
				}

				if (!ret) {

					if (element.detachEvent) {
						element.detachEvent("on" + type,element.handle);
					} else if (element.removeEventListener) {
						element.removeEventListener(type,element.handle,false);
					}

					ret = null;
					delete elEvents[type];
				}
			}
	
			
			for ( ret in elEvents ) {
				break;
			}

			if ( !ret ) {
				element.handle = element.events = null;
			}
		}
	},

	
	handle : function (event) {

		var retVal;

		
		event = ptEvent.fix(event || window.event || {}); 

		var c = this.events && this.events[event.type];

		var args = [].slice.call(arguments,1);
		args.unshift(event);

		for (var j in c) {
			
			

			var temp = c[j];

			args[0].handler = c[j];
			args[0].data = c[j].data;

			
			var hRetVal = c[j].apply( this, args );
	
            if ( retVal !== false ) {
                retVal = hRetVal;
			}
	
            if ( hRetVal === false ) {
                event.preventDefault();
                event.stopPropagation();
            }
		}

		
		if (browserInfoObj.isIE) {
			event.target = event.preventDefault = event.stopPropagation = 
			event.handler = event.data = null;
       	}
		return retVal;
	},

	
	fix : function (event) {

		
		if (!event.target && event.srcElement)
			event.target = event.srcElement;

		
		if (event.pageX == undefined && event.clientX != undefined) {
            if (typeof document == "undefined" || typeof document == "unknown") return event;
			var e = document.documentElement, b = document.body;
			event.pageX = event.clientX + (e.scrollLeft || b.scrollLeft);
			event.pageY = event.clientY + (e.scrollTop || b.scrollTop);
		}
				
		
		if (browserInfoObj.isSafari && event.target.nodeType == 3) {

			
			
			var originalEvent = event;
			event = {};
			event = originalEvent;
			
			
			event.target = originalEvent.target.parentNode;
			
			
			
			event.preventDefault = function() {
				return originalEvent.preventDefault();
			};
			event.stopPropagation = function() {
				return originalEvent.stopPropagation();
			};
		}
		
		
		if (!event.preventDefault)
			event.preventDefault = function () { event.returnValue = false; };
			
		if (!event.stopPropagation)
			event.stopPropagation = function () { event.cancelBubble = true; };
		return event;
	}
}; 

new function () {
	
	if (browserInfoObj.isMozilla) {
		document.addEventListener( "DOMContentLoaded", ptEvent.init, false );

	
	} else if (browserInfoObj.isIE && window == top) {
		(function(){
			if (ptEvent.done) { return; }

			try {
				
				document.documentElement.doScroll("left");
			} catch( error ) {
				setTimeout( arguments.callee, 0 );
				return;
			}
			
			ptEvent.init();
		})();

	
	
	} else if (browserInfoObj.isSafari) {
		
		ptEvent.safariTimer = setInterval(function () {

				
				if ( document.readyState == "loaded" || 
					document.readyState == "complete" ) {
	
					
					clearInterval(ptEvent.safariTimer);
					ptEvent.safariTimer = null;
	
					
					ptEvent.init();
				}
			}, 10); 
	}
	ptEvent.add(window,"load",ptEvent.init);
}; 
} 

var ptUtil = {
	
	
	
	
	id : function (s) {
		if (typeof s == "string") { return document.getElementById(s); }
		return s;
	},

	
	
	
	
	
	getElems : function (pNode,crit) {

		var elems = [];
		var elName;
		var cName;
		var id;
		var t;

		if (!pNode || !crit) return elems;
		
		
		var re = /^([a-z0-9_-]+)(.)([a-z0-9\\*_-]*)/i;
		var m = re.exec(crit);

		if (m && m[2] === ".") {
			elName = m[1];
			cName = m[3];
		} else {
			
			re = /^([a-z0-9_-]+)(#)([a-z0-9\\*_-]*)/i;
			m = re.exec(crit);
			if (m && m[2] === "#") {
				elName = m[1];
				id = m[3];
			} else {
				
				elName = crit;
			}
		}
			
		if (elName || cName) {
			var cNode;
			for (var i = 0; i < pNode.childNodes.length; i++) {
				cNode = pNode.childNodes[i];

				
				if (cNode.nodeType === 1) {
					
					if (elName && cName) {
						if (cNode.nodeName.toLowerCase() === elName && 
							ptUtil.isClassMember(cNode,cName)) {
							elems.push(cNode);
						}
					} else if (elName && cNode.nodeName.toLowerCase() === elName) {
						elems.push(cNode);
					} else if (ptUtil.isClassMember(cNode,cName)) { 
						elems.push(cNode);
					}
					
					
					t = ptUtil.getElems(cNode,crit);
					if (t[0]) elems = elems.concat(t);
				}
			}
		} else if (id) {
			
			elems.push(ptUtil.id(id));
		}
		return elems;
	},

	
	
	
	
	appendHTML : function (pNode,html,cNodeTag) {
	
		if (!pNode || !html) return;

		if (cNodeTag) {
			
			var elems = ptUtil.getElems(pNode,cNodeTag);
			for (var i = 0; i < elems.length; i++) {
				ptUtil.appendNodeFromHTML(elems[i],html);
			}	
		} else {
			ptUtil.appendNodeFromHTML(pNode,html);
		}
	},

	appendNodeFromHTML : function (n,html) {
	
		
		if ( html && typeof html == "string" ) {

			var div = document.createElement("div");
			div.innerHTML = html;
			div = div.firstChild;
			n.appendChild(div);
		}
	},		

	
	
	
	
	
	
	swapClass : function (pNode,fClass,tClass,cNodeTag) {

		
		if (!pNode || !fClass || !tClass) return;	

		if (cNodeTag) {
			var elems = ptUtil.getElems(pNode,cNodeTag);
			for (var i = 0; i < elems.length; i++) {
				ptUtil.removeClass(elems[i],fClass);
				ptUtil.addClass(elems[i],tClass);
			}
		} else {
			ptUtil.removeClass(pNode,fClass);
			ptUtil.addClass(pNode,tClass);
		}
	},

	
	
	
	addClass : function (el, cName) {
		
		if (el && !ptUtil.isClassMember(el,cName)) {

			if (el.className) {
				
				el.className = el.className.replace(/^\s+|\s+$/g, "");
				el.className += " " + cName;
			} else {
				el.className += "" + cName;
			}
		}
	},

	
	
	
	removeClass : function (el, cName) {

		
		
		
		if (el) {
			el.className = el.className.replace(new RegExp("\\b"+ cName+"\\b\\s*", "g"), "");
		}
	},

	
	
	
	isClassMember : function (el, cName) {

		if (!el) { return false; }

		
		var classes = el.className;
		if (!classes) { return false; }
		
		
		if (classes === cName) { return true; }

		
		var whiteSpace = /\s+/;
		if (!whiteSpace.test(classes)) { return false; }

		
		
		var c = classes.split(whiteSpace);
		for (var i = 0; i < c.length; i++) {
			if (c[i] === cName) { return true; }
		}
		return false;

	},

	
	getElemsByClass : function (searchClass,node,tag) {

		var classElems = [];

		if (!node) { node = document; }

		if (!tag) {	tag = "*"; }

		var els = node.getElementsByTagName(tag);
		var pattern = new RegExp("(^|\\s)" + searchClass + "(\\s|$)");

		for (var i = 0, j = els.length; i < j; i++) {
			if (pattern.test(els[i].className) ) { classElems.push(els[i]); }
		}
		return classElems;
	},

	
	
	
	getCSSValue : function (el,prop) {
	
		var cssProp = prop;
		var retVal = null;
		
		if (cssProp === "float") {
			cssProp = browserInfoObj.isIE ? "styleFloat" : "cssFloat";
		}
		
		if (el.style[cssProp]) {
			retVal = el.style[cssProp];

	  	
 		} else if (el.currentStyle) {
			retVal = el.currentStyle[cssProp];

			
			
			if ( !/^\d+(px)?$/i.test(retVal) && /^\d/.test(retVal) ) {

				
				var left = el.style.left, rsLeft = el.runtimeStyle.left;

				
				el.runtimeStyle.left = el.currentStyle.left;
				el.style.left = retVal || 0;
				retVal = el.style.pixelLeft + "px";

				
				el.style.left = left;
				el.runtimeStyle.left = rsLeft;
			}

		
		} else if (document.defaultView && document.defaultView.getComputedStyle) {
			retVal = document.defaultView.getComputedStyle(el,"")[cssProp];
		}
		return retVal;

	},

	
	
	
	
	setCSSValue : function (el,prop,value) {

		var cssProp = prop;
		if (cssProp === "float") {
			cssProp = browserInfoObj.isIE ? "styleFloat" : "cssFloat";
		}

		el.style[cssProp] = value;

	},

	
	winSize : function () {

		var de = document.documentElement;
		var height = window.innerHeight || self.innerHeight || (de && de.clientHeight) || document.body.clientHeight;
		var width = window.innerWidth || self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
		return {height:height, width:width};
	},	

	
	getNextSibling : function (node,nodeType,styleClass) {

		if (!node) { return null; }
	
		var sibling = node.nextSibling;
		while (sibling) {
			if (sibling.nodeName.toLowerCase() === nodeType) {
				if (styleClass && styleClass !== "") {
					if (this.isClassMember(sibling,styleClass)) {
						return sibling;
					}
				} else {	
					return sibling;
				}
			}
			sibling = sibling.nextSibling;
		}
		return null;
	},

	
	getPrevSibling : function (node,nodeType,styleClass) {

		if (!node) { return null; }
	
		var sibling = node.previousSibling;
		while (sibling) {
			if (sibling.nodeName.toLowerCase() === nodeType) {
				if (styleClass && styleClass !== "") {
					if (this.isClassMember(sibling,styleClass)) {
						return sibling;
					}
				} else {	
					return sibling;
				}
			}
			sibling = sibling.previousSibling;
		}
		return null;
	},

	
	getGrandParent : function (pNode) {
		if (pNode.parentNode) 
			return pNode.parentNode.parentNode;
		else
			return null;
	},

    	
	getFirstChild : function (node) {
		var firstChild;
		if (node.firstElementChild) {
			firstChild = node.firstElementChild;
		} else {
			firstChild = node.firstChild;
			while (firstChild && firstChild.nodeType !== 1) {
				firstChild = firstChild.nextSibling;
			}
		}
		return firstChild;
	},

	
	getKeyCode : function (evt) {

		if (!evt && window.event) {	evt = window.event; }
		if (!evt) {	return 0; }
		if (evt.keyCode) { return evt.keyCode; }
		if (evt.which) { return evt.which; }
		return 0;
	},

	
	isAltKey : function (evt) {

		if (!evt && window.event) {	evt = window.event; }
		if (!evt) {	return false; }
		if (evt.altKey) { return true; }
		if (evt.modifiers) { return (evt.modifiers & Event.ALT_MASK) != 0; }
		return false;
	},

	
	isCtrlKey : function (evt) {

		if (!evt && window.event) {	evt = window.event; }
		if (!evt) {	return false; }
		if (evt.ctrlKey) { return true; }
		if (evt.modifiers) { return (evt.modifiers & Event.CONTROL_MASK) != 0; }
		return false;
	},

	
	isShiftKey : function (evt) {

		if (!evt && window.event) {	evt = window.event; }
		if (!evt) { return false; }
		if (evt.shiftKey) { return true; }
		if (evt.modifiers) { return (evt.modifiers & Event.SHIFT_MASK) != 0; }
		return false;
	}
}; 

PTRTE_CheckImages = function (URI, UrlID, EditorField)
{
  
  if ((typeof URI == "undefined") || (URI == "")) URI = location.href;
  if ((typeof UrlID == "undefined") || (UrlID == "")) UrlID = "PT_RTE_IMG_DB_LOC";

  
  var baseUri = URI.replace("psp", "psc");
  var serverUri = baseUri.split("/psc/")[0];
  baseUri = serverUri + baseUri.match(/\/ps(c|p)\/?([^\/]*)?\/?([^\/]*)?\/?([^\/]*)?\//)[0];
  var URLoc = baseUri + "s/WEBLIB_PTRTE.ISCRIPT1.FieldFormula.IScript_RTE_IMAGE_ATTACH?URLId=" + UrlID;
  var psSiteName = (URI.split("/"))[4];
  psSiteName = (psSiteName.split("_"))[0];

  
  var objEditorField = null;
  if ((typeof EditorField != "undefined") && (EditorField != "")) {
    objEditorField = document.getElementById(EditorField);
  }
  if (objEditorField == null) {
    objEditorField = document.body;
  }

  
  var objImages = objEditorField.getElementsByTagName('img');

  
  if (typeof document.body.RTFImages == "undefined") document.body.RTFImages = new Array(0);

  
  var imgStr = "";
  for (var i=0; i<objImages.length; i++) {
    var img = objImages[i];

    if ((!img.id) || (!img.src)) continue;

    var tempval = img.id.split("###");
    var ImgID = tempval[0];
    var filename = tempval[1];

    if ((UrlID == ImgID) && !img.PTRTEImageVerified) {
      img.PTRTEImageVerified = "PENDING";

      imgStr = imgStr + "&Params=" + filename;

      document.body.RTFImages.push(img);

      
      tempval = img.src.split("/");
      img.oracletempimagesrc = serverUri + "/cs/" + psSiteName + "/cache/" + tempval[tempval.length-1];
    }
  }

  
  if (imgStr != "") {
    var PTRTELoader = new net.ContentLoader(
      URLoc + imgStr,
      null, null, "GET",
      function () {
        
        
        if (typeof document.body.RTFImages != "undefined") {
          for (var i=0; i<document.body.RTFImages.length; i++) {
            var img = document.body.RTFImages[i];
            if ((img) && (typeof img.oracletempimagesrc != "undefined")) {
              if (img.src != img.oracletempimagesrc) {
                img.src = img.oracletempimagesrc;
              } else {
                img.src = img.oracletempimagesrc + "?reload";
              }
              img.PTRTEImageVerified = "DONE";
            }
          }
        }
      },
      function () {
        
      },
      null,
      "application/x-www-form-urlencoded"
    );
  }
} 

function getptBaseURI()
{
	var ptBaseURI = "";
	var nPos = String(location).indexOf('\/psp\/');
	if (nPos != -1)
	{
		ptBaseURI = String(location).substr(nPos,String(location).length);
		var addressLoc = String(ptBaseURI).match(/\/ps(c|p)\/?([^\/]*)?\/?([^\/]*)?\/?([^\/]*)?\//);
		if (addressLoc)
			ptBaseURI = addressLoc[0].replace('\/psp\/','\/psc\/');
		else 
			ptBaseURI = "";
	}
	else 
		ptBaseURI = String(location).match(/\/ps(c|p)\/?([^\/]*)?\/?([^\/]*)?\/?([^\/]*)?\//)[0].replace('psp','psc');
		
	return ptBaseURI;
}
