/* AUTO-GENERATED FILE - DO NOT EDIT.
@title:  tealeafOptimized.js
@date: auto-generated
@author: yoshi chen
@desc: File is auto-generated from multiple source files to
optimize tealeaf files
*/
/*                                                                  
*
* @fileoverview 
* This is the configuration for the main UI Client Event Capture JavaScript.
* It contains versioning information and the the flag thant turns 
* the JavaScript into a true SDK.  
*
* @version 2008.11.17.1
*                                                                   
*/
if(typeof TeaLeaf == "undefined"){
	var TeaLeaf = {};
	TeaLeaf.tlStartLoad = new Date();

    if(typeof TeaLeaf.Configuration == "undefined"){
	    TeaLeaf.Configuration = {
	        "tlinit" : false,
		    "tlversion" : "2008.11.17.1",
		    "tlSDK" : false
	    };
    }
}


/*                                                                  
*
* @fileoverview 
* This is the main UI Client Event Capture JavaScript file that is  
* used by other JavaScript to register their onload routines.
*
* @requires 
* TeaLeafCfg.js
*
* @version 2008.11.17.1
*                                                                   
*/

if(TeaLeaf && TeaLeaf.Configuration && TeaLeaf.Configuration.tlinit == false){
    TeaLeaf.Configuration.tlinit = true;
    if( ! Array.prototype.push ) {
	    Array.prototype.stackEnd = 0;
        /**
        * Add push if the browser does not supply
        * them with the Array object (IE6 and earlier)
        * @addon
        */
	    Array.prototype.push = function(obj) {
		    this[this.stackEnd] = obj;
		    this.stackEnd++;
	    }
    }
    if( ! Array.prototype.pop ) {
        /**
        * Add pop if the browser does not supply
        * them with the Array object (IE6 and earlier)
        * @addon
        */
	    Array.prototype.pop = function(obj) {
		    this.stackEnd--;
		    return this[this.stackEnd];
	    }
    }
     
    /**
    * Set TeaLeaf UI Client Event Capture as an SDK. 
    * The default behavior is not set as an SDK 
    * @requires 
    * TeaLeafCfg.js
    * @addon
    */
    TeaLeaf.settlSDK = function(){
        TeaLeaf.Configuration.tlSDK = true;
    }

    /**
    * Reset TeaLeaf UI Client Event Capture not to act as an SDK.
    * The default behavior is not set as an SDK 
    * @requires 
    * TeaLeafCfg.js
    * @addon
    */    
    TeaLeaf.resettlSDK = function(){
        TeaLeaf.Configuration.tlSDK = false;
    }

    /**
    * Array to store all the object that need to be loaded after the page is rendered.
    * NOTE: This will not be used if the UI Client Event Capture is used as an SDK.
    */    
    TeaLeaf.tLoadObjs = new Array();
    /**
    * This function is used for the other javascript files to register their
    * onload functions to be called
    * @param obj object that is registered from other JavaScript to be loaded
    * @param functionName object function that is registered from other JavaScript to be loaded 
    * @requires 
    * TeaLeafCfg.js
    * @addon
    */    
    TeaLeaf.addOnLoad = function(obj, functionName){    
	    if(arguments.length == 1) {	    
		    TeaLeaf.tLoadObjs.push(obj);
	    } else if(arguments.length > 1) {	
			TeaLeaf.tLoadObjs.push(obj[functionName]);
	    }
    }
    /**
    * This function is used to load UI Client Event Caputre or the
    * UI Client Event Capture SDK.
    * @requires 
    * TeaLeafCfg.js
    * @addon
    */    
	TeaLeaf.PageSetup = function() {
	    if(TeaLeaf.Configuration.tlSDK == false ){ 		
	        for(var i=0; i<TeaLeaf.tLoadObjs.length; i++){
                TeaLeaf.tLoadObjs[i]();	    
	        }
	    }
		TeaLeaf.EndLoad = new Date();
	}	

    if (document.addEventListener) {
	    document.addEventListener("DOMContentLoaded", TeaLeaf.PageSetup, null); 
    }   
    else {
	    if (typeof(document.readyState) != "undefined") {
		    if( typeof document.onreadystatechange == "function" ) {
			    TeaLeaf.ReadyStateChange = document.onreadystatechange;
		    }
		    else {
			    TeaLeaf.ReadyStateChange = null;
		    }
		    document.onreadystatechange = function() {
			    if(document.readyState == "complete") {
				    TeaLeaf.PageSetup();
			    }
			    if( TeaLeaf.ReadyStateChange ) {
				    TeaLeaf.ReadyStateChange();
			    }
		    }; 
        }
	    else {
		    if( typeof window.onload == "function" ) {
			    TeaLeaf.OnLoad = window.onload;
		    }
		    else {
			    TeaLeaf.OnLoad = null;
		    }
		    window.onload = function() {
			    TeaLeaf.PageSetup();
			    if( TeaLeaf.OnLoad ) {
				    TeaLeaf.OnLoad();
			    }
		    }; 
	    }
    }
}


/*                                                                  
*
* @fileoverview
* Configuration file for TeaLeafEvent.js
*
* @version 2008.11.17.1
*
*/

if(typeof TeaLeaf.Event == "undefined"){
	
    TeaLeaf.Event = function(type, subtype, source) {
	    this.date = new Date();
	    if( subtype ) {
		    this.EventType    = type;
		    this.EventSubType = subtype;
		    if( source ) {
			    this.EventSource = source;
		    }
		    else{
		        
		        this.EventSource ="";
		    }
	    }
	    else {
		    this.EventType    = "CUSTOM";
		    this.EventSubType = type;
	    }
    }

   if(typeof TeaLeaf.Event.Configuration == "undefined"){
        TeaLeaf.Event.Configuration = {
            "tlinit"                    : false,
            "tlqueueevents"             : true,
            "tlqueueeventstimer"        : 900001,			
            "tlqueueeventsmaxsz"        : 8191,
            "tlshowexceptions"          : false,
            "tlurl"                     : "/browse/tealeaf.do",
            "tlsecureurl"               : "/profile/tealeaf.do",
            "tlpageidcookie"            : "TLTHID",
            "tleventcount"              : 0,
            "tlpageid"                  : "",
            "tlinitflag"                : false,
            "tlbeforeunloadflag"        : false,
            "tlusetopqueue"             : false,
            "tllastdwelltime"           : "",
            "tlidoflastvisitedcontrol"  : "",
            "tleventunloadflag"         : true,
            "tleventbeforeunloadflag"   : true,
            "tlcatcherrors"             : true,
            "tlignoresendfailure"       : true,
            "tlasync"                   : true,
            "tlvisitorder"              : "",

            tlResolution:[
                {"width": 799,       "height": 599,     "type": 0,  "displayText": "small"},
                {"width": 800,       "height": 600,     "type": 1,  "displayText": "800x600"},
                {"width": 1024,      "height": 760,     "type": 2,  "displayText": "1024x760"},
                {"width": 1280,      "height": 1024,    "type": 3,  "displayText": "1280x1024"},
                {"width": 1000000,   "height": 1000000, "type": 4,  "displayText": "large"}
            ],
            
		    tlHTTPRequestHeadersSet:[
		        {"tlreqhttpheadername": "Content-Type",                     "tlsethttpheader": true,    "tlreqhttpheadervalue": "TeaLeaf.Event.tlGetContentType()"},
			    {"tlreqhttpheadername": "X-TeaLeaf",                        "tlsethttpheader": true,    "tlreqhttpheadervalue": "TeaLeaf.Event.tlGetTeaLeafXEvent()"},
			    {"tlreqhttpheadername": "X-TeaLeafType",                    "tlsethttpheader": true,    "tlreqhttpheadervalue": "TeaLeaf.Event.tlEventType()"},
			    {"tlreqhttpheadername": "X-TeaLeafSubType",                 "tlsethttpheader": true,    "tlreqhttpheadervalue": "TeaLeaf.Event.tlEventSubType()"},
			    {"tlreqhttpheadername": "X-TeaLeaf-Page-Url",               "tlsethttpheader": true,    "tlreqhttpheadervalue": "TeaLeaf.Event.tlGetUrlPath()"},
                {"tlreqhttpheadername": "X-TeaLeaf-UIEventCapture-Version", "tlsethttpheader": true,    "tlreqhttpheadervalue": "TeaLeaf.Event.tlGetJSVersion()"}
		    ],
		    
		    tlHTTPRequestHeadersEvalInit:[
			    {"tlreqhttpheadername": "X-TeaLeaf-Screen-Res",         "tlsethttpheader": true,    "tlreqhttpheadervalue": "TeaLeaf.Event.tlResolutionType(screen.width ,screen.height)"},
			    {"tlreqhttpheadername": "X-TeaLeaf-Browser-Res",        "tlsethttpheader": true,    "tlreqhttpheadervalue": "TeaLeaf.Event.tlResolutionTypeBrowser()"},
			    {"tlreqhttpheadername": "X-TeaLeaf-Page-Render",        "tlsethttpheader": true,    "tlreqhttpheadervalue": "TeaLeaf.Event.tlGetRenderTime()"},
			    {"tlreqhttpheadername": "X-TeaLeaf-Page-Objects",       "tlsethttpheader": true,    "tlreqhttpheadervalue": "TeaLeaf.Event.tlGetElementCount(\"object\")"},
			    {"tlreqhttpheadername": "X-TeaLeaf-Page-Img-Fail",      "tlsethttpheader": true,    "tlreqhttpheadervalue": "TeaLeaf.Event.tlBadImageCount()"}
		    ],
		    tlHTTPRequestHeadersEvalBeforeUnload:[
			    {"tlreqhttpheadername": "X-TeaLeaf-Page-Cui-Events",    "tlsethttpheader": true,    "tlreqhttpheadervalue": "TeaLeaf.Event.tlGetEventCount()"},
			    {"tlreqhttpheadername": "X-TeaLeaf-Page-Cui-Bytes",     "tlsethttpheader": true,    "tlreqhttpheadervalue": "TeaLeaf.Event.tlGetSendStringBytes(sendStr)"},
			    {"tlreqhttpheadername": "X-TeaLeaf-Page-Dwell",         "tlsethttpheader": true,    "tlreqhttpheadervalue": "TeaLeaf.Event.tlGetDwellTime()"},
			    {"tlreqhttpheadername": "X-TeaLeaf-Page-Last-Field",    "tlsethttpheader": true,    "tlreqhttpheadervalue": "TeaLeaf.Event.tlGetLastVisitedElementID()"},
			    {"tlreqhttpheadername": "X-TeaLeaf-Visit-Order",        "tlsethttpheader": true,    "tlreqhttpheadervalue": "TeaLeaf.Event.tlGetVisitOrder()"}
		    ]
        };
    }
}


/*
*
* @fileoverview 
* Event and communication setup.   
*
* @requires 
* TeaLeaf.js
* TeaLeafEventCfg.js
*
* @version 2008.11.17.1
*                                                                   
*/
if(TeaLeaf.Event && TeaLeaf.Event.Configuration){
	try{
	    if(typeof TeaLeaf_PageID == "undefined"){
			TeaLeaf_PageID = null;
		}
	}
	catch(e){
		TeaLeaf_PageID = null;
	}
    
    TeaLeaf.Event.tlQueuedXML = "";
    /**
    * Get TeaLeaf UI Client Event content type that 
    * is sent in the HTTP headers of the TeaLeaf AJAX POST
    * that delivers the XML with the UI Cient Events to the 
    * capture device. 
    * @addon
    */
    TeaLeaf.Event.tlGetContentType = function(){
        var contentType = "text/xml";
        return contentType;
    }
    /**
    * Get TeaLeaf UI Client Event XEvent that 
    * is sent in the HTTP headers of the TeaLeaf AJAX POST
    * that delivers the XML with the UI Cient Events to the 
    * capture device. 
    * @addon
    */
    TeaLeaf.Event.tlGetTeaLeafXEvent = function(){
        var teaLeafXEvent = "ClientEvent";
        return teaLeafXEvent;
    }
    /**
    * Get TeaLeaf UI Client Event type set during
    * TeaLeaf event definition.
    * @addon
    */    
    TeaLeaf.Event.tlEventType = function(){
        return TeaLeaf.Event.SetType;
    }
    /**
    * Get TeaLeaf UI Client Event sub type set during
    * TeaLeaf event definition.
    * @addon
    */        
    TeaLeaf.Event.tlEventSubType = function(){
        return TeaLeaf.Event.SetSubType;
    }
    /**
    * Get the path relative to the host.
    * @addon
    */            
    TeaLeaf.Event.tlGetUrlPath = function(){
        var strpath = window.location.pathname;
        return strpath;
    }
    /**
    * Get TeaLeaf UI Client Event version that 
    * is sent in the HTTP headers of the TeaLeaf AJAX POST
    * that delivers the XML with the UI Cient Events to the 
    * capture device. 
    * @requires 
    * TeaLeafEventCfg.js
    * @addon
    */
    TeaLeaf.Event.tlGetJSVersion = function(){
        return TeaLeaf.Configuration.tlversion;
    }
    /**
    * Get the resolution type (0-4) based on the resolution defined in 
    * the configuration file. 
    * @param width 
    * @param height 
    * @requires 
    * TeaLeafEventCfg.js
    * @addon
    */
    TeaLeaf.Event.tlResolutionType = function(width, height){ 
        var res = TeaLeaf.Event.Configuration.tlResolution;
        for(var i=0; i<res.length; i++)
        {
            if(width <= res[i].width || height <= res[i].height)
            {
                return res[i].type;
            }
        }
        return res[length-1].type;        
    }
    /**
    * Get the browser resolution type. 
    * @requires 
    * TeaLeafEventCfg.js
    * @addon
    */
    TeaLeaf.Event.tlResolutionTypeBrowser = function(){
        var winWidth = 0;
        var winHeight = 0;  
        if(window.innerWidth){
            winWidth = window.innerWidth;
            winHeight = window.innerHeight;
        }
        else if(document.documentElement && document.documentElement.clientWidth){   
            winWidth = document.documentElement.clientWidth;
            winHeight = document.documentElement.clientHeight;
        }
        else if(document.body && document.body.clientWidth){
            winWidth = document.body.clientWidth;
            winHeight = document.body.clientHeight;
        }
        else{
            var elems = document.getElementsByTagName("body"); 
            if(elems.length > 0){
                winWidth = elems[0].clientWidth;
                winHeight = elems[0].clientHeight;
            }
        }                
        var retType = TeaLeaf.Event.tlResolutionType(winWidth, winHeight);  
        return retType;
    }
    /**
    * Get the page render time. 
    * @requires
    * TeaLeaf.js
    * TeaLeafCfg.js 
    * TeaLeafEventCfg.js
    * @addon
    */    
    TeaLeaf.Event.tlGetRenderTime = function(){
        return TeaLeaf.Event.PageLoadMilliSecs;
    }
    /**
    * Get element count. 
    * @param element DOM element name 
    * @addon
    */        
    TeaLeaf.Event.tlGetElementCount = function(element){
        return document.getElementsByName(element).length;		   	
    }
    /**
    * Get count of broaken images. 
    * @addon
    */            
    TeaLeaf.Event.tlBadImageCount = function() {
		var	cnt = 0;
		var ind;
		for(ind = 0; ind < document.images.length; ind++) {
			var	img = document.images[ind];
			
			
			
    		if (!img.complete) {
        		cnt++;
				continue;
    		}
    		
    		
    		
    		if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
        		cnt++;
    		}
    	}
    	return cnt;
	}	
    /**
    * Get TeaLeaf current event count. 
    * @addon
    */            	
	TeaLeaf.Event.tlGetEventCount = function(){
        return TeaLeaf.Event.Configuration.tleventcount;		   	
    }
    /**
    * Get sent sting length. 
    * @param sendStr get lenght of sendStr
    * @addon
    */            	
    TeaLeaf.Event.tlGetSendStringBytes = function(sendStr){
        return sendStr.length;		   	
    }
    /**
    * Get user dwell time on a page.
    * @requires
    * TeaLeaf.js
    * TeaLeafCfg.js 
    * TeaLeafEventCfg.js 
    * @addon
    */            	
    TeaLeaf.Event.tlGetDwellTime = function(){
        return TeaLeaf.Event.tlDateDiff(TeaLeaf.tlStartLoad, TeaLeaf.Event.Configuration.tllastdwelltime);
    }
    /**
    * Get the ID of the last visited DOM element that we have listeners attached.
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	    
    TeaLeaf.Event.tlGetLastVisitedElementID = function(){
        return TeaLeaf.Event.Configuration.tlidoflastvisitedcontrol;
    }
    /**
    * Get the date difference between two values.
    * @param v1 first time value 
    * @param v2 second time value 
    * @addon
    */            	        
    TeaLeaf.Event.tlDateDiff = function(v1, v2) {
		return Math.abs(v1-v2);
	}
    /**
    * Get the XForm path string with ids or names in fill out order.
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	    	
	TeaLeaf.Event.tlGetVisitOrder= function(){
	    return TeaLeaf.Event.Configuration.tlvisitorder;
	}
    /**
    * Re-format the XML.
    * @param Str containing XML to be re-formated 
    * @addon
    */            	        
    TeaLeaf.Event.tlFormatXML = function(Str) {
        if (Str) {
			if( Str.replace ) {
            	return Str.replace(/&/g, "&amp;").replace(/\"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
			}
			return Str;
		}
        return "";
    }
    /**
    * Get cookie value.
    * @param name cookie name 
    * @addon
    */            	            
    TeaLeaf.Event.tlGetCookie = 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 "";
		    }
	    }
	    else {
		    begin += 2;
	    }
	    var end = document.cookie.indexOf(";", begin);
	    if (end == -1) {
		    end = dc.length;
	    }
	    return unescape(dc.substring(begin + prefix.length, end));
    }  
    /**
    * Set HTTP headers.
    * @param tlreq XMLHTTPRequest object 
    * @param tlheaderconfig JSON array with the HTTP header field values. 
    * @requires
    * TeaLeaf.js
    * TeaLeafCfg.js 
    * TeaLeafEventCfg.js 
    * @addon
    */            	
    TeaLeaf.Event.tlSetHTTPHeaders = function(tlreq, tlheaderconfig){    
        for(var i=0; i<tlheaderconfig.length; i++) {
		    if(tlheaderconfig[i].tlsethttpheader == true){
			    tlreq.setRequestHeader(tlheaderconfig[i].tlreqhttpheadername, eval(tlheaderconfig[i].tlreqhttpheadervalue));
			}
        }
    }
    /**
    * Get TeaLeaf page id.
    * @requires
    * TeaLeaf.js
    * TeaLeafCfg.js 
    * TeaLeafEventCfg.js 
    * @addon
    */            	    
    TeaLeaf.Event.tlGetPageId = function(){
	    
	    if(TeaLeaf.Event.Configuration.tlpageid) {
		    return TeaLeaf.Event.Configuration.tlpageid;
	    }
	    
	    
	    
	    if( TeaLeaf.Event.Configuration.tlpageidcookie ) {
		    TeaLeaf.Event.Configuration.tlpageid = TeaLeaf.Event.tlGetCookie(TeaLeaf.Event.Configuration.tlpageidcookie);
		    if(TeaLeaf.Event.Configuration.tlpageid) {
			    return TeaLeaf.Event.Configuration.tlpageid;
		    }
	    }
	    
	    
	    if( TeaLeaf_PageID ) {
			TeaLeaf.Event.Configuration.tlpageid = TeaLeaf_PageID;
			return TeaLeaf.Event.Configuration.tlpageid;
	    }
    
	    
	    
	    TeaLeaf.Event.Configuration.tlpageid = "ID" + TeaLeaf.tlStartLoad.getHours() + "H" +
		    			TeaLeaf.tlStartLoad.getMinutes() + "M" +
			    		TeaLeaf.tlStartLoad.getSeconds() + "S" +
				    	TeaLeaf.tlStartLoad.getMilliseconds();
	    return TeaLeaf.Event.Configuration.tlpageid;
    }
    /**
    * Send failure message.
    * @param url url 
    * @param failedUrl url where failure occured 
    * @param message failure message 
    * @requires
    * TeaLeaf.js
    * TeaLeafCfg.js 
    * TeaLeafEventCfg.js 
    * @addon
    */            	    
    TeaLeaf.Event.tlSendFailure = function(url, failedUrl, message){
	    var tlnow = new Date();
	    var	t1970 = Date.UTC(tlnow.getUTCFullYear(),tlnow.getUTCMonth(),tlnow.getUTCDate(), tlnow.getUTCHours(),tlnow.getUTCMinutes(),tlnow.getUTCSeconds(), tlnow.getUTCMilliseconds());
    
	    var tltimeDur;
	    if( TeaLeaf.tlStartLoad ) {
		    tltimeDur = TeaLeaf.Event.tlDateDiff(tlnow, TeaLeaf.tlStartLoad);
	    }

	    TeaLeaf.Event.Configuration.tleventcount++;
	    tlsendStr = "<ClientEvent count=\"" + TeaLeaf.Event.Configuration.tleventcount +
	    		  "\" Type=\"INFO\" SubType=\"EXCEPTION\" " +
		    	  "PageId=\""        + TeaLeaf.Event.tlGetPageId()+ "\" " +
			      "FailedUrl=\""     + TeaLeaf.Event.tlFormatXML(failedUrl) + "\" " +
			      "Message=\""       + TeaLeaf.Event.tlFormatXML(message)   + "\" " +
			      "TimeDuration=\""  + tltimeDur + "\" " +
			      "DateSince1970=\"" + t1970 + "\" />\r\n";

	    
	    try {
	        TeaLeaf.Event.Configuration.tlasync = true;
	        var tlExceptionEvent = new TeaLeaf.Event("INFO", "EXCEPTION");
		    tlExceptionEvent.tlSendXML(tlsendStr,true);
	    }   
	    catch(exc) {
	        if( TeaLeaf.Event.Configuration.tlshowexceptions ) {
			    alert(exc.name + ": " + exc.message + "\r\n\r\nPos 4");
			}
	    }
    }   
    /**
    * Create the XMLHTTPRequest transport object.
    * @addon
    */            	                      
    TeaLeaf.Event.tlGetTransport = function(){
	    var	tlreq;
	    if(window.XMLHttpRequest) {
		    try {
			    tlreq = new XMLHttpRequest();
		    }
		    catch(e) {
			    tlreq = null;
		    }
	    }
	    else if(window.ActiveXObject) {
		    try {
			    tlreq = new ActiveXObject("Msxml2.XMLHTTP");
		    }
		    catch(e) {
			    try {
			    	tlreq = new ActiveXObject("Microsoft.XMLHTTP");
			    }
			    catch(e) {
				    tlreq = null;
			    }
		    }
	    }
	    return tlreq;
    }

    TeaLeaf.Event.TransportArray = new Array();
    
    /**
    * Get the XMLHTTPRequest transport object from the Transport Array if not create one.
    * @addon
    */            	                      
    TeaLeaf.Event.tlXMLHTTPObj = function(){   
 	    var i = 0;
	    for(; i < TeaLeaf.Event.TransportArray.length; i++) {
    		if( TeaLeaf.Event.TransportArray[i] && TeaLeaf.Event.TransportArray[i].readyState > 0 ) {
			    if( TeaLeaf.Event.TransportArray[i].readyState == 4 ) {
    				TeaLeaf.Event.TransportArray[i].abort();
    				TeaLeaf.Event.TransportArray[i].onreadystatechange = new function() {};
				    return TeaLeaf.Event.TransportArray[i];
			    }
		    }
		    else {
    			TeaLeaf.Event.TransportArray[i] = TeaLeaf.Event.tlGetTransport();
    			return TeaLeaf.Event.TransportArray[i];
		    }
	    }
	    
    	TeaLeaf.Event.TransportArray[i] = TeaLeaf.Event.tlGetTransport();
    	return TeaLeaf.Event.TransportArray[i];
    }  
    /**
    * Clean the XMLHTTPRequest Transport Array.
    * @addon
    */            	                          
    TeaLeaf.Event.tlCleanXMLHTTPObj = function(obj){
	    
	    var i = 0;
	    for(; i < TeaLeaf.Event.TransportArray.length; i++) {
		    if( obj == TeaLeaf.Event.TransportArray[i] ) {
    			TeaLeaf.Event.TransportArray[i] = null;
		    }
	    }   
    }
    /**
    * Add event handler.
    * @param tlitem element that we attach a listener
    * @param tlevt event that we listen for
    * @param tlhandler event handler
    * @addon
    */            	                              
    TeaLeaf.Event.tlAddHandler = function(tlitem, tlevt, tlhandler, tlcapture) {		
		try {
			    if( tlitem.addEventListener ) {
					if(navigator.userAgent.toLowerCase().indexOf('safari')!=-1){
						    tlitem.addEventListener('on'+tlevt, tlhandler, tlcapture);                                          
					}
					else{
						    tlitem.addEventListener(tlevt, tlhandler, tlcapture);
					}
			    }
			    else if( tlitem.attachEvent ) {
					tlitem.attachEvent('on'+tlevt, tlhandler);
			    }
		}
		catch(exc) {
			    if( TeaLeaf.Event.Configuration.tlshowexceptions ) {
					alert(exc.name + ": " + exc.message + "\r\n\r\nPos 4");
			    }
		}
	}	
    /**
    * Remove event handler.
    * @param tlitem element that we attached a listener
    * @param tlevt event that we listened
    * @param tlhandler event handler
    * @addon
    */            	                              
	TeaLeaf.Event.tlRemoveHandler = function(tlitem, tlevt, tlhandler, tlcapture) {
		try {
			if( tlitem.removeEventListener ) {
				tlitem.removeEventListener(tlevt, tlhandler, tlcapture);
			}
			else if( tlitem.detachEvent ) {
				tlitem.detachEvent('on'+tlevt, tlhandler);
			}
		}
		catch(exc) {
			if( TeaLeaf.Event.Configuration.tlshowexceptions ) {
				alert(exc.name + ": " + exc.message + "\r\n\r\nPos 5");
			}
		}
	}
    /**
    * Flush the event queue.
    * @param force forces the flush if true
    * @requires
    * TeaLeaf.js
    * TeaLeafCfg.js 
    * TeaLeafEventCfg.js 
    * @addon
    */            	                              
	TeaLeaf.Event.tlFlushQueue = function(force) {
		var	dataToSend = null;
		var	queueTime = TeaLeaf.Event.Configuration.tlqueueeventstimer;
		var maxTime = queueTime * 3;
		
		if(TeaLeaf.Event.Configuration.tlusetopqueue) {
			var now = new Date();
			var diff = (now - top.TeaLeaf.Event.TimeSent);		
			
			if( top.TeaLeaf.Event.tlQueuedXML ) {
				if( force || diff >= queueTime ) {
					dataToSend = top.TeaLeaf.Event.tlQueuedXML;
					top.TeaLeaf.Event.tlQueuedXML = "";
					top.TeaLeaf.Event.TimeSent = now;
				}
			}
			
			if( ! dataToSend ) {
				if( ! force && diff < (queueTime / 2) ) {
					
					
					
					
					
					
					if(queueTime >= maxTime){
					    queueTime = maxTime;
					}
					else{
					    queueTime = (queueTime * 3) / 2;
					}
				}
				return queueTime;
			}
		}
		else {
			if( ! TeaLeaf.Event.tlQueuedXML ) {
				return queueTime;
			}
			dataToSend = TeaLeaf.Event.tlQueuedXML;
			TeaLeaf.Event.tlQueuedXML = "";
		}
		
		
		var evt = new TeaLeaf.Event("GUI", "QUEUED");
		evt.tlSendXML(dataToSend);
		return queueTime;

    }
    /**
    * Push XML on the stack.
    * @param tag tag name
    * @addon
    */            	                              
    TeaLeaf.Event.prototype.tlPushXML = function(tag){
	    if( ! this.XMLStack ) {
		    this.XMLStack = new Array();
    	}
	    
	    var strTag = "  <" + tag;
	    if(this.XMLData){
	        this.XMLData += strTag;
	    }
	    else{
	        this.XMLData = strTag;
	    }
    }    
    /**
    * Pop XML from the stack.
    * @param tag tag name
    * @addon
    */            	                              
    TeaLeaf.Event.prototype.tlPopXML = function(){
        if(this.XMLData){
	        this.XMLData += " />\r\n";
	    }
	    else{
            return false;
	    }
    }   
    /**
    * Add data tot he XML stack.
    * @param name0 name of the XML attribute.
    * @param value0 value of the XML attribute.
    * @addon
    */            	                              
    TeaLeaf.Event.prototype.tlAddData = function(nameValueArray){
	    var offset = "";
	    if( this.XMLStack ) {
		    for(var ind = 0; ind < this.XMLStack.length; ind++) {
			    offset += "  ";
		    }		    
	    }	    

		var parts = [];
	    for(var ind = 0; ind < nameValueArray.length; ind += 2) {
			name = nameValueArray[ind];
			tlValue = TeaLeaf.Event.tlFormatXML(nameValueArray[ind+1]);
			if(name && tlValue)	
				parts[parts.length] = offset + " " + name + "=" + "\""+tlValue+"\"";
		}

		if(!this.XMLData) this.XMLData = "";
		this.XMLData += parts.join("");

	    delete nameValueArray;
    }   
    /**
    * Send the XML with the UI Client Events including the HTTP headers if set.
    * @param tlsendStr XML message
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	                              
    TeaLeaf.Event.prototype.tlSendXML = function(tlsendStr, tlignoresendfailure ){
	    
	    var tlreq = TeaLeaf.Event.tlXMLHTTPObj();
	    if( ! tlreq ) {
		    return;
	    }
	    
	    try {
		    var	tlurl = this.theUrl;
		    tlreq.onreadystatechange = function(code) {
			    if(tlreq.readyState == 2 && typeof TeaLeaf.Cookie != "undefined")
			    {
				
				
				var d = new Date();
				d.setTime(d.getTime()-86400000);
				TeaLeaf.Cookie.tlSetCookieValue("tlQueuedXML", "", d, "/");
			    }

			    if( tlreq.readyState == 4 ) {
				    
				    
				    
				    try {
					    if( tlreq.status != 200 && tlreq.status != 304 ) {

		                if(TeaLeaf.Event.Configuration.tlignoresendfailure == true){
					        TeaLeaf.Event.Configuration.tlignoresendfailure = false;
           				    TeaLeaf.Event.tlSendFailure(tlurl, tlurl, "Status " + tlreq.status + ": " + tlreq.statusText);
						    }
					    }
			    	}
				    catch(e) {
				    }
			    }
		    }
		    tlreq.open("POST", tlurl, TeaLeaf.Event.Configuration.tlasync);
		    
			TeaLeaf.Event.tlSetHTTPHeaders(tlreq, TeaLeaf.Event.Configuration.tlHTTPRequestHeadersSet);

            
            if( TeaLeaf.Event.Configuration.tlinitflag == true ){           
                TeaLeaf.Event.tlSetHTTPHeaders(tlreq, TeaLeaf.Event.Configuration.tlHTTPRequestHeadersEvalInit);
            }
            if( TeaLeaf.Event.Configuration.tlbeforeunloadflag == true ){
                TeaLeaf.Event.tlSetHTTPHeaders(tlreq, TeaLeaf.Event.Configuration.tlHTTPRequestHeadersEvalBeforeUnload);
            }  
    	    tlreq.send(tlsendStr);
    	}
	    catch(exc) {
		    if( TeaLeaf.Event.Configuration.tlshowexceptions ) {
			    if( exc.name ) {
				    alert(exc.name + ": " + exc.message + "\r\n\r\nURL: " + this.theUrl + "\r\n\r\nPos 3 ");
			    }
			    else {
				    alert(exc + "\r\n\r\nURL: " + this.theUrl + "\r\n\r\nPos 3 ");
			    }
		    }	    
		    if(TeaLeaf.Event.Configuration.tlignoresendfailure == true){
                TeaLeaf.Event.Configuration.tlignoresendfailure = false;
		        TeaLeaf.Event.tlSendFailure(this.theUrl, this.theUrl, exc);
		    }  
		 TeaLeaf.Event.tlCleanXMLHTTPObj(tlreq);
	    }
    }
    /**
    * Depending on the configuration settings send the XML or queue the XML message.
    * @requires
    * TeaLeaf.js
    * TeaLeafCfg.js
    * TeaLeafEventCfg.js 
    * @addon
    */            	                                  
    TeaLeaf.Event.prototype.tlSend = function(bRoot){
	    
	    if( this.XMLStack ) {
		    while( this.XMLStack.length > 0 ) {
			    this.tlPopXML()
		    }
	    }
	    var	t1970 = Date.UTC(this.date.getUTCFullYear(),this.date.getUTCMonth(),this.date.getUTCDate(), 
	                    this.date.getUTCHours(),this.date.getUTCMinutes(),this.date.getUTCSeconds(), this.date.getUTCMilliseconds());
	    var timeDur;
	    if( TeaLeaf.tlStartLoad ) {
		    timeDur = TeaLeaf.Event.tlDateDiff(this.date, TeaLeaf.tlStartLoad);
	    }

	    TeaLeaf.Event.Configuration.tleventcount++;
	    sendStr = "<ClientEvent count=\"" + TeaLeaf.Event.Configuration.tleventcount +
			  "\" Type=\"" + this.EventType + "\" SubType=\"" + this.EventSubType+"\"";
	    if( this.EventSource ) {
		    sendStr = sendStr + "\" Source=\"" + this.EventSource+ "\"";
	    }
	    if(bRoot){
	        sendStr = sendStr + 
		    	    " PageId=\""        + TeaLeaf.Event.tlGetPageId() +"\""+
			        " TimeDuration=\""  + timeDur + "\""+
			        " DateSince1970=\"" + t1970 +
			        "\" >\r\n" +
			        this.XMLData +
			        "</ClientEvent>\r\n";
	    }
	    else{
	        sendStr = sendStr + 
		    	    " PageId=\""        + TeaLeaf.Event.tlGetPageId() +"\""+
			        this.XMLData        +
			        " TimeDuration=\""  + timeDur + "\""+
			        " DateSince1970=\"" + t1970 +
			        "\" />\r\n";
	    }
	    
	    if( TeaLeaf.Event.Configuration.tlqueueevents ) {
			if( TeaLeaf.Event.Configuration.tlusetopqueue ) {
				if( top.TeaLeaf.Event.tlQueuedXML ) {
					top.TeaLeaf.Event.tlQueuedXML += sendStr;
				}
				else {
					top.TeaLeaf.Event.tlQueuedXML = sendStr;
				}
			}
			else {
				if( TeaLeaf.Event.tlQueuedXML ) {
					TeaLeaf.Event.tlQueuedXML += sendStr;	
				}
				else {
					TeaLeaf.Event.tlQueuedXML = sendStr;
				}
			}
			
			
			if( TeaLeaf.Event.Configuration.tlqueueeventsmaxsz < TeaLeaf.Event.tlQueuedXML.length ) {	    	
	    		TeaLeaf.Event.tlFlushQueue();
			}
			return;
	    }
	    
	    try {
		    this.tlSendXML(sendStr);
		    this.XMLData = "";
	    }
    	catch(exp) {
	    }
	    this.XMLData = "";
    }

    /**
    * Encode a string to be suitable for an XML attribute.
    * @param str
    * @addon
    */            	                              
    TeaLeaf.Event.tlXMLEncode = function(str){
	    if(str == null) return str;
	    str = str.replace(/&/g, "&#38;");
	    str = str.replace(/"/g, "&#34;");
	    str = str.replace(/'/g, "&#39;");
	    str = str.replace(/:/g, "&#58;");
	    return str;
    }   

    /**
    * Decode a string encoded with tlXMLEncode.
    * @param str
    * @addon
    */            	                              
    TeaLeaf.Event.tlXMLDecode = function(str){
	    if(str == null) return str;
	    str = str.replace(/&#58;/g, ":");
	    str = str.replace(/&#39;/g, "'");
	    str = str.replace(/&#34;/g, "\"");
	    str = str.replace(/&#38;/g, "&");
	    return str;
    }

    /**
    * Enable HTTP Headers defined in the TeaLeafEventCfg.js.
    * @param obj determines what set of HTTP headers to be set. 
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	                                   
    TeaLeaf.Event.tlEnableAllHTTPHeaders = function(obj) {         
        if(obj){
            if(obj == "info"){
                TeaLeaf.Event.tlEventJSONCfgUtil(TeaLeaf.Event.Configuration.tlHTTPRequestHeadersSet, true, "all");            
            }
            else if(obj == "init"){
                TeaLeaf.Event.tlEventJSONCfgUtil(TeaLeaf.Event.Configuration.tlHTTPRequestHeadersEvalInit, true, "all");
            }
            else if(obj == "beforeunload"){
                TeaLeaf.Event.tlEventJSONCfgUtil(TeaLeaf.Event.Configuration.tlHTTPRequestHeadersEvalBeforeUnload, true, "all");
            } 
        } 
        else{
            TeaLeaf.Event.tlEventJSONCfgUtil(TeaLeaf.Event.Configuration.tlHTTPRequestHeadersSet, true, "all");            
            TeaLeaf.Event.tlEventJSONCfgUtil(TeaLeaf.Event.Configuration.tlHTTPRequestHeadersEvalInit, true, "all");
            TeaLeaf.Event.tlEventJSONCfgUtil(TeaLeaf.Event.Configuration.tlHTTPRequestHeadersEvalBeforeUnload, true, "all");        
        }        
    }
    /**
    * Enable HTTP Headers defined in the TeaLeafEventCfg.js.
    * @param obj determines what set of HTTP headers to be set. 
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	                                   
    TeaLeaf.Event.tlEnableHTTPHeader = function(obj, headerName) { 
        if(obj == "info"){
            TeaLeaf.Event.tlEventJSONCfgUtil(TeaLeaf.Event.Configuration.tlHTTPRequestHeadersSet, true, headerName);            
        }
        else if(obj == "init"){
            TeaLeaf.Event.tlEventJSONCfgUtil(TeaLeaf.Event.Configuration.tlHTTPRequestHeadersEvalInit, true, headerName);
        }
        else if(obj == "beforeunload"){
            TeaLeaf.Event.tlEventJSONCfgUtil(TeaLeaf.Event.Configuration.tlHTTPRequestHeadersEvalBeforeUnload, true, headerName);
        } 
    }
    /**
    * Disable HTTP Headers defined in the TeaLeafEventCfg.js.
    * @param obj determines what set of HTTP headers to be set. 
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	                                   
    TeaLeaf.Event.tlDisableAllHTTPHeaders = function(obj) {         
        if(obj){
            if(obj == "info"){
                TeaLeaf.Event.tlEventJSONCfgUtil(TeaLeaf.Event.Configuration.tlHTTPRequestHeadersSet, false, "all");            
            }
            else if(obj == "init"){
                TeaLeaf.Event.tlEventJSONCfgUtil(TeaLeaf.Event.Configuration.tlHTTPRequestHeadersEvalInit, false, "all");
            }
            else if(obj == "beforeunload"){
                TeaLeaf.Event.tlEventJSONCfgUtil(TeaLeaf.Event.Configuration.tlHTTPRequestHeadersEvalBeforeUnload, false, "all");
            } 
        } 
        else{
            TeaLeaf.Event.tlEventJSONCfgUtil(TeaLeaf.Event.Configuration.tlHTTPRequestHeadersSet, false, "all");            
            TeaLeaf.Event.tlEventJSONCfgUtil(TeaLeaf.Event.Configuration.tlHTTPRequestHeadersEvalInit, false, "all");
            TeaLeaf.Event.tlEventJSONCfgUtil(TeaLeaf.Event.Configuration.tlHTTPRequestHeadersEvalBeforeUnload, false, "all");        
        }        
    }    
    /**
    * Enable queuing of events.
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	                                   
    TeaLeaf.Event.tlEnableQueueEvents = function() { 
        TeaLeaf.Event.Configuration.tlqueueevents = true; 
    }  
    /**
    * Disable queuing of events.
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	                                   
    TeaLeaf.Event.tlDisableQueueEvents = function() { 
        TeaLeaf.Event.Configuration.tlqueueevents = false; 
    }   
    /**
    * Enable showing of exception in an alert message.
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	                                   
    TeaLeaf.Event.tlEnableShowExceptions = function() { 
        TeaLeaf.Event.Configuration.tlshowexceptions = true; 
    }
    /**
    * Disable showing of exception in an alert message.
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	                                       
    TeaLeaf.Event.tlDisableShowExceptions = function() { 
        TeaLeaf.Event.Configuration.tlshowexceptions = false; 
    } 
    /**
    * Set queue event flush time.
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	                                       
    TeaLeaf.Event.tlSetQueueEventTime = function(tlvalue) { 
    
        TeaLeaf.Event.Configuration.tlqueueeventstimer = tlvalue; 
    }  
    /**
    * Get queue event flush time.
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	                                       
    TeaLeaf.Event.tlGetQueueEventTime = function() { 
        return TeaLeaf.Event.Configuration.tlqueueeventstimer; 
    }
    /**
    * Set queue event maximum size.
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	                                       
    TeaLeaf.Event.tlSetQueueEventMaxSize = function(tlvalue) { 
        TeaLeaf.Event.Configuration.tlqueueeventsmaxsz = tlvalue; 
    }    
    /**
    * Get queue event maximum size.
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	                                       
    TeaLeaf.Event.tlGetQueueEventMaxSize = function() { 
        return TeaLeaf.Event.Configuration.tlqueueeventsmaxsz; 
    } 
    /**
    * Set the url where TeaLeaf posts.
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	                                       
    TeaLeaf.Event.tlSetPostURL = function(tlvalue) { 
        TeaLeaf.Event.Configuration.tlurl = tlvalue; 
    }
    /**
    * Get the url where TeaLeaf posts.
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	                                       
    TeaLeaf.Event.tlGetPostURL = function() { 
        return TeaLeaf.Event.Configuration.tlurl; 
    }  
    /**
    * Set page id cookie value.
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	                                       
    TeaLeaf.Event.tlSetPageIDCookie = function(tlvalue) { 
        TeaLeaf.Event.Configuration.tlpageidcookie = tlvalue; 
    }
    /**
    * Get page id cookie value.
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	                                       
    TeaLeaf.Event.tlGetPageIDCookie = function(tlvalue) { 
        return TeaLeaf.Event.Configuration.tlpageidcookie; 
    }   
    /**
    * JSON configuration utility allowing to enable/disable certain DOM events
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	                                       
    TeaLeaf.Event.tlEventJSONCfgUtil = function(tlJSONConfig, tlEnable, domEventName) {         
        for(var i = 0; i<tlJSONConfig.length; i++){
            if(domEventName == "all"){
                tlJSONConfig[i].load = tlEnable;
            }
            else if (domEventName == tlJSONConfig[i].domevent){
                tlJSONConfig[i].load = tlEnable;
            }
        }  
    }  
    /**
    * Error handler.
    * @param message error 
    * @param url url
    * @param line line where error occured
    * @requires   
    * TeaLeafEventCfg.js 
    * @addon
    */            	                                       
	TeaLeaf.Event.tlErrorHandler = function(message, url, line) {	
		var	now = new Date();
		if( ! line ) {
			line = "unknown";
		}
		var	tlevt = new TeaLeaf.Event("INFO", "EXCEPTION");
		var tlAddNameValueArray = new Array("Message", message, 
			                                "URL", escape(url), 
			                                "Line", line);
        tlevt.tlAddData(tlAddNameValueArray);
        TeaLeaf.Event.Configuration.tlasync = true;
		tlevt.tlSend();
		TeaLeaf.Event.tlFlushQueue();
		return false;
	}	
	/**
    * Handle the before unload event and flush the queue of events.
    *
    * @requires 
    * TeaLeafEventCfg.js
    * @addon
    */            	                                                                			
	TeaLeaf.Event.tlBeforeUnload = function(){
	    if(TeaLeaf.Event.Configuration.tleventbeforeunloadflag == true){ 
            TeaLeaf.Event.Configuration.tleventunloadflag = false;   
		    
		    var	tlevt = new TeaLeaf.Event("PERFORMANCE", "BeforeUnload");	
		    TeaLeaf.Event.SetType = tlevt.EventType;

		    if(TeaLeaf.Event.SetSubType == ""){
                TeaLeaf.Event.SetSubType = tlevt.EventSubType;
            }
            else{
                TeaLeaf.Event.SetSubType += "; " + tlevt.EventSubType;
            }                    
            TeaLeaf.Event.Configuration.tlbeforeunloadflag = true;
            TeaLeaf.Event.Configuration.tlignoresendfailure = true;
 	        TeaLeaf.Event.Configuration.tlasync = false;
 		    tlevt.tlSend();  
		    TeaLeaf.Event.tlFlushQueue(true);
		}	
        TeaLeaf.Event.tlRemoveHandler(window, "beforeunload", eval(TeaLeaf.Event.tlBeforeUnload), false);
        TeaLeaf.Event.tlRemoveHandler(window, "unload", eval(TeaLeaf.Event.tlUnload), false);
	}
	/**
    * Handle the unload event and flush the queue of events.
    *
    * @requires 
    * TeaLeafEventCfg.js
    * @addon
    */            	                                                                				
	TeaLeaf.Event.tlUnload = function(){
        if(TeaLeaf.Event.Configuration.tleventunloadflag ){         
            TeaLeaf.Event.Configuration.tllastdwelltime = new Date();
            TeaLeaf.Event.Configuration.tleventbeforeunloadflag = false;

		    
		    var	tlevt = new TeaLeaf.Event("PERFORMANCE", "Unload");
		    TeaLeaf.Event.SetType = tlevt.EventType;
		    
		    if(TeaLeaf.Event.SetSubType == ""){
                TeaLeaf.Event.SetSubType = tlevt.EventSubType;
            }
            else{
                TeaLeaf.Event.SetSubType += "; " + tlevt.EventSubType;
            }
            TeaLeaf.Event.Configuration.tlignoresendfailure = true;
            TeaLeaf.Event.Configuration.tlasync = false;
		    tlevt.tlSend();
		    TeaLeaf.Event.tlFlushQueue(true);
        }  
        TeaLeaf.Event.tlRemoveHandler(window, "beforeunload", eval(TeaLeaf.Event.tlBeforeUnload), false);
        TeaLeaf.Event.tlRemoveHandler(window, "unload", eval(TeaLeaf.Event.tlUnload), false);
	}
	
    /**
    * Event setup.
    * @requires
    * TeaLeafEventCfg.js 
    * @addon
    */            	                                       
	TeaLeaf.Event.EventSetup = function() {
        
        if(TeaLeaf.Event.Configuration.tlcatcherrors){
            TeaLeaf.Event.tlAddHandler(window, "error", TeaLeaf.Event.tlErrorHandler, false);                
        }
        if(!TeaLeaf.Client){
            TeaLeaf.Event.tlAddHandler(window, "beforeunload", eval(TeaLeaf.Event.tlBeforeUnload), false);
            TeaLeaf.Event.tlAddHandler(window, "unload", eval(TeaLeaf.Event.tlUnload), false);
        }
		
		if( TeaLeaf.Event.Configuration.tlqueueevents ) {
			TeaLeaf.Event.tlTimerRoutine = function() {
				
				var	timeAmount = TeaLeaf.Event.Configuration.tlqueueeventstimer;
				try {
					timeAmount = TeaLeaf.Event.tlFlushQueue();
				}
				catch(exc) {
					if( TeaLeaf.Event.Configuration.tlshowexceptions ) {
						alert(exc.name + ": " + exc.message + "\r\n\r\nPos 7");
					}
				}
				
				
				setTimeout('TeaLeaf.Event.tlTimerRoutine()', timeAmount);
			}
			setTimeout('TeaLeaf.Event.tlTimerRoutine()', TeaLeaf.Event.Configuration.tlqueueeventstimer);
		}
    	TeaLeaf.Event.Loaded = true;
	}
	
	var	tmpUrl;
	if( window.location.protocol == "http:" ) {
    	tmpUrl = TeaLeaf.Event.Configuration.tlurl;
	}
	else {
    	tmpUrl = TeaLeaf.Event.Configuration.tlsecureurl;
	}

	
	if( tmpUrl.substr(0, 1) == "/" ) {
    TeaLeaf.Event.prototype.theUrl = window.location.protocol + "//" + window.location.host + tmpUrl;
	}
	else {
    	TeaLeaf.Event.prototype.theUrl = window.location.href.substr(0, window.location.href.lastIndexOf("/")+1) + tmpUrl;
	}
	
	if(TeaLeaf.Event.Configuration.tlinit == false){
	    TeaLeaf.Event.Configuration.tlinit = true;
        TeaLeaf.Event.prototype.XMLData = "";  
        TeaLeaf.addOnLoad(TeaLeaf.Event.EventSetup); 
    }
}

/*                                                                  
*
* @fileoverview 
* This is the configuration file for capturing Client Events that 
* happen on the rendered DOM. It proviedes the capabilty to block fields
* and turn off an on events on the Window and Document object. 
*
* @version 2008.11.17.1
*                                                                   
*/
if(typeof TeaLeaf.Client == "undefined"){
    TeaLeaf.Client = {};

    if(typeof TeaLeaf.Client.Configuration == "undefined"){
	    TeaLeaf.Client.Configuration = {
	        "tlinit" : false,
		    "tlpassword"         : 1,		
		    "tlsendfocus"        : false,
		    "tlsendblur"         : true,
		    "tlunloadflag"       : true,
		    "tlactiontype"       : "No Submit",
		    "tlbeforeunloadflag" : true,
		    "tlcontrolsattached" : false,
		    "tlassignTLID"       : false,   
		    "tlscanupdate"       : 0,

		    
		    
		    
		    tlScheduledScan : true,

		    
		    
		    
		    tlExcludeTags : true,

		    
		    
		    
		    
		    tlUniversalAttach : false,

		    
		    
		    
		    tlStoreQueueInCookie : false,

		    
		    
		    
		    
		    
		    
		    
		    tlFieldBlock:[
			    {"tlfieldname": "TLCREDITCARD",   "caseinsensitive": true, "eventvaluereplace": "",  "eventnovalue": true},
			    {"tlfieldname": "tlpassword",     "caseinsensitive": true, "eventvaluereplace": "",  "eventnovalue": true},
			    {"tlfieldname": "tlpwd",          "caseinsensitive": true, "eventvaluereplace": "",  "eventnovalue": true},
			    {"tlfieldname": "tlqty",          "caseinsensitive": true, "eventvaluereplace": "333",  "eventnovalue": false}
		    ],
	
		    tlFieldBlockMap : null,
		
		    
		    tlWindowHandlers:[
			    {"domevent": "resize",          "load": false,  "tlhandler": "TeaLeaf.Client.tlQueueResize"},
			    {"domevent": "focus",           "load": true,  "tlhandler": "TeaLeaf.Client.tlSetFocusTime"},
			    {"domevent": "help",            "load": true,  "tlhandler": "TeaLeaf.Client.tlAddEvent"},
			    {"domevent": "scroll",          "load": false,  "tlhandler": "TeaLeaf.Client.tlQueueScroll"},
			    {"domevent": "beforeprint",     "load": false,  "tlhandler": "TeaLeaf.Client.tlAddEvent"},
			    {"domevent": "afterprint",      "load": false,  "tlhandler": "TeaLeaf.Client.tlAddEvent"}
		    ],

		    
		    tlDocumentHandlers:[
			    {"domevent": "click",        "load": true,     "tlhandler": "TeaLeaf.Client.tlAddEvent"},
			    {"domevent": "dblclick",     "load": true,     "tlhandler": "TeaLeaf.Client.tlAddEvent"},
			    {"domevent": "keyup",        "load": true,     "tlhandler": "TeaLeaf.Client.tlQueueKey"},
			    {"domevent": "mousedown",    "load": false,     "tlhandler": "TeaLeaf.Client.tlAddEvent"},
			    {"domevent": "mouseup",      "load": false,     "tlhandler": "TeaLeaf.Client.tlAddEvent"},
			    {"domevent": "mouseover",    "load": false,     "tlhandler": "TeaLeaf.Client.tlAddEvent"},
			    {"domevent": "mouseout",      "load": false,     "tlhandler": "TeaLeaf.Client.tlAddEvent"},
			    
			    
			    {"domevent": "mousemove",    "load": false,     "tlhandler": "TeaLeaf.Client.tlUserMovement"}
		    ],
		    
		    tlSingleAttach:[
			    {"domelementID": "",    "domevent": "mousedown",    "tlhandler": "TeaLeaf.Client.tlAddEvent"},
			    {"domelementID": "",    "domevent": "mouseup",      "tlhandler": "TeaLeaf.Client.tlAddEvent"},
			    {"domelementID": "",    "domevent": "mouseover",    "tlhandler": "TeaLeaf.Client.tlAddEvent"},
			    {"domelementID": "",    "domevent": "mouseout",     "tlhandler": "TeaLeaf.Client.tlAddEvent"}
		    ],

		    /*  tlNodeTags by default includes a list of tag names that are "unimportant"
		     *  or not rendered. The associated true/false value is used in conjunction with
		     *  tlExcludeTags - e.g. if tlExcludeTags is true and a node tag is true, it will
		     *  be excluded; if tlExcludeTags is true and a node tag is false, the tag will be
		     *  included. Similarly if tlExcludeTags is false (meaning to explicitly include the
		     *  listed node tags, those with "true" with be excluded.
		     */
		    tlNodeTags : {
		        "APPLET"    : true,
		        "ATTRIBUTE" : true,
			"B"	    : true,
		        "BASE"      : true,
			"BODY"	    : true,
		        "BR"        : true,
		        "CENTER"    : true,
		        "COL"       : true,
		        "COLGROUP"  : true,
		        "COMMENT"   : true,
			"DIV"	    : true,
		        "DEFAULT"   : true,
		        "DEL"       : true,
		        "EVENT"     : true,
		        "FONT"      : true,
			"FORM"	    : true,
			"HEAD"	    : true,
		        "HISTORY"   : true,
		        "HR"        : true,
		        "HTML"      : true,
		        "I"         : true,
		        "INS"       : true,
		        "LINK"      : true,
		        "MAP"       : true,
		        "META"      : true,
		        "NAMESPACE" : true,
		        "NAVIGGATOR" : true,
		        "NOBR"      : true,
		        "OPTION"    : true,
		        "P"         : true,
		        "PARAM"     : true,
		        "S"         : true,
		        "SCRIPT"    : true,
		        "SMALL"     : true,
		        "STRIKE"    : true,
		        "STRONG"    : true,
		        "STYLE"     : true,
		        "SUB"       : true,
		        "SUP"       : true,
		        "TH"        : true,
		        "TITLE"     : true,
		        "THEAD"     : true,
		        "TFOOT"     : true,
		        "TR"        : true,
		        "U"         : true
		    }
	    };
	    	
	    TeaLeaf.Client.Configuration.tlIdCounter = new Array();
    }
}


/*                                                                  
*
* @fileoverview 
* This is the main UI Client Event Capture JavaScript file that is  
* used by other JavaScript to register their onload routines.
*
* @requires 
* TeaLeaf.js
* TeaLeafEvent.js
* TeaLeafClientCfg.js
*
* @version 2008.11.17.1
*                                                                   
*/
if(TeaLeaf.Client && TeaLeaf.Client.Configuration){
	
	TeaLeaf.Client.tlTimeoutID = -1;
	
	/**
    * Enable all event handlers specified in the configuration.
    * @param obj parameter that determines to enable handlers to the window or document object or both.
    * @requires
    * TeaLeafClientCfg.js 
    * @addon
    */            	                                           
    TeaLeaf.Client.tlEnableAllEventHandlers = function(obj) {         
        if(obj){
            if(obj == window){
                TeaLeaf.Client.tlClientJSONCfgUtil(TeaLeaf.Client.Configuration.tlWindowHandlers, true, "all");
            }
            else if(obj == document){
                TeaLeaf.Client.tlClientJSONCfgUtil(TeaLeaf.Client.Configuration.tlDocumentHandlers, true, "all");
            }
        } 
        else{
            TeaLeaf.Client.tlClientJSONCfgUtil(TeaLeaf.Client.Configuration.tlWindowHandlers, true, "all");
            TeaLeaf.Client.tlClientJSONCfgUtil(TeaLeaf.Client.Configuration.tlDocumentHandlers, true, "all");        
        }        
    }
	/**
    * Enable a specific event handler defined in the configuration.
    * @param obj parameter that determines to enable handlers to the window or document object.
    * @param domEventName name of the event to enable.
    * @requires
    * TeaLeafClientCfg.js 
    * @addon
    */            	                                               
    TeaLeaf.Client.tlEnableEventHandler = function(obj, domEventName) { 
        if(obj == window){  
            TeaLeaf.Client.tlClientJSONCfgUtil(TeaLeaf.Client.Configuration.tlWindowHandlers, true, domEventName); 
        }
        else{
            TeaLeaf.Client.tlClientJSONCfgUtil(TeaLeaf.Client.Configuration.tlDocumentHandlers, true, domEventName); 
        }        
    }
	/**
    * Disable all event handlers specified in the configuration.
    * @param obj parameter that determines to disable handlers to the window or document object or both.
    * @requires
    * TeaLeafClientCfg.js 
    * @addon
    */            	                                           
    TeaLeaf.Client.tlDisableAllEventHandlers = function(obj) { 
        if(obj){
            if(obj == window){
                TeaLeaf.Client.tlClientJSONCfgUtil(TeaLeaf.Client.Configuration.tlWindowHandlers, false, "all");
            }
            else if(obj == document){
                TeaLeaf.Client.tlClientJSONCfgUtil(TeaLeaf.Client.Configuration.tlDocumentHandlers, false, "all");
            }
        } 
        else{
            TeaLeaf.Client.tlClientJSONCfgUtil(TeaLeaf.Client.Configuration.tlWindowHandlers, false, "all");
            TeaLeaf.Client.tlClientJSONCfgUtil(TeaLeaf.Client.Configuration.tlDocumentHandlers, false, "all");        
        }        
    }
	/**
    * Disable a specific event handler defined in the configuration.
    * @param obj parameter that determines to disable handlers to the window or document object.
    * @param domEventName name of the event to enable.
    * @requires
    * TeaLeafClientCfg.js 
    * @addon
    */            	                                                   
    TeaLeaf.Client.tlDisableEventHandlers = function(obj, domEventName) { 
        if(obj == window){                
            TeaLeaf.Client.tlClientJSONCfgUtil(TeaLeaf.Client.Configuration.tlWindowHandlers, false, domEventName); 
        }
        else{
            TeaLeaf.Client.tlClientJSONCfgUtil(TeaLeaf.Client.Configuration.tlDocumentHandlers, false, domEventName); 
        }        
    }    
	/**
    * Utility that helps enabling or disabling of event handlers.
    * @param tlJSONConfig configuration array.
    * @param tlEnable enable (true or false flag).
    * @param domEventName event name to enable or disable.
    * @addon
    */            	                                                       
    TeaLeaf.Client.tlClientJSONCfgUtil = function(tlJSONConfig, tlEnable, domEventName) {         
        for(var i = 0; i<tlJSONConfig.length; i++){
            if(domEventName == "all"){
                tlJSONConfig[i].load = tlEnable;
            }
            else if (domEventName == tlJSONConfig[i].domevent){
                tlJSONConfig[i].load = tlEnable;
            }
        }  
    }  
	TeaLeaf.Client.tlHasUserMovement = false;
	/**
    * Detect user movement.
    *
    * @requires 
    * TeaLeafClientCfg.js
    * TeaLeafEvent.js
    * @addon
    */            	                                                           
	TeaLeaf.Client.tlUserMovement = function() {
		TeaLeaf.Client.tlHasUserMovement = true;
		TeaLeaf.Event.tlRemoveHandler(document, "mousemove", TeaLeaf.Client.tlUserMovement, false);
	}
	/**
    * Add a unique Id to a DOM element.
    * @param itemSource DOM element that needs an id.
    * @requires 
    * TeaLeafClientCfg.js
    * @addon
    */            	                                                                
    TeaLeaf.Client.tlAddIdToControl = function(itemSource) {  	    
	    if ((itemSource.id && itemSource.id != "") || (itemSource.name && itemSource.name != "")) {
		    return;
	    }
	    var idTag = itemSource.tagName;

	    var thereYet = TeaLeaf.Client.Configuration.tlIdCounter[idTag];
	    if (thereYet == undefined)
		    TeaLeaf.Client.Configuration.tlIdCounter[idTag] = 0;

        var idElement = "_TL_" + idTag + "_"
            + TeaLeaf.Client.Configuration.tlIdCounter[idTag];
        var item  = document.getElementById(idElement);
        var baseId = idElement;
        
        if(item){
            
            while(document.getElementById("_TL_" + idTag + "_"
                + TeaLeaf.Client.Configuration.tlIdCounter[idTag]++));
        }
        
        itemSource.id = baseId;
        TeaLeaf.Client.Configuration.tlIdCounter[idTag]++;
	}  

	/**
    * Loops through a JSON array to find the elemement if exists.
    * @param name or id of element.
    * @param JSON.
    * @requires 
    * TeaLeafClientCfg.js
    * @addon
    */            	                                                                
	TeaLeaf.Client.tlFindinJSON = function(tlElement, tlJSON) {        
        var tlNameorId = TeaLeaf.Client.tlGetName(tlElement);
        if(tlNameorId){
            for(var i=0; i<tlJSON.length; i++){ 
                if(tlNameorId == tlJSON[i].tlfieldname){  
                    return tlJSON[i];
                }
            }
        }
    }

	/**
    * Check if element is silent.
    * @param name or id of element.
    * @requires 
    * TeaLeafClientCfg.js
    * @addon
    */            	                                                                
	TeaLeaf.Client.tlIsReplace = function(name) {
		
		if( !name ) {
			return false;
		}
		
		if( typeof name == "object" ) {			
			if( name.TeaLeafReplace) { 	
 				return true;
			}		    
		}
		else{
		    var tlReplace = document.getElementById(name);  
		    if(tlReplace.TeaLeafReplace == true){
 		        return true;		    
		    }		    
		    if(!tlReplace){
		        tlReplace = document.getElementsByName(name);     
		        for(var i=0; i<tlSilent.length; i++){
		            if(tlReplace[i].TeaLeafReplace == true){
 		                return true;
		            }
		        }
		    }
		}
		
		if( name.type == "password" ) {
			return TeaLeaf.Client.Configuration.tlpassword == 2;
		}

		return false;
	}

	/**
    * Replace element with dummy value, needed in some cases
    * when there is client validation.
    * @param elem
    * @requires 
    * TeaLeafClientCfg.js
    * @addon
    */            	                                                                	
	TeaLeaf.Client.tlReplaceValue = function(elem) {
		var name = TeaLeaf.Client.tlGetName(elem);
		TeaLeaf.Client.tlMakeFieldBlockMap();
		var map_item = TeaLeaf.Client.Configuration.tlFieldBlockMap[name.toLowerCase()];
		if(map_item == null) return "";
		if(map_item["eventvaluereplace"].length > 0) return map_item["eventvaluereplace"];
		else return "";
    }
    
	/**
    * Check if element is excluded from capture.
    * @param name or id of element.
    * @requires 
    * TeaLeafClientCfg.js
    * @addon
    */            	                                                                	
	TeaLeaf.Client.tlIsExcluded = function(name) {
		
		if( !name ) {
			return false;
		}
		
		if( typeof name == "object" ) {			
			if( name.TeaLeafExclude ) {
				return true;
			}		    
		}
		else{
		    var tlExclude = document.getElementById(name);   		    
		    if(tlExclude){
		        if(tlExclude.TeaLeafExclude){   
		            return true;		    
		        }		       
		    }
		    else{
		        tlExclude = document.getElementsByName(name);     
		        if(tlExclude){
		            for(var i=0; i<tlExclude.length; i++){
		                if(tlExclude[i].TeaLeafExclude){
		                    return true;
		                }
		            }
		        }		    
		    }
		    return false;
		}
		
		if( name.type == "password" ) {
			return TeaLeaf.Client.Configuration.tlpassword == 2;
		}

		return false;
	}
	/**
    * Get the name from a DOM node.
    * @param theNode DOM element.
    * @addon
    */            	                                                                
	TeaLeaf.Client.tlGetName = function(theNode) {
		if( theNode == null ) {
			return null;
		}
		var		id = theNode.id;
		if( id && id != "" ) {
			return id;
		}
		var		name = theNode.name;
		if( name && name != "" ) {
			return name;
		}
		return null;
	}
	/**
    * Get event source DOM element.
    * @param theEvent DOM event.
    * @addon
    */            	                                                                
    TeaLeaf.Client.tlGetEventSource = function(theEvent) {
        var	itemSource = null;       
        if(theEvent){	
	        if( theEvent.srcElement ) {	
	            itemSource = theEvent.srcElement;
	        }
	        else {	
	            itemSource = theEvent.target;
		        if( itemSource == null ) {
		            itemSource = theEvent.explicitOriginalTarget;			
			        if( itemSource == null ) {
			            itemSource = theEvent.originalTarget;
			        }
	    	    }
	        }
	        if(itemSource && (itemSource.name == null || itemSource.name == "")) {
	            
		        if( itemSource.parentNode && itemSource.parentNode.tagName ) {
		            if( itemSource.parentNode.tagName == "A" ||
			            itemSource.parentNode.tagName == "LINK" ) {
				            itemSource = itemSource.parentNode;
			            }
		            }
	            }
	        }
	    return itemSource;
    }	
	/**
    * If we don't have an name, get the index from either the anchors
    * or the links collection.
    * @param theNode DOM element.
    * @param full XML format.
    * @addon
    */            	                                                                
	TeaLeaf.Client.tlGetAnchor = function(theNode, full) {
		if( theNode == null ) {
			return null;
		}
		if( theNode.name && theNode.name != "" ) {
			return null;
		}
		var		idx;
		for(idx = 0; idx < document.anchors.length; idx++) {
			if( document.anchors[idx] == theNode ) {
				if( full ) {
					return "<AnchorElement>" + idx + "</AnchorElement>\r\n";
				}
				else {
					return "Anchor-" + idx;
				}
			}
		}
		for(idx = 0; idx < document.links.length; idx++) {
			if( document.links[idx] == theNode ) {
				if( full ) {
					return "<LinkElement>" + idx + "</LinkElement>\r\n";
				}
				else {
					return "Link-" + idx;
				}
			}
		}	
		return null;
	}

	/**
	 * Check if element is of type input
	 */
	TeaLeaf.Client.checkIsInput = function(elem) {
	    if(typeof(elem) == "string") elem = document.getElementById(elem);
	
            switch(elem.tagName) 
	    {
		case "INPUT":
		case "SELECT":
		case "TEXTAREA":
		    return true;
	    }

	    return false;
	}


	/**
    * If we don't have an name, get the index from either the anchors
    * or the links collection.
    * @param str XML string.
    * @requires 
    * TeaLeafClientCfg.js
    * TeaLeafEvent.js
    * @addon
    */            	                                                                	
	TeaLeaf.Event.tlFormatXMLName = function(str) {
		
		if( ! str || str.length <= 0 )
			return null;

		var	rtn = "";
		if( ! TeaLeaf.Event.tlNameStartChar(str.charCodeAt(0)) ) {
			rtn = "_";
		}
		var	max = str.length;
		var	ind;
		for(ind = 0; ind < max; ind++) {
			if( TeaLeaf.Event.tlNameChar(str.charCodeAt(ind)) ) {
				rtn = rtn + str.charAt(ind);
			}
			else {
				rtn = rtn + "_";
			}
		}
		return rtn;
	}
	/**
	* Utility function to help format the XML.
    * @param chr character.
    * @addon
    */            	                                                                	
    TeaLeaf.Event.tlNameStartChar = function(chr) {
		
		
		
		
		
		
		return (chr >= 0x41 && chr <= 0x5A) || chr == 0x5F ||
			(chr >= 0x61   && chr <= 0x7A)   || (chr >= 0xC0   && chr <= 0xD6)   ||
			(chr >= 0xD8   && chr <= 0xF6)   || (chr >= 0xF8   && chr <= 0x2FF)  ||
			(chr >= 0x370  && chr <= 0x37D)  || (chr >= 0x37F  && chr <= 0x1FFF) ||
			(chr >= 0x200C && chr <= 0x200D) || (chr >= 0x2070 && chr <= 0x218F) ||
			(chr >= 0x2C00 && chr <= 0x2FEF) || (chr >= 0x3001 && chr <= 0xD7FF) ||
			(chr >= 0xF900 && chr <= 0xFDCF) || (chr >= 0xFDF0 && chr <= 0xFFFD);
	}
	/**
	* Utility function to help format the XML.
    * @param chr character.
    * @addon
    */            	                                                                	
    TeaLeaf.Event.tlNameChar = function(chr) {
		
		return TeaLeaf.Event.tlNameStartChar(chr) || chr == 0x2D || chr == 0x2E ||
			(chr >= 0x30 && chr <= 0x39) || chr == 0xB7  ||
			(chr >= 0x0300 && chr <= 0x036F) || (chr >= 0x203F && chr <= 0x2040);
	}

	TeaLeaf.Client.tlQueuedKeys = "";

	/**
    * Queues the keys
    * @param theEvent DOM event.
    * @requires 
    * TeaLeafClientCfg.js
    * TeaLeafEvent.js
    * @addon
    */            	                                                                	
	TeaLeaf.Client.tlQueueKey = function(theEvent) {
        TeaLeaf.Client.tlSendResize();
        TeaLeaf.Client.tlSendScroll();
		if( ! theEvent ) {
			theEvent = window.event;
		}
		if( theEvent.keyCode < 0x20 ) {
			return;
		}
		
		var	itemSource = TeaLeaf.Client.tlGetEventSource(theEvent);
		if( ! itemSource ) {
			return;
		}
		
		if( ! itemSource.TeaLeafFocusTime ) {
			itemSource.TeaLeafFocusTime = new Date();
		}
		if( TeaLeaf.Client.tlQueuedKeySource ) {
			if( TeaLeaf.Client.tlQueuedKeySource != itemSource ) {
				if( TeaLeaf.Client.tlQueuedKeys && TeaLeaf.Client.tlQueuedKeys.length > 0 )
                    TeaLeaf.Client.tlSendKeys();
				TeaLeaf.Client.tlQueuedKeySource = itemSource;
			}
		}
		else {
			TeaLeaf.Client.tlQueuedKeySource = itemSource;
		}
		
		
		var	name  = TeaLeaf.Client.tlGetName(itemSource);

		var	lev = null;
		if( ! name ) {
			lev = TeaLeaf.Client.tlGetAnchor(itemSource, false);
			if( ! lev ) {
				TeaLeaf.Client.tlQueuedKeySource = null;
				return;
			}
		}
		else {
			if( TeaLeaf.Client.tlIsReplace(itemSource) ) {
				TeaLeaf.Client.tlQueuedKeysCount++;
				return;
			}
			if( TeaLeaf.Client.tlIsExcluded(itemSource) ) {
			    TeaLeaf.Client.tlQueuedKeys=null;
				TeaLeaf.Client.tlQueuedKeysCount++;
				return;
			}
		}
		
		if( TeaLeaf.Client.tlQueuedKeys ) {
			if( TeaLeaf.Client.tlQueuedKeys.length > 0 ) {
				TeaLeaf.Client.tlQueuedKeys = TeaLeaf.Client.tlQueuedKeys + ";";
			}
		}
		
		if( theEvent.ctrlKey ) {
			if( TeaLeaf.Client.tlQueuedKeys ) {
				TeaLeaf.Client.tlQueuedKeys = TeaLeaf.Client.tlQueuedKeys + "ctrl-";
			}
			else {
				TeaLeaf.Client.tlQueuedKeys = "ctrl-";
			}
		}
		if( theEvent.altKey ) {
			if( TeaLeaf.Client.tlQueuedKeys ) {
				TeaLeaf.Client.tlQueuedKeys = TeaLeaf.Client.tlQueuedKeys + "alt-";
			}
			else {
				TeaLeaf.Client.tlQueuedKeys = "alt-";
			}
		}
		if( theEvent.shiftKey ) {
			if( TeaLeaf.Client.tlQueuedKeys ) {
				TeaLeaf.Client.tlQueuedKeys = TeaLeaf.Client.tlQueuedKeys + "shift-";
			}
			else {
				TeaLeaf.Client.tlQueuedKeys = "shift-";
			}
		}
		TeaLeaf.Client.tlQueuedKeys = TeaLeaf.Client.tlQueuedKeys + theEvent.keyCode;
	}
	/**
    * Send the keys.
    * @requires 
    * TeaLeafClientCfg.js
    * TeaLeafEvent.js
    * @addon
    */            	                                                                	
	TeaLeaf.Client.tlSendKeys = function() {	
		if( ! TeaLeaf.Client.tlQueuedKeySource ||
			( ! TeaLeaf.Client.tlQueuedKeys && ! TeaLeaf.Client.tlQueuedKeysCount ) ) {
				return;
		}
		
		
		var	qSource = TeaLeaf.Client.tlQueuedKeySource;
		var	qKeys   = TeaLeaf.Client.tlQueuedKeys;
		var	qCount  = TeaLeaf.Client.tlQueuedKeysCount;
		TeaLeaf.Client.tlQueuedKeySource = null;
		TeaLeaf.Client.tlQueuedKeys      = "";
		TeaLeaf.Client.tlQueuedKeysCount = 0; 
    
        var tlreplace = false; 
		if( TeaLeaf.Client.tlIsReplace(qSource) ) {		
			tlreplace = true;
			return;
		}
		var	excluded = false;
 
		if( TeaLeaf.Client.tlIsExcluded(qSource) ) {

			excluded = true;
			qKeys = null;
		}
		
		
		var	name  = TeaLeaf.Client.tlGetName(qSource);
		var	lev = null;
		if( name == null ) {
			lev = TeaLeaf.Client.tlGetAnchor(qSource, false);
			if( lev == null ) {
				return;
			}
		}
		else {
			if( TeaLeaf.Client.tlIsExcluded(name) ) {
				return null;
			}
		}
		
		var	tlevt = new TeaLeaf.Event("GUI", "KeyUp");
        var tlAddNameValueArray = new Array("Name", qSource.name,
			                                "Id", qSource.id,
			                                "Lev", lev,
			                                "ElementType", qSource.type,
			                                "TagName", qSource.tagName,
			                                "KeyCount", qCount);
        tlevt.tlAddData(tlAddNameValueArray);

		if(excluded) {
		    var tlAddNameValueArrayExcluded = new Array("Excluded", "true");
            tlevt.tlAddData(tlAddNameValueArrayExcluded);
		}
		else if(tlreplace){
			
			var tlRepValue = TeaLeaf.Client.tlGetReplaceValue(qSource);			
			var tlAddNameValueArrayReplaceName = new Array("ValueIn", name,
				                                          name,   tlRepValue,
				                                          "KeyCode", qKeys);                                          
			tlevt.tlAddData(tlAddNameValueArrayReplaceName);
		}
		else {
			var	tlManualName = TeaLeaf.Event.tlFormatXMLName(name);			
			var tlAddNameValueArrayManualName = new Array("ValueIn", tlManualName,
				                                          tlManualName,   qSource.value,
				                                          "KeyCode", qKeys);                                          
			tlevt.tlAddData(tlAddNameValueArrayManualName);
		}
		
		tlevt.tlSend();
	}
	/**
    * Send resize event.
    * @requires 
    * TeaLeafClientCfg.js
    * TeaLeafEvent.js
    * @addon
    */            	                                                                	
	TeaLeaf.Client.tlSendResize = function() {	
		if( ! TeaLeaf.Client.ResizeClientX && ! TeaLeaf.Client.ResizeClientY ) {
			return;
		}
		var	tlevt = new TeaLeaf.Event("GUI", "Resize");
        var tlAddNameValueArray = new Array("ClientX", TeaLeaf.Client.ResizeClientX,
			                                "ClientY", TeaLeaf.Client.ResizeClientY,
			                                "ScreenX", TeaLeaf.Client.ResizeScreenX,
			                                "ScreenY", TeaLeaf.Client.ResizeScreenY);
        tlevt.tlAddData(tlAddNameValueArray);
		TeaLeaf.Client.ResizeClientX = null;
		TeaLeaf.Client.ResizeClientY = null;
		TeaLeaf.Client.ResizeScreenX = null;
		TeaLeaf.Client.ResizeScreenY = null;
		
		tlevt.tlSend();
	}
	
	/**
    * Queue scroll event.
    * @requires 
    * TeaLeafClientCfg.js
    * TeaLeafEvent.js
    * @addon
    */            	
    TeaLeaf.Client.tlQueueScroll = function(tlEvent) {

	    TeaLeaf.Client.tlSendKeys();
	    TeaLeaf.Client.tlSendResize();

	    if( ! tlEvent ) {
		    tlEvent = window.event;
	    }
	    
	    if( tlEvent.clientX ) {
		    
		    TeaLeaf.Client.ScrollClientX = tlEvent.clientX;
		    TeaLeaf.Client.ScrollClientY = tlEvent.clientY;
		    TeaLeaf.Client.ScrollScreenX = tlEvent.screenX;
		    TeaLeaf.Client.ScrollScreenY = tlEvent.screenY;
	    }
	    else {
		    
		    TeaLeaf.Client.ScrollHeight = tlEvent.target.scrollHeight;
		    TeaLeaf.Client.ScrollWidth  = tlEvent.target.scrollWidth;
		    TeaLeaf.Client.ScrollTop    = tlEvent.target.scrollTop;
		    TeaLeaf.Client.ScrollLeft   = tlEvent.target.scrollLeft;
	    }
    }

	/**
    * Send scroll event.
    * @requires 
    * TeaLeafClientCfg.js
    * TeaLeafEvent.js
    * @addon
    */            	                                                                	
	TeaLeaf.Client.tlSendScroll = function() {	
		if( ! TeaLeaf.Client.ScrollClientX && ! TeaLeaf.Client.ScrollHeight ) {
			return;
		}
		var	tlevt = new TeaLeaf.Event("GUI", "Scroll");
        var tlAddNameValueArray = new Array("ClientX",      TeaLeaf.Client.ScrollClientX,
			                                "ClientY",      TeaLeaf.Client.ScrollClientY,
			                                "ScreenX",      TeaLeaf.Client.ScrollScreenX,
			                                "ScreenY",      TeaLeaf.Client.ScrollScreenY,
			                                "ScrollHeight", TeaLeaf.Client.ScrollHeight,
			                                "ScrollWidth",  TeaLeaf.Client.ScrollWidth,
			                                "ScrollTop",    TeaLeaf.Client.ScrollTop,
			                                "ScrollLeft",   TeaLeaf.Client.ScrollLeft);	
		tlevt.tlAddData(tlAddNameValueArray);	
		TeaLeaf.Client.ScrollClientX = null;
		TeaLeaf.Client.ScrollClientY = null;
		TeaLeaf.Client.ScrollScreenX = null;
		TeaLeaf.Client.ScrollScreenY = null;
		TeaLeaf.Client.ScrollHeight  = null;
		TeaLeaf.Client.ScrollWidth   = null;
		TeaLeaf.Client.ScrollTop     = null;
		TeaLeaf.Client.ScrollLeft    = null;
		
		tlevt.tlSend();
	}

    /**
    * Find the nearest ancestor for a DOM node of the given type
    * @param node The original node
    * @param tag The tag to match on
    * @addon
    */  
	TeaLeaf.Client.tlFindAncestorByTag = function(node, tag)
    {
        var cur_node = node.parentNode;
        while(cur_node && cur_node != window.document)
        {
            if(cur_node.nodeType != 1) continue;
            if(cur_node.tagName == tag) break;
            else cur_node = cur_node.parentNode;
        }
        
        return cur_node;
    }

    /**
    * Generate an XPath for the node, consumable by TeaLeaf.Client.tlGetNodeFromXPath
    * @param node The starting node
    * @param tag The tag to match on
    * @addon
    */
    TeaLeaf.Client.tlGetXPathFromNode = function(node)
    {
        if(node == null) return null;
        var xpath = [];
        var cur_node = node;
        var nodes_arr = null;
        var parent_node = null;
        
       while(cur_node != window.document && (cur_node.id == null || cur_node.id == ""))
       {
            nodes_arr = null;
            parent_node = null;
            switch(cur_node.tagName)
            {
                case "TD":
                    if(parent_node = TeaLeaf.Client.tlFindAncestorByTag(cur_node, "TR"))
                        nodes_arr = parent_node.cells;
                    break;
                case "TR":
                    if(parent_node = TeaLeaf.Client.tlFindAncestorByTag(cur_node, "TABLE"))
                        nodes_arr = parent_node.rows;
                    break;
	        case "OPTION":
		            if(parent_node = TeaLeaf.Client.tlFindAncestorByTag(cur_node, "SELECT"))
		                nodes_arr = parent_node.options;
		    break;
                default:
                    parent_node = cur_node.parentNode;
		            if(!parent_node) parent_node = window.document;
		            nodes_arr = parent_node.childNodes;
		            break;
            }
            
            if(nodes_arr == null) return null;
            var j=0;
            for(var i=0; i<nodes_arr.length; i++)
            {
	            if(nodes_arr[i].nodeType == 1 && nodes_arr[i].tagName == cur_node.tagName)
                {
                    if(nodes_arr[i] == cur_node)
                    {
                        xpath[xpath.length] = [cur_node.tagName, j];
                        break;
                    }
                    
                    j++;
                }
            }
            
	    cur_node = parent_node;
        }
        
        if(cur_node.id != null && cur_node.id != "") xpath[xpath.length] = [cur_node.id];
        
        var parts = [];
        for(var i=xpath.length-1; i>=0; i--)
        {
            if(xpath[i].length > 1)
                parts[parts.length] = "['"+xpath[i][0]+"',"+xpath[i][1]+"]";
            else
                parts[parts.length] = "['"+xpath[i][0].replace(/'/g, "\\'")+"']";
        }
        
        return "["+parts.join(",")+"]";
    }

    /**
    * Find a node specified by an XPath generated by TeaLeaf.Client.tlGetXPathFromNode
    * @param path The XPath
    * @addon
    */      
    TeaLeaf.Client.tlGetNodeFromXPath = function(path, decode)
    {
        if(path == null) return null;
	if(decode) path = TeaLeaf.Event.tlXMLDecode(path);
        var xpath = eval(path);
        if(xpath == null) return null;
        var cur_node = window.document;
        
        for(var i=0; i<xpath.length; i++)
        {
	        found = false;
            if(xpath[i].length == 1)
            {
                cur_node = document.getElementById(xpath[i]);
                if(cur_node == null) return null; 
            }
            else
            {
                k = 0;
	            switch(cur_node.tagName)
	            {
		            case "TABLE": children = cur_node.rows; break;
		            case "TR": children = cur_node.cells; break;
		            case "SELECT": children = cur_node.options; break;
		            default: children = cur_node.childNodes; break;
	            }

                for(var j=0; j<children.length; j++)
                {
	                if(children[j].nodeType != 1) continue;
                    if(children[j].tagName == xpath[i][0])
                    {
                        if(k == xpath[i][1])
                        {
                            cur_node = children[j];
		                    found = true;
                            break;
                        }
                        
                        k++;
                    }
                }

	            if(!found) return null;
            }
        }
       
        return cur_node;
    }

    
    window.TeaLeaf_Client_tlGetNodeFromXPath = TeaLeaf.Client.tlGetNodeFromXPath;

	/**
    * Add an event.
    * @param theEvent DOM event.
    * @requires 
    * TeaLeafClientCfg.js
    * TeaLeafEvent.js
    * @addon
    */            	                                                                	
	TeaLeaf.Client.tlAddEvent = function(theEvent) {
		
		if( ! theEvent ) theEvent = window.event;

		
		
		
		if(theEvent.tealeafMarked === true) return;
		

		
		var	itemSource = TeaLeaf.Client.tlGetEventSource(theEvent);
		if( ! itemSource ) return;

		
        	TeaLeaf.Client.tlSendKeys();
        	TeaLeaf.Client.tlSendResize();
        	TeaLeaf.Client.tlSendScroll();		

		
		if( ! itemSource.TeaLeafFocusTime ) {
			switch(theEvent.type)
			{
				case "keyup":
				case "change":
				case "click":
				case "dblclick":
				case "mousedown":
					itemSource.TeaLeafFocusTime = new Date();
					break;
			}
		}
		
		
		if( theEvent.type == "blur" && itemSource.type == "application/x-shockwave-flash" ) {
			return;
		}
	
			

		if(theEvent.type == "click" && TeaLeaf.Client.checkIsInput(itemSource)){
		    TeaLeaf.Event.Configuration.tlidoflastvisitedcontrol = TeaLeaf.Client.tlGetName(itemSource);	      
		}
		
		var	tlevt = new TeaLeaf.Event("GUI", theEvent.type);
		
		
		var tlAddNameValueArray = new Array("Name", itemSource.name,
			                                "Id", itemSource.id,
			       			        "ElementType", itemSource.type,
			                                "TagName", itemSource.tagName,
			                                "AltKey", theEvent.altKey?"True":null,
			                                "CtrlKey", theEvent.ctrlKey?"True":null,
			                                "ShiftKey", theEvent.shiftKey?"True":null,
			                                "NodeName", theEvent.nodeName,
			                                "NodeValue", theEvent.nodeValue,
							                "XPath", TeaLeaf.Client.tlGetXPathFromNode(itemSource));
        tlevt.tlAddData(tlAddNameValueArray);


		var tlName = TeaLeaf.Client.tlGetName(itemSource);

		if( theEvent.type == "blur" && itemSource.TeaLeafFocusTime ) {
			var	now = new Date();
			var tlAddNameValueArrayTimeIn = new Array("TimeInControl", TeaLeaf.Event.tlDateDiff(now, itemSource.TeaLeafFocusTime));
            tlevt.tlAddData(tlAddNameValueArrayTimeIn);
			itemSource.TeaLeafFocusTime = null;
		}

        if(itemSource.TeaLeafExclude) {
		    var tlAddNameValueArrayExcluded = new Array("Excluded", "true");
		    tlevt.tlAddData(tlAddNameValueArrayExcluded);
		}		 
        else{
            var tlManualName = TeaLeaf.Event.tlFormatXMLName(tlName);
            var tlRepValue = itemSource.TeaLeafReplace ? TeaLeaf.Client.tlReplaceValue(itemSource) : itemSource.value;
            var tlAddNameValueArrayManualName = new Array("ValueIn", tlManualName, 
                                                           tlManualName, tlRepValue,
				                                          "KeyCode", theEvent.keyCode);                            
           tlevt.tlAddData(tlAddNameValueArrayManualName);		
       }

		tlevt.tlSend();
	}	
	/**
    * Send all the form field values with the form submit.
    * @param theEvent DOM event.
    * @requires 
    * TeaLeafClientCfg.js
    * TeaLeafEvent.js
    * @addon
    */            	                                                                			
	TeaLeaf.Client.tlHandleFormSubmit = function(theEvent) {
		
		TeaLeaf.Client.Configuration.tlactiontype = "Submit";	
		
        TeaLeaf.Client.tlSendKeys();
        TeaLeaf.Client.tlSendResize();
        TeaLeaf.Client.tlSendScroll();

		
		if( ! theEvent ) {
			theEvent = window.event;
		}
		
		var	itemSource = TeaLeaf.Client.tlGetEventSource(theEvent);
		if( ! itemSource ) {
			return;
		}
		
		var	i;
		if( ! itemSource.name ) {
			var	forms = document.forms;
			for(i = 0; i < forms.length; i++) {
				if( forms[i] == itemSource ) {
					itemSource.name = "Ordinal-" + i;
					break;
				}
			}
		}
		
		if( ! itemSource.name ) {
			return;
		}
		
        if( TeaLeaf.Client.tlIsReplace(itemSource) ) {
            var tlRepValue = TeaLeaf.Client.tlGetReplaceValue(itemSource);			
            var name = TeaLeaf.Client.tlGetName(itemSource);
            var tlAddNameValueArrayReplaceName = new Array("ValueIn", name,
                name,   tlRepValue); 

            tlevt.tlAddData(tlAddNameValueArrayReplaceName);      
        }
		
		var	tlevt = new TeaLeaf.Event("GUI", theEvent.type);
		
        var tlAddNameValueArray = new Array("Name", itemSource.name,
			                                "Id", itemSource.id,
			                                "ElementType", itemSource.type,
			                                "TagName", itemSource.tagName,
			                                "AltKey", theEvent.altKey?"True":null,
			                                "CtrlKey", theEvent.ctrlKey?"True":null,
			                                "ShiftKey", theEvent.shiftKey?"True":null,
			                                "NodeName", theEvent.nodeName,
			                                "NodeValue", theEvent.nodeValue,
			                                "VisitOrder", TeaLeaf.Event.Configuration.tlvisitorder);
        tlevt.tlAddData(tlAddNameValueArray);
		var	children = itemSource.getElementsByTagName("INPUT");
		var tlAddNameValueArrayInputFieldCount = new Array("InputFieldCount", children.length);
        tlevt.tlAddData(tlAddNameValueArrayInputFieldCount);
		tlevt.tlPushXML("InputFields");	
		
		for(i = 0; i < children.length; i++) {
			var	child = children[i];
			
			if( ! child.name ) {
				continue;
			}
			
			tlevt.tlPushXML("Field"+i);
            var tlAddNameValueArrayNode = new Array("Name", child.name,
				                                    "Id", child.id,
				                                    "ElementType", child.type,
				                                    "TagName", child.tagName);
            tlevt.tlAddData(tlAddNameValueArrayNode);
				
			if( TeaLeaf.Client.tlIsExcluded(name) ) {
			    var tlAddNameValueArrayExcluded = new Array("Excluded", "true");
			    tlevt.tlAddData(tlAddNameValueArrayExcluded);
			}
			
			else if( TeaLeaf.Client.tlIsReplace(child.name) ) {
                var tlRepValue = TeaLeaf.Client.tlGetReplaceValue(child);			
                var name = TeaLeaf.Client.tlGetName(child);
                var tlAddNameValueArrayReplaceName = new Array("ValueIn", name,
                        name,   tlRepValue); 

                tlevt.tlAddData(tlAddNameValueArrayReplaceName);      
			}
			else {
				var	tlManualName = TeaLeaf.Event.tlFormatXMLName(child.name);
			    var tlAddNameValueArrayManualName = new Array("ValueIn", tlManualName, tlManualName, child.value);
                tlevt.tlAddData(tlAddNameValueArrayManualName);
			}
			tlevt.tlPopXML();
		}
		tlevt.tlPopXML();
		tlevt.tlSend();
		TeaLeaf.Event.Configuration.tlvisitorder = "";
	}
	/**
    * Handle the resize event.
    * @param theEvent DOM event.
    * @requires 
    * TeaLeafClientCfg.js
    * TeaLeafEvent.js
    * @addon
    */            	                                                                			
	TeaLeaf.Client.tlQueueResize = function(tlEvent) {
		TeaLeaf.Client.tlSendKeys();
		TeaLeaf.Client.tlSendScroll();
		if( ! tlEvent ) {
			tlEvent = window.event;
		}
		if( tlEvent.clientX) {
			TeaLeaf.ResizeClientX = tlEvent.clientX;
			TeaLeaf.ResizeClientY = tlEvent.clientY;
			TeaLeaf.ResizeScreenX = tlEvent.screenX;
			TeaLeaf.ResizeScreenY = tlEvent.screenY;
		}
		else {
			TeaLeaf.ResizeClientX = tlEvent.target.width;
			TeaLeaf.ResizeClientY = tlEvent.target.height;
		}
	}
	/**
    * Handle the form reset event.
    * @param theEvent DOM event.
    * @requires 
    * TeaLeafClientCfg.js
    * TeaLeafEvent.js
    * @addon
    */            	                                                                			
	TeaLeaf.Client.tlHandleFormReset = function(theEvent) {
		
		TeaLeaf.Client.tlSendKeys();
		TeaLeaf.Client.tlSendResize();
		TeaLeaf.Client.tlSendScroll();
		
		if( ! theEvent ) {
			theEvent = window.event;
		}
		
		var	itemSource = TeaLeaf.Client.tlGetEventSource(theEvent);
		if( ! itemSource ) {
			return;
		}
		
		var	i;
		if( ! itemSource.name ) {
			var	forms = document.forms;
			for(i = 0; i < forms.length; i++) {
				if( forms[i] == itemSource ) {
					itemSource.name = "Ordinal-" + i;
					break;
				}
			}
		}
		
		if( name == null ) {
			return;
		}
		
		if( TeaLeaf.Client.tlIsReplace(itemSource) ) {
		    var tlRepValue = TeaLeaf.Client.tlGetReplaceValue(itemSource);			
            var tlname = TeaLeaf.Client.tlGetName(itemSource);
            var tlAddNameValueArrayReplaceName = new Array("ValueIn", tlname,
                                                tlname,   tlRepValue); 
            tlevt.tlAddData(tlAddNameValueArrayReplaceName);

		}
		
		var	tlevt = new TeaLeaf.Event("GUI", theEvent.type);
		
        var tlAddNameValueArray = new Array("Name", itemSource.name,
			                                "Id", itemSource.id,
			                                "ElementType", itemSource.type,
			                                "TagName", itemSource.tagName,
			                                "AltKey", theEvent.altKey?"True":null,
			                                "CtrlKey", theEvent.ctrlKey?"True":null,
			                                "ShiftKey", theEvent.shiftKey?"True":null,
			                                "NodeName", theEvent.nodeName,
			                                "NodeValue", theEvent.nodeValue,
			                                "VisitOrder", TeaLeaf.Event.Configuration.tlvisitorder);
        tlevt.tlAddData(tlAddNameValueArray);
		tlevt.tlSend();
		TeaLeaf.tlVisitOrder = "";
	}	
	/**
    * Handle the before unload event and flush the queue of events client events captured.
    *
    * @requires 
    * TeaLeafClientCfg.js
    * TeaLeafEvent.js
    * @addon
    */            	                                                                			
	TeaLeaf.Client.tlBeforeUnload = function() {
	    
	    if(TeaLeaf.Client.tlBeforeUnloadFired) return;
	    TeaLeaf.Client.tlBeforeUnloadFired = true;

	    
	    
	    if(typeof TeaLeaf.Cookie != "undefined" && TeaLeaf.Client.Configuration.tlStoreQueueInCookie){
		    var d = new Date();
		    d.setTime(d.getTime()+300000);
		    var cookie_val = TeaLeaf.Event.tlQueuedXML.replace(/(\r|\n)/g, "").replace(/;/g, "%3B");
		    TeaLeaf.Cookie.tlSetCookieValue("tlQueuedXML", cookie_val, d, "/");
	    }
        if(TeaLeaf.Client.Configuration.tlbeforeunloadflag == true){ 
            TeaLeaf.Event.Configuration.tllastdwelltime = new Date();
            TeaLeaf.Client.Configuration.tlunloadflag = false;   
		 
		    
		    var	tlevt = new TeaLeaf.Event("PERFORMANCE", "BeforeUnload");	
		    TeaLeaf.Event.SetType = tlevt.EventType;

		    if(TeaLeaf.Event.SetSubType == ""){
                TeaLeaf.Event.SetSubType = tlevt.EventSubType;
            }
            else{
                TeaLeaf.Event.SetSubType += "; " + tlevt.EventSubType;
            }                    
            TeaLeaf.Event.Configuration.tlbeforeunloadflag = true;
            var tlAddNameValueArray = new Array("MouseMove", TeaLeaf.Client.tlHasUserMovement?"TRUE":"FALSE",
		                                        "Action", TeaLeaf.Client.Configuration.tlactiontype, 
		                                        "VisitOrder", TeaLeaf.Event.Configuration.tlvisitorder);          
            tlevt.tlAddData(tlAddNameValueArray);
            TeaLeaf.Event.Configuration.tlasync = false;        		
		    tlevt.tlSend();
	
		    TeaLeaf.Event.tlFlushQueue(true);
		    TeaLeaf.Event.Configuration.tlvisitorder = "";
		    TeaLeaf.Client.tlDetachFromAllControls();
		}
	}
	/**
    * Handle the unload event and flush the queue of events client events captured.
    *
    * @requires 
    * TeaLeafClientCfg.js
    * TeaLeafEvent.js
    * @addon
    */            	                                                                				
	TeaLeaf.Client.tlUnload = function(){
        if( TeaLeaf.Client.Configuration.tlunloadflag ){         
            TeaLeaf.Event.Configuration.tllastdwelltime = new Date();
            TeaLeaf.Client.Configuration.tlbeforeunloadflag = false;

		    
		    var	tlevt = new TeaLeaf.Event("PERFORMANCE", "Unload");
		    TeaLeaf.Event.SetType = tlevt.EventType;
		    
		    if(TeaLeaf.Event.SetSubType == ""){
                TeaLeaf.Event.SetSubType = tlevt.EventSubType;
            }
            else{
                TeaLeaf.Event.SetSubType += "; " + tlevt.EventSubType;
            }
            var tlAddNameValueArray = new Array("MouseMove", TeaLeaf.Client.tlHasUserMovement?"TRUE":"FALSE",
		                                        "Action", TeaLeaf.Client.Configuration.tlactiontype, 
		                                        "VisitOrder", TeaLeaf.Event.Configuration.tlvisitorder);
            tlevt.tlAddData(tlAddNameValueArray);
            TeaLeaf.Event.Configuration.tlasync = false;
		    tlevt.tlSend();
		    TeaLeaf.Event.tlFlushQueue(true);
		    TeaLeaf.Event.Configuration.tlvisitorder = "";
		    TeaLeaf.Client.tlDetachFromAllControls();
        }
	}
	/**
    * Attach listeners to all controls including controls in frames.
    *
    * @requires 
    * TeaLeafClientCfg.js
    * TeaLeafEvent.js
    * @addon
    */            	                                                                			
	TeaLeaf.Client.tlAttachToAllControls = function() {
        
		TeaLeaf.Client.Configuration.tlcontrolsattached = true;
		
		TeaLeaf.Client.tlAttachToControls(window);
		
        try{
			var	ind;
			for(ind = 0; ind < window.frames.length; ind++) {
				if(window == window.frames[ind]) continue;
				TeaLeaf.Client.tlAttachToControls(window.frames[ind]);
			}
		}
		catch(e){}
	}
	
	/**
    * Attach listeners for specified events to specified controls.
    * 
    * @requires 
    * TeaLeafClientCfg.js
    * TeaLeafEvent.js
    * @addon
    */            	                                                                			
	TeaLeaf.Client.tlSingleAttach = function() {	
	    var tldomsingleelements = TeaLeaf.Client.Configuration.tlSingleAttach;
	
        for(var i=0; i<tldomsingleelements.length; i++){      
            if(tldomsingleelements[i].domelementID
                    && tldomsingleelements[i].domelementID !=""){                
                var tlelement = document.getElementById(tldomsingleelements[i].domelementID);
                if(tlelement){
                    var func = eval(tldomsingleelements[i].tlhandler);
                    TeaLeaf.Event.tlAddHandler(tlelement, tldomsingleelements[i].domevent, func, false);   
                }            
            }
        }
	}

	/**
    * Attach listeners to controls based on the configuration. It also attaches 
    * 'beforeunload' and 'unload' handlers.
    * @param win window object.
    * @requires 
    * TeaLeafClientCfg.js
    * TeaLeafEvent.js
    * @addon
    */            	                                                                			
	TeaLeaf.Client.tlAttachToControls = function(win) {
            try{
                TeaLeaf.Event.tlAddHandler(win, "beforeunload", eval(TeaLeaf.Client.tlBeforeUnload), false);
                TeaLeaf.Event.tlAddHandler(win, "unload", eval(TeaLeaf.Client.tlUnload), false);
                
                
                var handlers = TeaLeaf.Client.Configuration.tlWindowHandlers;
                for(var i=0; i<handlers.length; i++) {
                    if(handlers[i].load == true){
                        var func = eval(handlers[i].tlhandler);
                        TeaLeaf.Event.tlAddHandler(win, handlers[i].domevent, func, false);
                    }
                }

                handlers = TeaLeaf.Client.Configuration.tlDocumentHandlers;
                for(var i=0; i<handlers.length; i++) {
                    if(handlers[i].load == true){
                        var func = eval(handlers[i].tlhandler);
                        TeaLeaf.Event.tlAddHandler(win.document, handlers[i].domevent, func, false);
                    }
                }

                
		TeaLeaf.Client.tlProcessNode(win.document.body);

                
            }
            catch (e) { }
	}
	/**
    * Check if a handler is attached to a control, otherwhise,
    * if the control is INPUT or SELECT attach focus, blur and change 
    * @param control control to check.
    * @requires 
    * TeaLeafEvent.js
    * @addon
    */            	                                                                				
	TeaLeaf.Client.tlCheckAttach = function(control) {	
		
		if( control.TeaLeaf || control.TeaLeafExclude) return;
		control.TeaLeaf = true;

		if(TeaLeaf.Client.Configuration.tlassignTLID)
			TeaLeaf.Client.tlAddIdToControl(control);

	  	TeaLeaf.Client.tlMakeFieldBlockMap();

		
		
		switch(control.tagName)
		{
			case "INPUT":
			case "SELECT":
			case "TEXTAREA":
				if( TeaLeaf.Client.Configuration.tlsendfocus ) {
                    			TeaLeaf.Event.tlAddHandler(control, 'focus',  TeaLeaf.Client.tlSetFocusTime, false);
				}				
				if( TeaLeaf.Client.Configuration.tlsendblur ) {
                        		TeaLeaf.Event.tlAddHandler(control, 'blur',   TeaLeaf.Client.tlHandleBlur, false);
				}
				TeaLeaf.Event.tlAddHandler(control, 'change', TeaLeaf.Client.tlAddEvent, false);

				
				item_name = TeaLeaf.Client.tlGetName(control);

				if(item_name == null) break;
				lower_item_name = item_name.toLowerCase();
				map_item = TeaLeaf.Client.Configuration.tlFieldBlockMap[lower_item_name];

				if(map_item == null) break;
				if(map_item["tlfieldname"] == item_name ||
		   	  	   (map_item["caseinsensitive"] && map_item["tlfieldname"] == lower_item_name))
				{
					control.TeaLeafExclude = map_item["eventnovalue"];
					control.TeaLeafReplace = map_item["eventvaluereplace"].length > 0;
				}
				break;
		}

		if(TeaLeaf.Client.Configuration.tlUniversalAttach)	
		{
	 	    var handlers = TeaLeaf.Client.Configuration.tlDocumentHandlers;
		    for(var i=0; i<handlers.length; i++)
	  	    {
	    		    if(handlers[i]["load"])
				    TeaLeaf.Event.tlAddHandler(control, handlers[i]["domevent"], eval(handlers[i]["tlhandler"]), false);
		    }
		}
	}
	/**
    * Attach to INPUT and SELECT. 
    * @param win window object.
    * @addon
    */            	                                                                					
	TeaLeaf.Client.tlCheckIndControls = function(win) {
            try{
                if(win.document){  
                    var items = win.document.getElementsByTagName("INPUT");				    
                    for(var i = 0; i < items.length; i++) {			
                        TeaLeaf.Client.tlCheckAttach(items[i]);
                    }	
                    items = win.document.getElementsByTagName("SELECT");
                    for(var i = 0; i < items.length; i++) {
                        TeaLeaf.Client.tlCheckAttach(items[i]);
                    }
                    items = win.document.getElementsByTagName("BODY"); 
                    if(items.length>0){		
                        items = items[0].getElementsByTagName("*");		       
                        for(var i = 0; i < items.length; i++) {
                            TeaLeaf.Client.tlCheckAttach(items[i]);
                        }
                    }
                }
            }
            catch(e) { }
        }
      
    /**
    * Attach to the given DOM node and all descendants 
    * @param obj DOM object
    * @param ignore_descendants (Optional) boolean to ignore child nodes
    * @addon
    */  
    TeaLeaf.Client.tlProcessNode = function(obj, ignore_descendants) {
	if(typeof(obj) == "string") obj = document.getElementById(obj);
	if(obj == null) return;
        try{
		switch(obj.tagName)
		{
			case "INPUT":
			case "SELECT":
			case "TEXTAREA":
				TeaLeaf.Client.tlCheckAttach(obj);
				break;
			default:
        			if(TeaLeaf.Client.Configuration.tlUniversalAttach && TeaLeaf.Client.tlTagNameAllowed(obj.tagName))
					TeaLeaf.Client.tlCheckAttach(obj);
				break;
		}

		if(!ignore_descendants)
		{
			var explicit_tags = ["INPUT","SELECT","TEXTAREA"];
			for(var i=0; i<explicit_tags.length; i++)
			{
				items = obj.getElementsByTagName(explicit_tags[i]);
                    		for(var j=0; j<items.length; j++)
                        		TeaLeaf.Client.tlCheckAttach(items[j]);
			}

			if(TeaLeaf.Client.Configuration.tlUniversalAttach)
			{
				if(TeaLeaf.Client.Configuration.tlExcludeTags)
				{
           				items = obj.getElementsByTagName("*");
            				for(var i = 0; i < items.length; i++) {
            					if(TeaLeaf.Client.tlTagNameAllowed(items[i].tagName))
                  					TeaLeaf.Client.tlCheckAttach(items[i]);
            				}
				}
				else
				{
					for(var i in TeaLeaf.Client.tlNodeTags)
					{
						items = obj.getElementsByTagName(i);
						for(var j=0; j<items.length; j++)
							TeaLeaf.Client.tlCheckAttach(items[j]);
					}
				}
			}
		}
        }
	catch(e) {}
    }
	/**
    * Handle focus event.
    * @param theEvent DOM event.
    * @requires 
    * TeaLeafClientCfg.js
    * @addon
    */            	                                                                						
	TeaLeaf.Client.tlSetFocusTime = function(theEvent) {
		
		if( ! theEvent ) {
			theEvent = window.event;
		}
		
		var	itemSource = TeaLeaf.Client.tlGetEventSource(theEvent);
		if( ! itemSource || itemSource.type == "application/x-shockwave-flash" ) {
			return;
		}
		
		var	itemSource = TeaLeaf.Client.tlGetEventSource(theEvent);
		if( ! itemSource ) {
			return;
		}
		if( ! itemSource.TeaLeafFocusTime ) {
			itemSource.TeaLeafFocusTime = new Date();
		}
		
		if(TeaLeaf.Client.Configuration.tlsendfocus ) {
			TeaLeaf.Client.tlAddEvent(theEvent);
		}
	}	
	/**
    * Handle blur event.
    * @param theEvent DOM event.
    * @requires 
    * TeaLeafClientCfg.js
    * @addon
    */            	                                                                						
	TeaLeaf.Client.tlHandleBlur = function(theEvent) {
		
		if( ! theEvent ) {
			theEvent = window.event;
		}
		
		var	itemSource = TeaLeaf.Client.tlGetEventSource(theEvent);
		if( ! itemSource || itemSource.type == "application/x-shockwave-flash" ) {
			return;
		}
		TeaLeaf.Client.tlEndVisit(itemSource);
		if(TeaLeaf.Client.checkIsInput(itemSource))
			TeaLeaf.Event.Configuration.tlidoflastvisitedcontrol = TeaLeaf.Client.tlGetName(itemSource);
		
		if( TeaLeaf.Client.Configuration.tlsendblur ) {
			TeaLeaf.Client.tlAddEvent(theEvent);
		}
	}
	/**
    * Last element visited.
    * @param itemSource DOM element.
    * @requires 
    * TeaLeafClientCfg.js
    * @addon
    */            	                                                                						
	TeaLeaf.Client.tlEndVisit = function(itemSource) {
		if( itemSource.TeaLeafFocusTime ) {
			var name = TeaLeaf.Client.tlGetName(itemSource);
			if( ! name ) {
				name = TeaLeaf.Client.tlGetAnchor(itemSource, false);
				if( name ) {
					name = "LEVEL" + name;
				}
				else {
					name = "unnamed";
				}
			}
			var diff = TeaLeaf.Event.tlDateDiff(itemSource.TeaLeafFocusTime, new Date());
			var entry = name + ':' + diff;

			if( TeaLeaf.Event.Configuration.tlvisitorder.length > 0 )
				TeaLeaf.Event.Configuration.tlvisitorder = TeaLeaf.Event.Configuration.tlvisitorder + ";" + entry;
			else
				TeaLeaf.Event.Configuration.tlvisitorder = entry;
		}
	}
	/**
    * Detach from all controls including frames.
    *
    * @requires 
    * TeaLeafClientCfg.js
    * @addon
    */            	                                                                						
	TeaLeaf.Client.tlDetachFromAllControls = function() {
		
		TeaLeaf.Client.Configuration.tlcontrolsattached = false;

		
		TeaLeaf.Client.tlDetachFromControls(window);

		
		try{
			var	ind;
			for(ind = 0; ind < window.frames.length; ind++) {
				var	w = window.frames[ind];
				TeaLeaf.Client.tlDetachFromControls(w);
			}
		}
		catch(e){}
	}
	/**
    * Detach listeners to controls based on the configuration. 
    * @param win window object.
    * @requires 
    * TeaLeafClientCfg.js
    * TeaLeafEvent.js
    * @addon
    */            	                                                                			
	TeaLeaf.Client.tlDetachFromControls = function(win) {
	try{
	    var handlers = TeaLeaf.Client.Configuration.tlWindowHandlers;
	    for(var i=0; i<handlers.length; i++) {
	        var func = eval(handlers[i].tlhandler);
	        TeaLeaf.Event.tlRemoveHandler(win, handlers[i].domevent, func, false);
	    }
	    handlers = TeaLeaf.Client.Configuration.tlDocumentHandlers;
	    for(var i=0; i<handlers.length; i++) {
	        var func = eval(handlers[i].tlhandler);
	        TeaLeaf.Event.tlRemoveHandler(win.document, handlers[i].domevent, func, false);
	    }

	    
	    var items = win.document.getElementsByTagName("INPUT");
	    var i;
	    for(i = 0; i < items.length; i++) {
	        TeaLeaf.Event.tlRemoveHandler(items[i], 'change', TeaLeaf.Client.tlAddEvent, false);
            TeaLeaf.Event.tlRemoveHandler(items[i], 'blur',   TeaLeaf.Client.tlHandleBlur, false);
	        items[i].TeaLeaf = false;
	    }
	    items = win.document.getElementsByTagName("SELECT");
	    for(i = 0; i < items.length; i++) {
	        TeaLeaf.Event.tlRemoveHandler(items[i], 'change', TeaLeaf.Client.tlAddEvent, false);
            TeaLeaf.Event.tlRemoveHandler(items[i], 'blur',   TeaLeaf.Client.tlHandleBlur, false);
	        items[i].TeaLeaf = false;
	    }
	} 
	catch(e) { }
  }
  /**
  * Attach a listener to a specific control. 
  * @param domelement DOM element.
  * @param eventtype TeaLeaf Event type.
  * @param eventHandler Event handler.
  * @requires 
  * TeaLeafEvent.js
  * @addon
  */            	                                                                			  
  TeaLeaf.Client.tlAttachToControl = function(domelement, eventtype, eventHandler) {
    if(eventHandler){
        TeaLeaf.Event.tlAddHandler(domelement, eventtype, eventHandler, false);
    }
    else{
        TeaLeaf.Event.tlAddHandler(domelement, eventtype, eval(TeaLeaf.Client.tlAddEvent), false);
    }
  }
  /**
  * Detach a listener to a specific control. 
  * @param domelement DOM element.
  * @param eventtype TeaLeaf Event type.
  * @param eventHandler Event handler.
  * @requires 
  * TeaLeafEvent.js
  * @addon
  */            	                                                                			  
  TeaLeaf.Client.tlDetachFromControl = function(domelement, eventtype, eventHandler) {
    if(eventHandler){
        TeaLeaf.Event.tlRemoveHandler(domelement, eventtype, eventHandler, false);
    }
    else{
        TeaLeaf.Event.tlRemoveHandler(domelement, eventtype, eval(TeaLeaf.Client.tlAddEvent), false);
    }
  }
  /**
  * Mark the blocked fields based on the configuration. 
  *
  * @requires 
  * TeaLeafClientCfg.js
  * @addon
  */       
  TeaLeaf.Client.tlMarkBlocked = function(items) { 
	
	
	  TeaLeaf.Client.tlMakeFieldBlockMap();
	  if(items == null) items = document.getElementsByTagName("INPUT");

	  for(var i=0; i<items.length; i++)
	  {
		item_name = TeaLeaf.Client.tlGetName(items[i]);
		if(item_name == null) continue;
		lower_item_name = item_name.toLowerCase();
		map_item = TeaLeaf.Client.Configuration[lower_item_name];
		if(map_item == null) continue;
		if(map_item["tlfieldname"] == item_name ||
		   (map_item["caseinsensitive"] && map_item["tlfieldname"] == lower_item_name))
		{
			items[i].TeaLeafExclude = map_item["eventnovalue"];
			items[i].TeaLeafReplace = map_item["eventvaluereplace"].length > 0;
		}
	 }
  }  

  /**
  * Scan the DOM based on a timer set in the configuration and attach
  * to controls that might have been rendered due to a DOM update. 
  *
  * @requires 
  * TeaLeafClientCfg.js
  * @addon
  */            	                                                                			  
   TeaLeaf.Client.tlScanForAdditions = function() {
	   	if(!TeaLeaf.Client.Configuration.tlScheduledScan) return;

		
		
		TeaLeaf.Client.tlProcessNode(document.body);
		
		try{
			for(var i=0; i<window.frames.length; i++) {
				var w = window.frames[i];
				TeaLeaf.Client.tlProcessNode(w.document.body);
				
			}			
		}
		catch(e){}	
		
		window.clearTimeout(TeaLeaf.Client.tlTimeoutID);	
		TeaLeaf.Client.tlTimeoutID = window.setTimeout(TeaLeaf.Client.tlScanForAdditions, TeaLeaf.Client.Configuration.tlscanupdate);		
	}

	TeaLeaf.Client.tlTagNameAllowed = function(tag) {
	    if(tag == null) 
	        return false;
	    var tagVal = TeaLeaf.Client.Configuration.tlNodeTags[tag];	    
	    if(tagVal == null) 
	        tagVal = false; 
	    if(TeaLeaf.Client.Configuration.tlExcludeTags) 
	        return !tagVal;
	    else 
	        return tagVal;
	}

	TeaLeaf.Client.tlMakeFieldBlockMap = function() {
	    if(TeaLeaf.Client.Configuration.tlFieldBlockMap != null) return;
		TeaLeaf.Client.Configuration.tlFieldBlockMap = {};

		var fields = TeaLeaf.Client.Configuration.tlFieldBlock;
		for(var i=0; i<fields.length; i++){
		    name = fields[i]["tlfieldname"];
			if(name == null) continue;
			else name = name.toLowerCase();
			if(fields[i]["caseinsensitive"]) fields[i]["tlfieldname"] = name;
			TeaLeaf.Client.Configuration.tlFieldBlockMap[name] = fields[i];
		}
	}

  /**
  * Start registering DOM listeners based on the config options. 
  * NOTE: This function is ment to be used in SDK mode. 
  *
  * @requires 
  * TeaLeafClientCfg.js
  * @addon
  */            	                                                                			  
   TeaLeaf.Client.tlStartListeners = function() {
   		
		TeaLeaf.Client.tlAttachToAllControls();	
		TeaLeaf.Client.tlSingleAttach();
   }

  /**
  * Unregister DOM listeners based on the config options. 
  * NOTE: This function is ment to be used in SDK mode. 
  *
  * @requires 
  * TeaLeafClientCfg.js
  * @addon
  */            	                                                                			  
   TeaLeaf.Client.tlEndListeners = function() {
   		TeaLeaf.Event.tlFlushQueue(true);
        TeaLeaf.Client.tlDetachFromAllControls();
   }
	
  /**
  * Setup function that attaches to all the controls on the page. 
  * @addon
  */            	                                           
  TeaLeaf.Client.tlSetup = function() {
	  	
		if(typeof TeaLeaf.Cookie != "undefined")
		{
			var queuedXML = TeaLeaf.Cookie.tlGetCookieValue("tlQueuedXML");
			if(queuedXML != null && queuedXML != "")
				TeaLeaf.Event.tlQueuedXML += queuedXML.replace(/%3B/g, ";");
		}

		
		TeaLeaf.Client.tlAttachToAllControls();	
		TeaLeaf.Client.tlSingleAttach();
		
		
		window.OrigOpen = window.open;
		window.open = function(url,name,features,replace) {
			var numberArgs = arguments.length;
			var	status = "blocked";
			var subWin = window.OrigOpen(url, name, features, replace);
			try {
				if(!subWin.closed)
					status = "visible";
			}
			catch(exc) {
				if( TeaLeaf.Event.Configuration.tlshowexceptions ) {
					alert(exc.name + ": " + exc.message + "\r\n\r\nPos 8");
				}
			};
			var	tlevt = new TeaLeaf.Event("GUI", "WindowOpen");	
			var tlAddNameValueArray = new Array("Status", status, 
				                                "Url", escape(url),
				                                "Name", name, 
				                                "Features", features, 
				                                "Replace", replace);
			tlevt.tlAddData(tlAddNameValueArray);
			tlevt.tlSend(); 
			return subWin;
		};	
		
		
		window.clearTimeout(TeaLeaf.Client.tlTimeoutID);
		
		if(TeaLeaf.Client.Configuration.tlscanupdate >0 ){
            TeaLeaf.Client.tlTimeoutID = window.setTimeout(TeaLeaf.Client.tlScanForAdditions, TeaLeaf.Client.Configuration.tlscanupdate);
        }
    }		
	/**
    * Initialize the call to tlSetup UI Client Event
    * Capture is not used as an SDK.
    * @requires
    * TeaLeafEvent.js
    * @addon
    */            	                                           
	TeaLeaf.Client.CallInit = function() {	
        TeaLeaf.Event.tlRemoveHandler(window, "beforeunload", eval(TeaLeaf.Client.tlBeforeUnload), false);
        TeaLeaf.Event.tlRemoveHandler(window, "unload", eval(TeaLeaf.Client.tlUnload), false);
    	TeaLeaf.addOnLoad(TeaLeaf.Client.tlSetup);
	}

    if(TeaLeaf.Client.Configuration.tlinit == false){
        TeaLeaf.Client.Configuration.tlinit = true;
	    TeaLeaf.Client.CallInit();		
	}
}

/*                                                                  
*
* @fileoverview 
* This is the configuration for TeaLeafEnv.js  
*
* @version 2008.11.17.1
*                                                                   
*/
if(typeof TeaLeaf.Env == "undefined"){	
	TeaLeaf.Env = {};

    if(typeof TeaLeaf.Env.Configuration == "undefined"){
        TeaLeaf.Env.Configuration = {
            "tlinit" : false,
            "tlinitpost" : true,
            
            tlPlugins : [
		        {"tlIEplugin": "ShockwaveFlash.ShockwaveFlash.1",         "tlpluginname": "Shockwave Flash",      "tlversion":"1.0",    "tlenable": false},    
		        {"tlIEplugin": "MediaPlayer.MediaPlayer.1",               "tlpluginname": "Windows Media Player", "tlversion":"",    "tlenable": false},
		        {"tlIEplugin": "PDF.PdfCtrl.1",                           "tlpluginname": "Adobe Acrobat",        "tlversion":"",     "tlenable": false},
		        {"tlIEplugin": "QuickTimeCheckObject.QuickTimeCheck.1",   "tlpluginname": "QuickTime",            "tlversion":"",     "tlenable": false}
			]
        };
    }
}

/*                                                                  
*
* @fileoverview
* This file sends Summary about Window, Document, Navigator and Screen 
* objects rendered on the page.
* 
* @requires 
* TeaLeaf.js
* TeaLeafEnvCfg.js
* TeaLeafEvent.js
*
* @version 2008.11.17.1
*                                                                   
*/
if(TeaLeaf.Env && TeaLeaf.Env.Configuration) {		
	/**
    * Send a page summary about Window, Document, Navigator and Screen 
    * object when the page is loaded.
    * @requires
    * TeaLeafEvent.js 
    * @addon
    */            	                                       
	TeaLeaf.Env.tlSendPageSummary = function() {
	    if( TeaLeaf.Configuration.tlSDK == false ){	    
	        if( TeaLeaf.Env.Configuration.tlinitpost == true ) {                 
                TeaLeaf.Env.Configuration.tlinitpost = false; 
                var tlevt = new TeaLeaf.Event("PERFORMANCE", "INIT");
			    TeaLeaf.Event.PageLoadMilliSecs = TeaLeaf.Event.tlDateDiff(TeaLeaf.tlStartLoad, tlevt.date);
                TeaLeaf.Event.SetType = tlevt.EventType;
                
                if(TeaLeaf.Event.SetSubType == ""){
                    TeaLeaf.Event.SetSubType = tlevt.EventSubType;
                }
                else{
                    TeaLeaf.Event.SetSubType += "; " + tlevt.EventSubType;
                }
                TeaLeaf.Event.Configuration.tlinitflag = true;                
                TeaLeaf.Env.tlInfo(tlevt);    
                TeaLeaf.Env.tlDOMDocumentInfo(tlevt);
                TeaLeaf.Env.tlDOMWindowInfo(tlevt);
                TeaLeaf.Env.tlDOMNavigatorInfo(tlevt);
                TeaLeaf.Env.tlDOMScreenInfo(tlevt);
                TeaLeaf.Env.tlPluginInfo(tlevt);
			    tlevt.tlSend(true);
            }
	    }
    }
	/*
    * Gather Basic Info.
    * @param tlevt TeaLeaf event used for reporting on the Document object.  
    * @requires
    * TeaLeafEvent.js 
    * @addon
    */            	                                           
    TeaLeaf.Env.tlInfo = function(tlevt){
        tlevt.tlPushXML("Info");
        var tlAddNameValueArray = new Array("PageLoadMilliSecs", TeaLeaf.Event.tlGetRenderTime(),
				                                    "Version", TeaLeaf.Event.tlGetJSVersion(), 
				                                    "TimezoneOffset", tlevt.date.getTimezoneOffset());
        tlevt.tlAddData(tlAddNameValueArray);  
        tlevt.tlPopXML();
    }
    
	/*
    * Gather Information about the Document object.
    * @param tlevt TeaLeaf event used for reporting on the Document object.  
    * @requires
    * TeaLeafEvent.js 
    * @addon
    */            	                                           
    TeaLeaf.Env.tlDOMDocumentInfo = function(tlevt){
        tlevt.tlPushXML("Document");
        var tlAddNameValueArray1 = new Array("URL", document.URL,
		                                    "Title", document.title,
						                    "Referer", document.referer,
						                    "ContentType", document.contentType,
						                    "LastModified", document.lastModified,
						                    "CharacterSet", document.characterSet,
						                    "Height", document.height,
						                    "Width", document.width);
		tlevt.tlAddData(tlAddNameValueArray1);
        var tlAddNameValueArray2 = new Array("Anchors", document.anchors.length,
						                     "Applets", document.applets.length,
						                     "Embeds", document.embeds.length,
						                     "Forms", document.forms.length,
						                     "Images", document.images.length,
						                     "BadImages", TeaLeaf.Event.tlBadImageCount(),
						                     "Links", document.links.length,
						                     "Plugins", document.plugins.length);
		tlevt.tlAddData(tlAddNameValueArray2);
		tlevt.tlPopXML();
    }
	/**
    * Gather Information about the Window object.
    * @param tlevt TeaLeaf event used for reporting on the Window object.
    * @requires
    * TeaLeafEvent.js 
    * @addon
    */            	                                           
    TeaLeaf.Env.tlDOMWindowInfo = function(tlevt){
	    tlevt.tlPushXML("Window");
	    var tlAddNameValueArray = new Array("WindowHref", escape(window.location.href),
						                    "WindowProtocol", window.location.protocol,
						                    "WindowHost", window.location.host,
						                    "WindowHostName", window.location.hostname,
						                    "WindowPort", window.location.port,
						                    "WindowPathName", window.location.pathname);	
		tlevt.tlAddData(tlAddNameValueArray);
		if( window.innerHeight && window.innerWidth ) {
		    var tlAddNameValueArrayWinClientSize = new Array("ClientSize", window.innerHeight + "x" + window.innerWidth);
		    tlevt.tlAddData(tlAddNameValueArrayWinClientSize);
		}
		else if(document.body) {
		    if(document.body.clientWidth && document.body.clientHeight){
		        var tlAddNameValueArrayDocClientSize = new Array("ClientSize", document.body.clientHeight + "x" + document.body.clientWidth);
                tlevt.tlAddData(tlAddNameValueArrayDocClientSize);
            }
		}
		var tlAddNameValueArrayScreen = new Array("FullScreen", navigator.fullScreen,
						                          "Frames", window.frames.length);
        tlevt.tlAddData(tlAddNameValueArrayScreen);
		tlevt.tlPopXML();
    }
	/**
    * Gather Information about the Navigator object.
    * @param tlevt TeaLeaf event used for reporting on the Navigator object.
    * @requires
    * TeaLeafEvent.js 
    * @addon
    */            	                                           
    TeaLeaf.Env.tlDOMNavigatorInfo = function(tlevt){
	    tlevt.tlPushXML("Navigator");
		
		var tlAddNameValueArray = new Array("AppCodeName", navigator.appCodeName,
						"AppName", navigator.appName,
						"AppVersion", navigator.appVersion,
						"BrowserLanguage", navigator.browserLanguage,
						"CookieEnabled", navigator.cookieEnabled,
						"CPUClass", navigator.cpuClass,
						"Language", navigator.language,
						"OSCPU", navigator.oscpu,
						"Platform", navigator.platform,
						"Product", navigator.product,
						"SystemLanguage", navigator.systemLanguage,
						"UserAgent", navigator.userAgent,
						"UserLanguage", navigator.userLanguage,
						"Vendor", navigator.vendor,
						"VendorSub", navigator.vendorSub);
		tlevt.tlAddData(tlAddNameValueArray);
		tlevt.tlPopXML();
    }    
	/**
    * Gather Information about the Screen object.
    * @param tlevt TeaLeaf event used for reporting on the Navigator object.
    * @requires
    * TeaLeafEvent.js 
    * @addon
    */            	                                           
    TeaLeaf.Env.tlDOMScreenInfo = function(tlevt){ 
 	    tlevt.tlPushXML("Screen");
		
		var tlAddNameValueArray = new Array("AvailHeight", screen.availHeight,
						                    "AvailLeft", screen.availLeft,
						                    "AvailTop", screen.availTop,
						                    "AvailWidth", screen.availWidth,
						                    "BufferDepth", screen.bufferDepth,
						                    "ColorDepth", screen.colorDepth,
						                    "DeviceXDPI", screen.deviceXDPI,
						                    "DeviceYDPI", screen.deviceYDPI,
						                    "FontSmoothingEnabled", screen.fontSmoothingEnabled,
						                    "Height", screen.height,
						                    "Left", screen.left,
						                    "LogicalXDPI", screen.logicalXDPI,
						                    "LogicalYDPI", screen.logicalYDPI,
						                    "Top", screen.top,
						                    "UpdateInterval", screen.updateInterval,
						                    "Width", screen.width);
		tlevt.tlAddData(tlAddNameValueArray);	
		tlevt.tlPopXML();

    }
	/**
    * Gather Information about the available plugins.
    * @param tlevt TeaLeaf event used for reporting on available plugins.
    * @requires
    * TeaLeafEvent.js 
    * @addon
    */            	                                           
    TeaLeaf.Env.tlPluginInfo = function(tlevt){  
        if(window.ActiveXObject){
            for (var i = 0; i <TeaLeaf.Env.Configuration.tlPlugins.length; i++) {
                if(TeaLeaf.Env.Configuration.tlPlugins[i].tlenable){            
                    var tlPlugin = TeaLeaf.Env.Configuration.tlPlugins[i].tlIEplugin;
                    try {
                        var tlActiveX = new ActiveXObject(tlPlugin); 
                        if(tlActiveX){  
                            tlevt.tlPushXML("Plugin");
                            var tlAddNameValueArray = new Array("pluginname", TeaLeaf.Env.Configuration.tlPlugins[i].tlpluginname,
                                                                "version", TeaLeaf.Env.Configuration.tlPlugins[i].tlversion);	               
		                    tlevt.tlAddData(tlAddNameValueArray);	
		                    tlevt.tlPopXML();
                        }
                    }
                    catch(e){}
                }
            }
        }
        else{
          for(var i =0; i <navigator.plugins.length; i++){       
                for(var j =0; j <TeaLeaf.Env.Configuration.tlPlugins.length; j++){               
                    if(TeaLeaf.Env.Configuration.tlPlugins[j].tlenable){                    
                        var tlnavpluginname = navigator.plugins[i].name.substr(0, TeaLeaf.Env.Configuration.tlPlugins[j].tlpluginname.length);    
                        if(tlnavpluginname == TeaLeaf.Env.Configuration.tlPlugins[j].tlpluginname){   
                            TeaLeaf.Env.Configuration.tlPlugins[j].tlenable = false;        
                            tlevt.tlPushXML("Plugin");
                            var tlAddNameValueArray = new Array("pluginname", TeaLeaf.Env.Configuration.tlPlugins[j].tlpluginname,
                                                                "version", TeaLeaf.Env.Configuration.tlPlugins[j].tlversion);
		                    tlevt.tlAddData(tlAddNameValueArray);	
		                    tlevt.tlPopXML();

                        }                           
                    }  
                }
            }        
        } 
    }

	/**
    * Initialize the call to tlSendPageSummary when UI Client Event
    * Capture is not used as an SDK.
    * @addon
    */            	                                           
	TeaLeaf.Env.CallInit = function() {	
        TeaLeaf.addOnLoad(TeaLeaf.Env.tlSendPageSummary);
	}	
	if(TeaLeaf.Env.Configuration.tlinit == false){
	    TeaLeaf.Env.Configuration.tlinit = true;
	    TeaLeaf.Env.CallInit();
	}
}
