function trackvideo(x, y, video_id, vidtime, vidlength, vidcomplete) {
	//console.log('trackvideo() called');
	//alert("x: " + x);
	//alert("y: " + y);
	//console.log("video_id: " + video_id);
	//alert("vidtime: " + vidtime);
	//alert("vidlength: " + vidlength);
	//alert("vidcomplete: " + vidcomplete);
    //debugger;
	if (window.XMLHttpRequest) {
		xmlHttp=new XMLHttpRequest()
	} else if (window.ActiveXObject) {
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
			
	var dt = new Date();
	var ms = dt.getMilliseconds();
	var dtms = dt + ":" + ms;
	var openpage = "hits.aspx?d35m@s36p=" + x + "&qz76ut=" + y + "&b=" + video_id + "&vtime=" + vidtime + "&vlength=" + vidlength + "&vcomplete=" + vidcomplete + "&dt=" + dtms;
	xmlHttp.open('GET',openpage);
	xmlHttp.send(null);
	
}

function swapVid(filename) {
    var flash = window.document.hc;
    flash.switchvid_js(filename);
}

var flashInterval = 0;

function loadVid(){
	flashInterval = setInterval("playFlashVideo()", 200);
}


function playFlashVideo() {
	try {	
	    var video = window.document.hc;
    	video.loadvid_js();
		clearInterval(flashInterval);
	}
	catch (e) {
	}
}

function trackend(video_id) {
    //debugger;
    var flash = window.document.hc;
	
    vinfo = flash.browserclose_js();
	
    // vinfo is a 3-part string that is comma separated
    // The first part is the current video being played
    // The second part is the current duration of the video being played
    // The third part is if the video has been completely watched (y/n)
    // Need to update that record when the browser is closed
    if ((vinfo != "") && (vinfo != null) && vinfo != 'null') {
	
        vidinfo = vinfo.split(",");
	
	    vidtime = vidinfo[0];
	    vidlength = vidinfo[1];
	    vidcomplete = vidinfo[2];
	
	    trackvideo('%6E%65%72%66%76%75%6C%63%61%6E', '%69%68%61%74%65%74%68%61%74%62%6F%62%62%61%72%6B%65%72', video_id, vidtime, vidlength, vidcomplete);

    }
	
}

