/////////////////////////////
// INSTRUCTIONS TO RELEASE:
// remove dojo.debug calls, the dojo.debug require and run through jsmin on the default setting. Copy the result into lib.js
// JSMin will remove all commnets so the easiest way to remove the dojo.debug calls is to search for dojo.debug and replace with '//'
// then remove the require for dojo.debug.
/////////////////////////////
// NOTES: please comment as necessary to aid in readability. the comments wont release 
/////////////////////////////

dojo.require("dojo.dom");
dojo.require("dojo.style");
dojo.require("dojo.debug");
dojo.require("dojo.event");
dojo.require("dojo.widget.Manager");
dojo.require("dojo.widget.Widget");
dojo.require("dojo.widget.Parse");
dojo.require("dojo.widget.validate");
dojo.require("dojo.lang.*");
dojo.require("dojo.event.browser");
dojo.require("dojo.date");
dojo.require("dojo.math");
dojo.require("dojo.widget.Dialog");
dojo.require("dojo.widget.SortableTable");
dojo.require("dojo.widget.html.SortableTable");

/////////////////////////////
// SeeSaw EventManager.js Code
// requires lang.*, event, event.browser
/////////////////////////////		
var eventManager = new function(){
    // Connects and [obj] its [function(String)] to the [targetNode] innerHTML listener
    this.connectOnDOMUpdate = function(targetNode, obj, func){
        if (dojo.render.html.ie) {
            //Connect the IE onafterupdate to divs
            dojo.event.connect(target, 'onafterupdate', obj, func);
            alert("completed ie connect for: " + func);
        }
        else {
            //Everything other than IE connect on DOMSubtreeModified
            dojo.event.browser.addListener(target, "DOMSubtreeModified", hitch(obj, func));
            alert("completed mozilla connect for: " + func);
        }
    }
}


/////////////////////////////
// SeeSaw Optimizer Transition Code
// requires DOM, Style, Debug
/////////////////////////////
dojo.debug("parsing ssn utils");
var ssn = new SSNUtils();
function SSNUtils(){
    this.activateTransition = function(){
        dojo.debug("Starting transition");
        if (document.body) {
            //document.body.style.backgroundColor = "#FFFF";
            dojo.debug("in if");
            dojo.style.setStyle(document.body, "background-color", "rgb(255, 255, 255)");
        }
        else {
            dojo.debug("in else");
            //b.style.backgroundColor = "#FFFF";
            dojo.style.setStyle(document.getElementsByTagName("body")[0], "background-color", "rgb(255, 255, 255)");
        }
        dojo.debug("set bg color");
        var tag = "<" + "img src=\"" + PIU + "\"/" + ">";
        dojo.byId("processingImage").innerHTML = tag;
        //var node = dojo.dom.createDocumentFromText(tag);
        //dojo.byId("processingImage").appendChild(node);
        dojo.debug("appended the child");
        dojo.style.hide(dojo.byId("pageSizer"));
        dojo.style.setStyle(dojo.byId("transition"), "display", "inline");
        dojo.debug("toggled the transition");
    };
}


/////////////////////////////
// SeeSaw Map Code
/////////////////////////////
dojo.debug("parsing map");

var props_detailsDialog = {
    focusElement: "",
    widgetId: "locationDetailDialog",
    bgColor: "#000000",
    bgOpacity: 0.5,
    toggle: "fade",
    toggleDuration: 250
};
var locations;
var points_of_interest;

function MapManager(mapContainerNode){
    this.dialogContents = "locationDetailDialog"; 
    this.closeButtonIds = ["closeLocationDialog", "closeLocationDialogIcon"];
	this.mapNodes=["mapData","mapPager","ssnMapContainer"];
	this.dialogContents="locationDetailDialog";
	this.closeButtonIds=["closeLocationDialog","closeLocationDialogIcon"];
    this.detailDialog = null; // hold dojo dialog for detail dialog of a location
    this.container = mapContainerNode;
	this.dialogRendered = "false";
	this.showInfoWindow = true;
    
    this.icon = null; // holds POI icon
	this.mapSize = "Manual"; 
	this.map = null; // holds map object
	this.markerMgr = null; //holds the Google marker manager
	this.pts = []; // used to center and zoom 
	this.markers = []; // used to batch add markers with marker manager 
	this.eventListeners = []; // used to hold listeners on markers to clean up
	
    this.placeMarker = function(geoPoint, img, desc, xsize, ysize, zIndex){  
			var markerIcon = this.createCustomMarkerImage(img, xsize, ysize);
			var markerOptions = { icon: markerIcon, zIndexProcess: this.ZIndexProcess  };
            var marker = new GMarker(geoPoint, markerOptions);  
			this.markers.push(marker);
//			dojo.debug("lat="+marker.getLatLng().lat()+" long="+marker.getLatLng().lng()+" url="+marker.getIcon().image + "desc="+desc);
			if (this.showInfoWindow) {
				this.eventListeners.push(GEvent.addListener(marker, "click", function(){
					marker.openInfoWindowHtml(desc);
				}));
			}
			marker.zIndex = zIndex  * 1000000 + marker.getLatLng().lat();
			marker.z
//			this.map.addOverlay(marker);
        };  	
    this.createCustomMarkerImage = function (img, xsize, ysize){  
            var myImage = new GIcon();  
			myImage.image = img;
            myImage.iconSize = new GSize(xsize,ysize);
			myImage.iconAnchor = new GPoint(6, 20);
			myImage.infoWindowAnchor = new GPoint(5, 1);  
            return myImage;   
        }; 	
	this.ZIndexProcess = function (marker) {
		return marker.zIndex;
	}
    this.createMap = function(){
		dojo.debug("in create Map");
 		if (this.map==null) {
			this.startMap();
		};
		dojo.event.connect(this,"triggerDialog", dojo.byId(mapManager.dialogTriggerButtonId), "onclick");
		this.clearLocations();
		this.createLocations();
		this.createPOIs();
		this.render();
    };
	this.startMap = function(){
		dojo.debug("creating new GMap");
		this.mapOptions = {}
		if (this.mapWidth != 0 && this.mapHeight != 0) {
			this.mapOptions.size = new GSize(this.mapWidth, this.mapHeight);
		}
		this.map = new GMap2(document.getElementById("map"), this.mapOptions);
		this.resizeMap(this.map, this.pts);
		var mgrOptions = { borderPadding: 50 };
		this.markerMgr = new MarkerManager(this.map, mgrOptions);
	};
	
	this.render = function(){
		this.markerMgr.addMarkers(this.markers,0);  
		this.resizeMap(this.map, this.pts);
		this.map.setUIToDefault();
		this.markerMgr.refresh();
		this.dialogRendered="false";   
	};	
	
   this.createLocations = function(){
   		dojo.debug("starting to  create map locations");
		if (locations != null) {
			this.pts = [];
			var d; // array to iterate over
			var loc; // each value of iteration
			var pt; // new geo pt for the value
			var desc = "";
			d = locations;
			dojo.debug("locations size =" + d.length);
			for (var i = 0; i < d.length; i++) {
				loc = d[i];
				pt = new GLatLng(loc.lat*1, loc.lng*1);
				this.pts.push(pt);
				if (this.showInfoWindow) {
					desc = this.makeMarkerDescription(loc);
				}
				this.placeMarker(pt,loc.icon,desc,this.markerWidth,this.markerHeight);
			};
			dojo.debug("finished creating map locations");
		};
	};	
	this.clearLocations = function (){
		dojo.debug("in clear locations");
		for(var j = 0; j<this.eventListeners.length; ++j){
			GEvent.removeListener(this.eventListeners[j]);
		}
		this.markerMgr.clearMarkers();
		this.markers=[];
		this.eventListeners=[];
		this.pts=[];
	};
	this.renderAddress = function (loc){
		return loc.address + '<br/>'+ loc.city + ','+ loc.state + "&nbsp;" + loc.zip + '<br/>';
	};
	this.renderMeasurement = function(loc){
		return '<b>' + loc.headerPlacements + '</b>' +  "&nbsp;" + loc.placements + '<br/>' +
			'<b>' + loc.headerImpressions + '</b>' + "&nbsp;" + loc.impressions + '<br/>';
	};
	this.renderPrice = function(loc){
		if (loc.CPM != null) {
			return '<b>' + loc.headerCPM + '</b>' + "&nbsp;" + loc.CPM + '<br/>';
		}
		else 
			return "";
	};
	this.renderImage = function (loc){
		return "";
		/**
		 *      TODO: Eventually make these AJAX calls      
		 * 		<span class='thumbnail'>
				<img jwcid="@Any" 
					  src="ognl:renderPhoto()" 
					  width='80' 
					  height='96'/>					  
				<img jwcid="@Image" image="asset:getLocationPicAsset()" width="80" height="96"/>
		 */
	}
	this.renderLink = function (loc){
		// click the hidden Tacos button to tell server to render dialog
		onclickfcn = 'onclick=mapManager.triggerDialog(event)' ;
		//set hidden input so that the server knows which location to use to retrieve details for dialog
		mousedownfcn = 'onmousedown=\"dojo.byId(\'locationHiddenInput\').value =' + loc.locationID + ';\"';
		result = '<a href=\"javascript:tacos.noReturn()\"' + mousedownfcn + onclickfcn + '>' + loc.linkLabel + '</a><br/>';
		//bw = new bw_check();
		//if (!bw.ie8) {
			return result;
		//}
		//else {
		//	return loc.linkLabel;
		//}
	}

	this.makeMarkerDescription = function(loc){
		desc = '<div class="mapMarkerOverlay" style="cursor:pointer">' +
		this.renderImage(loc) +
		'<span class="text">' +
		'<b>' +
		loc.name +
		'</b>' +
		'<br/>' +
		this.renderAddress(loc) +
		this.renderMeasurement(loc) +
		this.renderPrice(loc) +
		this.renderLink(loc) +
		'</span></div>';
		return desc;
	}

	   this.createPOIs = function(){
   		dojo.debug("starting to  create map POIs");
		if (points_of_interest != null) {
			var d; // array to iterate over
			var poi; // each value of iteration
			var pt; // new geo pt for the value
			d = points_of_interest;
			dojo.debug("points of interest size =" + d.length);
			for (var i = 0; i < d.length; i++) {
				poi = d[i];
				pt = new GLatLng(poi.lat * 1, poi.lng * 1); //type conversions
				desc = "<div>" + poi.address + "</div>";
				var yIcon;
				this.placeMarker(pt,this.icon,desc,this.POIWidth,this.POIHeight, this.POIZAxis);
			};
			dojo.debug("finished creating map POis");
		};
	};	
	this.findCenter = function(aPts){
		var start=new YGeoPoint(37,-90);
		if(aPts.length==0) return start;
		var minLat,maxLat, minLon, maxLon, cLat, cLon;
		minLat=maxLat=aPts[0].Lat;
		minLon=maxLon=aPts[0].Lon;
		for(var i=0; i<aPts.length; i++){
			minLat=Math.min(minLat,aPts[i].Lat);
			maxLat=Math.max(maxLat,aPts[i].Lat);
			minLon=Math.min(minLon,aPts[i].Lon);
			maxLon=Math.max(maxLon,aPts[i].Lon);
		}
		cLat=dojo.math.round((minLat+maxLat)/2,6);
		cLon=dojo.math.round((minLon+maxLon)/2,6);
		return new YGeoPoint(cLat,cLon);
	};

	this.resizeMap = function( map, points ){
		var bounds = new GLatLngBounds();
		for ( var k = 0; k < points.length; k++ ) {
		   bounds.extend(points[k]);
		 } 
		map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
	};


    this.ajaxUpdate = function(element, responseElement, elementId){
        dojo.debug("mapManager ajaxUpdate listener");
    };
    
    this.responseComplete = function(responseElements){
        dojo.debug("mapManager Response complete listener");
        for (var i = 0; i < responseElements.length; i++) {
            if (responseElements[i].getAttribute("id") == this.dialogContents) {
                //Details update
                dojo.debug("opening dialog");
                this.openDialog();
            }
        }
    };
	this.triggerDialog = function (event){
		// click the hidden Tacos button to tell server to render dialog
		// dojo advice attached to this function is used to click the button 
		// and send over the event struvtire properly in a browser independent way
	}
    this.openDialog = function(){
        dojo.debug("dialog not created creating");
        this.detailDialog = dojo.widget.createWidget("dialog", props_detailsDialog, dojo.byId(this.dialogContents));
        this.detailDialog.setCloseControl(dojo.byId(this.closeButtonIds[0]));
        this.detailDialog.setCloseControl(dojo.byId(this.closeButtonIds[1]));
        dojo.debug("opening detaildialog");
        this.detailDialog.show();
    };
    this.resizeMessage = function(){
        var left = dojo.style.getInnerWidth(dojo.byId("ssnMapContainer")) / 2 - 130;
        dojo.style.setStyleAttributes(dojo.byId("msgPanelNone"), "width:230px;position:relative;top:-250px;left:" + left + "px;");
    };
	this.cleanup = function(){
		if (!this.dialogRendered) {
			if (this.map != null) {
				this.map.GUnload();
			}
			alert("nulling map");
			this.map = null;
			locations = null;
			points_of_interest = null;
			delete locations;
			delete points_of_interest;
			dojo.event.topic.unsubscribe("updateMap");
			mapElement = dojo.byId('map');
			if (mapElement != null) {
				alert("removing dom node");
				mapElement.parentNode.removeChild(mapElement);
			}
		}
	}
}



/* Modal Dialog object - used to hide the scrollable elements in the document
 * unfortunately we cannot parse all the divs checking for style.overflow
 * because it might cause an unresponsive script dialog
 * so for now just handle textareas and select boxes and in the future
 * enable redefinition of overflow containing selectors and undo after dialog close
 *
 */
function ModalDialog(dialog){
    this.dialog = dialog;
    this.scrollableElements = {};
    this.showScrollBars = function(){
        if (!dojo.render.html.ie) {
            //we are only hiding the nodes so iterate through the scrollabeElements and show them
            for (var node in this.scrollableElements) {
                this.scrollableElements[node].style["display"] = "block";
            }
        }
    };
    this.hideScrollBars = function(){
        if (!dojo.render.html.ie) {
            //grab all textareas, select boxes and toggle display none
            //grab all divs/spans that have calculated overflow and hide them
            var textAreaNodes = document.getElementsByTagName("textarea");
            var selectNodes = document.getElementsByTagName("select");
            var divNodes = document.getElementsByTagName("div");
            var node;
            for (var i = 0; i < textAreaNodes.length; i++) {
                node = textAreaNodes[i];
                dojo.debug("textArea id " + node.id);
                if (dojoSSN.isDescendant(node, dialog)) { // replaced prototype.js Element.descendantOf
                    //node.oldDisplayStyle = node.style["display"];
                    node.style["display"] = "none";
                    this.scrollableElements[node.name] = node;
                }
            }
            for (var i = 0; i < selectNodes.length; i++) {
                node = selectNodes[i];
                dojo.debug("select size " + node.size);
                if (node.getAttribute("size") > 1 && dojoSSN.isDescendant(node, dialog)) { // replaced prototype.js Element.descendantOf
                    //node.oldDisplayStyle = node.style["display"];
                    node.style["display"] = "none";
                    this.scrollableElements[node.name] = node;
                }
            }
            /*
             //this takes too long on the average page
             for(var i = 0; i < divNodes.length; i++){
             node = divNodes[i];
             dojo.debug("div id "+ node.id);
             if(node.style.overflow || node.style.overflowX || node.style.overflowY){
             //dojo.debug("this node is scrollable "+ node.style.overflowX +" "+ node.style.overflowY + " "+ node.style.overflow);
             //node has the ability to be scrollable
             //node.oldDisplayStyle = node.style["display"];
             node.style["display"] = "none";
             this.scrollableElements[node.toString] = node;
             }
             }
             */
        }
    };
}

/////////////////////////////
// SeeSaw Form Code
// requires Debug, Event, base
/////////////////////////////
dojo.debug("parsing field validation");
/**
 fieldValidator - contians the properties of a form field that needs to be validated
 field - the id of the field
 isRequired - is it isRequired to be filled out/checked/selected etc
 missingString/invalidString - the vaidation invalid/isRequired text
 isDojo - is this a dojo validation widget?
 */
//The global form dirty bit
var ssnDirty = 0;

/**
 * The field validator object - this contains the properties for field validation
 */
function fieldValidator(fieldId, isRequired, missingString, invalidString, isDojo, fieldType, length, widgetObj, label, toValidate){
    this.fieldId = fieldId;
    this.isRequired = isRequired;
    this.invalidString = invalidString;
    this.missingString = missingString;
    this.isDojo = isDojo;
    this.fieldType = fieldType;
    this.length = length;
    this.widgetObj = widgetObj;
    this.label = label;
    this.toValidate = toValidate;
}

/**
 * The field invalid message - contains the properties to pass to the message panel
 */
function validationMessage(label, message){
    this.label = label;
    this.message = message;
}

/**
 * The descriptor used for the dirty field information
 */
function dirtyDescriptor(event, label){
    this.label = label;
    this.event = event;
}

dojo.debug("parsing forms");
/**
 * The prototype object for form processing
 */
function SSNBaseForm(){
    this.changedFieldList = [];
    this.focusList = [];
    this.validatorSet = [];
    this.validationErrorMessages = [];
    
    this.showConfirmationDialog = function(){
        dojo.widget.byId("messagingDialog").show();
    };
    
    this.addValidationErrorMessage = function(label, message){
        var m = new validationMessage(label, message);
        this.validationErrorMessages.push(m);
    };
    
    this.preSubmit = function(type){
        switch (type) {
            case "save":
                dojo.debug("save");
                return this.validateForm();
            case "continue":
                dojo.debug("continue");
                return this.validateForm();
            case "update":
                return this.validateForm();
            case "delete":
                return true;
            case "back":
                dojo.debug("back button call");
                return true;
            //if(this.checkDirty()){
            //this.showConfirmationDialog();
            //return this.validateForm();
            //reset dirty
            //	return false;
            //}
            //else{
            //	return true;
            //}
            case "cancel":
                dojo.debug("cancel");
                return true;
            default:
                dojo.debug("default");
                return true;
        }
    };
    
    this.keyPressHandler = function(evnt){
        var charCode;
        if (evnt) {
            charCode = evnt.keyCode;
            if (charCode == 13) {
                dojo.event.topic.publish('enter', evnt);
            }
        }
        else {
            charCode = window.event.keyCode;
            if (charCode == 13) {
                dojo.event.topic.publish('enter', window.event);
            }
        }
        //if(dojo.render.html.ie){
        //try doing
        //event.cancelBubble = true
        //to stop the bing noise in ie
        //}else{
        //event.stopPropagation()
        //}
    };
    
    this.validateForm = function(){
        var index = 0;
        var length = this.validatorSet.length;
        var track = true;
        
        while (index < length) {
            dojo.debug("Required: Loop condition before index: " + index + " length: " + length + " track: " + track);
            // call toValidate, if defined
            if (!this.validatorSet[index].toValidate || this.validatorSet[index].toValidate()) {
                // validate the filed
                track = this.checkRequired(this.validatorSet[index]) && track;
                dojo.debug("field type = " + this.validatorSet[index].fieldType + " " + this.validatorSet[index].length);
            }
            
            index++;
            dojo.debug("Required: Loop condition before index: " + index + " length: " + length + " track: " + track);
        }
        if (!track) {
            window.scroll(0, 0);
            dojo.byId(this.focusList[0]).focus();
            dojo.event.topic.publish("validationWarning", this.validationErrorMessages);
            this.validationErrorMessages = [];
            return false;
        }
        else {
        
            index = 0;
            while (index < length) {
                //dojo.debug("Valid:Loop condition before index: " + index + " length: " + length + " track: " +track);
                // call toValidate, if defined
                if (!this.validatorSet[index].toValidate || this.validatorSet[index].toValidate()) {
                    // validate the filed
                    track = this.checkValid(this.validatorSet[index]) && track;
                }
                
                //dojo.debug("field type = " + this.validatorSet[index].fieldType +" "+ this.validatorSet[index].length);
                index++;
                //dojo.debug("Valid:Loop condition before index: " + index + " length: " + length + " track: " +track);
            }
        }
        if (!track) {
            window.scroll(0, 0);
            //window.scroll(0,0);
            dojo.byId(this.focusList[0]).focus();
            dojo.event.topic.publish("validationError", this.validationErrorMessages);
            this.validationErrorMessages = [];
            return false;
        }
        else {
            return true;
        }
    };
    
    this.checkValid = function(currValidator){
        //dojo.debug("running valid validator ");
        if (currValidator.isDojo && currValidator.isRequired && !currValidator.widgetObj.isEmpty()) {
            //dojo.debug("is dojo validator");
            var field = currValidator.widgetObj;
            //dojo.debug("here - " + field.isEmpty() + currValidator.isRequired);
            if (field.isValid()) {
                return true;
            }
            else {
                this.focusList.push(field.widgetId);
                field.highlight();
                dojo.debug("validation failed 2");
                this.addValidationErrorMessage(currValidator.label, currValidator.invalidString);
                return false;
            }
        }
        else {
            return true;
        }
    };
    
    this.checkRequired = function(currValidator){
        dojo.debug("running required validator ");
        if (currValidator.isDojo) {
            //dojo.debug("is dojo validator");
            var field = currValidator.widgetObj;
            dojo.debug("********here - " + field.isEmpty() + " and " + currValidator.isRequired);
            if (currValidator.isRequired && field.isEmpty()) {
                this.focusList.push(field.widgetId);
                dojo.debug("validation failed 1 on field: " + currValidator.label + " - " + currValidator.fieldId);
                this.addValidationErrorMessage(currValidator.label, currValidator.missingString);
                return false;
            }
            else {
                return true;
            }
        }
        else {
            //dojo.debug("not a dojo validator");
            dojo.debug("******" + currValidator.label + " - " + currValidator.fieldId + " - " + currValidator.isRequired);
            switch (currValidator.fieldType) {
                case "inputfield":
                    //	dojo.debug("FATAL case inputfield");
                    //dojo.debug("Case can't happen");
                    return true;
                case "inputarea":
                    if (currValidator.isRequired) {
                        var value = new String(dojo.byId(currValidator.fieldId).value);
                        value = value.replace(/^\s+|\s+$/g, '');
                        if (value.length > 0 && value.length > currValidator.length) {
                            return true;
                        }
                        else {
                            this.focusList.push(currValidator.fieldId);
                            dojo.debug("validation failed 3");
                            this.addValidationErrorMessage(currValidator.label, currValidator.missingString);
                            return false;
                        }
                    }
                    else {
                        return true;
                    }
                    break;
                case "selectbox":
                    if (currValidator.isRequired) {
                        if (currValidator.length == "single") {
                            if (dojo.byId(currValidator.fieldId).selectedIndex != 0) {
                                return true;
                            }
                            else {
                                this.focusList.push(currValidator.fieldId);
                                dojo.debug("validation failed 4");
                                this.addValidationErrorMessage(currValidator.label, currValidator.missingString);
                                return false;
                            }
                        }
                        else {
                            //dojo.debug("Executing multiple");
                            if (dojo.byId(currValidator.fieldId).selectedIndex > -1) {
                                //dojo.debug("multiple is good: " +dojo.byId(currValidator.fieldId).selectedIndex );
                                return true;
                            }
                            else {
                                this.focusList.push(currValidator.fieldId);
                                dojo.debug("validation failed 6");
                                this.addValidationErrorMessage(currValidator.label, currValidator.missingString);
                                return false;
                            }
                        }
                    }
                    else {
                        return true;
                    }
                    break;
                case "checkbox":
                    //dojo.debug("checkbox id: " + currValidator.fieldId);
                    if (currValidator.isRequired) {
                        if (dojo.byId(currValidator.fieldId).checked) {
                            return true;
                        }
                        else {
                            this.focusList.push(currValidator.fieldId);
                            dojo.debug("validation failed 5");
                            this.addValidationErrorMessage(currValidator.label, currValidator.missingString);
                            return false;
                        }
                    }
                    else {
                        return true;
                    }
                case "datepicker":
                    return true;
                default:
                    dojo.debug("Big problem, this shouldn't happen");
                    return true;
            }
        }
    };
    this.checkDirty = function(){
        dojo.debug("DIRTY IS: " + ssnDirty);
        if (ssnDirty > 0) {
            return true;
        }
        else {
            return false;
        }
    };
    this.resetDirty = function(){
        ssnDirty = 0;
    };
    this.formFieldChangeEventHandler = function(message){
        dojo.debug("modifying dirty " + ssnDirty + " with label " + message.label);
        this.changedFieldList.push(message);
        ssnDirty++;
        dojo.debug("new dirty: " + ssnDirty);
    };
    this.addValidator = function(fieldId, isRequired, missingString, invalidString, isDojo, fieldType, length, widgetObj, label){
        addValidator(fieldId, isRequired, missingString, invalidString, isDojo, fieldType, length, widgetObj, label, null);
    };
    this.addValidator = function(fieldId, isRequired, missingString, invalidString, isDojo, fieldType, length, widgetObj, label, toValidate){
        dojo.debug("adding validator: " + fieldId);
        if (!fieldId) {
            dojo.debug("FATAL: Couldnot get the input object registered named: " + fieldId);
            return;
        }
        this.validatorSet.push(new fieldValidator(fieldId, isRequired, missingString, invalidString, isDojo, fieldType, length, widgetObj, label, toValidate));
    };
    
}

/////////////////////////////
// SeeSaw Keyhandler Code
// requires dojo base
/////////////////////////////
dojo.debug("parsing key handler");
/**
 * Registers a cross-browser on key up handler
 */
function RegisterOnKeyUpHandler(handler){
    if (handler) {
        dojo.debug("registering onkey handler: " + handler);
        if (dojo.render.html.ie) {
            document.attachEvent("onkeyup", handler);
        }
        else {
            document.addEventListener("keyup", handler, false);
        }
    }
}


/////////////////////////////
// SeeSaw Form Focus Code
// requires Debug
/////////////////////////////
dojo.debug("parsing form focus");
/**
 * Sets the focus on the first displayable form field in a given form
 */
function SetFormFieldFocus(form){
    if (form) {
        var ff = form.elements[0];
        var i = 0;
        var l = form.elements.length;
        dojo.debug("Starting focus " + ff.id + " - " + ff);
        dojo.debug("Form element array length is " + l);
        loop: while (i < l) {
            if (ff.type) {
                if (ff.type != "hidden" && ff.type != "checkbox") {
                    if (ff.offsetLeft > 0) { /*dojo.style.isVisible(ff)*/
                        dojo.debug(ff.offsetLeft + "focusing on " + ff.name);
                        ff.focus();
                        if (ff.select) 
                            ff.select();
                        dojo.debug("focus selected");
                        dojo.debug("focus on input type: " + ff.type);
                        break loop;
                    }
                }
            }
            else 
                if (ff.options) {
                    if (ff.offsetLeft > 0) {
                        dojo.debug(ff.offsetLeft + "focusing on " + ff.name);
                        ff.focus();
                        dojo.debug("focus on select box");
                        break loop;
                    }
                }
                else {
                    dojo.debug("focus - not a valid type");
                }
            i++;
            ff = form.elements[i];
            //dojo.debug("continuing focus check "+ ff.id + " - " + ff +" and i: " + i);
        }
        dojo.debug("Focus complete");
    }
}

/////////////////////////////
// SeeSaw Validation Widget Code
// requires widget.validate
/////////////////////////////
dojo.debug("parsing validation widget constructor");
function CreateValidationWidget(name, props, node){
    var v = node.value;
    //dojo.debug("${inputFieldID} has a value of: " + refNode_${inputFieldID}.value);
    var w = dojo.widget.createWidget(name, props, node);
    //dojo.debug("executed inputfield onchange reg");
    //dojo.debug("w post create is- value " + w.textbox.value + " wtype " + w.widgetType + " type " + w.type + " trim " + w.trim + " uc " + w.ucFirst + " lcv " + w.lastCheckedValue + " val " + w.value);
    node.value = v;
    w.textbox.value = v;
    w.lastCheckedValue = v;
    w.value = v;
    return w;
}


/////////////////////////////
// BUTTONS
// requires event.topic, debug
/////////////////////////////
dojo.debug("parsing ajax sub button");
/**
 * AjaxSubmitButton
 * The object for the ajax submit button - contains all the behavior for the tacos buttons
 * param ajaxFormSubmitFncName - the name of the tacos submit func
 * param typeStr - the type of action associated with the submit button
 * param buttonIDStr - the dom ID of the button
 * param formObj - the object associated with the tacos form
 */
function AjaxSubmitButton(ajaxFormSubmitFncName, typeStr, buttonIDStr, formObj, formDomObjString, thisRef){
    this.ASBFnc = ajaxFormSubmitFncName;
    this.type = typeStr;
    this.idStr = buttonIDStr;
    this.formObject = formObj;
    this.formDomObjString = formDomObjString;
    this.t = thisRef;
    
    this.submit = function(event){
        document[this.ASBFnc](event); // The tacos submit funct
        dojo.debug("AjaxSubmitButton - submitting and the event was: " + event[this.type]);
    };
    
    this.topicHandler = function(event){
        dojo.debug("Topic message published: " + event);
        dojo.debug("The event is: " + event[this.type]);
        this.onclick(event);
        dojo.debug("should have clicked idStr"); // someone has requested a click on the interested topic
    };
    
    this.fixButton = function(){
        //this.formObject = dojo.byId(this.formDomObjString);
        if (this.type !== 'none') {
            dojo.event.topic.subscribe(this.type, this, "topicHandler"); /////var -- possibly 'this'
            dojo.debug("subscribing button to topic " + this.type);
        }
        dojo.debug("fixing button - " + this.idStr);
        //Swap out the onclick generated by tacos so we can intercept the click and perform validation, dirty form etc.
        var domObj = dojo.byId(this.idStr); /////var
        dojo.debug("button: " + domObj);
        dojo.event.disconnect(domObj, "onclick", document, this.ASBFnc); /////var
        dojo.debug("disconnected");
        dojo.event.connect(domObj, "onclick", this, "onclick"); /////var
        dojo.debug("connected onclick");
    };
    
    this.onclick = function(event){
        // here we want to delegate the submit requisites in the business requirements to the form ie in validation, dirty form etc.
        dojo.debug("onclick begin");
        var proceed = false;
        dojo.debug("type = " + this.type); /////var
        proceed = this.formObject.preSubmit(this.type); //the form preSubmit will run based on the type //var
        if (proceed) {
            dojo.debug("Form returned true. Submitting the form");
            this.submit(event);
        }
        return;
    };
}

//////////////////////////////
// ROUNDED CORNERS roundCorners.js
//////////////////////////////
dojo.debug("parsing rounded corners");
function roundedCorners(){
    var divs = document.getElementsByTagName('div');
    var rounded_divs = [];
    for (var i = 0; i < divs.length; i++) {
        if (/\brounded\b/.exec(divs[i].className)) {
            rounded_divs[rounded_divs.length] = divs[i];
        }
    }
    for (var i = 0; i < rounded_divs.length; i++) {
        var original = rounded_divs[i];
        /* Make it the inner div of the four */
        original.className = original.className.replace('rounded', 'rounded4');
        /* Now create the outer-most div */
        var tr = document.createElement('div');
        tr.className = 'rounded1';
        /* Swap out the original (we'll put it back later) */
        original.parentNode.replaceChild(tr, original);
        /* Create the two other inner nodes */
        var tl = document.createElement('div');
        tl.className = 'rounded2';
        var br = document.createElement('div');
        br.className = 'rounded3';
        /* Now glue the nodes back in to the document */
        tr.appendChild(tl);
        tl.appendChild(br);
        br.appendChild(original);
    }
}

function roundedSteps(){
    var divs = document.getElementsByTagName('div');
    var rounded_divs = [];
    for (var i = 0; i < divs.length; i++) {
        if (/\bstep\b/.exec(divs[i].className)) {
            rounded_divs[rounded_divs.length] = divs[i];
        }
    }
    for (var i = 0; i < rounded_divs.length; i++) {
        var original = rounded_divs[i];
        /* Make it the inner div of the four */
        original.className = original.className.replace('step', 'step4');
        /* Now create the outer-most div */
        var tr = document.createElement('div');
        tr.className = 'step1';
        /* Swap out the original (we'll put it back later) */
        original.parentNode.replaceChild(tr, original);
        /* Create the two other inner nodes */
        var tl = document.createElement('div');
        tl.className = 'step2';
        var br = document.createElement('div');
        br.className = 'step3';
        /* Now glue the nodes back in to the document */
        tr.appendChild(tl);
        tl.appendChild(br);
        br.appendChild(original);
    }
}


//////////////////////////////
// DatePicker.js code
//////////////////////////////

//
// calendar -- a javascript date picker designed for easy localization.
//
//
//
// Author: Per Norrman (pernorrman@telia.com)
// 
// Based on Tapestry 2.3-beta1 Datepicker by Paul Geerts
// 
// Thanks to:
//     Vladimir [vyc@quorus-ms.ru] for fixing the IE6 zIndex problem.
//
// The normal setup would be to have one text field for displaying the 
// selected date, and one button to show/hide the date picker control.
// This is  the recommended javascript code:
// 
//	<script language="javascript">
//		var cal;
//
//		function init() {
//			cal = new Calendar();
//			cal.setIncludeWeek(true);
//			cal.setFormat("yyyy-MM-dd");
//			cal.setMonthNames(.....);
//			cal.setShortMonthNames(....);
//			cal.create();
//			
//			document.form.button1.onclick = function() {
//				cal.toggle(document.form.button1);
//			}
//			cal.onchange = function() {
//				document.form.textfield1.value  = cal.formatDate();
//			}
//		}
//	</script>
//
// The init function is invoked when the body is loaded.
//
//
dojo.debug("parsing calendar");
function Calendar(date){
    if (arguments.length == 0) {
        this._currentDate = new Date();
        this._selectedDate = null;
    }
    else {
        this._currentDate = new Date(date);
        this._selectedDate = new Date(date);
    }
    
    // Accumulated days per month, for normal and for leap years.
    // Used in week number calculations.	
    Calendar.NUM_DAYS = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
    
    Calendar.LEAP_NUM_DAYS = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335];
    
    
    this._bw = new bw_check();
    this._showing = false;
    this._includeWeek = false;
    this._hideOnSelect = true;
    this._alwaysVisible = false;
    
    this._dateSlot = new Array(42);
    this._weekSlot = new Array(6);
    
    this._firstDayOfWeek = 1;
    this._minimalDaysInFirstWeek = 4;
    
    this._monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
    
    this._shortMonthNames = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
    
    // Week days start with Sunday=0, ... Saturday=6
    this._weekDayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
    
    this._shortWeekDayNames = ["Sun1", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
    
    this._defaultFormat = "yyyy-MM-dd";
    
    this._format = this._defaultFormat;
    
    this._calDiv = null;
    
    this._clearButtonLabel = "Clear";
    
}

/**
 *	CREATE the Calendar DOM element
 */
Calendar.prototype.create = function(){
    var div;
    var table;
    var tbody;
    var tr;
    var td;
    var dp = this;
    
    // Create the top-level div element
    this._calDiv = document.createElement("div");
    this._calDiv.className = "calendar";
    this._calDiv.style.maxWidth = "310px";
    this._calDiv.style.position = "absolute";
    this._calDiv.style.display = "none";
    this._calDiv.style.border = "1px solid WindowText";
    this._calDiv.style.textAlign = "center";
    this._calDiv.style.background = "Window";
    this._calDiv.style.zIndex = "400";
    
    
    // header div
    div = document.createElement("div");
    div.className = "calendarHeader";
    div.style.background = "ActiveCaption";
    div.style.padding = "3px";
    div.style.borderBottom = "1px solid WindowText";
    this._calDiv.appendChild(div);
    
    table = document.createElement("table");
    table.style.cellSpacing = 0;
    div.appendChild(table);
    
    tbody = document.createElement("tbody");
    table.appendChild(tbody);
    
    tr = document.createElement("tr");
    tbody.appendChild(tr);
    
    // Previous Month Button
    td = document.createElement("td");
    this._previousMonth = document.createElement("button");
    this._previousMonth.className = "prevMonthButton"
    this._previousMonth.appendChild(document.createTextNode("<<"));
    //this._previousMonth.appendChild(document.createTextNode(String.fromCharCode(9668)));
    td.appendChild(this._previousMonth);
    tr.appendChild(td);
    
    
    
    //
    // Create the month drop down 
    //
    td = document.createElement("td");
    td.className = "labelContainer";
    tr.appendChild(td);
    this._monthSelect = document.createElement("select");
    for (var i = 0; i < this._monthNames.length; i++) {
        var opt = document.createElement("option");
        opt.innerHTML = this._monthNames[i];
        opt.value = i;
        if (i == this._currentDate.getMonth()) {
            opt.selected = true;
        }
        this._monthSelect.appendChild(opt);
    }
    td.appendChild(this._monthSelect);
    
    
    // 
    // Create the year drop down
    //
    td = document.createElement("td");
    td.className = "labelContainer";
    tr.appendChild(td);
    this._yearSelect = document.createElement("select");
    for (var i = 1920; i < 2050; ++i) {
        var opt = document.createElement("option");
        opt.innerHTML = i;
        opt.value = i;
        if (i == this._currentDate.getFullYear()) {
            opt.selected = false;
        }
        this._yearSelect.appendChild(opt);
    }
    td.appendChild(this._yearSelect);
    
    
    td = document.createElement("td");
    this._nextMonth = document.createElement("button");
    this._nextMonth.appendChild(document.createTextNode(">>"));
    //this._nextMonth.appendChild(document.createTextNode(String.fromCharCode(9654)));
    this._nextMonth.className = "nextMonthButton";
    td.appendChild(this._nextMonth);
    tr.appendChild(td);
    
    // Calendar body
    div = document.createElement("div");
    div.className = "calendarBody";
    this._calDiv.appendChild(div);
    this._table = div;
    
    // Create the inside of calendar body	
    
    var text;
    table = document.createElement("table");
    //table.style.width="100%";
    table.align = "center";
    table.className = "grid";
    table.style.font = "small-caption";
    table.style.fontWeight = "normal";
    table.style.textAalign = "center";
    table.style.color = "WindowText";
    table.style.cursor = "default";
    table.cellPadding = "3";
    table.cellSpacing = "0";
    
    div.appendChild(table);
    var thead = document.createElement("thead");
    table.appendChild(thead);
    tr = document.createElement("tr");
    thead.appendChild(tr);
    
    // weekdays header
    if (this._includeWeek) {
        td = document.createElement("th");
        text = document.createTextNode("w");
        td.appendChild(text);
        td.className = "weekNumberHead";
        td.style.textAlign = "left";
        tr.appendChild(td);
    }
    for (i = 0; i < 7; ++i) {
        td = document.createElement("th");
        text = document.createTextNode(this._shortWeekDayNames[(i + this._firstDayOfWeek) % 7]);
        td.appendChild(text);
        td.className = "weekDayHead";
        td.style.fontWeight = "bold";
        td.style.borderBottom = "1px solid WindowText";
        tr.appendChild(td);
    }
    
    // Date grid
    tbody = document.createElement("tbody");
    table.appendChild(tbody);
    
    for (week = 0; week < 6; ++week) {
        tr = document.createElement("tr");
        tbody.appendChild(tr);
        
        if (this._includeWeek) {
            td = document.createElement("td");
            td.className = "weekNumber";
            td.style.fontWeight = "normal";
            td.style.borderRight = "1px solid WindowText";
            td.style.textAlign = "left";
            text = document.createTextNode(String.fromCharCode(160));
            td.appendChild(text);
            //setCursor(td);
            td.align = "center";
            tr.appendChild(td);
            var tmp = new Object();
            tmp.tag = "WEEK";
            tmp.value = -1;
            tmp.data = text;
            this._weekSlot[week] = tmp;
        }
        
        for (day = 0; day < 7; ++day) {
            td = document.createElement("td");
            text = document.createTextNode(String.fromCharCode(160));
            td.appendChild(text);
            setCursor(td);
            td.align = "center";
            td.style.fontWeight = "normal";
            
            tr.appendChild(td);
            var tmp = new Object();
            tmp.tag = "DATE";
            tmp.value = -1;
            tmp.data = text;
            this._dateSlot[(week * 7) + day] = tmp;
            
        }
    }
    
    // Calendar Footer
    div = document.createElement("div");
    div.className = "calendarFooter";
    this._calDiv.appendChild(div);
    
    table = document.createElement("table");
    //table.style.width="100%";
    table.align = "center";
    table.className = "footerTable";
    table.cellSpacing = 0;
    div.appendChild(table);
    
    tbody = document.createElement("tbody");
    table.appendChild(tbody);
    
    tr = document.createElement("tr");
    tbody.appendChild(tr);
    
    //
    // The TODAY button	
    //
    td = document.createElement("td");
    this._todayButton = document.createElement("button");
    var today = new Date();
    var buttonText = today.getDate() + " " + this._monthNames[today.getMonth()] + ", " + today.getFullYear();
    this._todayButton.appendChild(document.createTextNode(buttonText));
    td.appendChild(this._todayButton);
    tr.appendChild(td);
    
    //
    // The CLEAR button
    //
    td = document.createElement("td");
    this._clearButton = document.createElement("button");
    var today = new Date();
    this._clearButton.appendChild(document.createTextNode(this._clearButtonLabel));
    td.appendChild(this._clearButton);
    tr.appendChild(td);
    
    
    this._update();
    this._updateHeader();
    
    
    
    // IE55+ extension		
    this._previousMonth.hideFocus = true;
    this._nextMonth.hideFocus = true;
    this._todayButton.hideFocus = true;
    // end IE55+ extension
    
    // hook up events
    // buttons
    this._previousMonth.onclick = function(){
        dp.prevMonth();
    };
    
    this._nextMonth.onclick = function(){
        dp.nextMonth();
    };
    
    this._todayButton.onclick = function(){
        dp.setSelectedDate(new Date());
        dp.hide();
    };
    
    this._clearButton.onclick = function(){
        //dp.clearSelectedDate();
        dp.hide();
    };
    
    
    this._calDiv.onselectstart = function(){
        return false;
    };
    
    this._table.onclick = function(e){
        // find event
        if (e == null) 
            e = document.parentWindow.event;
        
        // find td
        var el = e.target != null ? e.target : e.srcElement;
        while (el.nodeType != 1) 
            el = el.parentNode;
        while (el != null && el.tagName && el.tagName.toLowerCase() != "td") 
            el = el.parentNode;
        
        // if no td found, return
        if (el == null || el.tagName == null || el.tagName.toLowerCase() != "td") 
            return;
        
        var d = new Date(dp._currentDate);
        var n = Number(el.firstChild.data);
        if (isNaN(n) || n <= 0 || n == null) 
            return;
        
        if (el.className == "weekNumber") 
            return;
        
        d.setDate(n);
        dp.setSelectedDate(d);
        
        if (!dp._alwaysVisible && dp._hideOnSelect) {
            dp.hide();
        }
        
    };
    
    
    this._calDiv.onkeydown = function(e){
        if (e == null) 
            e = document.parentWindow.event;
        var kc = e.keyCode != null ? e.keyCode : e.charCode;
        
        if (kc == 13) {
            var d = new Date(dp._currentDate).valueOf();
            dp.setSelectedDate(d);
            
            if (!dp._alwaysVisible && dp._hideOnSelect) {
                dp.hide();
            }
            return false;
        }
        
        
        if (kc < 37 || kc > 40) 
            return true;
        
        var d = new Date(dp._currentDate).valueOf();
        if (kc == 37) // left
            d -= 24 * 60 * 60 * 1000;
        else 
            if (kc == 39) // right
                d += 24 * 60 * 60 * 1000;
            else 
                if (kc == 38) // up
                    d -= 7 * 24 * 60 * 60 * 1000;
                else 
                    if (kc == 40) // down
                        d += 7 * 24 * 60 * 60 * 1000;
        
        dp.setCurrentDate(new Date(d));
        return false;
    }
    
    // ie6 extension
    this._calDiv.onmousewheel = function(e){
        if (e == null) 
            e = document.parentWindow.event;
        var n = -e.wheelDelta / 120;
        var d = new Date(dp._currentDate);
        var m = d.getMonth() + n;
        d.setMonth(m);
        
        
        dp.setCurrentDate(d);
        
        return false;
    }
    
    this._monthSelect.onchange = function(e){
        if (e == null) 
            e = document.parentWindow.event;
        e = getEventObject(e);
        dp.setMonth(e.value);
    }
    
    this._monthSelect.onclick = function(e){
        if (e == null) 
            e = document.parentWindow.event;
        e = getEventObject(e);
        e.cancelBubble = true;
    }
    
    this._yearSelect.onchange = function(e){
        if (e == null) 
            e = document.parentWindow.event;
        e = getEventObject(e);
        dp.setYear(e.value);
    }
    
    
    document.body.appendChild(this._calDiv);
    
    
    return this._calDiv;
}

Calendar.prototype._update = function(){


    // Calculate the number of days in the month for the selected date
    var date = this._currentDate;
    var today = toISODate(new Date());
    
    
    var selected = "";
    if (this._selectedDate != null) {
        selected = toISODate(this._selectedDate);
    }
    var current = toISODate(this._currentDate);
    var d1 = new Date(date.getFullYear(), date.getMonth(), 1);
    var d2 = new Date(date.getFullYear(), date.getMonth() + 1, 1);
    var monthLength = Math.round((d2 - d1) / (24 * 60 * 60 * 1000));
    
    // Find out the weekDay index for the first of this month
    var firstIndex = (d1.getDay() - this._firstDayOfWeek) % 7;
    if (firstIndex < 0) {
        firstIndex += 7;
    }
    
    var index = 0;
    while (index < firstIndex) {
        this._dateSlot[index].value = -1;
        this._dateSlot[index].data.data = String.fromCharCode(160);
        this._dateSlot[index].data.parentNode.className = "";
        this._dateSlot[index].data.parentNode.style.fontWeight = "normal";
        this._dateSlot[index].data.parentNode.style.border = "none";
        index++;
    }
    
    for (i = 1; i <= monthLength; i++, index++) {
        this._dateSlot[index].value = i;
        this._dateSlot[index].data.data = i;
        this._dateSlot[index].data.parentNode.className = "";
        this._dateSlot[index].data.parentNode.style.fontWeight = "normal";
        this._dateSlot[index].data.parentNode.style.border = "none";
        if (toISODate(d1) == today) {
            this._dateSlot[index].data.parentNode.className = "today";
            this._dateSlot[index].data.parentNode.style.fontWeight = "bold";
        }
        if (toISODate(d1) == current) {
            this._dateSlot[index].data.parentNode.className += " current";
            this._dateSlot[index].data.parentNode.style.border = "1px dotted WindowText";
            this._dateSlot[index].data.parentNode.style.background = " ";
        }
        if (toISODate(d1) == selected) {
            this._dateSlot[index].data.parentNode.className += " selected";
            this._dateSlot[index].data.parentNode.style.border = "1px solid WindowText";
        }
        d1 = new Date(d1.getFullYear(), d1.getMonth(), d1.getDate() + 1);
    }
    
    var lastDateIndex = index;
    
    while (index < 42) {
        this._dateSlot[index].value = -1;
        this._dateSlot[index].data.data = String.fromCharCode(160);
        this._dateSlot[index].data.parentNode.className = "";
        this._dateSlot[index].data.parentNode.style.fontWeight = "normal";
        this._dateSlot[index].data.parentNode.style.border = "none";
        ++index;
    }
    
    // Week numbers
    if (this._includeWeek) {
        d1 = new Date(date.getFullYear(), date.getMonth(), 1);
        for (i = 0; i < 6; ++i) {
            if (i == 5 && lastDateIndex < 36) {
                this._weekSlot[i].data.data = String.fromCharCode(160);
                this._weekSlot[i].data.parentNode.style.borderRight = "none";
            }
            else {
                week = weekNumber(this, d1);
                this._weekSlot[i].data.data = week;
                this._weekSlot[i].data.parentNode.style.borderRight = "1px solid WindowText";
            }
            d1 = new Date(d1.getFullYear(), d1.getMonth(), d1.getDate() + 7);
        }
    }
}

Calendar.prototype.show = function(element){
    if (!this._showing) {
        var p = getPoint(element);
        this._calDiv.style.display = "block";
        this._calDiv.style.top = (p.y + element.offsetHeight + 1) + "px";
        this._calDiv.style.left = p.x + "px";
        this._showing = true;
        
        /* -------- */
        if (this._bw.ie6) {
            dw = this._calDiv.offsetWidth;
            dh = this._calDiv.offsetHeight;
            var els = document.getElementsByTagName("body");
            var body = els[0];
            if (!body) 
                return;
            
            //paste iframe under the modal
            var underDiv = this._calDiv.cloneNode(false);
            underDiv.style.zIndex = "390";
            underDiv.style.margin = "0px";
            underDiv.style.padding = "0px";
            underDiv.style.display = "block";
            underDiv.style.width = dw;
            underDiv.style.height = dh;
            underDiv.style.border = "1px solid WindowText";
            underDiv.innerHTML = "<iframe width=\"100%\" height=\"100%\" frameborder=\"0\"></iframe>";
            body.appendChild(underDiv);
            this._underDiv = underDiv;
        }
        /* -------- */
        
        if (this._calDiv.focus) 
            this._calDiv.focus();
        
    }
};

Calendar.prototype.hide = function(){
    if (this._showing) {
        this._calDiv.style.display = "none";
        this._showing = false;
        if (this._bw.ie6) {
            if (this._underDiv) 
                this._underDiv.removeNode(true);
        }
    }
}

Calendar.prototype.toggle = function(element){
    if (this._showing) {
        this.hide();
    }
    else {
        this.show(element);
    }
}



Calendar.prototype.onchange = function(){
};


Calendar.prototype.setCurrentDate = function(date){
    if (date == null) {
        return;
    }
    
    // if string or number create a Date object
    if (typeof date == "string" || typeof date == "number") {
        date = new Date(date);
    }
    
    
    // do not update if not really changed
    if (this._currentDate.getDate() != date.getDate() ||
    this._currentDate.getMonth() != date.getMonth() ||
    this._currentDate.getFullYear() != date.getFullYear()) {
    
        this._currentDate = new Date(date);
        
        this._updateHeader();
        this._update();
        
    }
    
}

Calendar.prototype.setSelectedDate = function(date){
    this._selectedDate = new Date(date);
    this.setCurrentDate(this._selectedDate);
    if (typeof this.onchange == "function") {
        this.onchange();
    }
}

Calendar.prototype.clearSelectedDate = function(){
    this._selectedDate = null;
    if (typeof this.onchange == "function") {
        this.onchange();
    }
}

Calendar.prototype.getElement = function(){
    return this._calDiv;
}

Calendar.prototype.setIncludeWeek = function(v){
    if (this._calDiv == null) {
        this._includeWeek = v;
    }
}

Calendar.prototype.setClearButtonLabel = function(v){
    this._clearButtonLabel = v;
}

Calendar.prototype.getSelectedDate = function(){
    if (this._selectedDate == null) {
        return null;
    }
    else {
        return new Date(this._selectedDate);
    }
}

Calendar.prototype.initialize = function(monthNames, shortMonthNames, weekDayNames, shortWeekDayNames, format, firstDayOfWeek, includeWeek, minimalDaysInFirstWeek, clearButtonLabel){
    this.setMonthNames(monthNames);
    this.setShortMonthNames(shortMonthNames);
    this.setWeekDayNames(weekDayNames);
    this.setShortWeekDayNames(shortWeekDayNames);
    this.setFormat(format);
    this.setFirstDayOfWeek(firstDayOfWeek);
    this.setIncludeWeek(includeWeek);
    this.setMinimalDaysInFirstWeek(minimalDaysInFirstWeek);
    this.setClearButtonLabel(clearButtonLabel);
    
    this.create();
}


Calendar.prototype._updateHeader = function(){

    // 
    var options = this._monthSelect.options;
    var m = this._currentDate.getMonth();
    for (var i = 0; i < options.length; ++i) {
        options[i].selected = false;
        if (options[i].value == m) {
            options[i].selected = true;
        }
    }
    
    options = this._yearSelect.options;
    var year = this._currentDate.getFullYear();
    for (var i = 0; i < options.length; ++i) {
        options[i].selected = false;
        if (options[i].value == year) {
            options[i].selected = true;
        }
    }
    
}

Calendar.prototype.setYear = function(year){
    var d = new Date(this._currentDate);
    d.setFullYear(year);
    this.setCurrentDate(d);
}

Calendar.prototype.setMonth = function(month){
    var d = new Date(this._currentDate);
    d.setMonth(month);
    this.setCurrentDate(d);
}

Calendar.prototype.nextMonth = function(){
    this.setMonth(this._currentDate.getMonth() + 1);
}

Calendar.prototype.prevMonth = function(){
    this.setMonth(this._currentDate.getMonth() - 1);
}

Calendar.prototype.setFirstDayOfWeek = function(nFirstWeekDay){
    this._firstDayOfWeek = nFirstWeekDay;
}

Calendar.prototype.getFirstDayOfWeek = function(){
    return this._firstDayOfWeek;
}

Calendar.prototype.setMinimalDaysInFirstWeek = function(n){
    this._minimalDaysInFirstWeek = n;
}


Calendar.prototype.getMinimalDaysInFirstWeek = function(){
    return this._minimalDaysInFirstWeek;
}

Calendar.prototype.setMonthNames = function(a){
    // sanity test
    this._monthNames = a;
}

Calendar.prototype.setShortMonthNames = function(a){
    // sanity test
    this._shortMonthNames = a;
}

Calendar.prototype.setWeekDayNames = function(a){
    // sanity test
    this._weekDayNames = a;
}

Calendar.prototype.setShortWeekDayNames = function(a){
    // sanity test
    this._shortWeekDayNames = a;
}

Calendar.prototype.getFormat = function(){
    return this._format;
}

Calendar.prototype.setFormat = function(f){
    this._format = f;
}

Calendar.prototype.formatDate = function(){
    if (this._selectedDate == null) {
        return "";
    }
    
    var bits = new Array();
    // work out what each bit should be
    var date = this._selectedDate;
    bits['d'] = date.getDate();
    bits['dd'] = pad(date.getDate(), 2);
    bits['ddd'] = this._shortWeekDayNames[date.getDay()];
    bits['dddd'] = this._weekDayNames[date.getDay()];
    
    bits['M'] = date.getMonth() + 1;
    bits['MM'] = pad(date.getMonth() + 1, 2);
    bits['MMM'] = this._shortMonthNames[date.getMonth()];
    bits['MMMM'] = this._monthNames[date.getMonth()];
    
    var yearStr = "" + date.getFullYear();
    yearStr = (yearStr.length == 2) ? '19' + yearStr : yearStr;
    bits['yyyy'] = yearStr;
    bits['yy'] = bits['yyyy'].toString().substr(2, 2);
    
    bits['s'] = date.getSeconds();
    bits['ss'] = pad(date.getSeconds(), 2);
    
    bits['m'] = date.getMinutes();
    bits['mm'] = pad(date.getMinutes(), 2);
    
    bits['H'] = date.getHours();
    bits['HH'] = pad(date.getHours(), 2);
    
    // do some funky regexs to replace the format string
    // with the real values
    var frm = new String(this._format);
    // TAPESTRY-669: Have to be very explicit about keys, to keep functions added
    // to Array (by the Prototype library, if its around) from getting mixed in.
    var keys = new Array('d', 'dd', 'ddd', 'dddd', 'M', 'MM', 'MMM', 'MMMM', 'yyyy', 'yy', 's', 'ss', 'm', 'mm', 'H', 'HH');
    for (var i = 0; i < keys.length; i++) {
        frm = eval("frm.replace(/\\b" + keys[i] + "\\b/,\"" + bits[keys[i]] + "\");");
    }
    
    return frm;
}


function isLeapYear(year){
    return ((year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)));
}

function yearLength(year){
    if (isLeapYear(year)) 
        return 366;
    else 
        return 365;
}

function dayOfYear(date){
    var a = Calendar.NUM_DAYS;
    if (isLeapYear(date.getFullYear())) {
        a = Calendar.LEAP_NUM_DAYS;
    }
    var month = date.getMonth();
    
    return a[month] + date.getDate();
}

// ---------------------------------------------
// Week number stuff
// ---------------------------------------------

function weekNumber(cal, date){

    var dow = date.getDay();
    var doy = dayOfYear(date);
    var year = date.getFullYear();
    
    // Compute the week of the year.  Valid week numbers run from 1 to 52
    // or 53, depending on the year, the first day of the week, and the
    // minimal days in the first week.  Days at the start of the year may
    // fall into the last week of the previous year; days at the end of
    // the year may fall into the first week of the next year.
    var relDow = (dow + 7 - cal.getFirstDayOfWeek()) % 7; // 0..6
    var relDowJan1 = (dow - doy + 701 - cal.getFirstDayOfWeek()) % 7; // 0..6
    var week = Math.floor((doy - 1 + relDowJan1) / 7); // 0..53
    if ((7 - relDowJan1) >= cal.getMinimalDaysInFirstWeek()) {
        ++week;
    }
    
    if (doy > 359) { // Fast check which eliminates most cases
        // Check to see if we are in the last week; if so, we need
        // to handle the case in which we are the first week of the
        // next year.
        var lastDoy = yearLength(year);
        var lastRelDow = (relDow + lastDoy - doy) % 7;
        if (lastRelDow < 0) {
            lastRelDow += 7;
        }
        if (((6 - lastRelDow) >= cal.getMinimalDaysInFirstWeek()) &&
        ((doy + 7 - relDow) > lastDoy)) {
            week = 1;
        }
    }
    else 
        if (week == 0) {
            // We are the last week of the previous year.
            var prevDoy = doy + yearLength(year - 1);
            week = weekOfPeriod(cal, prevDoy, dow);
        }
    
    return week;
}

function weekOfPeriod(cal, dayOfPeriod, dayOfWeek){
    // Determine the day of the week of the first day of the period
    // in question (either a year or a month).  Zero represents the
    // first day of the week on this calendar.
    var periodStartDayOfWeek = (dayOfWeek - cal.getFirstDayOfWeek() - dayOfPeriod + 1) % 7;
    if (periodStartDayOfWeek < 0) {
        periodStartDayOfWeek += 7;
    }
    
    // Compute the week number.  Initially, ignore the first week, which
    // may be fractional (or may not be).  We add periodStartDayOfWeek in
    // order to fill out the first week, if it is fractional.
    var weekNo = Math.floor((dayOfPeriod + periodStartDayOfWeek - 1) / 7);
    
    // If the first week is long enough, then count it.  If
    // the minimal days in the first week is one, or if the period start
    // is zero, we always increment weekNo.
    if ((7 - periodStartDayOfWeek) >= cal.getMinimalDaysInFirstWeek()) {
        ++weekNo;
    }
    
    return weekNo;
}




function getEventObject(e){ // utility function to retrieve object from event
    if (navigator.appName == "Microsoft Internet Explorer") {
        return e.srcElement;
    }
    else { // is mozilla/netscape
        // need to crawl up the tree to get the first "real" element
        // i.e. a tag, not raw text
        var o = e.target;
        while (!o.tagName) {
            o = o.parentNode;
        }
        return o;
    }
}

function addEvent(name, obj, funct){ // utility function to add event handlers
    if (navigator.appName == "Microsoft Internet Explorer") {
        obj.attachEvent("on" + name, funct);
    }
    else { // is mozilla/netscape
        obj.addEventListener(name, funct, false);
    }
}


function deleteEvent(name, obj, funct){ // utility function to delete event handlers
    if (navigator.appName == "Microsoft Internet Explorer") {
        obj.detachEvent("on" + name, funct);
    }
    else { // is mozilla/netscape
        obj.removeEventListener(name, funct, false);
    }
}

function setCursor(obj){
    if (navigator.appName == "Microsoft Internet Explorer") {
        obj.style.cursor = "hand";
    }
    else { // is mozilla/netscape
        obj.style.cursor = "pointer";
    }
}

function Point(iX, iY){
    this.x = iX;
    this.y = iY;
}


function getPoint(aTag){
    var oTmp = aTag;
    var point = new Point(0, 0);
    
    do {
        point.x += oTmp.offsetLeft;
        point.y += oTmp.offsetTop;
        oTmp = oTmp.offsetParent;
    }
    while (oTmp.tagName != "BODY" && oTmp.tagName != "HTML");
    
    return point;
}

function toISODate(date){
    var s = date.getFullYear();
    var m = date.getMonth() + 1;
    if (m < 10) {
        m = "0" + m;
    }
    var day = date.getDate();
    if (day < 10) {
        day = "0" + day;
    }
    return String(s) + String(m) + String(day);
    
}

function pad(number, X){ // utility function to pad a number to a given width
    X = (!X ? 2 : X);
    number = "" + number;
    while (number.length < X) {
        number = "0" + number;
    }
    return number;
}

function bw_check(){
    var is_major = parseInt(navigator.appVersion);
    this.nver = is_major;
    this.ver = navigator.appVersion;
    this.agent = navigator.userAgent;
    this.dom = document.getElementById ? 1 : 0;
    this.opera = window.opera ? 1 : 0;
    this.ie5 = (this.ver.indexOf("MSIE 5") > -1 && this.dom && !this.opera) ? 1 : 0;
    this.ie6 = (this.ver.indexOf("MSIE 6") > -1 && this.dom && !this.opera) ? 1 : 0;
	this.ie7 = (this.ver.indexOf("MSIE 7") > -1 && this.dom && !this.opera) ? 1 : 0;
	this.ie8 = (this.ver.indexOf("MSIE 8") > -1 && this.dom && !this.opera) ? 1 : 0;
    this.ie4 = (document.all && !this.dom && !this.opera) ? 1 : 0;
    this.ie = this.ie4 || this.ie5 || this.ie6;
    this.mac = this.agent.indexOf("Mac") > -1;
    this.ns6 = (this.dom && parseInt(this.ver) >= 5) ? 1 : 0;
    this.ie3 = (this.ver.indexOf("MSIE") && (is_major < 4));
    this.hotjava = (this.agent.toLowerCase().indexOf('hotjava') != -1) ? 1 : 0;
    this.ns4 = (document.layers && !this.dom && !this.hotjava) ? 1 : 0;
    this.bw = (this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera);
    this.ver3 = (this.hotjava || this.ie3);
    this.opera7 = ((this.agent.toLowerCase().indexOf('opera 7') > -1) || (this.agent.toLowerCase().indexOf('opera/7') > -1));
    this.operaOld = this.opera && !this.opera7;
    return this;
};


////////////////////////////////
//text wrap adjust for bullit lists
////////////////////////////////
function bullitListAdjust(){

    var exploreHmNetworkLiSpans = dojoSSN.query("div.exploreHomeNetworkList ul.bullet li span");
    var exploreHmLifePatternLiSpans = dojoSSN.query("div.exploreHomeLifePatternList ul.bullet li span");
    
    exploreHmNetworkLiSpans.filter(function(item){
        if (item.innerHTML.length >= 42) {
            return (item);
        }
    }).forEach(function(item){
        dojoSSN.style(item.parentNode.parentNode, "height", "3em");
    });
    
    exploreHmLifePatternLiSpans.filter(function(item){
        console.log("exploreHmLifePatternLiSpans length: " + item.innerHTML.length)
        if (item.innerHTML.length >= 23) {
            return (item);
        }
    }).forEach(function(item){
        dojoSSN.style(item.parentNode.parentNode, "height", "3em");
    });
    
}


////////////////////////////////
// tbody scrollContent DOM height adjuster
// for when the number of rows does not fill the height of the tbody
////////////////////////////////
function tbodyScrollContentAdjust(){

    var tbodyNode, tbodyTR;
    
    if (dojoSSN.query("#campaignsTable_DojoTable tbody")) {
        tbodyNode = dojoSSN.query("#campaignsTable_DojoTable tbody");
        tbodyTR = dojoSSN.query("#campaignsTable_DojoTable tbody > tr");
        if (tbodyTR.length <= 13) {
            tbodyNode.style("height", "auto");
        }
    }
    
    if (dojoSSN.query("div.typicalPricingTable tbody")) {
        tbodyNode = dojoSSN.query("div.typicalPricingTable tbody");
        tbodyTR = dojoSSN.query("div.typicalPricingTable tbody > tr");
        if (tbodyTR.length <= 13) {
            tbodyNode.style("height", "auto");
        }
    }
    
    if (dojoSSN.query("#networkTable tbody")) {
        tbodyNode = dojoSSN.query("#networkTable tbody");
        tbodyTR = dojoSSN.query("#networkTable tbody > tr");
        if (tbodyTR.length <= 20) {
            tbodyNode.style("height", "auto");
        }
    }
    
    if (dojoSSN.query("#geoSummaryTable_Wrapper tbody")) {
        tbodyNode = dojoSSN.query("#geoSummaryTable_Wrapper tbody");
        tbodyTR = dojoSSN.query("#geoSummaryTable_Wrapper tbody > tr");
        if (tbodyTR.length <= 11) {
            tbodyNode.style("height", "auto");
        }
    }
    
    if (dojoSSN.query("#placeSummaryTable_Wrapper tbody")) {
        tbodyNode = dojoSSN.query("#placeSummaryTable_Wrapper tbody");
        tbodyTR = dojoSSN.query("#placeSummaryTable_Wrapper tbody > tr");
        if (tbodyTR.length <= 8) {
            tbodyNode.style("height", "auto");
        }
    }
    
    if (dojoSSN.query("#CampaignSummaryDemoIndexTable_Wrapper tbody")) {
        tbodyNode = dojoSSN.query("#CampaignSummaryDemoIndexTable_Wrapper tbody");
        tbodyTR = dojoSSN.query("#CampaignSummaryDemoIndexTable_Wrapper tbody > tr");
        if (tbodyTR.length <= 8) {
            tbodyNode.style("height", "auto");
        }
    }
    
    if (dojoSSN.query("#geoSummaryDemoIndexTable_Wrapper tbody")) {
        tbodyNode = dojoSSN.query("#geoSummaryDemoIndexTable_Wrapper tbody");
        tbodyTR = dojoSSN.query("#geoSummaryDemoIndexTable_Wrapper tbody > tr");
        if (tbodyTR.length <= 11) {
            tbodyNode.style("height", "auto");
        }
    }
    
    if (dojoSSN.query("#placeSummaryDemoIndexTable_Wrapper tbody")) {
        tbodyNode = dojoSSN.query("#placeSummaryDemoIndexTable_Wrapper tbody");
        tbodyTR = dojoSSN.query("#placeSummaryDemoIndexTable_Wrapper tbody > tr");
        if (tbodyTR.length <= 8) {
            tbodyNode.style("height", "auto");
        }
    }
    
    if (dojoSSN.query("#demoTable_Wrapper tbody")) {
        tbodyNode = dojoSSN.query("#demoTable_Wrapper tbody");
        tbodyTR = dojoSSN.query("#demoTable_Wrapper tbody > tr");
        if (tbodyTR.length <= 13) {
            tbodyNode.style("height", "auto");
        }
    }
    
    //	if (dojoSSN.query("#networkTable tbody")){
    //		tbodyNode = dojoSSN.query("div.exploreTable div.tableContainer");//note: query's NOT a tbody node but a table wrapper
    //		tbodyTR = dojoSSN.query("#networkTable tbody > tr");
    //		if (tbodyTR.length <= 14) {
    //			tbodyNode.style("height", "auto");
    //		}
    //	}
}

//////////////////////////////
// PROGRAMATIC DATA GRIDS
//////////////////////////////




//////////////////////////////
// TIP BUBBLE CODE old tipBubble.js
//////////////////////////////
dojo.debug("parsing toolitps");
function enableTooltips(id){
    var links, i, h;
    if (!document.getElementById || !document.getElementsByTagName) 
        return;
    AddCss();
    h = document.createElement("span");
    h.id = "btc";
    h.setAttribute("id", "btc");
    h.style.position = "absolute";
    document.getElementsByTagName("body")[0].appendChild(h);
    links = dojo.html.getElementsByClassName("fieldHelp");
    /*if(id==null) links=document.getElementsByTagName("a");
     else links=document.getElementById(id).getElementsByTagName("a");
     */
    for (i = 0; i < links.length; i++) {
        Prepare(links[i]);
    }
}

function Prepare(el){
    var tooltip, t, b, s, l;
    t = el.getAttribute("title");
    if (t == null || t.length == 0) 
        t = "link:";
    el.removeAttribute("title");
    tooltip = CreateEl("span", "tooltip");
    s = CreateEl("span", "top");
    s.appendChild(document.createTextNode(t));
    tooltip.appendChild(s);
    b = CreateEl("b", "bottom");
    /* Commenting out the creation of the href element
     l=el.getAttribute("href");
     if(l.length>28) l=l.substr(0,25)+"...";
     b.appendChild(document.createTextNode(l));*/
    tooltip.appendChild(b);
    setOpacity(tooltip);
    el.tooltip = tooltip;
    el.onmouseover = showTooltip;
    el.onmouseout = hideTooltip;
    el.onmousemove = Locate;
}

function showTooltip(e){
    document.getElementById("btc").appendChild(this.tooltip);
    Locate(e);
}

function hideTooltip(e){
    var d = document.getElementById("btc");
    if (d.childNodes.length > 0) 
        d.removeChild(d.firstChild);
}

function setOpacity(el){
    el.style.filter = "alpha(opacity:95)";
    el.style.KHTMLOpacity = "0.95";
    el.style.MozOpacity = "0.95";
    el.style.opacity = "0.95";
}

function CreateEl(t, c){
    var x = document.createElement(t);
    x.className = c;
    x.style.display = "block";
    return (x);
}

function AddCss(){
    /*var l=CreateEl("link");
    
     l.setAttribute("type","text/css");
    
     l.setAttribute("rel","stylesheet");
    
     l.setAttribute("href","../css/tipBubble.css");
    
     l.setAttribute("media","screen");
    
     document.getElementsByTagName("head")[0].appendChild(l);
    
     */
    
}

function Locate(e){
    var posx = 0, posy = 0;
    if (e == null) 
        e = window.event;
    if (e.pageX || e.pageY) {
        posx = e.pageX;
        posy = e.pageY;
    }
    else 
        if (e.clientX || e.clientY) {
            if (document.documentElement.scrollTop) {
                posx = e.clientX + document.documentElement.scrollLeft;
                posy = e.clientY + document.documentElement.scrollTop;
            }
            else {
                posx = e.clientX + document.body.scrollLeft;
                posy = e.clientY + document.body.scrollTop;
            }
        }
    document.getElementById("btc").style.top = (posy + 10) + "px";
    document.getElementById("btc").style.left = (posx - 20) + "px";
}

dojo.debug("parsing analytics");
//////////////////////////////
// WEBANALYTICS CODE
// 
/////////////////////////////
function convertToAnalyticsKeyValue(key, value, varType){
    //sample
    //;NY;;;;evar5=Area,
    return ";" + value + ";;;;" + varType + "=" + key + ",";
}

/**
 * The web analytics object responsible for compiling the webanalytics information
 */
function WebAnalytics(){
    this.products = "";
    this.reset = function(){
        this.products = "";
    };
    this.init = function(){
        // set up the subscription
        dojo.event.topic.subscribe("addToCart", WebAnalytics, "cartTopicHandler");
        dojo.event.topic.subscribe("webAnalytics", WebAnalytics, "generalTopicHandler");
    };
    this.cartTopicHandler = function(msg){
        if (msg) {
            this.products += msg;
        }
    };
    this.generalTopicHandler = function(msg){
    
    };
    this.setPrototype = function(){
    
    };
}

var webAnalytics = new WebAnalytics();

//////////////////////////////
// OMNITURE WEBANALYTICS CODE
// DON'T CHANGE ANYTHING !!!! SERIOUSLY
/////////////////////////////
function s_doPlugins(s){
    if (!s.campaign) {
        s.campaign = s.getQueryParam('cmpid');
        s.campaign = s.getValOnce(s.campaign, 's_campaign', 0);
    }
    if (s.prop1) {
        s.prop1 = s.prop1.toLowerCase();
    }
    if (s.prop1) {
        s.eVar1 = s.prop1;
        var t_search = s.getValOnce(s.eVar1, 'ev1', 0);
        if (t_search) {
            s.events = s.apl(s.events, 'event1', ',', 1);
        }
    }
}

function initWebAnalytics(){
    /************************** CONFIG SECTION **************************/
    /* You may add or alter any code config here. */
    /* Link Tracking Config */
    s.trackDownloadLinks = true;
    s.trackExternalLinks = true;
    s.trackInlineStats = true;
    s.linkDownloadFileTypes = "exe,zip,wav,mp3,mov,mpg,avi,wmv,doc,pdf,xls";
    s.linkLeaveQueryString = false;
    s.linkTrackVars = "None";
    s.linkTrackEvents = "None";
    s.usePlugins = true;
    s.doPlugins = s_doPlugins;
    /************************** PLUGINS SECTION *************************/
    /*
     * Plugin: getQueryParam 2.1 - return query string parameter(s)
     */
    s.getQueryParam = new Function("p", "d", "u", "" +
    "var s=this,v='',i,t;d=d?d:'';u=u?u:(s.pageURL?s.pageURL:s.wd.locati" +
    "on);if(u=='f')u=s.gtfs().location;while(p){i=p.indexOf(',');i=i<0?p" +
    ".length:i;t=s.p_gpv(p.substring(0,i),u+'');if(t)v+=v?d+t:t;p=p.subs" +
    "tring(i==p.length?i:i+1)}return v");
    s.p_gpv = new Function("k", "u", "" +
    "var s=this,v='',i=u.indexOf('?'),q;if(k&&i>-1){q=u.substring(i+1);v" +
    "=s.pt(q,'&','p_gvf',k)}return v");
    s.p_gvf = new Function("t", "k", "" +
    "if(t){var s=this,i=t.indexOf('='),p=i<0?t:t.substring(0,i),v=i<0?'T" +
    "rue':t.substring(i+1);if(p.toLowerCase()==k.toLowerCase())return s." +
    "epa(v)}return ''");
    /*
     * Plugin: getValOnce 0.2 - get a value once per session or number of days
     */
    s.getValOnce = new Function("v", "c", "e", "" +
    "var s=this,k=s.c_r(c),a=new Date;e=e?e:0;if(v){a.setTime(a.getTime(" +
    ")+e*86400000);s.c_w(c,v,e?a:0);}return v==k?'':v");
    /*
     * Plugin Utility: apl v1.1
     */
    s.apl = new Function("L", "v", "d", "u", "" +
    "var s=this,m=0;if(!L)L='';if(u){var i,n,a=s.split(L,d);for(i=0;i<a." +
    "length;i++){n=a[i];m=m||(u==1?(n==v):(n.toLowerCase()==v.toLowerCas" +
    "e()));}}if(!m)L=L?L+d+v:v;return L");
    /*
     * Utility Function: split v1.5 - split a string (JS 1.0 compatible)
     */
    s.split = new Function("l", "d", "" +
    "var i,x=0,a=new Array;while(l){i=l.indexOf(d);i=i>-1?i:l.length;a[x" +
    "++]=l.substring(0,i);l=l.substring(i+d.length);}return a");
    
    /* WARNING: Changing any of the below variables will cause drastic
     changes to how your visitor data is collected.  Changes should only be
     made when instructed to do so by your account manager.*/
    s.trackingServer = "stats.seesawnetworks.com";
    //s.trackingServerSecure="sstats.seesawnetworks.com";
    s.visitorNamespace = "seesawnetworks";
    s.dc = 112;
}

/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
var s_objectID;
function s_c2fe(f){
    var x = '', s = 0, e, a, b, c;
    while (1) {
        e = f.indexOf('"', s);
        b = f.indexOf('\\', s);
        c = f.indexOf("\n", s);
        if (e < 0 ||
        (b >=
        0 &&
        b < e)) 
            e = b;
        if (e < 0 || (c >= 0 && c < e)) 
            e = c;
        if (e >= 0) {
            x += (e > s ? f.substring(s, e) : '') +
            (e == c ? '\\n' : '\\' + f.substring(e, e + 1));
            s = e + 1
        }
        else 
            return x +
            f.substring(s)
    }
    return f
}

function s_c2fa(f){
    var s = f.indexOf('(') + 1, e = f.indexOf(')'), a = '', c;
    while (s >= 0 && s < e) {
        c = f.substring(s, s + 1);
        if (c == ',') 
            a += '","';
        else 
            if (("\n\r\t ").indexOf(c) < 0) 
                a += c;
        s++
    }
    return a ? '"' + a + '"' : a
}

function s_c2f(cc){
    cc = '' + cc;
    var fc = 'var f=new Function(', s = cc.indexOf(';', cc.indexOf('{')), e = cc.lastIndexOf('}'), o, a, d, q, c, f, h, x
    fc += s_c2fa(cc) + ',"var s=new Object;';
    c = cc.substring(s + 1, e);
    s = c.indexOf('function');
    while (s >= 0) {
        d = 1;
        q = '';
        x = 0;
        f = c.substring(s);
        a = s_c2fa(f);
        e = o = c.indexOf('{', s);
        e++;
        while (d > 0) {
            h = c.substring(e, e + 1);
            if (q) {
                if (h == q && !x) 
                    q = '';
                if (h == '\\') 
                    x = x ? 0 : 1;
                else 
                    x = 0
            }
            else {
                if (h == '"' || h == "'") 
                    q = h;
                if (h == '{') 
                    d++;
                if (h == '}') 
                    d--
            }
            if (d > 0) 
                e++
        }
        c = c.substring(0, s) +
        'new Function(' +
        (a ? a + ',' : '') +
        '"' +
        s_c2fe(c.substring(o + 1, e)) +
        '")' +
        c.substring(e + 1);
        s = c.indexOf('function')
    }
    fc += s_c2fe(c) + ';return s");'
    eval(fc);
    return f
}

function s_gi(un, pg, ss){
    var c = "function s_c(un,pg,s" +
    "s){var s=this;s.wd=window;if(!s.wd.s_c_in){s.wd.s_c_il=new Array;s." +
    "wd.s_c_in=0;}s._il=s.wd.s_c_il;s._in=s.wd.s_c_in;s._il[s._in]=s;s.w" +
    "d.s_c_in++;s.m=function(m){return (''+m).indexOf('{')<0};s.fl=funct" +
    "ion(x,l){return x?(''+x).substring(0,l):x};s.co=function(o){if(!o)r" +
    "eturn o;var n=new Object,x;for(x in o)if(x.indexOf('select')<0&&x.i" +
    "ndexOf('filter')<0)n[x]=o[x];return n};s.num=function(x){x=''+x;for" +
    "(var p=0;p<x.length;p++)if(('0123456789').indexOf(x.substring(p,p+1" +
    "))<0)return 0;return 1};s.rep=function(x,o,n){var i=x.indexOf(o);wh" +
    "ile(x&&i>=0){x=x.substring(0,i)+n+x.substring(i+o.length);i=x.index" +
    "Of(o,i+n.length)}return x};s.ape=function(x){var s=this,i;x=x?s.rep" +
    "(escape(''+x),'+','%2B'):x;if(x&&s.charSet&&s.em==1&&x.indexOf('%u'" +
    ")<0&&x.indexOf('%U')<0){i=x.indexOf('%');while(i>=0){i++;if(('89ABC" +
    "DEFabcdef').indexOf(x.substring(i,i+1))>=0)return x.substring(0,i)+" +
    "'u00'+x.substring(i);i=x.indexOf('%',i)}}return x};s.epa=function(x" +
    "){var s=this;return x?unescape(s.rep(''+x,'+',' ')):x};s.pt=functio" +
    "n(x,d,f,a){var s=this,t=x,z=0,y,r;while(t){y=t.indexOf(d);y=y<0?t.l" +
    "ength:y;t=t.substring(0,y);r=s.m(f)?s[f](t,a):f(t,a);if(r)return r;" +
    "z+=y+d.length;t=x.substring(z,x.length);t=z<x.length?t:''}return ''" +
    "};s.isf=function(t,a){var c=a.indexOf(':');if(c>=0)a=a.substring(0," +
    "c);if(t.substring(0,2)=='s_')t=t.substring(2);return (t!=''&&t==a)}" +
    ";s.fsf=function(t,a){var s=this;if(s.pt(a,',','isf',t))s.fsg+=(s.fs" +
    "g!=''?',':'')+t;return 0};s.fs=function(x,f){var s=this;s.fsg='';s." +
    "pt(x,',','fsf',f);return s.fsg};s.c_d='';s.c_gdf=function(t,a){var " +
    "s=this;if(!s.num(t))return 1;return 0};s.c_gd=function(){var s=this" +
    ",d=s.wd.location.hostname,n=s.fpCookieDomainPeriods,p;if(!n)n=s.coo" +
    "kieDomainPeriods;if(d&&!s.c_d){n=n?parseInt(n):2;n=n>2?n:2;p=d.last" +
    "IndexOf('.');if(p>=0){while(p>=0&&n>1){p=d.lastIndexOf('.',p-1);n--" +
    "}s.c_d=p>0&&s.pt(d,'.','c_gdf',0)?d.substring(p):d}}return s.c_d};s" +
    ".c_r=function(k){var s=this;k=s.ape(k);var c=' '+s.d.cookie,i=c.ind" +
    "exOf(' '+k+'='),e=i<0?i:c.indexOf(';',i),v=i<0?'':s.epa(c.substring" +
    "(i+2+k.length,e<0?c.length:e));return v!='[[B]]'?v:''};s.c_w=functi" +
    "on(k,v,e){var s=this,d=s.c_gd(),l=s.cookieLifetime,t;v=''+v;l=l?(''" +
    "+l).toUpperCase():'';if(e&&l!='SESSION'&&l!='NONE'){t=(v!=''?parseI" +
    "nt(l?l:0):-60);if(t){e=new Date;e.setTime(e.getTime()+(t*1000))}}if" +
    "(k&&l!='NONE'){s.d.cookie=k+'='+s.ape(v!=''?v:'[[B]]')+'; path=/;'+" +
    "(e&&l!='SESSION'?' expires='+e.toGMTString()+';':'')+(d?' domain='+" +
    "d+';':'');return s.c_r(k)==v}return 0};s.eh=function(o,e,r,f){var s" +
    "=this,b='s_'+e+'_'+s._in,n=-1,l,i,x;if(!s.ehl)s.ehl=new Array;l=s.e" +
    "hl;for(i=0;i<l.length&&n<0;i++){if(l[i].o==o&&l[i].e==e)n=i}if(n<0)" +
    "{n=i;l[n]=new Object}x=l[n];x.o=o;x.e=e;f=r?x.b:f;if(r||f){x.b=r?0:" +
    "o[e];x.o[e]=f}if(x.b){x.o[b]=x.b;return b}return 0};s.cet=function(" +
    "f,a,t,o,b){var s=this,r;if(s.apv>=5&&(!s.isopera||s.apv>=7))eval('t" +
    "ry{r=s.m(f)?s[f](a):f(a)}catch(e){r=s.m(t)?s[t](e):t(e)}');else{if(" +
    "s.ismac&&s.u.indexOf('MSIE 4')>=0)r=s.m(b)?s[b](a):b(a);else{s.eh(s" +
    ".wd,'onerror',0,o);r=s.m(f)?s[f](a):f(a);s.eh(s.wd,'onerror',1)}}re" +
    "turn r};s.gtfset=function(e){var s=this;return s.tfs};s.gtfsoe=new " +
    "Function('e','var s=s_c_il['+s._in+'];s.eh(window,\"onerror\",1);s." +
    "etfs=1;var c=s.t();if(c)s.d.write(c);s.etfs=0;return true');s.gtfsf" +
    "b=function(a){return window};s.gtfsf=function(w){var s=this,p=w.par" +
    "ent,l=w.location;s.tfs=w;if(p&&p.location!=l&&p.location.host==l.ho" +
    "st){s.tfs=p;return s.gtfsf(s.tfs)}return s.tfs};s.gtfs=function(){v" +
    "ar s=this;if(!s.tfs){s.tfs=s.wd;if(!s.etfs)s.tfs=s.cet('gtfsf',s.tf" +
    "s,'gtfset',s.gtfsoe,'gtfsfb')}return s.tfs};s.ca=function(){var s=t" +
    "his,imn='s_i_'+s.fun;if(s.d.images&&s.apv>=3&&(!s.isopera||s.apv>=7" +
    ")&&(s.ns6<0||s.apv>=6.1)){s.ios=1;if(!s.d.images[imn]&&(!s.isns||(s" +
    ".apv<4||s.apv>=5))){s.d.write('<im'+'g name=\"'+imn+'\" height=1 wi" +
    "dth=1 border=0 alt=\"\">');if(!s.d.images[imn])s.ios=0}}};s.mr=func" +
    "tion(sess,q,ta){var s=this,dc=s.dc,t1=s.trackingServer,t2=s.trackin" +
    "gServerSecure,ns=s.visitorNamespace,unc=s.rep(s.fun,'_','-'),imn='s" +
    "_i_'+s.fun,im,b,e,rs='http'+(s.ssl?'s':'')+'://'+(t1?(s.ssl&&t2?t2:" +
    "t1):((ns?ns:(s.ssl?'102':unc))+'.'+(s.dc?s.dc:112)+'.2o7.net'))+'/b" +
    "/ss/'+s.un+'/1/H.9-pdvu-2/'+sess+'?[AQB]&ndh=1'+(q?q:'')+(s.q?s.q:'" +
    "')+'&[AQE]';if(s.isie&&!s.ismac){if(s.apv>5.5)rs=s.fl(rs,4095);else" +
    " rs=s.fl(rs,2047)}if(s.ios||s.ss){if (!s.ss)s.ca();im=s.wd[imn]?s.w" +
    "d[imn]:s.d.images[imn];if(!im)im=s.wd[imn]=new Image;im.src=rs;if(r" +
    "s.indexOf('&pe=')>=0&&(!ta||ta=='_self'||ta=='_top'||(s.wd.name&&ta" +
    "==s.wd.name))){b=e=new Date;while(e.getTime()-b.getTime()<500)e=new" +
    " Date}return ''}return '<im'+'g sr'+'c=\"'+rs+'\" width=1 height=1 " +
    "border=0 alt=\"\">'};s.gg=function(v){var s=this;return s.wd['s_'+v" +
    "]};s.glf=function(t,a){if(t.substring(0,2)=='s_')t=t.substring(2);v" +
    "ar s=this,v=s.gg(t);if(v)s[t]=v};s.gl=function(v){var s=this;s.pt(v" +
    ",',','glf',0)};s.gv=function(v){var s=this;return s['vpm_'+v]?s['vp" +
    "v_'+v]:(s[v]?s[v]:'')};s.havf=function(t,a){var s=this,b=t.substrin" +
    "g(0,4),x=t.substring(4),n=parseInt(x),k='g_'+t,m='vpm_'+t,q=t,v=s.l" +
    "inkTrackVars,e=s.linkTrackEvents;s[k]=s.gv(t);if(s.lnk||s.eo){v=v?v" +
    "+','+s.vl_l:'';if(v&&!s.pt(v,',','isf',t))s[k]='';if(t=='events'&&e" +
    ")s[k]=s.fs(s[k],e)}s[m]=0;if(t=='visitorID')q='vid';else if(t=='pag" +
    "eURL')q='g';else if(t=='referrer')q='r';else if(t=='vmk')q='vmt';el" +
    "se if(t=='charSet'){q='ce';if(s[k]&&s.em==2)s[k]='UTF-8'}else if(t=" +
    "='visitorNamespace')q='ns';else if(t=='cookieDomainPeriods')q='cdp'" +
    ";else if(t=='cookieLifetime')q='cl';else if(t=='variableProvider')q" +
    "='vvp';else if(t=='currencyCode')q='cc';else if(t=='channel')q='ch'" +
    ";else if(t=='campaign')q='v0';else if(s.num(x)) {if(b=='prop')q='c'" +
    "+n;else if(b=='eVar')q='v'+n;else if(b=='hier'){q='h'+n;s[k]=s.fl(s" +
    "[k],255)}}if(s[k]&&t!='linkName'&&t!='linkType')s.qav+='&'+q+'='+s." +
    "ape(s[k]);return ''};s.hav=function(){var s=this;s.qav='';s.pt(s.vl" +
    "_t,',','havf',0);return s.qav};s.lnf=function(t,h){t=t?t.toLowerCas" +
    "e():'';h=h?h.toLowerCase():'';var te=t.indexOf('=');if(t&&te>0&&h.i" +
    "ndexOf(t.substring(te+1))>=0)return t.substring(0,te);return ''};s." +
    "ln=function(h){var s=this,n=s.linkNames;if(n)return s.pt(n,',','lnf" +
    "',h);return ''};s.ltdf=function(t,h){t=t?t.toLowerCase():'';h=h?h.t" +
    "oLowerCase():'';var qi=h.indexOf('?');h=qi>=0?h.substring(0,qi):h;i" +
    "f(t&&h.substring(h.length-(t.length+1))=='.'+t)return 1;return 0};s" +
    ".ltef=function(t,h){t=t?t.toLowerCase():'';h=h?h.toLowerCase():'';i" +
    "f(t&&h.indexOf(t)>=0)return 1;return 0};s.lt=function(h){var s=this" +
    ",lft=s.linkDownloadFileTypes,lef=s.linkExternalFilters,lif=s.linkIn" +
    "ternalFilters;lif=lif?lif:s.wd.location.hostname;h=h.toLowerCase();" +
    "if(s.trackDownloadLinks&&lft&&s.pt(lft,',','ltdf',h))return 'd';if(" +
    "s.trackExternalLinks&&(lef||lif)&&(!lef||s.pt(lef,',','ltef',h))&&(" +
    "!lif||!s.pt(lif,',','ltef',h)))return 'e';return ''};s.lc=new Funct" +
    "ion('e','var s=s_c_il['+s._in+'],b=s.eh(this,\"onclick\");s.lnk=s.c" +
    "o(this);s.t();s.lnk=0;if(b)return this[b](e);return true');s.bc=new" +
    " Function('e','var s=s_c_il['+s._in+'],f;if(s.d&&s.d.all&&s.d.all.c" +
    "ppXYctnr)return;s.eo=e.srcElement?e.srcElement:e.target;eval(\"try{" +
    "if(s.eo&&(s.eo.tagName||s.eo.parentElement||s.eo.parentNode))s.t()}" +
    "catch(f){}\");s.eo=0');s.ot=function(o){var a=o.type,b=o.tagName;re" +
    "turn (a&&a.toUpperCase?a:b&&b.toUpperCase?b:o.href?'A':'').toUpperC" +
    "ase()};s.oid=function(o){var s=this,t=s.ot(o),p=o.protocol,c=o.oncl" +
    "ick,n='',x=0;if(!o.s_oid){if(o.href&&(t=='A'||t=='AREA')&&(!c||!p||" +
    "p.toLowerCase().indexOf('javascript')<0))n=o.href;else if(c){n=s.re" +
    "p(s.rep(s.rep(s.rep(''+c,\"\\r\",''),\"\\n\",''),\"\\t\",''),' ',''" +
    ");x=2}else if(o.value&&(t=='INPUT'||t=='SUBMIT')){n=o.value;x=3}els" +
    "e if(o.src&&t=='IMAGE')n=o.src;if(n){o.s_oid=s.fl(n,100);o.s_oidt=x" +
    "}}return o.s_oid};s.rqf=function(t,un){var s=this,e=t.indexOf('=')," +
    "u=e>=0?','+t.substring(0,e)+',':'';return u&&u.indexOf(','+un+',')>" +
    "=0?s.epa(t.substring(e+1)):''};s.rq=function(un){var s=this,c=un.in" +
    "dexOf(','),v=s.c_r('s_sq'),q='';if(c<0)return s.pt(v,'&','rqf',un);" +
    "return s.pt(un,',','rq',0)};s.sqp=function(t,a){var s=this,e=t.inde" +
    "xOf('='),q=e<0?'':s.epa(t.substring(e+1));s.sqq[q]='';if(e>=0)s.pt(" +
    "t.substring(0,e),',','sqs',q);return 0};s.sqs=function(un,q){var s=" +
    "this;s.squ[un]=q;return 0};s.sq=function(q){var s=this,k='s_sq',v=s" +
    ".c_r(k),x,c=0;s.sqq=new Object;s.squ=new Object;s.sqq[q]='';s.pt(v," +
    "'&','sqp',0);s.pt(s.un,',','sqs',q);v='';for(x in s.squ)s.sqq[s.squ" +
    "[x]]+=(s.sqq[s.squ[x]]?',':'')+x;for(x in s.sqq)if(x&&s.sqq[x]&&(x=" +
    "=q||c<2)){v+=(v?'&':'')+s.sqq[x]+'='+s.ape(x);c++}return s.c_w(k,v," +
    "0)};s.wdl=new Function('e','var s=s_c_il['+s._in+'],r=true,b=s.eh(s" +
    ".wd,\"onload\"),i,o,oc;if(b)r=this[b](e);for(i=0;i<s.d.links.length" +
    ";i++){o=s.d.links[i];oc=o.onclick?\"\"+o.onclick:\"\";if((oc.indexO" +
    "f(\"s_gs(\")<0||oc.indexOf(\".s_oc(\")>=0)&&oc.indexOf(\".tl(\")<0)" +
    "s.eh(o,\"onclick\",0,s.lc);}return r');s.wds=function(){var s=this;" +
    "if(s.apv>3&&(!s.isie||!s.ismac||s.apv>=5)){if(s.b&&s.b.attachEvent)" +
    "s.b.attachEvent('onclick',s.bc);else if(s.b&&s.b.addEventListener)s" +
    ".b.addEventListener('click',s.bc,false);else s.eh(s.wd,'onload',0,s" +
    ".wdl)}};s.vs=function(x){var s=this,v=s.visitorSampling,g=s.visitor" +
    "SamplingGroup,k='s_vsn_'+s.un+(g?'_'+g:''),n=s.c_r(k),e=new Date,y=" +
    "e.getYear();e.setYear(y+10+(y<1900?1900:0));if(v){v*=100;if(!n){if(" +
    "!s.c_w(k,x,e))return 0;n=x}if(n%10000>v)return 0}return 1};s.dyasmf" +
    "=function(t,m){if(t&&m&&m.indexOf(t)>=0)return 1;return 0};s.dyasf=" +
    "function(t,m){var s=this,i=t?t.indexOf('='):-1,n,x;if(i>=0&&m){var " +
    "n=t.substring(0,i),x=t.substring(i+1);if(s.pt(x,',','dyasmf',m))ret" +
    "urn n}return 0};s.uns=function(){var s=this,x=s.dynamicAccountSelec" +
    "tion,l=s.dynamicAccountList,m=s.dynamicAccountMatch,n,i;s.un.toLowe" +
    "rCase();if(x&&l){if(!m)m=s.wd.location.host;if(!m.toLowerCase)m=''+" +
    "m;l=l.toLowerCase();m=m.toLowerCase();n=s.pt(l,';','dyasf',m);if(n)" +
    "s.un=n}i=s.un.indexOf(',');s.fun=i<0?s.un:s.un.substring(0,i)};s.sa" +
    "=function(un){s.un=un;if(!s.oun)s.oun=un;else if((','+s.oun+',').in" +
    "dexOf(un)<0)s.oun+=','+un;s.uns()};s.t=function(){var s=this,trk=1," +
    "tm=new Date,sed=Math&&Math.random?Math.floor(Math.random()*10000000" +
    "000000):tm.getTime(),sess='s'+Math.floor(tm.getTime()/10800000)%10+" +
    "sed,yr=tm.getYear(),vt=tm.getDate()+'/'+tm.getMonth()+'/'+(yr<1900?" +
    "yr+1900:yr)+' '+tm.getHours()+':'+tm.getMinutes()+':'+tm.getSeconds" +
    "()+' '+tm.getDay()+' '+tm.getTimezoneOffset(),tfs=s.gtfs(),ta='',q=" +
    "'',qs='';s.uns();if(!s.q){var tl=tfs.location,x='',c='',v='',p='',b" +
    "w='',bh='',j='1.0',k=s.c_w('s_cc','true',0)?'Y':'N',hp='',ct='',pn=" +
    "0,ps;if(s.apv>=4)x=screen.width+'x'+screen.height;if(s.isns||s.isop" +
    "era){if(s.apv>=3){j='1.1';v=s.n.javaEnabled()?'Y':'N';if(s.apv>=4){" +
    "j='1.2';c=screen.pixelDepth;bw=s.wd.innerWidth;bh=s.wd.innerHeight;" +
    "if(s.apv>=4.06)j='1.3'}}s.pl=s.n.plugins}else if(s.isie){if(s.apv>=" +
    "4){v=s.n.javaEnabled()?'Y':'N';j='1.2';c=screen.colorDepth;if(s.apv" +
    ">=5){bw=s.d.documentElement.offsetWidth;bh=s.d.documentElement.offs" +
    "etHeight;j='1.3';if(!s.ismac&&s.b){s.b.addBehavior('#default#homePa" +
    "ge');hp=s.b.isHomePage(tl)?\"Y\":\"N\";s.b.addBehavior('#default#cl" +
    "ientCaps');ct=s.b.connectionType}}}else r=''}if(s.pl)while(pn<s.pl." +
    "length&&pn<30){ps=s.fl(s.pl[pn].name,100)+';';if(p.indexOf(ps)<0)p+" +
    "=ps;pn++}s.q=(x?'&s='+s.ape(x):'')+(c?'&c='+s.ape(c):'')+(j?'&j='+j" +
    ":'')+(v?'&v='+v:'')+(k?'&k='+k:'')+(bw?'&bw='+bw:'')+(bh?'&bh='+bh:" +
    "'')+(ct?'&ct='+s.ape(ct):'')+(hp?'&hp='+hp:'')+(p?'&p='+s.ape(p):''" +
    ")}if(s.usePlugins)s.doPlugins(s);var l=s.wd.location,r=tfs.document" +
    ".referrer;if(!s.pageURL)s.pageURL=s.fl(l?l:'',255);if(!s.referrer)s" +
    ".referrer=s.fl(r?r:'',255);if(s.lnk||s.eo){var o=s.eo?s.eo:s.lnk;if" +
    "(!o)return '';var p=s.gv('pageName'),w=1,t=s.ot(o),n=s.oid(o),x=o.s" +
    "_oidt,h,l,i,oc;if(s.eo&&o==s.eo){while(o&&!n&&t!='BODY'){o=o.parent" +
    "Element?o.parentElement:o.parentNode;if(!o)return '';t=s.ot(o);n=s." +
    "oid(o);x=o.s_oidt}oc=o.onclick?''+o.onclick:'';if((oc.indexOf(\"s_g" +
    "s(\")>=0&&oc.indexOf(\".s_oc(\")<0)||oc.indexOf(\".tl(\")>=0)return" +
    " ''}ta=n?o.target:1;h=o.href?o.href:'';i=h.indexOf('?');h=s.linkLea" +
    "veQueryString||i<0?h:h.substring(0,i);l=s.linkName?s.linkName:s.ln(" +
    "h);t=s.linkType?s.linkType.toLowerCase():s.lt(h);if(t&&(h||l))q+='&" +
    "pe=lnk_'+(t=='d'||t=='e'?s.ape(t):'o')+(h?'&pev1='+s.ape(h):'')+(l?" +
    "'&pev2='+s.ape(l):'');else trk=0;if(s.trackInlineStats){if(!p){p=s." +
    "gv('pageURL');w=0}t=s.ot(o);i=o.sourceIndex;if(s.gg('objectID')){n=" +
    "s.gg('objectID');x=1;i=1}if(p&&n&&t)qs='&pid='+s.ape(s.fl(p,255))+(" +
    "w?'&pidt='+w:'')+'&oid='+s.ape(s.fl(n,100))+(x?'&oidt='+x:'')+'&ot=" +
    "'+s.ape(t)+(i?'&oi='+i:'')}}if(!trk&&!qs)return '';if(s.p_r)s.p_r()" +
    ";var code='';if(trk&&s.vs(sed))code=s.mr(sess,(vt?'&t='+s.ape(vt):'" +
    "')+s.hav()+q+(qs?qs:s.rq(s.un)),ta);s.sq(trk?'':qs);s.lnk=s.eo=s.li" +
    "nkName=s.linkType=s.wd.s_objectID=s.ppu='';return code};s.tl=functi" +
    "on(o,t,n){var s=this;s.lnk=s.co(o);s.linkType=t;s.linkName=n;s.t()}" +
    ";s.ssl=(s.wd.location.protocol.toLowerCase().indexOf('https')>=0);s" +
    ".d=document;s.b=s.d.body;s.n=navigator;s.u=s.n.userAgent;s.ns6=s.u." +
    "indexOf('Netscape6/');var apn=s.n.appName,v=s.n.appVersion,ie=v.ind" +
    "exOf('MSIE '),o=s.u.indexOf('Opera '),i;if(v.indexOf('Opera')>=0||o" +
    ">0)apn='Opera';s.isie=(apn=='Microsoft Internet Explorer');s.isns=(" +
    "apn=='Netscape');s.isopera=(apn=='Opera');s.ismac=(s.u.indexOf('Mac" +
    "')>=0);if(o>0)s.apv=parseFloat(s.u.substring(o+6));else if(ie>0){s." +
    "apv=parseInt(i=v.substring(ie+5));if(s.apv>3)s.apv=parseFloat(i)}el" +
    "se if(s.ns6>0)s.apv=parseFloat(s.u.substring(s.ns6+10));else s.apv=" +
    "parseFloat(v);s.em=0;if(String.fromCharCode){i=escape(String.fromCh" +
    "arCode(256)).toUpperCase();s.em=(i=='%C4%80'?2:(i=='%U0100'?1:0))}s" +
    ".sa(un);s.vl_l='visitorID,vmk,ppu,charSet,visitorNamespace,cookieDo" +
    "mainPeriods,cookieLifetime,pageName,pageURL,referrer,currencyCode,p" +
    "urchaseID';s.vl_t=s.vl_l+',variableProvider,channel,server,pageType" +
    ",campaign,state,zip,events,products,linkName,linkType';for(var n=1;" +
    "n<51;n++)s.vl_t+=',prop'+n+',eVar'+n+',hier'+n;s.vl_g=s.vl_t+',trac" +
    "kDownloadLinks,trackExternalLinks,trackInlineStats,linkLeaveQuerySt" +
    "ring,linkDownloadFileTypes,linkExternalFilters,linkInternalFilters," +
    "linkNames';if(pg)s.gl(s.vl_g);s.ss=ss;if(!ss){s.wds();s.ca()}}", l = window.s_c_il, n = navigator, u = n.userAgent, v = n.appVersion, e = v.indexOf('MSIE '), m = u.indexOf('Netscape6/'), a, i, s;
    if (l) 
        for (i = 0; i < l.length; i++) {
            s = l[i];
            if (s.oun == un) 
                return s;
            else 
                if (s.fs(s.oun, un)) {
                    s.sa(un);
                    return s
                }
        }
    if (e > 0) {
        a = parseInt(i = v.substring(e + 5));
        if (a > 3) 
            a = parseFloat(i)
    }
    else 
        if (m > 0) 
            a = parseFloat(u.substring(m + 10));
        else 
            a = parseFloat(v);
    if (a >=
    5 &&
    v.indexOf('Opera') < 0 &&
    u.indexOf('Opera') < 0) {
        eval(c);
        return new s_c(un, pg, ss)
    }
    else 
        s = s_c2f(c);
    return s(un, pg, ss)
}

