﻿function timestamp_class(this_current_time, this_start_time, this_end_time, this_time_difference) { 
    this.this_current_time = this_current_time;
    this.this_start_time = this_start_time;
    this.this_local_start_time = this_start_time;
    this.this_end_time = this_end_time;
    this.this_local_end_time = this_end_time;
    this.this_time_difference = this_time_difference;
    this.this_local_time_difference = this_time_difference;
    this.GetCurrentTime = GetCurrentTime;
    this.StartTiming = StartTiming;
    this.StartLocalTiming = StartLocalTiming;
    this.GetElapsedTime = GetElapsedTime;
    this.GetLocalElapsedTime = GetLocalElapsedTime;
    this.Order = 0;
}

//Get current time from date timestamp
function GetCurrentTime() {
    var my_current_timestamp;
    my_current_timestamp = new Date();		//stamp current date & time
    return my_current_timestamp.getTime();
}

//Stamp current time as start time and reset display textbox
function StartTiming() {
    this.this_start_time = GetCurrentTime();	//stamp current time
}

function StartLocalTiming() {
    this.this_local_start_time = GetCurrentTime();	//stamp current time
}

//Stamp current time as stop time, compute elapsed time difference and display in textbox
function GetElapsedTime() {
    this.this_end_time = GetCurrentTime();		//stamp current time
    this.this_time_difference = (this.this_end_time - this.this_start_time) / 1000;	//compute elapsed time
    return this.this_time_difference;
}

function GetLocalElapsedTime() {
    this.this_local_end_time = GetCurrentTime();		//stamp current time
    this.this_local_time_difference = (this.this_local_end_time - this.this_local_start_time) / 1000;	//compute elapsed time
    return this.this_local_time_difference;
}

var time_object = new timestamp_class(0, 0, 0, 0);	//create new time object and initialize it

time_object.StartTiming();

var info = '';

info += 'INICIO;;0;0|';

function SaveElapsedTime(field, elapsedTime, value){
    time_object.Order += 1;
    info += field + ';' + value + ';' + elapsedTime + ';' + time_object.Order + '|';
}

function SendInfo(host, sessionId, page){

    info += 'FIN;;' + time_object.GetElapsedTime() + ';0';
    
    var UrlGetData2 = '/WS/OLAP.asmx/Form_Behaviour_Track';
    var pars2 = 'HTTP_HOST=' + host + '&SessionId=' + sessionId + '&Page=' + page + '&Info=' + info;
    var myAjax2 = new Ajax.Request(UrlGetData2, {method: 'get', parameters: pars2});
}

