/*===========================================================
Reporting JS

Contains all functions neccessary for reporting
************************************************************
Created by Ming Chan(ming_chan@designreactor.com)
copyright © 2005 Design Reactor Inc.
************************************************************
Last Modified: 03/10/05
Version: 1.0
===========================================================*/
/*===========================
Define locations of the image
============================*/

//var imgOrgSrc= "http://marketplace.onbusinessnetwork.com/testingLog.img"
var imgOrgSrc= "http://demo.ciscovideo.com:8080/NatC_Metrics/clickImage.jsp";
var s_clickLocation="";
var s_action="";
var s_contentType="";
var s_contentID="";
var s_userID="";
var QA_log="";
var winURL="";
var myWindow=""
var reportingImage;
/*===========================
Write Image Functions
============================*/

function initReporting(){
	reportingImage= new Image(1,1);
	//document.write('<img src="' + imgOrgSrc + '" name="reportingImage" WIDTH=1 HEIGHT=1>');
}

/*===========================
Send Tracking Functions
============================*/

// variables being sent: clickLocation, action, contentType, contentID, userID
function sendReporting(){
	
	
	if (!document.getElementById) return
	var today= new Date();
	var imgSrc= imgOrgSrc + "?clickLocation=" + s_clickLocation + "&action=" + s_action + "&contentType=" + s_contentType + "&contentID=" + escape(s_contentID) + "&userID=" + s_userID + "&random=" + today.getTime();
	//document.reportingImage.setAttribute('src',imgSrc);
	reportingImage.src=imgSrc;
	
	/****** Popup file For QA **********/
	/*QA_log+= imgSrc +"<br><br>";
	QA_log= replace(QA_log,"&", " + ");
	winURL= "QAPopup.html?log=" + QA_log;
	
	myWindow = window.open(winURL,'QA','width=300,height=150,resizable=1,scrollbars=1, menubar=1');*/
} 

/*===========================
FOR QA
============================*/

function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);
    return newstr;
}

