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();
}


function poplink(url,name) {
  
	popwin = window.open(url,name);
	popwin.focus();
}


function trackhit(poo, stain, source_id, user_id, btn_id) {

	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=" + poo + "&qz76ut=" + stain + "&s=" + source_id + "&u=" + user_id + "&b=" + btn_id + "&dt=" + dtms;
	xmlHttp.open('GET',openpage);
	xmlHttp.send(null);
	
}

function trackvideo(poo, stain, video_id, vidtime, vidlength, vidcomplete) {

	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=" + poo + "&qz76ut=" + stain + "&b=" + video_id + "&vtime=" + vidtime + "&vlength=" + vidlength + "&vcomplete=" + vidcomplete + "&dt=" + dtms;
	xmlHttp.open('GET',openpage);
	xmlHttp.send(null);
	
}

function ValidateMe() {
    var ok = Page_ClientValidate();
    if (ok) {
        var pager = "pcoupon.aspx?name=" + document.getElementById('txt_name').value;
        popit(pager, 'vouch', '820', '320');
    } else {
        return false;
    }
}

function checkclient() {
    if (document.getElementById("hdn_clientid").value == "" || document.getElementById("hdn_clientid").value == "0") {
        alert("Please Select Location on Form");
        return false;
    } else {
        return true;
    }
}

function loadVid(){
	var t=setTimeout("playFlashVideo()",500);
}

function playFlashVideo() {
    var video = window.document.hc;
    video.loadvid_js();
}

function trackend(video_id) {

  	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 != "") {
	
	    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);

	}

}

function dealerswap(dname, daddress, dphone, daddress2, dphone2) {
    var flashy = window.document.varlogo;
    flashy.dealerswap_js(dname, daddress, dphone, daddress2, dphone2);
}
