// JavaScript Document


var leaving = 0;
function onleave(){
	if (leaving == 0){
		alert('LP leave');
		callServer("track1.php");
	}
}
function Trans(url){
	leaving = 1;
	window.open("index1.php?"+url,"_self");
}


var trans = 0;
var OptIn = 0;
// the following codes executes on load completion of the landing page
<!-- Get the entry time -->
var lStartTimer = new Date();	<!-- get the time this file was loaded-->
var lStartTime = lStartTimer.getTime();<!-- convert it to .000seconds -->

if (IsFrame())	{		// if there is a frame currently up, this is reentry situation. 
	// there is a frame up and so there is a Tracer Record. Update it and let 
	// let FrameHeader handle the write on exit
	parent.FrameHeader.Tracer(Src);
}

function TagOptIn(){
	OptIn = 1;
	return true;
}
function IsFrame(){
	if (top.length <2) return false;
	return true;
}
function leave1() { //record an earily departure
	if (trans==0){	// trans is 0, Transfer() was not executed, so capture the information now
		if (!IsFrame())	{		// if there is no frame currently up, this is a first entry situation. 
			//if there was no transfer to another odorxit window write exit note
			var dwell = GetDwellTime(); //Capture how log we were on the landing page
	 		callServer("track.php?0x,"+OptIn+",!"+Src+","+dwell+","+OptIn+","+Referer());
		}
	}
	return;
}

function GetDwellTime() { 	// record the dwell time on this page
	var lTimer = new Date();	<!-- get the current time -->
	var lTime = lTimer.getTime();<!-- convert it to .000seconds -->
	var i = 0;			// use the local times for dwell
	if (!IsFrame())	{	// if there is no frame currently up
		i = parseInt((lTime-lStartTime)/1000);
	}
	else {
		i = parseInt((lTime-gTime)/1000);	
		gTime = lTime;
	}
	if (i==0 || isNaN(i)) i=1;
	return i;		<!-- get the time in this file -->
}

// Transfer is to be called only from Landing Pages to enter the frames world.
// name = the switch index name of the window to display first when the frame comes up
// src = the Src tag from the landing page that called this function.
function Transfer(name,src){
var lUrl = "";
	trans = 1;					// stop leave1() from writing to disk
	if (!IsFrame())	{		// if there is no frame currently up, this is a first entry situation. 
		var dwell = GetDwellTime();		// figure out how long they were on the landing page
		lUrl = "./index.php?"+name+"-"+src+","+dwell+","+OptIn+","+Referer();
		window.open(lUrl,"_self"); //Request the Named page
	}
	else {	// else just add the trace info
		parent.FrameHeader.Tracer(src);
		parent.FrameHeader.gTime = lStartTime;
		window.open("./FrameIndexMain.html?"+name,"FrameIndex");
	}
}
// try to figure out who referred the link
function Referer() {
var SE=new  Array("abcsearch","aol","ask","dogpile","earthlink","findwhat","google","hithopper","homeexpo","hotbot","lycos","mamma","msn","mysearch","netscape","overture","searchtopper","sullivan","yahoo");
var lhref = top.document.location.href; // include the referrer get the URL call to the exiting page
	i = lhref.indexOf("?"); // See if referrer had an ID on it
	if ( i > -1){	// if there was an id tag fetch it and replace Unk
		return lhref.substring(i,i+5); //Get the ID
	}
	// if there is no ? see if there is some referer declared in the call string

	var from = document.referrer.toLowerCase();
	for (var x = 0 ; x < SE.length; x++) {
		if (from.indexOf(SE[x]) > -1) { 
			return SE[x].substring(0,3); 
		}
	}
	return "ukn";
}

// display a 500 px wide 400 px high table file in a seperate window.  Must spedify the file name and extension
function popWindow(theURL) {
var lUrl = "/PU/"+theURL+".htm";
//alert(lUrl);
newWindow = window.open(lUrl,"popWindow","dependent=yes, toolbar=no,menubar=no,resizable=no,scrollbars=yes,status=no,location=no,width=510px,height=400px");
newWindow.focus();
}



