
var _ep = {} ;

// tracking data

_ep.pid = '' ; // product id                   string
_ep.mid = '' ; // merchant id                string
_ep.eid = '' ; // engine id                    string
_ep.click = 1 ; // this is a click            bool

//  for eperfectdata.com
_ep.cc		= '' ;			// campaign code		string
_ep.mc		= '' ;			// member code		string
_ep.event	= '' ;
//

_ep.order_number = '' ;
_ep.order_value = 0 ;
_ep.order_qty = 0 ;
_ep.order_details = '' ;
_ep.order_details_qty = '' ;
_ep.order_details_price = '' ;
_ep.order_details_1 = '' ;
_ep.order_details_2 = '' ;
_ep.clientId = 55 ;
_ep.client_code= 'K1TQSP' ;


_ep.url= location.href ;  // url                                          string

_ep.title = document.title ;           // title of the page                       string

// settings
_ep.timeout       = 15768000 ;                 // timeout for tracking in seconds (6 months)        int
_ep.debug         = 0 ;                             // whether to show debug output  bool
_ep.type            = 'gif' ;                           // output type (gif|js)

// constants
_ep.TRACKERURL	= 'www.plumbworldemails.co.uk/tracker' ;	// url of tracker, without schema


// track method

_ep.track = function()
{

			var orderNo = escape(this.order_number) ;


			if( orderNo == null || trim(orderNo) == '' ) {
				

			} else if (orderNo) {
			
					this.event = 'ordercompleted' ;

			} 

            if(this.debug) this.type = 'js' ;
			
				
			var url = ((location.protocol == 'https:') ? 'https://' : 'http://')
				+ this.TRACKERURL + '?'
				+ 'click=' + parseInt(this.click) + '&'
				+ 'event=' + escape(this.event) + '&'
				+ 'orderno=' + escape(this.order_number) + '&'
				+ 'clientId=' + parseInt(this.clientId) + '&'
				+ 'client_code=' + escape(this.client_code) + '&'
				+ 'qty=' + escape(this.order_qty) + '&'
				+ 'value= ' + parseFloat(this.order_value).toFixed(2) + '&'
				+ 'details=' + escape(this.order_details) + '&'
				+ 'details_qty=' + escape(this.order_details_qty) + '&'
				+ 'details_price=' + escape(this.order_details_price) + '&'
				+ 'details_1=' + escape(this.order_details_1) + '&'						
				+ 'details_2=' + escape(this.order_details_2) + '&'
				+ 'url=' + escape(this.url) + '&'
				+ 'title=' + escape(this.title) + '&'
				+ 'type=' + ((this.debug) ? 'js' : 'gif') + '&'
				+ 'debug=' + ((this.debug) ? 1 : 0) + '&'
				;
			
			switch(this.type){
			
				// handle js with script tag, for debugging
				case 'js' :
					var h ='<script type="text/javascript" src="' + url + '"></scr' + 'ipt>' ;
					document.write(h) ;
					//alert(h);
					break ;
					
				// handle all others with new Image()
				case 'gif' :
				case 'xml' :
				case 'txt' :
				default :
					var i = new Image(1, 1) ;
					i.src = url ;			
					i.onload = function(){ return ; }
		
			}
				

            return true ;
			

}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

