﻿/*!
 * NSIST link click tracker
 *
 * Copyright (c) 2009 Jason Lu
 *
 * Date: 2009-11-06 11:00 +0800
 * Revision: 0
 */
 
var $jq = jQuery.noConflict(); 
jQuery(document).ready(function(e){
	jQuery('table table a').click(track);
	
});

function track(e)
{
	//alert('go');
	region=nsistTracker_region;
	country=nsistTracker_country;
	host=location.host;
	
	var d = new Date();
	time=d.getTime();
	linkText=$jq(this).html();
	/*
	if(linkText.indexOf('<img')!=-1)
	{
		linkText.substr(6,4);
		linkText=host+"JavaScript Code: "+val;
	}
	*/	
	linkHREF=$jq(this).attr('href');
	
	//alert(region+","+country+","+linkHREF+","+linkText+","+nsistURL);
	// I use sha1 hash to make a check code and pass the original seed(which is a time serial) to PHP
	// PHP do the same calculate to the seed, if the result is equal, then pass the exam.
	var parameter={'checkCode': sha1Hash(time),'time':time,'linkText':encodeURIComponent(linkText),'linkHREF':encodeURIComponent(linkHREF),'region':region, 'country':country};
	//jQuery.get(url, parameter);
	jQuery.ajax({
		'url': nsistURL,
		'dataType': 'jsonp',
		'data': parameter,
		'jsonp': 'processData',
		'error': function(xhr) {
			alert('Ajax request 發生錯誤');
		}
	});
	
}

function processData(data)
{
}