//**********************************************************************
// ThePort Utilities.  
// Author: Steve Soares
//**********************************************************************
// Copyright ThePort Inc.
////////////////////////////////////////////////////////////////////////
// Version History.
////////////////////////////////////////////////////////////////////////
//**********************************************************************

  function SizeChecker(ifElem) { 
    this.m_interval   = null;
    this.m_elem       = ifElem;
    this.m_lastHeight = -1;
    } 

  SizeChecker.prototype.setInterval = function(delay) { 
    if (this.m_interval) return;
    var m_obj  = this; 
    
    function timerRelay() { 
      m_obj.handleTimer(m_obj); 
      }
    this.m_interval   = setInterval(timerRelay, delay); 
    } 

  SizeChecker.prototype.clearInterval = function() { 
    if (this.m_interval)
      clearInterval(this.m_interval);
    this.m_interval   = null;
  }

  SizeChecker.prototype.handleTimer = function(obj) 
  {
    try {
    var width;
    var height;
    var scrollHeight;
    var offsetHeight;

    
    var elem= obj.m_elem;
    if (elem) {
      if (Prototype.Browser.IE) {
        height = elem.contentWindow.document.body.scrollHeight;
      }
      else {
  //        if (elem.contentWindow.document.height)
  //            height = elem.contentWindow.document.height;
  //        else 
          if (elem.contentWindow.document.body){
                if (elem.contentWindow.document.body.scrollHeight)
                    height = scrollHeight = elem.contentWindow.document.body.scrollHeight;
                if (elem.contentWindow.document.body.offsetHeight)
                    height = offsetHeight = elem.contentWindow.document.body.offsetHeight;
                if (scrollHeight && offsetHeight)
                    height = Math.max(scrollHeight, offsetHeight);
                }
          }

      if ((height==void(0))||(height<0)) return;

      //if (obj.m_lastHeight-height>15) {
      if ((height-obj.m_lastHeight>10)||(obj.m_lastHeight-height>10)) {
          elem.height       = height;
          obj.m_lastHeight  = height;
          }
      }
    } catch(e){};
  }
//************************************************************
// ThePort Utilities.  
// Author: Steve Soares
//************************************************************
/////////////////////////////////////////////////////////////
// Version History.
/////////////////////////////////////////////////////////////
//
// October 27, 2006 Initial Version.
//***************************************************************


//*******************************************************************
//*******************************************************************
var ThePortCookie = {  


//***********************************************************
//
//***********************************************************
setCookie: function (name,value,domain,expires) {
	var doc = document;
	//try{if (top != self){doc=top.document}} catch(e){}	
	//try{if (top != self){doc=doc.parent}} catch(e){}	
	doc.cookie = name + "=" + value +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((domain) ? "; domain=" + domain : "") +
		"; path=/";

	try{if (top != self){doc=top.document}
		doc.cookie = name + "=" + value +
			((expires) ? "; expires=" + expires.toGMTString() : "") +
			((domain) ? "; domain=" + domain : "") +
			"; path=/";
		} catch(e){}	
},

	
//***********************************************************
//
//***********************************************************
getCookie: function (name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
},



//***********************************************************
//
//***********************************************************
removeCookie: function (name){
var date = new Date();
date.setTime(date.getTime()+(-1*24*60*60*1000));
if (Prototype.Browser.IE) ThePortCookie.setCookie(name," ","",date);
else if (Prototype.Browser.WebKit) document.cookie =  name+"=; expires=Tue, 1 Jan 1980 00:00:00 UTC; path=/";
     else ThePortCookie.setCookie(name," ",document.domain,date);
}	


} // end namespace declaration..//**********************************************************************
// ThePort Utilities.  
// Author: Steve Soares
//**********************************************************************
// Copyright ThePort Inc.
////////////////////////////////////////////////////////////////////////
// Version History.
////////////////////////////////////////////////////////////////////////
//**********************************************************************
// October 27, 2006 Initial Version.
// (Some small functions grabbed from the top 10 javascripts website 
// and other built along the way...
//**********************************************************************

/*********************************************************************************/
//Detect whether there is a "hello" member in the arguments array:
//var parameter = 'hello' in arguments? arguments : "";
// 
//Detect whether arguments contains at least one argument
//var parameter = typeof arguments[0] != 'undefined'? arguments : "";
// 
//Detect whether the user passed an object(can be array) or a list of arguments
//var parameter = (typeof arguments[0] == 'object')? arguments[0] : arguments;
// 
//Detect whether there is an arguments passed into the function and assign the number of arguments into the variable
//var parameter = arguments.length || "";
//
//function Dup(obj)
//{
//   for (prop in obj) {
//      if (typeof(obj[prop]) == "object") {
//         this[prop] = new Dup(obj[prop])
//      } else {
//         this[prop] = obj[prop];
//      }
//   }
//}
//
//// usage 
//var array = new Array( "alkdsjf", "alksdjflasd" );
//var duplicated = new Dup( array );
//
/*********************************************************************************/

//***********************************************************
// Extend Array class.
//***********************************************************
Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};

function ThePortURLDecoder(psEncodeString) 
{
try {
  if ((typeof psEncodeString=="undefined")||(psEncodeString==null)) return null;
  var lsRegExp = /\+/g;
  return decodeURIComponent(String(psEncodeString).replace(lsRegExp, " ")); 
 } catch(e) { return null; }
}

function ThePortXMLEncodeString(string) {
	return string.replace('&','&amp;').replace('<','&lt;').replace('>','&gt;').replace('\'','&apos;').replace('"','&quot;');
}

/*
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}
*/

//********************************************************************
//
//********************************************************************
if (String.prototype.trim==null) String.prototype.trim = function (){
		if(this.length < 1) return "";
		var retVal = new String("");
		retVal = this.rTrim();
		retVal = retVal.lTrim();
		return retVal;
} 


//********************************************************************
//
//********************************************************************
if (String.prototype.rTrim==null) String.prototype.rTrim = function (){
	var w_space   = String.fromCharCode(32);
	var v_length  = this.length;
	var strTemp   = "";
	if(v_length < 0){
	  return "";
	  }
	var iTemp = v_length -1;
	while(iTemp > -1){
	  if(this.charAt(iTemp) == w_space){
    	  }
	  else{
		strTemp = this.substring(0,iTemp +1);
		break;
		}
	  iTemp = iTemp-1;
	  } //End While
	return strTemp;
} 


//********************************************************************
//
//********************************************************************
if (String.prototype.lTrim==null) String.prototype.lTrim = function(){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
	  return"";
	  }
	var v_length  = this.length;
	var strTemp   = "";
	var iTemp     = 0;

	while(iTemp < v_length){
	if(this.charAt(iTemp) == w_space){
	    }
	else{
	    strTemp = this.substring(iTemp,v_length);
	    break;
	    }
	iTemp = iTemp + 1;
	} //End While
	return strTemp;
} 


//********************************************************************
//
//********************************************************************
if (String.prototype.left==null) String.prototype.left = function(n){
	if (n <= 0)
	    return "";
	else if (n > this.length)
	    return this;
	else
	    return this.substring(0,n);
}


//********************************************************************
//
//********************************************************************
if (String.prototype.right==null) String.prototype.right = function(n){
    if (n <= 0)
       return "";
    else if (n > this.length)
       return this;
    else {
       var iLen = this.length;
       
       return this.substring(iLen, iLen - n);
      }
}


//********************************************************************
//
//********************************************************************
var ThePortUtils = {  // Javascript 'Namespace'.

ThePortPopupWindow:null,

OpenThePortPopupWindow:   function (url,w,h) { 
    try {
      if (window.ThePortPopupWindow) {
        window.ThePortPopupWindow.close();
        window.ThePortPopupWindow = null;
        }
    } catch(e){}
    try {
      var mh = h;
      var mw = w;
      var vertpos = (mw/2);
      var horpos = (mh/2);
      var swcalc = (screen.width/2);
      var shcalc = (screen.height/2);
      var tlt = (swcalc-vertpos);
      var tll = (shcalc-horpos);
      ThePortPopupWindow = window.open(url,"","height="+mh+",width="+mw+",top="+tll+",left="+tlt+",screenx="+tll+",screeny="+tlt+",scrollbars=1,resizable=no,dependent=yes,z-lock=yes");
    } catch(e){}
  },

getOuterXML: function (tree) {
  var text = "";
      if((tree.hasChildNodes())||((tree.attributes)&&(tree.attributes.length>0))) {
        text = '<'+tree.tagName;
        if ((tree.attributes)&&(tree.attributes.length>0)) {
          for(var i=0; i<tree.attributes.length; i++) {
            var attr = tree.attributes[i];
            text += " "+attr.nodeName+"='"+getValueFromNode(attr)+"' ";
            }
          }
        text += '>';
          
        //var nodes=tree.childNodes.length;
          if (tree.childNodes.length>0) {
            for(var i=0; i<tree.childNodes.length; i++)
              text+= ThePortUtils.getOuterXML(tree.childNodes[i]);
//            text += tree.text;
            text += '</'+tree.tagName+'>';
            }
        else text += '</'+tree.tagName+'>';
    }
    else {
          var txt = new String(getValueFromNode(tree));
          //txt     = tree.text;
          text   += txt.escapeHTML();
          //text += tree.text.escapeHTML();
         }
  return text;
},

//********************************************************************
//
//********************************************************************
findChildId: function(node, id) {
  try {
    var temp;
    if (node == null) {
      return null;
      }
    node = node.firstChild;
    while (node != null){
      if (node.id == id) {
        return node;
        }
      temp = this.findChildId(node, id);
      if (temp != null){
        return temp;
        }
      node = node.nextSibling;
      }
  }catch(e) { }    
  return null;
},


//********************************************************************
// String replace strange characters like '\n'
//********************************************************************
replace: function (str, from, to) {
    var i = str.indexOf(from);
    if (!from || !str || i == -1) return str;
    var newstr = str.substring(0, i) + to;
    if (i+from.length < str.length)
    newstr += replace(str.substring(i+from.length,str.length),from,to);
    return newstr;
},


//********************************************************************
//
//********************************************************************
toggleSummary: function(moduleGuid,itemId) {
  var instance;
  instance = ThePortModule.getInstance(moduleGuid);
  if (instance)
    instance.toggleSummaryItem(itemId);
},

//********************************************************************
// Handy little obj to pass vars by reference...
//********************************************************************
parm: function(value){this.value = value;},

//********************************************************************
// Clone and object...
//********************************************************************
clone: function(src) {for(i in src){this[i] = src[i];}},

//********************************************************************
// ~derived from  http://www.quirksmode.org/js/findpos.html#
//********************************************************************
findPosXY: function(obj,x,y)
{
  x.value = 0;
  y.value = 0;
  if (obj.offsetParent) {
	while (obj.offsetParent) {
	  x.value += obj.offsetLeft;
	  y.value += obj.offsetTop;
	  obj = obj.offsetParent;
  	  }
  	}
  else {
        if (obj.x)
		  x.value += obj.x;
        if (obj.y)
		  y.value += obj.y;
	   }
  return;
},


//*********************************************************************
//
//*********************************************************************
createIframeArea: function (url,parentNode)
{
  var x1 = new parm();
  var y1 = new parm();
  this.findPosXY(parentNode,x1,y1);

  var IFrameDoc;
  if (!document.createElement) {alert('cannot create element');return true};
  if (!this.m_IFrameObj && document.createElement) {
    // create the IFrame and assign a reference to the
    try {
        this.m_tempIFrame=document.createElement('iframe');
        this.m_tempIFrame.setAttribute('id',this.m_guid);
        this.m_tempIFrame.style.border='0px';
        this.m_tempIFrame.style.width='210px';
        this.m_tempIFrame.style.height='900px';
        this.m_IFrameObj = parentNode.appendChild(this.m_tempIFrame);
        this.m_tempIFrame.src = url;
      } catch(exception) {
        // This is for IE5 PC, which does not allow dynamic creation
        // and manipulation of an iframe object. Instead, we'll fake
        // it up by creating our own objects.
        alert('creation route #2');
        iframeHTML='\<iframe id="'+this.m_guid+'" style="';
        iframeHTML+='border:0px;';
        iframeHTML+='width:100px;';
        iframeHTML+='height:200px;';
        iframeHTML+='"><\/iframe>';
        document.body.innerHTML+=iframeHTML;
        this.m_IFrameObj = new Object();
        this.m_IFrameObj.document = new Object();
        this.m_IFrameObj.document.location = new Object();
        this.m_IFrameObj.document.location.iframe = document.getElementById(this.m_guid);
        this.m_IFrameObj.document.location.replace = function(location) {
          this.iframe.src = location;
          }
        }
    }
  return false;
},


//***********************************************************
//grabbed from the top 10 javascripts website
//***********************************************************
insertAfter: function (parent, node, referenceNode) 
{
  parent.insertBefore(node, referenceNode.nextSibling);
},


//***********************************************************
// grabbed from the top 10 javascripts website
//***********************************************************
addEvent: function (elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}
	else {
		elm['on' + evType] = fn;
	}
},


//***********************************************************
// grabbed from the top 10 javascripts website
//***********************************************************
addLoadEvent: function (func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
},


//***********************************************************
// grabbed from the top 10 javascripts website
//***********************************************************
getElementsByClass: function (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;
},


//***********************************************************
// grabbed from the top 10 javascripts website
//***********************************************************
toggle: function (obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
},

//***********************************************************
// port function...
//***********************************************************
openWindow: function (u,title,options)
  {
  var win;
  var o=""
  if (tp_openWin.arguments[2]){o=options;}
  var t = "linkwin"
  if (tp_openWin.arguments[1]){t=title;}
  win=window.open(u,t,o);
  win.focus()
 }
 

//***********************************************************
// port function
//***********************************************************
/*
setDivDisplay: function (sDivID,imgsrc)
  {
  if (document.all(sDivID)) {
    if (document.all(sDivID).style.display == "none") {
      document.all(sDivID).style.display = "";
      if (sDivID == 'summary') 
        document.all.hdnOptStyle.value = "SHOW"
      }
    else{      
        document.all(sDivID).style.display = "none";
        if (sDivID == 'summary') 
          document.all.hdnOptStyle.value = "HIDE"
        }
    }
  if (document.all(imgsrc)) {      
    var sImg;
    sImg = document.all(imgsrc).src;
    if (sImg.indexOf("plus") > 0)
      document.all(imgsrc).src = "/images/minus.gif";
    else document.all(imgsrc).src = "/images/plus.gif";
    }
  }
*/
} // End  Namespace declaration...


function getClientAreaWidth()
{
	var myWidth = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		myWidth = window.innerWidth;
	} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
		myWidth = document.documentElement.clientWidth;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myWidth = document.body.clientWidth;
	}
	return myWidth;
}

function getClientAreaHeight()
{
	var myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myHeight = document.body.clientHeight;
	}
  return myHeight;
}

//******************************************************************
// We need to use this function to get the value out of a node.
// because it works differently in different browsers.
// This function does NOT rely on any internal vars of the object
// so it can be extracted or called from anywhere without problems.
//******************************************************************
function getValueFromNode(node) 
{
  if (typeof node.text != 'undefined') 
	  return node.text;
  else if (typeof node.textContent != 'undefined') 
		  return node.textContent;
		else if (typeof node.innerText != 'undefined') 
				return node.innerText;
			else {
				  switch (node.nodeType) { 
					  case 3:		// Node Text
					  case 4:		// Node CData
						  return node.nodeValue;
					  break;
					  case 1:		// Node Element
					  case 11:	// Document fragment
					  var retVal = new String();
					  for (var i = 0; i < node.childNodes.length; i++) 
						  retVal += getNodeValue(node.childNodes[i]);
					  return retVal;
					  default: return "";
					  }
				}
}

//*****************************************************
// 
//*****************************************************
function getAttrValueFromNode(node,attr)
{
  try {
 	for (l=0;l<node.attributes.length;l++) {
	  if (node.attributes[l].nodeName == attr)
        return(node.attributes[l].nodeValue);
      }
  } catch(e) { return null;}
  return null;
}


//************************************************************
// ThePort Utilities.  
//************************************************************
/////////////////////////////////////////////////////////////
// Version History.
/////////////////////////////////////////////////////////////
//
// October 27, 2006 Initial Version.
//***************************************************************
// ThePort XMLWriter original code from CodeProject free source.  
//***************************************************************


//***************************************************************
//
//***************************************************************
function XMLWriter()
{
    this.XML    = new Array();
    this.Nodes  = new Array();
    this.State  = "";
    
    XMLWriter.prototype.FormatXML = function(Str)
    {
        if (Str)
            return Str.replace(/&/g, "&amp;").replace(/\"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
        return ""
    }
    
    XMLWriter.prototype.BeginNode = function(Name)
    {
        if (!Name) return;
        if (this.State=="beg") this.XML.push(">");
        this.State="beg";
        this.Nodes.push(Name);
        this.XML.push("<"+Name);
    }
    
    XMLWriter.prototype.EndNode = function()
    {
        if (this.State=="beg")
        {
            this.XML.push("/>");
            this.Nodes.pop();
        }
        else if (this.Nodes.length>0)
            this.XML.push("</"+this.Nodes.pop()+">");
        this.State="";
    }
    
    XMLWriter.prototype.Attrib = function(Name, Value)
    {
        if (this.State!="beg" || !Name) return;
        this.XML.push(" "+Name+"=\""+this.FormatXML(Value)+"\"");
    }
    
    XMLWriter.prototype.WriteString = function(Value)
    {
        if (this.State=="beg") this.XML.push(">");
        this.XML.push(this.FormatXML(Value));
        this.State="";
    }
    
    XMLWriter.prototype.Node = function(Name, Value)
    {
        if (!Name) return;
        if (this.State=="beg") this.XML.push(">");
        this.XML.push((Value=="" || !Value)?"<"+Name+"/>":"<"+Name+">"+this.FormatXML(Value)+"</"+Name+">");
        this.State="";
    }
    
    XMLWriter.prototype.Close = function()
    {
        while (this.Nodes.length>0)
            this.EndNode();
        this.State="closed";
    }
    
    XMLWriter.prototype.ToString = function(){return this.XML.join("");}
}/**
*
*  Base64 encode / decode
*  http://www.webtoolkit.info/
*
**/

var Base64 = {

    // private property
    _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

    // public method for encoding
    encode : function (input) {
        var output = "";
        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
        var i = 0;

        input = Base64._utf8_encode(input);

        while (i < input.length) {

            chr1 = input.charCodeAt(i++);
            chr2 = input.charCodeAt(i++);
            chr3 = input.charCodeAt(i++);

            enc1 = chr1 >> 2;
            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
            enc4 = chr3 & 63;

            if (isNaN(chr2)) {
                enc3 = enc4 = 64;
            } else if (isNaN(chr3)) {
                enc4 = 64;
            }

            output = output +
            this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
            this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

        }

        return output;
    },

    // public method for decoding
    decode : function (input) {
        var output = "";
        var chr1, chr2, chr3;
        var enc1, enc2, enc3, enc4;
        var i = 0;

        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

        while (i < input.length) {

            enc1 = this._keyStr.indexOf(input.charAt(i++));
            enc2 = this._keyStr.indexOf(input.charAt(i++));
            enc3 = this._keyStr.indexOf(input.charAt(i++));
            enc4 = this._keyStr.indexOf(input.charAt(i++));

            chr1 = (enc1 << 2) | (enc2 >> 4);
            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
            chr3 = ((enc3 & 3) << 6) | enc4;

            output = output + String.fromCharCode(chr1);

            if (enc3 != 64) {
                output = output + String.fromCharCode(chr2);
            }
            if (enc4 != 64) {
                output = output + String.fromCharCode(chr3);
            }

        }

        output = Base64._utf8_decode(output);

        return output;

    },

    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}
//----------------------------------------------------------------------------------------------------
// Modified version tooltip.js
//----------------------------------------------------------------------------------------------------

var OP = (navigator.userAgent.indexOf('Opera') != -1);
var IE = (navigator.userAgent.indexOf('MSIE') != -1 && !OP);
var GK = (navigator.userAgent.indexOf('Gecko') != -1);
var SA = (navigator.userAgent.indexOf('Safari') != -1);
var DOM = document.getElementById;

var tooltip = null;
var showMe = true;

function setTooltipActive(flag)
{
  showMe = flag;
}

function myCoolToolTip() {
  this.width = 0;                     
  this.bgColor = "#ffffff";             
  this.textFont = "verdana";      
  this.textSize = 10;                   
  this.textColor = "#000000";           
  this.border = "1px solid #ff7400";   
  this.opacity = 98;                    
  this.padding = 5;
  this.cursorDistance = 10;       
  this.fontWeight = "normal";        

  this.text = '';
  this.height = 0;
  this.obj = null;
  this.active = false;

  this.create = function() {
  if(!this.obj) this.init();

    var myStyle = (this.textFont ? 'font-family:' + this.textFont + '; ' : '') +
                  (this.textSize ? 'font-size:' + this.textSize + 'px; ' : '') +
                  (this.padding ? 'padding:' + this.padding + 'px; ' : '') +
                  (this.border ? 'border:' + this.border + '; ' : '') +
                  (this.width ? 'width:' + this.width + '; ' : '') +
                  (this.fontWeight ? 'font-weight:' + this.fontWeight + '; ' : '') +
                  (this.textColor ? 'color:' + this.textColor + '; ' : '');

    var tTContent = '<div'+ (myStyle ? ' style="background-image: url(/custom/modules/images/tooltipbg.gif); ' + myStyle + '"' : '') +'>'+ this.text +'</div>';

    if(DOM || IE) this.obj.innerHTML = tTContent;
    if(DOM) this.height = this.obj.offsetHeight;
    else if(IE) this.height = this.obj.style.pixelHeight;
    if(this.bgColor) this.obj.style.backgroundColor = this.bgColor;

    this.setOpacity();
    this.move();
    this.show();
  }

  this.init = function() {
    if(DOM) this.obj = document.getElementById('ToolTip');
    else if(IE) this.obj = document.all.ToolTip;
  }

  this.move = function() {
    var winX = getWinX() - (((GK && !SA) || OP) ? 17 : 0);
    var winY = getWinY() - (((GK && !SA) || OP) ? 17 : 0);
    var x = mouseX;
    var y = mouseY;

    if(x + this.width + this.cursorDistance > winX + getScrX())
      x -= this.width + this.cursorDistance;
    else x += this.cursorDistance;

    if(y + this.height + this.cursorDistance > winY + getScrY())
      y -= this.height;
    else y += this.cursorDistance;

    this.obj.style.left = x + 'px';
    this.obj.style.top = y + 'px';
  }

  this.show = function() {
    this.obj.style.visibility = 'visible';
    this.obj.style.zIndex = 69;
    this.active = true;
  }

  this.hide = function() {
    this.obj.style.visibility = 'hidden';
    this.obj.style.zIndex = -1;
    this.active = false;
  }

  this.setOpacity = function() {
    this.obj.style.filter = 'alpha(opacity=' + this.opacity + ')';
    this.obj.style.mozOpacity = '.1';
    if(this.obj.filters) this.obj.filters.alpha.opacity = this.opacity;
    if(!document.all && this.obj.style.setProperty)
      this.obj.style.setProperty('-moz-opacity', this.opacity / 100, '');
  }
}

function getScrX() {
  var offset = 0;
  if(window.pageXOffset)
    offset = window.pageXOffset;
  else if(document.documentElement && document.documentElement.scrollLeft)
    offset = document.documentElement.scrollLeft;
  else if(document.body && document.body.scrollLeft)
    offset = document.body.scrollLeft;
  return offset;
}

function getScrY() {
  var offset = 0;
  if(window.pageYOffset)
    offset = window.pageYOffset;
  else if(document.documentElement && document.documentElement.scrollTop)
    offset = document.documentElement.scrollTop;
  else if(document.body && document.body.scrollTop)
    offset = document.body.scrollTop;
  return offset;
}

function getWinX() {
  var size = 0;
  if(window.innerWidth)
    size = window.innerWidth;
  else if(document.documentElement && document.documentElement.clientWidth)
    size = document.documentElement.clientWidth;
  else if(document.body && document.body.clientWidth)
    size = document.body.clientWidth;
  else size = screen.width;
  return size;
}

function getWinY() {
  var size = 0;
  if(window.innerHeight)
    size = window.innerHeight;
  else if(document.documentElement && document.documentElement.clientHeight)
    size = document.documentElement.clientHeight;
  else if(document.body && document.body.clientHeight)
    size = document.body.clientHeight;
  else size = screen.height;
  return size;
}

function getMouseXY(e) {
  if(e && e.pageX != null) {
    mouseX = e.pageX;
    mouseY = e.pageY;
  }
  else if(event && event.clientX != null) {
    mouseX = event.clientX + getScrX();
    mouseY = event.clientY + getScrY();
  }
  if(mouseX < 0) mouseX = 0;
  if(mouseY < 0) mouseY = 0;
  if(tooltip && tooltip.active) tooltip.move();
}

function toolTip(text, width, opacity) {
  if(!showMe) return;
  document.onmousemove = getMouseXY;
  if(text) {
    tooltip = new myCoolToolTip();
    //tooltip.text = Base64.decode(text);

    //***************************************
    // attempt a base64 decode...
    //if it fails, use the original string.
    //***************************************
    /*(
	try {
    var b64;
    if ((text!=null)&&(text.length>0)) {
	    b64 = Base64.decode(text);
	    text = b64;
	    }
    } catch(e){}	  
*/
    tooltip.text = text;
    if(width) tooltip.width = width;
    if(opacity) tooltip.opacity = opacity;
    tooltip.create();
  }
  else if(tooltip) tooltip.hide();
}

function fixQt(str)
{
  var myStrQ = str;
  myStrQ = myStrQ.replace(/<img\s+[^>]+>/i,"");
  return myStrQ; 
}

function removeLinks(mystr)
{
  return mystr.replace(/<a\b[^>]*>(.*?)\<\/a\>/ig,"$1"); 
}

function makeToolTipCompliant(rawTXT)
{
  var newTTTxt = new String(rawTXT);

  //remove new lines
  newTTTxt = newTTTxt.replace(/\r/g,"").replace(/\n/g,"");

  //remove HTML tags
  newTTTxt = newTTTxt.replace(/<.*?>/g,"");

  //escape double quotes
  newTTTxt = newTTTxt.replace(/"/g,"&quot;");

  //escape single quotes
  newTTTxt = newTTTxt.replace(/'/g,"\\'");

  return newTTTxt
}
function makeToolTipCompliantWithHtml(rawTXT)
{  
  var newTTTxt = new String(rawTXT);

  //remove new lines
  newTTTxt = newTTTxt.replace(/\r/g,"").replace(/\n/g,"");

  //remove HTML tags
  //newTTTxt = newTTTxt.replace(/<.*?>/g,"");

  //escape double quotes
  newTTTxt = newTTTxt.replace(/"/g,"&quot;");

  //escape single quotes
  newTTTxt = newTTTxt.replace(/'/g,"\\'");  
  return newTTTxt
  
}
document.write('<div id="ToolTip" style="text-align: left; position:absolute; visibility:hidden;"></div>');

var mouseX = mouseY = 0;


function tp_RatingClick(i,itemRating,itemID, iMaxRating, sSelectedImage, sUnselectedImage, iItemType, iItemRatingType, iTotalRatings,itemOwnerID,doVmixPost)
		{				
			$('tp_israted_'+itemID).value = "1";	
			var url = "/community/app/nf/callback/insertrating.aspx";
			var args = "r="+i+"&i="+itemID+"&ot="+iItemType+"&irt="+iItemRatingType+"&o="+itemOwnerID+"&vmix="+doVmixPost;
			//document.write (args);
			iTotalRatings = parseFloat(iTotalRatings) + 1;
			
			PostURL(url,args,0,"tp_RatingEvalResponse")
			
			if($('tp_rating_text_'+itemID)){$('tp_rating_text_'+itemID).innerHTML = 'Thank you!';}
			if($('tp_total_ratings_'+itemID)){$('tp_total_ratings_'+itemID).innerHTML = iTotalRatings + ' total ratings';}
			
			for (var x = 1; x <= iMaxRating ; x++)
			{
				var imgId = x + "_Rating_"+itemID;		
				var y = $(imgId);
				if (y) {
				    y.onclick = null;
				    y.onmouseover = null;
				    y.onmouseout = null;
    				//y.onmouseout = tp_OnMouseOut;
	    			//$(imgId).removeAttribute('onClick');
		    		//$(imgId).removeAttribute('onMouseOver');					
			    	//Element.stopObserving($(imgId),'mouseover');				
				    if (x<=i) {
					    $(imgId).src = sSelectedImage;
					    $(imgId).alt = "You have already rated this item";
					    }
				    else {
					    $(imgId).src = sUnselectedImage;
					    $(imgId).alt = "You have already rated this item";					
				      }						
				    }
			}					
		}
function tp_OnMouseOut(iMaxRating,sUnselectedImage, sItemID)
{		
	var f = $('tp_israted_'+sItemID);
	if (f.value!="1")
	{
		for (var x = 1; x <= iMaxRating ; x++)
		{
			var imgId = x+"_Rating_"+sItemID;					
			$(imgId).src = sUnselectedImage;		
		}
	}
}
function tp_RatingEvalResponse()
{
	
}
function tp_RatingMouseOver(i,iMaxRating, sSelectedImage, sUnselectedImage, sItemID)
{		
	
	for (var x = 1; x <= iMaxRating ; x++)
	{
		var imgId = x+"_Rating_"+sItemID;	
		var y = $(imgId);	
		//y.onmouseout = tp_OnMouseOut(iMaxRating,sUnselectedImage,sItemID);
		var fn = function( e ){Event.stop( e );tp_OnMouseOut(iMaxRating,sUnselectedImage,sItemID);}; Event.observe(y, 'mouseout', fn, false);
		if (x<=i)
		{
			$(imgId).src = sSelectedImage;
			$(imgId).alt = "Please click to rate this item";
		}
		else
		{
			$(imgId).src = sUnselectedImage;
			$(imgId).alt = "Please click to rate this item";
		}
	}
}
function tp_LoginRedirect(sURL)
{
	window.location = sURL;
}﻿
function ThePortRatingsObj( sParentNodeName,
                            sRootNodeID,
                            oRatingTextNode,
                            oRatingTotalTextNode,
                            sRateOnImgPath,
                            sRateOffImgPath,
                            gOwnerID,
                            sItemTypeID,
                            sItemID,
                            sItemRatingType,
                            iItemScore,
                            iTotalNumRatings,
                            iUserItemRating,
                            sVoteNotAllowed,
                            iMaxRating,
                            iMinRating,
                            sDoVmixPost)
{
    this.m_activeID         = -1;
    this.m_oRoot            = null;
    this.m_iNumRatings      = iMaxRating-iMinRating;
    this.m_oRatings         = new Array(this.m_iNumRatings);
    this.m_sParentNodeName  = sParentNodeName;
    this.m_sRootNodeID      = sRootNodeID;
    this.m_sRateOnImgPath   = sRateOnImgPath;
    this.m_sRateOffImgPath  = sRateOffImgPath;
    this.m_gOwnerID         = gOwnerID;
    this.m_sItemTypeID      = sItemTypeID;
    this.m_sItemID          = sItemID;
    this.m_sItemRatingType  = sItemRatingType;
    this.m_iItemScore       = iItemScore;
    this.m_iTotalNumRatings = iTotalNumRatings;
    this.m_iUserItemRating  = iUserItemRating;
    if ((sVoteNotAllowed.toLowerCase() == "true")||(sVoteNotAllowed.toLowerCase() == "yes"))
        this.m_bVoteNotAllowed   = true;
    else this.m_bVoteNotAllowed   = false;
    this.m_iMaxRating       = iMaxRating;
    this.m_iMinRating       = iMinRating;
    this.m_sDoVmixPost      = sDoVmixPost;
    
    this.m_oRateThxNode     = oRatingTextNode;
    this.m_oRateTotalNode   = oRatingTotalTextNode;
  
    this.m_sPleaseClickMsg  = "Please click to rate this item";
    this.m_sAlreadyRated    = "You have already rated this item";
    this.m_sUserVotedMsg    = "Thank you!";
    this.m_sTotalVotesMsg   = "total ratings";
    this.m_oClickFns        = new Array(this.m_iNumRatings);
    this.m_oMouseOverFn     = new Array(this.m_iNumRatings);
    this.m_oMouseOutFn      = new Array(this.m_iNumRatings);
  
  // **********************************
  // Create the root node
  // **********************************
  this.m_root            = document.createElement("div");
  this.m_root.id         = sRootNodeID
  this.m_root.className  = ""
  for (i=0;i<this.m_iNumRatings;i++) {
        this.m_oRatings[i]              = document.createElement("img");
        this.m_oRatings[i].id           = i+"";
        this.m_oRatings[i].className    = "";
        this.m_oRatings[i].setAttribute('src', this.m_sRateOffImgPath);
        this.m_oRatings[i].setAttribute('height', '10px');
        this.m_oRatings[i].setAttribute('border', '0');
        // If the user has not voted, hook events to each vote image. 
        if (!this.m_bVoteNotAllowed) {
            var fn
            // Hook the OnClick event  
            fn = function(e) {if (window.event)el=e.srcElement;else el= e.currentTarget;this.RatingClick(parseInt(el.id),this);Event.stop(e);}.bind(this);
            this.m_oClickFns[i]=fn
            Event.observe(this.m_oRatings[i],'click',this.m_oClickFns[i]);
            // Hook the MouseOver Event...            
            fn = function(e) {if (window.event)el=e.srcElement;else el= e.currentTarget;this.RatingMouseOver(parseInt(el.id),this);Event.stop(e);}.bind(this);
            this.m_oMouseOverFn[i]=fn
            Event.observe(this.m_oRatings[i],'mouseover',this.m_oMouseOverFn[i]);
            // Hook the MouseOut Event...            
            fn = function(e){if (window.event)el=e.srcElement;else el= e.currentTarget;this.RatingMouseOut(parseInt(el.id),this);Event.stop(e);}.bind(this); 
            this.m_oMouseOutFn[i]=fn
            Event.observe(this.m_oRatings[i],'mouseout', this.m_oMouseOutFn[i]);
            }
        // Make sure it's visible & add to the main node.
        Element.show(this.m_oRatings[i]);
        this.m_root.appendChild(this.m_oRatings[i]);
        }
   this.SetScore(this);
   var elem = $(sParentNodeName);
   if (elem) elem.appendChild(this.m_root);
}


ThePortRatingsObj.prototype.RatingClick = function(i,obj)  
{	
    obj.m_bVoteNotAllowed = true
	var url = "/community/app/nf/callback/insertrating.aspx";
	var args = "r="+(i+1)+"&i="+obj.m_sItemID+"&ot="+obj.m_sItemTypeID+"&irt="+obj.m_sItemRatingType+"&o="+obj.m_gOwnerID+"&vmix="+obj.m_sDoVmixPost;
	iTotalRatings = parseInt(obj.m_iTotalNumRatings) + 1;
	
    var eUrl = encodeURI(url);
    var myAjax = new Ajax.Request(eUrl,{method: 'get', parameters: args, onComplete: this.RatingEvalResponse.bind(this)});
    if (obj.m_oRateThxNode)  obj.m_oRateThxNode.innerHTML = obj.m_sUserVotedMsg;
    if (obj.m_oRateTotalNode)  obj.m_oRateTotalNode.innerHTML = iTotalRatings + " " + obj.m_sTotalVotesMsg;
	
	for (var x = 0; x < obj.m_iNumRatings ; x++) {
        // Stop stopObserving has FF problems, so we remove each handler by hand.  :(
	    // This.m_oRatings[x].stopObserving();  // Remove all the handlers.
        Event.stopObserving(obj.m_oRatings[x],'click',obj.m_oClickFns[x])
        Event.stopObserving(obj.m_oRatings[x],'mouseover',obj.m_oMouseOverFn[x])
        Event.stopObserving(obj.m_oRatings[x],'mouseout',obj.m_oMouseOutFn[x])
        if (x<=i) 
	        obj.m_oRatings[x].src = obj.m_sRateOnImgPath;
        else obj.m_oRatings[x].src = obj.m_sRateOffImgPath;
        obj.m_oRatings[x].alt = obj.m_sAlreadyRated;		
	    }					
}


ThePortRatingsObj.prototype.SetScore = function(obj) 
{
    var x = 0;
    for (x=0;x<obj.m_iNumRatings;x++) {
        // If the user has voted, mark the vote images with a score already given.
        if (x<=obj.m_iItemScore-1) 
	        obj.m_oRatings[x].src = obj.m_sRateOnImgPath;
        else obj.m_oRatings[x].src = obj.m_sRateOffImgPath;
        obj.m_oRatings[x].alt = obj.m_sAlreadyRated;		
        }
}		


ThePortRatingsObj.prototype.RatingEvalResponse = function(originalRequest)
{  }


ThePortRatingsObj.prototype.RatingMouseOut = function(i,obj)
{		
    this.m_activeID = -1;
	if (Object.m_sRating==null)	{
	    for (var x = 0; x < obj.m_iNumRatings ; x++) {
	        obj.m_oRatings[x].src = obj.m_sRateOffImgPath;
		    obj.m_oRatings[x].alt = obj.m_sPleaseClickMsg;
		    }
    	}
    this.SetScore(obj);    	
}


ThePortRatingsObj.prototype.RatingMouseOver = function(i,obj) 
{		
    if (this.m_activeID==i) return;
	for (var x = 0; x < obj.m_iNumRatings ; x++) {
		if (x<=i) 
		    obj.m_oRatings[x].src = obj.m_sRateOnImgPath;
		else obj.m_oRatings[x].src = obj.m_sRateOffImgPath;
    	obj.m_oRatings[x].alt = obj.m_sPleaseClickMsg;
	    }
	this.m_activeID=i;
}


ThePortRatingsObj.prototype.tp_LoginRedirect = function(sURL)
{
	window.location = sURL;
}
//*******************************************************************
// ThePort PictureRenderer
// Derived from previously written ThePort flickr module.
// Modularized by Steve Soares
//*******************************************************************
// Version History.
//*******************************************************************
// March 26, 2007 Initial Version.
//*******************************************************************


/***********************************************************************/
/*                                                                     */
/***********************************************************************/
function PictureElement( tnailUrl, picUrl, link, title, description, author, date)
{
  this.m_tnailUrl     = tnailUrl;
  this.m_picUrl       = picUrl;
  this.m_link		      = link;
  this.m_title        = title;
  this.m_description  = description;
  this.m_author       = author;
  this.m_date         = date;  
}


/***********************************************************************/
/*                                                                     */
/***********************************************************************/
function PictureList()
{
 this.m_picList = new Array();
}


/***********************************************************************/
/*                                                                     */
/***********************************************************************/
PictureList.prototype.length = function()
{
 return this.m_picList.length;
}


/***********************************************************************/
/*                                                                     */
/***********************************************************************/
PictureList.prototype.addPicture = function(tnailUrl, picUrl, link, title, description, author, date)
{
  var elem = new PictureElement(tnailUrl, picUrl, link, title, description, author, date);
  this.addElement(elem);
}

/***********************************************************************/
/*                                                                     */
/***********************************************************************/
PictureList.prototype.addElement = function(pElem)
{
 this.m_picList.push(pElem);
}

/***********************************************************************/
/*                                                                     */
/***********************************************************************/
function PictureRenderer(displayElem,pictureList)
{
  this.m_displayElem  = displayElem;
  this.m_pictureList  = pictureList;
  this.m_viewModes    = new Array ("Slide show","List view","Thumbnail");
  this.m_viewMode     = 0;
  this.m_currentIndex = 0;
  this.m_uiElem       = null;
  this.m_pagingElem   = null;
  this.m_picModes     = new Array("Inline style","CSS class name");
  this.m_picMode      = [];
  this.m_picStyles    = [];
  this.m_datalist	  = null;
}
/***********************************************************************/
/*                                                                     */
/***********************************************************************/
PictureRenderer.prototype.setRenderMode = function(mode)
{
  var mode = this.m_viewModes.indexOf(mode);
  if (mode>=0) {
    this.m_viewMode = mode;
	this.m_currentIndex = 0;
    this.draw();
    }
}

/***********************************************************************/
/*                                                                     */
/***********************************************************************/
PictureRenderer.prototype.getRenderMode = function(idx)
{
  return this.m_viewModes[idx];
}

/***********************************************************************/
/*                                                                     */
/***********************************************************************/
PictureRenderer.prototype.getRenderModes = function()
{
  return this.m_viewModes;
}
/***********************************************************************/
/*                                                                     */
/***********************************************************************/
PictureRenderer.prototype.addPagingElements=function(pElem){
  this.m_pagingElem = pElem;
}
/***********************************************************************/
// pStyle = Parameter option inputs inline style or css classname 
// picMode = Inline Style or CSS classs name
/***********************************************************************/
PictureRenderer.prototype.setPictureStyle=function(renderMode,picMode,pStyle){  
  var mode = this.m_picModes.indexOf(picMode);  
  switch(this.m_viewModes.indexOf(renderMode)){
    case 0:this.m_picStyles[0] = pStyle;this.m_picMode[0]=(mode>0)?mode:0;break;
	case 1:this.m_picStyles[1] = pStyle;this.m_picMode[1]=(mode>0)?mode:0;break;
	case 2:this.m_picStyles[2] = pStyle;this.m_picMode[2]=(mode>0)?mode:0;break;
  }
}
/***********************************************************************/
/*                                                                     */
/***********************************************************************/
PictureRenderer.prototype.getPictureModes=function(){
  return this.m_picModes;
}
/***********************************************************************/
/*                                                                     */
/***********************************************************************/
PictureRenderer.prototype.getPictureMode=function(idx){
  return this.m_picModes[idx];
}
/***********************************************************************/
/*                                                                     */
/***********************************************************************/
PictureRenderer.prototype.draw = function() { 
  var output = '';
  if (!this.m_displayElem) return;
  if (this.m_pictureList.length()<=0) return;
  
  //var listPaging = null;
  if(this.m_pagingElem != null){
	this.m_datalist = new DataListPaging(this.m_displayElem,this.m_pagingElem);
  }
  var picStyle='';
  /* Slide Show Mode */  
  if (this.m_viewMode==0) {    
    if ((this.m_currentIndex<0)||(this.m_currentIndex>=this.m_pictureList.length())) return;
	var oTitle= this.m_pictureList.m_picList[this.m_currentIndex].m_title;
	var oLink = this.m_pictureList.m_picList[this.m_currentIndex].m_link;
    var oImage = this.m_pictureList.m_picList[this.m_currentIndex].m_picUrl;
	/* set picture style */
	if(this.m_picStyles[0] != null){ 
	  picStyle=(this.m_picMode[0]==0) ? 'style="filter:alpha(opacity=0);-moz-opacity:0.0;' + this.m_picStyles[0] + '"' : 'style="filter:alpha(opacity=0);-moz-opacity:0.0;" class="' + this.m_picStyles[0] + '"';
	}else{
	  picStyle="style='filter:alpha(opacity=0);-moz-opacity:0.0;border:1px solid #e3dfc5;width:240px;height:180px;'";
	  }
	data = "<div align='center'><a href='" + oLink + "' target='_blank'><img " + picStyle + " src='" + oImage + "' onload='PictureEffect(this);' /></a><br /><a href='" + oLink + "' target='_blank'>" + oTitle + "</a></div>";
    this.m_displayElem.innerHTML = '<div style="text-align:left">' + data + '</div>';
	if(this.m_pagingElem != null){
	  if(this.m_pagingElem.m_pageStatus != null)
	    this.m_pagingElem.m_pageStatus.innerHTML = 'Page ' + (this.m_currentIndex + 1) + ' of ' + this.m_pictureList.length();
	  (this.m_currentIndex >= (this.m_pictureList.length()-1)) ? this.m_pagingElem.m_next.style.display = 'none' : this.m_pagingElem.m_next.style.display = 'block';	  
      (this.m_currentIndex > 0) ? this.m_pagingElem.m_prev.style.display = 'block' : this.m_pagingElem.m_prev.style.display = 'none';
	  if(this.m_pagingElem.m_prev.onclick) this.m_pagingElem.m_prev.onclick = null;
	  if(this.m_pagingElem.m_next.onclick) this.m_pagingElem.m_next.onclick = null;	  
	  this.m_pagingElem.m_prev.onclick = function(e){ this.previous();}.bind(this);	  
      this.m_pagingElem.m_next.onclick = function(e){ this.next(); }.bind(this);
	}
	return;
  }
  // Show all the pictures...
  for (idx=0;idx<this.m_pictureList.length();idx++) {
    var tnailUrl      = this.m_pictureList.m_picList[idx].m_tnailUrl;
    var oLink         = this.m_pictureList.m_picList[idx].m_link;
    var oTitle        = this.m_pictureList.m_picList[idx].m_title;
    var oAuthor       = this.m_pictureList.m_picList[idx].m_author;
    var oDate         = this.m_pictureList.m_picList[idx].m_date;
    var oDescription  = this.m_pictureList.m_picList[idx].m_description;
	var html = '';
    /* List view */
	if (this.m_viewMode == 1) {
	  if(this.m_picStyles[1] != null){ 
	    picStyle=(this.m_picMode[1]==0) ? 'style="filter:alpha(opacity=0);-moz-opacity:0.0;' + this.m_picStyles[1] + '"' : 'style="filter:alpha(opacity=0);-moz-opacity:0.0;" class="' + this.m_picStyles[1] + '"';
	  }else{
	    picStyle="style='filter:alpha(opacity=0);-moz-opacity:0.0;border:1px solid #e3dfc5;width:75px;height:75px;'";
		}
	  html = "<a href='" + oLink + "' target='_blank'><img " + picStyle + " src='" +tnailUrl + "' onload='PictureEffect(this);' /></a>";
	  var tmp = '<tr><td>'+html+'</td>';		 
	  if(oAuthor!=null && oAuthor.length>0)
	    oAuthor = ' by ' + oAuthor;
	  if(oDate!=null && oDate.length>0)
	    oDate = 'on ' + oDate;
	  tmp += '<td valign="top"><span style="font-size:8pt"><a href="' + oLink + '" target="_blank">'+ oTitle 
	      + '</a></span><br /><span class="normaltxt10"> ' + oAuthor +'</span><br /><span class="normaltxt10"> ' +oDate+'</span></td></tr>';
	  output = '<table cellpadding="1" cellspacing="1">'+tmp+'</table>';		
  	  } 
  	/* thumbnail View */
  	else{
	  if(this.m_picStyles[2] != null){ 
	    picStyle=(this.m_picMode[2]==0) ? 'style="filter:alpha(opacity=0);-moz-opacity:0.0;' + this.m_picStyles[2] + '"' : 'style="filter:alpha(opacity=0);-moz-opacity:0.0;" class="' + this.m_picStyles[2] + '"';
	  }else{
	    picStyle="style='filter:alpha(opacity=0);-moz-opacity:0.0;border:1px solid #e3dfc5;width:75px;height:75px;'";
		}
	  html = "<a href='" + oLink + "' target='_blank'><img " + picStyle + " src='" +tnailUrl + "' onload='PictureEffect(this);' /></a>";
	  output = html + "&nbsp;";
	}    
	if(this.m_datalist != null){
	  (this.m_viewMode==2) ? this.m_datalist.setOuterHTML('<div align="center">','</div>') : this.m_datalist.setOuterHTML('','');
	  this.m_datalist.addItem(output);
    }
  }
	if(this.m_datalist != null) this.m_datalist.showResult();
	//this.m_displayElem.innerHTML = '<div style="text-align:left">'+ output + '</div>'; 
}
/***********************************************************************/
/*                                                                     */
/***********************************************************************/
PictureRenderer.prototype.next = function() 
{
  if (this.m_viewMode==0) {   /* Slide Show Mode */
    if ((this.m_currentIndex+1)<this.m_pictureList.length()) {
      this.m_currentIndex++;
      this.draw();
      }
    }
}
/***********************************************************************/
/*                                                                     */
/***********************************************************************/
PictureRenderer.prototype.previous = function() 
{
  if (this.m_viewMode==0) { /* Slide Show Mode */
    if ((this.m_currentIndex-1)>=0) {
      this.m_currentIndex--;
      this.draw();
      }
    }
}
/***********************************************************************/
/*                                                                     */
/***********************************************************************/
PictureRenderer.prototype.configureSelectControl = function(elem,hookFlag) 
{
  if (elem) {
    this.m_uiElem = elem;
	while(this.m_uiElem.length >= 1) this.m_uiElem.remove(0);
    for (i=0;i<this.m_viewModes.length;i++) {
      var option = document.createElement("OPTION") 
      this.m_uiElem.options.add(option);
      option.text = this.m_viewModes[i];
      option.value = i;
      }
    if (hookFlag==true) {
	  if(elem.onchange) elem.onchange = null;
      var fn = function(e){        
        this.setRenderMode(this.m_viewModes[this.m_uiElem.selectedIndex]);
        }.bind(this);     
	  elem.onchange = fn;
      }
    } 	
}
/***********************************************************************/
/*                                                                     */
/***********************************************************************/
PictureRenderer.prototype.setDisplayCount=function(count){ 
  this.m_datalist.setDisplayCount(count);
  this.m_datalist.showResult();
}
/***********************************************************************/
/*   Applies Picture Fading Effect                                                                 */
/***********************************************************************/
function PictureEffect(imgObject){
  var OPACITY = {IMG:imgObject};
  var op = /opera 5|opera\/5/i.test(navigator.userAgent) && window.opera;
  var ie = !op && /msie/i.test(navigator.userAgent);
  var mz = !op && /mozilla\/5/i.test(navigator.userAgent);
  //var safari = /Safari/i.test(navigator.userAgent);
  var timerid = setInterval(function() {
		try {
			var count = mz ? (OPACITY.IMG.style.MozOpacity*100) : OPACITY.IMG.filters.alpha.opacity;
			if (!ie) count+=5;
			else count+=20;
			if(count <= 100) {
				if(mz){ OPACITY.IMG.style.MozOpacity = (count/100); }
				else { OPACITY.IMG.filters.alpha.opacity=count;	}
			} else {
				clearInterval(OPACITY.TIMER);
			}
		} catch(e) {}
	},25);
	OPACITY.TIMER = timerid;
}//*******************************************************************
// DataListPaging
// Created by: Michael Castillones
//*******************************************************************
// Version History.
//*******************************************************************
// May 28, 2007 Initial Version.
//*******************************************************************
// Revision History :  Fixed IE Memory leaks
// ******************************************************************
// May 30,2007
/***********************************************************************/
// set Constructor parameters:
// Display Element, Total no. of items,, no. of Items displayed, previous button Element, next Button Element, page Status Element
// 
/***********************************************************************/
function PagingElements(pageCount,itmDispCount,prevElem,nextElem,pageStatusElem){
  this.m_itemDispCount = parseInt(itmDispCount);
  this.m_pageCount = parseInt(pageCount);
  this.m_prev = prevElem;
  this.m_next = nextElem;
  this.m_pageStatus = (pageStatusElem) ? pageStatusElem : null;  
}

DataListPaging=function(dispElem,pElem){  
  this.m_pagingElem = pElem; 
  this.m_pageIndex = 0;
  this.m_dataList = new Array();  
  this.m_elemDisp = dispElem;
  this.m_startTag = '';
  this.m_endTag = '';
  this.m_ObjectEvents = new Array();
  this.dispose();  
  this.configurePaging();
}
/***********************************************************************/
/*  Dispose event handler IE issue of memory leaks */
/***********************************************************************/
DataListPaging.prototype.dispose=function(){
  if(this.m_pagingElem.m_prev.onclick)
    this.m_pagingElem.m_prev.onclick = null;
  if(this.m_pagingElem.m_next.onclick)
    this.m_pagingElem.m_next.onclick = null;     
}
/***********************************************************************/
/*  add array of results */
/***********************************************************************/
DataListPaging.prototype.addList=function(pList){
  this.m_dataList = pList;
}
/***********************************************************************/
/* add item of results*/
/***********************************************************************/
DataListPaging.prototype.addItem=function(pItem){
  this.m_dataList.push(pItem);
}
/***********************************************************************/
/* set outerHTML for the array results                                 */
/***********************************************************************/
DataListPaging.prototype.setOuterHTML=function(startTag,endTag){  
  try{
    if(startTag.length>0 != ''&& startTag.length > 0){
      this.m_startTag = startTag;
      this.m_endTag = endTag;
	}
  }catch(e){ return false; }
  return true;
}
/***********************************************************************/
/*                                                                     */
/***********************************************************************/
DataListPaging.prototype.length=function(){
  return this.m_dataList.length;
}
DataListPaging.prototype.getObjectEvent=function(){
  var obj = new Object();
  obj.id = '';
  obj.eventType ='';
  obj.fn = null;
  return obj;
}

DataListPaging.prototype.addObjectEvent=function(objEvent){  
  this.m_ObjectEvents.push(objEvent);
}
DataListPaging.prototype.attachObjectEvents=function(){
  if(this.m_ObjectEvents.length <= 0) return;
  for(var i=0;i<this.m_ObjectEvents.length;i++){  
    elem = ThePortUtils.findChildId(this.m_elemDisp,this.m_ObjectEvents[i].id)	
	//alert(elem);
	if(elem){
	  Event.observe(elem,this.m_ObjectEvents[i].eventType,this.m_ObjectEvents[i].fn);
	  //alert(this.m_ObjectEvents[i].fn);
	  }
  }
}
/***********************************************************************/
/*       Show Results                                                              */
/***********************************************************************/
DataListPaging.prototype.showResult=function(){
  try{        
    //alert(this.m_pagingElem.m_pageCount);
    if(!this.m_dataList) return;
    if(!this.m_pagingElem.m_pageCount) return;
    if(!this.m_pagingElem.m_itemDispCount) return;
    if(this.m_dataList.length<=0) return;
    var result='';	
    var startIndex = this.m_pageIndex * this.m_pagingElem.m_itemDispCount;	
    for(var cnt=startIndex,idx=0;(cnt<this.m_dataList.length) && (cnt<this.m_pagingElem.m_pageCount) && (idx<this.m_pagingElem.m_itemDispCount); cnt++, idx++){	  
      result += this.m_dataList[cnt];
    }	
	if((this.m_startTag.length>0) && this.m_endTag.length>0)
	  result = this.m_startTag + result + this.m_endTag;	  
	this.m_elemDisp.innerHTML = result;
	this.attachObjectEvents();	
    (this.m_pageIndex >= (this.pageCount()-1)) ? this.m_pagingElem.m_next.style.display = 'none' : this.m_pagingElem.m_next.style.display = 'block';	  
    (this.m_pageIndex > 0) ? this.m_pagingElem.m_prev.style.display = 'block' : this.m_pagingElem.m_prev.style.display = 'none';    
	if(this.m_pagingElem.m_pageStatus != null)
		this.m_pagingElem.m_pageStatus.innerHTML = 'Page ' + this.currentPageIndex() + ' of ' + this.pageCount();	
  }catch(e){ alert(e.message) }
}
/***********************************************************************/
/*    Add handlers to paging buttons                        */
/***********************************************************************/
DataListPaging.prototype.configurePaging=function(){
  if((!this.m_pagingElem.m_prev) && (!this.m_pagingElem.m_next)) return;
  try{	
	 var fn = function(e){
	    this.previous();
	  }.bind(this);
	   this.m_pagingElem.m_prev.onclick = fn;	 
    fn = function(e){
		this.next();
	  }.bind(this);
	  this.m_pagingElem.m_next.onclick = fn;	
  }catch(e){ alert(e.message); }
}
/***********************************************************************/
/*                                                                     */
/***********************************************************************/
DataListPaging.prototype.next=function(){	
	try{	 
	  if(this.m_pageIndex<(this.pageCount()-1)) this.m_pageIndex++;	  
	  this.showResult();
	}catch(e){alert(e.message);}
}
/***********************************************************************/
/*                                                                     */
/***********************************************************************/
DataListPaging.prototype.previous=function(){
  if(this.m_pageIndex>0) this.m_pageIndex--;
  this.showResult();
}
/***********************************************************************/
/*                                                                     */
/***********************************************************************/
DataListPaging.prototype.currentPageIndex=function(){
  return this.m_pageIndex + 1;
}
DataListPaging.prototype.setCurrentPageIndex=function(idx){
  this.m_pageIndex = idx;
}
/***********************************************************************/
/*                                                                     */
/***********************************************************************/
DataListPaging.prototype.pageCount=function(){
  if(this.m_dataList.length <= 0) return null;
  if(this.m_pagingElem.m_itemDispCount <= 0) return null;
  return Math.ceil(this.m_dataList.length / this.m_pagingElem.m_itemDispCount);
}
/***********************************************************************/
/*                                                                     */
/***********************************************************************/
DataListPaging.prototype.setDisplayCount=function(count){ 
  this.m_pagingElem.m_itemDispCount = count;
  this.setCurrentPageIndex(0);
}/////////////////////////////////////////////////////////////
// ThePort NodeList Objects
// Author: Steve Soares
/////////////////////////////////////////////////////////////
// Copyright ThePort Inc.
/////////////////////////////////////////////////////////////
// Version History.
/////////////////////////////////////////////////////////////
// June 12 Initial Version.
/////////////////////////////////////////////////////////////

/**********************************************************************/
// 
/**********************************************************************/
function ThePortNodeList()
{
  this.m_masterNode   = null;
  this.m_cacheList    = null;
  this.m_masteOhtml   = null;
  this.m_cacheSystem  = new Array();
  this.reset();
}


/**********************************************************************/
// 
/**********************************************************************/
ThePortNodeList.prototype.setMasterNode = function(node)
{
/*
  if ((this.m_masterNode==node)&&(this.m_masteOhtml==node.outerHTML)) return; 
  this.m_masterNode=node;
  this.reset();
  debug("rebuilding list with nodeid = "+node.id);
  this.populateList(node);
*/
}

/**********************************************************************/
// 
/**********************************************************************/
/*
ThePortNodeList.prototype.populateList  = function(nodeList,node)
{
 var newNode;
 if ((node.id!=null)&&(node.id.length>0)) 
    this.addItem(nodeList,node,node.id);
  for (var i=0;i<node.childNodes.length;i++) {
    newNode = node.childNodes[i];
    if ((newNode.childNodes.length>0)||(newNode.tagName == "IFRAME")) {
      if (newNode.tagName == "IFRAME")
        this.populateList(nodeList,newNode.contentWindow.document);
      else this.populateList(nodeList,newNode);
      }
    else if ((newNode.id!=null)&&(newNode.id.length>0)) 
            this.addItem(nodeList,newNode,newNode.id);
    }
} 
*/
/**********************************************************************/
// 
/**********************************************************************/
ThePortNodeList.prototype.populateList  = function(nodeList,node)
{
  try {
    var temp;
    if (node == null) {
      return null;
      }
    node = node.firstChild;
    while (node != null){
      if ((node.id!=null)&&(node.id.length>0)) 
        this.addItem(nodeList,node,node.id);
      if (node.tagName == "IFRAME") 
        temp = this.populateList(nodeList,node.contentWindow.document);
      else temp = this.populateList(nodeList,node);
      if (temp != null){
        return temp;
        }
      node = node.nextSibling;
      }
  } catch(e) { }    
  return null;
}
 

/**********************************************************************/
// 
/**********************************************************************/
ThePortNodeList.prototype.reset = function()
{
  this.m_cacheList = null;
  this.m_cacheList = new Array();
}


/**********************************************************************/
// 
/**********************************************************************/
ThePortNodeList.prototype.length = function()
{
  return this.m_cacheList.length;
}


/**********************************************************************/
// 
/**********************************************************************/
ThePortNodeList.prototype.find = function(id)
{
  for (var i =0;i<this.m_cacheList.length;i++) {
    if (this.m_cacheList[i].m_id == id)  
      return this.m_cacheList[i].m_node;
    }
  return null;
}



/**********************************************************************/
// 
/**********************************************************************/
ThePortNodeList.prototype.addItem = function(nodeList,node,id)
{
  var item = new ThePortNodeItem(node,id);
  nodeList.push(item);
}


/**********************************************************************/
//
/**********************************************************************/
function ThePortNodeItem(node,id)
{
  this.m_node = node;
  this.m_id   = id;
}


/**********************************************************************/
// 
/**********************************************************************/
ThePortNodeList.prototype.findNodeList = function(node)
{
  var i=0;
  if (node==null) return;
  while (i<this.m_cacheSystem.length) {
    if (this.m_cacheSystem[i].m_node == node) {
//      if (false) { //(this.m_cacheSystem[i].m_ohtml == node.outerHTML)      
      if (this.m_cacheSystem[i].m_ohtml == node.outerHTML) {     
        return this.m_cacheSystem[i].m_list;
        }
      else {
            this.m_cacheSystem.splice(i,1);
            i = this.m_cacheSystem.length;
           }
      }
     i++;
    }
  var nodeList = this.buildList(node);
  if (nodeList) {
    this.m_cacheSystem.push(new ThePortCacheList(nodeList,node));
    return nodeList;
    }
  return null;
}


/**********************************************************************/
// 
/**********************************************************************/
ThePortNodeList.prototype.buildList = function(node)
{
  var nodeList = new Array();
  //debug("rebuilding list with nodeid = "+node.id);
  this.populateList(nodeList,node);
  if (nodeList.length<=0)
    return null;
  return nodeList;
}


/**********************************************************************/
// 
/**********************************************************************/
ThePortNodeList.prototype.findNodeFromId = function(pNode,id)
{
  try {
    var nodeList = this.findNodeList(pNode);
    if (!nodeList) return;
    for (var i =0;i<nodeList.length;i++) {
      if (nodeList[i].m_id == id)  
        return nodeList[i].m_node;
      }
    }
  catch(e) { }
  return null;
}


/**********************************************************************/
//
/**********************************************************************/
function ThePortCacheList(list,node)
{
  this.m_list  = list;
  this.m_node  = node;
  this.m_ohtml = node.outerHTML;
}

﻿//***********************************************************
// ThePortLogin Object.  
// Author: Steve Soares
// Copyright ThePort Inc.
// No longer Requires Prototype.js
//***********************************************************


function ThePortLogin() 
{
    this.m_sLoginServiceURL = "/apis/login/LoginService.asmx/";
    this.m_oPublicNameNode = null;
    this.m_oWelcomeNode = null;
    this.m_oInputNode   = null;
}


    //*********************************************************************
    //
    //*********************************************************************
    ThePortLogin.prototype.SendLoginUser = function (oWelcomeNode,oInputNode,oPublicNameNode) {
      var otxtLoginEmail = ThePort.Utils.GetObj("txtLoginEmail");
      var otxtLoginPassword = ThePort.Utils.GetObj("pwLoginPassword");
      // Lets make sure the values are good.
      if(otxtLoginEmail.value==ThePort.Common.CONST_EMPTY_STRING){alert("Please enter your email address.");return;}
      if(otxtLoginPassword.value==ThePort.Common.CONST_EMPTY_STRING){alert("Please enter your password.");return;}
      var ocbLoginRemember = ThePort.Utils.GetObj("cbLoginRemember");
      this.m_oPublicNameNode = oPublicNameNode;
      this.m_oWelcomeNode = oWelcomeNode;
      this.m_oInputNode   = oInputNode;
      this.OutputMessage(ThePort.Common.CONST_EMPTY_STRING);   // Clear the output message area...
      
      // Post the data.
      var sPostData = ThePort.Common.CONST_EMPTY_STRING;
      sPostData += "sLoginEmail="+encodeURIComponent(otxtLoginEmail.value);
      sPostData += "&sLoginPassword="+encodeURIComponent(otxtLoginPassword.value);
      sPostData += "&sLoginRememberMe="+encodeURIComponent(String(ocbLoginRemember.checked));
      eUrl = encodeURI(this.m_sLoginServiceURL+"SendLoginUser");
      this.OutputMessage(ThePort.Common.CONST_EMPTY_STRING);
      ThePort.Utils.Ajax('POST',eUrl,ThePort.Utils.Bind(this,"onSendLoginUserResponse"),sPostData);
      
    }


    //*********************************************************************
    //
    //*********************************************************************
    ThePortLogin.prototype.onSendLoginUserResponse = function(originalRequest) { 
        try {
            var bReturnValue = false;
            var oSR = new ThePort.ReplyObject(originalRequest.responseXML);
            // Call an EVENT.
            var boolResponse = false;
            if ((oSR.Response=="true")||(oSR.Response=="yes")||(oSR.Response=="1"))
               boolResponse = true;
            SMUserLogin.Event_LogInResponse(boolResponse,oSR.Data);
        } catch(e){}	 	         
        return bReturnValue;
    }


    //**********************************************************************
    // OPTION::SendEmailPassword  "email_UserPassword.xslt"
    //**********************************************************************
	ThePortLogin.prototype.SendEmailPassword = function(sXSLEmailPasswordFileName){
	    var otxtLoginEmail = ThePort.Utils.GetObj("txtLoginEmail");
	    if(otxtLoginEmail.value==ThePort.Common.CONST_EMPTY_STRING){alert("Please enter your email address.");}
	    else{
 		    eUrl = encodeURI(this.m_sLoginServiceURL+"SendEmailPassword?sLoginEmail="+otxtLoginEmail.value+"&sXSLEmailPasswordFileName="+sXSLEmailPasswordFileName)
            ThePort.Utils.Ajax("GET",eUrl,ThePort.Utils.Bind(this,"onSendEmailPasswordResponse"),null);
	        }
	    }


    //*********************************************************************
    //
    //*********************************************************************
    ThePortLogin.prototype.onSendEmailPasswordResponse = function(originalRequest) { 
        try {
            var bReturnValue = false;
            var oSR = new ThePort.ReplyObject(originalRequest.responseXML);
            // Call an EVENT.
            var boolResponse = false;
            if ((oSR.Response=="true")||(oSR.Response=="yes")||(oSR.Response=="1"))
               boolResponse = true;
            SMUserLogin.Event_SendEmailPasswordResponse(boolResponse,oSR.Data);
        } catch(e){}	 	         
        return bReturnValue;
    }


    //**********************************************************************
    // OPTION::SendResetPasswordEmail
    //**********************************************************************
	ThePortLogin.prototype.SendResetPasswordEmail = function(sXSLEmailResetFileName){
	    var otxtLoginEmail = ThePort.Utils.GetObj("txtLoginEmail");
	    if(otxtLoginEmail.value==ThePort.Common.CONST_EMPTY_STRING){alert("Please enter your email address.");}
	    else{
 		    eUrl = encodeURI(this.m_sLoginServiceURL+"SendResetPasswordEmail?sLoginEmail="+otxtLoginEmail.value+"&sXSLEmailResetFileName="+sXSLEmailResetFileName)
            ThePort.Utils.Ajax("GET",eUrl,ThePort.Utils.Bind(this,"onSendResetPasswordEmailResponse"),null);
	        }
	    }


    //*********************************************************************
    //
    //*********************************************************************
    ThePortLogin.prototype.onSendResetPasswordEmailResponse = function(originalRequest) { 
        try {
            var bReturnValue = false;
            var oSR = new ThePort.ReplyObject(originalRequest.responseXML);
            // Call an EVENT.
            var boolResponse = false;
            if ((oSR.Response=="true")||(oSR.Response=="yes")||(oSR.Response=="1"))
               boolResponse = true;
            SMUserLogin.Event_SendResetPasswordEmailResponse(boolResponse,oSR.Data);
        } catch(e){}	 	         
        return bReturnValue;
    }

	
    //**********************************************************************
    // OPTION::SendPasswordReminder
    //**********************************************************************
	ThePortLogin.prototype.SendPasswordReminder = function(){
	    var otxtLoginEmail = ThePort.Utils.GetObj("txtLoginEmail");
	    if(otxtLoginEmail.value==ThePort.Common.CONST_EMPTY_STRING){alert("Please enter your email address.");}
	    else{
 		    eUrl = encodeURI(this.m_sLoginServiceURL+"SendPasswordReminder?sLoginEmail="+otxtLoginEmail.value)
            ThePort.Utils.Ajax("GET",eUrl,ThePort.Utils.Bind(this,"onSendPasswordReminderResponse"),null);
	        }
	    }


    //*********************************************************************
    //
    //*********************************************************************
    ThePortLogin.prototype.onSendPasswordReminderResponse = function(originalRequest) { 
        try {
            var bReturnValue = false;
            var oSR = new ThePort.ReplyObject(originalRequest.responseXML);
            // Call an EVENT.
            var boolResponse = false;
            if ((oSR.Response=="true")||(oSR.Response=="yes")||(oSR.Response=="1"))
               boolResponse = true;
            SMUserLogin.Event_SendPasswordReminderResponse(boolResponse,oSR.Data);
        } catch(e){}	 	         
        return bReturnValue;
    }


    //**********************************************************************
    // Write output Message.
    //**********************************************************************
	ThePortLogin.prototype.OutputMessage = function(sMessage){
	    try {
		    var oMessage = ThePort.Utils.GetObj("loginOutputMessage");
		    oMessage.innerHTML = sMessage;
		    oMessage.style.display="block";	
    		} catch(e) {}
 		}


    //**********************************************************************
    // Write output Message.
    //**********************************************************************
	ThePortLogin.prototype.Register = function(){
	    window.location = "/community/app/reg/tptwiz/step.aspx";
	}


    //**********************************************************************
    // Keyboard handler for hitting <RETURN> in a text box.
    //**********************************************************************
    ThePortLogin.prototype.KeyDownHandler = function (e,c) {
        var ev = e || window.event;
        if (ev.keyCode == 13) {
		    // cancel the default submit
		    ev.returnValue=false;
		    ThePort.Utils.StopEvent(ev);
	        document.getElementById(c).click();
	        }
    }

﻿//***********************************************************
// ThePortServiceReply Decoder Object.  
// Author: Steve Soares
// Copyright ThePort Inc.
//***********************************************************
//***********************************************************
//***********************************************************
// D E P R I C A T E D !!!  See ThePortXSLUtilities.js!!!
// D E P R I C A T E D !!!  See ThePortXSLUtilities.js!!!
// D E P R I C A T E D !!!  See ThePortXSLUtilities.js!!!
// D E P R I C A T E D !!!  See ThePortXSLUtilities.js!!!
// D E P R I C A T E D !!!  See ThePortXSLUtilities.js!!!
// D E P R I C A T E D !!!  See ThePortXSLUtilities.js!!!
//***********************************************************
//***********************************************************
//***********************************************************
function ServiceReply(oXmlDoc)
{	
	this.m_bResponse    = false
    this.m_sResponse    = "";
    this.m_sData        = "";
    this.m_sStyle       = "";
	this.loadReply(oXmlDoc);
}


// Two older routines needing to be updated in SMUserLogin.xslt
ServiceReply.prototype.getResponse = function() {return this.m_bResponse;}
ServiceReply.prototype.getMessage = function() {return this.m_sData; }


// Newer functions...
ServiceReply.prototype.getResponseText = function() {return this.m_sResponse;}
ServiceReply.prototype.getDataText = function() {return this.m_sData;}
ServiceReply.prototype.getStyleText = function() {return this.m_sStyle;}


//******************************************************************
//
//******************************************************************
ServiceReply.prototype.getProcessedXML = function() {
    try {
        oProcessor = new ThePortXMLProcessor();
        oProcessor.loadXMLText(this.getDataText());
        oProcessor.loadXSLText(this.getStyleText());
        return (oProcessor.transform())
        } 
    catch (e) { return "Error in XSL transform."}
}


//****************************************************************
// By default the tags processed are always:
// Title, description, link & pubdate
// The caller may add any number of extra tags/attrs to this call.
// For example:
// myRssFeed.loadFeed(xmlDoc,'content:encoded','enclosure//@url')) 
//****************************************************************
ServiceReply.prototype.loadReply = function(oXmlDoc) {	
  this.m_bResponse = false;
  try {
      var sResponse	= new String(ThePortUtilities.GetTagValue(oXmlDoc,"Response")).toLowerCase();
      if ((sResponse=="true")||(sResponse=="yes")||(sResponse=="1"))
        this.m_bResponse = true;
      this.m_sResponse	= ThePortUtilities.GetTagValue(oXmlDoc,"Response");
      this.m_sData	= ThePortUtilities.GetTagValue(oXmlDoc,"Data");
      this.m_sStyle	= ThePortUtilities.GetTagValue(oXmlDoc,"Style");
      }
  catch (e) { return false; }
  return true;
}
//**********************************************
// End of ServiceReply Decoder.
//**********************************************

﻿/***************************************************/
/* ThePort XML/JSON Processing routines.           */
/* Author: Steve Soares                            */
/* Copyright ThePort Inc.                          */
/* Description:                                    */
/* Current implementation depends on no            */
/* other third party library.                      */
/***************************************************/


/***********************************************************/
/***********************************************************/
/**               CONSTANTS :: ThePort.Common             **/
/***********************************************************/
/***********************************************************/
function ThePortRegisterNS (ns) {
    var bCreated = false;
    var sNSElements = ns.split(".");
    var oNode = window;
    for(var i=0; i<sNSElements.length; i++)  {
        if(typeof oNode[sNSElements[i]] == 'undefined') {
        oNode[sNSElements[i]] = new Object();
        bCreated = true;
        }
      oNode = oNode[sNSElements[i]];
      }
    return bCreated;
}      

/***********************************************************/
/***********************************************************/
/**                   MODULE::ThePort                     **/
/***********************************************************/
/***********************************************************/
if (ThePortRegisterNS("ThePort")) {
    ThePort = {
    Initialize : function () {
        if (ThePortRegisterNS("ThePort.Initialized")) {
            ThePort.Debug.Log("Framework Initializing.")
            /*******************************************************/
            /*   The Framework let's everyone know all code has    */
            /* been loaded at this point.  This allows "triggered" */
            /* modules to begin checking for visibility changes.   */
            /*******************************************************/
            ThePort.Debug.Log("Initializing any triggers.")
            ThePort.XSL.CallAllModuleFunction("StartVisibilityInterval");
            var oTabSets = ThePort.Tabs.Array;
            if ((oTabSets!=null)&&(oTabSets.length>0)) {
                ThePort.Debug.Log("Initializing "+oTabSets.length +" tab sets.")
                for (var i=0;i<oTabSets.length;i++) {
                    oTabSets[i].Initialize();
                    }
                }
            }    
        }
     }
}

if (ThePortRegisterNS("ThePort.Module")) {
	ThePort.Module.Array = new Array();
	}
	
	

﻿/***********************************************************/
/***********************************************************/
/**                MODULE :: ThePort.Common               **/
/***********************************************************/
/***********************************************************/
if (ThePortRegisterNS("ThePort.Common")) {
    ThePort.Common = {

    //***********************
    // Standard defines.
    //***********************
    CONST_EMPTY_STRING      : "",
    CONST_UNDEFINED         : "undefined",
    CONST_TYPE_FUNCTION     : "function",
    CONST_ERROR_MESSAGE     : "Error",
    CONST_OPERATION_MORE    : "More",
    CONST_OPERATION_REFRESH : "Refresh",

    //***********************
    // Web form variables.
    //***********************
    CONST_FORM_POST         : "POST",
    CONST_FORM_GET          : "GET",
    CONST_FORM_DELETE       : "DELETE",
    CONST_FORM_PUT          : "PUT",

    //*****************
    // Types of data
    //*****************
    CONST_FORMAT_XML        : "xml",
    CONST_FORMAT_JSON       : "json",

    //******************
    // Content types.
    //******************
    CONST_CONTENTTYPE_JSON1 : "application/javascript",
    CONST_CONTENTTYPE_JSON2 : "application/json",
    CONST_CONTENTTYPE_JSON3 : "text/json",
    CONST_CONTENTTYPE_XML   : "text/xml",
    CONST_CONTENTTYPE       : "Content-type",
    CONST_FORM_POST_URLENC  : "application/x-www-form-urlencoded",
    CONST_CONTENTLENGTH     : "Content-length",
    CONST_HEADER_CONNECTION : "Connection",
    CONST_HEADER_CONN_CLOSE : "close",

    //*******************************
    // ActiveX object name for Ajax.
    //*******************************
    CONST_ACTIVEX1_AJAX_OBJ : "Msxml2.XMLHTTP",
    CONST_ACTIVEX2_AJAX_OBJ : "Microsoft.XMLHTTP",
    CONST_ACTIVEX_XML_OBJ   : "Microsoft.XMLDOM",

    //**************************************
    // Web services query string variables.
    //**************************************
    QS_NAME                 : "sName",
    QS_CACHE_RESET          : "SYS_CACHE_RESET",
    //QS_CACHE              : "iCache",
    //QS_CACHEBYUSER        : "iCacheByUser",
    QS_OBJECTID             : "sObjectID",
    QS_DATA                 : "sData",
    QS_DATAFORMAT           : "sFormat",
    QS_CALLBACKFN           : "CallBack",
    QS_HASH                 : "sHash",
    QS_COMMENT              : "sComment",
    QS_CONTEXTID            : "sContextID",
    QS_RESULTSTART          : "iResultStart",
    QS_NUMRESULTS           : "iNumResults",
    QS_OPERATION            : "SYS_Operation",
    QS_POPUP                : "SYS_PopUp",

    //******************
    // Generic Symbols
    //******************
    CONST_COMMA             : ",",
    CONST_EQUALS            : "=",
    CONST_QUESTION_MARK     : "?",

    //**********************
    // XML Decoded Symbols
    //**********************
    CONST_AMPERSAND         : "&",
    CONST_SINGLE_QUOTE      : "'",
    CONST_DBL_QUOTE         : '"',
    CONST_GREATER_THAN      : ">",
    CONST_LESS_THAN         : "<",

    //**********************
    // XML Encoded Symbols
    //**********************
    CONST_ENC_AMPERSAND     : "&amp;",
    CONST_ENC_SINGLE_QUOTE  : "&apos;",
    CONST_ENC_DBL_QUOTE     : "&quot;",
    CONST_ENC_GREATER_THAN  : "&gt;",
    CONST_ENC_LESS_THAN     : "&lt;",

    //*************************
    // HTTP ReadyState Values
    //*************************
    CONST_HTTP_READYSTATE_UNINITIALIZED : 0,
    CONST_HTTP_READYSTATE_LOADING       : 1, 
    CONST_HTTP_READYSTATE_LOADED        : 2,
    CONST_HTTP_READYSTATE_INTERACTIVE   : 3, 
    CONST_HTTP_READYSTATE_COMPLETED     : 4,

    CONST_STYLE_DISPLAY_ON              : "",
    CONST_STYLE_DISPLAY_OFF             : "none",

    CONST_AJAX_URL          : "/apis/Rest/RestService.ashx"

    }   /* End Constants */
}  /* End Namespace */

﻿/***********************************************************/
/***********************************************************/
/**                MODULE :: ThePort.Utils                **/
/***********************************************************/
/***********************************************************/
if (ThePortRegisterNS("ThePort.Utils")) {

ThePort.Utils = {
/*******************************/
/*  Ajax GET/POST Routine...   */
/*******************************/
Ajax : function (sCommand,sUrl,oBindFunction,sPostData) {
    var httpRequest = null;
    // Make the default a GET operation if none specified.
    if ((sCommand==null)||(sCommand == ThePort.Common.CONST_EMPTY_STRING))
        sCommand = ThePort.Common.CONST_FORM_GET;
    if (typeof XMLHttpRequest != ThePort.Common.CONST_UNDEFINED) {
        httpRequest = new XMLHttpRequest();
        }
    else if (typeof ActiveXObject != ThePort.Common.CONST_UNDEFINED) {
            try {
                httpRequest = new ActiveXObject(ThePort.Common.CONST_ACTIVEX1_AJAX_OBJ); 
                }
            catch (e) {
                try {
                    httpRequest = new ActiveXObject(ThePort.Common.CONST_ACTIVEX2_AJAX_OBJ); 
                    }
                    catch(e) { /* we're toast. */ }
                }
            }
    if (httpRequest != null) {
        httpRequest.open(sCommand, sUrl, true);
        var fn = function () {
                            if (httpRequest.readyState == ThePort.Common.CONST_HTTP_READYSTATE_COMPLETED) 
                                oBindFunction(httpRequest);
                             }
        httpRequest.onreadystatechange = fn;
        //if (sCommand == ThePort.Common.CONST_FORM_POST) {
        if (sPostData!=null) {
            // Set content type.
            httpRequest.setRequestHeader(ThePort.Common.CONST_CONTENTTYPE, ThePort.Common.CONST_FORM_POST_URLENC);
            // Set content length.
            httpRequest.setRequestHeader(ThePort.Common.CONST_CONTENTLENGTH, sPostData.length);
            // Set header "connection" to "close"
            httpRequest.setRequestHeader(ThePort.Common.CONST_HEADER_CONNECTION, ThePort.Common.CONST_HEADER_CONN_CLOSE);    
            }
        }
    // Send the data...
    httpRequest.send(sPostData);
    },


/****************************/
/* Closure Binder Functions */
/****************************/
  /**************************/
  /* Generic bind function. */
  /**************************/
Bind : function (oObject, fMethodName) {
    return function(o){oObject[fMethodName](o);}
    },
    /****************************************************************/    
    /* This binder function will allow you to send additional parms */
    /* to your function.                                            */
    /****************************************************************/    
Binder : function (oObject, fMethodName) {
    var oArgs = ThePort.XSL['Shift2Args'].apply(null, arguments); 
    return function(o){
        if (typeof o != ThePort.Common.CONST_UNDEFINED) {
            [].unshift.call(oArgs,o);
            }
        return oObject[fMethodName].apply(oObject,oArgs);}
    },
    /* this binder DOES Not Push(hence NP) any additional arg in the callee */
BinderNP : function (oObject, fMethodName) {
    var oArgs = ThePort.XSL['Shift2Args'].apply(null, arguments); 
    return function(){
        return oObject[fMethodName].apply(oObject,oArgs);}
    },
    /****************************************************************/    
    /* This supports additional params AND ALSO examines/expects a  */
    /* HTTP response ReplyObject and looks to see if the server     */
    /* returned an exception encoded in the replyObject and sends   */
    /* it to the debug window.                                      */
    /****************************************************************/    
AjaxBind : function (oObject, fMethodName) {
    var oArgs = ThePort.XSL['Shift2Args'].apply(null, arguments); 
    return function(o){
        // Log a server exception if has been returned from the call.
        if (ThePort.Debug.window)
            ThePort.Utils.LogServerException(o);
        if (typeof o != ThePort.Common.CONST_UNDEFINED) {
            [].unshift.call(oArgs,o);  
            }
        return oObject[fMethodName].apply(oObject,oArgs);}
    },

//********************************************************************
// findPosX & findPosY code by:
// http://www.quirksmode.org/js/findpos.html#
//********************************************************************
findPosX : function (obj) {
  var curleft = 0;
  if (obj.offsetParent) {
	while (obj.offsetParent) {
	  curleft += obj.offsetLeft;
	  obj = obj.offsetParent;
  	  }
  	}
  else if (obj.x)
		  curleft += obj.x;
  return curleft;
},


findPosY : function (obj) {
  var curtop = 0;
  if (obj.offsetParent) {
	while (obj.offsetParent) {
	  curtop += obj.offsetTop;
	  obj = obj.offsetParent;
	  }
	}
  else if (obj.y)
		  curtop += obj.y;
  return curtop;
},


/******************************************************************/
/* After the AJAX call, the response is coming into this function */
/******************************************************************/
LogServerException : function (oResponse) {
    try {
        var oReplyObject = ThePort.Utils.GetReplyObject(oResponse)
        if (typeof oReplyObject == ThePort.Common.CONST_UNDEFINED)
            return
        if (oReplyObject.ReturnCode<0) {
            ThePort.Debug.Log("          ****************************************************\n          ** Server ERROR or Exception returned inside Ajax callback **\n          ****************************************************\nException Message: '"+ oReplyObject.Message + "'\nDetails:\n" + oReplyObject.Data)
            }
    } catch(e) {}
},


/*************************************/
/* UnRegister lowest order namespace */
/*************************************/
RegisterModule : function (ns) {
 var found = false;
 var sNSElements = ns.split(".");
 var oNode = window;
 for(var i=0; i<sNSElements.length; i++)  {
    if(typeof oNode[sNSElements[i]] != ThePort.Common.CONST_UNDEFINED) {
      if (i==(sNSElements.length-1)) {
        delete oNode[sNSElements[i]];
        found = true;
        break;
        }
      oNode = oNode[sNSElements[i]];
      }
    }
    
 if (found) {
 	if (typeof ThePort.Module.Array == ThePort.Common.CONST_UNDEFINED)
		return;
	for (var j=0;j<ThePort.Module.Array.length;j++) 
	    if (ThePort.Module.Array[j].m_sModuleName == ns) {
	        ThePort.Module.Array[j].CleanUp();
	        delete ThePort.Module.Array[j];
	        ThePort.Module.Array.splice(j,1);
	        break;
	        }
    } 
  ThePortRegisterNS(ns);
},  


/************************************************/
/*                                              */
/************************************************/
GetTagValue : function(oDoc, sTagName) {
    try {
        if (oDoc) {
            var nodeList = oDoc.getElementsByTagName(sTagName);
            return ThePort.Utils.GetValueFromNode(nodeList[0]);
            }
    } catch(e) {}
    return null;
    },


/**************************************************/
/* Some little helper functions when posting data */
/**************************************************/
GetVariablePair : function(sName,sValue) {
    var sData = ThePort.Common.CONST_EMPTY_STRING;
	sData += sName;
	sData += ThePort.Common.CONST_EQUALS;
    sData += encodeURIComponent(sValue);
    return sData;
   },

/**************************************************/
/* Some little helper functions when posting data */
/**************************************************/
AddDictionaryPair : function(sName,sValue) {
    var sData = ThePort.Common.CONST_AMPERSAND;
	sData += ThePort.Utils.GetVariablePair(sName,sValue);
    return sData;
   },

/**************************************************/
/* Some little helper functions when posting data */
/**************************************************/
AddVariablePair : function(sName,sValue) {
    var sData = ThePort.Common.CONST_AMPERSAND;
	sData += ThePort.Utils.GetVariablePair(sName,sValue);
    return sData;
   },


/************************************************/
/*                                              */
/************************************************/
GetTagAttributeValue : function(oDoc, sTagName, sAttribName) {
    if (oDoc) {
        var nodeList = oDoc.getElementsByTagName(tagName);
        return this.getAttrValueFromNode(nodeList[0],sAttribName);
        }
    return null;
    },


/********************************************************************/
/* We need to use this function to get the value out of a node.     */
/* because it works differently in different browsers.              */
/* This function does NOT rely on any internal vars of the object   */
/* so it can be extracted or called from anywhere without problems. */
/********************************************************************/
GetValueFromNode : function(node) {
    if (typeof node.text != ThePort.Common.CONST_UNDEFINED) 
        return node.text;
    else if (typeof node.textContent != ThePort.Common.CONST_UNDEFINED) 
            return node.textContent;
         else if (typeof node.innerText != ThePort.Common.CONST_UNDEFINED) 
		        return node.innerText;
	          else {
                    switch (node.nodeType) {
                      case 3:		// Node Text
                      case 4:		// Node CData
                          return node.nodeValue;
                          break;
                      case 1:		// Node Element
                      case 11:	// Document fragment
                          var retVal = new String();
                          for (var i = 0; i < node.childNodes.length; i++) 
                              retVal += GetNodeValue(node.childNodes[i]);
                          return retVal;
                      default: return ThePort.Common.CONST_EMPTY_STRING;
                      }
		        }
    },


/*****************************************************/
/* Get a particular attribute of a particular node.  */
/*****************************************************/
GetAttrValueFromNode : function(node,attr) {
    try {
 	    for (l=0;l<node.attributes.length;l++) {
	        if (node.attributes[l].nodeName == attr)
                return(node.attributes[l].nodeValue);
            }
        } catch(e) { return null;}
    return null;
    },
    
// pass by reference.
Parm : function(value){this.value = value;},

/******************************/
/*          GetObj            */
/******************************/
GetObj : function (sID) {
    if ((sID==null) || (sID.length<=0))
        return null;
	return document.getElementById(sID); 
    },
    
GotoURL: function(sURL) {
    if (sURL!=null && sURL.length>0)
        window.location.href = sURL;
    },  
    
OpenWindow: function(sURL) {
    if (sURL!=null && sURL.length>0)
        {var o = window.open(sURL,sURL);}
    },   
    
StopEvent : function(eEvent) {
    if (eEvent.stopPropagation) 
        eEvent.stopPropagation();
    else eEvent.cancelBubble = true;
    },
    
Show : function(sID) {
   var oObj = ThePort.Utils.GetObj(sID);
   if (oObj)
        oObj.style.display = ThePort.Common.CONST_STYLE_DISPLAY_ON;
   },
        
Hide : function(sID) {
   var oObj = ThePort.Utils.GetObj(sID);
   if (oObj) 
        oObj.style.display = ThePort.Common.CONST_STYLE_DISPLAY_OFF;
   },
   
Toggle : function(sID) {
   var oObj = ThePort.Utils.GetObj(sID);
   if (oObj)
        if (oObj.style.display == ThePort.Common.CONST_STYLE_DISPLAY_OFF)
            ThePort.Utils.Show(sID);
        else ThePort.Utils.Hide(sID);
   },

SetClassName : function(sID,sClassName) {
   var oObj = ThePort.Utils.GetObj(sID);
   if (oObj)
      oObj.className = sClassName;
   },

SetInnerHTML : function(sID,sHTML) {
   var oObj = ThePort.Utils.GetObj(sID);
   if (oObj)
      oObj.innerHTML = sHTML;
   },

ScrollPageToNodeTop : function(sID) {
    var oNode = ThePort.Utils.GetObj(sID);
    if (!oNode){
        ThePort.Debug.Log("Unable to scroll to top of Node with ID="+sID);
        return;
        }
    ThePort.Debug.Log("Scrolling to top of Node with ID="+sID);
	var offset = 0;
	while(oNode.offsetParent) {
		offset += oNode.offsetTop;
		oNode = oNode.offsetParent;
	    }
	/* Lets only scroll if we need to scroll */
	var xp = new ThePort.Utils.Parm(0);    
	var yp = new ThePort.Utils.Parm(0);    
	ThePort.Utils.GetScrollPos(xp,yp);
	if (yp.value>offset)
        window.scrollTo(0, offset);
},        

GetScrollPos : function(xParm,yParm) 
{
  var px = 0, py = 0;
  if(typeof(window.pageYOffset)=='number') {
    py = window.pageYOffset;
    px = window.pageXOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop)){
            py = document.body.scrollTop;
            px = document.body.scrollLeft;
            } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop)){
                      py = document.documentElement.scrollTop;
                      px = document.documentElement.scrollLeft;
                      }
  xParm.value = px;
  yParm.value = py;
},


AddScriptTag : function(sId,sScript)
{
  var oNode = document.getElementById(sId);
  oNode.innerHTML = sScript;
  var x = oNode.getElementsByTagName("script");
  var h = document.getElementsByTagName("head")[0];
  for(var i=0;i<x.length;i++)	{
 	var s = document.createElement("script");
	s.type="text/javascript";
	h.appendChild(s);
	s.text=x[i].text;
    }
},

AddHeadScriptTag : function (sScript)
{
    var h = document.getElementsByTagName("head")[0];
    var s = document.createElement("script");
    s.type="text/javascript";
    s.text=sScript;
    h.appendChild(s);
},




IsVisible : function(obj)
{
  if (obj == document) return true

  if (!obj) return false
  if (!obj.parentNode) return false
  if (obj.style) {
  if (obj.style.display == 'none') return false
  if (obj.style.visibility == 'hidden') return false
  }

  //Try the computed style in a standard way
  if (window.getComputedStyle) {
  var style = window.getComputedStyle(obj, "")
  if (style.display == 'none') return false
  if (style.visibility == 'hidden') return false
  }

  //Or get the computed style using IE's silly proprietary way
  var style = obj.currentStyle
  if (style) {
  if (style['display'] == 'none') return false
  if (style['visibility'] == 'hidden') return false
  }

  return ThePort.Utils.IsVisible(obj.parentNode)
},

/******************************************************/   
/* http://www.openjs.com/scripts/data/json_encode.php */
/******************************************************/   
Obj2Json : function(arr) {
    var parts = [];
    var is_list = (Object.prototype.toString.apply(arr) === '[object Array]');

    for(var key in arr) {
    	var value = arr[key];
        if(typeof value == "object") { //Custom handling for arrays
            if(is_list) parts.push(obj2json(value)); /* :RECURSION: */
            else parts[key] = obj2json(value); /* :RECURSION: */
        } else {
            var str = "";
            if(!is_list) str = '"' + key + '":';

            //Custom handling for multiple data types
            if(typeof value == "number") str += value; //Numbers
            else if(value === false) str += 'false'; //The booleans
            else if(value === true) str += 'true';
            else str += '"' + value + '"'; //All other things
            // :TODO: Is there any more datatype we should be in the lookout for? (Functions?)

            parts.push(str);
        }
    }
    var json = parts.join(",");
    
    if(is_list) return '[' + json + ']';//Return numerical JSON
    return '{' + json + '}';//Return associative JSON
},
   
/* Sample:
    <input type="text" onKeydown="ThePort.Utils.KeyDownHandler(event,'btnGo');"/> 
    <button id="btnGo" onclick="DoSomething();" type="button">
*/   
    
GetReplyObject : function(oResponse) {
try {
    var sContentType= oResponse.getResponseHeader(ThePort.Common.CONST_CONTENTTYPE);
    // Is this a JSON response?   We look at the content type header to see what we're getting.
    //          See if the content coming in uses any of the JSON content type.
    if ((sContentType.indexOf(ThePort.Common.CONST_CONTENTTYPE_JSON1)>=0) || 
        (sContentType.indexOf(ThePort.Common.CONST_CONTENTTYPE_JSON2)>=0) || 
        (sContentType.indexOf(ThePort.Common.CONST_CONTENTTYPE_JSON3)>=0)) {  
            // create the JSON response out of thin air.
             eval(" var oReply = "+oResponse.responseText);
             return oReply;
            }
    return new ThePort.ReplyObject(oResponse.responseXML);
    } catch(e)  {
                ThePort.Debug.Log("Error creating a ReplyObject from the Ajax return data.\nPayload-Data::"+oResponse.responseText);
                }
},

ReplaceQSVariable : function (sUrl,sKey,sValue) {
    var re = new RegExp("([?|&])" + sKey + "=.*?(&|$)","i");
    if (sUrl.match(re))
        return sUrl.replace(re,'$1' + sKey + ThePort.Common.CONST_EQUALS + sValue + '$2');
    else
        return sUrl + ThePort.Common.CONST_AMPERSAND + sKey + ThePort.Common.CONST_EQUALS + sValue;
},

GetQSVariable : function (sUrl, sKey) {
   try {
        sKey = sKey.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
        var regexS = "[\\?&]"+sKey+"=([^&#]*)";
        var regex = new RegExp( regexS );
        var results = regex.exec( sUrl );
        if( results == null )
        return ThePort.Common.CONST_EMPTY_STRING;
        else return results[1];
    } catch(e)  { return ThePort.Common.CONST_EMPTY_STRING; }
},
    
// Specific Handler.  NOT GENERIC.
KeyDownHandler : function (eEvent,sButtonID) {
    var e = eEvent || window.event;
    if (ThePort.Event.GetEventKeyCode(e) == 13) {
	    // cancel the default submit
	    e.returnValue=false;
	    ThePort.Utils.StopEvent(e);
        ThePort.Utils.GetObj(sButtonID).click();
        }   
    },
    
Decode64 : function (input) {
  
    var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  
      var output = ThePort.Common.CONST_EMPTY_STRING;
      var chr1, chr2, chr3 = ThePort.Common.CONST_EMPTY_STRING;
      var enc1, enc2, enc3, enc4 = ThePort.Common.CONST_EMPTY_STRING;
      var i = 0;
  
      // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
      // var base64test = /[^A-Za-z0-9\+\/\=]/g;
      // if (base64test.exec(input)) {
      // Errors in the base64 code.  Bad chars.
      // }
      // input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ThePort.Common.CONST_EMPTY_STRING);
      do {
         enc1 = keyStr.indexOf(input.charAt(i++));
         enc2 = keyStr.indexOf(input.charAt(i++));
         enc3 = keyStr.indexOf(input.charAt(i++));
         enc4 = keyStr.indexOf(input.charAt(i++));
         chr1 = (enc1 << 2) | (enc2 >> 4);
         chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
         chr3 = ((enc3 & 3) << 6) | enc4;
         output = output + String.fromCharCode(chr1);
         if (enc3 != 64) {
            output = output + String.fromCharCode(chr2);
         }
         if (enc4 != 64) {
            output = output + String.fromCharCode(chr3);
         }
      } while (i < input.length);
      return unescape(output);
   },
   
InitHandler: function (onLoadFunction) {

    // Moziller 
    if (document.addEventListener) {
        document.addEventListener("DOMContentLoaded", onLoadFunction, false);
        return;
        }
    // IE 
    if (document.getElementById) {
        var deferScript = document.getElementById('_port_xsl_script_'); 
        if (deferScript) {
            deferScript.onreadystatechange = function() {
                if (this.readyState == "complete") {
                    onLoadFunction();
                    }
                };
            // Immediate check, right away...
            deferScript.onreadystatechange();
            // Stop IE leaks 
            deferScript = null;
            }
        return;
        }
    // Safari 
    if (/WebKit/i.test(navigator.userAgent)) { 
        var _timer = setInterval(function() {    
            if (/loaded|complete/.test(document.readyState)) {      
                clearInterval(_timer);      
                onLoadFunction(); // Doc is loaded.  Call our func
                }  
            }, 10);
        return;
        }
    // Other browsers 
    window.onload = onLoadFunction;
    },
    
PopWindow : function (url,w,h) { 
        try {
          if (window.ThePortPopupWindow) {
            window.ThePortPopupWindow.close();
            window.ThePortPopupWindow = null;
            }
        } catch(e){}
        try {
          var mh = h;
          var mw = w;
          var vertpos = (mw/2);
          var horpos = (mh/2);
          var swcalc = (screen.width/2);
          var shcalc = (screen.height/2);
          var tlt = (swcalc-vertpos);
          var tll = (shcalc-horpos);
          ThePortPopupWindow = window.open(url,"popwindow","location=1,toolbar=1,scrollbars=1,status=1,menubar=1,resizable=1,width="+mw+",height="+mh);

        } catch(e){}
      },
    
PopWindow2: function (u,w,h)
    {
    win=window.open(u,"PopWindow","scrollbars=1,status=1,resizable=1,menubar=1,width="+w+"height="+h);
    win.focus()
    },
   
GetObjByClassName: function (strClassName, objContainer) {

        var ar = arguments[2] || new Array();
        var re = new RegExp("\\b" + strClassName + "\\b", "g");
            if ( re.test(objContainer.className) ) {
                ar.push( objContainer );
            }
            for ( var i = 0; i < objContainer.childNodes.length; i++ ){
                GetObjByClassName( strClassName, objContainer.childNodes[i], ar ); // this needs to call itself here.
                return ar;
            }
    },
    
LoadHTMLIntoNode: function (oNode,content) {
        var search = content; 
        var script; 
        
        //***************************************************************************//
        //** ADD THE CONTENT TO THE NODE **BEFORE** ADDING THE JS TO THE DOM  -SMS **//
        //***************************************************************************//
        oNode.innerHTML=content; 
        // Match <script> as well as <script text=...etc      
        while( script = search.match(/(<script(.*?)>\s*(<!--)?)/i)) 
        { 
          search = search.substr(search.indexOf(RegExp.$1) + RegExp.$1.length); 
          if (!(endscript = search.match(/((-->)?\s*<\/script>)/))) break; 
          block = search.substr(0, search.indexOf(RegExp.$1)); 
          search = search.substring(block.length + RegExp.$1.length); 
          var oScript = document.createElement('script'); 
          oScript.text = block; 
          document.getElementsByTagName("head").item(0).appendChild(oScript); 
        } 
    }    
       
  } /* End Module */

} /* End Namespace */﻿/***********************************************************/
/***********************************************************/
/**                CLASS :: ThePort.XMLProcessor          **/
/***********************************************************/
/***********************************************************/

if (ThePortRegisterNS("ThePort.XMLProcessor")) {
    ThePort.XMLProcessor = function() {   
        this.m_sXml           = null; // My original xml string
        this.m_oXml           = null; // My xml document
        this.m_xsltProcessor  = null; // FF's xsl processor
        this.m_xsl            = null; // xsl used with the xml.  This will get changed depending on XSL params used.
        this.m_xslOriginal    = null; // Original copy of the xsl transform.
        this.m_sTree          = ThePort.Common.CONST_EMPTY_STRING;   // The text tree output.
        this.m_callback       = null;
        this.m_ajaxBusy       = false;
        }

    /******************************/
    /*  Transformer the XML/XSL.  */
    /******************************/
    ThePort.XMLProcessor.prototype.transform = function() {
        var xmlDoc = this.m_oXml;
        var xslDoc = this.m_xsl;
        try {
            /* Handle FireFox first... */
            if (typeof XSLTProcessor != ThePort.Common.CONST_UNDEFINED) {
                if (!this.m_xsltProcessor) {
                    this.m_xsltProcessor = new XSLTProcessor();
                    this.m_xsltProcessor.importStylesheet(xslDoc);
                    }
                try {
                    try {
                        var node = this.m_xsltProcessor.transformToDocument(xmlDoc);
                    } catch(e) { }
                    var xmlSerializer = new XMLSerializer();
                    var retString = xmlSerializer.serializeToString( node );
                    return retString;
                } catch(e) {}
              }
            else {
                 return (xmlDoc.transformNode(xslDoc));
                 }
            } catch(e) { }
        return ThePort.Common.CONST_EMPTY_STRING;
        }


    /***********************************/
    /*  Load an XML string into a DOM  */
    /***********************************/
    ThePort.XMLProcessor.prototype.loadXMLText = function(sXml) {
        this.m_sXml = sXml;
        this.m_oXml = ThePort.XSL.LoadDocument(sXml);
        }

    /**********************************************************************/
    // Revert to original XML.
    /**********************************************************************/
    ThePort.XMLProcessor.prototype.revert = function(sXml) {
        this.loadXMLText(this.m_sXml);
        }

    //**************************************************************
    //
    //**************************************************************
    ThePort.XMLProcessor.prototype.setNodeEventValue = function(obj,xPath) {
        var sValue = obj.value;
        this.setNodeValue(xPath,sValue);
        }

    /******************************************/
    /* Set the XSL style sheet from a string. */
    /******************************************/
    ThePort.XMLProcessor.prototype.loadXSLText = function (sXsl) {
        this.m_xsl = ThePort.XSL.LoadDocument(sXsl);
        /* Reset the xslProcessor... */
        if (typeof XSLTProcessor != ThePort.Common.CONST_UNDEFINED) {
            this.m_xsltProcessor = null;
            this.m_xsltProcessor = new XSLTProcessor();
            this.m_xsltProcessor.importStylesheet(this.m_xsl);
            }
        }

    //****************************************/
    /*  Set the value of some XPathed node.  */
    //****************************************/
    ThePort.XMLProcessor.prototype.SetNodeEventValue = function(obj,xPath) {
        var sValue = obj.value;
        this.setNodeValue(xPath,sValue);
        }


    /******************************/
    /*  Set Node value via XPath  */
    /******************************/
    ThePort.XMLProcessor.prototype.SetNodeValue = function(xPath,sValue) {
        // The IE way...
        if (window.ActiveXObject) {
            var oNode = this.m_oXml.selectNodes(xPath);
            if ((oNode!=null)&&(oNode.length>0))
                oNode[0].text = sValue
            }
        else {
            // And all the other browsers...
            var oNodes = this.m_oXml.evaluate(xPath, this.m_oXml, null, XPathResult.ANY_TYPE, null);
            var result = oNodes.iterateNext();
            if (result)
              result.childNodes[0].nodeValue = sValue
            }
        }
        
        
    /*****************************/
    /* Get Node value via XPath  */
    /*****************************/
    ThePort.XMLProcessor.prototype.getNodeValue = function(xPath) {
        var obj;
        // The IE way...
        if (window.ActiveXObject) {
            var oNode = this.m_oXml.selectNodes(xPath);
            if (oNode!=null)
                return oNode[0].text
            }
        else {
            // And all the other browsers...
            var oNodes = this.m_oXml.evaluate(xPath, this.m_oXml, null, XPathResult.ANY_TYPE, null);
            var result = oNodes.iterateNext();
            if (result)
                return result.childNodes[0].nodeValue
            }
        return null;
        }
        

    /************************************************/
    /*             DEBUG DISPLAY ROUTINE            */
    /************************************************/
    ThePort.XMLProcessor.prototype.parse = function(oDoc) {
        if (typeof oDoc.tagName != 'undefined') {
            this.m_sTree+='<ul><li>';
            this.m_sTree+='&lt;<b>'+oDoc.tagName+'</b>';
            // Process attributes.
            if (oDoc.attributes) {
                for(var i=0; i<oDoc.attributes.length; i++) {
                    var attrName=oDoc.attributes[i].name
                    var attrValue = ThePort.Utils.GetAttrValueFromNode(oDoc,attrName);
                    this.m_sTree+=" "+attrName+"='"+attrValue+"'"
                    }
                }
            this.m_sTree+='&gt; : ';
            if(oDoc.hasChildNodes()) {
                for(var j=0; j<oDoc.childNodes.length; j++) {
                    this.parse(oDoc.childNodes[j]);
                    }
                }
            this.m_sTree+='</li></ul>';
            }
        else this.m_sTree+=ThePort.Utils.GetValueFromNode(oDoc);
        }


    /************************************************/
    /*                 getTagValue                  */
    /************************************************/
    ThePort.XMLProcessor.prototype.getTagValue = function(sTagName) {
        return ThePort.Utils.GetTagValue(this.m_oXml,sTagName);
        }


    /************************************************/
    /*                                              */
    /************************************************/
    ThePort.XMLProcessor.prototype.debug = function() {
        if (this.m_oXml!=null) {
            win = window.open('');
            this.displayXML(win,this.m_oXml);
            win.document.close();
            }
        }


    /************************************************/
    /*             Show a NodeIterator              */
    /************************************************/
    ThePort.XMLProcessor.prototype.XmlToText = function() {
        var oXml = this.m_oXml;
        var oDoc = oXml.documentElement;
        this.m_sTree = ThePort.Common.CONST_EMPTY_STRING;
        this.parse(oDoc);
        return this.m_sTree;
        }


    /************************************************/
    /*             Show a NodeIterator              */
    /************************************************/
    ThePort.XMLProcessor.prototype.displayXML = function(oWin,oXml) {
        var oDoc = oXml.documentElement;
        this.m_sTree = ThePort.Common.CONST_EMPTY_STRING;
        this.parse(oDoc);
        oWin.document.write(this.m_sTree);
        this.m_sTree = ThePort.Common.CONST_EMPTY_STRING;
        }


    /***********************************************/
    /*   Delete an Object to the Server via AJAX   */
    /***********************************************/
    ThePort.XMLProcessor.prototype.Delete = function (sCacheKey,fnCallback) {
        // Is ajax in progress?  then return else set up for busy.
        if (this.m_ajaxBusy) return; else this.m_ajaxBusy =true;
    
        if (typeof fnCallback!=ThePort.Common.CONST_UNDEFINED)
            this.m_callback = fnCallback;
        else this.m_callback = null;
        
        var sPostData = ThePort.Common.CONST_EMPTY_STRING;
        /* Add the object to the post */
        sPostData+= ThePort.Utils.GetVariablePair(ThePort.Common.QS_DATA,ThePort.XSL.EscapeXML(ThePort.XSL.SerializeToXML(this.m_oXml)));
        if (typeof sCacheKey!=ThePort.Common.CONST_UNDEFINED)
            sPostData+= ThePort.Utils.AddVariablePair(ThePort.Common.QS_CACHE_RESET,sCacheKey);
        /*******************************************************************/
        /* REQUEST THE RESPONSE FROM THE SAVE TO BE EITHER XML OR JSON!!!! */
        /*******************************************************************/
        /* Use EITHER line below to get the response data in either format */
        /*             ThePort.Common.CONST_FORMAT_XML                     */
        /*             ThePort.Common.CONST_FORMAT_JSON                    */
        /*******************************************************************/
        sPostData+= ThePort.Utils.AddVariablePair(ThePort.Common.QS_DATAFORMAT,ThePort.Common.CONST_FORMAT_JSON);
        // Dispatch the Ajax call.-
        ThePort.Utils.Ajax(ThePort.Common.CONST_FORM_DELETE,ThePort.Common.CONST_AJAX_URL,ThePort.Utils.Bind(this,"Response"),sPostData);
        }
        
        
    /*********************************************/
    /*   Save an Object to the Server via AJAX   */
    /*********************************************/
    ThePort.XMLProcessor.prototype.Save = function (sCacheKey,fnCallback) {
        // Is ajax in progress.
        if (this.m_ajaxBusy) return; else this.m_ajaxBusy =true;

        if (typeof fnCallback!=ThePort.Common.CONST_UNDEFINED)
            this.m_callback = fnCallback;
        else this.m_callback = null;
        
        var sPostData = ThePort.Common.CONST_EMPTY_STRING;
        /* Add the object to the post */
        sPostData+= ThePort.Utils.GetVariablePair(ThePort.Common.QS_DATA,ThePort.XSL.EscapeXML(ThePort.XSL.SerializeToXML(this.m_oXml)));
        if (typeof sCacheKey!=ThePort.Common.CONST_UNDEFINED)
            sPostData+= ThePort.Utils.AddVariablePair(ThePort.Common.QS_CACHE_RESET,sCacheKey);
        /*******************************************************************/
        /* REQUEST THE RESPONSE FROM THE SAVE TO BE EITHER XML OR JSON!!!! */
        /*******************************************************************/
        /* Use EITHER line below to get the response data in either format */
        /*             ThePort.Common.CONST_FORMAT_XML                     */
        /*             ThePort.Common.CONST_FORMAT_JSON                    */
        /*******************************************************************/
        sPostData+= ThePort.Utils.AddVariablePair(ThePort.Common.QS_DATAFORMAT,ThePort.Common.CONST_FORMAT_JSON);
        // Dispatch the Ajax call.
        ThePort.Utils.Ajax(ThePort.Common.CONST_FORM_POST,ThePort.Common.CONST_AJAX_URL,ThePort.Utils.Bind(this,"Response"),sPostData);
        }
        
        
    /******************************************************************/
    /* After the AJAX call, the response is coming into this function */
    /******************************************************************/
    ThePort.XMLProcessor.prototype.Response = function (oResponse) {
        // If debug is active, LOG it if an exception occured on the server.
        if (ThePort.Debug.window)
            ThePort.Utils.LogServerException(oResponse);
        // Build a ReplyObject.
        var oReplyObject = ThePort.Utils.GetReplyObject(oResponse)
        //***********************************************************************************************
        // Ok, if the ajax service has sent us back an object in the Obj field of the replyObject,      *
        // then we are going to replace/update the object we are currently representing and thus update *
        // the javascript variable.                                                                     *
        //***********************************************************************************************
        if ((oReplyObject.Obj!=null)&&(oReplyObject.Obj.length>0))
            this.loadXMLText(oReplyObject.Obj);
        // Turn off the busy flag.
        this.m_ajaxBusy = false;
        // If we have been given a callback, we call it.        
        if (this.m_callback)
            this.m_callback(oReplyObject);
        else try {
                // This is old stuff, we still have this here for compatibility.
                ThePortReply.Event_Response(oReplyObject);
             } catch(e) {} 
        return;
        }
} /* End Namespace */
﻿/***********************************************************/
/***********************************************************/
/**                MODULE :: ThePort.XSL                  **/
/***********************************************************/
/***********************************************************/
if (ThePortRegisterNS("ThePort.XSL")) {
    ThePort.XSL = {

        /******************************/
        /*     Create XML Object      */
        /******************************/
    Instantiate : function (sXml) {
         var xmlString = sXml;
         if (xmlString.substr(0,4)=="&lt;")
              xmlString = ThePort.XSL.Decoder(sXml);
         var obj = new ThePort.XMLProcessor();
         obj.loadXMLText(xmlString);
         return obj;
         },

    Instantiate64 : function (xmlString) {
        var obj = new ThePort.XMLProcessor();
        return ThePort.XSL.Instantiate(ThePort.Utils.Decode64(xmlString));
        },

        /************************************/
        /* Routine to display XML onscreen. */
        /************************************/
    RenderXML : function (oXml) {
        var oXMLProcessor = new ThePort.XMLProcessor();
        oXMLProcessor.m_oXml = oXml
        oXMLProcessor.debug()
        },

        /************************************/
        /* Routine to display XML onscreen. */
        /************************************/
    ParseAndRenderXML : function (oWin,sXml) {
        var oXMLProcessor = new ThePort.XMLProcessor();
        oXMLProcessor.displayXML(oWin,ThePort.XSL.LoadDocument(sXml));
        },

        /************************************/
        /*        FormatXmlToString         */
        /************************************/
    FormatXmlToString : function (oXml) {
        var oProcessor = new ThePort.XMLProcessor();
        oProcessor.m_sTree = ThePort.Common.CONST_EMPTY_STRING;
        oProcessor.parse(oXml.documentElement);
        return oProcessor.m_sTree;
        },

        /***********************************/
        /*      Standard XML Decoder       */
        /***********************************/
    Decoder : function (sEncodedString) {
        try {
            if ((typeof sEncodedString==ThePort.Common.CONST_UNDEFINED)||
                (sEncodedString==null)) return null;
            sEncodedString = sEncodedString.replace(/&apos;/g, ThePort.Common.CONST_SINGLE_QUOTE);
            sEncodedString = sEncodedString.replace(/&quot;/g, ThePort.Common.CONST_DBL_QUOTE);
            sEncodedString = sEncodedString.replace(/&lt;/g, ThePort.Common.CONST_LESS_THAN);
            sEncodedString = sEncodedString.replace(/&gt;/g, ThePort.Common.CONST_GREATER_THAN);
            sEncodedString = sEncodedString.replace(/&amp;/g, ThePort.Common.CONST_AMPERSAND);
            return sEncodedString;
            } catch(e) { return null; }
        },

        /***************************************/
        /* Load an XML String into a Document. */
        /***************************************/
    LoadDocument : function(sXml) {
        var xmlDoc;
        // The IE way...
        if (window.ActiveXObject) {
            xmlDoc          = new ActiveXObject(ThePort.Common.CONST_ACTIVEX_XML_OBJ);
            xmlDoc.async    = false;
            xmlDoc.loadXML(sXml);
            }
        else {
            // And all the other browsers...
            var parser = new DOMParser();
            //xmlDoc = parser.parseFromString(ThePort.XSL.Decoder(sXml),ThePort.Common.CONST_CONTENTTYPE_XML);
            xmlDoc = parser.parseFromString(sXml,ThePort.Common.CONST_CONTENTTYPE_XML);
            }
        return(xmlDoc);           
        },

        /**************************************************/
        /* Convert a Document into an escaped XML String. */
        /**************************************************/
    EscapeXML : function (sXml) {
        var sOutput = sXml
        sOutput = sOutput.replace(/&/g, ThePort.Common.CONST_ENC_AMPERSAND);
        sOutput = sOutput.replace(/'/g, ThePort.Common.CONST_ENC_SINGLE_QUOTE);
        sOutput = sOutput.replace(/\"/g, ThePort.Common.CONST_ENC_DBL_QUOTE);
        sOutput = sOutput.replace(/</g, ThePort.Common.CONST_ENC_LESS_THAN);
        sOutput = sOutput.replace(/>/g, ThePort.Common.CONST_ENC_GREATER_THAN);
        return sOutput;    
        },  

        /*****************************************/
        /*  Serialize XML document to a String.  */
        /*****************************************/
    SerializeToXML : function(oXml) {
        var sXml = ThePort.Common.CONST_EMPTY_STRING
        if (window.ActiveXObject) 
            // IE serialize
            sXml = oXml.xml;
            // And all the other browsers...
        else sXml = (new XMLSerializer()).serializeToString(oXml);
        return(sXml);           
        },

        /***************************************************/
        /* Save an instantiated Object back to the server. */
        /***************************************************/
    Save : function (oObject,sCacheKey,fnCallback) {
        if (typeof oObject != ThePort.Common.CONST_UNDEFINED)
            oObject.Save(sCacheKey,fnCallback)
        else alert("Unable to save object to server.")
        },


        /***************************************************/
        /* Delete an instantiated Object back to the server. */
        /***************************************************/
    Delete : function (oObject,sCacheKey,fnCallback) {
        if (typeof oObject != ThePort.Common.CONST_UNDEFINED) {
            ThePort.Debug.Log("AJAX Rest object delete called.")
            oObject.Delete(sCacheKey,fnCallback)
            }
        else alert("Unable to delete object from server.")
        },


    AjaxPost : function (sUrl,sPostData,oCallbackFn) {
          // ***********************************************
          // Lets make sure the values are good.
          // ***********************************************
          if(sPostData.length<=0){return;}
          // *********************
          // Post the data.
          // *********************
          eUrl = encodeURI(sUrl)
          ThePort.Utils.Ajax(ThePort.Common.CONST_FORM_POST,eUrl,oCallbackFn,sPostData);
        },

        
    AjaxDelete : function (sUrl,sPostData,oCallbackFn) {
          // ***********************************************
          // Lets make sure the values are good.
          // ***********************************************
          if(sPostData.length<=0){return;}
          // *********************
          // Make the call.
          // *********************
          eUrl = encodeURI(sUrl)
          ThePort.Utils.Ajax(ThePort.Common.CONST_FORM_DELETE,eUrl,oCallbackFn,sPostData);
        },


    AjaxGet : function (sUrl,oCallbackFn) {
          // *********************
          // Make the call.
          // *********************
          eUrl = encodeURI(sUrl);
          ThePort.Utils.Ajax(ThePort.Common.CONST_FORM_GET,eUrl,oCallbackFn,ThePort.Common.CONST_EMPTY_STRING);
        },


    GetModulePointer : function (sModuleName) {
	    if (typeof ThePort.Module.Array == ThePort.Common.CONST_UNDEFINED)
		    return null;
	    for (var i=0;i<ThePort.Module.Array.length;i++) {
	        if ((ThePort.Module.Array[i].m_sName == sModuleName)||(ThePort.Module.Array[i].m_sModuleName == sModuleName)) 
	            return ThePort.Module.Array[i];
	        }
	    ThePort.Debug.Log("ERROR::GetModulePointer('"+sModuleName+"') Unable to find Module.");
	    return null;
        },

     // Sloppy to have 2 of these?  Maybe, but you get the idea.  
     ShiftArgs : function() {  
       try {
         [].shift.call(arguments);  
       } catch(e){}   
       return arguments;  
     },
     Shift2Args : function() {  
       try {
         [].shift.call(arguments);  // Get rid of parm #0
         [].shift.call(arguments);  // Get rid of parm #1
       } catch(e){}   
       return arguments;  
     },

    /*********************************************************/
    /* Call EVERY module in the framework and have it invoke */ 
    /* a function with any number of parameters.             */
    /*********************************************************/
    CallAllModuleFunction : function (oFnName) {
	    if (typeof ThePort.Module.Array == ThePort.Common.CONST_UNDEFINED)
		    return false;
        // Lets remove the first argument off of the arg list and send the rest to the function.
        var oArgs = this['ShiftArgs'].apply(null, arguments); 
	    for (var i=0;i<ThePort.Module.Array.length;i++) 
            try {value = ThePort.Module.Array[i][oFnName].apply(ThePort.Module.Array[i],oArgs);} catch(e){/*alert('e='+e);*/}
        },
            
    /**********************************************************************/
    /* Call ONLY modules with a give sName or ObjectName in the framework */
    /* and have it invoke a function with any number of parameters.       */
    /**********************************************************************/
    CallModuleFunction : function (sModuleName,oFnName) {
	    if (typeof ThePort.Module.Array == ThePort.Common.CONST_UNDEFINED)
		    return false;
        // Lets remove the first 2 arguments off of the arg list and send the rest to the function.
        var oArgs = this['Shift2Args'].apply(null, arguments); 
	    for (var i=0;i<ThePort.Module.Array.length;i++) {
	        if ((ThePort.Module.Array[i].m_sName == sModuleName)||(ThePort.Module.Array[i].m_sModuleName == sModuleName)) {
                try {value = ThePort.Module.Array[i][oFnName].apply(ThePort.Module.Array[i],oArgs);} catch(e){/*alert('e='+e);*/}
               }
            }
        }
    }   /* End Module */
}  /* End Namespace */



﻿/***********************************************************/
/***********************************************************/
/**                CLASS :: ThePort.Tabs                  **/
/***********************************************************/
/***********************************************************/
if (ThePortRegisterNS("ThePort.Tabs")) {

if (typeof ThePort.Tabs.Array == ThePort.Common.CONST_UNDEFINED)
	ThePort.Tabs.Array = new Array();

} /* End Namespace */

if (ThePortRegisterNS("ThePort.UI.Tabs")) {
/***********************************************************/
/***********************************************************/
/**                CLASS :: ThePort.XMLProcessor          **/
/***********************************************************/
/***********************************************************/
ThePort.UI.Tabs = function(sTabName,sTabAreaName,iTabCount,iTabStart) {   
    this.m_sTabName = sTabName;
    this.m_sTabAreaName = sTabAreaName;
    this.m_iTabCount = iTabCount;
    this.m_iTabStart = iTabStart;
    this.m_iActiveTab = iTabStart;
    ThePort.Tabs.Array.push(this);
}


//*******************************************************
// Render the Tab Controls in their various states.
//*******************************************************
ThePort.UI.Tabs.prototype.SetStart = function (iTabStart) {
    this.m_iTabStart = iTabStart;
    this.m_iActiveTab = this.m_iTabStart;
}


//*******************************************************
// Render the Tab Controls in their various states.
//*******************************************************
ThePort.UI.Tabs.prototype.Render = function (iActiveTab) {
    try {
        // Turn off all the others...
        this.m_iActiveTab = iActiveTab;
        for (i = 1; i <= this.m_iTabCount; i++) { 
            
	        try{document.getElementById(this.m_sTabName + i).className = 'tab' + i; } catch(e){}
	        try{document.getElementById(this.m_sTabAreaName + i).style.display = 'none'; } catch(e){}
	        }
	    // Turn the proper one on.
        try{document.getElementById(this.m_sTabName + iActiveTab).className = 'tab' + iActiveTab + ' tabactive';} catch(e){}
        try{document.getElementById(this.m_sTabAreaName + iActiveTab).style.display = 'block';} catch(e){}
      } catch(e) { }        
} 


//*******************************************************
// Render the Tab Controls in their various states.
//*******************************************************
ThePort.UI.Tabs.prototype.Hilight = function (iHilightTab) {
    try {
    return;
        //if (parseInt(iHilightTab)==this.m_iActiveTab)
        //return;
        // Turn off all the others...
        for (i = 1; i <= this.m_iTabCount; i++) { 
	        document.getElementById(this.m_sTabName + i).className = 'tab' + i; 
	        }
	    // Turn the proper one on.
        document.getElementById(this.m_sTabName + iHilightTab).className = 'tab' + iHilightTab + ' tabactive';
      } catch(e) { }        
} 

//*******************************************************
// Render the Tab Controls in their various states.
//*******************************************************
ThePort.UI.Tabs.prototype.UnHilight = function () {
return;
    this.Hilight(this.m_iActiveTab);
} 



//*******************************************************
// Render the Tab Controls in their various states.
//*******************************************************
ThePort.UI.Tabs.prototype.Initialize = function () {
   this.Render(this.m_iTabStart);
}
/* End Class */

} /* End Namespace */﻿/***********************************************************/
/***********************************************************/
/**                CLASS :: ThePortReplyObject            **/
/***********************************************************/
/***********************************************************/
if (ThePortRegisterNS("ThePort.ReplyObject")) {

ThePort.ReplyObject = function (oXmlDoc) {
    this.ID	        = ThePort.Common.CONST_EMPTY_STRING;
	this.Response   = ThePort.Common.CONST_EMPTY_STRING;
	this.ReturnCode = 0;
    this.Action     = ThePort.Common.CONST_EMPTY_STRING;
    this.ObjectName = ThePort.Common.CONST_EMPTY_STRING;
    this.Message    = ThePort.Common.CONST_EMPTY_STRING;
    this.Data       = ThePort.Common.CONST_EMPTY_STRING;
    this.Hash       = ThePort.Common.CONST_EMPTY_STRING;
    this.Obj        = ThePort.Common.CONST_EMPTY_STRING;
	this.loadReply(oXmlDoc);
    }


//******************************************************************
//
//******************************************************************
ThePort.ReplyObject.prototype.getProcessedXML = function() {
    try {
        oProcessor = new ThePort.XMLProcessor();
        oProcessor.loadXMLText(this.getDataText());
        oProcessor.loadXSLText(this.getStyleText());
        return (oProcessor.transform())
        } 
    catch (e) { return ThePort.Common.CONST_ERROR_MESSAGE}
    }


//****************************************************************
// By default the tags processed are always:
// Title, description, link & pubdate
// The caller may add any number of extra tags/attrs to this call.
// For example:
// myRssFeed.loadFeed(xmlDoc,'content:encoded','enclosure//@url')) 
//****************************************************************
ThePort.ReplyObject.prototype.loadReply = function(oXmlDoc) {
    try {
	    this.ID         = ThePort.Utils.GetTagValue(oXmlDoc,"ID");
	    this.Response   = ThePort.Utils.GetTagValue(oXmlDoc,"Response");
	    this.ReturnCode = ThePort.Utils.GetTagValue(oXmlDoc,"ReturnCode");
        this.Action     = ThePort.Utils.GetTagValue(oXmlDoc,"Action");
        this.ObjectName = ThePort.Utils.GetTagValue(oXmlDoc,"ObjectName");
        this.Message    = ThePort.Utils.GetTagValue(oXmlDoc,"Message");
        this.Data       = ThePort.Utils.GetTagValue(oXmlDoc,"Data");
        this.Hash       = ThePort.Utils.GetTagValue(oXmlDoc,"Hash");
        this.Obj        = ThePort.Utils.GetTagValue(oXmlDoc,"Obj");
        }
    catch (e) { return false; }
    return true;
    } /* End Function */
    
/* End Class */

} /* End Namespace */﻿/***********************************************************/
/***********************************************************/
/**                CLASS :: ThePort.UI.Paging             **/
/***********************************************************/
/***********************************************************/

if (ThePortRegisterNS("ThePort.UI.Paging")) {
//*****************
// Constructor
//*****************
ThePort.UI.Paging = function(sModuleID,sPagingID,iTotalItems,iResultStart,iNumResults,sInactiveClassName,sSelectedClassName) {
  this.m_iCurrentPage       = 0;
  this.m_iStartPage         = 0;
  this.m_iEndPage           = 0;
  this.m_iNumResults        = iNumResults;
  this.m_iTotalPages        = 0;
  this.m_iResultStart       = iResultStart;
  this.m_iTotalItems        = iTotalItems;
  this.m_sPagingID          = sPagingID;
  this.m_sModuleID          = sModuleID;
  this.m_sInactiveClassName = sInactiveClassName;
  this.m_sSelectedClassName = sSelectedClassName;
}

//*********************************************************
//*********************************************************
//                       Utility function. 
//*********************************************************
//*********************************************************
ThePort.UI.Paging.prototype.GetNumPageIndexes = function(sPagingID) {
    var i = 1;
    while (ThePort.Utils.GetObj(sPagingID+"Elem"+i)!=null)
        i++;
    return i-1;
}

//*******************************************************
// Render the Paging Controls in their various states.
//*******************************************************
ThePort.UI.Paging.prototype.Render = function () {
    var oNode;
    var oModule = ThePort.XSL.GetModulePointer(this.m_sModuleID);
    var sName = oModule.oDict.GetDictionaryKey('sName');
    // Get the number of individual paging elements.
    this.m_iNumPageIndexes = this.GetNumPageIndexes(this.m_sPagingID);
    this.m_iTotalPages = Math.ceil(this.m_iTotalItems/this.m_iNumResults);
    this.m_iCurrentPage = Math.max(Math.ceil(this.m_iResultStart/this.m_iNumResults),1);
    
    this.m_iStartPage = Math.max(1,Math.ceil(this.m_iCurrentPage-(this.m_iNumPageIndexes/2)));
    this.m_iEndPage = Math.min(this.m_iTotalPages,this.m_iStartPage+this.m_iNumPageIndexes-1);
    if (this.m_iEndPage<this.m_iStartPage+this.m_iNumPageIndexes-1)
        this.m_iStartPage = Math.max(1,this.m_iEndPage-(this.m_iNumPageIndexes)+1);
    

    //************************************************
    // Shut off end prev/next markers if not needed.
    //************************************************
    if (this.m_iTotalPages<=this.m_iNumPageIndexes) {
        ThePort.Utils.Hide(this.m_sPagingID+"Start")
        ThePort.Utils.Hide(this.m_sPagingID+"Prev")
        ThePort.Utils.Hide(this.m_sPagingID+"Next")
        ThePort.Utils.Hide(this.m_sPagingID+"End")
        }
    
    //**************************************
    // Setup the START & PREVIOUS markers. *
    //**************************************
    if (this.m_iCurrentPage<=1) {
        /* If it's not active, set the style and dont hook functions to the nodes. */
        ThePort.Utils.SetClassName(this.m_sPagingID+"Start",this.m_sInactiveClassName);
        ThePort.Utils.SetClassName(this.m_sPagingID+"Prev",this.m_sInactiveClassName);
        /* Send the onclicks to the current page.  This will cause NOTHING to happen and the return false will stop scrolling to the top of page. */
        this.RenderElement(sName,this.m_sPagingID+"Start",this.m_sModuleID,"",(this.m_iCurrentPage-1)*this.m_iNumResults+1,"ExecutePaging");
        this.RenderElement(sName,this.m_sPagingID+"Prev",this.m_sModuleID,"",(this.m_iCurrentPage-1)*this.m_iNumResults+1,"ExecutePaging");
        }
    else {
         this.RenderElement(sName,this.m_sPagingID+"Start",this.m_sModuleID,"",1,"ExecutePaging");
         this.RenderElement(sName,this.m_sPagingID+"Prev",this.m_sModuleID,"",(this.m_iCurrentPage-1)*this.m_iNumResults,"ExecutePaging");
         }
        
    //**************************//
    // Setup all the elements. *//
    //**************************//
    i=this.m_iStartPage;
    for (var j=1;j<=this.m_iNumPageIndexes;j=j+1) {
        if ((i>=this.m_iStartPage) && (i<=this.m_iEndPage)) {
            if (i==this.m_iCurrentPage) {
                ThePort.Utils.SetClassName(this.m_sPagingID+"Elem"+j,this.m_sSelectedClassName);
                }
            this.RenderElement(sName,this.m_sPagingID+"Elem"+j,this.m_sModuleID,i+"",(i-1)*this.m_iNumResults+1,"ExecutePaging");
            }
        else ThePort.Utils.Hide(this.m_sPagingID+"Elem"+j)
        i+=1;
        }
        
    //********************************
    // Setup the END & NEXT markers. *
    //********************************
    if (this.m_iTotalPages>this.m_iNumPageIndexes) {
        this.RenderElement(sName,this.m_sPagingID+"Next",this.m_sModuleID,"",(this.m_iCurrentPage+1)*this.m_iNumResults,"ExecutePaging");
        //this.RenderElement(sName,this.m_sPagingID+"Next",this.m_sModuleID,"",(this.m_iEndPage+1)*this.m_iNumResults,"ExecutePaging");
        this.RenderElement(sName,this.m_sPagingID+"End",this.m_sModuleID,"",((this.m_iTotalPages-1)*this.m_iNumResults)+1,"ExecutePaging");
        }
        
        
        if (this.m_iCurrentPage>=this.m_iTotalPages)
        {
            /* If it's not active, set the style and dont hook functions to the nodes. */
            ThePort.Utils.SetClassName(this.m_sPagingID+"Next",this.m_sInactiveClassName);
            ThePort.Utils.SetClassName(this.m_sPagingID+"End",this.m_sInactiveClassName);
            /* Send the onclicks to the current page.  This will cause NOTHING to happen and the return false will stop scrolling to the top of page. */
            this.RenderElement(sName,this.m_sPagingID+"Next",this.m_sModuleID,"",(this.m_iCurrentPage-1)*this.m_iNumResults+1,"ExecutePaging");
            this.RenderElement(sName,this.m_sPagingID+"End",this.m_sModuleID,"",(this.m_iCurrentPage-1)*this.m_iNumResults+1,"ExecutePaging");
        }
        /**************************************************************************/
        /* Added fix for being on page 11 of 14 where the current pages are 9-13  */
        /* and [next] blows up since it's beyond the total # of items.    -SMS    */ 
        /**************************************************************************/
        if (this.m_iCurrentPage>=this.m_iTotalPages) {
             ThePort.Utils.SetClassName(this.m_sPagingID+"Next",this.m_sInactiveClassName);
             }
            
    /* Render the current & total paging indicators */
    ThePort.Utils.SetInnerHTML(this.m_sPagingID + "CurrentPage"," " + this.m_iCurrentPage + " ");
    ThePort.Utils.SetInnerHTML(this.m_sPagingID + "TotalPages"," " + this.m_iTotalPages + " ");
 }
 
 
 //*******************************************************
// Render the Paging Controls in their various states.
//*******************************************************
ThePort.UI.Paging.prototype.More = function () {
    var oModule = ThePort.XSL.GetModulePointer(this.m_sModuleID);
    var sName = oModule.oDict.GetDictionaryKey('sName');
    //this.m_iNumPageIndexes = this.GetNumPageIndexes(this.m_sPagingID);
    this.m_iTotalPages = Math.ceil(this.m_iTotalItems/this.m_iNumResults);
    this.m_iCurrentPage = Math.max(Math.ceil(this.m_iResultStart/this.m_iNumResults),1);
    if (this.m_iTotalPages<this.m_iCurrentPage) {
        ThePort.Utils.Hide(this.m_sPagingID+"More")
        return;
        }
    this.RenderElement(sName,this.m_sPagingID+"More",this.m_sModuleID,"",this.m_iResultStart+this.m_iNumResults,"ExecuteMore");
    if (!oModule) { return false; }
    /* Render the current & total paging indicators */
    ThePort.Utils.SetInnerHTML(this.m_sPagingID + "CurrentShown"," " + (this.m_iResultStart + this.m_iNumResults -1 ) + " ");
    ThePort.Utils.SetInnerHTML(this.m_sPagingID + "TotalItems"," " + this.m_iTotalItems + " ");
 }
 

//*******************************************************
// Attach an onclick handler to an element.
//*******************************************************
ThePort.UI.Paging.prototype.RenderElement = function (sName,sElementID, sModuleID, sToken, iResultStart, ExecuteFunction) {
    var sOutput = "";
    oNode = ThePort.Utils.GetObj(sElementID);
    if (!oNode) { return; }
    oNode.onclick  = ThePort.Utils.BinderNP(this,ExecuteFunction,iResultStart);
    try {
        oNode.href = ThePort.Utils.ReplaceQSVariable(window.location.href,sName,ThePort.Common.QS_RESULTSTART+"="+iResultStart);
    } catch(e){}
	if (sToken.length>0)
	    oNode.innerHTML = sToken;
    return
 }


//***************************************************************
// This is the function when someone clicks a paging UI element.
//***************************************************************
ThePort.UI.Paging.prototype.GotoPage = function(iPageNumber) 
{
  var iResultStart = (iPageNumber-1)*this.m_iNumResults+1;
  if (iResultStart>this.m_iTotalItems)
    return;
  else this.ExecutePaging(iResultStart);
}


//***************************************************************
// This is the function when someone clicks a paging UI element.
//***************************************************************
ThePort.UI.Paging.prototype.ExecutePaging = function(iResultStart) 
{
    oModule = ThePort.XSL.GetModulePointer(this.m_sModuleID);
    if (!oModule) { return false; }
    oModule.oDict.PutDictionaryKey(ThePort.Common.QS_OPERATION,ThePort.Common.CONST_OPERATION_REFRESH);
    return this.Execute(iResultStart);
}

 
//***************************************************************
// This is the function when someone clicks a paging UI element.
//***************************************************************
ThePort.UI.Paging.prototype.ExecuteMore = function(iResultStart) 
{
    oModule = ThePort.XSL.GetModulePointer(this.m_sModuleID);
    if (!oModule) { return false; }
    oModule.oDict.PutDictionaryKey(ThePort.Common.QS_OPERATION,ThePort.Common.CONST_OPERATION_MORE);
    return this.Execute(iResultStart);
}


//***************************************************************
// This is the function when someone clicks a paging UI element.
//***************************************************************
ThePort.UI.Paging.prototype.Execute = function(iResultStart) {
    var sModuleID  = this.m_sModuleID;
    oModule = ThePort.XSL.GetModulePointer(sModuleID);
    if (!oModule) { return false; }
    if ((iResultStart == oModule.oDict.GetDictionaryKey(ThePort.Common.QS_RESULTSTART))||(iResultStart>this.m_iTotalItems)) {
        iResultStart = ((this.m_iTotalPages-1)*this.m_iNumResults)+1
        }
    oModule.oDict.PutDictionaryKey(ThePort.Common.QS_RESULTSTART,iResultStart+"");
    ThePort.Debug.Log("Module::"+oModule.m_sName+" is changing the current index in viewing to iResultStart="+iResultStart);
    if (oModule.oDict.GetDictionaryKey(ThePort.Common.QS_OPERATION) != ThePort.Common.CONST_OPERATION_MORE) {
        ThePort.Utils.ScrollPageToNodeTop(oModule.oDict.GetDictionaryKey("sParentID"));
        //
        //oModule.GoBusy(oModule.m_sPagingID);
        }
    oModule.GoBusy(this.m_sPagingID);
    oModule.Update();
    return false;
 }
/* End Class */

} /* End Namespace */﻿/***********************************************************/
/***********************************************************/
/**                MODULE :: ThePort.Event                **/
/***********************************************************/
/***********************************************************/
if (ThePortRegisterNS("ThePort.Event")) {
    ThePort.Event = {
    GetEventTarget : function(e) {
        if (e.target) oEventTarget = e.target;
	    else if (e.srcElement) oEventTarget = e.srcElement;
	    // Safari
	    if (targ.nodeType == 3) oEventTarget = oEventTarget.parentNode;
	    return oEventTarget;
    },
    GetEventKeyCode : function(e) {
	    if (e.keyCode) iKeyCode = e.keyCode;
	    else if (e.which) iKeyCode = e.which;
	    var cCharacter = String.fromCharCode(iKeyCode);
	    return iKeyCode;
    },
    IsEventRightMouseClick: function(e) {
	    if (e.which) bRightclick = (e.which == 3);
	    else if (e.button) bRightclick = (e.button == 2);
	    return bRightclick;
    },
    GetEventMouseX : function(e) {
	    var iPosX = 0;
	    if (e.pageX || e.pageY)
		    iPosX = e.pageX;
	    else if (e.clientX || e.clientY) 	
		        iPosX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
	    return iPosX;
    },
    GetEventMouseY : function(e) {
	    var iPosY = 0;
	    if (e.pageX || e.pageY) 
		    iPosY = e.pageY;
	    else if (e.clientX || e.clientY) 	
		        iPosY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	    return iPosY;
    },
    AddHandler : function( obj, type, fn ) {
	    if (obj.addEventListener)
		    obj.addEventListener( type, fn, false );
	    else if (obj.attachEvent)
	    {
		    obj["e"+type+fn] = fn;
    		obj.attachEvent( "on"+type, function() { obj["e"+type+fn](); } );
//		    obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
//		    obj.attachEvent( "on"+type, obj[type+fn] );
	    }
      },
    RemoveHandler : function( obj, type, fn ) {
	    if (obj.removeEventListener)
		    obj.removeEventListener( type, fn, false );
	    else if (obj.detachEvent)
	    {
		    obj.detachEvent( "on"+type, obj["e"+type+fn] );
		    obj["e"+type+fn] = null;
		    //obj.detachEvent( "on"+type, obj[type+fn] );
		    //obj[type+fn] = null;
		    //obj["e"+type+fn] = null;
	    }
      }
    }   /* End Module */
}  /* End Namespace */
    




﻿/***********************************************************/
/***********************************************************/
/**                CLASS :: ThePort.Dictionary            **/
/***********************************************************/
/***********************************************************/
ThePortRegisterNS("ThePort.Dictionary");
ThePort.Dictionary = function(sCSV) {
    this.sValues = [];
    if (typeof sCSV == ThePort.Common.CONST_UNDEFINED)
        sCSV = ThePort.Common.CONST_EMPTY_STRING;
    
	this.FromCSV(sCSV);
}

ThePort.Dictionary.prototype.GetDictionaryCSV = function() {
    return this.ToCSV();
}

ThePort.Dictionary.prototype.KeysToCSV = function() {
    var sOutput = ThePort.Common.CONST_EMPTY_STRING;
    for (key in this.sValues) {
	    if (typeof this.sValues[key] != ThePort.Common.CONST_TYPE_FUNCTION) {
    	    if (sOutput.length>0)
	            sOutput+=ThePort.Common.CONST_COMMA;
	        sOutput+= escape(key);
	        }
	    }
	    return sOutput;
    }

ThePort.Dictionary.prototype.ValuesToCSV = function() {
    var sOutput = ThePort.Common.CONST_EMPTY_STRING;
    for (key in this.sValues) {
	    if (typeof this.sValues[key] != ThePort.Common.CONST_TYPE_FUNCTION) {
    	    if (sOutput.length>0)
	            sOutput+=ThePort.Common.CONST_COMMA;
	        sOutput+= escape(this.sValues[key]);
	        }
	    }
	    return sOutput;
    }

ThePort.Dictionary.prototype.ToCSV = function() {
    var sOutput = ThePort.Common.CONST_EMPTY_STRING;
    for (key in this.sValues) {
	    if (typeof this.sValues[key] != ThePort.Common.CONST_TYPE_FUNCTION) {
    	    if (sOutput.length>0)
	            sOutput+=ThePort.Common.CONST_COMMA;
	        sOutput+= escape(key) + ThePort.Common.CONST_EQUALS + escape(this.sValues[key]);
	        }
	    }
	    return sOutput;
    }

ThePort.Dictionary.prototype.ResetDictionary = function() {
    this.sValues = null;
    this.sValues = []
}


ThePort.Dictionary.prototype.KeysFromCSV = function(sCSV) {
	this.sValues = []
	// We reject the case where these is no CSV passed in.  Perhaps an empty construction.
    if ((typeof sCSV == ThePort.Common.CONST_UNDEFINED)||(sCSV.length<=0))
        return;
	sItems = sCSV.split(/\s?,\s?/);
	for ( var i=0;i<sItems.length;i++) {
        this.AddStringPair(unescape(sItems[i]),unescape(ThePort.Common.CONST_EMPTY_STRING));
        }
}


ThePort.Dictionary.prototype.FromCSV = function(sCSV) {
	this.sValues = []
	// We reject the case where these is no CSV passed in.  Perhaps an empty construction.
    if ((typeof sCSV == ThePort.Common.CONST_UNDEFINED)||(sCSV.length<=0))
        return;
	
	// Values surrounded by quotes? REGx = /(?:'[^']*')|(?:[^, ]+)/g;
	sItems = sCSV.split(/\s?,\s?/);
	for ( var i=0;i<sItems.length;i++) {
	    var sTmp = sItems[i].split(/\s?=\s?/);
	    if (sTmp.length==2)
	        this.AddStringPair(unescape(sTmp[0]),unescape(sTmp[1]));
	    else if (sTmp.length==1)
	        this.AddStringPair(unescape(sTmp[0]),unescape(ThePort.Common.CONST_EMPTY_STRING));
        }
}

ThePort.Dictionary.prototype.PutDictionaryKey = function(sKey,sValue) {
        // We have this function for compatibility with the XSL counterpart.
        this.AddStringPair(sKey,sValue);
}

ThePort.Dictionary.prototype.RemoveDictionaryKey = function(sKey) {
        // We have this function for compatibility with the XSL counterpart.
        try {delete this.sValues[sKey];} catch(e){}
}

ThePort.Dictionary.prototype.GetDictionaryKey = function(sKey) {
        // We have this function for compatibility with the XSL counterpart.
        var oItem = this.sValues[sKey];
        if (typeof oItem == ThePort.Common.CONST_UNDEFINED)
            oItem = ThePort.Common.CONST_EMPTY_STRING;
        return oItem;
}

ThePort.Dictionary.prototype.AddStringPair = function(sKey,sValue) {
        // We do this to support replacing keys automaticly.
	    this.sValues[sKey] = sValue;
}

ThePort.Dictionary.prototype.AddControlID = function(sControlID) {
        // We do this to support replacing keys automaticly.
        var oNode = ThePort.Utils.GetObj(sControlID);
        if (oNode!=null) 
           AddControl(oNode);
}

ThePort.Dictionary.prototype.AddControl = function(oNode) {
        // We do this to support replacing keys automaticly.
        if (oNode!=null) {
           this.sValues[oNode.id] = oNode.value;
           }
}

ThePort.Dictionary.prototype.Items = function() {
        return (this.sValues == null ? [] : this.sValues);
}

ThePort.Dictionary.prototype.RemoveDictionaryKey = function(sKey) {
     try {delete this.sValues[sKey];} catch(e){}
}

ThePort.Dictionary.prototype.Count = function() {
        var i = 0;
        for (key in this.sValues)
        {
            if (typeof this.sValues[key] != ThePort.Common.CONST_TYPE_FUNCTION) 
            {
            i+=1; 
            }
        }
        return i;
}

ThePort.Dictionary.prototype.GetArraySortedByKey = function() {
    return this.GetArray();
}
ThePort.Dictionary.prototype.GetArraySortedByValue = function() {
    return this.GetArray(false);
}

ThePort.Dictionary.prototype.GetArray = function() {
        var arr = new Array();
        var _sortByValue = function(a,b) { return ((a[1] < b[1]) ? -1 : ((a[1] > b[1]) ? 1 : 0)); }
                
        var byKey = true;        
        if (arguments[0] != null && arguments[0] == false){byKey = false;}       
         
        for (key in this.sValues)
        {
            if (typeof this.sValues[key] != ThePort.Common.CONST_TYPE_FUNCTION) 
            {
                var a = new Array();
                a[0] = key;
                a[1] = this.sValues[key];
                arr.push(a);
            }
        }
        if (byKey == true){arr.sort();}else{arr.sort(_sortByValue);}
        
        return arr;
 }
    
﻿/***********************************************************/
/***********************************************************/
/**                 MODULE :: ThePort.Debug               **/
/***********************************************************/
/***********************************************************/
ThePortRegisterNS("ThePort.Debug");

ThePort.Debug = {
    Enable : function () {
        if (ThePort.Debug.window)
        return;
        ThePort.Debug.window = window.open("about:blank", "_blank","left=0,top=0,width=800,height=400,scrollbars=yes,status=yes,resizable=yes");
        if (ThePort.Debug.window) {
            ThePort.Debug.window.opener = self;
            // open the document for writing
            ThePort.Debug.window.document.open();
            ThePort.Debug.window.document.write("<HTML><HEAD><TITLE>Debug Window</TITLE></HEAD><BODY><PRE>\n");
            }
        else {
            if (typeof ThePort.Debug.alertMessage != ThePort.Common.CONST_UNDEFINED) {
                alert('You have enabled the debug window.  However it appears popups are disabled in your browser.');
                ThePort.Debug.alertMessage = true;
                }
            }

    },

    // If the debug window exists, then write to it
    Log : function (text) {
    try {
      if (ThePort.Debug.window) {
        ThePort.Debug.window.document.write(text+"\n");
      }
    } catch(e){} /* if someone closes our output window, lets not show any errors. */
    },

    // If the debug window exists, then write to it
    LogModuleMsg : function (oObj,sMessage) {
    try {
      if (ThePort.Debug.window) {
        var sValue = ""
        if (oObj.m_sName.length>0)
            sValue = oObj.m_sName;
        else sValue = oObj.m_sModuleName+"(Please setInterval 'sName' dictionary variable)";
        ThePort.Debug.window.document.write(sValue+" : "+ sMessage + "\n");
      }
    } catch(e){} /* if someone closes our output window, lets not show any errors. */
    },

    /* If the debug window exists, then close it */
    Disable : function() {
    try {
          if (ThePort.Debug.window) {
            ThePort.Debug.window.close();
            ThePort.Debug.window = null;
            }
        } catch(e){} /* if someone closes our output window, lets not show any errors. */
    }
}  /* End module */  
﻿/***********************************************************/
/***********************************************************/
/**                MODULE :: ThePort.Framework            **/
/***********************************************************/
/***********************************************************/
ThePortRegisterNS("ThePort.Framework");
ThePort.Framework = {
/*******************************/
/* Module Creation Routine...  */
/*******************************/
ModuleCreate : function (oObj,sDictCSV,sName,sParentID,sModuleID,sBusyIndicator,sParts) {
      oObj.oDict = new ThePort.Dictionary(sDictCSV);
      oObj.m_sName = sName;
      oObj.m_sParentID = sParentID;
      oObj.m_sModuleName = sModuleID;
      oObj.m_sBusyIndicator = sBusyIndicator;
      oObj.m_sHash = ThePort.Common.CONST_EMPTY_STRING;
      oObj.m_interval = null;
      oObj.m_timeout  = null;
      oObj.m_oPaging = null;
      oObj.m_busy = false;
      oObj.m_oBusyIndicatorNode = null;
      ThePort.Debug.LogModuleMsg(oObj,"New object Constructed.");
      /* Output debug information red-box with titles */
      if (sParts=='1') {
          if (oObj.m_sParentID!=null) {
              var oParent = ThePort.Utils.GetObj(oObj.m_sParentID);
              if (oParent) {
                  oParent.className = "tp_Show_Parts_Surround";
                  var oCtl = document.createElement("B");
                  var oTag = document.createTextNode("Module Name::" + sName + "    XSLT::" + oObj.oDict.GetDictionaryKey('sXslFileName')); 
                  oCtl.className="tp_Show_Parts_Title";
                  var oNewTitle = oCtl.appendChild(oTag);
                  oParent.insertBefore(oCtl, oParent.firstChild);
                  }
              }
           }
   },
    
ModuleUpdate : function (oObj) {
    ThePort.Debug.LogModuleMsg(oObj,"Making an AJAX UPDATE request.");
    oObj.GoBusy(oObj.m_sParentID);
    ThePort.Debug.LogModuleMsg(oObj,"Send ajax Update request.");
    /* Post the search request. */
    var eUrl = "/APIs/Services/XSL/Process.ashx";
    /*   Posted variables   */
    sPostData = ThePort.Utils.GetVariablePair(ThePort.Common.QS_DATA,oObj.oDict.ToCSV());
    if (oObj.m_sHash.length>0)
    sPostData += ThePort.Utils.AddVariablePair(ThePort.Common.QS_HASH,oObj.m_sHash);
    ThePort.XSL.AjaxPost(eUrl,sPostData,ThePort.Utils.AjaxBind(oObj,"onUpdateResponse"));
    },
    
ModuleOnUpdateResponse : function (oObj,oResponse) {
        ThePort.Debug.LogModuleMsg(oObj,"Processing an AJAX UPDATE Response.");
        oObj.NoBusy();
        ThePort.Debug.LogModuleMsg(oObj,"Handling ajax response.");
        var oReplyObj = new ThePort.ReplyObject(oResponse.responseXML);
        var oNode = ThePort.Utils.GetObj(oObj.m_sParentID);
        if (oReplyObj.Response != "true")  	{
            if (oNode) {
                ThePort.Debug.LogModuleMsg(oObj,"Ajax response=false, Message='"+oReplyObj.Message+"'");
                /* No updates or error, so we dont change the current. */
                //var sTxt = "Unsuccesful in update attempt" + oNode.innerHTML;
                //oNode.innerHTML = sTxt;
                }
            }
        else { /* Success in response, do something. */
            if (oNode)  {
                ThePort.Debug.LogModuleMsg(oObj,"Ajax response=true, Updating content with new hash='"+oReplyObj.Hash+"'");
                /*if (oReplyObj.Hash.length>0)this.SetHash(oReplyObj.Hash);*/
                ThePort.Debug.LogModuleMsg(oObj,"Updating display with ajax data.");
                var oPNode = ThePort.Utils.GetObj(oObj.oDict.GetDictionaryKey('sPagingID'));
                if ((oPNode)&&(oObj.oDict.GetDictionaryKey(ThePort.Common.QS_OPERATION)==ThePort.Common.CONST_OPERATION_MORE)) {
                oPNode.parentNode.removeChild( oPNode );
                oNode.innerHTML += oReplyObj.Data;
                }
            //else oNode.innerHTML = oReplyObj.Data;
            else {ThePort.Utils.LoadHTMLIntoNode(oNode,oReplyObj.Data);}
//            /* Now we execute the scripts within the data */
//            ThePort.Debug.LogModuleMsg(oObj,"Executing ajax payload scripts.");
//            var oScripts = oNode.getElementsByTagName('script');
//            for (var i = 0; i < oScripts.length; i++) {
//                //ThePort.Utils.AddHeadScriptTag(oScripts[i].text);
//                // Use this next line for debugging and the above line for prod.
//                eval(oScripts[i].text);
//                }
            }
      else  {
              ThePort.Debug.LogModuleMsg(oObj,"There are updates, but unable to locate sParentID::"+oObj.m_sParentID);
              oObj.CleanUp();
            }
      }
    },
    
ModuleGoBusy : function(oObj,sID) {
      try  {
      if (oObj.m_busy) return false;
      if (oObj.m_oBusyIndicatorNode!=null)
      return false;
      ThePort.Debug.LogModuleMsg(oObj,"Turning ON busy indicator.");
      if (typeof sID == ThePort.Common.CONST_UNDEFINED)
      sID = oObj.m_sParentID;
      var oDisplayNode = ThePort.Utils.GetObj(sID);
      if (oDisplayNode==null)
      return false;
      var iXPos =  ThePort.Utils.findPosX(oDisplayNode);
      var iYPos =  ThePort.Utils.findPosY(oDisplayNode);

      var iHeight = oDisplayNode.offsetHeight;
      var iWidth = oDisplayNode.offsetWidth;

      var iXLoc = iXPos + (iWidth/2)-60;
      var iYLoc = iYPos /*+ (iHeight/2);*/

      oObj.m_oBusyIndicatorNode = document.body.appendChild(document.createElement('div'));
      oObj.m_oBusyIndicatorNode.style.left		= iXLoc.toString()+"px";
      oObj.m_oBusyIndicatorNode.style.top		= iYLoc.toString()+"px";
      oObj.m_oBusyIndicatorNode.style.position	= "absolute";
      oObj.m_oBusyIndicatorNode.innerHTML = oObj.m_sBusyIndicator;
      /*
      var oImage = document.createElement('img');
      oImage.src = "/images/themes/default/loading.gif"; // ready for prod. dev should map the images folder to mountdoom
      this.m_oBusyIndicatorNode.appendChild(oImage);
      */
      } catch(e) {oObj.m_oBusyIndicatorNode = null;}
      oObj.m_busy = true;
      return true;
    },
    
ModuleNoBusy : function(oObj) {
    try {
        ThePort.Debug.LogModuleMsg(oObj,"Turning OFF busy indicator.");
        oObj.m_busy = false;
        if (oObj.m_oBusyIndicatorNode)
        oObj.m_oBusyIndicatorNode.parentNode.removeChild( oObj.m_oBusyIndicatorNode );
        oObj.m_oBusyIndicatorNode = null;
        } catch(e) {}
    },
    
ModuleRefresh : function (oObj)  {
    ThePort.Debug.LogModuleMsg(oObj,"Refreshing module.");
    if ((oObj.oDict.GetDictionaryKey(ThePort.Common.QS_OPERATION)==ThePort.Common.CONST_OPERATION_MORE)) {
        oObj.oDict.PutDictionaryKey(ThePort.Common.QS_RESULTSTART,"1");
        oObj.oDict.PutDictionaryKey(ThePort.Common.QS_OPERATION,ThePort.Common.CONST_OPERATION_REFRESH);
        }
    oObj.Update();
    },

ModuleDemand : function (oObj)  {
    ThePort.Debug.LogModuleMsg(oObj,"Module Demand called.  Turning off any icache variables.");
    oObj.oDict.PutDictionaryKey(ThePort.Common.QS_CACHE_RESET,"1");
//    if ((oObj.oDict.GetDictionaryKey(ThePort.Common.QS_CACHEBYUSER)!='')) {
//        oObj.oDict.PutDictionaryKey(ThePort.Common.QS_CACHEBYUSER,"0");
//        }
//    if ((oObj.oDict.GetDictionaryKey(ThePort.Common.QS_CACHE)!='')) {
//        oObj.oDict.PutDictionaryKey(ThePort.Common.QS_CACHE,"0");
//        }
    oObj.Refresh();
    },

ModuleSetHash : function (oObj,sHashValue)  {
      ThePort.Debug.LogModuleMsg(oObj,"Setting HASH for module data.");
      ThePort.Debug.LogModuleMsg(oObj,"Hash = "+sHashValue);
      oObj.m_sHash = sHashValue;
      },

ModuleShow : function (oObj)  {
      ThePort.Debug.LogModuleMsg(oObj,"Showing Module");
      ThePort.Utils.Show(oObj.m_sParentID);
      },

ModuleHide : function (oObj)  {
      ThePort.Debug.LogModuleMsg(oObj,"Hiding Module.");
      ThePort.Debug.LogModuleMsg(oObj,"Hide");
      ThePort.Utils.Hide(oObj.m_sParentID);
      },

ModuleRefreshInterval : function (oObj,seconds)  {
      oObj.StopInterval();
      if (seconds>0)  {
          ThePort.Debug.LogModuleMsg(oObj,"RefreshInterval pending update in "+seconds+" seconds.");
          oObj.m_interval   = setInterval(ThePort.Utils.Bind(oObj,'Refresh'), seconds*1000);
        }
      },

ModuleStopInterval : function (oObj)  {
      if (oObj.m_interval) {
          ThePort.Debug.LogModuleMsg(oObj,"Clearing previous interval.");
          clearInterval(oObj.m_interval);
          }
      oObj.m_interval = null;
      },

ModuleRefreshTimeout : function (oObj,seconds)  {
      oObj.StopTimeout();
      if (seconds>0)  {
          ThePort.Debug.LogModuleMsg(oObj,"RefreshTimeOut pending update in "+seconds+" seconds.");
          oObj.m_timeout   = setTimeout(ThePort.Utils.Bind(oObj,'Refresh'), seconds*1000);
          }
      },

ModuleDemandTimeout : function (oObj,seconds)  {
      oObj.StopTimeout();
      if (seconds>0)  {
          ThePort.Debug.LogModuleMsg(oObj,"DemandTimeOut pending update in "+seconds+" seconds.");
          oObj.m_timeout   = setTimeout(ThePort.Utils.Bind(oObj,'Demand'), seconds*1000);
          }
      },

ModuleStopTimeout : function (oObj)  {
      if (oObj.m_timeOut) {
          ThePort.Debug.LogModuleMsg(oObj,"Clearing any previous timeOut.");
          clearInterval(oObj.m_timeout);
          }
      oObj.m_timeout = null;
      },

ModuleCleanUp : function(oObj) {
      oObj.StopTimeout();
      oObj.StopInterval();
      oObj.NoBusy();
      ThePort.Debug.LogModuleMsg(oObj,"Timer cleanup.");
      },

ModuleGotoPage : function(oObj,iPageNum) {
      if (oObj.m_oPaging!=null) {
        oObj.m_oPaging.GotoPage(iPageNum);
        }
      }
      
}  /* End Namespace */
    
﻿/***********************************************************/
/***********************************************************/
/**                MODULE :: ThePort.Code                 **/
/***********************************************************/
/***********************************************************/
if (ThePortRegisterNS("ThePort.Code")) {
    ThePort.Code = {

    //***********************
    // Standard defines.
    //***********************
    CONST_SUCCESS           : 0,
    CONST_ERROR_TIMEOUT     : -1,
    CONST_ERROR_AUTH        : -2

    }   /* End Codes */
    
}  /* End Namespace */


﻿/***********************************************************/
/***********************************************************/
/**              EXTENSIONS TO STRING OBJECT              **/
/***********************************************************/
/***********************************************************/


//********************************************************************
//
//********************************************************************
if (String.prototype.trim==null) String.prototype.trim = function (){
		if(this.length < 1) return "";
		var retVal = new String("");
		retVal = this.rTrim();
		retVal = retVal.lTrim();
		return retVal;
} 


//********************************************************************
//
//********************************************************************
if (String.prototype.rTrim==null) String.prototype.rTrim = function (){
	var w_space   = String.fromCharCode(32);
	var v_length  = this.length;
	var strTemp   = "";
	if(v_length < 0){
	  return "";
	  }
	var iTemp = v_length -1;
	while(iTemp > -1){
	  if(this.charAt(iTemp) == w_space){
    	  }
	  else{
		strTemp = this.substring(0,iTemp +1);
		break;
		}
	  iTemp = iTemp-1;
	  } //End While
	return strTemp;
} 


//********************************************************************
//
//********************************************************************
if (String.prototype.lTrim==null) String.prototype.lTrim = function(){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
	  return"";
	  }
	var v_length  = this.length;
	var strTemp   = "";
	var iTemp     = 0;

	while(iTemp < v_length){
	if(this.charAt(iTemp) == w_space){
	    }
	else{
	    strTemp = this.substring(iTemp,v_length);
	    break;
	    }
	iTemp = iTemp + 1;
	} //End While
	return strTemp;
} 


//********************************************************************
//
//********************************************************************
if (String.prototype.left==null) String.prototype.left = function(n){
	if (n <= 0)
	    return "";
	else if (n > this.length)
	    return this;
	else
	    return this.substring(0,n);
}


//********************************************************************
//
//********************************************************************
if (String.prototype.right==null) String.prototype.right = function(n){
    if (n <= 0)
       return "";
    else if (n > this.length)
       return this;
    else {
       var iLen = this.length;
       
       return this.substring(iLen, iLen - n);
      }
}

//********************************************************************
//
//********************************************************************
if (String.prototype.trimEnd==null) String.prototype.trimEnd = function(sEnd){
    if (sEnd.length <= 0)
       return "";
    else if (sEnd.length > this.length)
       return this;
    else {
       var iLen = sEnd.length;
       var sEOS = this.right(iLen);
       if (sEOS == sEnd) {
            return this.substring(0, this.length-iLen);
            }
       return this;
      }
}
﻿/**********************************/
/*       Register Namespace       */
/**********************************/
if (ThePortRegisterNS("ThePort.UI.PopWindow")) {
/*******************************/
/*  DHTML Window Routines...   */
/*******************************/
ThePort.UI.PopWindow = {

/*******************************************/
/*  Open/Close Window On A Page Routine... */
/*******************************************/
popUpWindow:null,

OpenWindow: function (url,width,height,winType){      // this opens a modal dialogue with page behind grayed out (close with closeWindowOnPage)
	if (typeof width == ThePort.Common.CONST_UNDEFINED){width = 450;}	
	if (typeof height == ThePort.Common.CONST_UNDEFINED){height = 450;}
	if(winType=='modal'){
	    ThePort.UI.PopWindow.popUpWindow=ThePort.UI.PopModalWindow.open('tp_Win', 'iframe', url, '','width='+width+'px,height='+height+'px,center=1,resize=1,scrolling=1'); 
    }
	if(winType=='regular'){
	    ThePort.UI.PopWindow.popUpWindow=ThePort.UI.PopWindow.open('tp_Win', 'iframe', url, '','width='+width+'px,height='+height+'px,center=1,resize=1,scrolling=1'); 
    }
},

OpenRegularWindow: function (u,w,h){      // this opens a window regular window on a page
    ThePort.UI.PopWindow.OpenWindow(u,w,h,'regular');
},

CloseWindow: function (bRefresh){  // this closes a window (whether modal or regular)
    if(ThePort.UI.PopWindow.popUpWindow){
        ThePort.UI.PopWindow.popUpWindow.hide();
        if (bRefresh==true){window.location=window.location;}
    }
},

OpenModalWindow: function (u,w,h){      // this opens a modal dialogue with page behind grayed out
    ThePort.UI.PopWindow.OpenWindow(u,w,h,'modal');
},

CloseModalWindow: function (bRefresh){  // this closes a modal dialogue.
  ThePort.UI.PopWindow.CloseWindow(bRefresh); // not so sure about if this works
},

    ajaxbustcache: true, //Bust caching when fetching a file via Ajax?
    ajaxloadinghtml: '<b>Loading Page. Please wait...</b>', //HTML to show while window fetches Ajax Content?

    minimizeorder: 0,
    zIndexvalue:100,
    tobjects: [], //object to contain references to dhtml window divs, for cleanup purposes
    lastactivet: {}, //reference to last active DHTML window

    init:function(t){
	    var domwindow=document.createElement("div") //create dhtml window div
	    domwindow.id=t
	    domwindow.className="dhtmlwindow"
	    var domwindowdata=''
	    domwindowdata='<div class="drag-handle">'
	    domwindowdata+='DHTML Window <div class="drag-controls"></div>'
    	
	    domwindowdata+='</div>'
	    domwindowdata+='<div class="drag-contentarea"></div>'
	    domwindowdata+='<div class="drag-statusarea"><div class="drag-resizearea">&nbsp;</div></div>'

	    domwindowdata+='</div>'
	    domwindow.innerHTML=domwindowdata
	    document.getElementById("dhtmlwindowholder").appendChild(domwindow)
	    //this.zIndexvalue=(this.zIndexvalue)? this.zIndexvalue+1 : 100 //z-index value for DHTML window: starts at 0, increments whenever a window has focus
	    var t=document.getElementById(t)
	    var divs=t.getElementsByTagName("div")
	    for (var i=0; i<divs.length; i++){ //go through divs inside dhtml window and extract all those with class="drag-" prefix
		    if (/drag-/.test(divs[i].className))
			    t[divs[i].className.replace(/drag-/, "")]=divs[i] //take out the "drag-" prefix for shorter access by name
	    }
	    //t.style.zIndex=this.zIndexvalue //set z-index of this dhtml window
	    t.handle._parent=t //store back reference to dhtml window
	    t.resizearea._parent=t //same
	    t.controls._parent=t //same
	    t.onclose=function(){return true} //custom event handler "onclose"
	    t.onmousedown=function(){ThePort.UI.PopWindow.setfocus(this)} //Increase z-index of window when focus is on it
	    t.handle.onmousedown=ThePort.UI.PopWindow.setupdrag //set up drag behavior when mouse down on handle div
	    t.resizearea.onmousedown=ThePort.UI.PopWindow.setupdrag //set up drag behavior when mouse down on resize div
	    t.controls.onclick=ThePort.UI.PopWindow.enablecontrols
	    t.show=function(){ThePort.UI.PopWindow.show(this)} //public function for showing dhtml window
	    t.hide=function(){ThePort.UI.PopWindow.hide(this)} //public function for hiding dhtml window
	    t.close=function(){ThePort.UI.PopWindow.close(this)} //public function for closing dhtml window (also empties DHTML window content)
	    t.isClosed=false;
	    t.setSize=function(w, h){ThePort.UI.PopWindow.setSize(this, w, h)} //public function for setting window dimensions
	    t.moveTo=function(x, y){ThePort.UI.PopWindow.moveTo(this, x, y)} //public function for moving dhtml window (relative to viewpoint)
	    t.isResize=function(bol){ThePort.UI.PopWindow.isResize(this, bol)} //public function for specifying if window is resizable
	    t.isScrolling=function(bol){ThePort.UI.PopWindow.isScrolling(this, bol)} //public function for specifying if window content contains scrollbars
	    t.load=function(contenttype, contentsource, title){ThePort.UI.PopWindow.load(this, contenttype, contentsource, title)} //public function for loading content into window
	    this.tobjects[this.tobjects.length]=t
	    return t //return reference to dhtml window div
    },

    open:function(t, contenttype, contentsource, title, attr, recalonload){
	    var d=ThePort.UI.PopWindow; //reference dhtml window object
	    function getValue(Name){
		    var config=new RegExp(Name+"=([^,]+)", "i") //get name/value config pair (ie: width=400px,)
		    return (config.test(attr))? parseInt(RegExp.$1) : 0 //return value portion (int), or 0 (false) if none found
	    }
	    if (document.getElementById(t)==null) //if window doesn't exist yet, create it
		    t=this.init(t) //return reference to dhtml window div
	    else
		    t=document.getElementById(t)
	    this.setfocus(t)
	    t.setSize(getValue(("width")), (getValue("height"))) //Set dimensions of window
	    var xpos=getValue("center")? "middle" : getValue("left") //Get x coord of window
	    var ypos=getValue("center")? "middle" : getValue("top") //Get y coord of window
	    //t.moveTo(xpos, ypos) //Position window
	    if (typeof recalonload!="undefined" && recalonload=="recal" && this.scroll_top==0){ //reposition window when page fully loads with updated window viewpoints?
		    if (window.attachEvent && !window.opera) //In IE, add another 400 milisecs on page load (viewpoint properties may return 0 b4 then)
			    this.addEvent(window, function(){setTimeout(function(){t.moveTo(xpos, ypos)}, 400)}, "load")
		    else
			    this.addEvent(window, function(){t.moveTo(xpos, ypos)}, "load")
	    }
	    t.isResize(getValue("resize")) //Set whether window is resizable
	    t.isScrolling(getValue("scrolling")) //Set whether window should contain scrollbars
	    t.style.visibility="visible"
	    t.style.display="block"
	    t.contentarea.style.display="block"
	    t.moveTo(xpos, ypos) //Position window
	    t.load(contenttype, contentsource, title)
	    if (t.state=="minimized" && t.controls.firstChild.title=="Restore"){ //If window exists and is currently minimized?
	    //	t.controls.firstChild.setAttribute("src", dhtmlwindow.imagefiles[0]) //Change "restore" icon within window interface to "minimize" icon
		    t.controls.firstChild.setAttribute("title", "Minimize")
		    t.state="fullview" //indicate the state of the window as being "fullview"
	    }
	    return t
    },

    setSize:function(t, w, h){ //set window size (min is 150px wide by 100px tall)
	    t.style.width=Math.max(parseInt(w), 150)+"px"
	    t.contentarea.style.height=Math.max(parseInt(h), 100)+"px"
    },

    moveTo:function(t, x, y){ //move window. Position includes current viewpoint of document
	    this.getviewpoint() //Get current viewpoint numbers
	    t.style.left=(x=="middle")? this.scroll_left+(this.docwidth-t.offsetWidth)/2+"px" : this.scroll_left+parseInt(x)+"px"
	    t.style.top=(y=="middle")? this.scroll_top+(this.docheight-t.offsetHeight)/2+"px" : this.scroll_top+parseInt(y)+"px"
    },

    isResize:function(t, bol){ //show or hide resize inteface (part of the status bar)
	    t.statusarea.style.display=(bol)? "block" : "none"
	    t.resizeBool=(bol)? 1 : 0
    },

    isScrolling:function(t, bol){ //set whether loaded content contains scrollbars
	    t.contentarea.style.overflow=(bol)? "auto" : "hidden"
    },

    load:function(t, contenttype, contentsource, title){ //loads content into window plus set its title (3 content types: "inline", "iframe", or "ajax")
	    if (t.isClosed){
		    alert("DHTML Window has been closed, so no window to load contents into. Open/Create the window again.")
		    return
	    }
	    var contenttype=contenttype.toLowerCase() //convert string to lower case
	    if (typeof title!="undefined")
		    t.handle.firstChild.nodeValue=title
	    if (contenttype=="inline")
		    t.contentarea.innerHTML=contentsource
	    else if (contenttype=="div"){
		    var inlinedivref=document.getElementById(contentsource)
		    t.contentarea.innerHTML=(inlinedivref.defaultHTML || inlinedivref.innerHTML) //Populate window with contents of inline div on page
		    if (!inlinedivref.defaultHTML)
			    inlinedivref.defaultHTML=inlinedivref.innerHTML //save HTML within inline DIV
		    inlinedivref.innerHTML="" //then, remove HTML within inline DIV (to prevent duplicate IDs, NAME attributes etc in contents of DHTML window
		    inlinedivref.style.display="none" //hide that div
	    }
	    else if (contenttype=="iframe"){
		    t.contentarea.style.overflow="hidden" //disable window scrollbars, as iframe already contains scrollbars
		    if (!t.contentarea.firstChild || t.contentarea.firstChild.tagName!="IFRAME") //If iframe tag doesn't exist already, create it first
			    t.contentarea.innerHTML='<iframe src="" style="margin:0; padding:0; width:100%; height: 100%" name="_iframe-'+t.id+'"></iframe>'
		    window.frames["_iframe-"+t.id].location.replace(contentsource) //set location of iframe window to specified URL
		    }
	    else if (contenttype=="ajax"){
		    this.ajax_connect(contentsource, t) //populate window with external contents fetched via Ajax
	    }
	    t.contentarea.datatype=contenttype //store contenttype of current window for future reference
    },

    setupdrag:function(e){
	    var d=ThePort.UI.PopWindow; //reference dhtml window object
	    var t=this._parent //reference dhtml window div
	    d.etarget=this //remember div mouse is currently held down on ("handle" or "resize" div)
	    var e=window.event || e
	    d.initmousex=e.clientX //store x position of mouse onmousedown
	    d.initmousey=e.clientY
	    d.initx=parseInt(t.offsetLeft) //store offset x of window div onmousedown
	    d.inity=parseInt(t.offsetTop)
	    d.width=parseInt(t.offsetWidth) //store width of window div
	    d.contentheight=parseInt(t.contentarea.offsetHeight) //store height of window div's content div
	    if (t.contentarea.datatype=="iframe"){ //if content of this window div is "iframe"
		    t.style.backgroundColor="#F8F8F8" //colorize and hide content div (while window is being dragged)
		    t.contentarea.style.visibility="hidden"
	    }
	    document.onmousemove=d.getdistance //get distance travelled by mouse as it moves
	    document.onmouseup=function(){
		    if (t.contentarea.datatype=="iframe"){ //restore color and visibility of content div onmouseup
			    t.contentarea.style.backgroundColor="white"
			    t.contentarea.style.visibility="visible"
		    }
		    d.stop()
	    }
	    return false
    },

    getdistance:function(e){
	    var d=ThePort.UI.PopWindow;
	    var etarget=d.etarget
	    var e=window.event || e
	    d.distancex=e.clientX-d.initmousex //horizontal distance travelled relative to starting point
	    d.distancey=e.clientY-d.initmousey
	    if (etarget.className=="drag-handle") //if target element is "handle" div
		    d.move(etarget._parent, e)
	    else if (etarget.className=="drag-resizearea") //if target element is "resize" div
		    d.resize(etarget._parent, e)
	    return false //cancel default dragging behavior
    },

    getviewpoint:function(){ //get window viewpoint numbers
	    var ie=document.all && !window.opera
	    var domclientWidth=document.documentElement && parseInt(document.documentElement.clientWidth) || 100000 //Preliminary doc width in non IE browsers
	    this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
	    this.scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
	    this.scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
	    this.docwidth=(ie)? this.standardbody.clientWidth : (/Safari/i.test(navigator.userAgent))? window.innerWidth : Math.min(domclientWidth, window.innerWidth-16)
	    this.docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
    },

    rememberattrs:function(t){ //remember certain attributes of the window when it's minimized or closed, such as dimensions, position on page
	    this.getviewpoint() //Get current window viewpoint numbers
	    t.lastx=parseInt((t.style.left || t.offsetLeft))-ThePort.UI.PopWindow.scroll_left //store last known x coord of window just before minimizing
	    t.lasty=parseInt((t.style.top || t.offsetTop))-ThePort.UI.PopWindow.scroll_top
	    t.lastwidth=parseInt(t.style.width) //store last known width of window just before minimizing/ closing
    },

    move:function(t, e){
	    t.style.left=ThePort.UI.PopWindow.distancex+ThePort.UI.PopWindow.initx+"px"
	    t.style.top=ThePort.UI.PopWindow.distancey+ThePort.UI.PopWindow.inity+"px"
    },

    resize:function(t, e){
	    t.style.width=Math.max(ThePort.UI.PopWindow.width+ThePort.UI.PopWindow.distancex, 150)+"px"
	    t.contentarea.style.height=Math.max(ThePort.UI.PopWindow.contentheight+ThePort.UI.PopWindow.distancey, 100)+"px"
    },

    enablecontrols:function(e){
	    var d=ThePort.UI.PopWindow;
	    var sourceobj=window.event? window.event.srcElement : e.target //Get element within "handle" div mouse is currently on (the controls)
	    if (/Minimize/i.test(sourceobj.getAttribute("title"))) //if this is the "minimize" control
		    d.minimize(sourceobj, this._parent)
	    else if (/Restore/i.test(sourceobj.getAttribute("title"))) //if this is the "restore" control
		    d.restore(sourceobj, this._parent)
	    else if (/Close/i.test(sourceobj.getAttribute("title"))) //if this is the "close" control
		    d.close(this._parent)
	    return false
    },

    minimize:function(button, t){
	    ThePort.UI.PopWindow.rememberattrs(t)
	    //button.setAttribute("src", dhtmlwindow.imagefiles[2])
	    button.setAttribute("title", "Restore")
	    t.state="minimized" //indicate the state of the window as being "minimized"
	    t.contentarea.style.display="none"
	    t.statusarea.style.display="none"
	    if (typeof t.minimizeorder=="undefined"){ //stack order of minmized window on screen relative to any other minimized windows
		    ThePort.UI.PopWindow.minimizeorder++ //increment order
		    t.minimizeorder=ThePort.UI.PopWindow.minimizeorder
	    }
	    t.style.left="10px" //left coord of minmized window
	    t.style.width="200px"
	    var windowspacing=t.minimizeorder*10 //spacing (gap) between each minmized window(s)
	    t.style.top=ThePort.UI.PopWindow.scroll_top+ThePort.UI.PopWindow.docheight-(t.handle.offsetHeight*t.minimizeorder)-windowspacing+"px"
    },

    restore:function(button, t){
	    ThePort.UI.PopWindow.getviewpoint()
	    //button.setAttribute("src", dhtmlwindow.imagefiles[0])
	    button.setAttribute("title", "Minimize")
	    t.state="fullview" //indicate the state of the window as being "fullview"
	    t.style.display="block"
	    t.contentarea.style.display="block"
	    if (t.resizeBool) //if this window is resizable, enable the resize icon
		    t.statusarea.style.display="block"
	    t.style.left=parseInt(t.lastx)+ThePort.UI.PopWindow.scroll_left+"px" //position window to last known x coord just before minimizing
	    t.style.top=parseInt(t.lasty)+ThePort.UI.PopWindow.scroll_top+"px"
	    t.style.width=parseInt(t.lastwidth)+"px"
    },


    close:function(t){
	    try{
		    var closewinbol=t.onclose()
	    }
	    catch(err){ //In non IE browsers, all errors are caught, so just run the below
		    var closewinbol=true
     }
	    finally{ //In IE, not all errors are caught, so check if variable isn't defined in IE in those cases
		    if (typeof closewinbol=="undefined"){
			    alert("An error has occured somwhere inside your \"onclose\" event handler")
			    var closewinbol=true
		    }
	    }
	    if (closewinbol){ //if custom event handler function returns true
		    if (t.state!="minimized") //if this window isn't currently minimized
			    ThePort.UI.PopWindow.rememberattrs(t) //remember window's dimensions/position on the page before closing
		    if (window.frames["_iframe-"+t.id]) //if this is an IFRAME DHTML window
			    window.frames["_iframe-"+t.id].location.replace("about:blank")
		    else
			    t.contentarea.innerHTML=""
		    t.style.display="none"
		    t.isClosed=true //tell script this window is closed (for detection in t.show())
	    }
	    return closewinbol
    },


    setopacity:function(targetobject, value){ //Sets the opacity of targetobject based on the passed in value setting (0 to 1 and in between)
	    if (!targetobject)
		    return
	    if (targetobject.filters && targetobject.filters[0]){ //IE syntax
		    if (typeof targetobject.filters[0].opacity=="number") //IE6
			    targetobject.filters[0].opacity=value*100
		    else //IE 5.5
			    targetobject.style.filter="alpha(opacity="+value*100+")"
		    }
	    else if (typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax
		    targetobject.style.MozOpacity=value
	    else if (typeof targetobject.style.opacity!="undefined") //Standard opacity syntax
		    targetobject.style.opacity=value
    },

    setfocus:function(t){ //Sets focus to the currently active window
	    this.zIndexvalue++
	    t.style.zIndex=this.zIndexvalue
	    t.isClosed=false //tell script this window isn't closed (for detection in t.show())
	    this.setopacity(this.lastactivet.handle, 0.5) //unfocus last active window
	    this.setopacity(t.handle, 1) //focus currently active window
	    this.lastactivet=t //remember last active window
    },


    show:function(t){
	    if (t.isClosed){
		    alert("DHTML Window has been closed, so nothing to show. Open/Create the window again.")
		    return
	    }
	    if (t.lastx) //If there exists previously stored information such as last x position on window attributes (meaning it's been minimized or closed)
		    ThePort.UI.PopWindow.restore(t.controls.firstChild, t) //restore the window using that info
	    else
		    t.style.display="block"
	    this.setfocus(t)
	    t.state="fullview" //indicate the state of the window as being "fullview"
    },

    hide:function(t){
	    t.style.display="none"
    },

    ajax_connect:function(url, t){
	    var page_request = false
	    var bustcacheparameter=""
	    if (window.XMLHttpRequest) // if Mozilla, IE7, Safari etc
		    page_request = new XMLHttpRequest()
	    else if (window.ActiveXObject){ // if IE6 or below
		    try {
		    page_request = new ActiveXObject("Msxml2.XMLHTTP")
		    } 
		    catch (e){
			    try{
			    page_request = new ActiveXObject("Microsoft.XMLHTTP")
			    }
			    catch (e){}
		    }
	    }
	    else
		    return false
	    t.contentarea.innerHTML=this.ajaxloadinghtml
	    page_request.onreadystatechange=function(){ThePort.UI.PopWindow.ajax_loadpage(page_request, t)}
	    if (this.ajaxbustcache) //if bust caching of external page
		    bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
	    page_request.open('GET', url+bustcacheparameter, true)
	    page_request.send(null)
    },

    ajax_loadpage:function(page_request, t){
	    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
	    t.contentarea.innerHTML=page_request.responseText
	    }
    },


    stop:function(){
	    ThePort.UI.PopWindow.etarget=null //clean up
	    document.onmousemove=null
	    document.onmouseup=null
    },

    addEvent:function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
	    var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	    if (target.addEventListener)
		    target.addEventListener(tasktype, functionref, false)
	    else if (target.attachEvent)
		    target.attachEvent(tasktype, functionref)
    },

    cleanup:function(){
	    for (var i=0; i<ThePort.UI.PopWindow.tobjects.length; i++){
		    ThePort.UI.PopWindow.tobjects[i].handle._parent=ThePort.UI.PopWindow.tobjects[i].resizearea._parent=ThePort.UI.PopWindow.tobjects[i].controls._parent=null
	    }
	    window.onload=null
    }

} /*  End dhtmlwindow object */

document.write('<div id="dhtmlwindowholder"><span style="display:none">.</span></div>') //container that holds all dhtml window divs on page
window.onunload=ThePort.UI.PopWindow.cleanup;

} /* End Namespace */



//if (typeof dhtmlwindow=="undefined")
// alert('ERROR: Modal Window script requires all files from "DHTML Window widget" in order to work!')
if (ThePortRegisterNS("ThePort.UI.PopModalWindow")) {

/*******************************/
/*  DHTML Window Routines...   */
/*******************************/
ThePort.UI.PopModalWindow = {
    veilstack: 0,
    open:function(t, contenttype, contentsource, title, attr, recalonload){
	    var d=ThePort.UI.PopWindow; //reference dhtmlwindow object
	    this.interVeil=document.getElementById("interVeil") //Reference "veil" div
	    this.veilstack++ //var to keep track of how many modal windows are open right now
	    this.loadveil()
	    if (recalonload=="recal" && d.scroll_top==0)
		    d.addEvent(window, function(){ThePort.UI.PopModalWindow.adjustveil()}, "load")
	    var t=d.open(t, contenttype, contentsource, title, attr, recalonload)
	    //t.controls.firstChild.style.display="none" //Disable "minimize" button
	    t.controls.onclick=function(){ThePort.UI.PopModalWindow.close(this._parent, true)} //OVERWRITE default control action with new one
	    t.show=function(){ThePort.UI.PopModalWindow.show(this)} //OVERWRITE default t.show() method with new one
	    t.hide=function(){ThePort.UI.PopModalWindow.close(this)} //OVERWRITE default t.hide() method with new one
    return t
    },


    loadveil:function(){
	    var d=ThePort.UI.PopWindow;
	    d.getviewpoint()
	    this.docheightcomplete=(d.standardbody.offsetHeight>d.standardbody.scrollHeight)? d.standardbody.offsetHeight : d.standardbody.scrollHeight
	    this.interVeil.style.width=d.docwidth+"px" //set up veil over page
	    this.interVeil.style.height=this.docheightcomplete+"px" //set up veil over page
	    this.interVeil.style.left=0 //Position veil over page
	    this.interVeil.style.top=0 //Position veil over page
	    this.interVeil.style.visibility="visible" //Show veil over page
	    this.interVeil.style.display="block" //Show veil over page
    },

    adjustveil:function(){ //function to adjust veil when window is resized
	    if (this.interVeil && this.interVeil.style.display=="block") //If veil is currently visible on the screen
		    this.loadveil() //readjust veil
    },

    closeveil:function(){ //function to close veil
	    this.veilstack--
	    if (this.veilstack==0) //if this is the only modal window visible on the screen, and being closed
		    this.interVeil.style.display="none"
    },


    close:function(t, forceclose){ //DHTML modal close function
	    t.contentDoc=(t.contentarea.datatype=="iframe")? window.frames["_iframe-"+t.id].document : t.contentarea //return reference to modal window DIV (or document object in the case of iframe
	    if (typeof forceclose!="undefined")
		    t.onclose=function(){return true}
	    if (ThePort.UI.PopWindow.close(t)) //if close() returns true
		    this.closeveil()
    },


    show:function(t) {
	    ThePort.UI.PopModalWindow.veilstack++
	    ThePort.UI.PopModalWindow.loadveil()
	    ThePort.UI.PopWindow.show(t)
        }
} //END object declaration
document.write('<div id="interVeil"></div>');
ThePort.UI.PopWindow.addEvent(window, function(){if (typeof ThePort.UI.PopModalWindow!="undefined") ThePort.UI.PopModalWindow.adjustveil()}, "resize");

} /* End Namespace */﻿/*
xml2json v 1.1
copyright 2005-2007 Thomas Frank

 A simple call - myXML is a string containing your XML:
myJsonObject=xml2json.parser(myXML);
 
 A 2:nd, optional, parameter is "tags not to convert" - for example <b> and <i>:
myJsonObject=xml2json.parser(myXML,'b,i');
 
 A 3:rd, optional, parameter gives us a string showing us the JSON structure 
 instead of the actual JSON object:
myString=xml2json.parser(myXML,'','html');
 
- use "compact" for output without linebreaks or tabbing
- use "normal" for output with linebreaks and tabbing
- use "html" for a html representation

This program is free software under the terms of the 
GNU General Public License version 2 as published by the Free 
Software Foundation. It is distributed without any warranty.
*/
if (ThePortRegisterNS("ThePort.Xml2JSon")) {
    ThePort.Xml2JSon = {
	parser : function(xmlcode,ignoretags,debug) {
		if(!ignoretags){ignoretags=""};
		xmlcode=xmlcode.replace(/\s*\/>/g,'/>');
		xmlcode=xmlcode.replace(/<\?[^>]*>/g,"").replace(/<\![^>]*>/g,"");
		if (!ignoretags.sort){ignoretags=ignoretags.split(",")};
		var x=this.no_fast_endings(xmlcode);
		x=this.attris_to_tags(x);
		x=escape(x);
		x=x.split("%3C").join("<").split("%3E").join(">").split("%3D").join("=").split("%22").join("\"");
		for (var i=0;i<ignoretags.length;i++){
			x=x.replace(new RegExp("<"+ignoretags[i]+">","g"),"*$**"+ignoretags[i]+"**$*");
			x=x.replace(new RegExp("</"+ignoretags[i]+">","g"),"*$***"+ignoretags[i]+"**$*")
		};
		x='<JSONTAGWRAPPER>'+x+'</JSONTAGWRAPPER>';
		this.xmlobject={};
		var y=this.xml_to_object(x).jsontagwrapper;
		if(debug){y=this.show_json_structure(y,debug)};
		return y
	},
	xml_to_object:function(xmlcode){
		var x=xmlcode.replace(/<\//g,"§");
		x=x.split("<");
		var y=[];
		var level=0;
		var opentags=[];
		for (var i=1;i<x.length;i++){
			var tagname=x[i].split(">")[0];
			opentags.push(tagname);
			level++
			y.push(level+"<"+x[i].split("§")[0]);
			while(x[i].indexOf("§"+opentags[opentags.length-1]+">")>=0){level--;opentags.pop()}
		};
		var oldniva=-1;
		var objname="this.xmlobject";
		for (var i=0;i<y.length;i++){
			var preeval="";
			var niva=y[i].split("<")[0];
			var tagnamn=y[i].split("<")[1].split(">")[0];
			tagnamn=tagnamn.toLowerCase();
			var rest=y[i].split(">")[1];
			if(niva<=oldniva){
				var tabort=oldniva-niva+1;
				for (var j=0;j<tabort;j++){objname=objname.substring(0,objname.lastIndexOf("."))}
			};
			objname+="."+tagnamn;
			var pobject=objname.substring(0,objname.lastIndexOf("."));
			if (eval("typeof "+pobject) != "object"){preeval+=pobject+"={value:"+pobject+"};\n"};
			var objlast=objname.substring(objname.lastIndexOf(".")+1);
			var already=false;
			for (k in eval(pobject)){if(k==objlast){already=true}};
			var onlywhites=true;
			for(var s=0;s<rest.length;s+=3){
				if(rest.charAt(s)!="%"){onlywhites=false}
			};
			if (rest!="" && !onlywhites){
				if(rest/1!=rest){
					rest="'"+rest.replace(/\'/g,"\\'")+"'";
					rest=rest.replace(/\*\$\*\*\*/g,"</");
					rest=rest.replace(/\*\$\*\*/g,"<");
					rest=rest.replace(/\*\*\$\*/g,">")
				}
			} 
			else {rest="{}"};
			if(rest.charAt(0)=="'"){rest='unescape('+rest+')'};
			if (already && !eval(objname+".sort")){preeval+=objname+"=["+objname+"];\n"};
			var before="=";after="";
			if (already){before=".push(";after=")"};
			var toeval=preeval+objname+before+rest+after;
			eval(toeval);
			if(eval(objname+".sort")){objname+="["+eval(objname+".length-1")+"]"};
			oldniva=niva
		};
		return this.xmlobject
	},
	show_json_structure:function(obj,debug,l){
		var x='';
		if (obj.sort){x+="[\n"} else {x+="{\n"};
		for (var i in obj){
			if (!obj.sort){x+=i+":"};
			if (typeof obj[i] == "object"){
				x+=this.show_json_structure(obj[i],false,1)
			}
			else {
				if(typeof obj[i]=="function"){
					var v=obj[i]+"";
					//v=v.replace(/\t/g,"");
					x+=v
				}
				else if(typeof obj[i]!="string"){x+=obj[i]+",\n"}
				else {x+="'"+obj[i].replace(/\'/g,"\\'").replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r")+"',\n"}
			}
		};
		if (obj.sort){x+="],\n"} else {x+="},\n"};
		if (!l){
			x=x.substring(0,x.lastIndexOf(","));
			x=x.replace(new RegExp(",\n}","g"),"\n}");
			x=x.replace(new RegExp(",\n]","g"),"\n]");
			var y=x.split("\n");x="";
			var lvl=0;
			for (var i=0;i<y.length;i++){
				if(y[i].indexOf("}")>=0 || y[i].indexOf("]")>=0){lvl--};
				tabs="";for(var j=0;j<lvl;j++){tabs+="\t"};
				x+=tabs+y[i]+"\n";
				if(y[i].indexOf("{")>=0 || y[i].indexOf("[")>=0){lvl++}
			};
			if(debug=="html"){
				x=x.replace(/</g,"&lt;").replace(/>/g,"&gt;");
				x=x.replace(/\n/g,"<BR>").replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;")
			};
			if (debug=="compact"){x=x.replace(/\n/g,"").replace(/\t/g,"")}
		};
		return x
	},
	no_fast_endings:function(x){
		x=x.split("/>");
		for (var i=1;i<x.length;i++){
			var t=x[i-1].substring(x[i-1].lastIndexOf("<")+1).split(" ")[0];
			x[i]="></"+t+">"+x[i]
		}	;
		x=x.join("");
		return x
	},
	attris_to_tags: function(x){
		var d=' ="\''.split("");
		x=x.split(">");
		for (var i=0;i<x.length;i++){
			var temp=x[i].split("<");
			for (var r=0;r<4;r++){temp[0]=temp[0].replace(new RegExp(d[r],"g"),"_jsonconvtemp"+r+"_")};
			if(temp[1]){
				temp[1]=temp[1].replace(/'/g,'"');
				temp[1]=temp[1].split('"');
				for (var j=1;j<temp[1].length;j+=2){
					for (var r=0;r<4;r++){temp[1][j]=temp[1][j].replace(new RegExp(d[r],"g"),"_jsonconvtemp"+r+"_")}
				};
				temp[1]=temp[1].join('"')
			};
			x[i]=temp.join("<")
		};
		x=x.join(">");
		x=x.replace(/ ([^=]*)=([^ |>]*)/g,"><$1>$2</$1");
		x=x.replace(/>"/g,">").replace(/"</g,"<");
		for (var r=0;r<4;r++){x=x.replace(new RegExp("_jsonconvtemp"+r+"_","g"),d[r])}	;
		return x
	}

    }   /* End Module */
}  /* End Namespace */

﻿
/*
cbbLite function by Roger Johansson, http://www.456bereastreet.com/
*/
var cbbLite = {
	init : function() {
	// Check that the browser supports the DOM methods used
		if (!document.getElementById || !document.createElement || !document.appendChild) return false;
		var oElement, oOuter, oI1, oI2, tempId;
	// Find all elements with a class name of cbbLite
		var arrElements = document.getElementsByTagName('*');
		var oRegExp = new RegExp("(^|\\s)cbbLite(\\s|$)");
		for (var i=0; i<arrElements.length; i++) {
	// Save the original outer element for later
			oElement = arrElements[i];
			if (oRegExp.test(oElement.className)) {
	// 	Create a new element and give it the original element's class name(s) while replacing 'cbbLite' with 'cb'
				oOuter = document.createElement('div');
				oOuter.className = oElement.className.replace(oRegExp, '$1cb$2');
	// Give the new div the original element's id if it has one
				if (oElement.getAttribute("id")) {
					tempId = oElement.id;
					oElement.removeAttribute('id');
					oOuter.setAttribute('id', '');
					oOuter.id = tempId;
				}
	// Change the original element's class name and replace it with the new div
				oElement.className = 'i3Lite';
				oElement.parentNode.replaceChild(oOuter, oElement);
	// Create two new div elements and insert them into the outermost div
				oI1 = document.createElement('div');
				oI1.className = 'i1Lite';
				oOuter.appendChild(oI1);
				oI2 = document.createElement('div');
				oI2.className = 'i2Lite';
				oI1.appendChild(oI2);
	// Insert the original element
				oI2.appendChild(oElement);
	// Insert the top and bottom divs
				cbbLite.insertTop(oOuter);
				cbbLite.insertBottom(oOuter);
			}
		}
	},
	insertTop : function(obj) {
		var oOuter, oInner;
	// Create the two div elements needed for the top of the box
		oOuter=document.createElement("div");
		oOuter.className="btLite"; // The outer div needs a class name
	    oInner=document.createElement("div");
	    oOuter.appendChild(oInner);
		obj.insertBefore(oOuter,obj.firstChild);
	},
	insertBottom : function(obj) {
		var oOuter, oInner;
	// Create the two div elements needed for the bottom of the box
		oOuter=document.createElement("div");
		oOuter.className="bbLite"; // The outer div needs a class name
	    oInner=document.createElement("div");
	    oOuter.appendChild(oInner);
		obj.appendChild(oOuter);
	},
	// addEvent function from http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
	addEvent : function(obj, type, fn) {
		if (obj.addEventListener)
			obj.addEventListener(type, fn, false);
		else if (obj.attachEvent) {
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
			obj.attachEvent("on"+type, obj[type+fn]);
		}
	}
};
cbbLite.addEvent(window, 'load', cbbLite.init);
// Dark
var cbb = {
	init : function() {
	// Check that the browser supports the DOM methods used
		if (!document.getElementById || !document.createElement || !document.appendChild) return false;
		var oElement, oOuter, oI1, oI2, tempId;
	// Find all elements with a class name of cbb
		var arrElements = document.getElementsByTagName('*');
		var oRegExp = new RegExp("(^|\\s)cbb(\\s|$)");
		for (var i=0; i<arrElements.length; i++) {
	// Save the original outer element for later
			oElement = arrElements[i];
			if (oRegExp.test(oElement.className)) {
	// 	Create a new element and give it the original element's class name(s) while replacing 'cbb' with 'cb'
				oOuter = document.createElement('div');
				oOuter.className = oElement.className.replace(oRegExp, '$1cb$2');
	// Give the new div the original element's id if it has one
				if (oElement.getAttribute("id")) {
					tempId = oElement.id;
					oElement.removeAttribute('id');
					oOuter.setAttribute('id', '');
					oOuter.id = tempId;
				}
	// Change the original element's class name and replace it with the new div
				oElement.className = 'i3';
				oElement.parentNode.replaceChild(oOuter, oElement);
	// Create two new div elements and insert them into the outermost div
				oI1 = document.createElement('div');
				oI1.className = 'i1';
				oOuter.appendChild(oI1);
				oI2 = document.createElement('div');
				oI2.className = 'i2';
				oI1.appendChild(oI2);
	// Insert the original element
				oI2.appendChild(oElement);
	// Insert the top and bottom divs
				cbb.insertTop(oOuter);
				cbb.insertBottom(oOuter);
			}
		}
	},
	insertTop : function(obj) {
		var oOuter, oInner;
	// Create the two div elements needed for the top of the box
		oOuter=document.createElement("div");
		oOuter.className="bt"; // The outer div needs a class name
	    oInner=document.createElement("div");
	    oOuter.appendChild(oInner);
		obj.insertBefore(oOuter,obj.firstChild);
	},
	insertBottom : function(obj) {
		var oOuter, oInner;
	// Create the two div elements needed for the bottom of the box
		oOuter=document.createElement("div");
		oOuter.className="bb"; // The outer div needs a class name
	    oInner=document.createElement("div");
	    oOuter.appendChild(oInner);
		obj.appendChild(oOuter);
	},
	// addEvent function from http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
	addEvent : function(obj, type, fn) {
		if (obj.addEventListener)
			obj.addEventListener(type, fn, false);
		else if (obj.attachEvent) {
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
			obj.attachEvent("on"+type, obj[type+fn]);
		}
	}
}
cbb.addEvent(window, 'load', cbb.init);﻿
/********************************************************/
/********************************************************/
/* START::Depricated Wrapper classes for compatibility. */
/********************************************************/
/********************************************************/
 
/*********************************/
/* Begin ThePortCommon Constants */
/*********************************/
function ThePortCommon() {}
ThePortCommon.Constants = {
CONST_EMPTY_STRING      : ThePort.Common.CONST_EMPTY_STRING,
CONST_UNDEFINED         : ThePort.Common.CONST_UNDEFINED,
CONST_TYPE_FUNCTION     : ThePort.Common.CONST_TYPE_FUNCTION,
CONST_ERROR_MESSAGE     : ThePort.Common.CONST_ERROR_MESSAGE,

CONST_FORM_POST         : ThePort.Common.CONST_FORM_POST,
CONST_FORM_GET          : ThePort.Common.CONST_FORM_GET,
CONST_FORM_DELETE       : ThePort.Common.CONST_FORM_DELETE,
CONST_FORM_PUT          : ThePort.Common.CONST_FORM_PUT,

CONST_FORMAT_XML        : ThePort.Common.CONST_FORMAT_XML,
CONST_FORMAT_JSON       : ThePort.Common.CONST_FORMAT_JSON,

CONST_CONTENTTYPE_JSON1 : ThePort.Common.CONST_CONTENTTYPE_JSON1,
CONST_CONTENTTYPE_JSON2 : ThePort.Common.CONST_CONTENTTYPE_JSON2,
CONST_CONTENTTYPE_JSON3 : ThePort.Common.CONST_CONTENTTYPE_JSON3,
CONST_CONTENTTYPE_XML   : ThePort.Common.CONST_CONTENTTYPE_XML,
CONST_CONTENTTYPE       : ThePort.Common.CONST_CONTENTTYPE,
CONST_FORM_POST_URLENC  : ThePort.Common.CONST_FORM_POST_URLENC,
CONST_CONTENTLENGTH     : ThePort.Common.CONST_CONTENTLENGTH,
CONST_HEADER_CONNECTION : ThePort.Common.CONST_HEADER_CONNECTION,
CONST_HEADER_CONN_CLOSE : ThePort.Common.CONST_HEADER_CONN_CLOSE,

CONST_ACTIVEX1_AJAX_OBJ : ThePort.Common.CONST_ACTIVEX1_AJAX_OBJ,
CONST_ACTIVEX2_AJAX_OBJ : ThePort.Common.CONST_ACTIVEX2_AJAX_OBJ,
CONST_ACTIVEX_XML_OBJ   : ThePort.Common.CONST_ACTIVEX_XML_OBJ,

QS_NAME                 : ThePort.Common.QS_NAME,
QS_OBJECTID             : ThePort.Common.QS_OBJECTID,
QS_DATA                 : ThePort.Common.QS_DATA,
QS_DATAFORMAT           : ThePort.Common.QS_DATAFORMAT,
QS_HASH                 : ThePort.Common.QS_HASH,
QS_COMMENT              : ThePort.Common.QS_COMMENT,
QS_CONTEXTID            : ThePort.Common.QS_CONTEXTID,

CONST_COMMA             : ThePort.Common.CONST_COMMA,
CONST_EQUALS            : ThePort.Common.CONST_EQUALS,
CONST_QUESTION_MARK     : ThePort.Common.CONST_QUESTION_MARK,

CONST_AMPERSAND         : ThePort.Common.CONST_AMPERSAND,
CONST_SINGLE_QUOTE      : ThePort.Common.CONST_SINGLE_QUOTE,
CONST_DBL_QUOTE         : ThePort.Common.CONST_DBL_QUOTE,
CONST_GREATER_THAN      : ThePort.Common.CONST_GREATER_THAN,
CONST_LESS_THAN         : ThePort.Common.CONST_LESS_THAN,

CONST_ENC_AMPERSAND     : ThePort.Common.CONST_ENC_AMPERSAND,
CONST_ENC_SINGLE_QUOTE  : ThePort.Common.CONST_ENC_SINGLE_QUOTE,
CONST_ENC_DBL_QUOTE     : ThePort.Common.CONST_ENC_DBL_QUOTE,
CONST_ENC_GREATER_THAN  : ThePort.Common.CONST_ENC_GREATER_THAN,
CONST_ENC_LESS_THAN     : ThePort.Common.CONST_ENC_LESS_THAN,

CONST_HTTP_READYSTATE_UNINITIALIZED : ThePort.Common.CONST_HTTP_READYSTATE_UNINITIALIZED,
CONST_HTTP_READYSTATE_LOADING       : ThePort.Common.CONST_HTTP_READYSTATE_LOADING, 
CONST_HTTP_READYSTATE_LOADED        : ThePort.Common.CONST_HTTP_READYSTATE_LOADED,
CONST_HTTP_READYSTATE_INTERACTIVE   : ThePort.Common.CONST_HTTP_READYSTATE_INTERACTIVE, 
CONST_HTTP_READYSTATE_COMPLETED     : ThePort.Common.CONST_HTTP_READYSTATE_COMPLETED,
CONST_STYLE_DISPLAY_ON              : ThePort.Common.CONST_STYLE_DISPLAY_ON,
CONST_STYLE_DISPLAY_OFF             : ThePort.Common.CONST_STYLE_DISPLAY_OFF,

CONST_AJAX_URL                      : ThePort.Common.CONST_AJAX_URL
} 
/*******************************/
/* End ThePortCommon Constants */
/*******************************/

/***************************/
/* Begin ThePortXSL Module */
/***************************/
ThePortXSL = {
Instantiate : function (sXml) {
     return ThePort.XSL.Instantiate(sXml);
     },
Instantiate64 : function (xmlString) {
    return ThePort.XSL.Instantiate64(xmlString);
    },
RenderXML : function (oXml) {
    return ThePort.XSL.RenderXML(oXml);
    },
ParseAndRenderXML : function (oWin,sXml) {
    return ThePort.XSL.ParseAndRenderXML(oWin,sXml);
    },
FormatXmlToString : function (oXml) {
    return ThePort.XSL.FormatXmlToString(oXml);
    },
Decoder : function (sEncodedString) {
    return ThePort.XSL.Decoder(sEncodedString);
    },
LoadDocument : function(sXml) {
    return ThePort.XSL.LoadDocument(sXml);
    },
EscapeXML : function (sXml) {
    return ThePort.XSL.EscapeXML(sXml);
    },  
SerializeToXML : function(oXml) {
    return ThePort.XSL.SerializeToXML(oXml);
    },
Save : function (oObject,fnCallback) {
    return ThePort.XSL.Save(oObject,fnCallback);
    },
Delete : function (oObject,fnCallback) {
    return ThePort.XSL.Delete(oObject,fnCallback);
    },
AjaxPost : function (sUrl,sPostData,oCallbackFn) {
    return ThePort.XSL.AjaxPost(sUrl,sPostData,oCallbackFn);
    },
AjaxDelete : function (sUrl,sPostData,oCallbackFn) {
    return ThePort.XSL.AjaxDelete(sUrl,sPostData,oCallbackFn);
    },
AjaxGet : function (sUrl,oCallbackFn) {
    return ThePort.XSL.AjaxGet(sUrl,oCallbackFn);
    },
GetModulePointer : function (sModuleName) {
    return ThePort.XSL.GetModulePointer(sModuleName);
    },
CallModuleFunction : function (sModuleName,oFnName) {
    return ThePort.XSL.CallModuleFunction(sModuleName,oFnName);
    }
}
/*************************/
/* End ThePortXSL Module */
/*************************/

/*********************************/
/* Begin ThePortUtilities Module */
/*********************************/
ThePortUtilities = { 
Ajax : function (sCommand,sUrl,oBindFunction,sPostData) {
return ThePort.Utils.Ajax(sCommand,sUrl,oBindFunction,sPostData);
    },
Bind : function (oObject, fMethodName) {
return ThePort.Utils.Bind(oObject, fMethodName);
    },
AjaxBind : function (oObject, fMethodName) {
return ThePort.Utils.AjaxBind(oObject, fMethodName);
    },
LogServerException : function (oResponse) {
return ThePort.Utils.LogServerException(oResponse);
},
RegisterModule : function (ns) {
return ThePort.Utils.RegisterModule(ns);
},  
GetTagValue : function(oDoc, sTagName) {
return ThePort.Utils.GetTagValue(oDoc, sTagName);
    },
GetVariablePair : function(sName,sValue) {
    return ThePort.Utils.GetVariablePair(sName,sValue);
   },
AddDictionaryPair : function(sName,sValue) {
    return ThePort.Utils.AddDictionaryPair(sName,sValue);
   },
AddVariablePair : function(sName,sValue) {
    return ThePort.Utils.AddVariablePair(sName,sValue);
   },
GetTagAttributeValue : function(oDoc, sTagName, sAttribName) {
    return ThePort.Utils.GetTagAttributeValue(oDoc, sTagName, sAttribName);
    },
GetValueFromNode : function(node) {
    return ThePort.Utils.GetValueFromNode(node);
    },
GetAttrValueFromNode : function(node,attr) {
    return ThePort.Utils.GetAttrValueFromNode(node,attr);
    },
GetObj : function (oObjectID) {
    return ThePort.Utils.GetObj(oObjectID); 
    },
StopEvent : function(event) {
    return ThePort.Utils.StopEvent(event);
    },
Show : function(id) {
   return ThePort.Utils.Show(id);
   },
Hide : function(id) {
   return ThePort.Utils.Hide(id);
   },
Toggle : function(id) {
   return ThePort.Utils.Toggle(id);
   },
KeyDownHandler : function (eEvent,sButtonID) {
    return ThePort.Utils.KeyDownHandler(eEvent,sButtonID);
   },
GetReplyObject : function(oResponse) {
    return ThePort.Utils.GetReplyObject(oResponse);
    },
Decode64 : function (input) {
    return ThePort.Utils.Decode64(input);
   }
}
/*********************************/
/* End ThePortUtilities Module */
/*********************************/


/***********************************/
/* Begin ThePortXMLProcessor Class */
/***********************************/
ThePortXMLProcessor = function() {
    this.m_oXmp = new ThePort.XMLProcessor();  
}
ThePortXMLProcessor.prototype.transform = function() {
    return this.m_oXmp.transform()
    }
ThePortXMLProcessor.prototype.loadXMLText = function(sXml) {
    return this.m_oXmp.loadXMLText(sXml)
    }
ThePortXMLProcessor.prototype.revert = function(sXml) {
    return this.m_oXmp.revert(sXml);
    }
ThePortXMLProcessor.prototype.setNodeEventValue = function(obj,xPath) {
    return this.m_oXmp.setNodeEventValue(obj,xPath);
    }
ThePortXMLProcessor.prototype.loadXSLText = function (sXsl) {
    return this.m_oXmp.loadXSLText(sXsl);
    }
ThePortXMLProcessor.prototype.setNodeEventValue = function(obj,xPath) {
    return this.m_oXmp.setNodeEventValue(obj,xPath);
    }
ThePortXMLProcessor.prototype.setNodeValue = function(xPath,sValue) {
    return this.m_oXmp.setNodeValue(xPath,sValue);
    }
ThePortXMLProcessor.prototype.getNodeValue = function(xPath) {
    return this.m_oXmp.getNodeValue(xPath);
    }
ThePortXMLProcessor.prototype.parse = function(oDoc) {
    return this.m_oXmp.parse(oDoc);
    }
ThePortXMLProcessor.prototype.getTagValue = function(sTagName) {
    return this.m_oXmp.getTagValue(sTagName);
    }
ThePortXMLProcessor.prototype.debug = function() {
    return this.m_oXmp.debug();
    }
ThePortXMLProcessor.prototype.displayXML = function(oWin,oXml) {
    return this.m_oXmp.displayXML(oWin,oXml);
    }
ThePortXMLProcessor.prototype.Delete = function (fnCallback) {
    return this.m_oXmp.fnCallback(Delete);
    }
ThePortXMLProcessor.prototype.Save = function (fnCallback) {
    return this.m_oXmp.Save(fnCallback);
    }
ThePortXMLProcessor.prototype.Response = function (oResponse) {
    return this.m_oXmp.Response(oResponse);
    }
/*********************************/
/* End ThePortXMLProcessor Class */
/*********************************/


/**********************************/
/* Begin ThePortReplyObject Class */
/**********************************/
ThePortReplyObject = function (oXmlDoc) {
    this.m_ro = new ThePort.ReplyObject(oXmlDoc);
    this.ID	        = this.m_ro.ID;
	this.Response   = this.m_ro.Response;
	this.ReturnCode = this.m_ro.ReturnCode;
    this.Action     = this.m_ro.Action;
    this.ObjectName = this.m_ro.ObjectName;
    this.Message    = this.m_ro.Message;
    this.Data       = this.m_ro.Data;
    this.Hash       = this.m_ro.Hash;
    }
ThePortReplyObject.prototype.getProcessedXML = function() {
    return this.m_ro.getProcessedXML();
    }
ThePortReplyObject.prototype.loadReply = function(oXmlDoc) {	
    return this.m_ro.loadReply(oXmlDoc);
    this.ID	        = this.m_ro.ID;
	this.Response   = this.m_ro.Response;
	this.ReturnCode = this.m_ro.ReturnCode;
    this.Action     = this.m_ro.Action;
    this.ObjectName = this.m_ro.ObjectName;
    this.Message    = this.m_ro.Message;
    this.Data       = this.m_ro.Data;
    this.Hash       = this.m_ro.Hash;
    } 
/********************************/
/* End ThePortReplyObject Class */
/********************************/

/******************************************************/
/******************************************************/
/* END::Depricated Wrapper classes for compatibility. */
/******************************************************/
/******************************************************/
﻿﻿/*********************************************/
/* ThePort XML/JSON End Processing routines. */
/* Author: Steve Soares                      */
/* Copyright ThePort Inc.                    */
/*********************************************/


if (ThePortRegisterNS("ThePort.OnLoader")) {
    var oFunc = function() {ThePort.Initialize();}
    ThePort.Event.AddHandler(window,'load', oFunc);
}
	

