﻿function popit(url,name,w,h) {
	var winl = (screen.width-w)/2;
	if (winl < 0) winl = 0;
	
	popwin = window.open(url,name,"width=" + w + ",height=" + h + ",toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,top=0,left=" + winl);
	popwin.focus();
}

// Track the video if watched or finished
function trackvideo(poo, stain, cid, vid, vtype, nvid) {

	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 = "videos.aspx?t88ky@32n=" + poo + "&uw81nh=" + stain + "&cid=" + cid + "&vid=" + vid + "&vtype=" + vtype + "&nvid=" + nvid + "&dt=" + dtms;
	xmlHttp.open('GET',openpage);
	
	if (vtype == "watch") {
        xmlHttp.onreadystatechange = onSumResponse;
    }
        
	xmlHttp.send(null);
	
}

function testit() {
    alert("hi");
}

function onSumResponse() {

    if (xmlHttp.readyState == 4) {
        var serverResponse = xmlHttp.responseText;
      	var flash = window.document.ZieglerTV
        flash.setvidid_js(serverResponse);
    }
    
}

// Track clicks for channels
function trackchannels(poo, stain, cid) {

	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 = "clicks.aspx?t88ky@32n=" + poo + "&uw81nh=" + stain + "&cid=" + cid + "&dt=" + dtms;
	xmlHttp.open('GET',openpage);
	xmlHttp.send(null);
	
}		

