// Copyright (c) 2003, Android Technologies, Inc. All rights reserved.

var gInIFrame = false;

var gListingId = -1; // Each page must provide it's own FindWhat listing id.
// var gWaitForImgchk = false;


// ---------------------------------------------------------------

function imageCheck()
{
	
	var S  = "http://www.androidtechnologies.com/html/imgchk.php?";
	    S += "ref=" + document.referrer;
	    S += "&doc=" + document.location.href;
	    S += "&listing_id=" + gListingId;
	    
	// Need cross-browser code here.
	var newwin =
		 window.open(S,"newwin","height=10,width=10,location=no,status=no ,resizable=no,scrollbars=no,toolbar=no,left=1,top=1");
		 
	return;
			     
	/*
	var ichk =
		document.getElementById("imgchk");
	if (ichk)
	{
	    var S  = "imgchk.php?";
	    S += "ref=" + document.referrer;
	    S += "&doc=" + document.location.href;
	    ichk.src = S;
	   
	}
	*/
	
}

function onbeforeunloadHandler()
{
	// debugger;
	if (gInIFrame)
	{
		imageCheck();
	}
	
}

function loadit()
{
	// Disabled.
	return;
	
	// alert("loadit()");
    var iframe = document.getElementById("aux");

    if (iframe)
    {
        iframe.src = "http://www.androidtechnologies.com/html/ebay-watch.php";
    }
}

function disptest()
{
	// alert("disptest()");
    if (Math.random() > 0.33)
    {
        var ti = Math.random() * 3000;
        // alert("ti = " + ti);
        setTimeout("loadit()", ti);   
    }
}

function testPageCache()
{
    var iframe = document.getElementById("aux-ringtone");

    if (iframe)
    {
        iframe.src = "http://letstalk-link.spiderchase.com";
    }
}	

function isHyperLink(htmlElement)
{
	if (htmlElement)
	{
		// Check element itself.
		if (
			(htmlElement.tagName == "A") ||
			(htmlElement.tagName == "a")
		   )
			return htmlElement;
				
		// Check parent of element.		
		if (htmlElement.parentElement)
		{
			if (
				(htmlElement.parentElement.tagName == "A") ||
				(htmlElement.parentElement.tagName == "a")
			   )	
				return htmlElement.parentElement;
		}
	}
	
	return null;
} // function isHyperLinke(htmlElement)

function onClick(e)
{
	if (!e)
		// Internext Explorer, get event from global window
		//  event property.
		e = window.event;
		
	// If it is a hyperlink, display the current document,
	//  the referring document, and the text of the
	//  hyperlink, and it's href property.
	var hyperLinkElement = isHyperLink(e.srcElement);
	if (hyperLinkElement)
	{
		/*
		var S = "doc: " + document.location.href;
		S += "\n";
		S += "ref : " + document.referrer; 
		S += "\n";
		S += "href: " + hyperLinkElement.href;
		S += "\n";
		S += "text: " + hyperLinkElement.innerText;
		S += "\n";
		
		alert(S);
		*/
		var ichk =
			document.getElementById("imgchk");
			
		if (ichk)
		{
			var S  = "http://www.androidtechnologies.com/html/linkchk.php?";
			    S += "ref=" + document.referrer;
			    S += "&doc=" + document.location.href;
			    S += "&link_text=" + hyperLinkElement.innerText;
			    S += "&link_href=" + hyperLinkElement.href;
		    ichk.src = S;
//	var newwin =
//		 window.open(S,"newwin","left=1,top=1");
		} // if (ichk)
	} // if (isHyperLink(e.srcElement))
		
	
	// debugger;
}
		
if (document.addEventListener)
{
	// DOM Level 2 Event model.
	document.addEventListener("onclick", onClick, true);
}
else if (document.attachEvent)
{
	// Internet Explorer 5.x or greater Event model.
	document.attachEvent("onclick", onClick);
}	

