if (vsActive)
	{
		// Attach Event to page onload which tags all links (for global usage)
		if (window.addEventListener) //DOM 
		window.addEventListener("unload", vsReport, false)
		else if (window.attachEvent) //IE 
		window.attachEvent("onunload", vsReport)
		else if (document.getElementById) // Legacy
		window.onunload=vsReport;
	}
var vsLinkClicked = "";
var v_pc = ""; // page category
var v_ln = ""; // link name
var v_startTime = new Date();


function vsReport()
{
var vsQueryDebug = "";
var vsQuery = "";
var v_endTime = new Date();

// 1  of 4 assemble string of standard values
if(typeof window.webAnalyticsPageTitle == "undefined"){
	webAnalyticsPageTitle = countryTel +" "+ langUA2GO + " " + window.location.pathname;

}
if (webAnalyticsPageTitle != "") {

		if (window.location.pathname.indexOf('chinese') != -1) {
			webAnalyticsPageTitle = webAnalyticsPageTitle.replace(/^cn\sen\s/, 'cn zh ');
		}

		vsQueryDebug+="(page name) &v_pn="+escape(webAnalyticsPageTitle)+"\n";
		vsQuery+="&v_pn="+escape(webAnalyticsPageTitle);
}

if (window.vsErrorString)
	{
		if (vsErrorString != "")
			{
				vsQueryDebug+="(error string) &v_errorString="+escape(vsErrorString)+"\n";
				vsQuery+="&v_errorString="+escape(vsErrorString);
			}
	}
if (window.vsLinkClicked)
	{
		if (vsLinkClicked != "")
			{
				q=vsLinkClicked.split('?');
				if (q[1])
					{
						//Get all Name/Value pairs from the QueryString
						var pairs = q[1].split('&');
						for (i=0;i<pairs.length;i++)
							{
								//Get the Name from given Name/Value pair
								var keyval = pairs[i].split('=');
								if (keyval[0]=="navSource" && keyval[1].length>=1) { v_pc=keyval[1]; vsQueryDebug+="(page category) &v_pc="+escape(v_pc)+"\n";}
								if (keyval[0]=="linkTitle" && keyval[1].length>=1) { v_ln=keyval[1]; vsQueryDebug+="(link name) &v_ln="+escape(v_ln)+"\n";}

								if (keyval[0]=="navSource" && keyval[1].length>=1) { v_pc=keyval[1]; vsQuery+="&v_pc="+escape(v_pc);}
								if (keyval[0]=="linkTitle" && keyval[1].length>=1) { v_ln=keyval[1]; vsQuery+="&v_ln="+escape(v_ln);}
							}
					}
			}
	}
if (window.vsIsLoggedIn)
	if (vsIsLoggedIn == "true")
	{
		vsQueryDebug+="(logged in state) &v_loggedIn=true\n";
		vsQuery+="&v_loggedIn=true";
	}
	else if (vsIsLoggedIn == "false")
	{
		vsQueryDebug+="(logged in state) &v_loggedIn=false\n";
		vsQuery+="&v_loggedIn=false";
	}

// 2 of 4 appnd string with custom name/values
if (window.vsCustomItems)
	{
		for(i=0;i<vsCustomItems.length;i++)
		{
			if (vsCustomItems[i][0].length>=1 && vsCustomItems[i].length==2)
			{

				vsQueryDebug += "(custom value) &"+escape(vsCustomItems[i][0])+"="+escape(vsCustomItems[i][1])+"\n";
				vsQuery += "&"+escape(vsCustomItems[i][0])+"="+escape(vsCustomItems[i][1])+"\n";
			}
		}
	}

// 3 of 4 add uri and timestamp as last parameter.
		vsQueryDebug += "(URI of this page) &v_uri="+window.location.href+"\n";
		vsQuery += "&v_uri="+escape(window.location.href);

		vsQueryDebug += "(Time spent on this page) &v_duration="+(v_endTime-v_startTime);
		vsQuery += "&v_duration="+(v_endTime-v_startTime);

// 4 of 4 request image
if (vsQuery != "") //alert("Web Analytics src of img to be requested: www.united.com/ual/asset/vs.gif?Log=1\n"+vsQueryDebug)
document.getElementById('vsImage').src = writeVSprotocol+'://www.united.com/ual/asset/vs.gif?Log=1'+vsQuery;
}

// during load, embed vs target image
var writeVSprotocol = "http"; if(document.location.href.indexOf('https://') !=- 1){writeSWNprotocol = "https";}
document.write('<div><im'+'g src="'+writeVSprotocol+'://www.united.com/images/d.gif" border="0" width="1" height="1" alt="vs" id="vsImage"></div>');



// legacy insightfirst function (incase)
function if_queryForm()
{
return true; // basically, do nothing.
}

// remove spaces from a string
function removeSpaces(string) {
	var tstring = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
	tstring += splitstring[i];
	return tstring;
}
String.prototype.stripSpaces = function( ){ return this.replace( /\s/g, "" ); };