function tz_pagedims(){
    var tz_w,tz_h;
    if(self.innerHeight){
	tz_w = self.innerWidth;
	tz_h = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
	tz_w = document.documentElement.clientWidth;
	tz_h = document.documentElement.clientHeight;
    } else if (document.body) {
	tz_w=document.body.clientWidth;
	tz_h = document.body.clientHeight;
    }
    return Array(tz_w,tz_h);
}
function report_event(event_string) {

    var event_output = document.getElementById('event_output');
    if (event_output == null) {
				create_output_console();
    }

    if (event_string) {
				body_div = document.getElementById('output_body');
				body_div.innerHTML = "<div>" + event_string + "</div>" + body_div.innerHTML;
    }
}



function create_output_console() {
		var dims = tz_pagedims();

		event_output=document.createElement('div');
		event_output.setAttribute('id', 'event_output');
		//event_output.className='event-output';
		event_output.style.position = 'absolute';
		event_output.style.zIndex = '9999';


    if(typeof(dfa_preview_mode) != "undefined" && dfa_preview_mode){ 
        var width = '400px';
        var height = '350px';
    }else{
        var width = '300px';
        var height= '200px';
    }

		var left = dims[0] - parseInt(width) - 30  + 'px';
		var top = dims[1] - parseInt(height) - 60 + 'px';
		event_output.style.width = width;
        //event_output.style.height = height;
        event_output.style.left = left;
        event_output.style.top = top;
		event_output.style.display = 'block';
		//event_output.style.visibility = 'hidden';
		event_output.style.border = '3px #EF922E solid';
		//event_output.style.overflow = 'hidden';
		document.body.appendChild(event_output);

		header_div = '<div title="'+dyn_text["drag"]+'" id="output_header" style="cursor:move;font-size:80%;background-image:url(images/publish_background.gif);border-bottom:1px #EF922E solid;font-weight:700;"><span id="configure-utils-title">'+dyn_text["output-console"]+' [<a title"'+dyn_text["clear"]+'" href="javascript:clear_output();void(0);" style="text-decoration:underline;">clear</a>]</span><span class="close-dc-option-button"><a title="'+dyn_text["close"]+'" href="javascript:toggle_hide_output();void(0);"><img alt="Close" src="images/icon_close_button.gif" style="float:right;border:none;margin:2px;" /></a></span></div><div class="clear-dc"></div>';

		body_div = "<div id='output_body' style='display:block;overflow:auto;background-color:white;font-size:80%;text-align:left;'></div><div id='eo-resize-handle' style='display:block;width:100%;background-color:white;height:16px;'><img align='right' src='images/resize_corner.gif' id='event-options-resizeSE' style='cursor:se-resize;' /></div>";
		event_output.innerHTML = header_div + body_div;

		header_div = document.getElementById('output_header');
        header_div.style.width = "100%";
        header_div.style.height = "20px";
        header_div.style.left = left;
        header_div.style.top = top;

		body_div = document.getElementById('output_body');

        body_div.style.width = "100%";
        body_div.style.height = height;
        body_div.style.left = left;
        body_div.style.top = top;

		//Drag.init(header_div, event_output);
		$("#event_output").Resizable({
				minWidth: 300,
				minHeight: 150,
				dragHandle: '#output_header',
				onResize:(function(){
						$("#output_body").height($(this).height()-$("#eo-resize-handle").height()-$("#output_header").height());
				}),
				handlers: {
				se: '#event-options-resizeSE'
				}
		});
}


function build_dfa_output_tables() {

		if (document.getElementById('output_body') == null) {
				create_output_console();
		}

		body_div = document.getElementById('output_body');
    //build eventSequenceTable
    event_seq_table = '<div><table id="dfa_seq_table" cellpadding="2" cellspacing="1" width="100%" border="0"><th colspan="4" align="center">' + dyn_text['dfa_seq_trig'] + '</th><tr><th width="25%" align="center">' + dyn_text['dfa_seq_time']+ '</th><th width="25%" align="center">' + dyn_text['dfa_seq_name'] + '</th><th width="25%">' + dyn_text['dfa_seq_type'] +  '</th><th width="25%" align="center">' + dyn_text['dfa_seq_action'] + '</th></tr></table></div>';

    //build eventAggregationTable
    event_agg_table = '<div><table id="dfa_agg_table" cellpadding="2" cellspacing="1" width="100%" border="0"><th colspan="4" align="center">' + dyn_text['dfa_agg_logged'] + '</th><tr><th width="25%" align="center">' + dyn_text['dfa_agg_name']+ '</th><th width="25%" align="center">' + dyn_text['dfa_agg_type'] + '</th><th width="25%" align="center">' + dyn_text['dfa_agg_count'] +  '</th><th width="25%" align="center">' + dyn_text['dfa_agg_total_time'] + '</th></tr>';

    var METEventObjects = frames["main"].dartMETEvents;
		for (METEventId in METEventObjects){
			//add event name
			event_agg_table += '<tr><td id="agg_event_' + METEventObjects[METEventId].customEventId + '">' + METEventObjects[METEventId].name + '</td>';

			//add event type
			//should read "Standard" for metEvents with "isStandard" instance variable set to true
			if (METEventObjects[METEventId].isStandard) {
					event_agg_table += '<td>' + dyn_text['dfa_agg_standard'] + '</td>';
			} else {
					event_agg_table += '<td>' + METEventObjects[METEventId].type + '</td>';
			}

			//add event Count
			if (METEventObjects[METEventId].type == "Timer") {
					if (METEventObjects[METEventId].isStandard) {
							if (METEventObjects[METEventId].shouldDisplayCountForStandardTimer) {
									event_agg_table += '<td>0</td>';
							} else {
									// N/A displays for Timer
									event_agg_table += '<td>N/A</td>';
							}

							event_agg_table += '<td>0s</td>';

					} else {
							//not standard so display both count and time
							event_agg_table += '<td>0</td>'; //count
							event_agg_table += '<td>0s</td>'; //timer
					}
			} else {
					//non timer events
					event_agg_table += '<td>0</td>'; //count
					event_agg_table += '<td>N/A</td>'; //timer
			}
    	}

    event_agg_table += '</table></div>';
    //add tables to output_body
    body_div.innerHTML = event_seq_table + event_agg_table;
    
    $("#dfa_seq_table tr").each(function(i){
       if(i > 1){
	   if((i % 2) == 0){
	       this.style.backgroundColor = "#FFF6F0";
	   } else {
	       this.style.backgroundColor = "#EAEAEA"; 
	   }
       } else {
         this.style.backgroundColor = "#CCCCCC";
       }
    });

    $("#dfa_agg_table tr").each(function(i){
       if(i > 1){
	   if((i % 2) == 0){
	       this.style.backgroundColor = "#FFF6F0";
	   } else {
	       this.style.backgroundColor = "#EAEAEA"; 
	   }
       } else {
	   this.style.backgroundColor = "#CCCCCC";
       }
    });
}


function clear_output() {
    var body_div = document.getElementById('output_body');
    body_div.innerHTML = "";
		timerStartStatus = null;
		eventTriggered = null;
}

show = false;
function show_output() {
    var event_output = document.getElementById('event_output');
    if (event_output && show) {
	event_output.style.visibility = "visible";
    }
}

function toggle_show_output() {
    if (show) {
        toggle_hide_output();

	//we are in roadblock mode so hide display id's of roadblock creatives
	if(roadblock_mode){
	    hide_display_id();
	}

    } else {
	$("#tu-oc-btn img").attr("src","images/icon_dc_ic_on.gif");
        var event_output = document.getElementById('event_output');
        if (typeof(event_output) == 'undefined' || !event_output) {
	    report_event("");
	}

	//if this array exists, switch on display id's for roadblock creatives
	if(local_creative_list = window.frames.main.creative_list){
	    show_display_id();
	}

	show = true;
	show_output();
    }
}

function hide_output() {
    $("#tu-oc-btn img").attr("src","images/icon_dc_ic.gif");
    var event_output = document.getElementById('event_output');
    if (typeof(event_output) != 'undefined' && event_output) {
	event_output.style.visibility = "hidden";
    }
}

function toggle_hide_output() {
    show = false;
    hide_output();
}

function hide_display_id(){
    //need to create reference to creative_list which is in a different iframe
    local_creative_list = window.frames.main.creative_list;
    var x;

    for (x in local_creative_list){
	obj = local_creative_list[x];
	window.frames.main.$('#display-id-'+obj.id).hide();
    }
}

function show_display_id(){
    //need to create reference to creative_list which is in a different iframe
    local_creative_list = window.frames.main.creative_list;
    var x;

    for (x in local_creative_list){
	obj = local_creative_list[x];
	//alert('display-id-'+obj.id);
	window.frames.main.$('#display-id-'+obj.id).show();
    }
}

<!-- new part -->

function report_data(data_string) {
    var data_output = document.getElementById('data_output');
    if (data_output == null) {
	var dims = tz_pagedims();

	data_output=document.createElement('div');
	data_output.setAttribute('id', 'data_output');
	//event_output.className='event-output';
	data_output.style.position = 'absolute';
	data_output.style.zIndex = '9999';

	//new stuff
	//data_output.style.margin = 5px 0px 0px 5px;


	var width = '560px';
	var height = '240px';
	var left = dims[0] - parseInt(width) - 30  + 'px';
	var top = dims[1] - parseInt(height) - 195 + 'px';
	//place start position of window to where scrollbars don't clash
	//var left = dims[0] - parseInt(width) - 445  + 'px';
	//var top = dims[1] - parseInt(height) - 60 + 'px';
        data_output.style.width = width;
        //data_output.style.height = height;
        data_output.style.left = left;
        data_output.style.top = top;
	data_output.style.display = 'block';
	//data_output.style.visibility = 'hidden';
	data_output.style.border = '3px #EF922E solid';
	//data_output.style.overflow = 'auto';
	document.body.appendChild(data_output);

	header_div = '<div title="'+dyn_text["drag"]+'" id="data_header" style="cursor:move;font-size:80%;background-image:url(images/publish_background.gif);border-bottom:1px #EF922E solid;font-weight:700;"><span id="configure-utils-title">'+dyn_text["data-capture-console"]+'</span><span class="close-dc-option-button"><a title="'+dyn_text["close"]+'" href="javascript:dc_runner_stop();toggle_hide_data();void(0);"><img alt="Close" src="images/icon_close_button.gif" style="float:right;border:none;margin:2px;" /></a></span></div><div class="clear-dc"></div>';

	body_div = "<div id='data-body' style='display:block;overflow:auto;background:white;font-size:80%;text-align:left;'></div>";
	data_output.innerHTML = header_div + body_div;

	header_div = document.getElementById('data_header');
        header_div.style.width = width;
        header_div.style.height = "20px";
        header_div.style.left = left;
        header_div.style.top = top;

	body_div = document.getElementById('data-body');

        body_div.style.width = width;
        body_div.style.height = height;
        body_div.style.left = left;
        body_div.style.top = top;

	Drag.init(header_div, data_output);
    } else {
	body_div = document.getElementById('data-body');
    }
    if (data_string) {
      //body_div.innerHTML = "<div>" + data_string + "</div>" + body_div.innerHTML;
      body_div.innerHTML = "" + data_string + "" + body_div.innerHTML;
    }
}

function clear_data() {
    var body_div = document.getElementById('data-body');
    body_div.innerHTML = "";
}

show_dc = false;
function show_data() {
    var data_output = document.getElementById('data_output');
    if (data_output && show_dc) {
	data_output.style.visibility = "visible";
    }
}

function toggle_show_data() {
    if (show_dc) {
        toggle_hide_data();
    } else {
	$("#tu-dc-btn img").attr("src","images/icon_datacapture_on.gif");
        var data_output = document.getElementById('data_output');
        if (typeof(data_output) == 'undefined' || !data_output) {
	    report_data("");
	}
	show_dc = true;
	show_data();
	dc_runner_start();
    }
}

function hide_data() {
    $("#tu-dc-btn img").attr("src","images/icon_datacapture.gif");
    var data_output = document.getElementById('data_output');
    if (typeof(data_output) != 'undefined' && data_output) {
	data_output.style.visibility = "hidden";
    }
}

function toggle_hide_data() {
    show_dc = false;
    hide_data();
    dc_runner_stop();
}
