var global_clicked_on;
var global_target_page;
var current_win_location = window.location.href;
current_win_location = current_win_location.replace(/&/g, 'ANNDD');

var screen_res = screen.width+' x '+screen.height;
var color_depth = window.screen.colorDepth;

var java_enabled;
if (navigator.javaEnabled() < 1) java_enabled="No";
if (navigator.javaEnabled() == 1) java_enabled="Yes";


var referrer_page = document.referrer;
referrer_page = referrer_page.replace(/&/g, 'ANNDD');
// Create xmlHttp Request for AJAX update
var xmlHttp;
function xml_connection() {

      
  try
  {    // Firefox, Opera 8.0+, Safari    
  xmlHttp=new XMLHttpRequest();    
  }
  catch (e)
    {
    try
      {     
       xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
       }
   catch (e)
      {      
      try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
      }
        catch (e)
        {
        alert("Your browser does not support AJAX!");        
        return false;        
        }
      }    
    }

}
//END creating AJAX xmlHttp request component

//visitor info. functions

//end visitor info. functions

// creating an AJAX function to send request to server

function ajaxFunction(str,clicked_on,target_page) {
	
xml_connection();
xmlHttp.onreadystatechange=function()
      {
if(xmlHttp.readyState==4)
        {
        //document.myForm.time.value=xmlHttp.responseText;
        //document.getElementById('yestext').innerHTML=xmlHttp.responseText/2;
        }
}

	target_page = target_page.replace(/&/g, 'ANNDD');
	clicked_on = clicked_on.replace(/&/g, 'ANNDD');
	
	
var url="/ct.php";
url=url+"?current_page="+current_win_location+"&referrer="+referrer_page+"&screen_res="+screen_res+"&color_depth="+color_depth+"&java_enabled="+java_enabled+"&tagname="+str+"&clicked_on="+clicked_on+"&target_page="+target_page;

    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);  
    }
//END creating ajaxFunction
	


function GetParentNodeWithTagName(objNode, strTagName ){

			strTagName = strTagName.toLowerCase();

			for ( 
				objNode = objNode.parentNode ; 
				(
					objNode && (			
						(objNode.tagName && (objNode.tagName.toLowerCase() != strTagName)) ||
						(!objNode.tagName && (objNode.nodeType != 3)) 
					)
				);
				objNode = objNode.parentNode
				){

			}
		
			return( objNode );
		}
function FindParent( objNode, strTagName, attrib ){
			var objParent = GetParentNodeWithTagName( objNode, strTagName );
	
			if (objParent != null){
		
 if(objNode.tagName == 'A'){
			
global_clicked_on = objNode.innerHTML;

global_target_page = objNode.getAttribute(attrib);
			
			ajaxFunction(objNode.tagName,global_clicked_on,global_target_page);
			
}else if(objNode.tagName == 'IMG'){
			
global_clicked_on = objParent.innerHTML;

global_target_page = objParent.getAttribute(attrib);
			
ajaxFunction(objNode.tagName,global_clicked_on,global_target_page);
			
}
else{

global_clicked_on = objParent.innerHTML;

global_target_page = objParent.getAttribute(attrib);

//alert(global_clicked_on);
//alert(global_target_page);
ajaxFunction(objNode.tagName,global_clicked_on,global_target_page);
			

			} 
			}else{

			}
		
		}		
	
		
		
		
		
if (window.captureEvents){
window.captureEvents(Event.CLICK);
window.onclick=sourceCheck;
}
else
document.onclick=sourceCheck;

function sourceCheck(e){
var el=(typeof event!=='undefined')? event.srcElement : e.target


if(el.tagName=="IMG" || el.tagName=="img"){
// Link is on Image following will be executed
//alert(el.alt+ " ("+el.src+ ")");
FindParent(el, 'a', 'href');


//else the following will be excuted to check wheather its an INPUT
}else if((el.tagName=="INPUT" || el.tagName=="input") && (el.type=='button' || el.type=='submit') ){
// if INPUT the following will be executed
if(el.type== "submit"){
// form element will be submit button then following will be executed
global_clicked_on = el.value;
global_target_page = getFormAction(el);
ajaxFunction('Submit',global_clicked_on,global_target_page);
//alert(getFormAction(el));
}
// and then the following too for all form elements
global_clicked_on = el.value;
global_target_page = 'script';
ajaxFunction('Form Button',global_clicked_on,global_target_page);

}else if(el.tagName=="AREA" || el.tagName=="area"){
//if the element is AREA using map then the following will be executed
//alert(el.alt+ " ("+el.href+ ")");

global_clicked_on = el.alt;
global_target_page = el.href;
ajaxFunction('AREA',global_clicked_on,global_target_page);

}else if(el.tagName=="A" || el.tagName=="a"){
//if the element is AREA using map then the following will be executed
//alert(el.alt+ " ("+el.href+ ")");

global_clicked_on = el.innerHTML;
global_target_page = el.href;
ajaxFunction('A',global_clicked_on,global_target_page);


}else{
FindParent(el, 'a', 'href');

}

// this } is end of Function sourCheck
}

getFormAction = function(elt) {
		target = null;
		parentElt = elt.parentNode;
		if( parentElt.nodeType == 1 ) {
			if( parentElt.tagName == 'FORM' ) {
				target = parentElt.getAttribute('action');
			}else {
				target = getFormAction( elt.parentNode );
			}
		}else {
			target = getFormAction( elt.parentNode );
		}
		return target;
	}
	
	